From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id ABDD045FFF; Mon, 6 Jan 2025 12:34:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AB5C64067C; Mon, 6 Jan 2025 12:34:53 +0100 (CET) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.14]) by mails.dpdk.org (Postfix) with ESMTP id F14B24014F for ; Mon, 6 Jan 2025 12:34:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1736163292; x=1767699292; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=Hbw/KA20rY5CJ6zTTFtpeMmlgl/X4enu1Zn4GxK8yHU=; b=AD0REIulWQbYvSCLcRVLHruC9xOzYp4mjOR6UG+YtFyh1pqwA5mrA1XC OWLYTMtcmwqLtr69vJbOacfy4TcH1AuQILxno9kY6/U2g0yiYL5xGm7kv J41goq9q7bfG7Jx1fUo/SJOdhXfATe0db/tFqZbuh7ZYvGTpl/ckFDnu5 6xfTiD6y2bRgV1QdgytVG3JSCB+/kMWLEgRsmGRUe9UxAyfd4xNIxWJ6A 1VOyHSY8NU43E2mnaXheCPpzzpvQq4Xudoq5cyr0V4ED6AGTZ/en7CJYq UXDLViTOIZ/30Md0X6ftzUTsYiNejF5bJTKNHsLj6ehR8gn+zEa1UJmDn Q==; X-CSE-ConnectionGUID: 2W/YR0vNTUKBHbAreQPaWA== X-CSE-MsgGUID: TNdt8pPhTfi/tzCJMrVjVg== X-IronPort-AV: E=McAfee;i="6700,10204,11307"; a="40079043" X-IronPort-AV: E=Sophos;i="6.12,292,1728975600"; d="scan'208";a="40079043" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Jan 2025 03:34:51 -0800 X-CSE-ConnectionGUID: 6VUqg6i5RyO64CaujbjrSw== X-CSE-MsgGUID: 1HMRvMlXRU2+NkaWe5aZNQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,224,1728975600"; d="scan'208";a="139762182" Received: from orsmsx603.amr.corp.intel.com ([10.22.229.16]) by orviesa001.jf.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 06 Jan 2025 03:34:51 -0800 Received: from orsmsx601.amr.corp.intel.com (10.22.229.14) by ORSMSX603.amr.corp.intel.com (10.22.229.16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44; Mon, 6 Jan 2025 03:34:50 -0800 Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.44 via Frontend Transport; Mon, 6 Jan 2025 03:34:50 -0800 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (104.47.55.174) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.44; Mon, 6 Jan 2025 03:34:49 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=fwbhY6/2rteLv7nT5dljMjwGFvxyw4mym5E4NS9t3JyBrImdTX6s5S3TR8wJ8ZrsWQVH9J/+vGAxOZLUGsK/w5rMofjjXNT/q3aCp8VejEgQ2YQPi20gGTszKwVNVd5SbDWZw/5I+ytJ8Mu3z9G1PUrpOY34M8+g+R2ToqX7E1obue+yPbZrKJ2ruios/vXzvs5H1eR25hC5Lw3RLNZ8XmHrpZr0IONS5JNncOqTqztIVAUTppYZNIRh60hNgmNVPNVEXYwdEU50PU1QWOG4Ns3zjWOdkCKnUfzzJ6h3NIXvkvWdAGLPNvwa8EZWUEDHZM4RMhWKaGef0qvUL23LSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=l7J1DgXn8V4T4LR2A6LoUhkzlE2N5NJBFtScxqi9Hzo=; b=wGq/H3qqF/aC2YNrqoidfq2kbXP2OdlZTUK69+PZsixZ4dUz1ltHEw/jHNaFK3kiQ0uyxbA4m7szj9ta6xdLCLLY3wyjRicg/F4RiiqskUc8edfWKJp8GNNG3WBXFhdMnt1tWKSI500ValMmqqffpsuQl+L/ohoVKfBNoF1g1cyhtqp3SYf0bzeRdCSUS0ekYokeOm7QxHQDGbGM43fVX+6HhuKT+gr8FgLqTPxmm0SdEa7bRXBnYKnZippV5/fR9UvR8ifj6o6RKj7gLRAIgeMHvfQW3m7WYA3V2+09x5oEuPnPOvz3GWJudpPKxKr7cBwpuEciYksM0RHftPSq4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) by SA2PR11MB5083.namprd11.prod.outlook.com (2603:10b6:806:11b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8314.13; Mon, 6 Jan 2025 11:34:25 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::f120:cc1f:d78d:ae9b%5]) with mapi id 15.20.8314.015; Mon, 6 Jan 2025 11:34:24 +0000 Date: Mon, 6 Jan 2025 11:34:18 +0000 From: Bruce Richardson To: Morten =?iso-8859-1?Q?Br=F8rup?= CC: Andre Muezerie , Subject: Re: [PATCH v2 2/5] lib/eal: add portable version of __builtin_add_overflow Message-ID: References: <1735857169-19131-1-git-send-email-andremue@linux.microsoft.com> <1735936781-24199-1-git-send-email-andremue@linux.microsoft.com> <1735936781-24199-3-git-send-email-andremue@linux.microsoft.com> <98CBD80474FA8B44BF855DF32C47DC35E9F995@smartserver.smartshare.dk> Content-Type: text/plain; charset="iso-8859-1" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <98CBD80474FA8B44BF855DF32C47DC35E9F995@smartserver.smartshare.dk> X-ClientProxiedBy: DUZPR01CA0287.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b7::29) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|SA2PR11MB5083:EE_ X-MS-Office365-Filtering-Correlation-Id: de6d3072-4eb8-4e67-5c6f-08dd2e461217 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|376014|1800799024; X-Microsoft-Antispam-Message-Info: =?iso-8859-1?Q?+hxw5UErAJygKjoJs5aKdiXpHr9v5tWwe0DThhGSmD4kfMExTvBxu0ZfPQ?= =?iso-8859-1?Q?0MG9AgYV/BLbUWiWMlCOXjiTGqbruKt2iwqguA65sMkVmTlcH2T//MJ1or?= =?iso-8859-1?Q?XTLV+0kKx7dcovfgtjDBNYV4/qlnpbsmSK4TPc23is4lvORlhkUrD4Bb2l?= =?iso-8859-1?Q?o4X89KZzr/hO7bCzPAsBPQTEQvTW2KhkDTEp3qRhnXwnuv66QaSagJlQwu?= =?iso-8859-1?Q?y2uRUv4VkTG2urllbrURj1l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= =?iso-8859-1?Q?HRS3cZe0kPj8IW0DbhGOmo4HcTfb7iauBu3zC31KmKOuoP+QSczSNiCTQS?= =?iso-8859-1?Q?l9gzXYJ5w4ta820IomOl0e2v1DzMB2PzVR8LLAz3U9075POoMFH8janyUL?= =?iso-8859-1?Q?EZdS0IIsizU/0EKkdoZh3UaK3G6nltGxF99Blx8cMeMG+14lSL6iQkpXmK?= =?iso-8859-1?Q?VM0roHJMEqLel1+8lmYY/sX0MtrGJYOh0l1ZMGOx/YZeqR0qEqQAaIYe7O?= =?iso-8859-1?Q?WNxG959w8HL/Bs/9t5r0tSffHaU6E+fY47yz1rX8GFm+TtvzHy1ej8pSXG?= =?iso-8859-1?Q?omBoFmvLphoADfF6?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DS0PR11MB7309.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(376014)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?iso-8859-1?Q?tzh+mhbuME+BgbLvzoXsZbT6TtTVTp5bv4+hFdbQPuUYBs9auVT58NDVfB?= =?iso-8859-1?Q?iHJ8q3CMRFDeUL2UF9CZmL7zVemyRI4T5DoEB/R5lczktyO6IiwEUyAGTv?= =?iso-8859-1?Q?t2rzqCW1aOMNJc2v1ksEs6r114TQ3hBZ2jx7Q9LtcgONqy560VzNmPNtKw?= =?iso-8859-1?Q?LIR9b1GHfGDqBBQ+IVIJjUC6RK2lvawLPmQJxUVlIfQ+IRxpVHX6KkZQSx?= =?iso-8859-1?Q?TevnwVvy7p+Pu50tEN0eu0JSQDtSBhKSV+SlQEEP9CrElGRkaoYqEnO9Hm?= =?iso-8859-1?Q?kc7kjjw/o9PEY+EANRuUxatxbC/enhZS6iLAHy2D5oU7SROslUZaUW26dr?= =?iso-8859-1?Q?F9/XbBya03x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8859-1?Q?KP7Pa3e6jWV9kyCpM/z5YrCuReEtgl7PvwVuUBtmEK1wK3qO2DoSD0pDBQ?= =?iso-8859-1?Q?sR44H/b49PgHq16iWYApCXO4Esr5Q2tjXkr0LfnX+Cn7rjm4M6fd4FYewc?= =?iso-8859-1?Q?CgydRZ/GTr506tagz533ViB4GDD1n0PgbfPJVb7FNVPbCWFbmsOcyRvcn1?= =?iso-8859-1?Q?n1S3hPwIRHzRe75fwTfpW0uPmBwicpi/TZ3klhbHoqRHeg+U4NAix09uRR?= =?iso-8859-1?Q?TJHSFBLpMezGfOcNzYn7ONKLW+c3PDXRbonO3Z+OTxOubQ4qziQKTDkkeR?= =?iso-8859-1?Q?x5v6axKtMC1rrZaPX7uJN/ZX2r3XHxfZ3LTAIHy3VHnoEe+9PgRCjZycex?= =?iso-8859-1?Q?Q5/PlbwNpwh2WLwSKtt+AnO52Dj2FMywOFz7qvly5Wc30YNpgsZytxhg?= =?iso-8859-1?Q?=3D=3D?= X-MS-Exchange-CrossTenant-Network-Message-Id: de6d3072-4eb8-4e67-5c6f-08dd2e461217 X-MS-Exchange-CrossTenant-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jan 2025 11:34:24.3941 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GfhLjh1W7LxVGVEGpq4VmgijMI80DfChEMJQkCBBHuD7swc0iXPGAUSVUqFgbH+5Y1xe6PfeZTmmFiNXvoRb/K82YFM5ZsfvBBnNu3iD2+Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR11MB5083 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Mon, Jan 06, 2025 at 12:21:39PM +0100, Morten Brørup wrote: > > From: Bruce Richardson [mailto:bruce.richardson@intel.com] > > Sent: Monday, 6 January 2025 12.07 > > > > On Fri, Jan 03, 2025 at 12:39:38PM -0800, Andre Muezerie wrote: > > > __builtin_add_overflow is gcc specific. There's a need for a portable > > > version that can also be used with other compilers. > > > > > > This patch introduces rte_add_overflow. > > > > > > +/* > > > + * Function that allows performing simple arithmetic operations > > together with > > > + * checking whether the operation overflowed. > > > + * Example of usage: > > > + * uint8_t overflow; > > > + * uint16_t a, b, result; > > > + * a = 1; > > > + * b = 2; > > > + * overflow = rte_add_overflow(a, b, &result); > > > + */ > > > +#ifdef RTE_TOOLCHAIN_MSVC > > > +#define rte_add_overflow(a, b, res) _Generic((a), \ > > > + uint8_t : _addcarry_u8, \ > > > + uint16_t : _addcarry_u16, \ > > > + uint32_t : _addcarry_u32, \ > > > + uint64_t : _addcarry_u64)(0, a, b, res) > > > +#else > > > +#define rte_add_overflow(a, b, res) _Generic((a), \ > > > + uint8_t : __builtin_add_overflow, \ > > > + uint16_t : __builtin_add_overflow, \ > > > + uint32_t : __builtin_add_overflow, \ > > > + uint64_t : __builtin_add_overflow)(a, b, res) > > > +#endif > > > > For the gcc version, can you just simplify to the one-line below? > > > > #define rte_add_overflow __builtin_add_overflow > > Yes, but then GCC compilation would not fail if "a" has some other type than the four types explicitly supported. > I prefer keeping the method used this v2 patch. > Is that really a problem? Should our DPDK macro not support all the types that the GCC builtin supports? /Bruce