@@ -9,13 +9,53 @@ module unix_pthread
99
1010#if defined (__linux__)
1111
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.
1429
1530#elif defined (__FreeBSD__)
1631
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.
1959
2060#endif
2161
@@ -31,16 +71,28 @@ module unix_pthread
3171 character (kind= c_char) :: hidden(PTHREAD_MUTEX_SIZE)
3272 end type c_pthread_mutex_t
3373
74+ public :: c_pthread_cancel
3475 public :: c_pthread_create
3576 public :: c_pthread_detach
77+ public :: c_pthread_exit
3678 public :: c_pthread_join
3779 public :: c_pthread_mutex_destroy
3880 public :: c_pthread_mutex_init
3981 public :: c_pthread_mutex_lock
4082 public :: c_pthread_mutex_trylock
4183 public :: c_pthread_mutex_unlock
84+ public :: c_pthread_setcancelstate
85+ public :: c_pthread_setcanceltype
4286
4387 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+ 4496 ! int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg)
4597 function c_pthread_create (thread , attr , start_routine , arg ) bind(c, name= ' pthread_create' )
4698 import :: c_int, c_ptr, c_funptr, c_pthread_t
@@ -60,6 +112,13 @@ function c_pthread_detach(thread) bind(c, name='pthread_detach')
60112 integer (kind= c_int) :: c_pthread_detach
61113 end function c_pthread_detach
62114
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+ 63122 ! int pthread_join(pthread_t thread, void **value_ptr)
64123 function c_pthread_join (thread , value_ptr ) bind(c, name= ' pthread_join' )
65124 import :: c_int, c_ptr, c_pthread_t
@@ -109,5 +168,23 @@ function c_pthread_mutex_unlock(mutex) bind(c, name='pthread_mutex_unlock')
109168 type (c_pthread_mutex_t), intent (in ) :: mutex
110169 integer (kind= c_int) :: c_pthread_mutex_unlock
111170 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
112189 end interface
113190end module unix_pthread
0 commit comments