Skip to content

Commit 609163c

Browse files
committed
fixed code for windows
1 parent 800c321 commit 609163c

File tree

6 files changed

+27
-20
lines changed

6 files changed

+27
-20
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required( VERSION 3.14)
1+
cmake_minimum_required( VERSION 3.13...99.99)
22

33
project( mulle-thread VERSION 4.6.2 LANGUAGES C)
44

src/mulle-thread-c11.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141
#include <errno.h>
4242
#include <threads.h>
4343

44+
typedef int mulle_thread_rval_t;
45+
#define mulle_thread_return() return( 0) // bogus, exit is returned differently
46+
4447

4548
//typedef once_flag mulle_thread_once_t;
4649
typedef mtx_t mulle_thread_mutex_t;
@@ -95,7 +98,7 @@ static inline int mulle_thread_detach( mulle_thread_t thread)
9598
}
9699

97100

98-
static inline void mulle_thread_exit( mulle_thread_rval_t rval)
101+
static inline void mulle_thread_exit( int rval)
99102
{
100103
thrd_exit( rval);
101104
}

src/mulle-thread-pthreads.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
#include <stdint.h>
4343
#include <stdlib.h>
4444

45+
typedef void *mulle_thread_rval_t;
46+
#define mulle_thread_return() return( NULL)
47+
4548

4649
//typedef pthread_once_t mulle_thread_once_t;
4750
typedef pthread_mutex_t mulle_thread_mutex_t;
@@ -71,7 +74,7 @@ static inline int mulle_thread_create( mulle_thread_function_t *f,
7174
void *arg,
7275
mulle_thread_t *p_thread)
7376
{
74-
return( pthread_create( p_thread, NULL, (void *(*)()) f, arg));
77+
return( pthread_create( p_thread, NULL, f, arg));
7578
}
7679

7780

@@ -99,7 +102,7 @@ static inline int mulle_thread_detach( mulle_thread_t thread)
99102
}
100103

101104

102-
static inline void mulle_thread_exit( mulle_thread_rval_t rval)
105+
static inline void mulle_thread_exit( int rval)
103106
{
104107
pthread_exit( (void *) (intptr_t) rval);
105108
}

src/mulle-thread-windows.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static struct
177177
} global;
178178

179179

180-
static void mulle_thread_tss_init( void)
180+
void mulle_thread_tss_init( void)
181181
{
182182
for(;;)
183183
{
@@ -195,7 +195,7 @@ static void mulle_thread_tss_init( void)
195195
}
196196

197197

198-
static void mulle_thread_tss_done( void)
198+
void mulle_thread_tss_done( void)
199199
{
200200
for(;;)
201201
{

src/mulle-thread-windows.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
#include <errno.h>
4444
#include <assert.h>
4545

46-
46+
typedef unsigned int mulle_thread_rval_t;
47+
#define mulle_thread_return() return( 0)
4748

4849
typedef DWORD mulle_thread_tss_t;
4950
typedef HANDLE mulle_thread_t;
@@ -80,7 +81,7 @@ static inline int mulle_thread_create( mulle_thread_function_t *f,
8081
}
8182

8283

83-
static inline void mulle_thread_exit( mulle_thread_rval_t rval)
84+
static inline void mulle_thread_exit( int rval)
8485
{
8586
extern void mulle_thread_windows_destroy_tss( void);
8687

src/mulle-thread.h

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,24 +55,24 @@
5555
#endif
5656

5757

58-
// clang lies about __STDC_NO_THREADS__
58+
// clang lies about __STDC_NO_THREADS__, gcc does not necessary
59+
// windows thinks it has threads.h but its apparently something else ?
5960

60-
#ifndef HAVE_C11_THREADS
61-
# ifdef __clang__
62-
# if __has_include(<threads.h>)
63-
# define HAVE_C11_THREADS 1
64-
# endif
65-
# else
66-
# if __STDC_VERSION__ >= 201112L && ! defined( __STDC_NO_THREADS__)
67-
# define HAVE_C11_THREADS 1
61+
#ifndef _WIN32
62+
# ifndef HAVE_C11_THREADS
63+
# if defined( __has_include) || defined( __clang__) || (defined(__GNUC__) && (__GNUC__ >= 5))
64+
# if __has_include(<threads.h>)
65+
# define HAVE_C11_THREADS 1
66+
# endif
67+
# else
68+
# if __STDC_VERSION__ >= 201112L && ! defined( __STDC_NO_THREADS__)
69+
# define HAVE_C11_THREADS 1
70+
# endif
6871
# endif
6972
# endif
7073
#endif
7174

7275

73-
typedef int mulle_thread_rval_t;
74-
#define mulle_thread_return() return( 0) // bogus, exit is returned differently
75-
7676
#if HAVE_C11_THREADS && ! defined( MULLE_THREAD_USE_PTHREADS)
7777
# if TRACE_INCLUDE
7878
# pragma message( "Using C11 for threads")

0 commit comments

Comments
 (0)