diff options
| author | Mattias Andrée <maandree@operamail.com> | 2015-08-29 04:31:14 +0200 | 
|---|---|---|
| committer | Mattias Andrée <maandree@operamail.com> | 2015-08-29 04:31:14 +0200 | 
| commit | 6fe45b4c7578cc9da7538dd9f57be6d8df730b3b (patch) | |
| tree | 4399d20af6a514ac070615fb5b781eb85fcc46ab /include | |
| parent | only use __attributes__ if compiling with gcc (diff) | |
| download | slibc-6fe45b4c7578cc9da7538dd9f57be6d8df730b3b.tar.gz slibc-6fe45b4c7578cc9da7538dd9f57be6d8df730b3b.tar.bz2 slibc-6fe45b4c7578cc9da7538dd9f57be6d8df730b3b.tar.xz | |
add __C11__, __C99__, __C90__, and __noreturn
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'include')
| -rw-r--r-- | include/assert.h | 5 | ||||
| -rw-r--r-- | include/slibc/features.h | 38 | ||||
| -rw-r--r-- | include/stdalign.h | 7 | ||||
| -rw-r--r-- | include/stdnoreturn.h | 5 | 
4 files changed, 49 insertions, 6 deletions
| diff --git a/include/assert.h b/include/assert.h index e5a963d..763b7b4 100644 --- a/include/assert.h +++ b/include/assert.h @@ -75,7 +75,6 @@  #else  # define assert_perror(errnum)  \    ((void)((errnum == 0) ? 0 : (__assert_fail(NULL, errnum, __FILE__, __LINE__, __func__), 0))) -__USE_GNU  #endif @@ -89,8 +88,8 @@ __USE_GNU   * @param  line        The line in the source code whence the assertion was made   * @param  func        The function in the source code whence the assertion was made   */ -void __GCC_ONLY(__attribute__((noreturn, nonnull(3, 4, 5)))) -__assert_fail(const char* expression, int errnum, const char* file, int line, const char* func); +void __assert_fail(const char* expression, int errnum, const char* file, int line, const char* func) +  __noreturn __GCC_ONLY(__attribute__((nonnull(3, 4, 5)))); diff --git a/include/slibc/features.h b/include/slibc/features.h index a755f71..0cbc326 100644 --- a/include/slibc/features.h +++ b/include/slibc/features.h @@ -19,6 +19,31 @@  #define _SLIBC_FEATURES_H +/* These definitions are only to be used in slibc header-files. */ + + +/** + * Is C11, or newer, used? + */ +#if __STDC_VERSION__ >= 201112L +# define __C11__ +#endif + +/** + * Is C99, or newer, used? + */ +#if __STDC_VERSION__ >= 199901L +# define __C99__ +#endif + +/** + * Is C90, or newer, used? + */ +#if defined(__STDC_VERSION__) || defined(__STDC__) +# define __C90__ +#endif + +  /**   * Macro used to exclude code unless GCC is used. @@ -30,6 +55,19 @@  #endif +/** + * Specifies that a function never returns, that is, + * the process exits before the function returns. + */ +#if !defined(__C11__) && defined(__GNUC__) +# define __noreturn  __attribute__((noreturn)) +#elif defined(__C11__) +# define __noreturn  _Noreturn +#else +# define __noreturn  /* ignore */ +#endif + +  #endif diff --git a/include/stdalign.h b/include/stdalign.h index bce8f5d..b247b2c 100644 --- a/include/stdalign.h +++ b/include/stdalign.h @@ -20,13 +20,16 @@  #include <slibc/version.h> +#include <slibc/features.h> + +  /**   * Specify the alignment of a variable.   *    * @param  type  The type whose alignment shall be used.   */ -#if __STDC_VERSION__ < 201112L && defined(__GNUC__) +#if !defined(__C11__) && defined(__GNUC__)  # define _Alignas(type)  __attribute__((__aligned__(type)))  #endif  #define alignas(type)  _Alignas(type) @@ -38,7 +41,7 @@   * @param   type  The type.   * @return        The alignment of the type.   */ -#if __STDC_VERSION__ < 201112L && defined(__GNUC__) +#if !defined(__C11__) && defined(__GNUC__)  # define _Alignof(type)  __alignof__(type)  #endif  #define alignof(type)  _Alignof(type) diff --git a/include/stdnoreturn.h b/include/stdnoreturn.h index fd54d1b..19c6016 100644 --- a/include/stdnoreturn.h +++ b/include/stdnoreturn.h @@ -20,12 +20,15 @@  #include <slibc/version.h> +#include <slibc/features.h> + +  /**   * Specifies that a function never returns, that is,   * the process exits before the function returns.   */ -#if __STDC_VERSION__ < 201112L && defined(__GNUC__) +#if !defined(__C11__) && defined(__GNUC__)  # define _Noreturn  __attribute__((noreturn))  #endif  #define noreturn  _Noreturn | 
