1 /* Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB
2 This file is public domain and comes with NO WARRANTY of any kind */
3 
4 /* Defines for Win32 to make it compatible for MySQL */
5 
6 #ifndef _MYSQLND_CONFIG_WIN_H
7 #define _MYSQLND_CONFIG_WIN_H
8 
9 #include <sys/locking.h>
10 #include <windows.h>
11 #include <math.h>			/* Because of rint() */
12 #include <fcntl.h>
13 #include <io.h>
14 #include <malloc.h>
15 
16 #include <stdint.h>
17 
18 #ifndef HAVE_INT8_T
19 #define HAVE_INT8_T
20 #endif
21 #ifndef HAVE_UINT8_T
22 #define HAVE_UINT8_T
23 #endif
24 #ifndef HAVE_INT16_T
25 #define HAVE_INT16_T
26 #endif
27 #ifndef HAVE_UINT16_T
28 #define HAVE_UINT16_T
29 #endif
30 #ifndef HAVE_INT32_T
31 #define HAVE_INT32_T
32 #endif
33 #ifndef HAVE_UINT32_T
34 #define HAVE_UINT32_T
35 #endif
36 #ifndef HAVE_INT64_T
37 #define HAVE_INT64_T
38 #endif
39 #ifndef HAVE_UINT64_T
40 #define HAVE_UINT64_T
41 #endif
42 
43 
44 #ifndef _WIN64
45 #ifndef _WIN32
46 #define _WIN32				/* Compatible with old source */
47 #endif
48 #ifndef __WIN32__
49 #define __WIN32__
50 #endif
51 #endif /* _WIN64 */
52 #ifndef __WIN__
53 #define __WIN__				/* To make it easier in VC++ */
54 #endif
55 
56 /* Type information */
57 
58 #define SIZEOF_LONG		4
59 #define SIZEOF_LONG_LONG	8
60 
61 
62 #ifndef _WIN64
63 /* Optimized store functions for Intel x86 */
64 
65 #define sint2korr(A)	(*((int16_t *) (A)))
66 #define sint3korr(A)	((int32_t) ((((zend_uchar) (A)[2]) & 128) ? \
67 										(((uint32_t) 255L << 24) | \
68 										(((uint32_t) (zend_uchar) (A)[2]) << 16) |\
69 										(((uint32_t) (zend_uchar) (A)[1]) << 8) | \
70 										((uint32_t) (zend_uchar) (A)[0])) : \
71 										(((uint32_t) (zend_uchar) (A)[2]) << 16) |\
72 										(((uint32_t) (zend_uchar) (A)[1]) << 8) | \
73 										((uint32_t) (zend_uchar) (A)[0])))
74 #define sint4korr(A)	(*((int32_t *) (A)))
75 #define uint2korr(A)	(*((uint16_t *) (A)))
76 #define uint3korr(A)	(int32_t) (*((uint32_t *) (A)) & 0xFFFFFF)
77 #define uint4korr(A)	(*((uint32_t *) (A)))
78 #define uint5korr(A)	((uint64_t)(((uint32_t) ((zend_uchar) (A)[0])) +\
79 									(((uint32_t) ((zend_uchar) (A)[1])) << 8) +\
80 									(((uint32_t) ((zend_uchar) (A)[2])) << 16) +\
81 									(((uint32_t) ((zend_uchar) (A)[3])) << 24)) +\
82 									(((uint64_t) ((zend_uchar) (A)[4])) << 32))
83 #define uint8korr(A)	(*((uint64_t *) (A)))
84 #define sint8korr(A)	(*((int64_t *) (A)))
85 #define int2store(T,A)	*((uint16_t*) (T))= (uint16_t) (A)
86 #define int3store(T,A)		{	*(T)=  (zend_uchar) ((A));\
87 								*(T+1)=(zend_uchar) (((uint32_t) (A) >> 8));\
88 								*(T+2)=(zend_uchar) (((A) >> 16)); }
89 #define int4store(T,A)	*((int32_t *) (T))= (int32_t) (A)
90 #define int5store(T,A)	{	*(T)= (zend_uchar)((A));\
91 							*((T)+1)=(zend_uchar) (((A) >> 8));\
92 							*((T)+2)=(zend_uchar) (((A) >> 16));\
93 							*((T)+3)=(zend_uchar) (((A) >> 24)); \
94 							*((T)+4)=(zend_uchar) (((A) >> 32)); }
95 #define int8store(T,A)	*((uint64_t *) (T))= (uint64_t) (A)
96 
97 #define float8get(V,M)	{	*((int32_t *) &V) = *((int32_t*) M); \
98 							*(((int32_t *) &V)+1) = *(((int32_t*) M)+1); }
99 #define float8store(T,V) {	*((int32_t *) T) = *((int32_t*) &V); \
100 							*(((int32_t *) T)+1) = *(((int32_t*) &V)+1); }
101 #define float4get(V,M) { *((int32_t *) &(V)) = *((int32_t*) (M)); }
102 
103 #endif /* _WIN64 */
104 
105 #endif /* _MYSQLND_CONFIG_WIN_H */
106