Differences From Artifact [f3dd04ca64]:
- File
src/threading.h
— part of check-in
[4af49a13c3]
at
2017-05-07 20:10:13
on branch trunk
— Small code style change
Casts are now written like types in variable declarations. (user: js, size: 6290) [annotate] [blame] [check-ins using]
To Artifact [e37b27b008]:
- File
src/threading.h
— part of check-in
[c5b3c8ea87]
at
2017-05-14 14:18:26
on branch trunk
— Add nullability annotations to remaining headers
This explicitly excludes threading.h, as adding nullability annotations
requires adding them everywhere in the file. However, the types in there
are implementation defined, and might be pointers or not: Adding none
when it's a pointer would be an error, and adding one when it's not a
pointer would be an error, too. (user: js, size: 6326) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
134 135 136 137 138 139 140 | { return pthread_getspecific(key); } static OF_INLINE bool of_tlskey_set(of_tlskey_t key, void *ptr) { | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | { return pthread_getspecific(key); } static OF_INLINE bool of_tlskey_set(of_tlskey_t key, void *ptr) { return (pthread_setspecific(key, ptr) == 0); } #elif defined(OF_WINDOWS) static OF_INLINE void * of_tlskey_get(of_tlskey_t key) { return TlsGetValue(key); } |
︙ | ︙ | |||
169 170 171 172 173 174 175 | static OF_INLINE bool of_spinlock_new(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) *spinlock = 0; return true; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) | | | | | | | 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 | static OF_INLINE bool of_spinlock_new(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) *spinlock = 0; return true; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return (pthread_spin_init(spinlock, 0) == 0); #else return of_mutex_new(spinlock); #endif } static OF_INLINE bool of_spinlock_trylock(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) if (of_atomic_int_cmpswap(spinlock, 0, 1)) { of_memory_barrier_acquire(); return true; } return false; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return (pthread_spin_trylock(spinlock) == 0); #else return of_mutex_trylock(spinlock); #endif } static OF_INLINE bool of_spinlock_lock(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) size_t i; for (i = 0; i < OF_SPINCOUNT; i++) if (of_spinlock_trylock(spinlock)) return true; while (!of_spinlock_trylock(spinlock)) of_thread_yield(); return true; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return (pthread_spin_lock(spinlock) == 0); #else return of_mutex_lock(spinlock); #endif } static OF_INLINE bool of_spinlock_unlock(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) bool ret = of_atomic_int_cmpswap(spinlock, 1, 0); of_memory_barrier_release(); return ret; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return (pthread_spin_unlock(spinlock) == 0); #else return of_mutex_unlock(spinlock); #endif } static OF_INLINE bool of_spinlock_free(of_spinlock_t *spinlock) { #if defined(OF_HAVE_ATOMIC_OPS) return true; #elif defined(OF_HAVE_PTHREAD_SPINLOCKS) return (pthread_spin_destroy(spinlock) == 0); #else return of_mutex_free(spinlock); #endif } |