Skip to content

Commit

Permalink
MDEV-9154 : Remove workarounds (mainly dynamic function loading)
Browse files Browse the repository at this point in the history
for running obsolete versions of Windows
  • Loading branch information
vaintroub committed Jun 1, 2016
1 parent 22ede74 commit 3a7bc23
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 723 deletions.
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(CMAKE_C_COMPILER MATCHES "icl")
ENDIF()

ADD_DEFINITIONS(-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE)
ADD_DEFINITIONS(-D_WIN32_WINNT=0x0501)
ADD_DEFINITIONS(-D_WIN32_WINNT=0x0600)
# We do not want the windows.h macros min/max
ADD_DEFINITIONS(-DNOMINMAX)
# Speed up build process excluding unused header files
Expand Down
1 change: 0 additions & 1 deletion extra/yassl/taocrypt/src/random.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include <time.h>

#if defined(_WIN32)
#define _WIN32_WINNT 0x0400
#include <windows.h>
#include <wincrypt.h>
#else
Expand Down
27 changes: 3 additions & 24 deletions include/my_pthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,37 +54,16 @@ typedef struct st_pthread_link {
We use native conditions on Vista and later, and fallback to own
implementation on earlier OS version.
*/
typedef union
{
/* Native condition (used on Vista and later) */
CONDITION_VARIABLE native_cond;

/* Own implementation (used on XP) */
struct
{
uint32 waiting;
CRITICAL_SECTION lock_waiting;
enum
{
SIGNAL= 0,
BROADCAST= 1,
MAX_EVENTS= 2
} EVENTS;
HANDLE events[MAX_EVENTS];
HANDLE broadcast_block_event;
};
} pthread_cond_t;
typedef CONDITION_VARIABLE pthread_cond_t;


typedef int pthread_mutexattr_t;
#define pthread_self() GetCurrentThreadId()
#define pthread_handler_t EXTERNC void * __cdecl
typedef void * (__cdecl *pthread_handler)(void *);

typedef volatile LONG my_pthread_once_t;
#define MY_PTHREAD_ONCE_INIT 0
#define MY_PTHREAD_ONCE_INPROGRESS 1
#define MY_PTHREAD_ONCE_DONE 2
typedef INIT_ONCE my_pthread_once_t;
#define MY_PTHREAD_ONCE_INIT INIT_ONCE_STATIC_INIT;

#if !STRUCT_TIMESPEC_HAS_TV_SEC || !STRUCT_TIMESPEC_HAS_TV_NSEC
struct timespec {
Expand Down
9 changes: 0 additions & 9 deletions include/violite.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,6 @@ void vio_end(void);
#define SHUT_RD SD_RECEIVE
#endif

/*
Set thread id for io cancellation (required on Windows XP only,
and should to be removed if XP is no more supported)
*/

#define vio_set_thread_id(vio, tid) if(vio) vio->thread_id= tid
#else
#define vio_set_thread_id(vio, tid)
#endif

/* This enumerator is used in parser - should be always visible */
Expand Down Expand Up @@ -288,7 +280,6 @@ struct st_vio
#ifdef _WIN32
HANDLE hPipe;
OVERLAPPED overlapped;
DWORD thread_id; /* Used on XP only by vio_shutdown() */
DWORD read_timeout_ms;
DWORD write_timeout_ms;
#endif
Expand Down
38 changes: 1 addition & 37 deletions mysys/my_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -1124,43 +1124,7 @@ static int add_directory(MEM_ROOT *alloc, const char *dir, const char **dirs)
return 0;
}


#ifdef __WIN__
/*
This wrapper for GetSystemWindowsDirectory() will dynamically bind to the
function if it is available, emulate it on NT4 Terminal Server by stripping
the \SYSTEM32 from the end of the results of GetSystemDirectory(), or just
return GetSystemDirectory().
*/

typedef UINT (WINAPI *GET_SYSTEM_WINDOWS_DIRECTORY)(LPSTR, UINT);

static size_t my_get_system_windows_directory(char *buffer, size_t size)
{
size_t count;
GET_SYSTEM_WINDOWS_DIRECTORY
func_ptr= (GET_SYSTEM_WINDOWS_DIRECTORY)
GetProcAddress(GetModuleHandle("kernel32.dll"),
"GetSystemWindowsDirectoryA");

if (func_ptr)
return func_ptr(buffer, (uint) size);

/*
Windows NT 4.0 Terminal Server Edition:
To retrieve the shared Windows directory, call GetSystemDirectory and
trim the "System32" element from the end of the returned path.
*/
count= GetSystemDirectory(buffer, (uint) size);
if (count > 8 && stricmp(buffer+(count-8), "\\System32") == 0)
{
count-= 8;
buffer[count] = '\0';
}
return count;
}


static const char *my_get_module_parent(char *buf, size_t size)
{
char *last= NULL;
Expand Down Expand Up @@ -1209,7 +1173,7 @@ static const char **init_default_directories(MEM_ROOT *alloc)

{
char fname_buffer[FN_REFLEN];
if (my_get_system_windows_directory(fname_buffer, sizeof(fname_buffer)))
if (GetSystemWindowsDirectory(fname_buffer, sizeof(fname_buffer)))
errors += add_directory(alloc, fname_buffer, dirs);

if (GetWindowsDirectory(fname_buffer, sizeof(fname_buffer)))
Expand Down
Loading

0 comments on commit 3a7bc23

Please sign in to comment.