home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 September / INTERNET107.ISO / pc / software / windows / building / mysql / data1.cab / Development / include / config-win.h next >
Encoding:
C/C++ Source or Header  |  2003-05-17  |  9.9 KB  |  325 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. #define HAVE_BROKEN_NETINET_INCLUDES
  134. #ifdef __NT__
  135. #define HAVE_NAMED_PIPE            /* We can only create pipes on NT */
  136. #endif
  137.  
  138. /* We need to close files to break connections on shutdown */
  139. #ifndef SIGNAL_WITH_VIO_CLOSE
  140. #define SIGNAL_WITH_VIO_CLOSE
  141. #endif
  142.  
  143. /* Use all character sets in MySQL */
  144. #define USE_MB 1
  145. #define USE_MB_IDENT 1
  146. #define USE_STRCOLL 1
  147.  
  148. /* If LOAD DATA LOCAL INFILE should be enabled by default */
  149. #define ENABLED_LOCAL_INFILE 1
  150.  
  151. /* Convert some simple functions to Posix */
  152.  
  153. #define sigset(A,B) signal((A),(B))
  154. #define finite(A) _finite(A)
  155. #define sleep(A)  Sleep((A)*1000)
  156.  
  157. #ifndef __BORLANDC__
  158. #define access(A,B) _access(A,B)
  159. #endif
  160.  
  161. #if defined(__cplusplus)
  162.  
  163. inline double rint(double nr)
  164. {
  165.   double f = floor(nr);
  166.   double c = ceil(nr);
  167.   return (((c-nr) >= (nr-f)) ? f :c);
  168. }
  169.  
  170. #ifdef _WIN64
  171. #define ulonglong2double(A) ((double) (A))
  172. #define my_off_t2double(A)  ((double) (A))
  173.  
  174. #else
  175. inline double ulonglong2double(ulonglong value)
  176. {
  177.   longlong nr=(longlong) value;
  178.   if (nr >= 0)
  179.     return (double) nr;
  180.   return (18446744073709551616.0 + (double) nr);
  181. }
  182. #define my_off_t2double(A) ulonglong2double(A)
  183. #endif /* _WIN64 */
  184. #else
  185. #define inline __inline
  186. #endif /* __cplusplus */
  187.  
  188. #if SIZEOF_OFF_T > 4
  189. #define lseek(A,B,C) _lseeki64((A),(longlong) (B),(C))
  190. #define tell(A) _telli64(A)
  191. #endif
  192.  
  193. #define set_timespec(ABSTIME,SEC) { (ABSTIME).tv_sec=time((time_t*)0) + (time_t) (SEC); (ABSTIME).tv_nsec=0; }
  194.  
  195. #define STACK_DIRECTION -1
  196.  
  197. /* Optimized store functions for Intel x86 */
  198.  
  199. #define sint2korr(A)    (*((int16 *) (A)))
  200. #define sint3korr(A)    ((int32) ((((uchar) (A)[2]) & 128) ? \
  201.                   (((uint32) 255L << 24) | \
  202.                    (((uint32) (uchar) (A)[2]) << 16) |\
  203.                    (((uint32) (uchar) (A)[1]) << 8) | \
  204.                    ((uint32) (uchar) (A)[0])) : \
  205.                   (((uint32) (uchar) (A)[2]) << 16) |\
  206.                   (((uint32) (uchar) (A)[1]) << 8) | \
  207.                   ((uint32) (uchar) (A)[0])))
  208. #define sint4korr(A)    (*((long *) (A)))
  209. #define uint2korr(A)    (*((uint16 *) (A)))
  210. #define uint3korr(A)    (long) (*((unsigned long *) (A)) & 0xFFFFFF)
  211. #define uint4korr(A)    (*((unsigned long *) (A)))
  212. #define uint5korr(A)    ((ulonglong)(((uint32) ((uchar) (A)[0])) +\
  213.                     (((uint32) ((uchar) (A)[1])) << 8) +\
  214.                     (((uint32) ((uchar) (A)[2])) << 16) +\
  215.                     (((uint32) ((uchar) (A)[3])) << 24)) +\
  216.                     (((ulonglong) ((uchar) (A)[4])) << 32))
  217. #define uint8korr(A)    (*((ulonglong *) (A)))
  218. #define sint8korr(A)    (*((longlong *) (A)))
  219. #define int2store(T,A)    *((uint16*) (T))= (uint16) (A)
  220. #define int3store(T,A)        { *(T)=  (uchar) ((A));\
  221.                   *(T+1)=(uchar) (((uint) (A) >> 8));\
  222.                   *(T+2)=(uchar) (((A) >> 16)); }
  223. #define int4store(T,A)    *((long *) (T))= (long) (A)
  224. #define int5store(T,A)    { *(T)= (uchar)((A));\
  225.               *((T)+1)=(uchar) (((A) >> 8));\
  226.               *((T)+2)=(uchar) (((A) >> 16));\
  227.               *((T)+3)=(uchar) (((A) >> 24)); \
  228.               *((T)+4)=(uchar) (((A) >> 32)); }
  229. #define int8store(T,A)    *((ulonglong *) (T))= (ulonglong) (A)
  230.  
  231. #define doubleget(V,M)    { *((long *) &V) = *((long*) M); \
  232.               *(((long *) &V)+1) = *(((long*) M)+1); }
  233. #define doublestore(T,V) { *((long *) T) = *((long*) &V); \
  234.                *(((long *) T)+1) = *(((long*) &V)+1); }
  235. #define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); }
  236. #define float8get(V,M) doubleget((V),(M))
  237. #define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float))
  238. #define float8store(V,M) doublestore((V),(M))
  239.  
  240.  
  241. #define HAVE_PERROR
  242. #define HAVE_VFPRINT
  243. #define HAVE_CHSIZE        /* System has chsize() function */
  244. #define HAVE_RENAME        /* Have rename() as function */
  245. #define HAVE_BINARY_STREAMS    /* Have "b" flag in streams */
  246. #define HAVE_LONG_JMP        /* Have long jump function */
  247. #define HAVE_LOCKING        /* have locking() call */
  248. #define HAVE_ERRNO_AS_DEFINE    /* errno is a define */
  249. #define HAVE_STDLIB        /* everything is include in this file */
  250. #define HAVE_MEMCPY
  251. #define HAVE_MEMMOVE
  252. #define HAVE_GETCWD
  253. #define HAVE_TELL
  254. #define HAVE_TZNAME
  255. #define HAVE_PUTENV
  256. #define HAVE_SELECT
  257. #define HAVE_SETLOCALE
  258. #define HAVE_SOCKET        /* Giangi */
  259. #define HAVE_FLOAT_H
  260. #define HAVE_LIMITS_H
  261. #define HAVE_STDDEF_H
  262. #define HAVE_RINT        /* defined in this file */
  263. #define NO_FCNTL_NONBLOCK    /* No FCNTL */
  264. #define HAVE_ALLOCA
  265. #define HAVE_STRPBRK
  266. #define HAVE_STRSTR
  267. #define HAVE_COMPRESS
  268. #define HAVE_CREATESEMAPHORE
  269. #define HAVE_ISNAN
  270. #define HAVE_FINITE
  271. #define HAVE_ISAM        /* We want to have support for ISAM in 4.0 */
  272. #define HAVE_QUERY_CACHE
  273. #define SPRINTF_RETURNS_INT
  274.  
  275. #ifdef NOT_USED
  276. #define HAVE_SNPRINTF        /* Gave link error */
  277. #define _snprintf snprintf
  278. #endif
  279.  
  280. #ifdef _MSC_VER
  281. #define HAVE_LDIV        /* The optimizer breaks in zortech for ldiv */
  282. #define HAVE_ANSI_INCLUDE
  283. #define HAVE_SYS_UTIME_H
  284. #define HAVE_STRTOUL
  285. #endif
  286. #define my_reinterpret_cast(A) reinterpret_cast <A>
  287. #define my_const_cast(A) const_cast<A>
  288.  
  289.  
  290. /* MYSQL OPTIONS */
  291.  
  292. #ifdef _CUSTOMCONFIG_
  293. #include <custom_conf.h>
  294. #else
  295. #define DEFAULT_MYSQL_HOME    "c:\\mysql"
  296. #define PACKAGE            "mysql"
  297. #define DEFAULT_BASEDIR        "C:\\"
  298. #define SHAREDIR        "share"
  299. #define DEFAULT_CHARSET_HOME    "C:/mysql/"
  300. #endif
  301.  
  302. /* File name handling */
  303.  
  304. #define FN_LIBCHAR    '\\'
  305. #define FN_ROOTDIR    "\\"
  306. #define FN_NETWORK_DRIVES    /* Uses \\ to indicate network drives */
  307. #define FN_NO_CASE_SENCE    /* Files are not case-sensitive */
  308. #define MY_NFILE    1024
  309.  
  310. #define DO_NOT_REMOVE_THREAD_WRAPPERS
  311. #define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
  312. /* The following is only used for statistics, so it should be good enough */
  313. #ifdef __NT__  /* This should also work on Win98 but .. */
  314. #define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
  315. #define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
  316. #define statistic_add(V,C,L) thread_safe_add((V),(C),(L))
  317. #else
  318. #define thread_safe_add(V,C,L) \
  319.     pthread_mutex_lock((L)); (V)+=(C); pthread_mutex_unlock((L));
  320. #define thread_safe_sub(V,C,L) \
  321.     pthread_mutex_lock((L)); (V)-=(C); pthread_mutex_unlock((L));
  322. #define statistic_add(V,C,L)     (V)+=(C)
  323. #endif
  324. #define statistic_increment(V,L) thread_safe_increment((V),(L))
  325.