@@ -9,13 +9,53 @@ module unix_pthread
9
9
10
10
#if defined (__linux__)
11
11
12
- integer , parameter :: PTHREAD_SIZE = 8 ! 8 Bytes.
13
- integer , parameter :: PTHREAD_MUTEX_SIZE = 40 ! 40 Bytes.
12
+ integer (kind= c_int), parameter :: PTHREAD_CREATE_DETACHED = 1
13
+
14
+ integer (kind= c_int), parameter :: PTHREAD_CANCEL_ENABLE = 0
15
+ integer (kind= c_int), parameter :: PTHREAD_CANCEL_DISABLE = 1
16
+ integer (kind= c_int), parameter :: PTHREAD_CANCEL_DEFERRED = 0
17
+ integer (kind= c_int), parameter :: PTHREAD_CANCEL_ASYNCHRONOUS = 1
18
+ integer (kind= c_int), parameter :: PTHREAD_CANCELED = - 1
19
+
20
+ integer (kind= c_int), parameter :: PTHREAD_EXPLICIT_SCHED = 1
21
+ integer (kind= c_int), parameter :: PTHREAD_PROCESS_PRIVATE = 0
22
+
23
+ integer (kind= c_int), parameter :: PTHREAD_MUTEX_NORMAL = 0
24
+ integer (kind= c_int), parameter :: PTHREAD_MUTEX_ERRORCHECK = 2
25
+ integer (kind= c_int), parameter :: PTHREAD_MUTEX_RECURSIVE = 1
26
+
27
+ integer , parameter :: PTHREAD_SIZE = 8 ! 8 Bytes.
28
+ integer , parameter :: PTHREAD_MUTEX_SIZE = 40 ! 40 Bytes.
14
29
15
30
#elif defined (__FreeBSD__)
16
31
17
- integer , parameter :: PTHREAD_SIZE = 8 ! 8 Bytes.
18
- integer , parameter :: PTHREAD_MUTEX_SIZE = 8 ! 8 Bytes.
32
+ integer (kind= c_int), parameter :: PTHREAD_DETACHED = int (z' 1' )
33
+ integer (kind= c_int), parameter :: PTHREAD_SCOPE_SYSTEM = int (z' 2' )
34
+ integer (kind= c_int), parameter :: PTHREAD_INHERIT_SCHED = int (z' 4' )
35
+ integer (kind= c_int), parameter :: PTHREAD_NOFLOAT = int (z' 8' )
36
+
37
+ integer (kind= c_int), parameter :: PTHREAD_CREATE_DETACHED = PTHREAD_DETACHED
38
+ integer (kind= c_int), parameter :: PTHREAD_CREATE_JOINABLE = 0
39
+ integer (kind= c_int), parameter :: PTHREAD_SCOPE_PROCESS = 0
40
+ integer (kind= c_int), parameter :: PTHREAD_EXPLICIT_SCHED = 0
41
+
42
+ integer (kind= c_int), parameter :: PTHREAD_PROCESS_PRIVATE = 0
43
+ integer (kind= c_int), parameter :: PTHREAD_PROCESS_SHARED = 1
44
+
45
+ integer (kind= c_int), parameter :: PTHREAD_CANCEL_ENABLE = 0
46
+ integer (kind= c_int), parameter :: PTHREAD_CANCEL_DISABLE = 1
47
+ integer (kind= c_int), parameter :: PTHREAD_CANCEL_DEFERRED = 0
48
+ integer (kind= c_int), parameter :: PTHREAD_CANCEL_ASYNCHRONOUS = 2
49
+ integer (kind= c_int), parameter :: PTHREAD_CANCELED = 1
50
+
51
+ integer (kind= c_int), parameter :: PTHREAD_MUTEX_ERRORCHECK = 1 ! Default POSIX mutex.
52
+ integer (kind= c_int), parameter :: PTHREAD_MUTEX_RECURSIVE = 2 ! Recursive mutex.
53
+ integer (kind= c_int), parameter :: PTHREAD_MUTEX_NORMAL = 3 ! No error checking.
54
+ integer (kind= c_int), parameter :: PTHREAD_MUTEX_ADAPTIVE_NP = 4 ! Adaptive mutex, spins briefly before blocking on lock.
55
+ integer (kind= c_int), parameter :: PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_ERRORCHECK
56
+
57
+ integer , parameter :: PTHREAD_SIZE = 8 ! 8 Bytes.
58
+ integer , parameter :: PTHREAD_MUTEX_SIZE = 8 ! 8 Bytes.
19
59
20
60
#endif
21
61
@@ -31,16 +71,28 @@ module unix_pthread
31
71
character (kind= c_char) :: hidden(PTHREAD_MUTEX_SIZE)
32
72
end type c_pthread_mutex_t
33
73
74
+ public :: c_pthread_cancel
34
75
public :: c_pthread_create
35
76
public :: c_pthread_detach
77
+ public :: c_pthread_exit
36
78
public :: c_pthread_join
37
79
public :: c_pthread_mutex_destroy
38
80
public :: c_pthread_mutex_init
39
81
public :: c_pthread_mutex_lock
40
82
public :: c_pthread_mutex_trylock
41
83
public :: c_pthread_mutex_unlock
84
+ public :: c_pthread_setcancelstate
85
+ public :: c_pthread_setcanceltype
42
86
43
87
interface
88
+ ! int pthread_cancel(pthread_t thread)
89
+ function c_pthread_cancel (thread ) bind(c, name= ' pthread_cancel' )
90
+ import :: c_int, c_ptr, c_pthread_t
91
+ implicit none
92
+ type (c_pthread_t), intent (in ), value :: thread
93
+ integer (kind= c_int) :: c_pthread_cancel
94
+ end function c_pthread_cancel
95
+
44
96
! int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg)
45
97
function c_pthread_create (thread , attr , start_routine , arg ) bind(c, name= ' pthread_create' )
46
98
import :: c_int, c_ptr, c_funptr, c_pthread_t
@@ -60,6 +112,13 @@ function c_pthread_detach(thread) bind(c, name='pthread_detach')
60
112
integer (kind= c_int) :: c_pthread_detach
61
113
end function c_pthread_detach
62
114
115
+ ! void pthread_exit(void *retval)
116
+ subroutine c_pthread_exit (retval ) bind(c, name= ' pthread_exit' )
117
+ import :: c_ptr
118
+ implicit none
119
+ type (c_ptr), intent (in ), value :: retval
120
+ end subroutine c_pthread_exit
121
+
63
122
! int pthread_join(pthread_t thread, void **value_ptr)
64
123
function c_pthread_join (thread , value_ptr ) bind(c, name= ' pthread_join' )
65
124
import :: c_int, c_ptr, c_pthread_t
@@ -109,5 +168,23 @@ function c_pthread_mutex_unlock(mutex) bind(c, name='pthread_mutex_unlock')
109
168
type (c_pthread_mutex_t), intent (in ) :: mutex
110
169
integer (kind= c_int) :: c_pthread_mutex_unlock
111
170
end function c_pthread_mutex_unlock
171
+
172
+ ! int pthread_setcancelstate(int state, int *oldstate)
173
+ function c_pthread_setcancelstate (state , oldstate ) bind(c, name= ' pthread_setcancelstate' )
174
+ import :: c_int
175
+ implicit none
176
+ integer (kind= c_int), intent (in ), value :: state
177
+ integer (kind= c_int), intent (out ) :: oldstate
178
+ integer (kind= c_int) :: c_pthread_setcancelstate
179
+ end function c_pthread_setcancelstate
180
+
181
+ ! int pthread_setcanceltype(int type, int *oldtype)
182
+ function c_pthread_setcanceltype (type , oldtype ) bind(c, name= ' pthread_setcanceltype' )
183
+ import :: c_int
184
+ implicit none
185
+ integer (kind= c_int), intent (in ), value :: type
186
+ integer (kind= c_int), intent (out ) :: oldtype
187
+ integer (kind= c_int) :: c_pthread_setcanceltype
188
+ end function c_pthread_setcanceltype
112
189
end interface
113
190
end module unix_pthread
0 commit comments