0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-09-22 10:43:39 -04:00

If we have new features introduced by C11, use them

Instead of using hacks or compiler-specific features, if we have
standard features as defined in ISO C11, use them.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
This commit is contained in:
H. Peter Anvin
2016-12-20 02:29:58 -08:00
parent fd610f27d6
commit abd28c9ab9
5 changed files with 44 additions and 5 deletions

View File

@@ -77,6 +77,7 @@
# include "nasmint.h"
#endif
#include <assert.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
@@ -208,7 +209,10 @@ char *strsep(char **, const char *);
/*
* How to tell the compiler that a function doesn't return
*/
#ifdef HAVE_FUNC_ATTRIBUTE_NORETURN
#ifdef HAVE_STDNORETURN_H
# include <stdnoreturn.h>
# define no_return noreturn void
#elif defined(HAVE_FUNC_ATTRIBUTE_NORETURN)
# define no_return void __attribute__((noreturn))
#else
# define no_return void

View File

@@ -175,7 +175,18 @@ no_return nasm_assert_failed(const char *, int, const char *);
/*
* NASM failure at build time if x != 0
*/
#define nasm_build_assert(x) (void)(sizeof(char[1-2*!!(x)]))
#ifdef static_assert
# define nasm_build_assert(x) static_assert(x, "assertion " #x " failed")
#elif defined(HAVE_FUNC_ATTRIBUTE_ERROR)
# define nasm_build_assert(x) \
if (!(x)) { \
extern void __attribute__((error("assertion " #x " failed"))) \
fail(void); \
fail(); \
}
#else
# define nasm_build_assert(x) (void)(sizeof(char[1-2*!(x)]))
#endif
/*
* ANSI doesn't guarantee the presence of `stricmp' or