Where Online Learning is simpler!
The C and C++ Include Header Files
/usr/include/ntirpc/reentrant.h
$ cat -n /usr/include/ntirpc/reentrant.h 1 /*- 2 * Copyright (c) 1997,98 The NetBSD Foundation, Inc. 3 * All rights reserved. 4 * 5 * This code is derived from software contributed to The NetBSD Foundation 6 * by J.T. Conklin. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 18 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 20 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 21 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 * POSSIBILITY OF SUCH DAMAGE. 28 * 29 */ 30 31 /* 32 * This file was derived from a copy in FreeBSD CVS on August 26, 2010. 33 * FreeBSD/NetBSD have slightly different definitions for some/most of 34 * these functions and types, so they should just use the ones found 35 * in their system copy of reentrant.h. 36 */ 37 38 #ifndef REENTRANT_H 39 #define REENTRANT_H 40 41 #if defined(_WIN32) 42 #include
43 #elif defined(__APPLE__) 44 #include
45 #else 46 #include
47 #endif 48 49 #define mutex_t pthread_mutex_t 50 #define cond_t pthread_cond_t 51 #define rwlock_t pthread_rwlock_t 52 #define spinlock_t pthread_spinlock_t 53 #define once_t pthread_once_t 54 55 #define thread_key_t pthread_key_t 56 #if defined(__linux__) 57 #define MUTEX_INITIALIZER PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP 58 #else 59 #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER 60 #endif 61 #define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER 62 #define ONCE_INITIALIZER PTHREAD_ONCE_INIT 63 64 static inline int 65 mutex_init(pthread_mutex_t *m, const pthread_mutexattr_t *a 66 __attribute__ ((unused))) 67 { 68 pthread_mutexattr_t attr; 69 int rslt; 70 71 pthread_mutexattr_init(&attr); 72 #if defined(__linux__) 73 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP); 74 #endif 75 rslt = pthread_mutex_init(m, &attr); 76 pthread_mutexattr_destroy(&attr); 77 78 return (rslt); 79 } 80 81 #define mutex_lock(m) pthread_mutex_lock(m) 82 #define mutex_trylock(m) pthread_mutex_trylock(m) 83 #define mutex_unlock(m) pthread_mutex_unlock(m) 84 #define mutex_destroy(m) pthread_mutex_destroy(m) 85 86 #define cond_init(c, a, p) pthread_cond_init(c, a) 87 #define cond_signal(m) pthread_cond_signal(m) 88 #define cond_broadcast(m) pthread_cond_broadcast(m) 89 #define cond_wait(c, m) pthread_cond_wait(c, m) 90 #define cond_timedwait(c, m, a) pthread_cond_timedwait(c, m, a) 91 #define cond_destroy(c) pthread_cond_destroy(c) 92 93 #define rwlock_init(l, a) \ 94 do { \ 95 int rc; \ 96 \ 97 rc = pthread_rwlock_init(l, a); \ 98 if (rc != 0) { \ 99 abort(); \ 100 } \ 101 } while (0) 102 103 #define rwlock_rdlock(l) \ 104 do { \ 105 int rc; \ 106 \ 107 rc = pthread_rwlock_rdlock(l); \ 108 if (rc != 0) { \ 109 abort(); \ 110 } \ 111 } while (0) 112 113 #define rwlock_wrlock(l) \ 114 do { \ 115 int rc; \ 116 \ 117 rc = pthread_rwlock_wrlock(l); \ 118 if (rc != 0) { \ 119 abort(); \ 120 } \ 121 } while (0) 122 123 #define rwlock_unlock(l) \ 124 do { \ 125 int rc; \ 126 \ 127 rc = pthread_rwlock_unlock(l); \ 128 if (rc != 0) { \ 129 abort(); \ 130 } \ 131 } while (0) 132 133 #define rwlockattr_init(a) \ 134 do { \ 135 int rc; \ 136 \ 137 rc = pthread_rwlockattr_init(a); \ 138 if (rc != 0) { \ 139 abort(); \ 140 } \ 141 } while (0) 142 143 #define rwlock_destroy(l) \ 144 do { \ 145 int rc; \ 146 \ 147 rc = pthread_rwlock_destroy(l); \ 148 if (rc != 0) { \ 149 abort(); \ 150 } \ 151 } while (0) 152 153 #define spin_init(l, a) pthread_spin_init(l, a) 154 #define spin_lock(l) pthread_spin_lock(l) 155 #define spin_trylock(l) pthread_spin_trylock(l) 156 #define spin_unlock(l) pthread_spin_unlock(l) 157 #define spin_destroy(l) pthread_spin_destroy(l) 158 159 #define thr_keycreate(k, d) pthread_key_create(k, d) 160 extern void thr_keyfree(void *k); 161 #define thr_setspecific(k, p) pthread_setspecific(k, p) 162 #define thr_getspecific(k) pthread_getspecific(k) 163 #define thr_sigsetmask(f, n, o) pthread_sigmask(f, n, o) 164 165 #define thr_once(o, i) pthread_once(o, i) 166 #define thr_self() pthread_self() 167 #define thr_exit(x) pthread_exit(x) 168 169 #endif /* REENTRANT_H */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2025 MyWebUniversity.com ™