rc_compat.h (2086B)
1 #ifndef RC_COMPAT_H 2 #define RC_COMPAT_H 3 4 #include "rc_export.h" 5 6 #include <stdio.h> 7 #include <stdlib.h> 8 #include <string.h> 9 10 RC_BEGIN_C_DECLS 11 12 #if defined(MINGW) || defined(__MINGW32__) || defined(__MINGW64__) 13 14 /* MinGW redefinitions */ 15 16 #define RC_NO_VARIADIC_MACROS 1 17 18 #elif defined(_MSC_VER) 19 20 /* Visual Studio redefinitions */ 21 22 #ifndef strcasecmp 23 #define strcasecmp _stricmp 24 #endif 25 #ifndef strncasecmp 26 #define strncasecmp _strnicmp 27 #endif 28 #ifndef strdup 29 #define strdup _strdup 30 #endif 31 32 #elif __STDC_VERSION__ < 199901L 33 34 /* C89 redefinitions */ 35 #define RC_C89_HELPERS 1 36 37 #define RC_NO_VARIADIC_MACROS 1 38 39 #ifndef snprintf 40 extern int rc_snprintf(char* buffer, size_t size, const char* format, ...); 41 #define snprintf rc_snprintf 42 #endif 43 44 #ifndef strncasecmp 45 extern int rc_strncasecmp(const char* left, const char* right, size_t length); 46 #define strncasecmp rc_strncasecmp 47 #endif 48 49 #ifndef strcasecmp 50 extern int rc_strcasecmp(const char* left, const char* right); 51 #define strcasecmp rc_strcasecmp 52 #endif 53 54 #ifndef strdup 55 extern char* rc_strdup(const char* str); 56 #define strdup rc_strdup 57 #endif 58 59 #endif /* __STDC_VERSION__ < 199901L */ 60 61 #ifndef __STDC_WANT_SECURE_LIB__ 62 /* _CRT_SECURE_NO_WARNINGS redefinitions */ 63 #define strcpy_s(dest, sz, src) strcpy(dest, src) 64 #define sscanf_s sscanf 65 66 /* NOTE: Microsoft secure gmtime_s parameter order differs from C11 standard */ 67 #include <time.h> 68 extern struct tm* rc_gmtime_s(struct tm* buf, const time_t* timer); 69 #define gmtime_s rc_gmtime_s 70 #endif 71 72 #ifdef RC_NO_THREADS 73 typedef int rc_mutex_t; 74 75 #define rc_mutex_init(mutex) 76 #define rc_mutex_destroy(mutex) 77 #define rc_mutex_lock(mutex) 78 #define rc_mutex_unlock(mutex) 79 #else 80 #ifdef _WIN32 81 typedef struct rc_mutex_t { 82 void* handle; /* HANDLE is defined as "void*" */ 83 } rc_mutex_t; 84 #else 85 #include <pthread.h> 86 typedef pthread_mutex_t rc_mutex_t; 87 #endif 88 89 void rc_mutex_init(rc_mutex_t* mutex); 90 void rc_mutex_destroy(rc_mutex_t* mutex); 91 void rc_mutex_lock(rc_mutex_t* mutex); 92 void rc_mutex_unlock(rc_mutex_t* mutex); 93 #endif 94 95 RC_END_C_DECLS 96 97 #endif /* RC_COMPAT_H */