12 #ifndef __DECAF_COMMON_H__ 13 #define __DECAF_COMMON_H__ 1 16 #if defined (__GNUC__) // File only exists for GNU compilers 17 #include <sys/types.h> 26 #if DOXYGEN || defined(__attribute__) 27 #define __attribute__(x) 33 # define __attribute__(x) // Turn off attribute code 34 # define __attribute(x) 35 # define __restrict__ __restrict // Use MSVC restrict code 37 # define DECAF_API_VIS __declspec(dllexport) // MSVC for visibility 39 # define DECAF_API_VIS __declspec(dllimport) 46 #define DECAF_API_VIS __attribute__((visibility("default"))) 47 #define DECAF_API_IMPORT 51 #define DECAF_NOINLINE __attribute__((noinline)) 52 #define DECAF_INLINE inline __attribute__((always_inline,unused)) 53 #define DECAF_WARN_UNUSED __attribute__((warn_unused_result)) 54 #define DECAF_NONNULL __attribute__((nonnull)) 56 #if defined (__clang_major__) && __clang_major__ >= 3 \ 57 || defined (__GNUC__) && __GNUC__ >= 5 \ 58 || defined (__GNUC__) && __GNUC__ == 4 && __GNUC_MINOR__ >= 5 59 #define DECAF_DEPRECATED(msg) __attribute__ ((deprecated(msg))) 61 #define DECAF_DEPRECATED(msg) __attribute__ ((deprecated)) 72 #ifndef DECAF_WORD_BITS 73 #if (defined(__ILP64__) || defined(__amd64__) || defined(__x86_64__) || (((__UINT_FAST32_MAX__)>>30)>>30)) 74 #define DECAF_WORD_BITS 64 76 #define DECAF_WORD_BITS 32 80 #if DECAF_WORD_BITS == 64 86 #elif DECAF_WORD_BITS == 32 87 typedef uint32_t decaf_word_t; 88 typedef int32_t decaf_sword_t; 89 typedef uint32_t decaf_bool_t; 90 typedef uint64_t decaf_dword_t; 91 typedef int64_t decaf_dsword_t; 93 #error "Only supporting DECAF_WORD_BITS = 32 or 64 for now" 98 #if DECAF_WORD_BITS == 64 100 static const decaf_bool_t DECAF_TRUE = (
decaf_bool_t)0xFFFFFFFFFFFFFFFF;
102 static const decaf_word_t DECAF_WORD_ALL_SET = (
decaf_word_t)0xFFFFFFFFFFFFFFFF;
104 static const decaf_word_t DECAF_WORD_ALL_UNSET = (
decaf_word_t)0x0;
105 #elif DECAF_WORD_BITS == 32 107 static const decaf_bool_t DECAF_TRUE = (decaf_bool_t)0xFFFFFFFF; 109 static const decaf_word_t DECAF_WORD_ALL_SET = (
decaf_word_t)0xFFFFFFFF;
111 static const decaf_word_t DECAF_WORD_ALL_UNSET = (
decaf_word_t)0x0;
113 #error "Only supporting DECAF_WORD_BITS = 32 or 64 for now" 117 static const decaf_bool_t DECAF_FALSE = 0;
128 decaf_succeed_if(decaf_bool_t x) {
133 static DECAF_INLINE decaf_bool_t
151 ) DECAF_NONNULL DECAF_WARN_UNUSED;
The operation failed.
Definition: common.h:122
int32_t decaf_sword_t
Signed word size for internal computations.
Definition: common.h:88
decaf_error_t
Another boolean type used to indicate success or failure.
Definition: common.h:120
decaf_bool_t DECAF_API_VIS decaf_memeq(const void *data1, const void *data2, size_t size) DECAF_NONNULL DECAF_WARN_UNUSED
Compare two buffers, returning DECAF_TRUE if they are equal.
#define DECAF_WORD_BITS
The number of bits in a word.
Definition: common.h:76
The operation succeeded.
Definition: common.h:121
int64_t decaf_dsword_t
Signed double-word size for internal computations.
Definition: common.h:91
uint32_t decaf_bool_t
"Boolean" type, will be set to all-zero or all-one (i.e.
Definition: common.h:89
uint32_t decaf_word_t
Word size for internal computations.
Definition: common.h:87
void DECAF_API_VIS decaf_bzero(void *data, size_t size) DECAF_NONNULL
Overwrite data with zeros.
uint64_t decaf_dword_t
Double-word size for internal computations.
Definition: common.h:90