[llvm-bugs] [Bug 32377] New: __STDC_NO_THREADS__ undefined with glibc

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 22 09:41:48 PDT 2017


https://bugs.llvm.org/show_bug.cgi?id=32377

            Bug ID: 32377
           Summary: __STDC_NO_THREADS__ undefined with glibc
           Product: clang
           Version: 3.9
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Driver
          Assignee: unassignedclangbugs at nondot.org
          Reporter: clang at evan.coeusgroup.com
                CC: llvm-bugs at lists.llvm.org

glibc doesn't support the C11 threads API but clang doesn't define
__STDC_NO_THREADS__, even in C11 mode, as is required by the C11 spec (ยง
6.10.8.3).

I know this is partially a libc issue, since it's really up to the standard
library (not the compiler) to support the API.  glibc does contain a `#define
__STDC_NO_THREADS__ 1` (as of 2.16) in stdc-predef.h, but clang doesn't
automatically include that file (GCC does).

I'm working around this issue right now by including stdc-predef.h (indirectly,
for portability reasons; limits.h -> features.h -> stdc-predef.h), but AFAIK
this shouldn't be necessary for a conformant implementation of C11.  I should
be able to have something like

  #if defined(__STDC_VERSION__) && \
      (__STDC_VERSION__ >= 201102L) && \
      !defined(__STDC_NO_THREADS__)
  #  include <threads.h>
  #endif

as the first few lines in my code, and have it work as expected.

It seems like the most straightforward solution would be to include
<stdc-predef.h> on glibc just like GCC does
(<https://gcc.gnu.org/viewcvs/gcc/trunk/gcc/config/glibc-c.c?view=markup#l26>).

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170322/97ab2d6b/attachment.html>


More information about the llvm-bugs mailing list