xref: /haiku/headers/posix/pthread.h (revision 51978af14a173e7fae0563b562be5603bc652aeb)
1 #ifndef _PTHREAD_H_
2 #define _PTHREAD_H_
3 /*
4 ** Distributed under the terms of the OpenBeOS License.
5 */
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 extern pthread_mutex_t _pthread_mutex_static_initializer(void);
33 extern pthread_mutex_t _pthread_recursive_mutex_static_initializer(void);
34 #define PTHREAD_MUTEX_INITIALIZER \
35 	pthread_mutex_static_initializer();
36 #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER \
37 	pthread_recursive_mutex_static_initializer();
38 
39 /* mutex functions */
40 extern int pthread_mutex_destroy(pthread_mutex_t *mutex);
41 extern int pthread_mutex_getprioceiling(pthread_mutex_t *mutex, int *_priorityCeiling);
42 extern int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr);
43 extern int pthread_mutex_lock(pthread_mutex_t *mutex);
44 extern int pthread_mutex_setprioceiling(pthread_mutex_t *mutex, int newPriorityCeiling,
45 				int *_oldPriorityCeiling);
46 extern int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *spec);
47 extern int pthread_mutex_trylock(pthread_mutex_t *mutex);
48 extern int pthread_mutex_unlock(pthread_mutex_t *mutex);
49 
50 /* mutex attribute functions */
51 extern int pthread_mutexattr_destroy(pthread_mutexattr_t *mutexAttr);
52 extern int pthread_mutexattr_getprioceiling(pthread_mutexattr_t *mutexAttr, int *_priorityCeiling);
53 extern int pthread_mutexattr_getprotocol(pthread_mutexattr_t *mutexAttr, int *_protocol);
54 extern int pthread_mutexattr_getpshared(pthread_mutexattr_t *mutexAttr, int *_processShared);
55 extern int pthread_mutexattr_gettype(pthread_mutexattr_t *mutexAttr, int *_type);
56 extern int pthread_mutexattr_init(pthread_mutexattr_t *mutexAttr);
57 extern int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *mutexAttr, int priorityCeiling);
58 extern int pthread_mutexattr_setprotocol(pthread_mutexattr_t *mutexAttr, int protocol);
59 extern int pthread_mutexattr_setpshared(pthread_mutexattr_t *mutexAttr, int processShared);
60 extern int pthread_mutexattr_settype(pthread_mutexattr_t *mutexAttr, int type);
61 
62 #endif	/* _PTHREAD_ */
63