58 #define PERM_DIRS 0777 63 #define D_MKDIR(x) mkdir(x) 65 #define strcasecmp _stricmp 66 #define vsnprintf _vsnprintf 67 #define snprintf _snprintf 69 #define ftello _ftelli64 70 #define fseeko _fseeki64 71 #elif defined (__MINGW32__) 72 #define ftello ftello64 73 #define fseeko fseeko64 75 #error Only MSC and mingw supported for Windows 78 #define UINT64_MAX ((uint64_t)0xffffffffffffffff) 83 int __cdecl _fseeki64(FILE *, __int64,
int);
84 __int64 __cdecl _ftelli64(FILE *);
93 #define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0) 94 #define ctime_r(tp,tmp) (ctime(tp)?(strcpy((tmp),ctime((tp))),(tmp)):0) 97 #define gmtime_r(tp,tmp) (gmtime(tp)?(*(tmp)=*gmtime(tp),(tmp)):0) 98 #define ctime_r(tp,tmp) (ctime(tp)?(strcpy((tmp),ctime((tp))),(tmp)):0) 99 #define fseeko(stream, offset, whence) fseek(stream, (long)offset, whence) 107 #define D_MKDIR(x) mkdir(x, PERM_DIRS) 110 #ifdef HAVE_SYS_STAT_H 111 #include <sys/stat.h> 114 #ifdef HAVE_SYS_TYPES_H 115 #include <sys/types.h> 118 #ifdef HAVE_SYS_SHM_H 122 #ifdef HAVE_SYS_WAIT_H 123 #include <sys/wait.h> 130 #ifdef HAVE_SEMAPHORE_H 131 #include <semaphore.h> 141 void pst_debug(
int level,
int line,
const char *file,
const char *fmt, ...);
142 void pst_debug_hexdump(
int level,
int line,
const char *file,
const char* buf,
size_t size,
int cols,
int delta);
148 #define MESSAGEPRINT1(...) pst_debug(1, __LINE__, __FILE__, __VA_ARGS__) 149 #define MESSAGEPRINT2(...) pst_debug(2, __LINE__, __FILE__, __VA_ARGS__) 150 #define MESSAGEPRINT3(...) pst_debug(3, __LINE__, __FILE__, __VA_ARGS__) 157 pst_debug_unlock(); \ 162 exit(EXIT_FAILURE); \ 165 #define DEBUG_WARN(x) MESSAGEPRINT3 x 166 #define DEBUG_INFO(x) MESSAGEPRINT2 x 167 #define DEBUG_HEXDUMP(x, s) pst_debug_hexdump(1, __LINE__, __FILE__, (char*)x, s, 0x10, 0) 168 #define DEBUG_HEXDUMPC(x, s, c) pst_debug_hexdump(1, __LINE__, __FILE__, (char*)x, s, c, 0) 171 #define DEBUG_ENT(x) \ 173 pst_debug_func(1, x); \ 174 pst_debug(1, __LINE__, __FILE__, "Entering function\n"); \ 176 #define DEBUG_RET() \ 178 pst_debug(1, __LINE__, __FILE__, "Leaving function\n"); \ 179 pst_debug_func_ret(1); \ 182 #define DEBUG_INIT(fname,mutex) {pst_debug_init(fname,mutex);} 183 #define DEBUG_CLOSE() {pst_debug_close();} 184 #define RET_DERROR(res, ret_val, x) if (res) { DIE(x);} 188 #if BYTE_ORDER == BIG_ENDIAN 189 # define LE64_CPU(x) \ 190 x = ((((x) & UINT64_C(0xff00000000000000)) >> 56) | \ 191 (((x) & UINT64_C(0x00ff000000000000)) >> 40) | \ 192 (((x) & UINT64_C(0x0000ff0000000000)) >> 24) | \ 193 (((x) & UINT64_C(0x000000ff00000000)) >> 8 ) | \ 194 (((x) & UINT64_C(0x00000000ff000000)) << 8 ) | \ 195 (((x) & UINT64_C(0x0000000000ff0000)) << 24) | \ 196 (((x) & UINT64_C(0x000000000000ff00)) << 40) | \ 197 (((x) & UINT64_C(0x00000000000000ff)) << 56)); 198 # define LE32_CPU(x) \ 199 x = ((((x) & 0xff000000) >> 24) | \ 200 (((x) & 0x00ff0000) >> 8 ) | \ 201 (((x) & 0x0000ff00) << 8 ) | \ 202 (((x) & 0x000000ff) << 24)); 203 # define LE16_CPU(x) \ 204 x = ((((x) & 0xff00) >> 8) | \ 205 (((x) & 0x00ff) << 8)); 206 #elif BYTE_ORDER == LITTLE_ENDIAN 207 # define LE64_CPU(x) {} 208 # define LE32_CPU(x) {} 209 # define LE16_CPU(x) {} 211 # error "Byte order not supported by this library" 215 #define PST_LE_GET_UINT64(p) \ 216 (uint64_t)((((uint8_t const *)(p))[0] << 0) | \ 217 (((uint8_t const *)(p))[1] << 8) | \ 218 (((uint8_t const *)(p))[2] << 16) | \ 219 (((uint8_t const *)(p))[3] << 24) | \ 220 (((uint8_t const *)(p))[4] << 32) | \ 221 (((uint8_t const *)(p))[5] << 40) | \ 222 (((uint8_t const *)(p))[6] << 48) | \ 223 (((uint8_t const *)(p))[7] << 56)) 225 #define PST_LE_GET_INT64(p) \ 226 (int64_t)((((uint8_t const *)(p))[0] << 0) | \ 227 (((uint8_t const *)(p))[1] << 8) | \ 228 (((uint8_t const *)(p))[2] << 16) | \ 229 (((uint8_t const *)(p))[3] << 24) | \ 230 (((uint8_t const *)(p))[4] << 32) | \ 231 (((uint8_t const *)(p))[5] << 40) | \ 232 (((uint8_t const *)(p))[6] << 48) | \ 233 (((uint8_t const *)(p))[7] << 56)) 235 #define PST_LE_GET_UINT32(p) \ 236 (uint32_t)((((uint8_t const *)(p))[0] << 0) | \ 237 (((uint8_t const *)(p))[1] << 8) | \ 238 (((uint8_t const *)(p))[2] << 16) | \ 239 (((uint8_t const *)(p))[3] << 24)) 241 #define PST_LE_GET_INT32(p) \ 242 (int32_t)((((uint8_t const *)(p))[0] << 0) | \ 243 (((uint8_t const *)(p))[1] << 8) | \ 244 (((uint8_t const *)(p))[2] << 16) | \ 245 (((uint8_t const *)(p))[3] << 24)) 247 #define PST_LE_GET_UINT16(p) \ 248 (uint16_t)((((uint8_t const *)(p))[0] << 0) | \ 249 (((uint8_t const *)(p))[1] << 8)) 251 #define PST_LE_GET_INT16(p) \ 252 (int16_t)((((uint8_t const *)(p))[0] << 0) | \ 253 (((uint8_t const *)(p))[1] << 8)) 255 #define PST_LE_GET_UINT8(p) (*(uint8_t const *)(p)) 257 #define PST_LE_GET_INT8(p) (*(int8_t const *)(p)) 259 #define MAXDATEFMTLEN 40
void pst_debug_func_ret(int level)
void pst_debug_hexdump(int level, int line, const char *file, const char *buf, size_t size, int cols, int delta)
void * pst_realloc(void *ptr, size_t size)
void pst_debug_init(const char *fname, void *output_mutex)
void pst_debug_hexdumper(FILE *out, const char *buf, size_t size, int cols, int delta)
void pst_debug_func(int level, const char *function)
void * pst_malloc(size_t size)
void pst_debug_setlevel(int level)
void pst_debug(int level, int line, const char *file, const char *fmt,...)