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.5 required=3.0 tests=AWL,BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, 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 B72C91F55B for ; Mon, 25 May 2020 07:04:23 +0000 (UTC) Received: from localhost ([::1]:34102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jd79q-0008DH-Hc for normalperson@yhbt.net; Mon, 25 May 2020 03:04:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jd79d-0008D9-DK for bug-gnulib@gnu.org; Mon, 25 May 2020 03:04:09 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:40417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jd79c-0006KK-BR for bug-gnulib@gnu.org; Mon, 25 May 2020 03:04:09 -0400 Received: by mail-pf1-x42f.google.com with SMTP id v2so3390595pfv.7 for ; Mon, 25 May 2020 00:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2IM69g8HtKTwvQiiDMfacNt4Hm/eLUhW1b0YbPdzj8w=; b=kP79IwGGdoLhqLcrtRsbK9ypIhfnbYSK7a/CBt+CSBGWA2+AZb4o04x1Q6XcbRam0k 3XCSlLV4/HvMSh7UGGEuBfALEM/x7sQZc4ogyEoiU2mgIvJgVst+0Ka8ttHn8Kl5l72t ASeN3XrGstemwbCiT6ZEZP9xUkyzA5EmCnivqeJP1u6AMMkGSBKyk60cKs+eHIxmU0Cy uqi9y+uhGXQurR1VHssugKaGnnhGgew8B79Tf0C9xkOqBUDYgHvJYZFeCuINDxrL0k+N 1CsWw99EoKQDS5SoAzSYCWTTjtvq49qRVexHFzBLNo6QmB04mRKAsFLf5NLILD031YOv P0bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2IM69g8HtKTwvQiiDMfacNt4Hm/eLUhW1b0YbPdzj8w=; b=BSve91MUIxBvDixC9uOOt5mDO2eLKYJwN8s04T6UxvMsjBZqybA+tVnJWKKHCSIvRE B21B+xmqnkUAQERJ15jfZJSI7opfUS8IbXonJEvGHkUvHd4S7QYAF82dAwyfgV/+I9tM sxwWjeyBS0jQZLYea8rIPOIyJ1fLLUN8n8n52PzYP3uGzO13I7nEbDuWb+kCUvhIk70D 36Sg6JHVK91Qrr0fwtSplbQg2Ti0NNz75rJFl0T6ysrrQqhKzOJFT56R7fDv6TGtBVoP jH8IBTu9AIRZaq21cNk0FKxPjstgYwYXn9XMHw94Voy0Ga5JrejfGtOhQOg2hiey026y FylA== X-Gm-Message-State: AOAM53025k99kMzr7s0RTSCRLDbJK/OsC6cKQdaQC84f7JPkSGE4w0r7 rSAEkGpVzWnSG7Gy6Qs5//BsLmhZFeTgFjzOPUI= X-Google-Smtp-Source: ABdhPJxkw8k4vDjmnYtZaxkzEAi4ls721yHWaRU1qBxeb9yvbVv6C+3Aof+3JQ+UtrGD4/0guGbhYtRYxGgOXf7jr40= X-Received: by 2002:a63:d602:: with SMTP id q2mr629480pgg.23.1590390246368; Mon, 25 May 2020 00:04:06 -0700 (PDT) MIME-Version: 1.0 References: <3693477.VlezqqQ6Ty@omega> In-Reply-To: <3693477.VlezqqQ6Ty@omega> From: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= Date: Mon, 25 May 2020 09:03:55 +0200 Message-ID: Subject: Re: Module suggestion: Atomic operations To: Bruno Haible Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=marc.nieper@gmail.com; helo=mail-pf1-x42f.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=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: , Cc: =?UTF-8?Q?Marc_Nieper=2DWi=C3=9Fkirchen?= , bug-gnulib@gnu.org Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" Hi Bruno, Am So., 24. Mai 2020 um 22:54 Uhr schrieb Bruno Haible : > Yes, given that the platform support for these atomic types/operations is > increasing, it would accelerate the adoption if there was a Gnulib module, > like you describe it. Program developers could then adopt > without losing portability to a number of platforms. So, you mean that Gnulib should try to provide in case it is not available? I have to think about it whether this can ever work (and in an efficient way). When I raised the question, I was more thinking of a custom interface that abstracts both over and some other implementation with explicit mutexes, much like the tls module abstracts over C11's TLS and some other implementations, like the pthread one. One problem with as given is that atomic values have no destructors. Thus, we cannot simply attach locks to them in a pre-C11 implementation because there is no place to destroy the locks. Thus, we would have to work with a pool of locks shared by all atomic variables. But when to set up the pool? A module atomic with a header "atomic.h" could implement an interface that has destructors (which are mapped to no-ops when is available). > Personally I'm not very motivated to work on that (because in most algorithms > I've seen, mutexes/locks are the way to go, and because I find the memory_order > stuff hard to understand). But if you want to work on that, it will be > welcome! I should wait for the copyright assignment first. As for the memory_order things. A first version of the module may map everything to memory_order_seq_cst, which is safe but not always the most efficient. Marc