Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/libc/src/new/common/posix/pthread.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / libc / src / new / common / posix / pthread.rs` 332 lines ยท 10947 bytes Raw Blame History 1 //! Header: `pthread.h` 2 //! 3 //! 4 5 use crate::prelude::*; 6 7 extern "C" { 8 #[cfg(any(target_os = "android", target_os = "linux"))] 9 pub fn pthread_atfork( 10 prepare: Option, 11 parent: Option, 12 child: Option, 13 ) -> c_int; 14 15 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 16 pub fn pthread_attr_getguardsize( 17 attr: *const crate::pthread_attr_t, 18 guardsize: *mut size_t, 19 ) -> c_int; 20 21 #[cfg(any( 22 target_os = "android", 23 target_os = "l4re", 24 target_os = "linux", 25 target_vendor = "apple", 26 ))] 27 pub fn pthread_attr_getinheritsched( 28 attr: *const crate::pthread_attr_t, 29 inheritsched: *mut c_int, 30 ) -> c_int; 31 32 #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] 33 pub fn pthread_attr_getschedparam( 34 attr: *const crate::pthread_attr_t, 35 param: *mut crate::sched_param, 36 ) -> c_int; 37 38 #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] 39 pub fn pthread_attr_getschedpolicy( 40 attr: *const crate::pthread_attr_t, 41 policy: *mut c_int, 42 ) -> c_int; 43 44 #[cfg(any( 45 target_os = "android", 46 target_os = "emscripten", 47 target_os = "linux", 48 target_os = "l4re" 49 ))] 50 pub fn pthread_attr_getstack( 51 attr: *const crate::pthread_attr_t, 52 stackaddr: *mut *mut c_void, 53 stacksize: *mut size_t, 54 ) -> c_int; 55 56 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 57 pub fn pthread_attr_setguardsize(attr: *mut crate::pthread_attr_t, guardsize: size_t) -> c_int; 58 59 #[cfg(any( 60 target_os = "android", 61 target_os = "l4re", 62 target_os = "linux", 63 target_vendor = "apple" 64 ))] 65 pub fn pthread_attr_setinheritsched( 66 attr: *mut crate::pthread_attr_t, 67 inheritsched: c_int, 68 ) -> c_int; 69 70 #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] 71 pub fn pthread_attr_setschedparam( 72 attr: *mut crate::pthread_attr_t, 73 param: *const crate::sched_param, 74 ) -> c_int; 75 76 #[cfg(any(target_os = "l4re", target_os = "linux", target_vendor = "apple"))] 77 pub fn pthread_attr_setschedpolicy(attr: *mut crate::pthread_attr_t, policy: c_int) -> c_int; 78 79 #[cfg(any( 80 target_os = "android", 81 target_os = "emscripten", 82 target_os = "linux", 83 target_os = "l4re" 84 ))] 85 pub fn pthread_attr_setstack( 86 attr: *mut crate::pthread_attr_t, 87 stackaddr: *mut c_void, 88 stacksize: size_t, 89 ) -> c_int; 90 91 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 92 pub fn pthread_barrier_destroy(barrier: *mut crate::pthread_barrier_t) -> c_int; 93 94 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 95 pub fn pthread_barrier_init( 96 barrier: *mut crate::pthread_barrier_t, 97 attr: *const crate::pthread_barrierattr_t, 98 count: c_uint, 99 ) -> c_int; 100 101 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 102 pub fn pthread_barrier_wait(barrier: *mut crate::pthread_barrier_t) -> c_int; 103 104 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 105 pub fn pthread_barrierattr_destroy(attr: *mut crate::pthread_barrierattr_t) -> c_int; 106 107 #[cfg(any(target_os = "android", target_os = "linux"))] 108 pub fn pthread_barrierattr_getpshared( 109 attr: *const crate::pthread_barrierattr_t, 110 shared: *mut c_int, 111 ) -> c_int; 112 113 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 114 pub fn pthread_barrierattr_init(attr: *mut crate::pthread_barrierattr_t) -> c_int; 115 116 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 117 pub fn pthread_barrierattr_setpshared( 118 attr: *mut crate::pthread_barrierattr_t, 119 shared: c_int, 120 ) -> c_int; 121 122 #[cfg(any(target_os = "l4re", all(target_os = "linux", not(target_env = "ohos"))))] 123 pub fn pthread_cancel(thread: crate::pthread_t) -> c_int; 124 125 #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux",))] 126 pub fn pthread_condattr_getclock( 127 attr: *const crate::pthread_condattr_t, 128 clock_id: *mut crate::clockid_t, 129 ) -> c_int; 130 131 #[cfg(any( 132 target_os = "android", 133 target_os = "l4re", 134 target_os = "linux", 135 target_vendor = "apple", 136 ))] 137 pub fn pthread_condattr_getpshared( 138 attr: *const crate::pthread_condattr_t, 139 pshared: *mut c_int, 140 ) -> c_int; 141 142 #[cfg(any(target_os = "android", target_os = "emscripten", target_os = "linux",))] 143 pub fn pthread_condattr_setclock( 144 attr: *mut crate::pthread_condattr_t, 145 clock_id: crate::clockid_t, 146 ) -> c_int; 147 148 #[cfg(any( 149 target_os = "android", 150 target_os = "emscripten", 151 target_os = "linux", 152 target_os = "l4re", 153 target_vendor = "apple", 154 ))] 155 pub fn pthread_condattr_setpshared( 156 attr: *mut crate::pthread_condattr_t, 157 pshared: c_int, 158 ) -> c_int; 159 160 #[cfg(any( 161 target_os = "android", 162 target_os = "emscripten", 163 target_os = "l4re", 164 target_os = "linux", 165 ))] 166 pub fn pthread_create( 167 native: *mut crate::pthread_t, 168 attr: *const crate::pthread_attr_t, 169 f: extern "C" fn(*mut c_void) -> *mut c_void, 170 value: *mut c_void, 171 ) -> c_int; 172 173 #[cfg(any(target_os = "android", target_os = "linux"))] 174 pub fn pthread_getcpuclockid(thread: crate::pthread_t, clk_id: *mut crate::clockid_t) -> c_int; 175 176 #[cfg(any( 177 target_os = "android", 178 target_os = "l4re", 179 target_os = "linux", 180 target_vendor = "apple", 181 ))] 182 pub fn pthread_getschedparam( 183 native: crate::pthread_t, 184 policy: *mut c_int, 185 param: *mut crate::sched_param, 186 ) -> c_int; 187 188 // FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required 189 // in pthread. 190 #[cfg(any( 191 target_os = "android", 192 target_os = "emscripten", 193 target_os = "l4re", 194 target_os = "linux" 195 ))] 196 pub fn pthread_kill(thread: crate::pthread_t, sig: c_int) -> c_int; 197 198 #[cfg(all(target_os = "linux", not(target_env = "ohos")))] 199 pub fn pthread_mutex_consistent(mutex: *mut crate::pthread_mutex_t) -> c_int; 200 201 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 202 #[cfg_attr(gnu_time_bits64, link_name = "__pthread_mutex_timedlock64")] 203 #[cfg_attr(musl_redir_time64, link_name = "__pthread_mutex_timedlock_time64")] 204 pub fn pthread_mutex_timedlock( 205 lock: *mut crate::pthread_mutex_t, 206 abstime: *const crate::timespec, 207 ) -> c_int; 208 209 #[cfg(target_os = "linux")] 210 pub fn pthread_mutexattr_getprotocol( 211 attr: *const crate::pthread_mutexattr_t, 212 protocol: *mut c_int, 213 ) -> c_int; 214 215 #[cfg(any( 216 target_os = "android", 217 target_os = "l4re", 218 target_os = "linux", 219 target_vendor = "apple", 220 ))] 221 pub fn pthread_mutexattr_getpshared( 222 attr: *const crate::pthread_mutexattr_t, 223 pshared: *mut c_int, 224 ) -> c_int; 225 226 #[cfg(all(target_os = "linux", not(target_env = "ohos")))] 227 pub fn pthread_mutexattr_getrobust( 228 attr: *const crate::pthread_mutexattr_t, 229 robustness: *mut c_int, 230 ) -> c_int; 231 232 #[cfg(target_os = "linux")] 233 pub fn pthread_mutexattr_setprotocol( 234 attr: *mut crate::pthread_mutexattr_t, 235 protocol: c_int, 236 ) -> c_int; 237 238 #[cfg(any( 239 target_os = "android", 240 target_os = "emscripten", 241 target_os = "linux", 242 target_os = "l4re", 243 target_vendor = "apple", 244 ))] 245 pub fn pthread_mutexattr_setpshared( 246 attr: *mut crate::pthread_mutexattr_t, 247 pshared: c_int, 248 ) -> c_int; 249 250 #[cfg(all(target_os = "linux", not(target_env = "ohos")))] 251 pub fn pthread_mutexattr_setrobust( 252 attr: *mut crate::pthread_mutexattr_t, 253 robustness: c_int, 254 ) -> c_int; 255 256 #[cfg(any( 257 target_os = "android", 258 target_os = "emscripten", 259 target_os = "linux", 260 target_os = "l4re", 261 target_vendor = "apple", 262 ))] 263 pub fn pthread_rwlockattr_getpshared( 264 attr: *const crate::pthread_rwlockattr_t, 265 val: *mut c_int, 266 ) -> c_int; 267 268 #[cfg(any( 269 target_os = "android", 270 target_os = "emscripten", 271 target_os = "linux", 272 target_os = "l4re", 273 target_vendor = "apple", 274 ))] 275 pub fn pthread_rwlockattr_setpshared( 276 attr: *mut crate::pthread_rwlockattr_t, 277 val: c_int, 278 ) -> c_int; 279 280 // FIXME(1.0): These shoul be combined to the version that takes an optional unsafe function. 281 #[cfg(any(target_os = "l4re", target_os = "linux"))] 282 pub fn pthread_once(control: *mut crate::pthread_once_t, routine: extern "C" fn()) -> c_int; 283 #[cfg(target_vendor = "apple")] 284 pub fn pthread_once( 285 once_control: *mut crate::pthread_once_t, 286 init_routine: Option, 287 ) -> c_int; 288 289 #[cfg(any( 290 target_os = "android", 291 target_os = "l4re", 292 target_os = "linux", 293 target_vendor = "apple", 294 ))] 295 pub fn pthread_setschedparam( 296 native: crate::pthread_t, 297 policy: c_int, 298 param: *const crate::sched_param, 299 ) -> c_int; 300 301 #[cfg(target_os = "linux")] 302 pub fn pthread_setschedprio(native: crate::pthread_t, priority: c_int) -> c_int; 303 304 // FIXME(reorg): In recent POSIX versions, this is a signal.h function and not required 305 // in pthread. 306 #[cfg(any( 307 target_os = "android", 308 target_os = "emscripten", 309 target_os = "l4re", 310 target_os = "linux" 311 ))] 312 pub fn pthread_sigmask( 313 how: c_int, 314 set: *const crate::sigset_t, 315 oldset: *mut crate::sigset_t, 316 ) -> c_int; 317 318 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 319 pub fn pthread_spin_destroy(lock: *mut crate::pthread_spinlock_t) -> c_int; 320 321 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 322 pub fn pthread_spin_init(lock: *mut crate::pthread_spinlock_t, pshared: c_int) -> c_int; 323 324 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 325 pub fn pthread_spin_lock(lock: *mut crate::pthread_spinlock_t) -> c_int; 326 327 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 328 pub fn pthread_spin_trylock(lock: *mut crate::pthread_spinlock_t) -> c_int; 329 330 #[cfg(any(target_os = "android", target_os = "l4re", target_os = "linux"))] 331 pub fn pthread_spin_unlock(lock: *mut crate::pthread_spinlock_t) -> c_int; 332 }