rx: Split out rxi_ConnectionMatch
[openafs.git] / src / rx / rx_pthread.h
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 /* rx_pthread.h defines the lock and cv primitives required for a thread
11  * safe user mode rx.
12  */
13
14 #ifndef RX_PTHREAD_H
15 #define RX_PTHREAD_H
16
17 #ifndef RX_ENABLE_LOCKS
18 #define RX_ENABLE_LOCKS 1
19 #endif
20
21 /* Block signals to child threads. */
22 #include <afs/pthread_nosigs.h>
23 #include <afs/opr.h>
24 #include <opr/lock.h>
25
26 #ifdef AFS_NT40_ENV
27 #include <wtypes.h>
28 #include <winbase.h>
29 #include <winsock2.h>
30 #include <pthread.h>
31
32 typedef pthread_mutex_t afs_kmutex_t;
33 typedef pthread_cond_t afs_kcondvar_t;
34
35 #define pthread_yield() Sleep(0)
36
37 #else /* AFS_NT40_ENV */
38
39 #include <pthread.h>
40 typedef pthread_mutex_t afs_kmutex_t;
41 typedef pthread_cond_t afs_kcondvar_t;
42
43 #if !defined(pthread_yield) && defined(AFS_SUN5_ENV)
44 #define pthread_yield() thr_yield()
45 #endif
46 #if !defined(pthread_yield) && !defined(AFS_AIX_ENV)
47 #define pthread_yield() sleep(0)
48 #endif
49 #if !defined(pthread_yield) && (_XOPEN_SOURCE + 0) >= 500
50 #define pthread_yield() sched_yield()
51 #endif
52 #endif /* AFS_NT40_ENV */
53
54 #define MUTEX_INIT(a, b, c, d) opr_mutex_init(a)
55 #define MUTEX_DESTROY(l) opr_mutex_destroy(l)
56 #define MUTEX_ENTER(l) opr_mutex_enter(l)
57 #define MUTEX_TRYENTER(l) opr_mutex_tryenter(l)
58 #define MUTEX_EXIT(l) opr_mutex_exit(l)
59 #define MUTEX_ASSERT(l) opr_mutex_assert(l)
60 #define CV_INIT(cv, a, b, c) opr_cv_init(cv)
61 #define CV_DESTROY(cv) opr_cv_destroy(cv)
62 #define CV_WAIT(cv, l) opr_cv_wait(cv, l)
63 #define CV_TIMEDWAIT(cv, l, t) opr_cv_timedwait(cv, l, t)
64 #define CV_SIGNAL(cv) opr_cv_signal(cv)
65 #define CV_BROADCAST(cv) opr_cv_broadcast(cv)
66
67 #endif /* RX_PTHREAD_H */