1 /* 2 * This file is part of the zlog Library. 3 * 4 * Copyright (C) 2011 by Hardy Simpson <HardySimpson1984@gmail.com> 5 * 6 * Licensed under the LGPL v2.1, see the file COPYING in base directory. 7 */ 8 #ifndef __zc_xplatform_h 9 #define __zc_xplatform_h 10 11 #include <limits.h> 12 13 #define ZLOG_INT32_LEN sizeof("-2147483648") - 1 14 #define ZLOG_INT64_LEN sizeof("-9223372036854775808") - 1 15 16 #if ((__GNU__ == 2) && (__GNUC_MINOR__ < 8)) 17 #define ZLOG_MAX_UINT32_VALUE (uint32_t) 0xffffffffLL 18 #else 19 #define ZLOG_MAX_UINT32_VALUE (uint32_t) 0xffffffff 20 #endif 21 22 #define ZLOG_MAX_INT32_VALUE (uint32_t) 0x7fffffff 23 24 #define MAXLEN_PATH 1024 25 #define MAXLEN_CFG_LINE (MAXLEN_PATH * 4) 26 27 #define FILE_NEWLINE "\n" 28 #define FILE_NEWLINE_LEN 1 29 30 #include <string.h> 31 #include <strings.h> 32 33 #define STRCMP(_a_,_C_,_b_) ( strcmp(_a_,_b_) _C_ 0 ) 34 #define STRNCMP(_a_,_C_,_b_,_n_) ( strncmp(_a_,_b_,_n_) _C_ 0 ) 35 #define STRICMP(_a_,_C_,_b_) ( strcasecmp(_a_,_b_) _C_ 0 ) 36 #define STRNICMP(_a_,_C_,_b_,_n_) ( strncasecmp(_a_,_b_,_n_) _C_ 0 ) 37 38 39 #ifdef __APPLE__ 40 #include <AvailabilityMacros.h> 41 #endif 42 43 /* Define zlog_fstat to fstat or fstat64() */ 44 #if defined(__APPLE__) && !defined(MAC_OS_X_VERSION_10_6) 45 #define zlog_fstat fstat64 46 #define zlog_stat stat64 47 #else 48 #define zlog_fstat fstat 49 #define zlog_stat stat 50 #endif 51 52 /* Define zlog_fsync to fdatasync() in Linux and fsync() for all the rest */ 53 #ifdef __linux__ 54 #define zlog_fsync fdatasync 55 #else 56 #define zlog_fsync fsync 57 #endif 58 59 60 61 #endif 62