Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp157236ybs; Tue, 26 May 2020 06:10:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0zAJQ5KhnY3omb5W9UE8QNhKhkI7Xkv50/1vLujg6Z1hkFxr4O+PTO6oBqNMtzAeh64HU X-Received: by 2002:a05:6402:3185:: with SMTP id di5mr19773592edb.330.1590498626839; Tue, 26 May 2020 06:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590498626; cv=none; d=google.com; s=arc-20160816; b=WA903T38/X+idSN2TJt1hDSuKlV+usravo2HUNLjR0cjBG9QBM3bCTLG5Dds4uD3Yc ys6CRATRkouwhq0mEjy+/CvXhP5V22/Zc4G1rCcPqp23fry58Vz0awNxK1sYlNaqHy8z aayR1u4eFLDiCa6jT1DJnzO5VMlChWMHzUxLT5nnhVErbT9mnaXM4X58GKrM+BMT6tT7 4u0FGBhntQWoioZezA5uh7Dlf+IJXqrFB4JEeBXXLKM1J1od0t1DpI/lpJP+xJ0tci3M WldMDsgQl/LV0XdjqrfaXBf8fSJs6LZN0LXMJCnWCssUo/navHGY2kc8yjKE+kIVKUg3 Ujxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dkim-signature; bh=WsRwgk9yIsXFnSEXFT2w5jAISXwAreFSORAIbunvzRM=; b=tl2V/CS/pz9PlC40bbtHDNyyscmI8b93SL7O9Xon4fiScr/ovwqaKxcDiolrnnU9uW EcfOxQuP+nDRK86ISQQffZy8u3gcOVwzEi8YzRRBp89/N27NUEAEzPc9boI/UU8gmWnl tOykvXNe+1Dj+dCtI4pFhH7LC7cQgtQo6P8Vo2cdHfuTISV7ZgA1EUoIUekNpXY+KOQx /8YBwC1Zd6nY4YP+CuWW3Y7aYllg7shKf1zL1A/6rZ401wcUVL0dBAzw3M+yftypd6AE S7BUKioNy5gUtUsNYnCbY/QPzWX0U7z+I+vq9iy/iWGIzUpLAeH5THpE14Uh1TW8yU4x Ct8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=box0P1wo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x17si12309072edi.409.2020.05.26.06.10.04; Tue, 26 May 2020 06:10:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=box0P1wo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389192AbgEZMl1 (ORCPT + 99 others); Tue, 26 May 2020 08:41:27 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:20026 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388497AbgEZMl0 (ORCPT ); Tue, 26 May 2020 08:41:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590496885; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=WsRwgk9yIsXFnSEXFT2w5jAISXwAreFSORAIbunvzRM=; b=box0P1woWfbLxR0QIIWWDJCdxQ5bkHvcGarHEVFAc/LXlSE0F5ek9mS9AxM+cbjngvPeT4 buZ1GVpvHabdyStErkTf1YZn2VKpyKpuSZkSylKfKYf3LixLF7DtJCXAQzu2qpIf3ZYZzQ /NOpBTUxp+IFOb8atvRQsUsgdsc2dSc= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-220-J_sAvGetPgm4HTtpzu6Dxw-1; Tue, 26 May 2020 08:41:21 -0400 X-MC-Unique: J_sAvGetPgm4HTtpzu6Dxw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4BAAE1800D42; Tue, 26 May 2020 12:41:19 +0000 (UTC) Received: from oldenburg2.str.redhat.com (ovpn-112-180.ams2.redhat.com [10.36.112.180]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5DB661CA; Tue, 26 May 2020 12:41:16 +0000 (UTC) From: Florian Weimer To: Mathieu Desnoyers Cc: libc-alpha , Rich Felker , linux-api , Boqun Feng , Will Deacon , linux-kernel , Peter Zijlstra , Ben Maurer , Dave Watson , Thomas Gleixner , Paul , Paul Turner , Joseph Myers Subject: Re: [PATCH glibc 1/3] glibc: Perform rseq registration at C startup and thread creation (v19) References: <20200501021439.2456-1-mathieu.desnoyers@efficios.com> <20200501021439.2456-2-mathieu.desnoyers@efficios.com> <87v9kqbzse.fsf@oldenburg2.str.redhat.com> <941087675.33347.1590418305398.JavaMail.zimbra@efficios.com> <87367ovy6k.fsf@oldenburg2.str.redhat.com> <108939265.33525.1590428184533.JavaMail.zimbra@efficios.com> Date: Tue, 26 May 2020 14:41:14 +0200 In-Reply-To: <108939265.33525.1590428184533.JavaMail.zimbra@efficios.com> (Mathieu Desnoyers's message of "Mon, 25 May 2020 13:36:24 -0400 (EDT)") Message-ID: <87lflerhqt.fsf@oldenburg2.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Mathieu Desnoyers: > Something like this ? > > #ifdef __cplusplus > # if __cplusplus >= 201103L > # define rseq_static_assert (expr, diagnostic) static_assert (expr, diagnostic) > # define rseq_alignof alignof > # endif > #elif __STDC_VERSION__ >= 201112L > # define rseq_static_assert (expr, diagnostic) _Static_assert (expr, diagnostic) > # define rseq_alignof _Alignof > #endif > > #ifndef rseq_static_assert > # define rseq_static_assert (expr, diagnostic) /* nothing */ > #endif You can't have a space in #defines like that, no matter what GNU style says. 8-) > /* Ensure the compiler supports __attribute__ ((aligned)). */ > rseq_static_assert ((rseq_alignof (struct rseq_cs) >= 32, "alignment")); > rseq_static_assert ((rseq_alignof (struct rseq) >= 32, "alignment")); You need to move the ; into rseq_static_assert. And if you use explicit arguments, you can't use double parentheses. >> And something similar for _Alignas/attribute aligned, > > I don't see where _Alignas is needed here ? > > For attribute aligned, what would be the oldest supported C and C++ > standards ? There are no standardized attributes for C, there is only _Alignas. C++11 has an alignas specifier; it's not an attribute either. I think these are syntactically similar. >> with an error for >> older standards and !__GNUC__ compilers (because neither the type nor >> __thread can be represented there). > > By "type" you mean "struct rseq" here ? What does it contain that requires > a __GNUC__ compiler ? __attribute__ and __thread support. > About __thread, I recall other compilers have other means to declare it. > In liburcu, I end up with the following: > > #if defined (__cplusplus) && (__cplusplus >= 201103L) > # define URCU_TLS_STORAGE_CLASS thread_local > #elif defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) > # define URCU_TLS_STORAGE_CLASS _Thread_local > #elif defined (_MSC_VER) > # define URCU_TLS_STORAGE_CLASS __declspec(thread) > #else > # define URCU_TLS_STORAGE_CLASS __thread > #endif > > Would something along those lines be OK for libc ? Yes, it would be okay (minus the Visual C++ part). This part does not have to go into UAPI headers first. A fallback definition of __thread should be okay. Outside glibc, the TLS model declaration is optional, I think. The glibc *definition* ensures that the variable is initial-exec. Thanks, Florian