From: Owen Shepherd Date: Sun, 30 Dec 2012 22:55:11 +0000 (+0000) Subject: Add _PDCLIB_UNREACHABLE (defines block of code as unreachable) and _PDCLIB_UNDEFINED... X-Git-Url: https://pd.if.org/git/?p=pdclib.old;a=commitdiff_plain;h=42b55f2fe048f172af302c43e83733b2344854cc Add _PDCLIB_UNREACHABLE (defines block of code as unreachable) and _PDCLIB_UNDEFINED(var) (defines the contents of the passed variable to be undefined) macros to _PDCLIB_aux.h --- diff --git a/internals/_PDCLIB_aux.h b/internals/_PDCLIB_aux.h index bc13897..c3e38d0 100644 --- a/internals/_PDCLIB_aux.h +++ b/internals/_PDCLIB_aux.h @@ -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*/