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 2A5FB4300F; Tue, 8 Aug 2023 20:23:54 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 00E6B41148; Tue, 8 Aug 2023 20:23:54 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by mails.dpdk.org (Postfix) with ESMTP id F0720410E6; Tue, 8 Aug 2023 20:23:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691519032; x=1723055032; h=date:from:to:cc:subject:message-id:references: content-transfer-encoding:in-reply-to:mime-version; bh=6vPUirede5XFpaV1b5DOisMUC1l0b1VswuFjrbUQpRc=; b=mKUrErIQmR+tHm/JZNMK2EvO+ppDkUJi+6zPU58BHYfyKeDHUrcTWOHq CYDqe3OQ9n96XJBqDMoaUWmVRf6pIrXmaDm+Z3Wi4UviD3IqCrDK+b2MX 7nfXiLdeM395tQLhgaYM1N5bMSjSazq1dU+6FzzrCnewC/RJHPwmawyKY dXcQPyPvC7ZLraLnn0IpUbaOwg5Zi9v0AXYau4CzyN+DCj2v0h3o+1MpX sV4TaPcistJaIE8zlEGe22aO2mRCwV5F3/38sNgyo6eF7K3iY7AVjUiTT kV1WwB9oYU+BlKkyg37CDg3ZcRDxY2687d5w2wS0Qjt8FygyknzGcyMAo g==; X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="368368213" X-IronPort-AV: E=Sophos;i="6.01,157,1684825200"; d="scan'208";a="368368213" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Aug 2023 11:23:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10795"; a="761018485" X-IronPort-AV: E=Sophos;i="6.01,157,1684825200"; d="scan'208";a="761018485" Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by orsmga008.jf.intel.com with ESMTP; 08 Aug 2023 11:23:49 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) 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.27; Tue, 8 Aug 2023 11:23:49 -0700 Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 8 Aug 2023 11:23:49 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27 via Frontend Transport; Tue, 8 Aug 2023 11:23:49 -0700 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (104.47.57.175) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.27; Tue, 8 Aug 2023 11:23:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RYQ5XK+fDT50yrDbu9SPiQub4zxJibkJkfUC1jFEU46mq1UaNaqyj86cL4oprdDQDFR3hUlVxDK8BhmBevwtoFxGva33ZEQaQ1DLsEF2XofGmtW3ned7I7E2r3zUoNp+TWHWUI49eAUnFrZVPFbF1r42dnyrMUnYWSw7nrcJ3dpGEkZsyTlOcmLQOx2cRvHfrXHnYK7v5BbOFeZaoybYNJFXH6bf4vDIIUhV0oeqpXy1UggCpbV3jGUGoLNPOBcvpsga2ths4FYJnHizFrouq5Mm0HvvftQd877Rjxcwng1sVvWI0LSSddN2aIHPnN7Q4sonfvi2SRgbJPwlaZjWmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=9VO4fxiPeK7aVU83TDtpmwHQKCaaxjEGVSVTET2UmQI=; b=ajWuabL1zQlvQ+uguSs347di50KhOaRFfWO/A9qtodRVcOtWhRFiw5RXvFAw+XzZXo7WGDk325UONgzni7UVy4r99uRDjR7B2h/j2OmR4i80FJOqL5qSeNLX5VuY+Hd5uHGcbYi1WoUJnC3rO10t+3LfOPtnbg1t9lqehY6gHEDAX9N6avwY0lNPZIIk2EJDxfzEENWwyo+oL+oll+cDfzM8kvZFHbj5Fj0R+MaLRzSBG0+VnUcxdxQCIGZE5/groVW6/F0rOnHK2CmcRZ491bRKaOaptsUmNCQpVi/ozXvmrKkNhZRc4IQaeaKX77+uLsRTNjGZNYFL+iXgBUdv8g== 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 CH3PR11MB8752.namprd11.prod.outlook.com (2603:10b6:610:1c2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.27; Tue, 8 Aug 2023 18:23:47 +0000 Received: from DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::9802:65f0:c441:780f]) by DS0PR11MB7309.namprd11.prod.outlook.com ([fe80::9802:65f0:c441:780f%7]) with mapi id 15.20.6652.026; Tue, 8 Aug 2023 18:23:47 +0000 Date: Tue, 8 Aug 2023 19:23:41 +0100 From: Bruce Richardson To: Tyler Retzlaff CC: , , , , , Subject: Re: C11 atomics adoption blocked Message-ID: References: <20230808175303.GA11006@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20230808175303.GA11006@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> X-ClientProxiedBy: DB3PR06CA0032.eurprd06.prod.outlook.com (2603:10a6:8:1::45) To DS0PR11MB7309.namprd11.prod.outlook.com (2603:10b6:8:13e::17) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS0PR11MB7309:EE_|CH3PR11MB8752:EE_ X-MS-Office365-Filtering-Correlation-Id: 3bffe30e-775a-4b60-aab1-08db983c9b3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: p3icm6nyHcb/gBmqNCGe244v5TLhqj/yigxeaL0drb3STdKL5tm2c8VxBwuBV2aYx3V05+2zTEBqPjoWBOr+AgaXtyaHkl8JCvJzXpFEkk/PuKiSDvPyIubpAFV8DRDbSeZ8P11h3GvikFHBA1DziYe5cYvE6jcCztdvlAPObQjYANWDoeJYNd/JjbpUt43j2A1QYyZS+FJJe9xJbWzulEAmB4RgvSrKK+8CUwOvPA3cTjXYvxEKVawkgbo/E+y6tMUyU/LuTSbPUHvPY3Cu7hiruqlHvzom5PaGhIHDYbcbapGuxIPUuEEPVeC154O72LlqPKib5fqyKZEd0wx3j9YSPJlEn9zKN5iN/DYv+mG9theVHAMtVnZHRn6+hGV/im3YHeXbi3ev2TmqRndxjIymHhzW/rMRSjnJbFLIFPHpShiguJhtf558AUt4MK+9oDLbnyCYX4c8j7aUsIw3P56MGtrWgWRYTPj+A+hs+RwYdcYPVIXbmscEiQ9ba//1ySGAtQkmeR+qIM16sl7X9/npXpJblC3hD+u2X2S8DZo0mu5LpmH8EDOJnyNW1kg5GMjO5qM4kP0jZnj5DpZZe0geKy+ZFwsynB36COADBEA= 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:(13230028)(39860400002)(366004)(136003)(396003)(376002)(346002)(451199021)(1800799003)(186006)(44832011)(8676002)(8936002)(41300700001)(6916009)(4326008)(66899021)(5660300002)(316002)(83380400001)(86362001)(2906002)(6512007)(6666004)(966005)(6486002)(6506007)(26005)(66476007)(66556008)(66946007)(478600001)(82960400001)(38100700002)(21314003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?UzVKNnFTT3VSbWlPMndOYVBDNTNmZUFlZUkxM08vT0QxQ0NkTEdpbElmY1RF?= =?utf-8?B?aWJHSXRUTFNjelh6bGowM1g4TWFCL0I5ZzJlK1hMa2NUZVNxZHk2NEhBVjRQ?= =?utf-8?B?STBuckFWRWl4WWRjN01xNHJqWVRsUU1yRkFRZ3MrTzQxMWxIY3RRdCt3ZVB4?= =?utf-8?B?VGpqS3VpUzlEYnpnVHJXZGk5c3d3MTU3YTNIVFBwMlRxdVBYajg4cEFvSG5p?= =?utf-8?B?TWZtZUJ3WDhoOG9NU1lFekxjM2NFU1R2YUFDbzFOUlRrVmtWNWpzbXJPZDFw?= =?utf-8?B?ZmNCUlNHc3VmcVN0M2dPOENQcHlrb292czRxc0J1aE5ISm5mbXFVTTdhMHR5?= =?utf-8?B?VEVVeFdTelBZNk42YnRjUUVqaDJrMEdsWld0dUdzOGcyN2tuWXRycHZlUnVK?= =?utf-8?B?Y1ZtNkN2QjArUVlETnd6cXV1MlZFczFWbVQv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-AuthSource: DS0PR11MB7309.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Aug 2023 18:23:47.4783 (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: x+xen3xA3GONb1h1RKbvDK7oLEmd+AuboU80etGTuGxdsLduQxhveaarUs40bdS0ueHsLJ1b1VBd1ttxmE4D4+JcqpRWn+AzmL3wAwnwIcA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR11MB8752 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 Tue, Aug 08, 2023 at 10:53:03AM -0700, Tyler Retzlaff wrote: > Hi folks, > > Moving this discussion to the dev mailing list for broader comment. > > Unfortunately, we've hit a roadblock with integrating C11 atomics > for DPDK. The main issue is that GNU C++ prior to -std=c++23 explicitly > cannot be integrated with C11 stdatomic.h. Basically, you can't include > the header and you can't use `_Atomic' type specifier to declare atomic > types. This is not a problem with LLVM or MSVC as they both allow > integration with C11 stdatomic.h, but going forward with C11 atomics > would break using DPDK in C++ programs when building with GNU g++. > > Essentially you cannot compile the following with g++. > > #include > > int main(int argc, char *argv[]) { return 0; } > > In file included from atomic.cpp:1: > /usr/lib/gcc/x86_64-pc-cygwin/11/include/stdatomic.h:40:9: error: > ‘_Atomic’ does not name a type > 40 | typedef _Atomic _Bool atomic_bool; > > ... more errors of same ... > > It's also acknowledged as something known and won't fix by GNU g++ > maintainers. > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60932 > > Given the timeframe I would like to propose the minimally invasive, > lowest risk solution as follows. > > 1. Adopt stdatomic.h for all Windows targets, leave all Linux/BSD targets > using GCC builtin C++11 memory model atomics. > 2. Introduce a macro that allows _Atomic type specifier to be applied to > function parameter, structure field types and variable declarations. > > * The macro would expand empty for Linux/BSD targets. > * The macro would expand to C11 _Atomic keyword for Windows targets. > > 3. Introduce basic macro that allows __atomic_xxx for normalized use > internal to DPDK. > > * The macro would not be defined for Linux/BSD targets. > * The macro would expand __atomic_xxx to corresponding stdatomic.h > atomic_xxx operations for Windows targets. > > 4. We re-evaluate adoption of C11 atomics and corresponding requirement of > -std=c++23 compliant compiler at the next long term ABI promise release. > > Q: Why not define macros that look like the standard and expand those > names to builtins? > A: Because introducing the names is a violation of the C standard, we > can't / shouldn't define atomic_xxx names in the applications namespace > as we are not ``the implementation''. > A: Because the builtins offer a subset of stdatomic.h capability they > can only operate on pointer and integer types. If we presented the > stdatomic.h names there might be some confusion attempting to perform > atomic operations on e.g. _Atomic specified struct would fail but only > on BSD/Linux builds (with the proposed solution). > Out of interest, rather than splitting on Windows vs *nix OS for the atomics, what would it look like if we split behaviour based on C vs C++ use? Would such a thing work? Also, just wondering about the scope of the changes here. How many header files are affected where we publicly expose atomics? Thanks, /Bruce