16 #ifndef INCLUDE_NN_NLIB_PLATFORM_H_ 17 #define INCLUDE_NN_NLIB_PLATFORM_H_ 20 # error Sorry, ILP64 not supported 24 #define NLIB_VERSION_YEAR 2018 25 #define NLIB_VERSION_YEAR_SHORT 18 26 #define NLIB_VERSION_DATE 0605 27 #define NLIB_VERSION 20180605 30 # ifndef __STDC_FORMAT_MACROS 31 # define __STDC_FORMAT_MACROS // not needed in C11 34 #ifndef __STDC_WANT_LIB_EXT1__ 35 # define __STDC_WANT_LIB_EXT1__ 1 39 # define __has_builtin(x) 0 43 # define __has_feature(x) 0 46 #ifndef __has_cpp_attribute 47 # define __has_cpp_attribute(x) 0 50 #ifndef __has_attribute 51 # define __has_attribute(x) 0 54 #ifndef __has_declspec_attribute 55 # define __has_declspec_attribute(x) 0 59 # define __has_include(x) 0 62 #if __has_feature(thread_sanitizer) 63 # define NLIB_NO_TSAN __attribute__((no_sanitize("thread"))) 68 #if __has_feature(address_sanitizer) 69 # define NLIB_NO_ASAN __attribute__((no_sanitize("address"))) 74 #if __has_feature(memory_sanitizer) 75 # define NLIB_NO_MSAN __attribute__((no_sanitize("memory"))) 84 # define NLIB_UNUSED(x) (void)(x) 92 #if !defined(NLIB_THREAD_AA_) && defined(__clang__) && \ 93 (!defined(SWIG)) && __has_attribute(capability) 94 #define NLIB_THREAD_AA_(x) __attribute__((x)) 96 #ifdef NLIB_THREAD_AA_ 97 #undef NLIB_THREAD_AA_ 99 #define NLIB_THREAD_AA_(x) 102 #define NLIB_CAPABILITY(x) NLIB_THREAD_AA_(capability(x)) 103 #define NLIB_SCOPED_CAPABILITY NLIB_THREAD_AA_(scoped_lockable) 104 #define NLIB_GUARDED_BY(x) NLIB_THREAD_AA_(guarded_by(x)) 105 #define NLIB_PT_GUARDED_BY(x) NLIB_THREAD_AA_(pt_guarded_by(x)) 106 #define NLIB_ACQUIRED_BEFORE(...) NLIB_THREAD_AA_(acquired_before(__VA_ARGS__)) 107 #define NLIB_ACQUIRED_AFTER(...) NLIB_THREAD_AA_(acquired_after(__VA_ARGS__)) 108 #define NLIB_REQUIRES(...) NLIB_THREAD_AA_(requires_capability(__VA_ARGS__)) 109 #define NLIB_REQUIRES_SHARED(...) NLIB_THREAD_AA_(requires_shared_capability(__VA_ARGS__)) 110 #define NLIB_ACQUIRE(...) NLIB_THREAD_AA_(acquire_capability(__VA_ARGS__)) 111 #define NLIB_ACQUIRE_SHARED(...) NLIB_THREAD_AA_(acquire_shared_capability(__VA_ARGS__)) 112 #define NLIB_RELEASE(...) NLIB_THREAD_AA_(release_capability(__VA_ARGS__)) 113 #define NLIB_RELEASE_SHARED(...) NLIB_THREAD_AA_(release_shared_capability(__VA_ARGS__)) 114 #define NLIB_TRY_ACQUIRE(...) NLIB_THREAD_AA_(try_acquire_capability(__VA_ARGS__)) 115 #define NLIB_TRY_ACQUIRE_SHARED(...) NLIB_THREAD_AA_(try_acquire_shared_capability(__VA_ARGS__)) 116 #define NLIB_EXCLUDES(...) NLIB_THREAD_AA_(locks_excluded(__VA_ARGS__)) 117 #define NLIB_ASSERT_CAPABILITY(x) NLIB_THREAD_AA_(assert_capability(x)) 118 #define NLIB_ASSERT_SHARED_CAPABILITY(x) NLIB_THREAD_AA_(assert_shared_capability(x)) 119 #define NLIB_RETURN_CAPABILITY(x) NLIB_THREAD_AA_(lock_returned(x)) 120 #define NLIB_NO_THREAD_SAFETY_ANALYSIS NLIB_THREAD_AA_(no_thread_safety_analysis) 127 #if (defined(__cplusplus) && __cplusplus >= 201703L) || \ 128 (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) 132 #if defined(NLIB_RENAME_CAPI) 133 #include "nn/nlib/Platform_rename.h" 138 #define NLIB_CAPI(x) x 141 #define NLIB_STRINGIFY_(s) #s 142 #define NLIB_STRINGIFY(s) NLIB_STRINGIFY_(s) 144 #if defined(_MSC_VER) 145 # include "nn/nlib/Platform_win32.h" 146 #elif defined(__linux__) || \ 147 defined(__FreeBSD__) || \ 148 defined(__CYGWIN__) || \ 149 (defined(__APPLE__) && defined(__MACH__)) 153 # include "nn/nlib/Platform_unix.h" 154 #elif defined(NN_PLATFORM_CTR) 155 # include "nn/nlib/Platform_ctr.h" 157 # include "nn/nlib/Platform_cafe.h" 158 #elif defined(__NX__) 159 # include "nn/nlib/Platform_nx.h" 162 #if defined(_MSC_VER) && defined(n_EXPORTS) 163 #undef NLIB_VIS_PUBLIC 164 #define NLIB_VIS_PUBLIC NLIB_WINEXPORT 167 #ifndef __analysis_assume 168 # define __analysis_assume(expr) 171 #ifndef _Printf_format_string_ 172 # define _Printf_format_string_ 175 #if defined(__ARM_NEON__) || defined(__aarch64__) 196 #if defined(NLIB_SSE41) || defined(NLIB_NEON) 199 # include <arm_neon.h> 202 # include <smmintrin.h> 205 # include <nmmintrin.h> 209 #if defined(__ARM_ACLE) 210 #include <arm_acle.h> 217 # define RSIZE_MAX 0x7FFFFFFFL 219 # define RSIZE_MAX 0x7FFFFFFFFFFFFFFFLL 224 # define NLIB_WARN(exp) ("WARNING: " exp) 234 #ifndef __PRIS_PREFIX 235 # define __PRIS_PREFIX "z" 239 # define PRIdS __PRIS_PREFIX "d" 243 # define PRIxS __PRIS_PREFIX "x" 247 # define PRIuS __PRIS_PREFIX "u" 251 # define PRIXS __PRIS_PREFIX "X" 255 # define PRIoS __PRIS_PREFIX "o" 259 # define NLIB_ASSUME(cond) switch (0) case 0: default: if (cond) ; else __builtin_unreachable() 262 #ifdef NLIB_NONNULL_ENABLED 263 # define NLIB_EINVAL_IFNULL(p) 265 # define NLIB_EINVAL_IFNULL(p) if (!p) return EINVAL 268 #ifndef NLIB_C_INLINE 269 # define NLIB_C_INLINE __inline 281 #include <inttypes.h> 284 #ifdef __cpp_unicode_characters 305 #if defined(__cplusplus) && !defined(NLIB_DOXYGEN) 306 #if __cplusplus >= 201703L || (defined(_HAS_STD_BYTE) && _HAS_STD_BYTE != 0) 308 #elif __cplusplus >= 201103L || defined(_MSC_VER) 317 #if defined(__LP64__) && __LP64__ == 1 327 #ifndef NLIB_VIS_PUBLIC_ALT 328 #define NLIB_VIS_PUBLIC_ALT NLIB_VIS_PUBLIC 331 #ifndef NLIB_EXPIMP_TEMPLATE 332 # define NLIB_EXPIMP_TEMPLATE(x) NLIB_STATIC_ASSERT(sizeof(char) == 1) 362 #if defined(__INTELLISENSE__) 363 #define NLIB_ATOMIC_RELAXED (0) 364 #define NLIB_ATOMIC_ACQUIRE (1) 365 #define NLIB_ATOMIC_RELEASE (2) 366 #define NLIB_ATOMIC_ACQ_REL (3) 367 #define NLIB_ATOMIC_SEQ_CST (7) 373 int32_t val,
int memorder);
379 int success_memorder,
380 int failure_memorder);
408 int64_t desired,
int weak,
409 int success_memorder,
int failure_memorder);
436 int weak,
int success_memorder,
int failure_memorder);
444 #ifndef NLIB_TIMESPEC_HAS_NATIVE 463 #define NLIB_TO_TIMESPEC(tm, t) \ 464 (tm)->tv_sec = (time_t)((t) / (1000 * 10000)); \ 465 (tm)->tv_nsec = ((long)((t) % (1000 * 10000)) * 100) 467 #define NLIB_FROM_TIMESPEC(tm, t) \ 468 ((t) = (nlib_time)((tm)->tv_sec) * (1000 * 10000) + ((tm)->tv_nsec / 100)) 470 #define NLIB_TO_SEC_NSEC(sec, nsec, t) \ 471 (sec) = (int64_t)((t) / (1000 * 10000)); \ 472 (nsec) = ((uint32_t)((t) % (1000 * 10000)) * 100) 474 #define NLIB_FROM_SEC_NSEC(sec, nsec, t) \ 475 ((t) = (nlib_time)(sec) * (1000 * 10000) + ((nsec) / 100)) 481 NLIB_TO_TIMESPEC(tm, t);
489 NLIB_TO_TIMESPEC(tm, d);
495 NLIB_FROM_TIMESPEC(tm, d);
499 #if !defined(NLIB_TIMER_HAS_NATIVE) 501 #elif defined(_MSC_VER) 503 #elif defined(__linux__) 509 struct nlib_timerspec_ {
521 void* param, uint32_t flags);
528 #define NLIB_TIMER_SHORTTERM_TASK 0x00000001 529 #define NLIB_TIMER_LONGTERM_TASK 0x00000002 550 #define NLIB_PHYSICAL_ALLOC_PROT_NONE 0 551 #define NLIB_PHYSICAL_ALLOC_PROT_READ 1 552 #define NLIB_PHYSICAL_ALLOC_PROT_WRITE 2 553 #define NLIB_PHYSICAL_ALLOC_PROT_EXEC 4 559 #define NLIB_TLS_INVALID (nlib_tls)(-1) 562 #ifdef NLIB_PTHREAD_nlib_tls_alloc 580 #ifdef NLIB_PTHREAD_nlib_tls_alloc 583 return pthread_key_create(tls, destr);
585 errno_t e = pthread_key_create(tls, destr);
588 (void)pthread_setspecific(*tls, NULL);
594 #ifdef NLIB_PTHREAD_nlib_tls_free 596 return pthread_key_delete(tls);
601 #ifdef NLIB_PTHREAD_nlib_tls_setvalue 607 #ifdef NLIB_PTHREAD_nlib_tls_setvalue 609 return pthread_setspecific(tls, value);
613 #ifdef NLIB_PTHREAD_nlib_tls_getvalue 620 #ifdef NLIB_PTHREAD_nlib_tls_getvalue 622 *value = pthread_getspecific(tls);
631 #ifdef NLIB_PTHREAD_nlib_mutex_init 639 #ifdef NLIB_PTHREAD_nlib_mutex_init 641 return pthread_mutex_init(mutex, NULL);
652 #ifdef NLIB_PTHREAD_nlib_mutex_lock 665 #ifdef NLIB_PTHREAD_nlib_mutex_lock 667 return pthread_mutex_lock(mutex);
673 #ifdef NLIB_PTHREAD_nlib_mutex_trylock 679 #ifdef NLIB_PTHREAD_nlib_mutex_trylock 681 return pthread_mutex_trylock(mutex);
688 #ifdef NLIB_PTHREAD_nlib_mutex_unlock 694 #ifdef NLIB_PTHREAD_nlib_mutex_unlock 696 return pthread_mutex_unlock(mutex);
700 #ifdef NLIB_PTHREAD_nlib_mutex_destroy 707 #ifdef NLIB_PTHREAD_nlib_mutex_destroy 709 return pthread_mutex_destroy(mutex);
714 const struct timespec* tm)
715 NLIB_TRY_ACQUIRE(0, *mutex) {
717 NLIB_FROM_TIMESPEC(tm, delta);
741 NLIB_FROM_TIMESPEC(tm, duration);
749 #ifdef NLIB_PTHREAD_nlib_cond_init 757 #ifdef NLIB_PTHREAD_nlib_cond_init 759 return pthread_cond_init(cond, NULL);
763 #ifdef NLIB_PTHREAD_nlib_cond_signal 769 #ifdef NLIB_PTHREAD_nlib_cond_signal 771 return pthread_cond_signal(cond);
775 #ifdef NLIB_PTHREAD_nlib_cond_broadcast 781 #ifdef NLIB_PTHREAD_nlib_cond_broadcast 783 return pthread_cond_broadcast(cond);
787 #ifdef NLIB_PTHREAD_nlib_cond_wait 815 #ifdef NLIB_PTHREAD_nlib_cond_wait 818 return pthread_cond_wait(cond, mutex);
833 #ifdef NLIB_PTHREAD_nlib_cond_destroy 839 #ifdef NLIB_PTHREAD_nlib_cond_destroy 841 return pthread_cond_destroy(cond);
847 NLIB_REQUIRES(*mutex) {
849 NLIB_FROM_TIMESPEC(tm, d);
855 const struct timespec* tm) NLIB_REQUIRES(*mutex) {
857 NLIB_FROM_TIMESPEC(tm, d);
864 #ifndef NLIB_RWLOCK_HAS_NATIVE 865 struct nlib_rwlock_ {
870 NLIB_CAPABILITY(
"mutex")
873 #define NLIB_RWLOCK_INITIALIZER { \ 875 { NLIB_RECURSIVE_TIMED_MUTEX_INITIALIZER, NLIB_RECURSIVE_TIMED_MUTEX_INITIALIZER }, \ 876 NLIB_COND_INITIALIZER } 879 #ifdef NLIB_PTHREAD_nlib_rwlock_init 886 #ifdef NLIB_PTHREAD_nlib_rwlock_init 888 return pthread_rwlock_init(rwlock, NULL);
892 #ifdef NLIB_PTHREAD_nlib_rwlock_destroy 898 #ifdef NLIB_PTHREAD_nlib_rwlock_destroy 900 return pthread_rwlock_destroy(rwlock);
904 #ifdef NLIB_PTHREAD_nlib_rwlock_rdlock 910 #ifdef NLIB_PTHREAD_nlib_rwlock_rdlock 912 NLIB_NO_THREAD_SAFETY_ANALYSIS {
913 return pthread_rwlock_rdlock(rwlock);
917 #ifdef NLIB_PTHREAD_nlib_rwlock_tryrdlock 924 #ifdef NLIB_PTHREAD_nlib_rwlock_tryrdlock 926 NLIB_NO_THREAD_SAFETY_ANALYSIS {
927 return pthread_rwlock_tryrdlock(rwlock);
938 #ifdef NLIB_PTHREAD_nlib_rwlock_rdunlock 945 #ifdef NLIB_PTHREAD_nlib_rwlock_rdunlock 947 NLIB_NO_THREAD_SAFETY_ANALYSIS {
948 return pthread_rwlock_unlock(rwlock);
952 #ifdef NLIB_PTHREAD_nlib_rwlock_wrlock 958 #ifdef NLIB_PTHREAD_nlib_rwlock_wrlock 960 NLIB_NO_THREAD_SAFETY_ANALYSIS {
961 return pthread_rwlock_wrlock(rwlock);
965 #ifdef NLIB_PTHREAD_nlib_rwlock_trywrlock 971 #ifdef NLIB_PTHREAD_nlib_rwlock_trywrlock 973 NLIB_NO_THREAD_SAFETY_ANALYSIS {
974 return pthread_rwlock_trywrlock(rwlock);
985 #ifdef NLIB_PTHREAD_nlib_rwlock_wrunlock 991 #ifdef NLIB_PTHREAD_nlib_rwlock_wrunlock 993 NLIB_NO_THREAD_SAFETY_ANALYSIS {
994 return pthread_rwlock_unlock(rwlock);
1000 NLIB_TRY_ACQUIRE_SHARED(0, *rwlock) {
1002 NLIB_FROM_TIMESPEC(tm, d);
1006 static NLIB_C_INLINE
1008 NLIB_TRY_ACQUIRE_SHARED(0, *rwlock) {
1010 NLIB_FROM_TIMESPEC(tm, d);
1014 static NLIB_C_INLINE
1016 NLIB_TRY_ACQUIRE(0, *rwlock) {
1018 NLIB_FROM_TIMESPEC(tm, d);
1022 static NLIB_C_INLINE
1024 NLIB_TRY_ACQUIRE(0, *rwlock) {
1026 NLIB_FROM_TIMESPEC(tm, d);
1031 #if defined(_MSC_VER) && defined(NLIB_RWLOCK_HAS_NATIVE) 1032 typedef struct nlib_condrwlock_ {
1033 CONDITION_VARIABLE cond;
1035 #define NLIB_CONDRWLOCK_INITIALIZER { CONDITION_VARIABLE_INIT } 1037 typedef struct nlib_condrwlock_ {
1041 #define NLIB_CONDRWLOCK_INITIALIZER { NLIB_COND_INITIALIZER, NLIB_MUTEX_INITIALIZER } 1062 const struct timespec* tm,
1065 NLIB_FROM_TIMESPEC(tm, d);
1071 const struct timespec* tm,
1074 NLIB_FROM_TIMESPEC(tm, d);
1081 #ifndef NLIB_BARRIER_HAS_NATIVE 1082 struct nlib_barrier_ {
1090 #ifdef NLIB_PTHREAD_nlib_barrier_init 1096 #ifdef NLIB_PTHREAD_nlib_barrier_init 1098 return pthread_barrier_init(barrier, NULL, count);
1102 #ifdef NLIB_PTHREAD_nlib_barrier_destroy 1108 #ifdef NLIB_PTHREAD_nlib_barrier_destroy 1110 return pthread_barrier_destroy(barrier);
1119 #ifndef NLIB_ONCE_HAS_NATIVE 1120 struct nlib_onceflag_ {
1124 #define NLIB_ONCE_INIT { 0 } 1133 #elif defined(_MSC_VER) 1135 #define NLIB_ONCE_INIT INIT_ONCE_STATIC_INIT 1138 #elif defined(__APPLE__) || defined(__FreeBSD__) 1140 #define NLIB_ONCE_INIT 0 1145 #define NLIB_ONCE_INIT PTHREAD_ONCE_INIT 1149 return pthread_once(flag, func);
1159 typedef struct nlib_mq_ {
1165 #define NLIB_MQ_BLOCK 0 1166 #define NLIB_MQ_NONBLOCK 1 1167 #define NLIB_MQ_LOCKFREE 2 1178 typedef struct nlib_mq_attr_ {
1208 #if defined(__x86_64__) || defined(__i386__) || defined(_M_IX86) || defined(_M_AMD64) 1210 #elif defined(__ARM_ACLE) 1217 #define NLIB_THREAD_INVALID (nlib_thread)(0) 1219 #ifndef NLIB_SPINLOCK_HAS_NATIVE 1223 #ifndef NLIB_THREAD_ATTR_HAS_NATIVE 1224 struct nlib_thread_attr_ {
1235 struct nlib_thread_attr_ {
1236 pthread_attr_t attr;
1253 #ifdef NLIB_PTHREAD_nlib_thread_join 1259 #ifdef NLIB_PTHREAD_nlib_thread_join 1261 return pthread_join(thread, NULL);
1265 #ifdef NLIB_PTHREAD_nlib_thread_detach 1271 #ifdef NLIB_PTHREAD_nlib_thread_detach 1273 return pthread_detach(thread);
1277 #ifdef NLIB_PTHREAD_nlib_thread_self 1283 #ifdef NLIB_PTHREAD_nlib_thread_self 1285 *thread = pthread_self();
1293 #ifdef NLIB_PTHREAD_nlib_thread_equal 1299 #ifdef NLIB_PTHREAD_nlib_thread_equal 1301 return pthread_equal(th1, th2);
1309 #ifdef NLIB_PTHREAD_nlib_thread_getname 1315 #ifdef NLIB_PTHREAD_nlib_thread_getname 1317 return pthread_getname_np(thread, name, len);
1342 void** __restrict stack_addr,
size_t* __restrict stack_size)
1346 #define NLIB_THREAD_ATTR_KEY_DETACHSTATE (1) 1347 #define NLIB_THREAD_ATTR_KEY_STACKSIZE (2) 1348 #define NLIB_THREAD_ATTR_KEY_PRIORITY (4) 1349 #define NLIB_THREAD_ATTR_KEY_AFFINITY (5) 1350 #define NLIB_THREAD_ATTR_KEY_EXPLICIT_SCHED (6) 1358 #ifndef NN_PLATFORM_CTR 1366 #elif defined(pthread_cleanup_push) 1367 # define nlib_thread_cleanup_push(fn, arg) pthread_cleanup_push(fn, arg) 1368 # define nlib_thread_cleanup_pop(exec) pthread_cleanup_pop(exec) 1369 #elif !defined(NN_PLATFORM_CTR) 1370 struct nlib_thread_cleanup_handler_ {
1371 void (*func)(
void*);
1373 struct nlib_thread_cleanup_handler_* next;
1375 #define nlib_thread_cleanup_push(fn, arg) switch (0) case 0: default: { \ 1376 struct nlib_thread_cleanup_handler_ _thread_cleanup_handler = { fn, arg, NULL }; \ 1377 nlib_thread_cleanup_push_(&_thread_cleanup_handler) 1378 #define nlib_thread_cleanup_pop(exec) nlib_thread_cleanup_pop_(exec); } 1380 NLIB_VIS_PUBLIC void nlib_thread_cleanup_push_(
struct nlib_thread_cleanup_handler_* handler);
1402 void*
const* __restrict buf,
size_t count)
NLIB_NONNULL;
1408 kNlibLogUnknown = 0,
1417 kNlibLogLevelEqualOrAbove = 0x10,
1418 kNlibLogLevelEqualOrBelow = 0x20,
1419 kNlibLogLevelAll = 0x30
1422 typedef enum nlib_log_key {
1423 kNlibLogAttrUnknown = 0,
1426 kNlibLogAttrMsvcTrace,
1432 #ifndef NLIB_ATTRIBUTE_PRINTF 1433 # define NLIB_ATTRIBUTE_PRINTF(x, y) __attribute__((format(printf, x, y))) 1437 const char* __restrict fmt, ...)
1446 #ifndef NLIB_FD_O_RDONLY 1450 # define NLIB_FD_O_RDONLY O_RDONLY 1453 #ifndef NLIB_FD_O_WRONLY 1457 # define NLIB_FD_O_WRONLY O_WRONLY 1460 #ifndef NLIB_FD_O_RDWR 1464 # define NLIB_FD_O_RDWR O_RDWR 1467 #ifndef NLIB_FD_O_APPEND 1471 # define NLIB_FD_O_APPEND O_APPEND 1474 #ifndef NLIB_FD_O_CREAT 1478 # define NLIB_FD_O_CREAT O_CREAT 1481 #ifndef NLIB_FD_O_TRUNC 1485 # define NLIB_FD_O_TRUNC O_TRUNC 1488 #ifndef NLIB_FD_O_EXCL 1492 # define NLIB_FD_O_EXCL O_EXCL 1495 #ifndef NLIB_SEEK_SET 1499 # define NLIB_SEEK_SET SEEK_SET 1502 #ifndef NLIB_SEEK_CUR 1506 # define NLIB_SEEK_CUR SEEK_CUR 1514 #define NLIB_FD_INVALID (-1) 1555 #if !defined(NLIB_IOVEC_HAS_NATIVE) 1556 struct nlib_fd_iovec_ {
1560 typedef struct nlib_fd_iovec_ nlib_fd_iovec;
1562 typedef struct iovec nlib_fd_iovec;
1580 unsigned int flags);
1584 errno_t nlib_rename(
const char* __restrict old_path,
const char* __restrict new_path);
1589 typedef struct nlib_dir_ nlib_dir;
1590 typedef struct nlib_dirent_ {
1611 uint64_t* __restrict free_bytes_available,
1612 uint64_t* __restrict total_bytes,
1613 uint64_t* __restrict total_free_bytes);
1619 struct nlib_fileid_ {
1620 #if defined(_MSC_VER) 1622 #elif defined(NLIB_UNIX) 1629 typedef struct nlib_fileid_ nlib_fileid;
1637 #if defined(_MSC_VER) || defined(NLIB_UNIX) 1638 #include "nn/nlib/Platform_socket.h" 1649 # warning Do not define EDQUOT. nlib may not work correctly. 1653 #ifndef NLIB_SKIP_ERRNO_DEFINE 1655 #if !defined(__CYGWIN__) && !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NX__) 1656 #include "nn/nlib/Platform_errno.h" 1663 #ifndef NLIB_SPINLOCK_HAS_NATIVE 1664 #define NLIB_SPINLOCK_INITIALIZER (0) 1666 #ifndef NN_PLATFORM_CTR 1679 #if defined(__arm__) 1680 #if __has_builtin(__builtin_arm_ldrex) 1681 int R5 = __builtin_arm_ldrex(lock);
1683 int R5 = __ldrex(lock);
1686 #if __has_builtin(__builtin_arm_strex) 1687 if (__builtin_arm_strex(1, lock) == 0) {
1689 if (__strex(1, lock) == 0) {
1691 #if !defined(NN_PLATFORM_CTR) 1699 nlib_spinlock_lock_(lock);
1701 int32_t expected = 0;
1704 nlib_spinlock_lock_(lock);
1709 #if defined(__arm__) 1710 #if __has_builtin(__builtin_arm_ldrex) 1711 int R5 = __builtin_arm_ldrex(lock);
1713 int R5 = __ldrex(lock);
1716 #if __has_builtin(__builtin_arm_strex) 1717 if (__builtin_arm_strex(1, lock) == 0) {
1719 if (__strex(1, lock) == 0) {
1721 #if !defined(NN_PLATFORM_CTR) 1731 int32_t expected = 0;
1740 #if defined(NN_PLATFORM_CTR) 1743 int32_t expected = 1;
1747 nlib_spinlock_unlock_(lock);
1749 #if defined(__arm__) 1761 _Printf_format_string_
const char* __restrict fmt, va_list args)
1765 _Printf_format_string_
const char* __restrict fmt, ...)
1769 _Printf_format_string_ const
char* __restrict fmt, va_list args)
1773 _Printf_format_string_ const
char* __restrict fmt, ...)
1777 int nlib_printf(_Printf_format_string_ const
char* fmt, ...)
1782 _Printf_format_string_ const
wchar_t* __restrict fmt, va_list args)
1786 _Printf_format_string_ const
wchar_t* __restrict fmt, ...)
1790 _Printf_format_string_ const
wchar_t* __restrict fmt, va_list args)
1794 _Printf_format_string_ const
wchar_t* __restrict fmt, ...)
NLIB_NONNULL_3;
1799 errno_t nlib_vsnprintf_fallback(
size_t* __restrict count,
char* __restrict buf,
size_t size,
1800 _Printf_format_string_ const
char* __restrict fmt, va_list args)
1803 errno_t nlib_snprintf_fallback(
size_t* __restrict count,
char* __restrict buf,
1804 size_t size, _Printf_format_string_ const
char* __restrict fmt, ...)
1807 errno_t nlib_vsnwprintf_fallback(
size_t* __restrict count,
wchar_t* __restrict buf,
size_t size,
1808 _Printf_format_string_ const
wchar_t* __restrict fmt, va_list args)
1811 errno_t nlib_snwprintf_fallback(
size_t* __restrict count,
wchar_t* __restrict buf,
size_t size,
1812 _Printf_format_string_ const
wchar_t* __restrict fmt, ...)
1820 static
errno_t nlib_memcpy(
void* __restrict s1,
size_t s1max, const
void* __restrict s2,
size_t n)
1825 void*
nlib_memccpy(
void* __restrict dest,
size_t dest_size, const
void* __restrict src,
1828 #ifdef NLIB_LIBC_nlib_memcmp 1834 #ifdef NLIB_LIBC_nlib_memcmp 1835 static NLIB_C_INLINE
int nlib_memcmp(
const void* buf1,
const void* buf2,
size_t n) {
1836 return memcmp(buf1, buf2, n);
1840 NLIB_VIS_PUBLIC_ALT
const void*
nlib_memchr(
const void* s,
int c,
size_t n)
1842 NLIB_VIS_PUBLIC_ALT
const void*
nlib_memrchr(
const void* s,
int c,
size_t n)
1844 NLIB_VIS_PUBLIC_ALT
const void*
nlib_memchr_not(
const void* s,
int c,
size_t n)
1849 NLIB_VIS_PUBLIC_ALT
const void*
nlib_memchr_lt(
const void* s,
int c,
size_t n)
1851 NLIB_VIS_PUBLIC_ALT
const void*
nlib_memchr_gt(
const void* s,
int c,
size_t n)
1854 NLIB_VIS_PUBLIC_ALT
const void*
nlib_memchr_mb(
const void* s,
size_t n)
1857 const char* __restrict
set,
size_t n)
1860 const char* __restrict
set,
size_t n)
1865 const char*
nlib_skipws(
size_t* __restrict cnt_lf,
const char** __restrict last_lf,
1868 #ifdef NLIB_LIBC_nlib_strlen 1874 #ifdef NLIB_LIBC_nlib_strlen 1875 static NLIB_C_INLINE
size_t nlib_strlen(
const char* s) {
return strlen(s); }
1878 #ifdef NLIB_LIBC_nlib_strnlen 1884 #ifdef NLIB_LIBC_nlib_strnlen 1885 static NLIB_C_INLINE
size_t nlib_strnlen(
const char* s,
size_t maxsize) {
1886 #if defined(_MSC_VER) || defined(__STDC_LIB_EXT1__) 1887 return strnlen_s(s, maxsize);
1889 return strnlen(s, maxsize);
1894 #ifdef NLIB_LIBC_nlib_strcpy 1900 #ifdef NLIB_LIBC_nlib_strcpy 1901 static NLIB_C_INLINE
1903 #if defined(_MSC_VER) || defined(__STDC_LIB_EXT1__) 1904 return strcpy_s(s1, s1max, s2);
1911 #ifdef NLIB_LIBC_nlib_strncpy 1916 errno_t nlib_strncpy(
char* __restrict s1,
size_t s1max,
const char* __restrict s2,
size_t n)
1918 #ifdef NLIB_LIBC_nlib_strncpy 1919 static NLIB_C_INLINE
1920 errno_t nlib_strncpy(
char* __restrict s1,
size_t s1max,
const char* __restrict s2,
size_t n) {
1921 #if defined(_MSC_VER) || defined(__STDC_LIB_EXT1__) 1922 return strncpy_s(s1, s1max, s2, n);
1929 #ifdef NLIB_LIBC_nlib_strchr 1935 #ifdef NLIB_LIBC_nlib_strchr 1936 static NLIB_C_INLINE
const char*
nlib_strchr(
const char* s,
int c) {
return strchr(s, c); }
1939 #ifdef NLIB_LIBC_nlib_strrchr 1945 #ifdef NLIB_LIBC_nlib_strrchr 1946 static NLIB_C_INLINE
const char*
nlib_strrchr(
const char* s,
int c) {
return strrchr(s, c); }
1951 static NLIB_C_INLINE
const char* nlib_strchr_mb(
const char* s) {
1955 return (
const char*)p;
1961 #ifdef NLIB_LIBC_nlib_wcslen 1967 #ifdef NLIB_LIBC_nlib_wcslen 1968 static NLIB_C_INLINE
size_t nlib_wcslen(
const wchar_t* s) {
return wcslen(s); }
1971 #ifdef NLIB_LIBC_nlib_wcsnlen 1977 #ifdef NLIB_LIBC_nlib_wcsnlen 1978 static NLIB_C_INLINE
size_t nlib_wcsnlen(
const wchar_t* s,
size_t maxsize) {
1979 #if defined(_MSC_VER) || defined(__STDC_LIB_EXT1__) 1980 return wcsnlen_s(s, maxsize);
1982 return wcsnlen(s, maxsize);
1987 #ifdef NLIB_LIBC_nlib_wcscpy 1992 errno_t nlib_wcscpy(
wchar_t* __restrict s1,
size_t s1max,
const wchar_t* __restrict s2)
1994 #ifdef NLIB_LIBC_nlib_wcscpy 1995 static NLIB_C_INLINE
1996 errno_t nlib_wcscpy(
wchar_t* __restrict s1,
size_t s1max,
const wchar_t* __restrict s2) {
1997 #if defined(_MSC_VER) || defined(__STDC_LIB_EXT1__) 1998 return wcscpy_s(s1, s1max, s2);
2005 #ifdef NLIB_LIBC_nlib_wcsncpy 2010 errno_t nlib_wcsncpy(
wchar_t* __restrict s1,
size_t s1max,
const wchar_t* __restrict s2,
size_t n)
2012 #ifdef NLIB_LIBC_nlib_wcsncpy 2013 static NLIB_C_INLINE
2014 errno_t nlib_wcsncpy(
wchar_t* __restrict s1,
size_t s1max,
const wchar_t* __restrict s2,
size_t n) {
2015 #if defined(_MSC_VER) || defined(__STDC_LIB_EXT1__) 2016 return wcsncpy_s(s1, s1max, s2, n);
2059 static NLIB_C_INLINE
2060 errno_t nlib_strto_int8(int8_t* result,
const char* nptr,
char** endptr,
int base) {
2064 if (e != 0 && e != ERANGE)
return e;
2065 if (tmp > 127 || tmp < -128) {
2066 *result = tmp < 0 ? -128 : 127;
2069 *result = (int8_t)tmp;
2072 static NLIB_C_INLINE
2073 errno_t nlib_strto_int16(int16_t* result,
const char* nptr,
char** endptr,
int base) {
2077 if (e != 0 && e != ERANGE)
return e;
2078 if (tmp > 32767 || tmp < -32768) {
2079 *result = tmp < 0 ? -32768 : 32767;
2082 *result = (int16_t)tmp;
2085 static NLIB_C_INLINE
2086 errno_t nlib_strto_uint8(uint8_t* result,
const char* nptr,
char** endptr,
int base) {
2090 if (e != 0 && e != ERANGE)
return e;
2095 *result = (uint8_t)tmp;
2098 static NLIB_C_INLINE
2099 errno_t nlib_strto_uint16(uint16_t* result,
const char* nptr,
char** endptr,
int base) {
2103 if (e != 0 && e != ERANGE)
return e;
2108 *result = (uint16_t)tmp;
2113 const char* first,
const char* last,
int base);
2116 const char* first,
const char* last,
int base);
2119 const char* first,
const char* last,
int base);
2122 const char* first,
const char* last,
int base);
2125 const char* first,
const char* last,
int base);
2128 const char* first,
const char* last,
int base);
2131 const char* first,
const char* last,
int base);
2134 const char* first,
const char* last,
int base);
2137 const char* first,
const char* last);
2140 const char* first,
const char* last);
2151 const wchar_t* __restrict from,
size_t from_size)
2155 wchar_t* __restrict to,
size_t to_size,
2156 const nlib_utf8_t* __restrict from,
size_t from_size)
2163 size_t* __restrict supplementary_codepoint_count,
2164 size_t* __restrict len,
2168 size_t* __restrict supplementary_codepoint_count,
2169 size_t* __restrict from_read,
2211 const nlib_utf8_t* __restrict from,
size_t from_size)
2221 const nlib_utf8_t* __restrict from,
size_t from_size)
2228 size_t nlib_utf16len_(
const uint16_t* str)
NLIB_NONNULL;
2230 size_t nlib_utf16nlen_(
const uint16_t* str,
size_t maxsize)
NLIB_NONNULL;
2234 errno_t nlib_utf16ncpy_(uint16_t* s1,
size_t s1max,
const uint16_t* s2,
size_t n)
NLIB_NONNULL;
2237 return nlib_utf16len_((
const uint16_t*)str);
2241 return nlib_utf16nlen_((
const uint16_t*)str, maxsize);
2245 return nlib_utf16cpy_((uint16_t*)s1, s1max, (
const uint16_t*)s2);
2249 return nlib_utf16ncpy_((uint16_t*)s1, s1max, (
const uint16_t*)s2, n);
2253 size_t nlib_utf32len_(
const uint32_t* str)
NLIB_NONNULL;
2255 size_t nlib_utf32nlen_(
const uint32_t* str,
size_t maxsize)
NLIB_NONNULL;
2259 errno_t nlib_utf32ncpy_(uint32_t* s1,
size_t s1max,
const uint32_t* s2,
size_t n)
NLIB_NONNULL;
2262 return nlib_utf32len_((
const uint32_t*)str);
2266 return nlib_utf32nlen_((
const uint32_t*)str, maxsize);
2270 return nlib_utf32cpy_((uint32_t*)s1, s1max, (
const uint32_t*)s2);
2274 return nlib_utf32ncpy_((uint32_t*)s1, s1max, (
const uint32_t*)s2, n);
2282 return nlib_utf16cplen_ex_(count, NULL, (
const uint16_t*)str);
2286 return nlib_utf16cplen_ex_(count, len, (
const uint16_t*)str);
2291 #if defined(CAFE) || defined(NN_PLATFORM_CTR) 2293 return ((x & 0xFF) << 8) | ((x >> 8) & 0xFF);
2296 return (x << 24) | ((x & 0xFF00U) << 8) | ((x >> 8) & 0xFF00U) | (x >> 24);
2300 ((x & 0xFF00U) << 40) |
2301 ((x & 0xFF0000U) << 24) |
2302 ((x & 0xFF000000U) << 8) |
2303 ((x >> 8) & 0xFF000000U) |
2304 ((x >> 24) & 0xFF0000U) |
2305 ((x >> 40) & 0xFF00U) |
2308 #elif defined(_MSC_VER) 2319 kUnicodeCharCategoryLu = 0,
2320 kUnicodeCharCategoryLl = 1,
2321 kUnicodeCharCategoryLt = 2,
2322 kUnicodeCharCategoryLm = 3,
2323 kUnicodeCharCategoryLo = 4,
2324 kUnicodeCharCategoryMn = 5,
2325 kUnicodeCharCategoryMc = 6,
2326 kUnicodeCharCategoryMe = 7,
2327 kUnicodeCharCategoryNd = 8,
2328 kUnicodeCharCategoryNl = 9,
2329 kUnicodeCharCategoryNo = 10,
2330 kUnicodeCharCategoryPc = 11,
2331 kUnicodeCharCategoryPd = 12,
2332 kUnicodeCharCategoryPs = 13,
2333 kUnicodeCharCategoryPe = 14,
2334 kUnicodeCharCategoryPi = 15,
2335 kUnicodeCharCategoryPf = 16,
2336 kUnicodeCharCategoryPo = 17,
2337 kUnicodeCharCategorySm = 18,
2338 kUnicodeCharCategorySc = 19,
2339 kUnicodeCharCategorySk = 20,
2340 kUnicodeCharCategorySo = 21,
2341 kUnicodeCharCategoryZs = 22,
2342 kUnicodeCharCategoryZl = 23,
2343 kUnicodeCharCategoryZp = 24,
2344 kUnicodeCharCategoryCc = 25,
2345 kUnicodeCharCategoryCf = 26,
2346 kUnicodeCharCategoryCs = 27,
2347 kUnicodeCharCategoryCo = 28,
2348 kUnicodeCharCategoryCn = 29
2351 kCaseMappingUpperCase = 0,
2352 kCaseMappingLowerCase
2356 kUnicodeCharPropertyCategory = 0,
2357 kUnicodeCharPropertyCombiningClass
2360 kCaseFoldingDefault = 0,
2361 kCaseFoldingExcludeSpecialI
2373 kUnicodeBreakPropertyGrapheme = 0,
2374 kUnicodeBreakPropertyWord,
2375 kUnicodeBreakPropertySentence,
2376 kUnicodeBreakPropertyLine
2379 kUnicodeBreakStop = 0,
2380 kUnicodeBreakContinue,
2381 kUnicodeBreakDefault = 0
2431 NLIB_VIS_PUBLIC_ALT
void nlib_free(
void* ptr);
2454 # define NLIB_MEMCPY(a, b, c) memcpy((a), (b), (c)) 2457 #ifndef NLIB_MEMMOVE 2458 # define NLIB_MEMMOVE(a, b, c) memmove((a), (b), (c)) 2462 # define NLIB_MEMSET(a, b, c) memset((a), (b), (c)) 2482 return (
'0' <= ch && ch <=
'9') || (
'A' <= ch && ch <=
'Z') || (
'a' <= ch && ch <=
'z');
2485 return (
'A' <= ch && ch <=
'Z') || (
'a' <= ch && ch <=
'z');
2487 static NLIB_C_INLINE
int nlib_isblank(
int ch) {
return ch ==
' ' || ch ==
'\t'; }
2488 static NLIB_C_INLINE
int nlib_iscntrl(
int ch) {
return (ch >= 0 && ch <= 0x1F) || ch == 0x7F; }
2489 static NLIB_C_INLINE
int nlib_isdigit(
int ch) {
return (
'0' <= ch && ch <=
'9'); }
2490 static NLIB_C_INLINE
int nlib_isgraph(
int ch) {
return ch >= 0x21 && ch <= 0x7E; }
2491 static NLIB_C_INLINE
int nlib_islower(
int ch) {
return (ch >=
'a' && ch <=
'z'); }
2492 static NLIB_C_INLINE
int nlib_isprint(
int ch) {
return ch >= 0x20 && ch <= 0x7E; }
2493 static NLIB_C_INLINE
int nlib_ispunct(
int ch) {
return (ch >= 0x00 && ch <= 0x20) || ch == 0x7F; }
2495 return ((ch) ==
' ' || (ch) ==
'\t' || (ch) ==
'\n');
2497 static NLIB_C_INLINE
int nlib_isupper(
int ch) {
return (ch >=
'A' && ch <=
'Z'); }
2499 return (
unsigned int)(ch -
'0') < 10u ||
2500 (
unsigned int)((ch | 0x20) -
'a') < 6u;
2503 return (ch >=
'A' && ch <=
'Z') ? ch + (
'a' -
'A') : ch;
2506 return (ch >=
'a' && ch <=
'z') ? ch - (
'a' -
'A') : ch;
2511 static NLIB_C_INLINE
2512 errno_t nlib_memcpy(
void* __restrict s1,
size_t s1max,
const void* __restrict s2,
size_t n) {
2513 #if defined(_MSC_VER) || defined(__STDC_LIB_EXT1__) 2514 return memcpy_s(s1, s1max, s2, n);
2516 #ifndef NLIB_NONNULL_ENABLED 2517 if (!s1 || !s2)
return ERANGE;
2520 NLIB_MEMSET(s1, 0, s1max);
2523 NLIB_MEMCPY(s1, s2, n);
2529 static NLIB_C_INLINE
2531 #if defined(_MSC_VER) || defined(__STDC_LIB_EXT1__) 2532 return memmove_s(s1, s1max, s2, n);
2534 #ifndef NLIB_NONNULL_ENABLED 2535 if (!s1 || !s2)
return ERANGE;
2537 if (s1max < n)
return ERANGE;
2538 NLIB_MEMMOVE(s1, s2, n);
2543 static NLIB_C_INLINE
2545 NLIB_EINVAL_IFNULL(buf);
2546 NLIB_MEMSET(buf, ch, n);
2553 #if defined(NLIB_SSE42) 2555 return _mm_popcnt_u32(x);
2558 return _mm_popcnt_u32(x);
2562 return (
int)_mm_popcnt_u64(x);
2564 uint32_t lo = (uint32_t)(x & 0xFFFFFFFFU);
2565 uint32_t hi = (uint32_t)((x >> 32) & 0xFFFFFFFFU);
2566 return _mm_popcnt_u32(lo) + _mm_popcnt_u32(hi);
2569 #elif defined(NLIB_NEON) 2571 uint8x8_t x0 = vcnt_u8(vreinterpret_u8_u64(vcreate_u64(x)));
2573 return vaddv_u8(x0);
2575 uint8x8_t x1 = vpadd_u8(x0, x0);
2576 return vget_lane_u8(x1, 0);
2580 uint8x8_t x0 = vcnt_u8(vreinterpret_u8_u64(vcreate_u64(x)));
2582 return vaddv_u8(x0);
2584 uint8x8_t x1 = vpadd_u8(x0, x0);
2585 uint8x8_t x2 = vpadd_u8(x1, x1);
2586 return vget_lane_u8(x2, 0);
2590 uint8x8_t x0 = vcnt_u8(vreinterpret_u8_u64(vcreate_u64(x)));
2592 return vaddv_u8(x0);
2594 uint8x8_t x1 = vpadd_u8(x0, x0);
2595 uint8x8_t x2 = vpadd_u8(x1, x1);
2596 uint8x8_t x3 = vpadd_u8(x2, x2);
2597 return vget_lane_u8(x3, 0);
2603 return _nlib_popcnt_array[(x >> 24) & 0xFF] + _nlib_popcnt_array[(x >> 16) & 0xFF] +
2604 _nlib_popcnt_array[(x >> 8) & 0xFF] + _nlib_popcnt_array[(x)& 0xFF];
2607 return _nlib_popcnt_array[(x >> 56) & 0xFF] + _nlib_popcnt_array[(x >> 48) & 0xFF] +
2608 _nlib_popcnt_array[(x >> 40) & 0xFF] + _nlib_popcnt_array[(x >> 32) & 0xFF] +
2609 _nlib_popcnt_array[(x >> 24) & 0xFF] + _nlib_popcnt_array[(x >> 16) & 0xFF] +
2610 _nlib_popcnt_array[(x >> 8) & 0xFF] + _nlib_popcnt_array[(x)& 0xFF];
2613 return _nlib_popcnt_array[(x >> 8) & 0xFF] + _nlib_popcnt_array[(x)& 0xFF];
2625 #if defined(_MSC_VER) 2628 return _BitScanReverse(&cnt, x) ? (int)(31 - cnt) : 32;
2633 return _BitScanForward(&cnt, x) ? cnt : 32;
2638 return _BitScanReverse64(&cnt, x) ? (int)(63 - cnt) : 64;
2642 DWORD dw = (DWORD)(x >> 32);
2643 if (_BitScanReverse(&cnt, dw)) {
2644 return (
int)(31 - cnt);
2647 return _BitScanReverse(&cnt, dw) ?
2648 (int)(63 - cnt) : 64;
2655 return _BitScanForward64(&cnt, x) ? cnt : 64;
2658 DWORD dw = (DWORD)(x);
2659 if (_BitScanForward(&cnt, dw)) {
2662 dw = (DWORD)(x >> 32);
2663 return _BitScanForward(&cnt, dw) ?
2664 (int)(32 + cnt) : 64;
2673 unsigned int dw = (
unsigned int)(x >> 32);
2678 dw = (
unsigned int)(x);
2684 #elif defined(NN_PLATFORM_CTR) 2696 static size_t nlib_strlcpy(
char* __restrict s1,
const char* __restrict s2,
size_t s1max)
2698 static NLIB_C_INLINE
2699 size_t nlib_strlcpy(
char* __restrict s1,
const char* __restrict s2,
size_t s1max) {
2700 #if defined(__FreeBSD__) 2701 return strlcpy(s1, s2, s1max);
2705 NLIB_MEMCPY(s1, s2, len + 1);
2707 NLIB_MEMCPY(s1, s2, s1max - 1);
2708 s1[s1max - 1] =
'\0';
2718 #if __has_builtin(__builtin_bitreverse32) 2719 return __builtin_bitreverse32(x);
2720 #elif __has_builtin(__builtin_arm_rbit) 2721 return __builtin_arm_rbit(x);
2722 #elif defined(__arm__) && !defined(NN_PLATFORM_CTR) 2725 x = ((x & 0x55555555U) << 1) | ((x >> 1) & 0x55555555U);
2726 x = ((x & 0x33333333U) << 2) | ((x >> 2) & 0x33333333U);
2727 x = ((x & 0x0F0F0F0FU) << 4) | ((x >> 4) & 0x0F0F0F0FU);
2729 x = _byteswap_ulong(x);
2730 #elif defined(CAFE) || defined(NN_PLATFORM_CTR) 2731 x = (x << 24) | ((x & 0xFF00) << 8) |
2732 ((x >> 8) & 0xFF00) | (x >> 24);
2734 x = __builtin_bswap32(x);
2741 #if __has_builtin(__builtin_bitreverse64) 2742 return __builtin_bitreverse64(x);
2743 #elif __has_builtin(__builtin_arm_rbit64) 2744 return __builtin_arm_rbit64(x);
2745 #elif __has_builtin(__builtin_arm_rbit) 2746 return __builtin_arm_rbit(x >> 32) |
2747 (((uint64_t)__builtin_arm_rbit(x)) << 32);
2748 #elif defined(__arm__) && !defined(NN_PLATFORM_CTR) 2749 return __rbit(x >> 32) |
2750 (((uint64_t)__rbit(x)) << 32);
2752 x = ((x & 0x5555555555555555ULL) << 1) | ((x >> 1) & 0x5555555555555555ULL);
2753 x = ((x & 0x3333333333333333ULL) << 2) | ((x >> 2) & 0x3333333333333333ULL);
2754 x = ((x & 0x0F0F0F0F0F0F0F0FULL) << 4) | ((x >> 4) & 0x0F0F0F0F0F0F0F0FULL);
2756 x = _byteswap_uint64(x);
2757 #elif defined(CAFE) || defined(NN_PLATFORM_CTR) 2760 ((x & 0xFF00U) << 40) |
2761 ((x & 0xFF0000U) << 24) |
2762 ((x & 0xFF000000U) << 8) |
2763 ((x >> 8) & 0xFF000000U) |
2764 ((x >> 24) & 0xFF0000U) |
2765 ((x >> 40) & 0xFF00U) |
2768 x = __builtin_bswap64(x);
2782 #if defined(_MSC_VER) 2783 #if defined(n_EXPORTS) 2784 #undef NLIB_VIS_PUBLIC 2785 #define NLIB_VIS_PUBLIC NLIB_WINIMPORT 2786 #elif defined(nx_misc_EXPORTS) 2787 # undef NLIB_VIS_PUBLIC 2788 # define NLIB_VIS_PUBLIC NLIB_WINEXPORT 2792 #endif // INCLUDE_NN_NLIB_PLATFORM_H_
The structure to store information on UTF-8 string conversion.
Structure to store the settings and current status of a message queue.
Specifies the time to elapse before the timer initially starts up and the interval between the subseq...