hamsterdb Embedded Database 1.1.14
|
00001 /* 00002 * Copyright (C) 2005-2010 Christoph Rupp (chris@crupp.de). 00003 * 00004 * This program is free software; you can redistribute it and/or modify it 00005 * under the terms of the GNU General Public License as published by the 00006 * Free Software Foundation; either version 2 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * See files COPYING.* for License information. 00010 */ 00011 00019 #ifndef HAM_TYPES_H__ 00020 #define HAM_TYPES_H__ 00021 00022 #ifdef __cplusplus 00023 extern "C" { 00024 #endif 00025 00026 /* 00027 * Check the operating system and word size 00028 */ 00029 #ifdef UNDER_CE 00030 # undef WIN32 00031 # define WIN32 1 00032 # define HAM_OS_WINCE 1 00033 #endif 00034 00035 #ifdef WIN32 00036 # undef HAM_OS_WIN32 00037 # define HAM_OS_WIN32 1 00038 # ifdef WIN64 00039 # undef HAM_64BIT 00040 # define HAM_64BIT 1 00041 # elif WIN32 00042 # undef HAM_32BIT 00043 # define HAM_32BIT 1 00044 # else 00045 # error "Neither WIN32 nor WIN64 defined!" 00046 # endif 00047 #else /* posix? */ 00048 # undef HAM_OS_POSIX 00049 # define HAM_OS_POSIX 1 00050 # if defined(__LP64__) || defined(__LP64) || __WORDSIZE==64 00051 # undef HAM_64BIT 00052 # define HAM_64BIT 1 00053 # else 00054 # undef HAM_32BIT 00055 # define HAM_32BIT 1 00056 # endif 00057 #endif 00058 00059 #if defined(HAM_OS_POSIX) && defined(HAM_OS_WIN32) 00060 # error "Unknown arch - neither HAM_OS_POSIX nor HAM_OS_WIN32 defined" 00061 #endif 00062 00063 /* 00064 * windows.h is needed for for HANDLE 00065 */ 00066 #if defined(HAM_OS_WIN32) 00067 # define WIN32_MEAN_AND_LEAN 00068 # include <windows.h> 00069 #endif 00070 00071 /* 00072 * improve memory debugging on WIN32 by using crtdbg.h (only MSVC 00073 * compiler and debug builds!) 00074 * 00075 * make sure crtdbg.h is loaded before malloc.h! 00076 */ 00077 #if defined(_MSC_VER) && defined(HAM_OS_WIN32) 00078 # if (defined(WIN32) || defined(__WIN32)) && !defined(UNDER_CE) 00079 # if defined(DEBUG) || defined(_DEBUG) 00080 # ifndef _CRTDBG_MAP_ALLOC 00081 # define _CRTDBG_MAP_ALLOC 1 00082 # endif 00083 # endif 00084 # include <crtdbg.h> 00085 # include <malloc.h> 00086 # endif 00087 #endif 00088 00089 /* 00090 * Create the EXPORT macro for Microsoft Visual C++ 00091 */ 00092 #ifndef HAM_EXPORT 00093 # ifdef _MSC_VER 00094 # define HAM_EXPORT __declspec(dllexport) 00095 # else 00096 # define HAM_EXPORT extern 00097 # endif 00098 #endif 00099 00100 /* 00101 * The default calling convention is cdecl 00102 */ 00103 #ifndef HAM_CALLCONV 00104 # define HAM_CALLCONV 00105 #endif 00106 00110 #ifdef HAM_32BIT 00111 # ifdef _MSC_VER 00112 typedef signed __int64 ham_s64_t; 00113 typedef unsigned __int64 ham_u64_t; 00114 # else 00115 typedef signed long long ham_s64_t; 00116 typedef unsigned long long ham_u64_t; 00117 # endif 00118 typedef signed int ham_s32_t; 00119 typedef unsigned int ham_u32_t; 00120 typedef signed short ham_s16_t; 00121 typedef unsigned short ham_u16_t; 00122 typedef signed char ham_s8_t; 00123 typedef unsigned char ham_u8_t; 00124 #endif 00125 00130 #ifdef HAM_64BIT 00131 # ifdef _MSC_VER 00132 typedef signed __int64 ham_s64_t; 00133 typedef unsigned __int64 ham_u64_t; 00134 # else 00135 typedef signed long ham_s64_t; 00136 typedef unsigned long ham_u64_t; 00137 # endif 00138 typedef signed int ham_s32_t; 00139 typedef unsigned int ham_u32_t; 00140 typedef signed short ham_s16_t; 00141 typedef unsigned short ham_u16_t; 00142 typedef signed char ham_s8_t; 00143 typedef unsigned char ham_u8_t; 00144 #endif 00145 00146 /* 00147 * Undefine macros to avoid macro redefinitions 00148 */ 00149 #undef HAM_INVALID_FD 00150 #undef HAM_FALSE 00151 #undef HAM_TRUE 00152 00153 /* 00154 * typedefs for posix 00155 */ 00156 #ifdef HAM_OS_POSIX 00157 typedef int ham_fd_t; 00158 # define HAM_INVALID_FD (-1) 00159 #endif 00160 00161 /* 00162 * typedefs for Windows 32- and 64-bit 00163 */ 00164 #ifdef HAM_OS_WIN32 00165 # ifdef CYGWIN 00166 typedef int ham_fd_t; 00167 # else 00168 typedef HANDLE ham_fd_t; 00169 # endif 00170 # define HAM_INVALID_FD (0) 00171 #endif 00172 00176 typedef int ham_bool_t; 00177 #define HAM_FALSE 0 00178 #define HAM_TRUE (!HAM_FALSE) 00179 00183 typedef int ham_status_t; 00184 00191 typedef ham_u64_t ham_offset_t; 00192 00199 typedef ham_u32_t ham_size_t; 00200 00204 #define HAM_MAX_U32 (~(ham_u32_t)0) 00205 #define HAM_MAX_SIZE_T (~(ham_size_t)0) 00206 00207 00208 #ifdef __cplusplus 00209 } // extern "C" 00210 #endif 00211 00212 #endif /* HAM_TYPES_H__ */