* 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