]> pd.if.org Git - pdclib/blobdiff - internals/_PDCLIB_aux.h
Patch suggested by darkinsanity, http://forum.osdev.org/viewtopic.php?p=256346#p256346
[pdclib] / internals / _PDCLIB_aux.h
index bc13897a7d4254383cc3890499c69ba7459f4a09..484e930f24618c24fbee7dc563835e441ceeed35 100644 (file)
@@ -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
     #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
     #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*/