… | |
… | |
16 | ///////////////////////////////////////////////////////////////////////////// |
16 | ///////////////////////////////////////////////////////////////////////////// |
17 | |
17 | |
18 | #ifdef _WIN32 |
18 | #ifdef _WIN32 |
19 | |
19 | |
20 | //#define NTDDI_VERSION NTDDI_WIN2K // needed to get win2000 api calls, fails with mingw |
20 | //#define NTDDI_VERSION NTDDI_WIN2K // needed to get win2000 api calls, fails with mingw |
|
|
21 | #if _WIN32_WINNT < 0x400 |
21 | #define _WIN32_WINNT 0x400 // maybe working alternative for mingw |
22 | # define _WIN32_WINNT 0x400 // maybe working alternative for mingw |
|
|
23 | #endif |
22 | #include <stdio.h>//D |
24 | #include <stdio.h>//D |
23 | #include <fcntl.h> |
25 | #include <fcntl.h> |
24 | #include <io.h> |
26 | #include <io.h> |
25 | #include <time.h> |
27 | #include <time.h> |
26 | #include <winsock2.h> |
28 | #include <winsock2.h> |
… | |
… | |
31 | #if defined(__MINGW32__) && defined(_TIMESPEC_DEFINED) |
33 | #if defined(__MINGW32__) && defined(_TIMESPEC_DEFINED) |
32 | #define HAVE_STRUCT_TIMESPEC 1 |
34 | #define HAVE_STRUCT_TIMESPEC 1 |
33 | #endif |
35 | #endif |
34 | |
36 | |
35 | #include <pthread.h> |
37 | #include <pthread.h> |
|
|
38 | #ifndef pthread_sigmask |
36 | #define sigset_t int |
39 | # define sigset_t int |
37 | #define sigfillset(a) |
40 | # define sigfillset(a) |
38 | #define pthread_sigmask(a,b,c) |
41 | # define pthread_sigmask(a,b,c) |
39 | #define sigaddset(a,b) |
42 | # define sigaddset(a,b) |
40 | #define sigemptyset(s) |
43 | # define sigemptyset(s) |
|
|
44 | #endif |
41 | |
45 | |
42 | typedef pthread_mutex_t xmutex_t; |
46 | typedef pthread_mutex_t xmutex_t; |
43 | #define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER |
47 | #define X_MUTEX_INIT PTHREAD_MUTEX_INITIALIZER |
44 | #define X_MUTEX_CREATE(mutex) pthread_mutex_init (&(mutex), 0) |
48 | #define X_MUTEX_CREATE(mutex) pthread_mutex_init (&(mutex), 0) |
45 | #define X_LOCK(mutex) pthread_mutex_lock (&(mutex)) |
49 | #define X_LOCK(mutex) pthread_mutex_lock (&(mutex)) |
… | |
… | |
58 | |
62 | |
59 | static int |
63 | static int |
60 | xthread_create (xthread_t *tid, void *(*proc)(void *), void *arg) |
64 | xthread_create (xthread_t *tid, void *(*proc)(void *), void *arg) |
61 | { |
65 | { |
62 | int retval; |
66 | int retval; |
|
|
67 | #if 0 |
63 | pthread_attr_t attr; |
68 | pthread_attr_t attr; |
64 | |
69 | |
65 | pthread_attr_init (&attr); |
70 | pthread_attr_init (&attr); |
66 | pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); |
71 | pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED); |
67 | |
72 | |
68 | retval = pthread_create (tid, &attr, proc, arg) == 0; |
73 | retval = pthread_create (tid, &attr, proc, arg) == 0; |
69 | |
74 | |
70 | pthread_attr_destroy (&attr); |
75 | pthread_attr_destroy (&attr); |
|
|
76 | #else |
|
|
77 | retval = pthread_create (tid, 0, proc, arg) == 0; |
|
|
78 | |
|
|
79 | if (retval) |
|
|
80 | pthread_detach (*tid); |
|
|
81 | #endif |
71 | |
82 | |
72 | return retval; |
83 | return retval; |
73 | } |
84 | } |
74 | |
85 | |
75 | #define respipe_read(a,b,c) PerlSock_recv ((a), (b), (c), 0) |
86 | #define respipe_read(a,b,c) PerlSock_recv ((a), (b), (c), 0) |