Skip to content

Commit

Permalink
MDEV-25602 get rid of __WIN__ in favor of standard _WIN32
Browse files Browse the repository at this point in the history
This fixed the MySQL bug# 20338 about misuse of double underscore
prefix __WIN__, which was old MySQL's idea of identifying Windows
Replace it by _WIN32 standard symbol for targeting Windows OS
(both 32 and 64 bit)

Not that connect storage engine is not fixed in this patch (must be
fixed in "upstream" branch)
  • Loading branch information
vaintroub committed Jun 6, 2021
1 parent 06dd151 commit 3d6eb7a
Show file tree
Hide file tree
Showing 132 changed files with 303 additions and 379 deletions.
4 changes: 2 additions & 2 deletions client/async_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/


#ifndef __WIN__
#ifndef _WIN32
#include <poll.h>
#else
#include <WinSock2.h>
Expand All @@ -33,7 +33,7 @@ static const char *my_groups[]= { "client", NULL };
static int
wait_for_mysql(MYSQL *mysql, int status)
{
#ifdef __WIN__
#ifdef _WIN32
fd_set rs, ws, es;
int res;
struct timeval tv, *timeout;
Expand Down
2 changes: 1 addition & 1 deletion client/client_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <mysql_version.h>

#ifndef WEXITSTATUS
# ifdef __WIN__
# ifdef _WIN32
# define WEXITSTATUS(stat_val) (stat_val)
# else
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
Expand Down
14 changes: 7 additions & 7 deletions client/mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ extern "C" {
#endif /* defined(HAVE_CURSES_H) && defined(HAVE_TERM_H) */

#undef bcmp // Fix problem with new readline
#if defined(__WIN__)
#if defined(_WIN32)
#include <conio.h>
#else
#include <readline.h>
Expand Down Expand Up @@ -1587,7 +1587,7 @@ static struct my_option my_long_options[] =
{"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __WIN__
#ifdef _WIN32
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
Expand Down Expand Up @@ -1893,7 +1893,7 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
set_if_bigger(opt_silent,1); // more silent
break;
case 'W':
#ifdef __WIN__
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;
opt_protocol_type= "pipe";

Expand Down Expand Up @@ -2026,7 +2026,7 @@ static int get_options(int argc, char **argv)

static int read_and_execute(bool interactive)
{
#if defined(__WIN__)
#if defined(_WIN32)
String tmpbuf;
String buffer;
#endif
Expand Down Expand Up @@ -2106,7 +2106,7 @@ static int read_and_execute(bool interactive)
if (opt_outfile && glob_buffer.is_empty())
fflush(OUTFILE);

#if defined(__WIN__)
#if defined(_WIN32)
tee_fputs(prompt, stdout);
if (!tmpbuf.is_alloced())
tmpbuf.alloc(65535);
Expand Down Expand Up @@ -2139,7 +2139,7 @@ static int read_and_execute(bool interactive)
if (line)
free(line);
line= readline(prompt);
#endif /* defined(__WIN__) */
#endif /* defined(_WIN32) */

/*
When Ctrl+d or Ctrl+z is pressed, the line may be NULL on some OS
Expand Down Expand Up @@ -2194,7 +2194,7 @@ static int read_and_execute(bool interactive)
}
}

#if defined(__WIN__)
#if defined(_WIN32)
buffer.free();
tmpbuf.free();
#else
Expand Down
8 changes: 4 additions & 4 deletions client/mysql_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static int run_command(char* cmd, const char *mode)
}


#ifdef __WIN__
#ifdef _WIN32
/**
Check to see if there are spaces in a path.
Expand Down Expand Up @@ -329,7 +329,7 @@ static int get_default_values()
if ((error= make_tempfile(defaults_file, "txt")))
goto exit;

#ifdef __WIN__
#ifdef _WIN32
{
char *format_str= 0;

Expand Down Expand Up @@ -860,7 +860,7 @@ static int process_options(int argc, char *argv[], char *operation)
memset(buff, 0, sizeof(buff));

strncpy(buff, opt_basedir, sizeof(buff) - 1);
#ifdef __WIN__
#ifdef _WIN32
strncat(buff, "/", sizeof(buff) - strlen(buff) - 1);
#else
strncat(buff, FN_DIRSEP, sizeof(buff) - strlen(buff) - 1);
Expand Down Expand Up @@ -1175,7 +1175,7 @@ static int bootstrap_server(char *server_path, char *bootstrap_file)
char bootstrap_cmd[FN_REFLEN];
int error= 0;

#ifdef __WIN__
#ifdef _WIN32
char *format_str= 0;
const char *verbose_str= NULL;

Expand Down
8 changes: 4 additions & 4 deletions client/mysql_upgrade.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#endif

#ifndef WEXITSTATUS
# ifdef __WIN__
# ifdef _WIN32
# define WEXITSTATUS(stat_val) (stat_val)
# else
# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
Expand Down Expand Up @@ -121,7 +121,7 @@ static struct my_option my_long_options[]=
"Password to use when connecting to server. If password is not given,"
" it's solicited on the tty.", &opt_password,&opt_password,
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __WIN__
#ifdef _WIN32
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
Expand Down Expand Up @@ -451,7 +451,7 @@ static int run_tool(char *tool_path, DYNAMIC_STRING *ds_res, ...)

va_end(args);

#ifdef __WIN__
#ifdef _WIN32
dynstr_append(&ds_cmdline, "\"");
#endif

Expand Down Expand Up @@ -1286,7 +1286,7 @@ int main(int argc, char **argv)
load_defaults_or_exit("my", load_default_groups, &argc, &argv);
defaults_argv= argv; /* Must be freed by 'free_defaults' */

#if defined(__WIN__)
#if defined(_WIN32)
if (GetModuleFileName(NULL, self_name, FN_REFLEN) == 0)
#endif
{
Expand Down
6 changes: 3 additions & 3 deletions client/mysqladmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ static struct my_option my_long_options[] =
{"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __WIN__
#ifdef _WIN32
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
Expand Down Expand Up @@ -278,7 +278,7 @@ get_one_option(const struct my_option *opt, const char *argument, const char *fi
option_silent++;
break;
case 'W':
#ifdef __WIN__
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;

/* Prioritize pipe if explicit via command line */
Expand Down Expand Up @@ -1153,7 +1153,7 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv)
{
bool old= (find_type(argv[0], &command_typelib, FIND_TYPE_BASIC) ==
ADMIN_OLD_PASSWORD);
#ifdef __WIN__
#ifdef _WIN32
size_t pw_len= strlen(typed_password);
if (pw_len > 1 && typed_password[0] == '\'' &&
typed_password[pw_len-1] == '\'')
Expand Down
2 changes: 1 addition & 1 deletion client/mysqlbinlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,7 @@ static Exit_status dump_local_log_entries(PRINT_EVENT_INFO *print_event_info,
stdin in binary mode. Errors on setting this mode result in
halting the function and printing an error message to stderr.
*/
#if defined (__WIN__) || defined(_WIN64)
#if defined (_WIN32)
if (_setmode(fileno(stdin), O_BINARY) == -1)
{
error("Could not set binary mode on stdin.");
Expand Down
4 changes: 2 additions & 2 deletions client/mysqlcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static struct my_option my_long_options[] =
"When using ANALYZE TABLE use the PERSISTENT FOR ALL option.",
&opt_persistent_all, &opt_persistent_all, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
#ifdef __WIN__
#ifdef _WIN32
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
Expand Down Expand Up @@ -355,7 +355,7 @@ get_one_option(const struct my_option *opt,
opt_upgrade= 1;
break;
case 'W':
#ifdef __WIN__
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;

/* Prioritize pipe if explicit via command line */
Expand Down
4 changes: 2 additions & 2 deletions client/mysqldump.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ static struct my_option my_long_options[] =
{"password", 'p',
"Password to use when connecting to server. If password is not given it's solicited on the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __WIN__
#ifdef _WIN32
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
Expand Down Expand Up @@ -896,7 +896,7 @@ get_one_option(const struct my_option *opt,
exit(1);
break;
case 'W':
#ifdef __WIN__
#ifdef _WIN32
opt_protocol= MYSQL_PROTOCOL_PIPE;

/* Prioritize pipe if explicit via command line */
Expand Down
4 changes: 2 additions & 2 deletions client/mysqlimport.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ static struct my_option my_long_options[] =
{"password", 'p',
"Password to use when connecting to server. If password is not given it's asked from the tty.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __WIN__
#ifdef _WIN32
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
Expand Down Expand Up @@ -252,7 +252,7 @@ get_one_option(const struct my_option *opt, const char *argument,
else
tty_password= 1;
break;
#ifdef __WIN__
#ifdef _WIN32
case 'W':
opt_protocol = MYSQL_PROTOCOL_PIPE;
opt_local_file=1;
Expand Down
4 changes: 2 additions & 2 deletions client/mysqlshow.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ static struct my_option my_long_options[] =
&opt_mysql_port,
&opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0,
0},
#ifdef __WIN__
#ifdef _WIN32
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
Expand Down Expand Up @@ -336,7 +336,7 @@ get_one_option(const struct my_option *opt, const char *argument,
tty_password=1;
break;
case 'W':
#ifdef __WIN__
#ifdef _WIN32
opt_protocol = MYSQL_PROTOCOL_PIPE;

/* Prioritize pipe if explicit via command line */
Expand Down
11 changes: 5 additions & 6 deletions client/mysqlslap.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,15 @@
#include <my_dir.h>
#include <signal.h>
#include <sslopt-vars.h>
#ifndef __WIN__
#ifndef _WIN32
#include <sys/wait.h>
#endif
#include <ctype.h>
#include <welcome_copyright_notice.h> /* ORACLE_WELCOME_COPYRIGHT_NOTICE */

#ifdef __WIN__
#ifdef _WIN32
#define srandom srand
#define random rand
#define snprintf _snprintf
#endif


Expand Down Expand Up @@ -282,7 +281,7 @@ static long int timedif(struct timeval a, struct timeval b)
return s + us;
}

#ifdef __WIN__
#ifdef _WIN32
static int gettimeofday(struct timeval *tp, void *tzp)
{
unsigned int ticks;
Expand Down Expand Up @@ -665,7 +664,7 @@ static struct my_option my_long_options[] =
{"password", 'p',
"Password to use when connecting to server. If password is not given it's "
"asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#ifdef __WIN__
#ifdef _WIN32
{"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG,
NO_ARG, 0, 0, 0, 0, 0, 0},
#endif
Expand Down Expand Up @@ -772,7 +771,7 @@ get_one_option(const struct my_option *opt, const char *argument,
tty_password= 1;
break;
case 'W':
#ifdef __WIN__
#ifdef _WIN32
opt_protocol= MYSQL_PROTOCOL_PIPE;

/* Prioritize pipe if explicit via command line */
Expand Down
2 changes: 1 addition & 1 deletion client/readline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file)
{
LINE_BUFFER *line_buff;

#ifndef __WIN__
#ifndef _WIN32
MY_STAT input_file_stat;
if (my_fstat(fileno(file), &input_file_stat, MYF(MY_WME)) ||
MY_S_ISDIR(input_file_stat.st_mode) ||
Expand Down
2 changes: 1 addition & 1 deletion cmake/os/Windows.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ IF(MSVC AND CMAKE_CXX_COMPILER_ID MATCHES Clang)
SET(CLANG_CL TRUE)
ENDIF()

ADD_DEFINITIONS(-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE)
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
ADD_DEFINITIONS(-D_WIN32_WINNT=0x0A00)
# We do not want the windows.h macros min/max
ADD_DEFINITIONS(-DNOMINMAX)
Expand Down
2 changes: 1 addition & 1 deletion config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@
#define PSAPI_VERSION 1 /* for GetProcessMemoryInfo() */

/* We don't want the min/max macros */
#ifdef __WIN__
#ifdef _WIN32
#define NOMINMAX 1
#endif

Expand Down
8 changes: 4 additions & 4 deletions dbug/dbug.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ extern void __gcov_flush();
#define fnmatch(A,B,C) strcmp(A,B)
#endif

#if defined(__WIN__)
#if defined(_WIN32)
#include <process.h>
#endif

Expand Down Expand Up @@ -1872,7 +1872,7 @@ static void DoPrefix(CODE_STATE *cs, uint _line_)
(void) fprintf(cs->stack->out_file->file, "%5d: ", cs->lineno);
if (cs->stack->flags & TIMESTAMP_ON)
{
#ifdef __WIN__
#ifdef _WIN32
/* FIXME This doesn't give microseconds as in Unix case, and the resolution is
in system ticks, 10 ms intervals. See my_getsystime.c for high res */
SYSTEMTIME loc_t;
Expand Down Expand Up @@ -2203,7 +2203,7 @@ void _db_flush_()
}


#ifndef __WIN__
#ifndef _WIN32
void _db_suicide_()
{
int retval;
Expand All @@ -2222,7 +2222,7 @@ void _db_suicide_()
fprintf(stderr, "sigsuspend returned %d errno %d \n", retval, errno);
assert(FALSE); /* With full signal mask, we should never return here. */
}
#endif /* ! __WIN__ */
#endif /* ! _WIN32 */


void _db_lock_file_()
Expand Down
2 changes: 1 addition & 1 deletion extra/innochecksum.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef __WIN__
#ifndef _WIN32
# include <unistd.h>
#endif
#include <my_getopt.h>
Expand Down
2 changes: 1 addition & 1 deletion extra/mariabackup/ds_stdout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ stdout_open(ds_ctxt_t *ctxt __attribute__((unused)),
stdout_file = (ds_stdout_file_t *) (file + 1);


#ifdef __WIN__
#ifdef _WIN32
setmode(fileno(stdout), _O_BINARY);
#endif

Expand Down

0 comments on commit 3d6eb7a

Please sign in to comment.