Skip to content

Commit abbd9d9

Browse files
author
Steinar H. Gunderson
committed
Bug #24573230: REMOVE #DEFINES WITH GLOBAL INFLUENCE FROM MY_GLOBAL.H
my_global.h should not have #defines that modify behavior of system headers; this is brittle, and better suited to CMake options, so move it there. It should also not try to #undef symbols from other files, which is again brittle (especially as these symbols tend to change without people remembering to update my_global.h -- it seems to already have happened during the introduction of yaSSL). Instead, make sure these symbols are simply not added during compilation in the first place. Every plugin now gets compiled with ${SSL_DEFINES} added automatically, so they don't have to add that manually -- except if they are recompiled for embedded, in which case ${SSL_DEFINES} is never added in the first place (instead of having to #undef them). I've double-checked that the logic for EMBEDDED_LIBRARY is the same by manually adding #error directives in my_global.h and compiling (then removed them again before submission). Change-Id: I70c0e2db82a9b65a1b0a5e35b75ce861bc1cdc0a
1 parent ba8d0b2 commit abbd9d9

15 files changed

+19
-41
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,10 @@ INCLUDE(configure.cmake)
570570
# Common defines and includes
571571
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
572572
ADD_DEFINITIONS(-DRAPIDJSON_NO_SIZETYPEDEFINE)
573+
ADD_DEFINITIONS(-D__STDC_LIMIT_MACROS) # Enable C99 limit macros
574+
ADD_DEFINITIONS(-D__STDC_FORMAT_MACROS) # Enable C99 printf format macros
575+
ADD_DEFINITIONS(-D_USE_MATH_DEFINES) # Get access to M_PI, M_E, etc. in math.h
576+
573577
INCLUDE_DIRECTORIES(
574578
${CMAKE_CURRENT_BINARY_DIR}/include
575579
${CMAKE_SOURCE_DIR}/extra/rapidjson/include

cmake/plugin.cmake

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ MACRO(MYSQL_ADD_PLUGIN)
124124
ADD_CONVENIENCE_LIBRARY(${target} STATIC ${SOURCES})
125125
SET_TARGET_PROPERTIES(${target}
126126
PROPERTIES COMPILE_DEFINITIONS "MYSQL_SERVER")
127+
SET_TARGET_PROPERTIES(${target}
128+
PROPERTIES COMPILE_FLAGS ${SSL_DEFINES})
127129

128130
DTRACE_INSTRUMENT(${target})
129131
ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES})
@@ -136,7 +138,7 @@ MACRO(MYSQL_ADD_PLUGIN)
136138
DTRACE_INSTRUMENT(${target}_embedded)
137139
IF(ARG_RECOMPILE_FOR_EMBEDDED)
138140
SET_TARGET_PROPERTIES(${target}_embedded
139-
PROPERTIES COMPILE_DEFINITIONS "MYSQL_SERVER;EMBEDDED_LIBRARY")
141+
PROPERTIES COMPILE_DEFINITIONS "MYSQL_SERVER;EMBEDDED_LIBRARY;NO_EMBEDDED_ACCESS_CHECKS")
140142
ENDIF()
141143
ADD_DEPENDENCIES(${target}_embedded GenError)
142144
ENDIF()

include/my_global.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525

2626
#include "my_config.h"
2727

28-
#define __STDC_LIMIT_MACROS /* Enable C99 limit macros */
29-
#define __STDC_FORMAT_MACROS /* Enable C99 printf format macros */
30-
#define _USE_MATH_DEFINES /* Get access to M_PI, M_E, etc. in math.h */
31-
3228
#ifdef _WIN32
3329
/* Include common headers.*/
3430
# include <winsock2.h>
@@ -521,13 +517,6 @@ typedef char my_bool; /* Small bool */
521517
#define MYSQL_PLUGIN_IMPORT
522518
#endif
523519

524-
#ifdef EMBEDDED_LIBRARY
525-
#define NO_EMBEDDED_ACCESS_CHECKS
526-
/* Things we don't need in the embedded version of MySQL */
527-
#undef HAVE_OPENSSL
528-
#endif /* EMBEDDED_LIBRARY */
529-
530-
531520
enum loglevel {
532521
ERROR_LEVEL= 0,
533522
WARNING_LEVEL= 1,

libmysqld/CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
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-
ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY
17-
${SSL_DEFINES})
16+
ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY -DNO_EMBEDDED_ACCESS_CHECKS)
1817

1918
INCLUDE_DIRECTORIES(
2019
${CMAKE_SOURCE_DIR}/include

libmysqld/examples/CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
22
#
33
# This program is free software; you can redistribute it and/or modify
44
# it under the terms of the GNU General Public License as published by
@@ -21,7 +21,8 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
2121
)
2222

2323

24-
ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -UMYSQL_CLIENT)
24+
ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -DNO_EMBEDDED_ACCESS_CHECKS)
25+
REMOVE_DEFINITIONS(-DMYSQL_CLIENT)
2526

2627

2728
MYSQL_ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
@@ -43,6 +44,7 @@ ENDIF()
4344

4445

4546

47+
REMOVE_DEFINITIONS(${SSL_DEFINES})
4648
MYSQL_ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc)
4749
TARGET_LINK_LIBRARIES(mysqltest_embedded mysqlserver)
4850

storage/ndb/memcache/src/ClusterConnectionPool.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights
2+
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights
33
reserved.
44
55
This program is free software; you can redistribute it and/or
@@ -21,9 +21,6 @@
2121
#include <my_config.h>
2222
#include <stdio.h>
2323
#include <assert.h>
24-
25-
/* C++ files must define __STDC_FORMAT_MACROS in order to get PRIu64 */
26-
#define __STDC_FORMAT_MACROS
2724
#include <inttypes.h>
2825
#include <pthread.h>
2926

storage/ndb/memcache/src/DataTypeHandler.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights
2+
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights
33
reserved.
44
55
This program is free software; you can redistribute it and/or
@@ -24,9 +24,6 @@
2424
#include <stdlib.h>
2525
#include <ctype.h>
2626
#include <errno.h>
27-
28-
/* C++ files must define __STDC_FORMAT_MACROS in order to get PRIu64 */
29-
#define __STDC_FORMAT_MACROS
3027
#include <inttypes.h>
3128

3229
#include <NdbApi.hpp>

storage/ndb/memcache/src/ndb_flush.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or
55
modify it under the terms of the GNU General Public License
@@ -21,7 +21,6 @@
2121
#include <my_config.h>
2222

2323
/* System headers */
24-
#define __STDC_FORMAT_MACROS
2524
#include <assert.h>
2625
#include <ctype.h>
2726

storage/ndb/memcache/src/ndb_pipeline.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights
2+
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights
33
reserved.
44
55
This program is free software; you can redistribute it and/or
@@ -22,8 +22,6 @@
2222
#include <pthread.h>
2323
#include <stdio.h>
2424

25-
/* C++ files must define __STDC_FORMAT_MACROS in order to get PRIu64 */
26-
#define __STDC_FORMAT_MACROS
2725
#include <inttypes.h>
2826

2927
#include "config.h"

storage/ndb/memcache/src/ndb_worker.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights
2+
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights
33
reserved.
44
55
This program is free software; you can redistribute it and/or
@@ -22,7 +22,6 @@
2222
#include <my_config.h>
2323

2424
/* System headers */
25-
#define __STDC_FORMAT_MACROS
2625
#include <unistd.h>
2726
#include <stdlib.h>
2827
#include <stdio.h>

storage/ndb/memcache/src/schedulers/S_sched.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include <ctype.h>
2424
#include <stdio.h>
2525
#include <sys/errno.h>
26-
#define __STDC_FORMAT_MACROS
2726
#include <inttypes.h>
2827

2928
/* Memcache headers */

storage/ndb/memcache/src/schedulers/Scheduler73.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights
2+
Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights
33
reserved.
44
55
This program is free software; you can redistribute it and/or
@@ -22,7 +22,6 @@
2222
#include <ctype.h>
2323
#include <stdio.h>
2424
#include <sys/errno.h>
25-
#define __STDC_FORMAT_MACROS
2625
#include <inttypes.h>
2726

2827
/* Memcache headers */

storage/ndb/memcache/src/schedulers/Stockholm.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include <my_config.h>
2323

2424
/* System headers */
25-
/* C++ files must define __STDC_FORMAT_MACROS in order to get PRIu64 */
26-
#define __STDC_FORMAT_MACROS
2725
#include <inttypes.h>
2826
#include <stdio.h>
2927

storage/ndb/memcache/src/schedulers/Trondheim.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2015, Oracle and/or its affiliates. All rights
2+
Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights
33
reserved.
44
55
This program is free software; you can redistribute it and/or
@@ -23,7 +23,6 @@
2323
#include <ctype.h>
2424
#include <stdio.h>
2525
#include <sys/errno.h>
26-
#define __STDC_FORMAT_MACROS
2726
#include <inttypes.h>
2827

2928
/* Memcache headers */

storage/perfschema/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}
2323
${SSL_INCLUDE_DIRS})
2424

2525
ADD_DEFINITIONS(-DMYSQL_SERVER)
26-
IF (SSL_DEFINES)
27-
ADD_DEFINITIONS(${SSL_DEFINES})
28-
ENDIF()
2926

3027
#
3128
# Maintainer: keep this list sorted, to avoid merge collisions.

0 commit comments

Comments
 (0)