X-Git-Url: https://pd.if.org/git/?p=pdclib;a=blobdiff_plain;f=internals%2F_PDCLIB_aux.h;h=16e7ed86ce0353b1055da508ed65702eb0125900;hp=bc13897a7d4254383cc3890499c69ba7459f4a09;hb=25241f49cbda2d67169a3f072b43ad6bc0b8dba9;hpb=28f6edc984f962ed33ac4fb505cf94b3e78f3f6d diff --git a/internals/_PDCLIB_aux.h b/internals/_PDCLIB_aux.h index bc13897..16e7ed8 100644 --- a/internals/_PDCLIB_aux.h +++ b/internals/_PDCLIB_aux.h @@ -1,5 +1,5 @@ -#ifndef _PDCLIB_AUX_H -#define _PDCLIB_AUX_H +#ifndef __PDCLIB_AUX_H +#define __PDCLIB_AUX_H __PDCLIB_AUX_H /* Auxiliary PDCLib code <_PDCLIB_aux.h> @@ -96,7 +96,7 @@ #endif #ifdef __has_attribute - #define _PDCLIB_HAS_ATTRIBUTE(x) __has_builtin(x) + #define _PDCLIB_HAS_ATTRIBUTE(x) __has_attribute(x) #else #define _PDCLIB_HAS_ATTRIBUTE(x) (0) #endif @@ -181,6 +181,15 @@ #define _PDCLIB_DEPRECATED __attribute__ ((__deprecated__)) #endif +#if !defined(_PDCLIB_UNREACHABLE) && _PDCLIB_GCC_BUILTIN(__builtin_unreachable, 4, 0) + #define _PDCLIB_UNREACHABLE __builtin_unreachable() +#endif + +#if !defined(_PDCLIB_UNDEFINED) && defined(__GNUC__) + #define _PDCLIB_UNDEFINED(_var) \ + do { __asm__("" : "=X"(_var)); } while(0) +#endif + /* No-op fallbacks */ #ifndef _PDCLIB_nothrow @@ -224,6 +233,14 @@ #define _PDCLIB_DEPRECATED #endif +#ifndef _PDCLIB_UNREACHABLE + #define _PDCLIB_UNREACHABLE do {} while(0) +#endif + +#ifndef _PDCLIB_UNDEFINED + #define _PDCLIB_UNDEFINED(_var) do {} while(0) +#endif + /*#if _PDCLIB_C_VERSION != 1999 #error PDCLib might not be fully conforming to either C89 or C95 prior to v2.x. #endif*/ @@ -232,11 +249,18 @@ /* Helper macros: */ /* _PDCLIB_cc( x, y ) concatenates two preprocessor tokens without extending */ /* _PDCLIB_concat( x, y ) concatenates two preprocessor tokens with extending */ +/* _PDCLIB_concat3( x, y, z ) is the same for three tokens */ +/* _PDCLIB_static_assert( x ) provides a compile-time check mechanism */ /* -------------------------------------------------------------------------- */ #define _PDCLIB_cc( x, y ) x ## y #define _PDCLIB_concat( x, y ) _PDCLIB_cc( x, y ) #define _PDCLIB_concat3( x, y, z ) _PDCLIB_concat( _PDCLIB_concat( x, y ), z ) +#if _PDCLIB_C_VERSION >= 2011 +#define _PDCLIB_static_assert _Static_assert +#else +#define _PDCLIB_static_assert( e, m ) ;enum { _PDCLIB_concat( _PDCLIB_assert_, __LINE__ ) = 1 / ( !!( e ) ) } +#endif #define _PDCLIB_symbol2value( x ) #x #define _PDCLIB_symbol2string( x ) _PDCLIB_symbol2value( x )