Skip to content

Commit 80eef62

Browse files
committed
Build fixes for MacOS and Windows
1 parent 7159c18 commit 80eef62

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

include/my_global.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,15 +363,11 @@ typedef int (*qsort_cmp)(const void *,const void *);
363363
#else
364364
#define qsort_t RETQSORTTYPE /* Broken GCC cant handle typedef !!!! */
365365
#endif
366-
typedef SOCKET_SIZE_TYPE size_socket;
367-
368-
#ifndef SOCKOPT_OPTLEN_TYPE
369-
#define SOCKOPT_OPTLEN_TYPE size_socket
370-
#endif
371366

372367
#ifdef HAVE_SYS_SOCKET_H
373368
#include <sys/socket.h>
374369
#endif
370+
typedef SOCKET_SIZE_TYPE size_socket;
375371

376372
#ifndef SOCKOPT_OPTLEN_TYPE
377373
#define SOCKOPT_OPTLEN_TYPE size_socket

unittest/libmariadb/ssl.c.in

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,14 @@
2222

2323
static int skip_ssl= 1;
2424

25+
#ifdef WIN32
26+
#define pthread_exit(A) _endthreadex(0)
27+
#endif
28+
2529
const char *ssluser= "ssluser";
2630
const char *sslpw= "sslpw";
2731

28-
#ifndef WIN32
2932
pthread_mutex_t LOCK_test;
30-
#endif
3133

3234
int check_skip_ssl()
3335
{
@@ -109,7 +111,7 @@ static int test_conc95(MYSQL *my)
109111
rc= mysql_query(my, "FLUSH PRIVILEGES");
110112
check_mysql_rc(rc, my);
111113

112-
mysql= mysql_init(mysql);
114+
mysql= mysql_init(NULL);
113115
mysql_ssl_set(mysql,
114116
"@CMAKE_SOURCE_DIR@/unittest/libmariadb/certs/server-key.pem",
115117
"@CMAKE_SOURCE_DIR@/unittest/libmariadb/certs/server-cert.pem",
@@ -193,9 +195,12 @@ static int test_multi_ssl_connections(MYSQL *unused)
193195
}
194196

195197
#ifndef WIN32
196-
static void ssl_thread(void)
198+
static void ssl_thread(void *dummy)
199+
#else
200+
DWORD WINAPI ssl_thread(void *dummy)
201+
#endif
197202
{
198-
MYSQL *mysql;
203+
MYSQL *mysql= NULL;
199204

200205
mysql_thread_init();
201206

@@ -226,7 +231,12 @@ static void ssl_thread(void)
226231
static int test_ssl_threads(MYSQL *mysql)
227232
{
228233
int i, rc;
229-
pthread_t thread[50];
234+
#ifndef WIN32
235+
pthread_t threads[50];
236+
#else
237+
HANDLE hthreads[50];
238+
DWORD dthreads[50];
239+
#endif
230240
MYSQL_RES *res;
231241
MYSQL_ROW row;
232242

@@ -243,9 +253,21 @@ static int test_ssl_threads(MYSQL *mysql)
243253
pthread_mutex_init(&LOCK_test, NULL);
244254

245255
for (i=0; i < 50; i++)
246-
pthread_create(&thread[i], NULL, (void *)&ssl_thread, NULL);
256+
{
257+
#ifndef WIN32
258+
pthread_create(&threads[i], NULL, (void *)ssl_thread, NULL);
259+
#else
260+
hthreads[i]= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)ssl_thread, NULL, 0, &dthreads[i]);
261+
if (hthreads[i]==NULL)
262+
diag("error while starting thread");
263+
#endif
264+
}
247265
for (i=0; i < 50; i++)
248-
pthread_join(thread[i], NULL);
266+
#ifndef WIN32
267+
pthread_join(threads[i], NULL);
268+
#else
269+
WaitForSingleObject(hthreads[i], INFINITE);
270+
#endif
249271

250272
pthread_mutex_destroy(&LOCK_test);
251273

@@ -258,7 +280,6 @@ static int test_ssl_threads(MYSQL *mysql)
258280
mysql_free_result(res);
259281
return OK;
260282
}
261-
#endif
262283

263284
static int test_phpbug51647(MYSQL *my)
264285
{
@@ -483,7 +504,7 @@ static int test_bug62743(MYSQL *my)
483504
return OK;
484505
}
485506

486-
#ifndef _WIN32
507+
#ifndef WIN32
487508
int thread_conc102(void)
488509
#else
489510
DWORD WINAPI thread_conc102(void)
@@ -530,7 +551,7 @@ static int test_conc_102(MYSQL *mysql)
530551
int i;
531552
MYSQL_ROW row;
532553
MYSQL_RES *res;
533-
#ifndef _WIN32
554+
#ifndef WIN32
534555
pthread_t threads[50];
535556
#else
536557
HANDLE hthreads[50];
@@ -546,17 +567,17 @@ static int test_conc_102(MYSQL *mysql)
546567

547568
for (i=0; i < 50; i++)
548569
{
549-
#ifndef _WIN32
570+
#ifndef WIN32
550571
pthread_create(&threads[i], NULL, (void *)thread_conc102, NULL);
551572
#else
552-
hthreads[i]= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread_conc27, NULL, 0, &threads[i]);
573+
hthreads[i]= CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread_conc102, NULL, 0, &threads[i]);
553574
if (hthreads[i]==NULL)
554575
diag("error while starting thread");
555576
#endif
556577
}
557578
for (i=0; i < 50; i++)
558579
{
559-
#ifndef _WIN32
580+
#ifndef WIN32
560581
pthread_join(threads[i], NULL);
561582
#else
562583
WaitForSingleObject(hthreads[i], INFINITE);
@@ -605,3 +626,4 @@ int main(int argc, char **argv)
605626
mysql_server_end();
606627
return(exit_status());
607628
}
629+

0 commit comments

Comments
 (0)