Skip to content

Commit

Permalink
Bug#26781567: REMOVE C LEGACY [noclose]
Browse files Browse the repository at this point in the history
Remove a large swath of extern "C" that is no longer needed, since all of our
code is C++ (and all plugins/components must also obviously be C++). The only
place extern "C" really is relevant now, is functions exported from libmysql,
plugin entry points (as they rely on C name mangling), a few rare places
where we interact with the C standard library, and some leftover code that is
still not converted to C++ due to various issues.

MyISAM has, as usual, been kept out of the cleanups.

Change-Id: I38f9dabe60eac808f7da62d6de2f6d1efed50932
  • Loading branch information
Steinar H. Gunderson committed Nov 17, 2017
1 parent 8b1c279 commit 2bffaeb
Show file tree
Hide file tree
Showing 205 changed files with 365 additions and 1,535 deletions.
2 changes: 0 additions & 2 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2746,10 +2746,8 @@ static bool add_line(String &buffer, char *line, size_t line_length,

#ifdef HAVE_READLINE

C_MODE_START
static char *new_command_generator(const char *text, int);
static char **new_mysql_completion(const char *text, int start, int end);
C_MODE_END

/*
Tell the GNU Readline library how to complete. We want to try to complete
Expand Down
2 changes: 0 additions & 2 deletions client/mysqltest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,9 @@ extern CHARSET_INFO my_charset_utf16le_bin;
using std::string;
using std::unique_ptr;

C_MODE_START
static void signal_handler(int sig);
static bool get_one_option(int optid, const struct my_option *,
char *argument);
C_MODE_END

enum {
OPT_PS_PROTOCOL=OPT_MAX_CLIENT_OPTION, OPT_SP_PROTOCOL,
Expand Down
2 changes: 1 addition & 1 deletion components/mysql_server/dynamic_loader_path_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */

typedef std::string my_string;

extern "C" MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info;
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO *system_charset_info;
bool check_string_char_length(const LEX_CSTRING &str, const char *err_msg,
size_t max_char_length, const CHARSET_INFO *cs,
bool no_error);
Expand Down
3 changes: 0 additions & 3 deletions components/mysql_server/log_builtins.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ static HANDLE hEventLog= NULL; // global
#endif


extern "C"
{
PSI_memory_key key_memory_log_error_loaded_services;
PSI_memory_key key_memory_log_error_stack;
}

using std::string;
using std::unique_ptr;
Expand Down
8 changes: 0 additions & 8 deletions include/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@

#include "my_inttypes.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
Calculate how much memory needed for dst of base64_encode()
*/
Expand Down Expand Up @@ -62,8 +58,4 @@ int64 base64_decode(const char *src, size_t src_len,
/* Allow multuple chunks 'AAA= AA== AA==', binlog uses this */
#define MY_BASE64_DECODE_ALLOW_MULTIPLE_CHUNKS 1


#ifdef __cplusplus
}
#endif
#endif /* !__BASE64_H_INCLUDED__ */
4 changes: 0 additions & 4 deletions include/decimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
#include "my_inttypes.h"
#include "my_macros.h"

C_MODE_START

typedef enum
{TRUNCATE=0, HALF_EVEN, HALF_UP, CEILING, FLOOR}
decimal_round_mode;
Expand Down Expand Up @@ -143,8 +141,6 @@ static inline int decimal_string_size(const decimal_t *dec)
#define E_DEC_ERROR 31
#define E_DEC_FATAL_ERROR 30

C_MODE_END

#endif // MYSQL_ABI_CHECK

#endif // DECIMAL_INCLUDED
10 changes: 0 additions & 10 deletions include/errmsg.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,9 @@
Note that the auth subsystem also uses codes with a CR_ prefix.
*/

#ifdef __cplusplus
extern "C" {
#endif
void init_client_errs(void);
void finish_client_errs(void);
extern const char *client_errors[]; /* Error messages */
#ifdef __cplusplus
}
#endif

#define CR_MIN_ERROR 2000 /* For easier client code */
#define CR_MAX_ERROR 2999
Expand Down Expand Up @@ -120,11 +114,7 @@ extern const char *client_errors[]; /* Error messages */
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */

/* Visual Studio requires '__inline' for C code */
#if !defined(__cplusplus) && defined(_MSC_VER)
static __inline const char* ER_CLIENT(int client_errno)
#else
static inline const char* ER_CLIENT(int client_errno)
#endif
{
if (client_errno >= CR_ERROR_FIRST && client_errno <= CR_ERROR_LAST)
return client_errors[client_errno - CR_ERROR_FIRST];
Expand Down
7 changes: 0 additions & 7 deletions include/ft_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#include "my_base.h"
#include "my_inttypes.h"

#ifdef __cplusplus
extern "C" {
#endif

#define HA_FT_MAXBYTELEN 336
#define HA_FT_MAXCHARLEN (HA_FT_MAXBYTELEN/4)

Expand Down Expand Up @@ -131,7 +127,4 @@ FT_INFO *ft_init_search(uint,void *, uint, uchar *, uint,
const CHARSET_INFO *, uchar *);
bool ft_boolean_check_syntax_string(const uchar *);

#ifdef __cplusplus
}
#endif
#endif /* FT_GLOBAL_INCLUDED */
8 changes: 0 additions & 8 deletions include/heap.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@
#include "my_tree.h"
#include "thr_lock.h"

#ifdef __cplusplus
extern "C" {
#endif

/* defines used by heap-funktions */

#define HP_MAX_LEVELS 4 /* 128^5 records is enough */
Expand Down Expand Up @@ -259,8 +255,4 @@ extern uchar * heap_find(HP_INFO *info,int inx,const uchar *key);
extern int heap_check_heap(HP_INFO *info, bool print_status);
extern void heap_position(HP_INFO *info, HP_HEAP_POSITION *pos);


#ifdef __cplusplus
}
#endif
#endif
3 changes: 0 additions & 3 deletions include/keycache.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
#include "mysql/psi/mysql_cond.h"
#include "mysql/psi/mysql_mutex.h"

C_MODE_START

/* declare structures that is used by KEY_CACHE */

struct BLOCK_LINK;
Expand Down Expand Up @@ -166,5 +164,4 @@ extern void multi_key_cache_change(KEY_CACHE *old_data,
KEY_CACHE *new_data);
extern int reset_key_cache_counters(const char *name,
KEY_CACHE *key_cache);
C_MODE_END
#endif /* _keycache_h */
4 changes: 0 additions & 4 deletions include/lf.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
#include "mysql/service_mysql_alloc.h"
#include "sql_string.h"

C_MODE_START

/*
wait-free dynamic array, see lf_dynarray.c
Expand Down Expand Up @@ -236,7 +234,5 @@ typedef int lf_hash_match_func(const uchar *el);
void *lf_hash_random_match(LF_HASH *hash, LF_PINS *pins,
lf_hash_match_func *match, uint rand_val);

C_MODE_END

#endif

11 changes: 3 additions & 8 deletions include/m_ctype.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,9 @@
#include "my_compiler.h"
#include "my_inttypes.h"
#include "my_loglevel.h"
#include "my_macros.h"
#include "my_sharedlib.h"

#ifdef __cplusplus
extern "C" {
#endif

#define MY_CS_NAME_SIZE 32
#define MY_CS_CTYPE_TABLE_SIZE 257
#define MY_CS_TO_LOWER_TABLE_SIZE 256
Expand Down Expand Up @@ -452,7 +449,9 @@ struct CHARSET_INFO
*/

extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_bin;
C_MODE_START
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_latin1;
C_MODE_END
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_filename;
extern MYSQL_PLUGIN_IMPORT CHARSET_INFO my_charset_utf8mb4_0900_ai_ci;

Expand Down Expand Up @@ -784,8 +783,4 @@ values < 0x7F. */
#define my_strntoull(s, a, b, c,d, e) ((s)->cset->strntoull((s),(a),(b),(c),(d),(e)))
#define my_strntod(s, a, b, c, d) ((s)->cset->strntod((s),(a),(b),(c),(d)))

#ifdef __cplusplus
}
#endif

#endif /* _m_ctype_h */
10 changes: 2 additions & 8 deletions include/m_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@
*/
#define NullS (char *) 0

#if defined(__cplusplus)
extern "C" {
#endif

/*
my_str_malloc(), my_str_realloc() and my_str_free() are assigned to
implementations in strings/alloc.c, but can be overridden in
Expand Down Expand Up @@ -293,7 +289,9 @@ size_t my_gcvt(double x, my_gcvt_arg_type type, int width, char *to,
#define MY_GCVT_MAX_FIELD_WIDTH (DBL_DIG + 4 + MY_MAX(5, MAX_DECPT_FOR_F_FORMAT)) \

extern char *int2str(long val, char *dst, int radix, int upcase);
C_MODE_START
extern char *int10_to_str(long val,char *dst,int radix);
C_MODE_END
extern char *str2int(const char *src,int radix,long lower,long upper,
long *val);
longlong my_strtoll10(const char *nptr, char **endptr, int *error);
Expand Down Expand Up @@ -325,10 +323,6 @@ static inline char *ullstr(longlong value, char *buff)
return buff;
}

#if defined(__cplusplus)
}
#endif

#define STRING_WITH_LEN(X) (X), ((sizeof(X) - 1))
#define USTRING_WITH_LEN(X) ((uchar*) X), ((sizeof(X) - 1))
#define C_STRING_WITH_LEN(X) ((char *) (X)), ((sizeof(X) - 1))
Expand Down
4 changes: 0 additions & 4 deletions include/my_aes.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
#include "my_inttypes.h"
#include "my_macros.h"

C_MODE_START

/** AES IV size is 16 bytes for all supported ciphers except ECB */
#define MY_AES_IV_SIZE 16

Expand Down Expand Up @@ -135,6 +133,4 @@ int my_aes_get_size(uint32 source_length, enum my_aes_opmode opmode);
bool my_aes_needs_iv(my_aes_opmode opmode);


C_MODE_END

#endif /* MY_AES_INCLUDED */
8 changes: 1 addition & 7 deletions include/my_bit.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -28,8 +28,6 @@
#include "my_inttypes.h"
#include "my_macros.h"

C_MODE_START

extern const char _my_bits_nbits[256];
extern const uchar _my_bits_reverse_table[256];

Expand Down Expand Up @@ -126,9 +124,6 @@ static inline uint32 my_reverse_bits(uint32 key)
_my_bits_reverse_table[(key>>24) ];
}

C_MODE_END

#ifdef __cplusplus
/**
Determine if a single bit is set among some bits.
@tparam IntType an integer type
Expand Down Expand Up @@ -159,6 +154,5 @@ constexpr bool is_single_bit(IntType bits)
*/
return bits != 0 && (bits & (bits - 1)) == 0;
}
#endif /* __cplusplus */

#endif /* MY_BIT_INCLUDED */
7 changes: 0 additions & 7 deletions include/my_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ struct MY_BITMAP
mysql_mutex_t *mutex{nullptr};
};

#ifdef __cplusplus
extern "C" {
#endif
extern void create_last_word_mask(MY_BITMAP *map);
extern bool bitmap_init(MY_BITMAP *map, my_bitmap_map *buf, uint n_bits,
bool thread_safe);
Expand Down Expand Up @@ -145,8 +142,4 @@ static inline void bitmap_set_all(MY_BITMAP *map)
memset(map->bitmap, 0xFF, 4 * no_words_in_map(map));
}

#ifdef __cplusplus
}
#endif

#endif /* _my_bitmap_h_ */
9 changes: 1 addition & 8 deletions include/my_check_opt.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -20,10 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
@file include/my_check_opt.h
*/

#ifdef __cplusplus
extern "C" {
#endif

/*
All given definitions needed for MyISAM storage engine:
myisamchk.c or/and ha_myisam.cc or/and micheck.c
Expand Down Expand Up @@ -67,7 +63,4 @@ extern "C" {

#define T_REP_ANY (T_REP | T_REP_BY_SORT | T_REP_PARALLEL)

#ifdef __cplusplus
}
#endif
#endif
14 changes: 3 additions & 11 deletions include/my_compare.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
#include "my_inttypes.h"
#include "myisampack.h"

#ifdef __cplusplus
extern "C" {
#endif

/*
There is a hard limit for the maximum number of keys as there are only
8 bits in the index file header for the number of keys in a table.
Expand Down Expand Up @@ -115,9 +111,9 @@ struct HA_KEYSEG /* Key-portion */

extern int ha_compare_text(const CHARSET_INFO *, uchar *, uint, uchar *, uint ,
bool);
extern int ha_key_cmp(HA_KEYSEG *keyseg, uchar *a,
uchar *b, uint key_length, uint nextflag,
uint *diff_pos);
extern "C" int ha_key_cmp(HA_KEYSEG *keyseg, uchar *a,
uchar *b, uint key_length, uint nextflag,
uint *diff_pos);

/*
Inside an in-memory data record, memory pointers to pieces of the
Expand All @@ -126,8 +122,4 @@ extern int ha_key_cmp(HA_KEYSEG *keyseg, uchar *a,
*/
#define portable_sizeof_char_ptr 8

#ifdef __cplusplus
}
#endif

#endif /* _my_compare_h */
3 changes: 2 additions & 1 deletion include/my_dbug.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <stdio.h>
#endif

// Needs to be extern "C" for the time being, since extra/regex/ uses it.
#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -167,7 +168,7 @@ extern void _db_flush_gcov_();

#endif

#ifdef __cplusplus
#ifdef __cplusplus
}
#endif

Expand Down
Loading

0 comments on commit 2bffaeb

Please sign in to comment.