| 1 | /* |
| 2 | Copyright (c) 2011-2016 mingw-w64 project |
| 3 | |
| 4 | Permission is hereby granted, free of charge, to any person obtaining a |
| 5 | copy of this software and associated documentation files (the "Software"), |
| 6 | to deal in the Software without restriction, including without limitation |
| 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 | and/or sell copies of the Software, and to permit persons to whom the |
| 9 | Software is furnished to do so, subject to the following conditions: |
| 10 | |
| 11 | The above copyright notice and this permission notice shall be included in |
| 12 | all copies or substantial portions of the Software. |
| 13 | |
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 20 | DEALINGS IN THE SOFTWARE. |
| 21 | */ |
| 22 | |
| 23 | #ifndef WIN_PTHREAD_H |
| 24 | #define WIN_PTHREAD_H |
| 25 | |
| 26 | #include <setjmp.h> |
| 27 | /* internal header files */ |
| 28 | #include "rwlock.h" |
| 29 | |
| 30 | #define LIFE_THREAD 0xBAB1F00D |
| 31 | #define DEAD_THREAD 0xDEADBEEF |
| 32 | #define EXCEPTION_SET_THREAD_NAME ((DWORD) 0x406D1388) |
| 33 | |
| 34 | typedef struct _pthread_v _pthread_v; |
| 35 | struct _pthread_v |
| 36 | { |
| 37 | unsigned int valid; |
| 38 | void *ret_arg; |
| 39 | void *(* func)(void *); |
| 40 | _pthread_cleanup *clean; |
| 41 | int nobreak; |
| 42 | HANDLE h; |
| 43 | HANDLE evStart; |
| 44 | pthread_mutex_t p_clock; |
| 45 | int cancelled : 2; |
| 46 | int in_cancel : 2; |
| 47 | int thread_noposix : 2; |
| 48 | unsigned int p_state; |
| 49 | unsigned int keymax; |
| 50 | void **keyval; |
| 51 | unsigned char *keyval_set; |
| 52 | char *thread_name; |
| 53 | pthread_spinlock_t spin_keys; |
| 54 | DWORD tid; |
| 55 | int rwlc; |
| 56 | pthread_rwlock_t rwlq[RWLS_PER_THREAD]; |
| 57 | int sched_pol; |
| 58 | int ended; |
| 59 | struct sched_param sched; |
| 60 | jmp_buf jb; |
| 61 | struct _pthread_v *next; |
| 62 | pthread_t x; /* Internal posix handle. */ |
| 63 | }; |
| 64 | |
| 65 | typedef struct __pthread_idlist { |
| 66 | struct _pthread_v *ptr; |
| 67 | pthread_t id; |
| 68 | } __pthread_idlist; |
| 69 | |
| 70 | int _pthread_tryjoin(pthread_t t, void **res); |
| 71 | void _pthread_setnobreak(int); |
| 72 | int __pthread_shallcancel(void); |
| 73 | WINPTHREAD_API struct _pthread_v * __pth_gpointer_locked (pthread_t id); |
| 74 | int _pthread_delay_np_ms (DWORD to); |
| 75 | |
| 76 | #endif |