Eneboo - Documentación para desarrolladores
|
00001 /* Copyright (C) 2000 MySQL AB 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ 00016 00017 /* Defines for Win32 to make it compatible for MySQL */ 00018 00019 #ifdef __WIN2000__ 00020 /* We have to do this define before including windows.h to get the AWE API 00021 functions */ 00022 #define _WIN32_WINNT 0x0500 00023 #endif 00024 00025 #include <sys/locking.h> 00026 #include <windows.h> 00027 #include <math.h> /* Because of rint() */ 00028 #include <fcntl.h> 00029 #include <io.h> 00030 #include <malloc.h> 00031 00032 #define HAVE_SMEM 1 00033 00034 #if defined(_WIN64) || defined(WIN64) 00035 #define SYSTEM_TYPE "Win64" 00036 #elif defined(_WIN32) || defined(WIN32) 00037 #define SYSTEM_TYPE "Win32" 00038 #else 00039 #define SYSTEM_TYPE "Windows" 00040 #endif 00041 00042 #if defined(_M_IA64) 00043 #define MACHINE_TYPE "ia64" 00044 #elif defined(_M_IX86) 00045 #define MACHINE_TYPE "ia32" 00046 #elif defined(_M_ALPHA) 00047 #define MACHINE_TYPE "axp" 00048 #else 00049 #define MACHINE_TYPE "unknown" /* Define to machine type name */ 00050 #endif 00051 00052 #if !(defined(_WIN64) || defined(WIN64)) 00053 #ifndef _WIN32 00054 #define _WIN32 /* Compatible with old source */ 00055 #endif 00056 #ifndef __WIN32__ 00057 #define __WIN32__ 00058 #endif 00059 #endif /* _WIN64 */ 00060 #ifndef __WIN__ 00061 #define __WIN__ /* To make it easier in VC++ */ 00062 #endif 00063 00064 /* File and lock constants */ 00065 #define O_SHARE 0x1000 /* Open file in sharing mode */ 00066 #ifdef __BORLANDC__ 00067 #define F_RDLCK LK_NBLCK /* read lock */ 00068 #define F_WRLCK LK_NBRLCK /* write lock */ 00069 #define F_UNLCK LK_UNLCK /* remove lock(s) */ 00070 #else 00071 #define F_RDLCK _LK_NBLCK /* read lock */ 00072 #define F_WRLCK _LK_NBRLCK /* write lock */ 00073 #define F_UNLCK _LK_UNLCK /* remove lock(s) */ 00074 #endif 00075 00076 #define F_EXCLUSIVE 1 /* We have only exclusive locking */ 00077 #define F_TO_EOF (INT_MAX32/2) /* size for lock of all file */ 00078 #define F_OK 0 /* parameter to access() */ 00079 00080 #define S_IROTH S_IREAD /* for my_lib */ 00081 00082 #ifdef __BORLANDC__ 00083 #define FILE_BINARY O_BINARY /* my_fopen in binary mode */ 00084 #define O_TEMPORARY 0 00085 #define O_SHORT_LIVED 0 00086 #define SH_DENYNO _SH_DENYNO 00087 #else 00088 #define O_BINARY _O_BINARY /* compability with MSDOS */ 00089 #define FILE_BINARY _O_BINARY /* my_fopen in binary mode */ 00090 #define O_TEMPORARY _O_TEMPORARY 00091 #define O_SHORT_LIVED _O_SHORT_LIVED 00092 #define SH_DENYNO _SH_DENYNO 00093 #endif 00094 #define NO_OPEN_3 /* For my_create() */ 00095 00096 #define SIGQUIT SIGTERM /* No SIGQUIT */ 00097 00098 #undef _REENTRANT /* Crashes something for win32 */ 00099 #undef SAFE_MUTEX /* Can't be used on windows */ 00100 00101 #define LONGLONG_MIN ((__int64) 0x8000000000000000) 00102 #define LONGLONG_MAX ((__int64) 0x7FFFFFFFFFFFFFFF) 00103 #define ULONGLONG_MAX ((unsigned __int64) 0xFFFFFFFFFFFFFFFF) 00104 #define LL(A) ((__int64) A) 00105 #define ULL(A) ((unsigned __int64) A) 00106 00107 /* Type information */ 00108 00109 #if defined(__EMX__) || !defined(HAVE_UINT) 00110 #undef HAVE_UINT 00111 #define HAVE_UINT 00112 typedef unsigned short ushort; 00113 typedef unsigned int uint; 00114 #endif /* defined(__EMX__) || !defined(HAVE_UINT) */ 00115 00116 typedef unsigned __int64 ulonglong; /* Microsofts 64 bit types */ 00117 typedef __int64 longlong; 00118 #ifndef HAVE_SIGSET_T 00119 typedef int sigset_t; 00120 #endif 00121 #define longlong_defined 00122 /* 00123 off_t should not be __int64 because of conflicts in header files; 00124 Use my_off_t or os_off_t instead 00125 */ 00126 #ifndef HAVE_OFF_T 00127 typedef long off_t; 00128 #endif 00129 typedef __int64 os_off_t; 00130 #ifdef _WIN64 00131 typedef UINT_PTR rf_SetTimer; 00132 #else 00133 #ifndef HAVE_SIZE_T 00134 typedef unsigned int size_t; 00135 #endif 00136 typedef uint rf_SetTimer; 00137 #endif 00138 00139 #define Socket_defined 00140 #define my_socket SOCKET 00141 #define bool BOOL 00142 #define SIGPIPE SIGINT 00143 #define RETQSORTTYPE void 00144 #define QSORT_TYPE_IS_VOID 00145 #define RETSIGTYPE void 00146 #define SOCKET_SIZE_TYPE int 00147 #define my_socket_defined 00148 #define bool_defined 00149 #define byte_defined 00150 #define HUGE_PTR 00151 #define STDCALL __stdcall /* Used by libmysql.dll */ 00152 #define isnan(X) _isnan(X) 00153 #define finite(X) _finite(X) 00154 00155 #ifndef UNDEF_THREAD_HACK 00156 #define THREAD 00157 #endif 00158 #define VOID_SIGHANDLER 00159 #define SIZEOF_CHAR 1 00160 #define SIZEOF_LONG 4 00161 #define SIZEOF_LONG_LONG 8 00162 #define SIZEOF_OFF_T 8 00163 #ifdef _WIN64 00164 #define SIZEOF_CHARP 8 00165 #else 00166 #define SIZEOF_CHARP 4 00167 #endif 00168 #define HAVE_BROKEN_NETINET_INCLUDES 00169 #ifdef __NT__ 00170 #define HAVE_NAMED_PIPE /* We can only create pipes on NT */ 00171 #endif 00172 00173 /* ERROR is defined in wingdi.h */ 00174 #undef ERROR 00175 00176 /* We need to close files to break connections on shutdown */ 00177 #ifndef SIGNAL_WITH_VIO_CLOSE 00178 #define SIGNAL_WITH_VIO_CLOSE 00179 #endif 00180 00181 /* Use all character sets in MySQL */ 00182 #define USE_MB 1 00183 #define USE_MB_IDENT 1 00184 #define USE_STRCOLL 1 00185 00186 /* All windows servers should support .sym files */ 00187 #undef USE_SYMDIR 00188 #define USE_SYMDIR 00189 00190 /* If LOAD DATA LOCAL INFILE should be enabled by default */ 00191 #define ENABLED_LOCAL_INFILE 1 00192 00193 /* Convert some simple functions to Posix */ 00194 00195 #define sigset(A,B) signal((A),(B)) 00196 #define finite(A) _finite(A) 00197 #define sleep(A) Sleep((A)*1000) 00198 #define popen(A) popen(A,B) _popen((A),(B)) 00199 #define pclose(A) _pclose(A) 00200 00201 #ifndef __BORLANDC__ 00202 #define access(A,B) _access(A,B) 00203 #endif 00204 00205 #if !defined(__cplusplus) 00206 #define inline __inline 00207 #endif /* __cplusplus */ 00208 00209 inline double rint(double nr) 00210 { 00211 double f = floor(nr); 00212 double c = ceil(nr); 00213 return (((c-nr) >= (nr-f)) ? f :c); 00214 } 00215 00216 #ifdef _WIN64 00217 #define ulonglong2double(A) ((double) (ulonglong) (A)) 00218 #define my_off_t2double(A) ((double) (my_off_t) (A)) 00219 00220 #else 00221 inline double ulonglong2double(ulonglong value) 00222 { 00223 longlong nr=(longlong) value; 00224 if (nr >= 0) 00225 return (double) nr; 00226 return (18446744073709551616.0 + (double) nr); 00227 } 00228 #define my_off_t2double(A) ulonglong2double(A) 00229 #endif /* _WIN64 */ 00230 00231 #if SIZEOF_OFF_T > 4 00232 #define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C)) 00233 #define tell(A) _telli64(A) 00234 #endif 00235 00236 #define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; } 00237 00238 #define STACK_DIRECTION -1 00239 00240 /* Optimized store functions for Intel x86 */ 00241 00242 #ifndef _WIN64 00243 #define sint2korr(A) (*((int16 *) (A))) 00244 #define sint3korr(A) ((int32) ((((uchar) (A)[2]) & 128) ? \ 00245 (((uint32) 255L << 24) | \ 00246 (((uint32) (uchar) (A)[2]) << 16) |\ 00247 (((uint32) (uchar) (A)[1]) << 8) | \ 00248 ((uint32) (uchar) (A)[0])) : \ 00249 (((uint32) (uchar) (A)[2]) << 16) |\ 00250 (((uint32) (uchar) (A)[1]) << 8) | \ 00251 ((uint32) (uchar) (A)[0]))) 00252 #define sint4korr(A) (*((long *) (A))) 00253 #define uint2korr(A) (*((uint16 *) (A))) 00254 /* 00255 ATTENTION ! 00256 00257 Please, note, uint3korr reads 4 bytes (not 3) ! 00258 It means, that you have to provide enough allocated space ! 00259 */ 00260 #define uint3korr(A) (long) (*((unsigned int *) (A)) & 0xFFFFFF) 00261 #define uint4korr(A) (*((unsigned long *) (A))) 00262 #define uint5korr(A) ((ulonglong)(((uint32) ((uchar) (A)[0])) +\ 00263 (((uint32) ((uchar) (A)[1])) << 8) +\ 00264 (((uint32) ((uchar) (A)[2])) << 16) +\ 00265 (((uint32) ((uchar) (A)[3])) << 24)) +\ 00266 (((ulonglong) ((uchar) (A)[4])) << 32)) 00267 #define uint8korr(A) (*((ulonglong *) (A))) 00268 #define sint8korr(A) (*((longlong *) (A))) 00269 #define int2store(T,A) *((uint16*) (T))= (uint16) (A) 00270 #define int3store(T,A) { *(T)= (uchar) ((A));\ 00271 *(T+1)=(uchar) (((uint) (A) >> 8));\ 00272 *(T+2)=(uchar) (((A) >> 16)); } 00273 #define int4store(T,A) *((long *) (T))= (long) (A) 00274 #define int5store(T,A) { *(T)= (uchar)((A));\ 00275 *((T)+1)=(uchar) (((A) >> 8));\ 00276 *((T)+2)=(uchar) (((A) >> 16));\ 00277 *((T)+3)=(uchar) (((A) >> 24)); \ 00278 *((T)+4)=(uchar) (((A) >> 32)); } 00279 #define int8store(T,A) *((ulonglong *) (T))= (ulonglong) (A) 00280 00281 #define doubleget(V,M) { *((long *) &V) = *((long*) M); \ 00282 *(((long *) &V)+1) = *(((long*) M)+1); } 00283 #define doublestore(T,V) { *((long *) T) = *((long*) &V); \ 00284 *(((long *) T)+1) = *(((long*) &V)+1); } 00285 #define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); } 00286 #define floatget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(float)) 00287 #define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float)) 00288 #define float8get(V,M) doubleget((V),(M)) 00289 #define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) 00290 #define float8store(V,M) doublestore((V),(M)) 00291 #endif /* _WIN64 */ 00292 00293 #define HAVE_PERROR 00294 #define HAVE_VFPRINT 00295 #define HAVE_RENAME /* Have rename() as function */ 00296 #define HAVE_BINARY_STREAMS /* Have "b" flag in streams */ 00297 #define HAVE_LONG_JMP /* Have long jump function */ 00298 #define HAVE_LOCKING /* have locking() call */ 00299 #define HAVE_ERRNO_AS_DEFINE /* errno is a define */ 00300 #define HAVE_STDLIB /* everything is include in this file */ 00301 #define HAVE_MEMCPY 00302 #define HAVE_MEMMOVE 00303 #define HAVE_GETCWD 00304 #define HAVE_TELL 00305 #define HAVE_TZNAME 00306 #define HAVE_PUTENV 00307 #define HAVE_SELECT 00308 #define HAVE_SETLOCALE 00309 #define HAVE_SOCKET /* Giangi */ 00310 #define HAVE_FLOAT_H 00311 #define HAVE_LIMITS_H 00312 #define HAVE_STDDEF_H 00313 #define HAVE_RINT /* defined in this file */ 00314 #define NO_FCNTL_NONBLOCK /* No FCNTL */ 00315 #define HAVE_ALLOCA 00316 #define HAVE_STRPBRK 00317 #define HAVE_STRSTR 00318 #define HAVE_COMPRESS 00319 #define HAVE_CREATESEMAPHORE 00320 #define HAVE_ISNAN 00321 #define HAVE_FINITE 00322 #define HAVE_QUERY_CACHE 00323 #define SPRINTF_RETURNS_INT 00324 #define HAVE_SETFILEPOINTER 00325 #define HAVE_VIO 00326 00327 #ifdef NOT_USED 00328 #define HAVE_SNPRINTF /* Gave link error */ 00329 #define _snprintf snprintf 00330 #endif 00331 00332 #ifdef _MSC_VER 00333 #define HAVE_LDIV /* The optimizer breaks in zortech for ldiv */ 00334 #define HAVE_ANSI_INCLUDE 00335 #define HAVE_SYS_UTIME_H 00336 #define HAVE_STRTOUL 00337 #endif 00338 #define my_reinterpret_cast(A) reinterpret_cast <A> 00339 #define my_const_cast(A) const_cast<A> 00340 00341 00342 /* MYSQL OPTIONS */ 00343 00344 #ifdef _CUSTOMCONFIG_ 00345 #include <custom_conf.h> 00346 #else 00347 #define DEFAULT_MYSQL_HOME "c:\\" 00348 #define DATADIR "c:\\" 00349 #define PACKAGE "mysql" 00350 #define DEFAULT_BASEDIR "c:\\" 00351 #define SHAREDIR "share" 00352 #define DEFAULT_CHARSET_HOME "c:/" 00353 #endif 00354 00355 /* File name handling */ 00356 00357 #define FN_LIBCHAR '\\' 00358 #define FN_ROOTDIR "\\" 00359 #define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */ 00360 #define FN_NO_CASE_SENCE /* Files are not case-sensitive */ 00361 #define OS_FILE_LIMIT 2048 00362 00363 #define DO_NOT_REMOVE_THREAD_WRAPPERS 00364 #define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V)) 00365 /* The following is only used for statistics, so it should be good enough */ 00366 #ifdef __NT__ /* This should also work on Win98 but .. */ 00367 #define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C)) 00368 #define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C)) 00369 #define statistic_add(V,C,L) thread_safe_add((V),(C),(L)) 00370 #else 00371 #define thread_safe_add(V,C,L) \ 00372 pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L)); 00373 #define thread_safe_sub(V,C,L) \ 00374 pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L)); 00375 #define statistic_add(V,C,L) (V)+=(C) 00376 #endif 00377 #define statistic_increment(V,L) thread_safe_increment((V),(L)) 00378 00379 #define shared_memory_buffer_length 16000 00380 #define default_shared_memory_base_name "MYSQL" 00381 #define MYSQL_DEFAULT_CHARSET_NAME "latin1" 00382 #define MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci" 00383 00384 #define HAVE_SPATIAL 1 00385 #define HAVE_RTREE_KEYS 1 00386 00387 /* Define charsets you want */ 00388 /* #undef HAVE_CHARSET_armscii8 */ 00389 /* #undef HAVE_CHARSET_ascii */ 00390 #define HAVE_CHARSET_big5 1 00391 #define HAVE_CHARSET_cp1250 1 00392 /* #undef HAVE_CHARSET_cp1251 */ 00393 /* #undef HAVE_CHARSET_cp1256 */ 00394 /* #undef HAVE_CHARSET_cp1257 */ 00395 /* #undef HAVE_CHARSET_cp850 */ 00396 /* #undef HAVE_CHARSET_cp852 */ 00397 /* #undef HAVE_CHARSET_cp866 */ 00398 #define HAVE_CHARSET_cp932 1 00399 /* #undef HAVE_CHARSET_dec8 */ 00400 #define HAVE_CHARSET_euckr 1 00401 #define HAVE_CHARSET_gb2312 1 00402 #define HAVE_CHARSET_gbk 1 00403 /* #undef HAVE_CHARSET_greek */ 00404 /* #undef HAVE_CHARSET_hebrew */ 00405 /* #undef HAVE_CHARSET_hp8 */ 00406 /* #undef HAVE_CHARSET_keybcs2 */ 00407 /* #undef HAVE_CHARSET_koi8r */ 00408 /* #undef HAVE_CHARSET_koi8u */ 00409 #define HAVE_CHARSET_latin1 1 00410 #define HAVE_CHARSET_latin2 1 00411 /* #undef HAVE_CHARSET_latin5 */ 00412 /* #undef HAVE_CHARSET_latin7 */ 00413 /* #undef HAVE_CHARSET_macce */ 00414 /* #undef HAVE_CHARSET_macroman */ 00415 #define HAVE_CHARSET_sjis 1 00416 /* #undef HAVE_CHARSET_swe7 */ 00417 #define HAVE_CHARSET_tis620 1 00418 #define HAVE_CHARSET_ucs2 1 00419 #define HAVE_CHARSET_ujis 1 00420 #define HAVE_CHARSET_utf8 1 00421 #define HAVE_UCA_COLLATIONS 1 00422