|
238 | 238 | #endif |
239 | 239 | #define assert(a) (a) |
240 | 240 |
|
241 | | -#elif __linux__ && __arm__ |
242 | | - #include <inttypes.h> |
243 | | - #include <alloca.h> |
244 | | - |
245 | | - #define INLINE static __inline |
246 | | - |
247 | | - #define _X64 "llx" |
248 | | - #define _F64 "lld" |
249 | | - #define _FSEC "ld" |
250 | | - #define _FUSEC "ld" |
251 | | - |
252 | | - #define _ARCH_O_DIRECT (O_DIRECT) |
253 | | - #define malloc_align(addr, align, size) \ |
254 | | - (addr = memalign((align), (size))) |
255 | | - #define free_align(addr) free(addr) |
256 | | - |
257 | | - #ifndef spin_t |
258 | | - // spinlock |
259 | | - #include <pthread.h> |
260 | | - #define spin_t pthread_spinlock_t |
261 | | - #define spin_init(arg) pthread_spin_init(arg, PTHREAD_PROCESS_SHARED) |
262 | | - #define spin_lock(arg) pthread_spin_lock(arg) |
263 | | - #define spin_trylock(arg) \ |
264 | | - (pthread_spin_trylock(arg) == 0) |
265 | | - #define spin_unlock(arg) pthread_spin_unlock(arg) |
266 | | - #define spin_destroy(arg) pthread_spin_destroy(arg) |
267 | | - #define SPIN_INITIALIZER (spin_t)(0) |
268 | | - #endif |
269 | | - #ifndef mutex_t |
270 | | - // mutex |
271 | | - #include <pthread.h> |
272 | | - #define mutex_t pthread_mutex_t |
273 | | - #define mutex_init(arg) pthread_mutex_init(arg, NULL) |
274 | | - #define mutex_lock(arg) pthread_mutex_lock(arg) |
275 | | - #define mutex_trylock(arg) \ |
276 | | - (pthread_mutex_trylock(arg) == 0) |
277 | | - #define mutex_unlock(arg) pthread_mutex_unlock(arg) |
278 | | - #define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER |
279 | | - #define mutex_destroy(arg) pthread_mutex_destroy(arg) |
280 | | - #endif |
281 | | - #ifndef thread_t |
282 | | - // thread |
283 | | - #include <pthread.h> |
284 | | - #define thread_t pthread_t |
285 | | - #define thread_cond_t pthread_cond_t |
286 | | - #define thread_create(tid, func, args) \ |
287 | | - pthread_create((tid), NULL, (func), (args)) |
288 | | - #define thread_join(tid, ret) pthread_join(tid, ret) |
289 | | - #define thread_cancel(tid) pthread_cancel(tid) |
290 | | - #define thread_exit(code) pthread_exit(code) |
291 | | - #define thread_cond_init(cond) pthread_cond_init(cond, NULL) |
292 | | - #define thread_cond_destroy(cond) pthread_cond_destroy(cond) |
293 | | - #define thread_cond_wait(cond, mutex) pthread_cond_wait(cond, mutex) |
294 | | - #define thread_cond_timedwait(cond, mutex, ms) \ |
295 | | - { \ |
296 | | - struct timespec ts = convert_reltime_to_abstime(ms); \ |
297 | | - pthread_cond_timedwait(cond, mutex, &ts); \ |
298 | | - } |
299 | | - #define thread_cond_signal(cond) pthread_cond_signal(cond) |
300 | | - #define thread_cond_broadcast(cond) pthread_cond_broadcast(cond) |
301 | | - #endif |
302 | | - |
303 | 241 | #elif __linux__ |
304 | 242 | #include <inttypes.h> |
305 | 243 | #include <alloca.h> |
|
329 | 267 | (pthread_spin_trylock(arg) == 0) |
330 | 268 | #define spin_unlock(arg) pthread_spin_unlock(arg) |
331 | 269 | #define spin_destroy(arg) pthread_spin_destroy(arg) |
332 | | - #define SPIN_INITIALIZER (spin_t)(1) |
| 270 | + #if defined(__i386__) || defined(__x86_64__) |
| 271 | + #define SPIN_INITIALIZER (spin_t)(1) |
| 272 | + #elif defined(__arm__) || defined(__aarch64__) |
| 273 | + #define SPIN_INITIALIZER (spin_t)(0) |
| 274 | + #else |
| 275 | + #error Unsupported architecture for SPIN_INITIALIZER |
| 276 | + #endif |
333 | 277 | #endif |
334 | 278 | #ifndef mutex_t |
335 | 279 | // mutex |
|
0 commit comments