home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 Autumn / INTERNET109.ISO / pc / software / windows / building / mysql / data1.cab / Development / include / config-win.h next >
Encoding:
C/C++ Source or Header  |  2003-08-03  |  9.6 KB  |  330 lines

  1. /* Copyright (C) 2000 MySQL AB
  2.  
  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 2 of the License, or
  6.    (at your option) any later version.
  7.  
  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU General Public License
  14.    along with this program; if not, write to the Free Software
  15.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  16.  
  17. /* Defines for Win32 to make it compatible for MySQL */
  18.  
  19. #include <sys/locking.h>
  20. #include <windows.h>
  21. #include <math.h>            /* Because of rint() */
  22. #include <fcntl.h>
  23. #include <io.h>
  24. #include <malloc.h>
  25.  
  26. #if defined(__NT__)
  27. #define SYSTEM_TYPE    "NT"
  28. #elif defined(__WIN2000__)
  29. #define SYSTEM_TYPE    "WIN2000"
  30. #else
  31. #define SYSTEM_TYPE    "Win95/Win98"
  32. #endif
  33.  
  34. #if defined(_WIN64) || defined(WIN64)
  35. #define MACHINE_TYPE    "ia64"        /* Define to machine type name */
  36. #else
  37. #define MACHINE_TYPE    "i32"        /* Define to machine type name */
  38. #ifndef _WIN32
  39. #define _WIN32                /* Compatible with old source */
  40. #endif
  41. #ifndef __WIN32__
  42. #define __WIN32__
  43. #endif
  44. #endif /* _WIN64 */
  45. #ifndef __WIN__
  46. #define __WIN__                  /* To make it easier in VC++ */
  47. #endif
  48.  
  49. /* File and lock constants */
  50. #define O_SHARE        0x1000        /* Open file in sharing mode */
  51. #ifdef __BORLANDC__
  52. #define F_RDLCK        LK_NBLCK    /* read lock */
  53. #define F_WRLCK        LK_NBRLCK    /* write lock */
  54. #define F_UNLCK        LK_UNLCK    /* remove lock(s) */
  55. #else
  56. #define F_RDLCK        _LK_NBLCK    /* read lock */
  57. #define F_WRLCK        _LK_NBRLCK    /* write lock */
  58. #define F_UNLCK        _LK_UNLCK    /* remove lock(s) */
  59. #endif
  60.  
  61. #define F_EXCLUSIVE    1        /* We have only exclusive locking */
  62. #define F_TO_EOF    (INT_MAX32/2)    /* size for lock of all file */
  63. #define F_OK        0        /* parameter to access() */
  64.  
  65. #define S_IROTH        S_IREAD        /* for my_lib */
  66.  
  67. #ifdef __BORLANDC__
  68. #define FILE_BINARY    O_BINARY    /* my_fopen in binary mode */
  69. #define O_TEMPORARY    0
  70. #define O_SHORT_LIVED    0
  71. #define SH_DENYNO    _SH_DENYNO
  72. #else
  73. #define O_BINARY    _O_BINARY    /* compability with MSDOS */
  74. #define FILE_BINARY    _O_BINARY    /* my_fopen in binary mode */
  75. #define O_TEMPORARY    _O_TEMPORARY
  76. #define O_SHORT_LIVED    _O_SHORT_LIVED
  77. #define SH_DENYNO    _SH_DENYNO
  78. #endif
  79. #define NO_OPEN_3            /* For my_create() */
  80.  
  81. #define SIGQUIT        SIGTERM        /* No SIGQUIT */
  82.  
  83. #undef _REENTRANT            /* Crashes something for win32 */
  84. #undef SAFE_MUTEX            /* Can't be used on windows */
  85.  
  86. #define LONGLONG_MIN    ((__int64) 0x8000000000000000)
  87. #define LONGLONG_MAX    ((__int64) 0x7FFFFFFFFFFFFFFF)
  88. #define LL(A)        ((__int64) A)
  89.  
  90. /* Type information */
  91.  
  92. typedef unsigned short    ushort;
  93. typedef unsigned int    uint;
  94. typedef unsigned __int64 ulonglong;    /* Microsofts 64 bit types */
  95. typedef __int64 longlong;
  96. typedef int sigset_t;
  97. #define longlong_defined
  98. /* off_t should not be __int64 because of conflicts in header files;
  99.    Use my_off_t or os_off_t instead */
  100. typedef long off_t;
  101. typedef __int64 os_off_t;
  102. #ifdef _WIN64
  103. typedef UINT_PTR rf_SetTimer;
  104. #else
  105. typedef unsigned int size_t;
  106. typedef uint rf_SetTimer;
  107. #endif
  108.  
  109. #define Socket_defined
  110. #define my_socket SOCKET
  111. #define bool BOOL
  112. #define SIGPIPE SIGINT
  113. #define RETQSORTTYPE void
  114. #define QSORT_TYPE_IS_VOID
  115. #define RETSIGTYPE void
  116. #define SOCKET_SIZE_TYPE int
  117. #define my_socket_defined
  118. #define bool_defined
  119. #define byte_defined
  120. #define HUGE_PTR
  121. #define STDCALL __stdcall        /* Used by libmysql.dll */
  122. #define isnan(X) _isnan(X)
  123. #define finite(X) _finite(X)
  124.  
  125. #ifndef UNDEF_THREAD_HACK
  126. #define THREAD
  127. #endif
  128. #define VOID_SIGHANDLER
  129. #define SIZEOF_CHAR        1
  130. #define SIZEOF_LONG        4
  131. #define SIZEOF_LONG_LONG    8
  132. #define SIZEOF_OFF_T        8
  133. #ifdef _WIN64
  134. #define SIZEOF_CHARP        8
  135. #else
  136. #define SIZEOF_CHARP        4
  137. #endif
  138. #define HAVE_BROKEN_NETINET_INCLUDES
  139. #ifdef __NT__
  140. #define HAVE_NAMED_PIPE            /* We can only create pipes on NT */
  141. #endif
  142.  
  143. /* We need to close files to break connections on shutdown */
  144. #ifndef SIGNAL_WITH_VIO_CLOSE
  145. #define SIGNAL_WITH_VIO_CLOSE
  146. #endif
  147.  
  148. /* Use all character sets in MySQL */
  149. #define USE_MB 1
  150. #define USE_MB_IDENT 1
  151. #define USE_STRCOLL 1
  152.  
  153. /* If LOAD DATA LOCAL INFILE should be enabled by default */
  154. #define ENABLED_LOCAL_INFILE 1
  155.  
  156. /* Convert some simple functions to Posix */
  157.  
  158. #define sigset(A,B) signal((A),(B))
  159. #define finite(A) _finite(A)
  160. #define sleep(A)  Sleep((A)*1000)
  161.  
  162. #ifndef __BORLANDC__
  163. #define access(A,B) _access(A,B)
  164. #endif
  165.  
  166. #if defined(__cplusplus)
  167.  
  168. inline double rint(double nr)
  169. {
  170.   double f = floor(nr);
  171.   double c = ceil(nr);
  172.   return (((c-nr) >= (nr-f)) ? f :c);
  173. }
  174.  
  175. #ifdef _WIN64
  176. #define ulonglong2double(A) ((double) (A))
  177. #define my_off_t2double(A)  ((double) (A))
  178.  
  179. #else
  180. inline double ulonglong2double(ulonglong value)
  181. {
  182.   longlong nr=(longlong) value;
  183.   if (nr >= 0)
  184.     return (double) nr;
  185.   return (18446744073709551616.0 + (double) nr);
  186. }
  187. #define my_off_t2double(A) ulonglong2double(A)
  188. #endif /* _WIN64 */
  189. #else
  190. #define inline __inline
  191. #endif /* __cplusplus */
  192.  
  193. #if SIZEOF_OFF_T > 4
  194. #define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
  195. #define tell(A) _telli64(A)
  196. #endif
  197.  
  198. #define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; }
  199.  
  200. #define STACK_DIRECTION -1
  201.  
  202. /* Optimized store functions for Intel x86 */
  203.  
  204. #ifndef _WIN64
  205. #define sint2korr(A)    (*((int16 *) (A)))
  206. #define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
  207.                   (((uint32) 255L << 24) | \
  208.                    (((uint32) (uchar) (A)[2]) << 16) |\
  209.                    (((uint32) (uchar) (A)[1]) << 8) | \
  210.                    ((uint32) (uchar) (A)[0])) : \
  211.                   (((uint32) (uchar) (A)[2]) << 16) |\
  212.                   (((uint32) (uchar) (A)[1]) << 8) | \
  213.                   ((uint32) (uchar) (A)[0])))
  214. #define sint4korr(A)    (*((long *) (A)))
  215. #define uint2korr(A)    (*((uint16 *) (A)))
  216. #define uint3korr(A)    (long) (*((unsigned long *) (A)) & 0xFFFFFF)
  217. #define uint4korr(A)    (*((unsigned long *) (A)))
  218. #define uint5korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
  219.                     (((uint32) ((uchar) (A)[1])) << 8) +\
  220.                     (((uint32) ((uchar) (A)[2])) << 16) +\
  221.                     (((uint32) ((uchar) (A)[3])) << 24)) +\
  222.                     (((ulonglong) ((uchar) (A)[4])) << 32))
  223. #define uint8korr(A)    (*((ulonglong *) (A)))
  224. #define sint8korr(A)    (*((longlong *) (A)))
  225. #define int2store(T,A)    *((uint16*) (T))= (uint16) (A)
  226. #define int3store(T,A)        { *(T)=  (uchar) ((A));\
  227.                   *(T+1)=(uchar) (((uint) (A) >> 8));\
  228.                   *(T+2)=(uchar) (((A) >> 16)); }
  229. #define int4store(T,A)    *((long *) (T))= (long) (A)
  230. #define int5store(T,A)    { *(T)= (uchar)((A));\
  231.               *((T)+1)=(uchar) (((A) >> 8));\
  232.               *((T)+2)=(uchar) (((A) >> 16));\
  233.               *((T)+3)=(uchar) (((A) >> 24)); \
  234.               *((T)+4)=(uchar) (((A) >> 32)); }
  235. #define int8store(T,A)    *((ulonglong *) (T))= (ulonglong) (A)
  236.  
  237. #define doubleget(V,M)    { *((long *) &V) = *((long*) M); \
  238.               *(((long *) &V)+1) = *(((long*) M)+1); }
  239. #define doublestore(T,V) { *((long *) T) = *((long*) &V); \
  240.                *(((long *) T)+1) = *(((long*) &V)+1); }
  241. #define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
  242. #define float8get(V,M) doubleget((V),(M))
  243. #define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
  244. #define float8store(V,M) doublestore((V),(M))
  245. #endif /* _WIN64 */
  246.  
  247. #define HAVE_PERROR
  248. #define HAVE_VFPRINT
  249. #define HAVE_RENAME        /* Have rename() as function */
  250. #define HAVE_BINARY_STREAMS    /* Have "b" flag in streams */
  251. #define HAVE_LONG_JMP        /* Have long jump function */
  252. #define HAVE_LOCKING        /* have locking() call */
  253. #define HAVE_ERRNO_AS_DEFINE    /* errno is a define */
  254. #define HAVE_STDLIB        /* everything is include in this file */
  255. #define HAVE_MEMCPY
  256. #define HAVE_MEMMOVE
  257. #define HAVE_GETCWD
  258. #define HAVE_TELL
  259. #define HAVE_TZNAME
  260. #define HAVE_PUTENV
  261. #define HAVE_SELECT
  262. #define HAVE_SETLOCALE
  263. #define HAVE_SOCKET        /* Giangi */
  264. #define HAVE_FLOAT_H
  265. #define HAVE_LIMITS_H
  266. #define HAVE_STDDEF_H
  267. #define HAVE_RINT        /* defined in this file */
  268. #define NO_FCNTL_NONBLOCK    /* No FCNTL */
  269. #define HAVE_ALLOCA
  270. #define HAVE_STRPBRK
  271. #define HAVE_STRSTR
  272. #define HAVE_COMPRESS
  273. #define HAVE_CREATESEMAPHORE
  274. #define HAVE_ISNAN
  275. #define HAVE_FINITE
  276. #define HAVE_ISAM        /* We want to have support for ISAM in 4.0 */
  277. #define HAVE_QUERY_CACHE
  278. #define SPRINTF_RETURNS_INT
  279.  
  280. #ifdef NOT_USED
  281. #define HAVE_SNPRINTF        /* Gave link error */
  282. #define _snprintf snprintf
  283. #endif
  284.  
  285. #ifdef _MSC_VER
  286. #define HAVE_LDIV        /* The optimizer breaks in zortech for ldiv */
  287. #define HAVE_ANSI_INCLUDE
  288. #define HAVE_SYS_UTIME_H
  289. #define HAVE_STRTOUL
  290. #endif
  291. #define my_reinterpret_cast(A) reinterpret_cast <A>
  292. #define my_const_cast(A) const_cast<A>
  293.  
  294.  
  295. /* MYSQL OPTIONS */
  296.  
  297. #ifdef _CUSTOMCONFIG_
  298. #include <custom_conf.h>
  299. #else
  300. #define DEFAULT_MYSQL_HOME    "c:\\mysql"
  301. #define PACKAGE            "mysql"
  302. #define DEFAULT_BASEDIR        "C:\\"
  303. #define SHAREDIR        "share"
  304. #define DEFAULT_CHARSET_HOME    "C:/mysql/"
  305. #endif
  306.  
  307. /* File name handling */
  308.  
  309. #define FN_LIBCHAR    '\\'
  310. #define FN_ROOTDIR    "\\"
  311. #define FN_NETWORK_DRIVES    /* Uses \\ to indicate network drives */
  312. #define FN_NO_CASE_SENCE    /* Files are not case-sensitive */
  313. #define MY_NFILE    1024
  314.  
  315. #define DO_NOT_REMOVE_THREAD_WRAPPERS
  316. #define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
  317. /* The following is only used for statistics, so it should be good enough */
  318. #ifdef __NT__  /* This should also work on Win98 but .. */
  319. #define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
  320. #define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
  321. #define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
  322. #else
  323. #define thread_safe_add(V,C,L) \
  324.     pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
  325. #define thread_safe_sub(V,C,L) \
  326.     pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
  327. #define statistic_add(V,C,L)     (V)+=(C)
  328. #endif
  329. #define statistic_increment(V,L) thread_safe_increment((V),(L))
  330.