]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/test_and_benchmark/libshared/src/libshared_porting_abstraction_layer/libshared_porting_abstraction_layer_thread_wait.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / test_and_benchmark / libshared / src / libshared_porting_abstraction_layer / libshared_porting_abstraction_layer_thread_wait.c
1 /***** includes *****/
2 #include "libshared_porting_abstraction_layer_internal.h"
3
4
5
6
7
8 /****************************************************************************/
9 #if( defined _WIN32 && !defined KERNEL_MODE && NTDDI_VERSION >= NTDDI_WINXP )
10
11   #ifdef LIBSHARED_PAL_THREAD_WAIT
12     #error More than one porting abstraction layer matches current platform in "libshared_porting_abstraction_layer_thread_wait.c".
13   #endif
14
15   #define LIBSHARED_PAL_THREAD_WAIT
16
17   void libshared_pal_thread_wait( libshared_pal_thread_handle_t thread_handle )
18   {
19     // TRD : thread_handle can be any value in its range
20
21     WaitForSingleObject( thread_handle, INFINITE );
22
23     return;
24   }
25
26 #endif
27
28
29
30
31
32 /****************************************************************************/
33 #if( defined _WIN32 && defined KERNEL_MODE && NTDDI_VERSION >= NTDDI_WINXP )
34
35   #ifdef LIBSHARED_PAL_THREAD_WAIT
36     #error More than one porting abstraction layer matches current platform in "libshared_porting_abstraction_layer_thread_wait.c".
37   #endif
38
39   #define LIBSHARED_PAL_THREAD_WAIT
40
41   void libshared_pal_thread_wait( libshared_pal_thread_handle_t thread_handle )
42   {
43     // TRD : thread_handle can be any value in its range
44
45     KeWaitForSingleObject( thread_handle, Executive, KernelMode, FALSE, NULL );
46
47     return;
48   }
49
50 #endif
51
52
53
54
55
56 /****************************************************************************/
57 #if( defined _POSIX_THREADS && _POSIX_THREADS > 0 && !defined KERNEL_MODE )
58
59   #ifdef LIBSHARED_PAL_THREAD_WAIT
60     #error More than one porting abstraction layer matches current platform in "libshared_porting_abstraction_layer_thread_wait.c".
61   #endif
62
63   #define LIBSHARED_PAL_THREAD_WAIT
64
65   void libshared_pal_thread_wait( libshared_pal_thread_handle_t thread_handle )
66   {
67     // TRD : thread_handle can be any value in its range
68
69     pthread_join( thread_handle, NULL );
70
71     return;
72   }
73
74 #endif
75
76
77
78
79
80 /****************************************************************************/
81 #if( defined __linux__ && defined KERNEL_MODE )
82
83   #ifdef LIBSHARED_PAL_THREAD_WAIT
84     #error More than one porting abstraction layer matches current platform in "libshared_porting_abstraction_layer_thread_wait.c".
85   #endif
86
87   #define LIBSHARED_PAL_THREAD_WAIT
88
89   void libshared_pal_thread_wait( libshared_pal_thread_handle_t thread_handle )
90   {
91     // TRD : thread_handle can be any value in its range
92
93     /* TRD : turns out this function does not exist in the linux kernel
94              you have to manage your own inter-thread sync
95              that breaks the lfds abstraction for thread start/wait
96              so this isn't going to get fixed in time for this release
97              leaving the function here so compilation will pass
98     */
99
100     return;
101   }
102
103 #endif
104
105
106
107
108
109 /****************************************************************************/
110 #if( !defined LIBSHARED_PAL_THREAD_WAIT )
111
112   #error No matching porting abstraction layer in "libshared_porting_abstraction_layer_thread_wait.c".
113
114 #endif
115