xref: /haiku/headers/posix/pthread.h (revision 24159a0c7d6d6dcba9f2a0c1a7c08d2c8167f21b)
1 /*
2 ** Distributed under the terms of the Haiku License.
3 */
4 #ifndef _PTHREAD_H_
5 #define _PTHREAD_H_
6 
7 
8 #include <time.h>
9 
10 
11 enum pthread_mutex_type {
12 	PTHREAD_MUTEX_DEFAULT,
13 	PTHREAD_MUTEX_NORMAL,
14 	PTHREAD_MUTEX_ERRORCHECK,
15 	PTHREAD_MUTEX_RECURSIVE,
16 };
17 
18 enum pthread_process_shared {
19 	PTHREAD_PROCESS_PRIVATE,
20 	PTHREAD_PROCESS_SHARED,
21 };
22 
23 
24 struct _pthread_mutex;
25 struct _pthread_mutexattr;
26 
27 typedef struct _pthread_mutex *pthread_mutex_t;
28 typedef struct _pthread_mutexattr *pthread_mutexattr_t;
29 
30 //extern pthread_mutexattr_t pthread_mutexattr_default;
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 extern pthread_mutex_t _pthread_mutex_static_initializer(void);
37 extern pthread_mutex_t _pthread_recursive_mutex_static_initializer(void);
38 #define PTHREAD_MUTEX_INITIALIZER \
39 	pthread_mutex_static_initializer();
40 #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER \
41 	pthread_recursive_mutex_static_initializer();
42 
43 /* mutex functions */
44 extern int pthread_mutex_destroy(pthread_mutex_t *mutex);
45 extern int pthread_mutex_getprioceiling(pthread_mutex_t *mutex, int *_priorityCeiling);
46 extern int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
47 extern int pthread_mutex_lock(pthread_mutex_t *mutex);
48 extern int pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int newPriorityCeiling,
49 				int *_oldPriorityCeiling);
50 extern int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *spec);
51 extern int pthread_mutex_trylock(pthread_mutex_t *mutex);
52 extern int pthread_mutex_unlock(pthread_mutex_t *mutex);
53 
54 /* mutex attribute functions */
55 extern int pthread_mutexattr_destroy(pthread_mutexattr_t *mutexAttr);
56 extern int pthread_mutexattr_getprioceiling(pthread_mutexattr_t *mutexAttr, int *_priorityCeiling);
57 extern int pthread_mutexattr_getprotocol(pthread_mutexattr_t *mutexAttr, int *_protocol);
58 extern int pthread_mutexattr_getpshared(pthread_mutexattr_t *mutexAttr, int *_processShared);
59 extern int pthread_mutexattr_gettype(pthread_mutexattr_t *mutexAttr, int *_type);
60 extern int pthread_mutexattr_init(pthread_mutexattr_t *mutexAttr);
61 extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *mutexAttr, int priorityCeiling);
62 extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *mutexAttr, int protocol);
63 extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *mutexAttr, int processShared);
64 extern int pthread_mutexattr_settype(pthread_mutexattr_t *mutexAttr, int type);
65 
66 /* misc. functions */
67 extern int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void));
68 
69 #ifdef __cplusplus
70 }
71 #endif
72 
73 #endif	/* _PTHREAD_ */
74