3 docCopyright("Steve Dekorte", 2002)
4 docLicense("BSD revised")
5 docDescription("This is a header that all other source files should include.")
9 These defines are helpful for doing OS specific checks in the code
12 #ifndef IOCOMMON_DEFINED
13 #define IOCOMMON_DEFINED 1
16 /*#define LOW_MEMORY_SYSTEM 1*/
22 #if defined (__SVR4) && defined (__sun)
24 #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)
26 #elif !defined(__SYMBIAN32__) && !defined(_MSC_VER) && !defined(__NeXT__)
29 typedef unsigned char uint8_t;
30 typedef signed char int8_t;
31 typedef unsigned short uint16_t;
32 typedef signed short int16_t;
33 typedef unsigned long uint32_t;
34 typedef signed long int32_t;
36 typedef unsigned long uint64_t;
37 typedef signed long int64_t;
39 typedef unsigned long long uint64_t;
40 typedef long long int64_t;
45 #if defined(WIN32) || defined(__WINS__) || defined(__MINGW32__) || defined(_MSC_VER)
46 #define inline __inline
47 #define snprintf _snprintf
48 #define usleep(x) Sleep(((x)+999)/1000)
55 #define _WIN32_WINNT 0x0400
57 // this also includes windows.h
60 #if !defined(__MINGW32__)
61 #if defined(BUILDING_BASEKIT_DLL) || defined(BUILDING_IOVMALL_DLL)
62 #define BASEKIT_API __declspec(dllexport)
64 #define BASEKIT_API __declspec(dllimport)
70 #ifndef _SYS_STDINT_H_
71 #include "PortableStdint.h"
75 #if !defined(__MINGW32__)
76 /* disable compile warnings which are always treated
77 as errors in my dev settings */
79 #pragma warning( disable : 4244 )
80 /* warning C4244: 'function' : conversion from 'double ' to 'int ', possible loss of data */
82 /*#pragma warning( disable : 4090 ) */
83 /* warning C4090: 'function' : different 'const' qualifiers */
85 /*#pragma warning( disable : 4024 )*/
86 /* warning C4024: different types for formal and actual parameter */
88 /*#pragma warning( disable : 4761 ) */
89 /* warning C4761: integral size mismatch in argument; conversion supplied */
91 /*#pragma warning( disable : 4047 ) */
92 /* warning C4047: '=' : 'char *' differs in levels of indirection from 'int ' */
93 #define ARCHITECTURE_x86 1
96 /* io_malloc, io_realloc, io_free undefined */
97 #if !defined(__SYMBIAN32__)
100 /* strlen undefined */
102 #include <malloc.h> /* for calloc */
106 // Not on windows so define this away
114 DBCS (Short for Double-Byte Character Set), a character set that uses two-byte (16-bit) characters. Some languages, such as Chinese, Japanese and Korean (CJK), have writing schemes with many different characters that cannot be represented with single-byte codes such as ASCII and EBCDIC.
116 In CJK world, CES (Character Encoding Scheme) and CCS (Coded Character Set) are actually different concept(one CES may contain multiple CCS).
117 For example, EUC-JP is a CES which includes CCS of ASCII and JIS X 0208 (optionally JIS X 0201 Kana and JIS X 0212).
119 In Japanese (because I am Japanese),
120 While EUC-JP and UTF-8 Map ASCII unchanged, ShiftJIS not (However ShiftJIS is de facto standard in Japan). For example, {0x95, 0x5c} represents one character. in ASCII, second byte(0x5c) is back slash character.
124 check whether double-byte character. supported only ShiftJIS.
125 if you want to use ShiftJIS characters in string literal, set compiler option -DDBCS_ENABLED=1.
129 #define ismbchar(c) ISSJIS((unsigned char)c)
130 #define mbcharlen(c) 2
131 #define ISSJIS(c) ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc))
133 #define ismbchar(c) 0
134 #define mbcharlen(c) 1
135 #endif /* DBCS_ENABLED */
141 //#define IO_CHECK_ALLOC
143 #ifdef IO_CHECK_ALLOC
144 BASEKIT_API
size_t io_memsize(void *ptr
);
146 #define io_malloc(size) io_real_malloc(size, __FILE__, __LINE__)
147 BASEKIT_API
void *io_real_malloc(size_t size
, char *file
, int line
);
149 #define io_calloc(count, size) io_real_calloc(count, size, __FILE__, __LINE__)
150 BASEKIT_API
void *io_real_calloc(size_t count
, size_t size
, char *file
, int line
);
152 #define io_realloc(ptr, size) io_real_realloc(ptr, size, __FILE__, __LINE__)
153 BASEKIT_API
void *io_real_realloc(void *ptr
, size_t newSize
, char *file
, int line
);
155 BASEKIT_API
void io_free(void *ptr
);
156 BASEKIT_API
void io_show_mem(char *s
);
157 BASEKIT_API
size_t io_maxAllocatedBytes(void);
158 BASEKIT_API
void io_resetMaxAllocatedBytes(void);
159 BASEKIT_API
size_t io_frees(void);
160 BASEKIT_API
size_t io_allocs(void);
161 BASEKIT_API
size_t io_allocatedBytes(void);
163 BASEKIT_API
void io_showUnfreed(void);
166 #define io_malloc malloc
167 #define io_calloc calloc
168 #define io_realloc io_freerealloc
172 #define io_maxAllocatedBytes() 0
174 #define io_allocs() 0
175 #define io_allocatedBytes() 0
176 #define io_resetMaxAllocatedBytes()
179 BASEKIT_API
void *cpalloc(const void *p
, size_t size
);
180 BASEKIT_API
void *io_freerealloc(void *p
, size_t size
);