I used n1570 for C11: http://www.iso-9899.info/n1570.html
and n3242 for C++11: 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf

C11:
stdalign.h:
7.15.1: The header <stdalign.h> defines four macros.
7.15.2: The macro
            alignas
        expands to _Alignas; the macro
            alignof
        expands to _Alignof.

7.15.3: The remaining macros are suitable for use in #if preprocessing
        directives. They are
            __alignas_is_defined
        and
            __alignof_is_defined
        which both expand to the integer constant 1.

stdnoreturn.h:
7.23.1: The header <stdnoreturn.h> defines the macro
            noreturn
        which expands to _Noreturn.

C++11:
stdalign.h:
18.10.2: The contents of these headers are the same as the Standard C library
         headers (...) <stdalign.h> (...) respectively, with the following 
changes:
18.10.6: The header <cstdalign> and the header <stdalign.h> shall not define a
         macro named alignas.

No mention of stdnoreturn.h.


Note that C++11 does not mention "alignof", even though it mentions
"alignas". Both are defined as keywords (Table 4 - Keywords).

A commit in Clang has this to say:

    libstdc++'s <cstdalign> #includes <stdalign.h> and expects it to guard 
against
    being included in C++. Don't define alignof or alignas in this case.  Note 
that
    the C++11 standard is broken in various ways here (it refers to the contents
    of <stdalign.h> in C99, where that header did not exist, and doesn't mention
    the alignas macro at all), but we do our best to do what it intended.

So I went ahead and followed Clang, not C++11.

Clang's stdnoreturn.h differs from the standard as well, as it defines
"__noreturn_is_defined". I couldn't find a reason, so I didn't.

stdnoreturn.h isn't mentioned in C++11, so skip the #ifndef __cplusplus.


The commit message in FreeBSD that contains these files notes: "Even
though these header files make little sense to me, they are part of the
standard.". I believe these headers are defined to preserve backwards
compatibility. There might exist code where the keywords "alignas", "alignof",
and "noreturn" are already defined. The standard therefore picked keywords
from the reserved namespace, i.e. ones starting with an underscore
and an upper case letter and provided the headers for convenience.


And also make whitespace in stdbool.h consistent with other files.


Index: include/Makefile
===================================================================
RCS file: /cvs/src/include/Makefile,v
retrieving revision 1.208
diff -u -p -r1.208 Makefile
--- include/Makefile    18 Nov 2015 16:48:34 -0000      1.208
+++ include/Makefile    30 Dec 2015 16:43:53 -0000
@@ -17,8 +17,8 @@ FILES=        a.out.h ar.h asr.h assert.h bitst
        md5.h memory.h ndbm.h netdb.h netgroup.h nlist.h nl_types.h \
        paths.h poll.h pwd.h ranlib.h readpassphrase.h regex.h \
        resolv.h rmd160.h search.h setjmp.h sha1.h sha2.h signal.h siphash.h \
-       sndio.h \
-       spawn.h stdbool.h stddef.h stdio.h stdlib.h string.h strings.h struct.h 
\
+       sndio.h spawn.h stdalign.h stdbool.h stddef.h stdio.h stdlib.h \
+       stdnoreturn.h string.h strings.h struct.h \
        sysexits.h tar.h tgmath.h time.h ttyent.h unistd.h utime.h \
        utmp.h uuid.h vis.h wchar.h wctype.h
 
Index: include/stdalign.h
===================================================================
RCS file: include/stdalign.h
diff -N include/stdalign.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ include/stdalign.h  30 Dec 2015 16:43:53 -0000
@@ -0,0 +1,18 @@
+/*     $OpenBSD$       */
+
+/*
+ * Public domain.
+ */
+
+#ifndef        _STDALIGN_H_
+#define        _STDALIGN_H_    
+
+#ifndef __cplusplus
+#define alignas _Alignas
+#define alignof _Alignof
+#endif
+
+#define __alignas_is_defined 1
+#define __alignof_is_defined 1
+
+#endif /* _STDALIGN_H_ */
Index: include/stdbool.h
===================================================================
RCS file: /cvs/src/include/stdbool.h,v
retrieving revision 1.7
diff -u -p -r1.7 stdbool.h
--- include/stdbool.h   4 Sep 2015 23:47:09 -0000       1.7
+++ include/stdbool.h   30 Dec 2015 16:43:53 -0000
@@ -1,4 +1,4 @@
-/* $OpenBSD: stdbool.h,v 1.7 2015/09/04 23:47:09 daniel Exp $ */
+/*     $OpenBSD: stdbool.h,v 1.7 2015/09/04 23:47:09 daniel Exp $      */
 
 /*
  * Written by Marc Espie, September 25, 1999
Index: include/stdnoreturn.h
===================================================================
RCS file: include/stdnoreturn.h
diff -N include/stdnoreturn.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ include/stdnoreturn.h       30 Dec 2015 16:43:53 -0000
@@ -0,0 +1,12 @@
+/*     $OpenBSD$       */
+
+/*
+ * Public domain.
+ */
+
+#ifndef        _STDNORETURN_H_
+#define        _STDNORETURN_H_ 
+
+#define noreturn _Noreturn
+
+#endif /* _STDNORETURN_H_ */

-- 
Michal Mazurek

Reply via email to