Skip to content

Commit 21bc817

Browse files
committed
Bug#18404381: REMOVE UNNEEDE CMAKE CHECKS AND #IFDEFS IN 5.7.5
Patch mysql#4: This patch does the following: - Removes HAVE_PATHS_H since paths.h is not needed - Removes unused HAVE_FP_EXCEPT - Moves some compiler related code from my_global.h to my_compiler.h - Reorganizes #includes in my_global.h, removes some duplicates - Removes definition of _XOPEN_SOURCE, no longer needed - Replaces BACKSLASH_MBTAIL and BASKSLASH_MBTAIL (typo...) with _WIN32 - Removes HAVE_CHSIZE, NO_OPEN_3, SOLARIS and NO_CLIENT_LONGLONG, never defined - Removes workaround for ancient FreeBSD bug, no longer relevant - Removes pthread_attr_setstacksize check, function always exists - HAVE_FEDISABLEEXCEPT is always true on FreeBSD - Removes THD::signals, never used - Removes THD::query_start_used, set but never read - Removes checks for old versions of Sun Studio - DTrace workarounds for old versions of GCC.
1 parent d46ed3f commit 21bc817

24 files changed

+110
-305
lines changed

cmake/dtrace.cmake

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,13 @@
1313
# along with this program; if not, write to the Free Software
1414
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
1515

16-
IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_COMPILER_IS_GNUCXX
17-
AND CMAKE_SIZEOF_VOID_P EQUAL 4)
18-
IF(NOT DEFINED BUGGY_GCC_NO_DTRACE_MODULES)
19-
EXECUTE_PROCESS(
20-
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} --version
21-
OUTPUT_VARIABLE out)
22-
IF(out MATCHES "3.4.6")
23-
# This gcc causes crashes in dlopen() for dtraced shared libs,
24-
# while standard shipped with Solaris10 3.4.3 is ok
25-
SET(BUGGY_GCC_NO_DTRACE_MODULES 1 CACHE INTERNAL "")
26-
ELSE()
27-
SET(BUGGY_GCC_NO_DTRACE_MODULES 0 CACHE INTERNAL "")
28-
ENDIF()
29-
ENDIF()
30-
ENDIF()
31-
3216
# Check if OS supports DTrace
3317
MACRO(CHECK_DTRACE)
3418
FIND_PROGRAM(DTRACE dtrace)
3519
MARK_AS_ADVANCED(DTRACE)
3620

3721
# On FreeBSD, dtrace does not handle userland tracing yet
38-
IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD"
39-
AND NOT BUGGY_GCC_NO_DTRACE_MODULES)
22+
IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
4023
SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace")
4124
ENDIF()
4225
SET(HAVE_DTRACE ${ENABLE_DTRACE})
@@ -91,12 +74,6 @@ IF(ENABLE_DTRACE)
9174
ENDIF()
9275

9376
FUNCTION(DTRACE_INSTRUMENT target)
94-
IF(BUGGY_GCC_NO_DTRACE_MODULES)
95-
GET_TARGET_PROPERTY(target_type ${target} TYPE)
96-
IF(target_type MATCHES "MODULE_LIBRARY")
97-
RETURN()
98-
ENDIF()
99-
ENDIF()
10077
IF(ENABLE_DTRACE)
10178
ADD_DEPENDENCIES(${target} gen_dtrace_header)
10279

cmake/os/WindowsCache.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ SET(HAVE_IEEEFP_H CACHE INTERNAL "")
4747
SET(HAVE_LANGINFO_H CACHE INTERNAL "")
4848
SET(HAVE_MALLOC_H 1 CACHE INTERNAL "")
4949
SET(HAVE_NETINET_IN_H CACHE INTERNAL "")
50-
SET(HAVE_PATHS_H CACHE INTERNAL "")
5150
SET(HAVE_POLL_H CACHE INTERNAL "")
5251
SET(HAVE_PWD_H CACHE INTERNAL "")
5352
SET(HAVE_STRINGS_H CACHE INTERNAL "")

config.h.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
#cmakedefine HAVE_LANGINFO_H 1
4646
#cmakedefine HAVE_MALLOC_H 1
4747
#cmakedefine HAVE_NETINET_IN_H 1
48-
#cmakedefine HAVE_PATHS_H 1
4948
#cmakedefine HAVE_POLL_H 1
5049
#cmakedefine HAVE_PWD_H 1
5150
#cmakedefine HAVE_STRINGS_H 1
@@ -193,7 +192,6 @@
193192
#cmakedefine HAVE_UINT 1
194193
#cmakedefine HAVE_ULONG 1
195194
#cmakedefine HAVE_U_INT32_T 1
196-
#cmakedefine HAVE_FP_EXCEPT 1
197195

198196
/* Code tests*/
199197
#cmakedefine STACK_DIRECTION @STACK_DIRECTION@

configure.cmake

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,6 @@ CHECK_INCLUDE_FILES (ieeefp.h HAVE_IEEEFP_H)
373373
CHECK_INCLUDE_FILES (langinfo.h HAVE_LANGINFO_H)
374374
CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
375375
CHECK_INCLUDE_FILES (netinet/in.h HAVE_NETINET_IN_H)
376-
CHECK_INCLUDE_FILES (paths.h HAVE_PATHS_H)
377376
CHECK_INCLUDE_FILES (poll.h HAVE_POLL_H)
378377
CHECK_INCLUDE_FILES (pwd.h HAVE_PWD_H)
379378
CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H)

include/my_compiler.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@
4040
# define MY_GNUC_PREREQ(maj, min) (0)
4141
#endif
4242

43+
/*
44+
The macros below are borrowed from include/linux/compiler.h in the
45+
Linux kernel. Use them to indicate the likelyhood of the truthfulness
46+
of a condition. This serves two purposes - newer versions of gcc will be
47+
able to optimize for branch predication, which could yield siginficant
48+
performance gains in frequently executed sections of the code, and the
49+
other reason to use them is for documentation
50+
*/
51+
#ifdef HAVE_BUILTIN_EXPECT
52+
# define likely(x) __builtin_expect((x),1)
53+
# define unlikely(x) __builtin_expect((x),0)
54+
#else
55+
# define likely(x) (x)
56+
# define unlikely(x) (x)
57+
#endif
58+
4359
/* Comunicate to the compiler the unreachability of the code. */
4460
#ifdef HAVE_BUILTIN_UNREACHABLE
4561
# define MY_ASSERT_UNREACHABLE() __builtin_unreachable()
@@ -66,6 +82,11 @@
6682
# define inline __inline
6783
#endif
6884

85+
/* Provide __func__ macro definition for Visual Studio. */
86+
#if defined(_MSC_VER)
87+
# define __func__ __FUNCTION__
88+
#endif
89+
6990
/**
7091
C++ Type Traits
7192
*/

include/my_global.h

Lines changed: 67 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,71 @@
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
@@ -39,9 +104,6 @@
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 */
@@ -62,12 +124,6 @@
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. */
@@ -86,95 +142,6 @@
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
@@ -185,13 +152,6 @@
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
253213
typedef int (*qsort_cmp)(const void *,const void *);
254214
typedef int (*qsort_cmp2)(const void*, const void *,const void *);
255215
C_MODE_END
256-
#ifdef HAVE_SYS_SOCKET_H
257-
#include <sys/socket.h>
258-
#endif
259216
#ifdef _WIN32
260217
typedef int socket_len_t;
261218
typedef 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)
396353
inline 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.

include/my_sys.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,6 @@ extern size_t escape_string_for_mysql(const CHARSET_INFO *charset_info,
877877
char *to, size_t to_length,
878878
const char *from, size_t length);
879879
#ifdef _WIN32
880-
#define BACKSLASH_MBTAIL
881880
/* File system character set */
882881
extern CHARSET_INFO *fs_character_set(void);
883882
#endif

0 commit comments

Comments
 (0)