00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef IOCOMMON_DEFINED
00011 #define IOCOMMON_DEFINED 1
00012
00013
00014 #include <stdlib.h>
00015 #include <string.h>
00016 #include <stddef.h>
00017
00018
00019 #if defined (__SVR4) && defined (__sun)
00020 #include <inttypes.h>
00021 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
00022 #include <inttypes.h>
00023 #elif !defined(__SYMBIAN32__) && !defined(_MSC_VER) && !defined(__NeXT__)
00024 #include <stdint.h>
00025 #else
00026 typedef unsigned char uint8_t;
00027 typedef signed char int8_t;
00028 typedef unsigned short uint16_t;
00029 typedef signed short int16_t;
00030 typedef unsigned long uint32_t;
00031 typedef signed long int32_t;
00032
00033
00034
00035
00036 typedef unsigned long long uint64_t;
00037 typedef long long int64_t;
00038 #endif
00039
00040
00041
00042 #if defined(WIN32) || defined(__WINS__) || defined(__MINGW32__) || defined(_MSC_VER)
00043 #define inline __inline
00044 #define snprintf _snprintf
00045 #define usleep(x) Sleep(((x)+999)/1000)
00046
00047 #define HAS_FIBERS 1
00048
00049 #define ON_WINDOWS 1
00050
00051
00052 #include <winsock2.h>
00053
00054
00055 #ifndef _WIN32_WINNT
00056 #define _WIN32_WINNT 0x0400
00057 #endif
00058
00059 #if !defined(__MINGW32__)
00060 #if defined(BUILDING_BASEKIT_DLL) || defined(BUILDING_IOVMALL_DLL)
00061 #define BASEKIT_API __declspec(dllexport)
00062 #else
00063 #define BASEKIT_API __declspec(dllimport)
00064 #endif
00065 #else
00066 #define BASEKIT_API
00067 #endif
00068
00069
00070
00071
00072
00073
00074 #if !defined(__MINGW32__)
00075
00076
00077
00078 #pragma warning( disable : 4244 )
00079
00080
00081 #pragma warning( disable : 4996 )
00082
00083
00084 #pragma warning( disable : 4018 )
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098 #define ARCHITECTURE_x86 1
00099 #endif
00100
00101
00102 #if !defined(__SYMBIAN32__)
00103 #include <memory.h>
00104
00105
00106 #include <string.h>
00107 #include <malloc.h>
00108 #endif
00109 #else
00110
00111
00112 #define BASEKIT_API
00113
00114 #endif
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133 #if DBCS_ENABLED
00134 #define ismbchar(c) ISSJIS((unsigned char)c)
00135 #define mbcharlen(c) 2
00136 #define ISSJIS(c) ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc))
00137 #else
00138 #define ismbchar(c) 0
00139 #define mbcharlen(c) 1
00140 #endif
00141
00142 #ifdef __cplusplus
00143 extern "C" {
00144 #endif
00145
00146
00147
00148 #ifdef IO_CHECK_ALLOC
00149 BASEKIT_API size_t io_memsize(void *ptr);
00150
00151 #define io_malloc(size) io_real_malloc(size, __FILE__, __LINE__)
00152 BASEKIT_API void *io_real_malloc(size_t size, char *file, int line);
00153
00154 #define io_calloc(count, size) io_real_calloc(count, size, __FILE__, __LINE__)
00155 BASEKIT_API void *io_real_calloc(size_t count, size_t size, char *file, int line);
00156
00157 #define io_realloc(ptr, size) io_real_realloc(ptr, size, __FILE__, __LINE__)
00158 BASEKIT_API void *io_real_realloc(void *ptr, size_t newSize, char *file, int line);
00159
00160 BASEKIT_API void io_free(void *ptr);
00161 BASEKIT_API void io_show_mem(char *s);
00162 BASEKIT_API size_t io_maxAllocatedBytes(void);
00163 BASEKIT_API void io_resetMaxAllocatedBytes(void);
00164 BASEKIT_API size_t io_frees(void);
00165 BASEKIT_API size_t io_allocs(void);
00166 BASEKIT_API size_t io_allocatedBytes(void);
00167
00168 BASEKIT_API void io_showUnfreed(void);
00169 #else
00170 #define io_memsize
00171 #define io_malloc malloc
00172 #define io_calloc calloc
00173 #define io_realloc io_freerealloc
00174 #define io_free free
00175 #define io_show_mem
00176
00177 #define io_maxAllocatedBytes() 0
00178 #define io_frees() 0
00179 #define io_allocs() 0
00180 #define io_allocatedBytes() 0
00181 #define io_resetMaxAllocatedBytes()
00182 #endif
00183
00184 BASEKIT_API void *cpalloc(const void *p, size_t size);
00185 BASEKIT_API void *io_freerealloc(void *p, size_t size);
00186
00187 int io_isBigEndian(void);
00188 BASEKIT_API uint32_t io_uint32InBigEndian(uint32_t i);
00189
00190 #ifdef __cplusplus
00191 }
00192 #endif
00193
00194 #endif
00195
00196
00197