compat-c.h

Go to the documentation of this file.
00001 
00020 #ifndef HYPERTABLE_COMPAT_C_H
00021 #define HYPERTABLE_COMPAT_C_H
00022 
00025 /* Name mangling */
00026 #ifdef __cplusplus
00027 #  define HT_EXTERN_C  extern "C"
00028 #else
00029 #  define HT_EXTERN_C  extern
00030 #endif
00031 
00032 /* Calling convention */
00033 #ifdef _MSC_VER
00034 #  define HT_CDECL      __cdecl
00035 #else
00036 #  define HT_CDECL
00037 #endif
00038 
00039 #define HT_PUBLIC(ret_type)     ret_type HT_CDECL
00040 #define HT_EXTERN(ret_type)     HT_EXTERN_C HT_PUBLIC(ret_type)
00041 
00042 #ifdef __GNUC__
00043 #  define HT_NORETURN __attribute__((__noreturn__))
00044 #  define HT_FORMAT(x) __attribute__((format x))
00045 #  define HT_FUNC __PRETTY_FUNCTION__
00046 #  define HT_COND(x, _prob_) __builtin_expect(x, _prob_)
00047 #else
00048 #  define HT_NORETURN
00049 #  define HT_FORMAT(x)
00050 #  ifndef __attribute__
00051 #    define __attribute__(x)
00052 #  endif
00053 #  define HT_FUNC __func__
00054 #  define HT_COND(x, _prob_) (x)
00055 #endif
00056 
00057 #define HT_LIKELY(x) HT_COND(x, 1)
00058 #define HT_UNLIKELY(x) HT_COND(x, 0)
00059 
00060 /* We want C limit macros, even when using C++ compilers */
00061 #ifndef __STDC_LIMIT_MACROS
00062 #  define __STDC_LIMIT_MACROS
00063 #endif
00064 #include <stdint.h>
00065 #include <stddef.h>
00066 #include <string.h>
00067 #include <strings.h>
00068 #include <stdlib.h>
00069 
00070 #endif /* HYPERTABLE_COMPAT_C_H */