00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef CMOCKA_PRIVATE_H_
00018 #define CMOCKA_PRIVATE_H_
00019
00020 #include "config.h"
00021
00022 #include <stdint.h>
00023
00024 #ifdef _WIN32
00025 #include <windows.h>
00026
00027 # ifdef _MSC_VER
00028 # include <stdio.h>
00029
00030 # undef inline
00031 # define inline __inline
00032
00033 # define strcasecmp _stricmp
00034 # define strncasecmp _strnicmp
00035
00036 # if defined(HAVE__SNPRINTF_S)
00037 # undef snprintf
00038 # define snprintf(d, n, ...) _snprintf_s((d), (n), _TRUNCATE, __VA_ARGS__)
00039 # else
00040 # if defined(HAVE__SNPRINTF)
00041 # undef snprintf
00042 # define snprintf _snprintf
00043 # else
00044 # if !defined(HAVE_SNPRINTF)
00045 # error "no snprintf compatible function found"
00046 # endif
00047 # endif
00048 # endif
00049
00050 # if defined(HAVE__VSNPRINTF_S)
00051 # undef vsnprintf
00052 # define vsnprintf(s, n, f, v) _vsnprintf_s((s), (n), _TRUNCATE, (f), (v))
00053 # else
00054 # if defined(HAVE__VSNPRINTF)
00055 # undef vsnprintf
00056 # define vsnprintf _vsnprintf
00057 # else
00058 # if !defined(HAVE_VSNPRINTF)
00059 # error "No vsnprintf compatible function found"
00060 # endif
00061 # endif
00062 # endif
00063 # endif
00064
00065
00066
00067
00068
00069 WINBASEAPI BOOL WINAPI IsDebuggerPresent(VOID);
00070
00071 #ifndef PRIdS
00072 # define PRIdS "Id"
00073 #endif
00074
00075 #ifndef PRIu64
00076 # define PRIu64 "I64u"
00077 #endif
00078
00079 #ifndef PRIuMAX
00080 # define PRIuMAX PRIu64
00081 #endif
00082
00083 #ifndef PRIxMAX
00084 #define PRIxMAX "I64x"
00085 #endif
00086
00087 #ifndef PRIXMAX
00088 #define PRIXMAX "I64X"
00089 #endif
00090
00091 #else
00092
00093 #ifndef __PRI64_PREFIX
00094 # if __WORDSIZE == 64
00095 # define __PRI64_PREFIX "l"
00096 # else
00097 # define __PRI64_PREFIX "ll"
00098 # endif
00099 #endif
00100
00101 #ifndef PRIdS
00102 # define PRIdS "zd"
00103 #endif
00104
00105 #ifndef PRIu64
00106 # define PRIu64 __PRI64_PREFIX "u"
00107 #endif
00108
00109 #ifndef PRIuMAX
00110 # define PRIuMAX __PRI64_PREFIX "u"
00111 #endif
00112
00113 #ifndef PRIxMAX
00114 #define PRIxMAX __PRI64_PREFIX "x"
00115 #endif
00116
00117 #ifndef PRIXMAX
00118 #define PRIXMAX __PRI64_PREFIX "X"
00119 #endif
00120
00121 #endif
00122
00124 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
00125
00127 #define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
00128
00130 #define ZERO_STRUCTP(x) do { if ((x) != NULL) memset((char *)(x), 0, sizeof(*(x))); } while(0)
00131
00133 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(a[0]))
00134
00136 #define BURN_STRING(x) do { if ((x) != NULL) memset((x), 'X', strlen((x))); } while(0)
00137
00150 #define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
00151
00155 #define discard_const_p(type, ptr) ((type *)discard_const(ptr))
00156
00157 #endif