From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id B63191F55B for ; Sun, 24 May 2020 13:36:59 +0000 (UTC) Received: from localhost ([::1]:51308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jcqoE-0005be-I9 for normalperson@yhbt.net; Sun, 24 May 2020 09:36:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jcqno-0005V9-KE for bug-gnulib@gnu.org; Sun, 24 May 2020 09:36:32 -0400 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:41668) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jcqnn-0007JL-QL for bug-gnulib@gnu.org; Sun, 24 May 2020 09:36:32 -0400 Received: by mail-pg1-x534.google.com with SMTP id r10so7484642pgv.8 for ; Sun, 24 May 2020 06:36:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=67byVYa/qOhrVZQdrvqNJ0AZ1rtX4zGDVVQFglk7uPE=; b=ZcqWSnMTBe/4FfbaGNJ+WQ00HeyJPwi51g2BHLiHG8gT/FuIs5iIiDRdxq04IM7IWz riEEE2re3FSTOU3rY+FRN+nxbasS5uufcaHra14iax/UmK7B19XoRa2Z7BKx9HmeJLpq XIc79ft8J/yjFywcRIrTLw+ssPWPAuZeoIF5/FlGIn2r0pepm3YvGYPNwg8jh7WrY7Ky erGHNsQGznqJE1NxeP7lnPv+wN7BqKIP45475OBBH96KEAVt5GD3rkno/HmKj0dZL/9z JWWH+Yn27V/Ob383D7pCRZOvdk2OvyJhH7gGxXTxcF3DcBGSqKPx41t1TnqnmnMC+/Eb FlIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=67byVYa/qOhrVZQdrvqNJ0AZ1rtX4zGDVVQFglk7uPE=; b=qYGPBbRHnd3ddQpwYddhHLnSIarufwhs6yVpjicvtaPXeSu63xvHILDvwd1OiekSgi CLXbpsnmdtFxbU19M6Ytz2lLZT22CB2iqZBSpfwNNjbnZd8dr8U4m8HEaBH4VgZqmAuN Bu5Oecij1YjsDlDllOJBARbpDBpkVTj8vS2QDlWH2cLP4K4rNfYznTFwUgWKkrCabyFa qoDCAnplO8G7trc7NqknKtQz5tVjNFxgfdu/081HwAH3yyutLhYe+l/t24By4wjwmr/e kHXUqkIa/vUqNOtGNpWH/OUIo3wgtTbjHkL0oEUEW6SiE5Oo4Usi9eh63H+ub4FLRz3T EJsQ== X-Gm-Message-State: AOAM531TePXJR5azsvE8YD/WY2QDqYAN5Zc4vjyklZIe8gtCvznmulSL QE1LfHAmWlsOfdvMqGBMmY8ZpQplQpmO1KDBDG0FfbcA X-Google-Smtp-Source: ABdhPJxBAPs++bYDFpj/eZjmEVN+PfocT1tYqJLqY/WkFkfL0bTDJ6MZyNuWpvOM/rYI8VmGNaq1p1R9S+sk7fceCNU= X-Received: by 2002:a63:4c0b:: with SMTP id z11mr19134897pga.348.1590327389992; Sun, 24 May 2020 06:36:29 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= Date: Sun, 24 May 2020 15:36:19 +0200 Message-ID: Subject: Module suggestion: Atomic operations To: bug-gnulib@gnu.org Content-Type: multipart/alternative; boundary="0000000000002839da05a664f35f" Received-SPF: pass client-ip=2607:f8b0:4864:20::534; envelope-from=marc.nieper@gmail.com; helo=mail-pg1-x534.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" --0000000000002839da05a664f35f Content-Type: text/plain; charset="UTF-8" C11 has introduced atomic types and atomic operations. When they are not available, one can use locks/mutexes instead. It would be nice if there was a Gnulib module that abstracts over this, much like the threadlib module and friends abstract over a specific threading implementation. What I am thinking of is the following: Given a type T, a new Gnulib module atomic allows the declaration of an atomic version of type T. This is straightforward on a platform that has . Otherwise the atomic version of T would be a struct consisting of an object of type T together with a lock. The rest of the module would then provide some simple atomic primitives like fetch_and_add, etc. that are either mapped to the C11 stdatomic counterparts or are implemented using the lock. Marc --0000000000002839da05a664f35f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
C11 has introduced atomic types and atomic operations.=C2=A0 When they a= re not available, one can use locks/mutexes instead.

It would be nice if there was a Gnu= lib module that abstracts over this, much like the threadlib module and fri= ends abstract over a specific threading implementation.

What I am thinking of is the fol= lowing: Given a type T, a new Gnulib module atomic allows the declaration o= f an atomic version of type T.=C2=A0 This is straightforward on a platform = that has <stdatomic.h>.=C2=A0 Otherwise the atomic version of T would= be a struct consisting of an object of type T together with a lock.
<= div class=3D"gmail_default" style=3D"font-family:monospace">
The rest of the mod= ule would then provide some simple atomic primitives like fetch_and_add, et= c. that are either mapped to the C11 stdatomic counterparts or are implemen= ted using the lock.

Marc
--0000000000002839da05a664f35f--