nlib
Platform_cafe.h
1 
2 #pragma once
3 #ifndef INCLUDE_NN_NLIB_PLATFORM_CAFE_H_
4 #define INCLUDE_NN_NLIB_PLATFORM_CAFE_H_
5 #ifndef INCLUDE_NN_NLIB_PLATFORM_H_
6 # error do not include directly
7 #endif
8 #ifdef CAFE
9 
10 #define NLIB_HAS_STDHEADER_STDINT
11 #define NLIB_HAS_STDHEADER_INTTYPES
12 
13 #include <ppc_ps.h>
14 #include <cafe/os.h>
15 #include <stdint.h>
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #ifndef NLIB_CAFE_PPC
22 # define NLIB_CAFE_PPC
23 #endif
24 #define NLIB_ALWAYS_INLINE inline __attribute__((always_inline))
25 #define NLIB_NEVER_INLINE __attribute__((__noinline__))
26 #ifdef __cplusplus
27 #define NLIB_LIKELY(x) __builtin_expect(!!(x), 1)
28 #define NLIB_UNLIKELY(x) __builtin_expect(!!(x), 0)
29 #else
30 #define NLIB_LIKELY(x) (x)
31 #define NLIB_UNLIKELY(x) (x)
32 #endif
33 #define NLIB_EXPECT(var, exp_value) __builtin_expect((var), (exp_value))
34 #define NLIB_CHECK_RESULT __attribute__((warn_unused_result))
35 #define NLIB_NORETURN __attribute__((noreturn))
36 #define NLIB_NONNULL __attribute__((nonnull))
37 #define NLIB_NONNULL_1 __attribute__((nonnull (1)))
38 #define NLIB_NONNULL_2 __attribute__((nonnull (2)))
39 #define NLIB_NONNULL_3 __attribute__((nonnull (3)))
40 #define NLIB_NONNULL_4 __attribute__((nonnull (4)))
41 #define NLIB_NONNULL_5 __attribute__((nonnull (5)))
42 #define NLIB_NONNULL_ENABLED
43 #define NLIB_ATTRIBUTE_MALLOC __attribute__((malloc))
44 #define NLIB_ATTRIBUTE_PURE __attribute__((pure))
45 #define NLIB_ATTRIBUTE_CONST __attribute__((const))
46 #define NLIB_ATTRIBUTE_ALLOC_SIZE1(n)
47 #define NLIB_ATTRIBUTE_ALLOC_SIZE2(n0, n1)
48 #define NLIB_ATTRIBUTE_ALLOC_ALIGN(algn)
49 #define NLIB_ATTRIBUTE_ASSUME_ALIGNED(n)
50 #ifndef NLIB_DEPRECATED
51 #define NLIB_DEPRECATED __attribute__((deprecated))
52 #endif
53 #ifndef NLIB_DEPRECATED_MSG
54 #define NLIB_DEPRECATED_MSG(msg) __attribute__((deprecated))
55 #endif
56 #define NLIB_VIS_HIDDEN
57 #define NLIB_VIS_PUBLIC
58 #define NLIB_WEAKSYMBOL __attribute__((weak))
59 
60 #define NLIB_MEMORY_ORDER_RELEASE __LWSYNC()
61 #define NLIB_MEMORY_ORDER_ACQUIRE __ISYNC()
62 #define NLIB_MEMORY_ORDER_ACQ_REL __LWSYNC(); __ISYNC()
63 #define NLIB_MEMORY_ORDER_SEQ_CST OSCoherencyBarrier()
64 
65 // GHS does not support '%zu', and cafe is 32bit environment
66 #define __PRIS_PREFIX
67 
68 typedef unsigned int nlib_tls;
69 
70 typedef OSFastMutex nlib_mutex;
71 #define NLIB_MUTEX_INITIALIZER {0}
72 #define NLIB_RECURSIVE_MUTEX_INITIALIZER {0}
73 #define NLIB_RECURSIVE_TIMED_MUTEX_INITIALIZER {0}
74 
75 typedef void* nlib_thread;
76 
77 typedef OSSemaphore nlib_semaphore;
78 
79 typedef OSFastCond nlib_cond;
80 #define NLIB_COND_INITIALIZER {0}
81 
82 void MyNoreturn_(void) __attribute__((noreturn));
83 #define NLIB_ASSUME(cond) switch (0) case 0: default: if (cond) ; else MyNoreturn_() /* NOLINT */
84 
85 #define NLIB_ATOMIC_RELAXED (0)
86 #define NLIB_ATOMIC_ACQUIRE (1)
87 #define NLIB_ATOMIC_RELEASE (2)
88 #define NLIB_ATOMIC_ACQ_REL (3)
89 #define NLIB_ATOMIC_SEQ_CST (7)
90 
91 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_load32(const int32_t* ptr, int memorder) {
92  int32_t rval = *(volatile int32_t*)ptr; // NOLINT
93  if (memorder & NLIB_ATOMIC_ACQUIRE)
95  return rval;
96 }
97 
98 static NLIB_ALWAYS_INLINE void nlib_atomic_store32(int32_t* ptr, int32_t val,
99  int memorder) {
100  if (memorder == NLIB_ATOMIC_SEQ_CST)
101  OSCoherencyBarrier();
102  else if (memorder & NLIB_ATOMIC_RELEASE)
104  *(volatile int32_t*)ptr = val; // NOLINT
105  if (memorder == NLIB_ATOMIC_SEQ_CST)
106  OSCoherencyBarrier();
107 }
108 
109 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_exchange32(int32_t* ptr, int32_t val,
110  int memorder) {
111  uint32_t x;
112  if (memorder == NLIB_ATOMIC_SEQ_CST)
113  OSCoherencyBarrier();
114  else if (memorder & NLIB_ATOMIC_RELEASE)
116  x = OSSwapAtomic((volatile OSAtomicVar*)ptr, (uint32_t)val); // NOLINT
117  if (memorder & NLIB_ATOMIC_ACQUIRE)
119  return (int32_t)x;
120 }
121 
122 static NLIB_ALWAYS_INLINE int nlib_atomic_compare_exchange32(int32_t* ptr, int32_t* expected,
123  int32_t desired, int weak,
124  int success_memorder,
125  int failure_memorder) {
126  if (success_memorder == NLIB_ATOMIC_SEQ_CST)
127  OSCoherencyBarrier();
128  else if (success_memorder & NLIB_ATOMIC_RELEASE)
130  if (weak == 0) {
131  BOOL result = OSCompareAndSwapAtomicEx(
132  (volatile OSAtomicVar*)ptr, // NOLINT
133  (u32)*expected, // NOLINT
134  (u32)desired, // NOLINT
135  (u32*)expected); // NOLINT
136  if (result) {
137  if (success_memorder & NLIB_ATOMIC_ACQUIRE)
139  } else {
140  if (failure_memorder & NLIB_ATOMIC_ACQUIRE)
142  }
143  return result;
144  } else {
145  u32 orig_val;
146  orig_val = (u32)__LWARX((u32*)ptr, 0);
147  if (orig_val == *expected) {
148  __DCBST(0, (u32)ptr);
149  if (__STWCX((u32*)ptr, 0, (u32)desired)) {
150  if (success_memorder & NLIB_ATOMIC_ACQUIRE)
152  return 1;
153  }
154  if (failure_memorder & NLIB_ATOMIC_ACQUIRE)
156  return 0;
157  } else {
158  *expected = (int32_t)orig_val;
159  if (failure_memorder & NLIB_ATOMIC_ACQUIRE)
161  return 0;
162  }
163  }
164 }
165 
166 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_add_fetch32(int32_t* ptr, int32_t val,
167  int memorder) {
168  int32_t x;
169  if (memorder == NLIB_ATOMIC_SEQ_CST)
170  OSCoherencyBarrier();
171  else if (memorder & NLIB_ATOMIC_RELEASE)
173  x = OSAddAtomic((volatile OSAtomicVar*)ptr, val); // NOLINT
174  if (memorder & NLIB_ATOMIC_ACQUIRE)
176  return x + val;
177 }
178 
179 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_sub_fetch32(int32_t* ptr, int32_t val,
180  int memorder) {
181  int32_t x;
182  if (memorder == NLIB_ATOMIC_SEQ_CST)
183  OSCoherencyBarrier();
184  else if (memorder & NLIB_ATOMIC_RELEASE)
186  x = OSAddAtomic((volatile OSAtomicVar*)ptr, -val); // NOLINT
187  if (memorder & NLIB_ATOMIC_ACQUIRE)
189  return x - val;
190 }
191 
192 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_and_fetch32(int32_t* ptr, int32_t val,
193  int memorder) {
194  int32_t x;
195  if (memorder == NLIB_ATOMIC_SEQ_CST)
196  OSCoherencyBarrier();
197  else if (memorder & NLIB_ATOMIC_RELEASE)
199  x = OSAndAtomic((volatile OSAtomicVar*)ptr, val); // NOLINT
200  if (memorder & NLIB_ATOMIC_ACQUIRE)
202  return x & val;
203 }
204 
205 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_xor_fetch32(int32_t* ptr, int32_t val,
206  int memorder) {
207  int32_t x;
208  if (memorder == NLIB_ATOMIC_SEQ_CST)
209  OSCoherencyBarrier();
210  else if (memorder & NLIB_ATOMIC_RELEASE)
212  x = OSXorAtomic((volatile OSAtomicVar*)ptr, val); // NOLINT
213  if (memorder & NLIB_ATOMIC_ACQUIRE)
215  return x ^ val;
216 }
217 
218 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_or_fetch32(int32_t* ptr, int32_t val,
219  int memorder) {
220  int32_t x;
221  if (memorder == NLIB_ATOMIC_SEQ_CST)
222  OSCoherencyBarrier();
223  else if (memorder & NLIB_ATOMIC_RELEASE)
225  x = OSOrAtomic((volatile OSAtomicVar*)ptr, val); // NOLINT
226  if (memorder & NLIB_ATOMIC_ACQUIRE)
228  return x | val;
229 }
230 
231 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_fetch_add32(int32_t* ptr, int32_t val,
232  int memorder) {
233  int32_t x;
234  if (memorder == NLIB_ATOMIC_SEQ_CST)
235  OSCoherencyBarrier();
236  else if (memorder & NLIB_ATOMIC_RELEASE)
238  x = OSAddAtomic((volatile OSAtomicVar*)ptr, val); // NOLINT
239  if (memorder & NLIB_ATOMIC_ACQUIRE)
241  return x;
242 }
243 
244 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_fetch_sub32(int32_t* ptr, int32_t val,
245  int memorder) {
246  int32_t x;
247  if (memorder == NLIB_ATOMIC_SEQ_CST)
248  OSCoherencyBarrier();
249  else if (memorder & NLIB_ATOMIC_RELEASE)
251  x = OSAddAtomic((volatile OSAtomicVar*)ptr, -val); // NOLINT
252  if (memorder & NLIB_ATOMIC_ACQUIRE)
254  return x;
255 }
256 
257 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_fetch_and32(int32_t* ptr, int32_t val,
258  int memorder) {
259  int32_t x;
260  if (memorder == NLIB_ATOMIC_SEQ_CST)
261  OSCoherencyBarrier();
262  else if (memorder & NLIB_ATOMIC_RELEASE)
264  x = OSAndAtomic((volatile OSAtomicVar*)ptr, val); // NOLINT
265  if (memorder & NLIB_ATOMIC_ACQUIRE)
267  return x;
268 }
269 
270 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_fetch_xor32(int32_t* ptr, int32_t val,
271  int memorder) {
272  int32_t x;
273  if (memorder == NLIB_ATOMIC_SEQ_CST)
274  OSCoherencyBarrier();
275  else if (memorder & NLIB_ATOMIC_RELEASE)
277  x = OSXorAtomic((volatile OSAtomicVar*)ptr, val); // NOLINT
278  if (memorder & NLIB_ATOMIC_ACQUIRE)
280  return x;
281 }
282 
283 static NLIB_ALWAYS_INLINE int32_t nlib_atomic_fetch_or32(int32_t* ptr, int32_t val,
284  int memorder) {
285  int32_t x;
286  if (memorder == NLIB_ATOMIC_SEQ_CST)
287  OSCoherencyBarrier();
288  else if (memorder & NLIB_ATOMIC_RELEASE)
290  x = OSOrAtomic((volatile OSAtomicVar*)ptr, val); // NOLINT
291  if (memorder & NLIB_ATOMIC_ACQUIRE)
293  return x;
294 }
295 
296 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_load64(const int64_t* ptr, int memorder) {
297  int64_t rval = (int64_t)OSGetAtomic64((volatile OSAtomicVar64*)ptr); // NOLINT
298  if (memorder & NLIB_ATOMIC_ACQUIRE)
300  return rval;
301 }
302 
303 static NLIB_ALWAYS_INLINE void nlib_atomic_store64(int64_t* ptr, int64_t val,
304  int memorder) {
305  if (memorder == NLIB_ATOMIC_SEQ_CST)
306  OSCoherencyBarrier();
307  else if (memorder & NLIB_ATOMIC_RELEASE)
309  OSSetAtomic64((volatile OSAtomicVar64*)ptr, (u64)val);
310  if (memorder == NLIB_ATOMIC_SEQ_CST)
311  OSCoherencyBarrier();
312 }
313 
314 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_exchange64(int64_t* ptr, int64_t val,
315  int memorder) {
316  uint64_t x;
317  if (memorder == NLIB_ATOMIC_SEQ_CST)
318  OSCoherencyBarrier();
319  else if (memorder & NLIB_ATOMIC_RELEASE)
321  x = OSSwapAtomic64((volatile OSAtomicVar64*)ptr, (uint64_t)val); // NOLINT
322  if (memorder & NLIB_ATOMIC_ACQUIRE)
324  return (int64_t)x;
325 }
326 
327 static NLIB_ALWAYS_INLINE int nlib_atomic_compare_exchange64(int64_t* ptr, int64_t* expected,
328  int64_t desired, int weak,
329  int success_memorder,
330  int failure_memorder) {
331  BOOL result;
332  (void)weak;
333  if (success_memorder == NLIB_ATOMIC_SEQ_CST)
334  OSCoherencyBarrier();
335  else if (success_memorder & NLIB_ATOMIC_RELEASE)
337 
338  result = OSCompareAndSwapAtomicEx64(
339  (volatile OSAtomicVar64*)ptr, // NOLINT
340  (u64)*expected, // NOLINT
341  (u64)desired, // NOLINT
342  (u64*)expected); // NOLINT
343  if (result) {
344  if (success_memorder & NLIB_ATOMIC_ACQUIRE)
346  } else {
347  if (failure_memorder & NLIB_ATOMIC_ACQUIRE)
349  }
350  return result;
351 }
352 
353 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_add_fetch64(int64_t* ptr, int64_t val,
354  int memorder) {
355  int64_t x;
356  if (memorder == NLIB_ATOMIC_SEQ_CST)
357  OSCoherencyBarrier();
358  else if (memorder & NLIB_ATOMIC_RELEASE)
360  x = OSAddAtomic64((volatile OSAtomicVar64*)ptr, val); // NOLINT
361  if (memorder & NLIB_ATOMIC_ACQUIRE)
363  return x + val;
364 }
365 
366 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_sub_fetch64(int64_t* ptr, int64_t val,
367  int memorder) {
368  int64_t x;
369  if (memorder == NLIB_ATOMIC_SEQ_CST)
370  OSCoherencyBarrier();
371  else if (memorder & NLIB_ATOMIC_RELEASE)
373  x = OSAddAtomic64((volatile OSAtomicVar64*)ptr, -val); // NOLINT
374  if (memorder & NLIB_ATOMIC_ACQUIRE)
376  return x - val;
377 }
378 
379 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_and_fetch64(int64_t* ptr, int64_t val,
380  int memorder) {
381  int64_t x;
382  if (memorder == NLIB_ATOMIC_SEQ_CST)
383  OSCoherencyBarrier();
384  else if (memorder & NLIB_ATOMIC_RELEASE)
386  x = OSAndAtomic64((volatile OSAtomicVar64*)ptr, val); // NOLINT
387  if (memorder & NLIB_ATOMIC_ACQUIRE)
389  return x & val;
390 }
391 
392 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_xor_fetch64(int64_t* ptr, int64_t val,
393  int memorder) {
394  int64_t x;
395  if (memorder == NLIB_ATOMIC_SEQ_CST)
396  OSCoherencyBarrier();
397  else if (memorder & NLIB_ATOMIC_RELEASE)
399  x = OSXorAtomic64((volatile OSAtomicVar64*)ptr, val); // NOLINT
400  if (memorder & NLIB_ATOMIC_ACQUIRE)
402  return x ^ val;
403 }
404 
405 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_or_fetch64(int64_t* ptr, int64_t val,
406  int memorder) {
407  int64_t x;
408  if (memorder == NLIB_ATOMIC_SEQ_CST)
409  OSCoherencyBarrier();
410  else if (memorder & NLIB_ATOMIC_RELEASE)
412  x = OSOrAtomic64((volatile OSAtomicVar64*)ptr, val); // NOLINT
413  if (memorder & NLIB_ATOMIC_ACQUIRE)
415  return x | val;
416 }
417 
418 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_fetch_add64(int64_t* ptr, int64_t val,
419  int memorder) {
420  int64_t x;
421  if (memorder == NLIB_ATOMIC_SEQ_CST)
422  OSCoherencyBarrier();
423  else if (memorder & NLIB_ATOMIC_RELEASE)
425  x = OSAddAtomic64((volatile OSAtomicVar64*)ptr, val); // NOLINT
426  if (memorder & NLIB_ATOMIC_ACQUIRE)
428  return x;
429 }
430 
431 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_fetch_sub64(int64_t* ptr, int64_t val,
432  int memorder) {
433  int64_t x;
434  if (memorder == NLIB_ATOMIC_SEQ_CST)
435  OSCoherencyBarrier();
436  else if (memorder & NLIB_ATOMIC_RELEASE)
438  x = OSAddAtomic64((volatile OSAtomicVar64*)ptr, -val); // NOLINT
439  if (memorder & NLIB_ATOMIC_ACQUIRE)
441  return x;
442 }
443 
444 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_fetch_and64(int64_t* ptr, int64_t val,
445  int memorder) {
446  int64_t x;
447  if (memorder == NLIB_ATOMIC_SEQ_CST)
448  OSCoherencyBarrier();
449  else if (memorder & NLIB_ATOMIC_RELEASE)
451  x = OSAndAtomic64((volatile OSAtomicVar64*)ptr, val); // NOLINT
452  if (memorder & NLIB_ATOMIC_ACQUIRE)
454  return x;
455 }
456 
457 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_fetch_xor64(int64_t* ptr, int64_t val,
458  int memorder) {
459  int64_t x;
460  if (memorder == NLIB_ATOMIC_SEQ_CST)
461  OSCoherencyBarrier();
462  else if (memorder & NLIB_ATOMIC_RELEASE)
464  x = OSXorAtomic64((volatile OSAtomicVar64*)ptr, val); // NOLINT
465  if (memorder & NLIB_ATOMIC_ACQUIRE)
467  return x;
468 }
469 
470 static NLIB_ALWAYS_INLINE int64_t nlib_atomic_fetch_or64(int64_t* ptr, int64_t val,
471  int memorder) {
472  int64_t x;
473  if (memorder == NLIB_ATOMIC_SEQ_CST)
474  OSCoherencyBarrier();
475  else if (memorder & NLIB_ATOMIC_RELEASE)
477  x = OSOrAtomic64((volatile OSAtomicVar64*)ptr, val); // NOLINT
478  if (memorder & NLIB_ATOMIC_ACQUIRE)
480  return x;
481 }
482 
483 static NLIB_ALWAYS_INLINE void* nlib_atomic_loadptr(void* const* ptr, int memorder) {
484  void* rval = *(void* volatile*)ptr; // NOLINT
485  if (memorder & NLIB_ATOMIC_ACQUIRE)
487  return rval;
488 }
489 
490 static NLIB_ALWAYS_INLINE void nlib_atomic_storeptr(void** ptr, void* val, int memorder) {
491  if (memorder == NLIB_ATOMIC_SEQ_CST)
492  OSCoherencyBarrier();
493  else if (memorder & NLIB_ATOMIC_RELEASE)
495  *(void* volatile*)ptr = val; // NOLINT
496  if (memorder == NLIB_ATOMIC_SEQ_CST)
497  OSCoherencyBarrier();
498 }
499 
500 static NLIB_ALWAYS_INLINE int nlib_atomic_compare_exchangeptr(void** ptr, void** expected,
501  void* desired, int weak,
502  int success_memorder,
503  int failure_memorder) {
504  return nlib_atomic_compare_exchange32((int32_t*)ptr, (int32_t*)expected, (int32_t)desired, // NOLINT
505  weak, success_memorder, failure_memorder);
506 }
507 
508 static NLIB_ALWAYS_INLINE void nlib_atomic_thread_fence(int memorder) {
509  switch (memorder) {
510  case NLIB_ATOMIC_RELAXED:
511  break;
512  case NLIB_ATOMIC_ACQUIRE:
514  break;
515  case NLIB_ATOMIC_RELEASE:
517  break;
518  case NLIB_ATOMIC_ACQ_REL:
520  break;
521  default:
523  break;
524  }
525 }
526 
527 #define NLIB_FD_O_RDONLY (0x0000)
528 #define NLIB_FD_O_WRONLY (0x0001)
529 #define NLIB_FD_O_RDWR (0x0002)
530 #define NLIB_FD_O_APPEND (0x0008)
531 #define NLIB_FD_O_CREAT (0x0100)
532 #define NLIB_FD_O_TRUNC (0x0200)
533 #define NLIB_FD_O_EXCL (0x0400)
534 
535 #ifdef __cplusplus
536 }
537 #endif
538 
539 #define NLIB_NOEXCEPT
540 
541 // --restrict is not specified in SDK's configuration
542 #ifndef __cplusplus
543 # define __restrict
544 #endif
545 
546 #define NLIB_MEMCPY(a, b, c) OSBlockMove((a), (b), (c), FALSE)
547 #define NLIB_MEMMOVE(a, b, c) OSBlockMove((a), (b), (c), FALSE)
548 #define NLIB_MEMSET(a, b, c) OSBlockSet((a), (b), (c))
549 
550 #ifndef NLIB_HAS_ZLIB
551 # define NLIB_HAS_ZLIB
552 #endif
553 
554 #ifndef NLIB_HAS_LIBCURL
555 # define NLIB_HAS_LIBCURL
556 #endif
557 
558 #endif
559 #endif // INCLUDE_NN_NLIB_PLATFORM_CAFE_H_
int32_t nlib_atomic_xor_fetch32(int32_t *ptr, int32_t val, int memorder)
アトミックな値の排他的論理和の計算を行います。動作はgccの__atomic_xor_fetch()に準じます。 ...
int64_t nlib_atomic_fetch_and64(int64_t *ptr, int64_t val, int memorder)
アトミックな値の論理積の計算を行います。動作はgccの__atomic_fetch_and()に準じます。 ...
int nlib_atomic_compare_exchangeptr(void **ptr, void **expected, void *desired, int weak, int success_memorder, int failure_memorder)
アトミックな値の比較と入れ替えを行います。動作はgccの__atomic_compare_exchange_n()に準じます。 ...
int32_t nlib_atomic_load32(const int32_t *ptr, int memorder)
アトミックに値をロードします。動作はgccの__atomic_load_n()に準じます。
#define NLIB_ALWAYS_INLINE
コンパイラに関数をインライン展開するように強く示します。
Definition: Platform_unix.h:69
int64_t nlib_atomic_fetch_add64(int64_t *ptr, int64_t val, int memorder)
アトミックな値の加算を行います。動作はgccの__atomic_fetch_add()に準じます。
sem_t nlib_semaphore
セマフォオブジェクトの型です。
#define NLIB_MEMORY_ORDER_ACQUIRE
メモリフェンスです。C++11ではatomic_thread_fence(memory_order_acquire)に一致します。 ...
#define NLIB_ATOMIC_RELEASE
gccの__ATOMIC_RELEASEやC++11のstd::memory_order_releaseに準じます。
int32_t nlib_atomic_or_fetch32(int32_t *ptr, int32_t val, int memorder)
アトミックな値の論理和の計算を行います。動作はgccの__atomic_or_fetch()に準じます。 ...
int64_t nlib_atomic_fetch_sub64(int64_t *ptr, int64_t val, int memorder)
アトミックな値の減算を行います。動作はgccの__atomic_fetch_sub()に準じます。
int64_t nlib_atomic_and_fetch64(int64_t *ptr, int64_t val, int memorder)
アトミックな値の論理積の計算を行います。動作はgccの__atomic_and_fetch()に準じます。 ...
int nlib_atomic_compare_exchange64(int64_t *ptr, int64_t *expected, int64_t desired, int weak, int success_memorder, int failure_memorder)
アトミックな値の比較と入れ替えを行います。動作はgccの__atomic_compare_exchange_n()に準じます。 ...
int64_t nlib_atomic_fetch_or64(int64_t *ptr, int64_t val, int memorder)
アトミックな値の論理和の計算を行います。動作はgccの__atomic_fetch_or()に準じます。 ...
#define NLIB_ATOMIC_ACQ_REL
gccの__ATOMIC_ACQ_RELやC++11のstd::memory_order_acq_relに準じます。
#define NLIB_ATOMIC_ACQUIRE
gccの__ATOMIC_ACQUIREやC++11のstd::memory_order_acquireに準じます。
pthread_key_t nlib_tls
TLSスロットのIDを示す型です。
void * nlib_atomic_loadptr(void *const *ptr, int memorder)
アトミックに値をロードします。動作はgccの__atomic_load_n()に準じます。
int64_t nlib_atomic_exchange64(int64_t *ptr, int64_t val, int memorder)
アトミックに値を入れ替えます。動作はgccの__atomic_exchange_n()に準じます。
#define NLIB_MEMORY_ORDER_SEQ_CST
メモリフェンスです。C++11ではatomic_thread_fence(memory_order_seq_cst)に一致します。 ...
int64_t nlib_atomic_sub_fetch64(int64_t *ptr, int64_t val, int memorder)
アトミックな値の減算を行います。動作はgccの__atomic_sub_fetch()に準じます。
int32_t nlib_atomic_fetch_xor32(int32_t *ptr, int32_t val, int memorder)
アトミックな値の排他的論理和の計算を行います。動作はgccの__atomic_fetch_xor()に準じます。 ...
#define NLIB_MEMORY_ORDER_ACQ_REL
メモリフェンスです。C++11ではatomic_thread_fence(memory_order_acq_rel)に一致します。 ...
int32_t nlib_atomic_sub_fetch32(int32_t *ptr, int32_t val, int memorder)
アトミックな値の減算を行います。動作はgccの__atomic_sub_fetch()に準じます。
int32_t nlib_atomic_fetch_sub32(int32_t *ptr, int32_t val, int memorder)
アトミックな値の減算を行います。動作はgccの__atomic_fetch_sub()に準じます。
int32_t nlib_atomic_add_fetch32(int32_t *ptr, int32_t val, int memorder)
アトミックな値の加算を行います。動作はgccの__atomic_add_fetch()に準じます。
void nlib_atomic_storeptr(void **ptr, void *val, int memorder)
アトミックに値をストアします。動作はgccの__atomic_store_n()に準じます。
void nlib_atomic_thread_fence(int memorder)
指定されたメモリバリアを配置します。
int32_t nlib_atomic_fetch_and32(int32_t *ptr, int32_t val, int memorder)
アトミックな値の論理積の計算を行います。動作はgccの__atomic_fetch_and()に準じます。 ...
pthread_cond_t nlib_cond
条件変数オブジェクトの型です。
#define NLIB_ATOMIC_RELAXED
gccの__ATOMIC_RELAXEDやC++11のstd::memory_order_relaxedに準じます。
pthread_mutex_t nlib_mutex
ミューテックス変数の型です。
int64_t nlib_atomic_xor_fetch64(int64_t *ptr, int64_t val, int memorder)
アトミックな値の排他的論理和の計算を行います。動作はgccの__atomic_xor_fetch()に準じます。 ...
#define NLIB_MEMORY_ORDER_RELEASE
メモリフェンスです。C++11ではatomic_thread_fence(memory_order_release)に一致します。 ...
int64_t nlib_atomic_add_fetch64(int64_t *ptr, int64_t val, int memorder)
アトミックな値の加算を行います。動作はgccの__atomic_add_fetch()に準じます。
int32_t nlib_atomic_and_fetch32(int32_t *ptr, int32_t val, int memorder)
アトミックな値の論理積の計算を行います。動作はgccの__atomic_and_fetch()に準じます。 ...
int nlib_atomic_compare_exchange32(int32_t *ptr, int32_t *expected, int32_t desired, int weak, int success_memorder, int failure_memorder)
アトミックな値の比較と入れ替えを行います。動作はgccの__atomic_compare_exchange_n()に準じます。 ...
void nlib_atomic_store64(int64_t *ptr, int64_t val, int memorder)
アトミックに値をストアします。動作はgccの__atomic_store_n()に準じます。
int64_t nlib_atomic_or_fetch64(int64_t *ptr, int64_t val, int memorder)
アトミックな値の論理和の計算を行います。動作はgccの__atomic_or_fetch()に準じます。 ...
#define NLIB_ATOMIC_SEQ_CST
gccの__ATOMIC_SEQ_CSTやC++11のstd::memory_order_seq_cstに準じます。
int32_t nlib_atomic_fetch_or32(int32_t *ptr, int32_t val, int memorder)
アトミックな値の論理和の計算を行います。動作はgccの__atomic_fetch_or()に準じます。 ...
int64_t nlib_atomic_fetch_xor64(int64_t *ptr, int64_t val, int memorder)
アトミックな値の排他的論理和の計算を行います。動作はgccの__atomic_fetch_xor()に準じます。 ...
int32_t nlib_atomic_fetch_add32(int32_t *ptr, int32_t val, int memorder)
アトミックな値の加算を行います。動作はgccの__atomic_fetch_add()に準じます。
void nlib_atomic_store32(int32_t *ptr, int32_t val, int memorder)
アトミックに値をストアします。動作はgccの__atomic_store_n()に準じます。
int32_t nlib_atomic_exchange32(int32_t *ptr, int32_t val, int memorder)
アトミックに値を入れ替えます。動作はgccの__atomic_exchange_n()に準じます。
pthread_t nlib_thread
スレッドを指し示す識別子
int64_t nlib_atomic_load64(const int64_t *ptr, int memorder)
アトミックに値をロードします。動作はgccの__atomic_load_n()に準じます。