1919
2020/* This is the include file that should be included 'first' in every C file. */
2121
22+ #include " my_config.h"
23+
24+ #ifdef _WIN32
25+ /* Include common headers.*/
26+ # include < winsock2.h>
27+ # include < ws2tcpip.h> /* SOCKET */
28+ # include < io.h> /* access(), chmod() */
29+ # include < process.h> /* getpid() */
30+ #endif
31+
32+ /*
33+ Temporary solution to solve bug#7156. Include "sys/types.h" before
34+ the thread headers, else the function madvise() will not be defined
35+ */
36+ #include < sys/types.h>
37+
38+ #if !defined(_WIN32)
39+ # include < pthread.h>
40+ # include < dlfcn.h>
41+ #endif
42+
43+ #include < stdio.h>
44+ #include < stdarg.h>
45+ #include < stdlib.h>
46+ #include < stddef.h>
47+ #include < math.h>
48+ #include < limits.h>
49+ #include < float.h>
50+ #include < fenv.h> /* For fesetround() */
51+ #include < fcntl.h>
52+ #include < time.h>
53+ #include < errno.h> /* Recommended by debian */
54+
55+ #if TIME_WITH_SYS_TIME
56+ # include < sys/time.h>
57+ #endif
58+ #ifdef HAVE_UNISTD_H
59+ # include < unistd.h>
60+ #endif
61+ #ifdef HAVE_ALLOCA_H
62+ # include < alloca.h>
63+ #endif
64+ /* We need the following to go around a problem with openssl on solaris */
65+ #if defined(HAVE_CRYPT_H)
66+ # include < crypt.h>
67+ #endif
68+ #ifdef HAVE_SYS_SOCKET_H
69+ # include < sys/socket.h>
70+ #endif
71+
72+ /*
73+ A lot of our programs uses asserts, so better to always include it
74+ This also fixes a problem when people uses DBUG_ASSERT without including
75+ assert.h
76+ */
77+ #include < assert.h>
78+
79+ /* Include standard definitions of operator new and delete. */
80+ #ifdef __cplusplus
81+ # include < new>
82+ #endif
83+
84+ #include " my_compiler.h"
85+
86+
2287/*
2388 InnoDB depends on some MySQL internals which other plugins should not
2489 need. This is because of InnoDB's foreign key support, "safe" binlog
39104#define C_MODE_END
40105#endif
41106
42- #include < my_config.h>
43- #include " my_compiler.h"
44-
45107#ifdef WITH_PERFSCHEMA_STORAGE_ENGINE
46108#define HAVE_PSI_INTERFACE
47109#endif /* WITH_PERFSCHEMA_STORAGE_ENGINE */
62124#undef SIZEOF_OFF_T
63125#define SIZEOF_OFF_T 8
64126
65- /* Include common headers.*/
66- #include < winsock2.h>
67- #include < ws2tcpip.h> /* SOCKET */
68- #include < io.h> /* access(), chmod() */
69- #include < process.h> /* getpid() */
70-
71127#define sleep (a ) Sleep((a)*1000 )
72128
73129/* Define missing access() modes. */
86142#define default_shared_memory_base_name " MYSQL"
87143#endif /* _WIN32*/
88144
89- /*
90- The macros below are borrowed from include/linux/compiler.h in the
91- Linux kernel. Use them to indicate the likelyhood of the truthfulness
92- of a condition. This serves two purposes - newer versions of gcc will be
93- able to optimize for branch predication, which could yield siginficant
94- performance gains in frequently executed sections of the code, and the
95- other reason to use them is for documentation
96- */
97- #ifdef HAVE_BUILTIN_EXPECT
98- # define likely (x ) __builtin_expect((x),1 )
99- # define unlikely (x ) __builtin_expect((x),0 )
100- #else
101- # define likely (x ) (x)
102- # define unlikely (x ) (x)
103- #endif
104-
105- /*
106- Temporary solution to solve bug#7156. Include "sys/types.h" before
107- the thread headers, else the function madvise() will not be defined
108- */
109- #if defined(sun) || defined(__sun)
110- #include < sys/types.h>
111- #endif
112-
113- /*
114- Solaris 9 include file <sys/feature_tests.h> refers to X/Open document
115-
116- System Interfaces and Headers, Issue 5
117-
118- saying we should define _XOPEN_SOURCE=500 to get POSIX.1c prototypes,
119- but apparently other systems (namely FreeBSD) don't agree.
120-
121- On a newer Solaris 10, the above file recognizes also _XOPEN_SOURCE=600.
122- Furthermore, it tests that if a program requires older standard
123- (_XOPEN_SOURCE<600 or _POSIX_C_SOURCE<200112L) it cannot be
124- run on a new compiler (that defines _STDC_C99) and issues an #error.
125- It's also an #error if a program requires new standard (_XOPEN_SOURCE=600
126- or _POSIX_C_SOURCE=200112L) and a compiler does not define _STDC_C99.
127-
128- To add more to this mess, Sun Studio C compiler defines _STDC_C99 while
129- C++ compiler does not!
130-
131- So, in a desperate attempt to get correct prototypes for both
132- C and C++ code, we define either _XOPEN_SOURCE=600 or _XOPEN_SOURCE=500
133- depending on the compiler's announced C standard support.
134-
135- Cleaner solutions are welcome.
136- */
137- #ifdef __sun
138- #if __STDC_VERSION__ - 0 >= 199901L
139- #define _XOPEN_SOURCE 600
140- #else
141- #define _XOPEN_SOURCE 500
142- #endif
143- #endif
144-
145- #if !defined(_WIN32)
146- #include < pthread.h>
147- #endif /* !defined(_WIN32) */
148-
149- #include < stdio.h>
150- #include < stdarg.h>
151- #include < stdlib.h>
152- #include < stddef.h>
153-
154- #include < math.h>
155- #include < limits.h>
156- #include < float.h>
157- #include < fenv.h> /* For fesetround() */
158-
159- #include < sys/types.h>
160- #include < fcntl.h>
161- #if TIME_WITH_SYS_TIME
162- # include < sys/time.h>
163- #endif
164- #include < time.h>
165- #ifdef HAVE_UNISTD_H
166- #include < unistd.h>
167- #endif
168- #ifdef HAVE_ALLOCA_H
169- #include < alloca.h>
170- #endif
171-
172- #include < errno.h> /* Recommended by debian */
173- /* We need the following to go around a problem with openssl on solaris */
174- #if defined(HAVE_CRYPT_H)
175- #include < crypt.h>
176- #endif
177-
178145/* *
179146 Cast a member of a structure to the structure that contains it.
180147
185152#define my_container_of (ptr, type, member ) \
186153 ((type *)((char *)ptr - offsetof(type, member)))
187154
188- /*
189- A lot of our programs uses asserts, so better to always include it
190- This also fixes a problem when people uses DBUG_ASSERT without including
191- assert.h
192- */
193- #include < assert.h>
194-
195155/* an assert that works at compile-time. only for constant expression */
196156#define compile_time_assert (X ) \
197157 do \
@@ -253,9 +213,6 @@ C_MODE_START
253213typedef int (*qsort_cmp)(const void *,const void *);
254214typedef int (*qsort_cmp2)(const void *, const void *,const void *);
255215C_MODE_END
256- #ifdef HAVE_SYS_SOCKET_H
257- #include < sys/socket.h>
258- #endif
259216#ifdef _WIN32
260217typedef int socket_len_t ;
261218typedef int sigset_t ;
@@ -391,7 +348,7 @@ typedef socket_len_t SOCKET_SIZE_TYPE; /* Used by NDB */
391348
392349/* Some defines of functions for portability */
393350
394- #if (_MSC_VER )
351+ #if (_WIN32 )
395352#if !defined(_WIN64)
396353inline double my_ulonglong2double (unsigned long long value)
397354{
@@ -412,7 +369,7 @@ inline unsigned long long my_double2ulonglong(double d)
412369 return (unsigned long long ) d;
413370}
414371#define double2ulonglong my_double2ulonglong
415- #endif
372+ #endif /* _WIN32 */
416373
417374#ifndef ulonglong2double
418375#define ulonglong2double (A ) ((double ) (ulonglong) (A))
@@ -451,8 +408,6 @@ inline unsigned long long my_double2ulonglong(double d)
451408#define SIZE_T_MAX (~((size_t ) 0 ))
452409#endif
453410
454- #include < math.h>
455-
456411#if (__cplusplus >= 201103L)
457412 /* For C++11 use the new std functions rather than C99 macros. */
458413 #include < cmath>
@@ -673,19 +628,10 @@ typedef char my_bool; /* Small bool */
673628#define dlopen_errno GetLastError ()
674629
675630#else /* _WIN32 */
676- #include < dlfcn.h>
677631#define DLERROR_GENERATE (errmsg, error_number ) errmsg= dlerror()
678632#define dlopen_errno errno
679633#endif /* _WIN32 */
680634
681-
682- /*
683- * Include standard definitions of operator new and delete.
684- */
685- #ifdef __cplusplus
686- #include < new>
687- #endif
688-
689635/* Length of decimal number represented by INT32. */
690636#define MY_INT32_NUM_DECIMAL_DIGITS 11U
691637
@@ -708,11 +654,6 @@ typedef char my_bool; /* Small bool */
708654#define bool In_C_you_should_use_my_bool_instead ()
709655#endif
710656
711- /* Provide __func__ macro definition for Visual Studio. */
712- #if defined(_MSC_VER)
713- # define __func__ __FUNCTION__
714- #endif
715-
716657/*
717658 MYSQL_PLUGIN_IMPORT macro is used to export mysqld data
718659 (i.e variables) for usage in storage engine loadable plugins.
0 commit comments