#ifndef COSMOPOLITAN_H_
#define COSMOPOLITAN_H_
/*!BEGIN libc/integral/normalize.inc */
#ifdef __COSMOPOLITAN__
#undef __COSMOPOLITAN__
#endif
#define __COSMOPOLITAN_MAJOR__ 3
#define __COSMOPOLITAN_MINOR__ 3
#define __COSMOPOLITAN_PATCH__ 9
#define __COSMOPOLITAN__ \
(100000000 * __COSMOPOLITAN_MAJOR__ + 1000000 * __COSMOPOLITAN_MINOR__ + \
__COSMOPOLITAN_PATCH__)
#ifndef __COUNTER__
#define __COUNTER__ __LINE__
#endif
#if __GNUC__ + 0 < 2
#undef __GNUC__
#elif defined(__GNUC__) && defined(SWIG) /* lool */
#undef __GNUC__
#elif defined(__GNUC__) && defined(__NVCC__) /* lool */
#undef __GNUC__
#elif !defined(__GNUC__) && defined(__APPLE__) /* modesty */
#define __GNUC__ 4
#define __GNUC_MINOR__ 2
#define __GNUC_PATCHLEVEL__ 1
#elif !defined(__GNUC__) && defined(__TINYC__)
#define __GNUC__ 2
#define __GNUC_MINOR__ 0
#define __GNUC_PATCHLEVEL__ 0
#endif
#if !defined(__x86_64__) && \
(defined(__amd64__) || (defined(_M_AMD64) && defined(_M_X64)))
#define __x86_64__ 1
#elif !defined(__i386__) && ((defined(__i486__) || defined(__i586__) || \
defined(__i686__) || defined(__i786__)) || \
_M_IX86 + 0 >= 400)
#define __i386__ 1
#elif !defined(__ia16__) && (defined(__MSDOS__) || defined(__BCC__))
#define __ia16__ 1
#endif
#if __ia16__ + __i386__ + __x86_64__ + 0
#define __x86__ 1
#endif
#ifdef _MSC_VER
#define __STRICT_ANSI__
#ifndef __STDC__
#define __STDC__
#endif
#endif
#ifndef __has_attribute
#define __has_attribute(x) 0
#endif
#ifndef __has_builtin
#define __has_builtin(x) 0
#endif
#ifndef __has_cpp_attribute
#define __has_cpp_attribute(x) 0
#endif
#ifndef __has_extension
#define __has_extension(x) 0
#endif
#ifdef unix
#undef unix
#endif
#ifdef linux
#undef linux
#endif
#ifdef __linux
#undef __linux
#endif
#ifdef __linux__
#undef __linux__
#endif
#ifndef __BIGGEST_ALIGNMENT__
#define __BIGGEST_ALIGNMENT__ 16
#endif
#ifdef _COSMO_SOURCE
#define FRAMESIZE 65536
#define _PAGESIZE 4096
#endif
#if defined(__LP64__) && !defined(__INT64_TYPE__)
/*!BEGIN libc/integral/lp64.inc */
#define __INT8_MAX__ 0x7f
#define __UINT8_MAX__ 0xff
#define __INT16_MAX__ 0x7fff
#define __UINT16_MAX__ 0xffff
#define __SHRT_MAX__ 0x7fff
#define __INT_MAX__ 0x7fffffff
#define __INT32_MAX__ 0x7fffffff
#define __UINT32_MAX__ 0xffffffffu
#define __INT64_MAX__ 0x7fffffffffffffffl
#define __UINT64_MAX__ 0xfffffffffffffffful
#define __SIZE_MAX__ 0xfffffffffffffffful
#define __INTPTR_MAX__ 0x7fffffffffffffffl
#define __UINTPTR_MAX__ 0xfffffffffffffffful
#define __WINT_MAX__ 0xffffffffu
#define __UINTMAX_MAX__ 0xffffffffffffffffUL
#define __INTMAX_MAX__ 0x7fffffffffffffffL
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_INT__ 4
#define __SIZEOF_LONG__ 8
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_POINTER__ 8
#define __SIZEOF_PTRDIFF_T__ 8
#define __SIZEOF_SIZE_T__ 8
#define __SIZEOF_WCHAR_T__ 4
#define __SIZEOF_WINT_T__ 4
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_FLOAT128__ 16
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_FLOAT80__ 16
#define __SIZEOF_LONG_DOUBLE__ 16
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#define __CHAR16_TYPE__ short unsigned int
#define __CHAR32_TYPE__ unsigned int
#define __INT16_TYPE__ short int
#define __INT32_TYPE__ int
#define __INT64_TYPE__ long int
#define __INT8_TYPE__ signed char
#define __INTMAX_TYPE__ long int
#define __INTPTR_TYPE__ long int
#define __PTRDIFF_TYPE__ long int
#define __SIZE_TYPE__ long unsigned int
#define __UINT16_TYPE__ short unsigned int
#define __UINT32_TYPE__ unsigned int
#define __UINT64_TYPE__ long unsigned int
#define __UINT8_TYPE__ unsigned char
#define __UINTMAX_TYPE__ long unsigned int
#define __UINTPTR_TYPE__ long unsigned int
#define __WCHAR_TYPE__ int
#define __WINT_TYPE__ unsigned int
#define __INT_LEAST8_TYPE__ __INT8_TYPE__
#define __UINT_LEAST8_TYPE__ __UINT8_TYPE__
#define __INT_LEAST16_TYPE__ __INT32_TYPE__
#define __UINT_LEAST16_TYPE__ __UINT16_TYPE__
#define __INT_LEAST32_TYPE__ __INT16_TYPE__
#define __UINT_LEAST32_TYPE__ __UINT32_TYPE__
#define __INT_LEAST64_TYPE__ __INT64_TYPE__
#define __UINT_LEAST64_TYPE__ __UINT64_TYPE__
#define __INT_FAST8_TYPE__ __INT8_TYPE__
#define __UINT_FAST8_TYPE__ __UINT8_TYPE__
#define __INT_FAST16_TYPE__ __INT32_TYPE__
#define __UINT_FAST16_TYPE__ __UINT32_TYPE__
#define __INT_FAST32_TYPE__ __INT32_TYPE__
#define __UINT_FAST32_TYPE__ __UINT32_TYPE__
#define __INT_FAST64_TYPE__ __INT64_TYPE__
#define __UINT_FAST64_TYPE__ __UINT64_TYPE__
#endif
#elif defined(_MSC_VER) && !defined(__INT64_TYPE__)
/*!BEGIN libc/integral/llp64.inc */
#define __INT8_MAX__ 0x7f
#define __UINT8_MAX__ 0xff
#define __INT16_MAX__ 0x7fff
#define __UINT16_MAX__ 0xffff
#define __SHRT_MAX__ 0x7fff
#define __INT_MAX__ 0x7fffffff
#define __INT32_MAX__ 0x7fffffff
#define __UINT32_MAX__ 0xffffffffu
#define __INT64_MAX__ 0x7fffffffffffffffl
#define __UINT64_MAX__ 0xffffffffffffffffull
#define __SIZE_MAX__ 0xffffffffffffffffull
#define __INTPTR_MAX__ 0x7fffffffffffffffll
#define __UINTPTR_MAX__ 0xffffffffffffffffull
#define __WINT_MAX__ 0xffffffffu
#define __SIZEOF_SHORT__ 2
#define __SIZEOF_INT__ 4
#define __SIZEOF_LONG__ 4
#define __SIZEOF_LONG_LONG__ 8
#define __SIZEOF_POINTER__ 8
#define __SIZEOF_PTRDIFF_T__ 8
#define __SIZEOF_SIZE_T__ 4
#define __SIZEOF_WCHAR_T__ 4
#define __SIZEOF_WINT_T__ 4
#define __SIZEOF_FLOAT__ 4
#define __SIZEOF_FLOAT128__ 16
#define __SIZEOF_DOUBLE__ 8
#define __SIZEOF_FLOAT80__ 16
#define __SIZEOF_LONG_DOUBLE__ 16
#define __INT8_C(c) c
#define __UINT8_C(c) c
#define __INT16_C(c) c
#define __UINT16_C(c) c
#define __INT32_C(c) c
#define __UINT32_C(c) c##U
#define __INT64_C(c) c##LL
#define __UINT64_C(c) c##ULL
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#define __INT8_TYPE__ signed char
#define __UINT8_TYPE__ unsigned char
#define __INT16_TYPE__ short int
#define __UINT16_TYPE__ short unsigned int
#define __INT32_TYPE__ int
#define __UINT32_TYPE__ unsigned int
#define __INT64_TYPE__ long long int
#define __UINT64_TYPE__ long long unsigned int
#define __INTPTR_TYPE__ long long int
#define __UINTPTR_TYPE__ long long unsigned int
#define __PTRDIFF_TYPE__ long long int
#define __SIZE_TYPE__ unsigned int
#define __WCHAR_TYPE__ int
#define __CHAR16_TYPE__ short unsigned int
#define __CHAR32_TYPE__ unsigned int
#define __WINT_TYPE__ unsigned int
#define __INT_LEAST8_TYPE__ __INT8_TYPE__
#define __UINT_LEAST8_TYPE__ __UINT8_TYPE__
#define __INT_LEAST16_TYPE__ __INT32_TYPE__
#define __UINT_LEAST16_TYPE__ __UINT16_TYPE__
#define __INT_LEAST32_TYPE__ __INT16_TYPE__
#define __UINT_LEAST32_TYPE__ __UINT32_TYPE__
#define __INT_LEAST64_TYPE__ __INT64_TYPE__
#define __UINT_LEAST64_TYPE__ __UINT64_TYPE__
#define __INT_FAST8_TYPE__ __INT8_TYPE__
#define __UINT_FAST8_TYPE__ __UINT8_TYPE__
#define __INT_FAST16_TYPE__ __INT32_TYPE__
#define __UINT_FAST16_TYPE__ __UINT32_TYPE__
#define __INT_FAST32_TYPE__ __INT32_TYPE__
#define __UINT_FAST32_TYPE__ __UINT32_TYPE__
#define __INT_FAST64_TYPE__ __INT64_TYPE__
#define __UINT_FAST64_TYPE__ __UINT64_TYPE__
#endif
#endif
#if !(__ASSEMBLER__ + __LINKER__ + 0)
#ifdef __STDC__
/*!BEGIN libc/integral/c.inc */
#if __GNUC__ + 0 < 2
#define __attribute__(x)
#endif
#ifndef __cplusplus
#define COSMOPOLITAN_C_START_
#define COSMOPOLITAN_C_END_
#define COSMOPOLITAN_CXX_START_
#define COSMOPOLITAN_CXX_END_
#define COSMOPOLITAN_CXX_USING_
#endif
#ifndef __ia16__
#define __far
#endif
#if !defined(__GNUC__) && __cplusplus + 0 >= 201103L
#define typeof(x) decltype(x)
#elif !defined(__GNUC__) && __STDC_VERSION__ + 0 < 201112
#define typeof(x) __typeof(x)
#endif
#ifdef __cplusplus
#if __cplusplus >= 201103L
#define _Alignof(x) alignof(x)
#endif /* C++11 */
#else /* __cplusplus */
#if __STDC_VERSION__ + 0 < 201112
#if __GNUC__ + _MSC_VER + 0
#define _Alignof(x) __alignof(x)
#else
#define _Alignof(x) /* basically all it ever did lool */ sizeof(x)
#endif /* GNU/MSVC/!ANSI */
#endif /* C11 */
#endif /* __cplusplus */
#if !defined(__cplusplus) && !defined(inline) && __STDC_VERSION__ + 0 < 199901
#if defined(__GNUC__) || defined(_MSC_VER)
#define inline __inline
#else
#define inline
#define __inline
#endif
#endif
#ifdef __chibicc__
#define __extension__
#endif
#if __STDC_VERSION__ + 0 < 201112
#ifdef __GNUC__
#define _Alignas(x) __attribute__((__aligned__(x)))
#elif defined(_MSC_VER)
#define _Alignas(x) __declspec(align(x))
#endif
#endif
#ifdef _MSC_VER
#define __builtin_unreachable() __assume(false)
#elif !((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 405 || \
defined(__clang__) || defined(__INTEL_COMPILER) || \
__has_builtin(__builtin_unreachable))
#define __builtin_unreachable() \
for (;;) { \
}
#endif
#if (!defined(__llvm__) && !__has_builtin(__builtin_assume))
#define __builtin_assume(x) \
do { \
if (!(x)) \
__builtin_unreachable(); \
} while (0)
#endif
#if __STDC_VERSION__ + 0 < 201112
#define _Atomic(TYPE) TYPE volatile
#endif
#ifdef __llvm__
#define __gnu_printf__ __printf__
#define __gnu_scanf__ __scanf__
#endif
#if __cplusplus + 0 >= 201103L
#define NULL nullptr
#elif !defined(__cplusplus)
#define NULL ((void *)0)
#else
#define NULL 0
#endif
#ifndef __cplusplus
#if defined(__GNUC__) && !defined(__llvm__)
#pragma GCC push_options
#pragma GCC diagnostic ignored "-Wc++-compat"
#endif
typedef __WCHAR_TYPE__ wchar_t;
typedef __CHAR16_TYPE__ char16_t;
typedef __CHAR32_TYPE__ char32_t;
#if defined(__GNUC__) && !defined(__llvm__)
#pragma GCC pop_options
#endif
#endif /* __cplusplus */
#ifndef __COSMOCC__
/*!BEGIN libc/stdbool.h */
#define COSMOPOLITAN_LIBC_STDBOOL_H_
#ifndef __cplusplus
#define bool _Bool
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
#define true ((_Bool) + 1u)
#define false ((_Bool) + 0u)
#else
#define true 1
#define false 0
#endif
#else /* __cplusplus */
#define _Bool bool
#endif /* __cplusplus */
#define __bool_true_false_are_defined 1
#endif
#define _LIBCPP_STDINT_H
typedef int errno_t;
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ssize_t;
typedef __INTPTR_TYPE__ intptr_t;
typedef __UINTPTR_TYPE__ uintptr_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __WINT_TYPE__ wint_t; /* uint32_t on linux but int32_t on xnu */
typedef __INT8_TYPE__ int8_t;
typedef __UINT8_TYPE__ uint8_t;
typedef __INT16_TYPE__ int16_t;
typedef __UINT16_TYPE__ uint16_t;
typedef __INT32_TYPE__ bool32;
typedef __INT32_TYPE__ int32_t;
typedef __UINT32_TYPE__ uint32_t;
typedef __INT64_TYPE__ int64_t;
typedef __UINT64_TYPE__ uint64_t;
typedef __INTMAX_TYPE__ intmax_t;
typedef __UINTMAX_TYPE__ uintmax_t;
#define __DEFINED_max_align_t
typedef long double max_align_t;
#ifdef _COSMO_SOURCE
#if (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 406 || defined(__llvm__)
typedef signed __int128 int128_t;
typedef unsigned __int128 uint128_t;
#endif
#endif /* _COSMO_SOURCE */
#ifndef __AXDX_T
#define __AXDX_T
typedef struct {
intptr_t ax, dx;
} axdx_t;
#endif
#ifndef __chibicc__
#define va_list __builtin_va_list
#define va_arg(ap, type) __builtin_va_arg(ap, type)
#define va_copy(dest, src) __builtin_va_copy(dest, src)
#define va_end(ap) __builtin_va_end(ap)
#define va_start(ap, last) __builtin_va_start(ap, last)
#else
/*!BEGIN libc/integral/lp64arg.inc */
/* variadic arguments for chibicc */
/* */
struct __va_list {
uint32_t gp_offset;
uint32_t fp_offset;
void *overflow_arg_area;
void *reg_save_area;
};
/* */
void *__va_arg(struct __va_list *, size_t, unsigned, unsigned);
#define __GNUC_VA_LIST 1
#define __gnuc_va_list va_list
#define va_end(AP)
#define va_copy(DST, SRC) ((DST)[0] = (SRC)[0])
#define va_start(AP, LAST) \
do { \
*(AP) = *(struct __va_list *)__va_area__; \
} while (0)
#define va_arg(AP, TYPE) \
(*(TYPE *)__va_arg(AP, sizeof(TYPE), _Alignof(TYPE), \
__builtin_reg_class(TYPE)))
typedef struct __va_list va_list[1];
#endif
#define libcesque dontthrow dontcallback
#define memcpyesque libcesque
#define strlenesque libcesque nosideeffect paramsnonnull()
#define vallocesque \
libcesque __wur returnsaligned((65536)) returnspointerwithnoaliases
#define reallocesque libcesque returnsaligned((16))
#define mallocesque reallocesque returnspointerwithnoaliases
#define interruptfn nocallersavedregisters forcealignargpointer
#ifndef pureconst
#define pureconst __attribute__((__const__))
#endif
#ifndef forcealign
#define forcealign(bytes) __attribute__((__aligned__(bytes)))
#endif
#define thatispacked __attribute__((__packed__))
#define printfesque(n) __attribute__((__format__(__gnu_printf__, n, n + 1)))
#define scanfesque(n) __attribute__((__format__(__gnu_scanf__, n, n + 1)))
#define strftimeesque(n) __attribute__((__format__(__strftime__, n, 0)))
#ifndef privileged
#define privileged \
_Section(".privileged") dontinline dontinstrument dontubsan dontasan
#endif
#ifndef wontreturn
#if (__has_attribute(__noreturn__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 208)
#define wontreturn __attribute__((__noreturn__))
#else
#define wontreturn
#endif
#endif
#ifndef nosideeffect
#if (__has_attribute(__pure__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 296)
#define nosideeffect __attribute__((__pure__))
#else
#define nosideeffect
#endif
#endif
#ifndef dontinline
#ifdef _MSC_VER
#define dontinline __declspec(noinline)
#elif (__has_attribute(__noinline__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 301)
#define dontinline __attribute__((__noinline__))
#else
#define dontinline
#endif
#endif
#ifndef dontclone
#if (__has_attribute(__noclone__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 405)
#define dontclone __attribute__((__noclone__))
#else
#define dontclone
#endif
#endif
#ifndef forceinline
#ifdef __cplusplus
#define forceinline inline
#else
#if (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 302
#if (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 403 || \
!defined(__cplusplus) || \
(defined(__clang__) && \
(defined(__GNUC_STDC_INLINE__) || defined(__GNUC_GNU_INLINE__)))
#if defined(__GNUC_STDC_INLINE__) || defined(__cplusplus)
#define forceinline \
static __inline __attribute__((__always_inline__, __gnu_inline__, \
__no_instrument_function__, __unused__))
#else
#define forceinline \
static __inline __attribute__((__always_inline__, \
__no_instrument_function__, __unused__))
#endif /* __GNUC_STDC_INLINE__ */
#endif /* GCC >= 4.3 */
#elif defined(_MSC_VER)
#define forceinline __forceinline
#else
#define forceinline static inline
#endif /* !ANSI && GCC >= 3.2 */
#endif /* __cplusplus */
#endif /* forceinline */
#ifndef __wur
#if ((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 304 || \
__has_attribute(__warn_unused_result__))
#define __wur __attribute__((__warn_unused_result__))
#else
#define __wur
#endif
#endif
#ifndef nullterminated
#if __has_attribute(__sentinel__) || __GNUC__ + 0 >= 4
#define nullterminated(x) __attribute__((__sentinel__ x))
#else
#define nullterminated(x)
#endif
#endif
#ifndef flattenout
#if __has_attribute(__flatten__) || \
((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 401 && !defined(__llvm__))
#define flattenout __attribute__((__flatten__))
#else
#define flattenout
#endif
#endif
#ifndef externinline
#if (!defined(__cplusplus) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 403 || \
(defined(__clang__) && \
(defined(__GNUC_STDC_INLINE__) || defined(__GNUC_GNU_INLINE__))))
#if defined(__GNUC_STDC_INLINE__) || defined(__cplusplus)
#define externinline extern __inline __attribute__((__gnu_inline__))
#else
#define externinline extern __inline __attribute__((__always_inline__))
#endif
#else
#define externinline inline
#endif
#endif
#ifndef relegated
#if (__has_attribute(__cold__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 403)
#define relegated __attribute__((__cold__))
#else
#define relegated
#endif
#endif
#if (__has_attribute(__warning__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 403)
#define warnifused(s) __attribute__((__warning__(s)))
#else
#define warnifused(s)
#endif
#ifndef firstclass
#if (__has_attribute(__hot__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 403)
#define firstclass __attribute__((__hot__))
#else
#define firstclass
#endif
#endif
#ifndef paramsnonnull
#if (__has_attribute(__nonnull__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 403)
#define paramsnonnull(opt_1idxs) __attribute__((__nonnull__ opt_1idxs))
#else
#define paramsnonnull(opt_1idxs)
#endif
#endif
#if __STDC_VERSION__ + 0 >= 199901L
#define hasatleast static
#else
#define hasatleast
#endif
#if __STDC_VERSION__ + 0 < 199901L && !defined(restrict)
#if !defined(__cplusplus) && \
((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 301 || defined(_MSC_VER))
#define restrict __restrict__
#else
#define restrict
#define __restrict
#endif
#endif
#ifndef dontcallback
#if (__has_attribute(__leaf__) || \
(!defined(__llvm__) && \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 406))
#define dontcallback __attribute__((__leaf__))
#else
#define dontcallback
#endif
#endif
#ifndef dontthrow
#if defined(__cplusplus) && \
(__has_attribute(dontthrow) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 303)
#define dontthrow __attribute__((__nothrow__))
#elif defined(_MSC_VER)
#define dontthrow __declspec(nothrow)
#else
#define dontthrow
#endif
#endif
#ifndef returnstwice
#if (__has_attribute(__returns_twice__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 402)
#define returnstwice __attribute__((__returns_twice__))
#else
#define returnstwice
#endif
#endif
#ifndef nodebuginfo
#if __has_attribute(__nodebug__) || defined(__llvm__)
#define nodebuginfo __attribute__((__nodebug__))
#else
#define nodebuginfo
#endif
#endif
#if (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 408 || \
__has_attribute(__force_align_arg_pointer__)
#define forcealignargpointer __attribute__((__force_align_arg_pointer__))
#else
#define forcealignargpointer "need modern compiler"
#endif
#ifndef returnsnonnull
#if (__has_attribute(__returns_nonnull__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 409)
#define returnsnonnull __attribute__((__returns_nonnull__))
#else
#define returnsnonnull
#endif
#endif
#if (__has_attribute(__assume_aligned__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 409)
#define returnsaligned(x) __attribute__((__assume_aligned__ x))
#else
#define returnsaligned(x)
#endif
#ifndef returnspointerwithnoaliases
#if (__has_attribute(__malloc__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 409)
#define returnspointerwithnoaliases __attribute__((__malloc__))
#elif defined(_MSC_VER)
#define returnspointerwithnoaliases __declspec(allocator)
#else
#define returnspointerwithnoaliases
#endif
#endif
#ifndef attributeallocsize
#if (__has_attribute(__alloc_size__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 409)
#define attributeallocsize(x) __attribute__((__alloc_size__ x))
#else
#define attributeallocsize(x)
#endif
#endif
#ifndef attributeallocalign
#if (__has_attribute(__alloc_align__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 409)
#define attributeallocalign(x) __attribute__((__alloc_align__ x))
#else
#define attributeallocalign(x)
#endif
#endif
#if __cplusplus + 0 >= 201103L
#define autotype(x) auto
#elif ((__has_builtin(__auto_type) || defined(__llvm__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 409) && \
!defined(__chibicc__))
#define autotype(x) __auto_type
#else
#define autotype(x) typeof(x)
#endif
#define offsetof(type, member) __builtin_offsetof(type, member)
#ifdef _COSMO_SOURCE
#ifndef dontinstrument
#if (__has_attribute(__no_instrument_function__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 204)
#if ((__GNUC__ + 0) >= 7 && !defined(__chibicc__)) || \
__has_attribute(__patchable_function_entry__)
#define dontinstrument \
__attribute__((__no_instrument_function__, \
__patchable_function_entry__(0, 0)))
#else
#define dontinstrument __attribute__((__no_instrument_function__))
#endif
#else
#define dontinstrument
#endif
#endif
#ifndef mayalias
#if (__has_attribute(__may_alias__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 303)
#define mayalias __attribute__((__may_alias__))
#else
#define mayalias
#endif
#endif
#ifndef dontoptimize
#if defined(__llvm__) || __has_attribute(__optnone__)
#define dontoptimize __attribute__((__optnone__))
#elif (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 407 || \
__has_attribute(__optimize__)
#define dontoptimize __attribute__((__optimize__(0)))
#endif
#endif
#ifndef optimizesize
#if (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 407 || \
__has_attribute(__optimize__)
#define optimizesize __attribute__((__optimize__("s")))
#elif defined(__llvm__) || __has_attribute(__optnone__)
#define optimizesize __attribute__((__optnone__))
#endif
#endif
#ifndef optimizespeed
/* warning: corrupts frame pointer; only use on leaf functions */
#if ((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 407 || \
__has_attribute(__optimize__))
#define optimizespeed __attribute__((__optimize__(3)))
#else
#define optimizespeed
#endif
#endif
#ifndef unrollloops
#if ((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 407 || \
__has_attribute(__optimize__))
#define unrollloops __attribute__((__optimize__("unroll-loops")))
#else
#define unrollloops
#endif
#endif
#ifndef _Microarchitecture
#if (__has_attribute(__target__) || \
(__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 404)
#define _Microarchitecture(march) __attribute__((__target__(march)))
#else
#define _Microarchitecture(march)
#endif
#endif
#ifdef __x86_64__
#if __GNUC__ >= 7 || __has_attribute(__no_caller_saved_registers__)
#define nocallersavedregisters __attribute__((__no_caller_saved_registers__))
#else
#define nocallersavedregisters "need modern compiler"
#endif
#else
#define nocallersavedregisters
#endif
#if ((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 408 || \
__has_attribute(__no_sanitize_address__))
#define dontasan __attribute__((__no_sanitize_address__))
#else
#define dontasan
#endif
#if ((__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 408 || \
__has_attribute(__no_sanitize_undefined__))
#define dontubsan __attribute__((__no_sanitize_undefined__))
#else
#define dontubsan
#endif
#ifdef __x86_64__
#define notpossible \
do { \
__asm__("nop\n\t" \
"ud2\n\t" \
"nop"); \
__builtin_unreachable(); \
} while (0)
#elif defined(__aarch64__)
#define notpossible \
do { \
__asm__("udf\t#0\n\t" \
"nop"); \
__builtin_unreachable(); \
} while (0)
#else
#define notpossible __builtin_trap()
#endif
#define donothing \
do { \
} while (0)
#define textstartup _Section(".text.startup")
#define textexit _Section(".text.exit")
#define textreal _Section(".text.real")
#define texthead _Section(".text.head")
#define textwindows _Section(".text.windows")
#define antiquity _Section(".text.antiquity")
#ifdef __llvm__
#define __builtin_ia32_movntdq(x, y) (*(x) = (y))
#endif
#ifndef _Section
#define _Section(s) __attribute__((__section__(s)))
#endif
#ifndef __llvm__
#pragma GCC diagnostic ignored "-Wformat=0" /* todo: patch gcc */
#pragma GCC diagnostic ignored "-Wbuiltin-declaration-mismatch"
#pragma GCC diagnostic warning "-Wunknown-pragmas"
#else
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wconstant-logical-operand" /* what */
#pragma GCC diagnostic ignored "-Wunknown-warning-option"
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#pragma GCC diagnostic ignored "-Wstring-plus-int" /* features 4 losers */
#pragma GCC diagnostic ignored "-Wkeyword-compat" /* c++ upgrade */
#pragma GCC diagnostic ignored "-Wuser-defined-literals" /* reserved for me */
#endif
#pragma GCC diagnostic ignored "-Wformat-extra-args" /* todo: patch gcc */
#pragma GCC diagnostic ignored "-Wunused-function" /* contradicts dce */
#pragma GCC diagnostic ignored "-Wunused-const-variable" /* sooo ridiculous */
#ifndef __cplusplus
#pragma GCC diagnostic ignored "-Wold-style-definition" /* orwellian bullsh */
#endif
#ifdef __x86_64__
#define DebugBreak() __asm__("int3")
#elif defined(__aarch64__)
#define DebugBreak() __asm__("brk\t#0x666")
#else
#define DebugBreak() __builtin_trap()
#endif
#ifdef __aarch64__
/* raise sigill (not sigtrap) like x86 does */
#define __builtin_trap() \
do { \
__asm__("udf\t#0x666"); \
__builtin_unreachable(); \
} while (0)
#endif
#endif /* _COSMO_SOURCE */
#define __veil(CONSTRAINT, EXPRESSION) \
__extension__({ \
autotype(EXPRESSION) VeiledValue = (EXPRESSION); \
__asm__("" : "=" CONSTRAINT ""(VeiledValue) : "0"(VeiledValue)); \
VeiledValue; \
})
#define __conceal(CONSTRAINT, EXPRESSION) \
__extension__({ \
autotype(EXPRESSION) VeiledValue = (EXPRESSION); \
__asm__ volatile("" : "=" CONSTRAINT ""(VeiledValue) : "0"(VeiledValue)); \
VeiledValue; \
})
#define __expropriate(EXPRESSION) \
__extension__({ \
__asm__ volatile("" ::"g"(EXPRESSION) : "memory"); \
0; \
})
#if !defined(__APPLE__) && defined(__x86_64__)
#define __yoink(SYMBOL) \
__asm__(".section .yoink\n\tnopl\t%0\n\t.previous" : : "m"(SYMBOL))
#elif defined(__aarch64__)
#define __yoink(SYMBOL) \
__asm__(".section .yoink\n\tb\t%0\n\t.previous" : : "m"(SYMBOL))
#else
#define __yoink(SYMBOL) (void)0
#endif
#if !defined(__APPLE__) && defined(__x86_64__)
#define __static_yoink(SYMBOLSTR) \
__asm__(".section .yoink\n\tnopl\t\"" SYMBOLSTR "\"\n\t.previous")
#elif defined(__aarch64__)
#define __static_yoink(SYMBOLSTR) \
__asm__(".section .yoink\n\tb\t\"" SYMBOLSTR "\"\n\t.previous")
#else
#define __static_yoink(SYMBOLSTR)
#endif
#if !defined(IM_FEELING_NAUGHTY)
#define __static_yoink_source(PATH) __static_yoink(PATH)
#else
#define __static_yoink_source(PATH)
#endif
#define __weak_reference(sym, alias) __weak_reference_impl(sym, alias)
#define __weak_reference_impl(sym, alias) \
__asm__(".weak\t" #alias "\n\t" \
".equ\t" #alias ", " #sym "\n\t" \
".type\t" #alias ",@notype")
#ifndef __chibicc__
#define __strong_reference(sym, alias) \
extern __typeof(sym) alias __attribute__((__alias__(#sym)))
#else
#define __strong_reference(sym, alias) __weak_reference(sym, alias)
#endif
#if defined(__GNUC__) || defined(__llvm__)
#define __funline \
extern __inline \
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
#else
#define __funline static inline
#endif
#if defined(__x86_64__) && (defined(__GNUC__) || defined(__llvm__)) && \
!defined(__chibicc__) && defined(__OPTIMIZE__)
#define __target_clones(x) __attribute__((__target_clones__(x ",default")))
#else
#define __target_clones(x)
#endif
#if !defined(TINY) && !defined(__AVX__)
#define __vex __target_clones("avx")
#else
#define __vex
#endif
#define __notice(sym, str) \
__attribute__((__section__(".notice"), __aligned__(1))) const char sym[] = \
"\n\n" str
#define MACHINE_CODE_ANALYSIS_BEGIN_
#define MACHINE_CODE_ANALYSIS_END_
#else
#define const
#define volatile
#endif
#ifdef __cplusplus
/*!BEGIN libc/integral/cxx.inc */
#define COSMOPOLITAN_CXX_START_ namespace cosmo {
#define COSMOPOLITAN_CXX_END_ }
#define COSMOPOLITAN_CXX_USING_ using namespace cosmo;
#define COSMOPOLITAN_C_START_ extern "C" {
#define COSMOPOLITAN_C_END_ }
#if !defined(__builtin_types_compatible_p) && !__has_builtin(types_compatible_p)
#if 0 /* todo jart whyyyy */
/*!BEGIN libc/integral/cxxtypescompat.inc */
#define NAME __cxx_types_compatible
#define QUALIFIED(Q1, Q2) \
template \
struct NAME<_T Q1, _U Q2> : NAME<_T, _U> {}
template
struct NAME {
enum { _value = 0 };
};
template
struct NAME<_T, _T> {
enum { _value = 1 };
};
template
struct NAME<_T[], _T[N]> {
enum { _value = 1 };
};
template
struct NAME<_T[N], _T[]> {
enum { _value = 1 };
};
QUALIFIED(const volatile, );
QUALIFIED(const volatile, const);
QUALIFIED(const, const volatile);
QUALIFIED(volatile, const volatile);
QUALIFIED(const volatile, volatile);
QUALIFIED(const, volatile);
QUALIFIED(volatile, const);
QUALIFIED(, const);
QUALIFIED(const, );
QUALIFIED(, volatile);
QUALIFIED(volatile, );
#undef QUALIFIED
#undef NAME
#define __builtin_types_compatible_p(A, B) \
(__cxx_types_compatible::_value)
#else
#define __builtin_types_compatible_p(A, B) 0
#endif
#endif
#if !defined(__builtin_choose_expr) && !__has_builtin(choose_expr)
#if 1
template
struct __cxx_choose_expr {
__cxx_choose_expr(_T _a, _U _b) : _value(_a) {
}
const _T _value;
};
template
struct __cxx_choose_expr {
__cxx_choose_expr(_T _a, _U _b) : _value(_b) {
}
const _U _value;
};
#define __builtin_choose_expr(X, A, B) \
(__cxx_choose_expr(A, B)._value)
#else
#define __builtin_choose_expr(X, A, B) ((X) ? (A) : (B))
#endif
#endif
#ifdef __aarch64__
/* todo jart whyyyy */
#define _Float16 __fp16
#endif
#endif
#endif
/*!BEGIN ape/ape.h */
#define COSMOPOLITAN_APE_APE_H_
#define APE_VERSION_MAJOR 1
#define APE_VERSION_MINOR 10
#define APE_VERSION_STR APE_VERSION_STR_(APE_VERSION_MAJOR, APE_VERSION_MINOR)
#define APE_VERSION_NOTE APE_VERSION_NOTE_(APE_VERSION_MAJOR, APE_VERSION_MINOR)
#define APE_VERSION_STR__(x, y) #x "." #y
#define APE_VERSION_STR_(x, y) APE_VERSION_STR__(x, y)
#define APE_VERSION_NOTE_(x, y) (100000000 * (x) + 1000000 * (y))
/*!BEGIN ape/relocations.h */
#define COSMOPOLITAN_APE_RELOCATIONS_H_
/*─────────────────────────────────────────────────────────────────────────────╗
│ αcτµαlly pδrταblε εxεcµταblε § relocations │
╚──────────────────────────────────────────────────────────────────────────────╝
One of the things αcτµαlly pδrταblε εxεcµταblε does a good job
abstracting, is how a program needs to exist at three addresses
simultaneously during the early stages of the loading process.
By default, the linker calculates all symbols using virtual addresses.
In some cases it's necessary to use addend macros that change virtual
addresses into the other two types: physical and real. */
#define IMAGE_BASE_REAL 0x2000
#ifndef IMAGE_BASE_VIRTUAL
#define IMAGE_BASE_VIRTUAL 0x400000
#endif
#ifndef IMAGE_BASE_PHYSICAL
#define IMAGE_BASE_PHYSICAL 0x100000
#endif
/**
* Returns Relative Virtual Address.
*/
#define RVA(x) ((x) - (IMAGE_BASE_VIRTUAL))
/**
* Adjusts virtual address so it's relative to load address.
*/
#define PHYSICAL(x) ((x) - (IMAGE_BASE_VIRTUAL - IMAGE_BASE_PHYSICAL))
/**
* Makes high-entropy read-only addresses relocatable in real mode.
*/
#define REAL(x) ((x) - (IMAGE_BASE_VIRTUAL - IMAGE_BASE_REAL))
#if IMAGE_BASE_VIRTUAL % 0x1000 != 0
#error "IMAGE_BASE_VIRTUAL must be 4kb aligned"
#endif
#if IMAGE_BASE_PHYSICAL % 0x1000 != 0
#error "IMAGE_BASE_PHYSICAL must be 4kb aligned"
#endif
#if IMAGE_BASE_REAL % 0x1000 != 0
#error "IMAGE_BASE_REAL must be 4kb aligned"
#endif
/*!BEGIN libc/ar.h */
#define COSMOPOLITAN_LIBC_AR_H_
COSMOPOLITAN_C_START_
#define ARMAG "!\n"
#define SARMAG 8
#define ARFMAG "`\n"
struct ar_hdr {
char ar_name[16];
char ar_date[12];
char ar_uid[6];
char ar_gid[6];
char ar_mode[8];
char ar_size[10];
char ar_fmag[2];
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/assert.h */
#undef _ASSERT_H
#undef assert
#ifdef _COSMO_SOURCE
#undef unassert
#undef npassert
#ifndef NDEBUG
#undef __assert_macro
#endif /* NDEBUG */
#endif /* _COSMO_SOURCE */
#define _ASSERT_H
COSMOPOLITAN_C_START_
void __assert_fail(const char *, const char *, int) libcesque;
void unassert(const char *, const char *, int) libcesque;
#ifdef NDEBUG
#define assert(x) ((void)0)
#else
#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__), 0)))
#endif
#if __STDC_VERSION__ >= 201112L && !defined(__cplusplus)
#undef static_assert
#define static_assert _Static_assert
#endif
#ifdef _COSMO_SOURCE
#ifndef NDEBUG
#define unassert(x) __assert_macro(x, #x)
#define npassert(x) __assert_macro(x, #x)
#define __assert_macro(x, s) \
({ \
if (__builtin_expect(!(x), 0)) { \
(unassert)(s, __FILE__, __LINE__); \
__asm__("nop"); \
__builtin_unreachable(); \
} \
(void)0; \
})
#else
#define npassert(x) \
({ \
if (__builtin_expect(!(x), 0)) { \
__builtin_trap(); \
} \
(void)0; \
})
#define unassert(x) \
({ \
if (__builtin_expect(!(x), 0)) { \
__builtin_unreachable(); \
} \
(void)0; \
})
#endif /* NDEBUG */
#endif /* _COSMO_SOURCE */
COSMOPOLITAN_C_END_
/*!BEGIN libc/atomic.h */
#define COSMOPOLITAN_LIBC_ATOMIC_H_
#define atomic_bool _Atomic(_Bool)
#define atomic_bool32 _Atomic(__INT32_TYPE__)
#define atomic_char _Atomic(char)
#define atomic_schar _Atomic(signed char)
#define atomic_uchar _Atomic(unsigned char)
#define atomic_short _Atomic(short)
#define atomic_ushort _Atomic(unsigned short)
#define atomic_int _Atomic(int)
#define atomic_uint _Atomic(unsigned int)
#define atomic_long _Atomic(long)
#define atomic_ulong _Atomic(unsigned long)
#define atomic_llong _Atomic(long long)
#define atomic_ullong _Atomic(unsigned long long)
#define atomic_char16_t _Atomic(__CHAR16_TYPE__)
#define atomic_char32_t _Atomic(__CHAR32_TYPE__)
#define atomic_wchar_t _Atomic(__WCHAR_TYPE__)
#define atomic_intptr_t _Atomic(__INTPTR_TYPE__)
#define atomic_uintptr_t _Atomic(__UINTPTR_TYPE__)
#define atomic_size_t _Atomic(__SIZE_TYPE__)
#define atomic_ptrdiff_t _Atomic(__PTRDIFF_TYPE__)
#define atomic_int_fast8_t _Atomic(__INT_FAST8_TYPE__)
#define atomic_uint_fast8_t _Atomic(__UINT_FAST8_TYPE__)
#define atomic_int_fast16_t _Atomic(__INT_FAST16_TYPE__)
#define atomic_uint_fast16_t _Atomic(__UINT_FAST16_TYPE__)
#define atomic_int_fast32_t _Atomic(__INT_FAST32_TYPE__)
#define atomic_uint_fast32_t _Atomic(__UINT_FAST32_TYPE__)
#define atomic_int_fast64_t _Atomic(__INT_FAST64_TYPE__)
#define atomic_uint_fast64_t _Atomic(__UINT_FAST64_TYPE__)
#define atomic_int_least8_t _Atomic(__INT_LEAST8_TYPE__)
#define atomic_uint_least8_t _Atomic(__UINT_LEAST8_TYPE__)
#define atomic_int_least16_t _Atomic(__INT_LEAST16_TYPE__)
#define atomic_uint_least16_t _Atomic(__UINT_LEAST16_TYPE__)
#define atomic_int_least32_t _Atomic(__INT_LEAST32_TYPE__)
#define atomic_uint_least32_t _Atomic(__UINT_LEAST32_TYPE__)
#define atomic_int_least64_t _Atomic(__INT_LEAST64_TYPE__)
#define atomic_uint_least64_t _Atomic(__UINT_LEAST64_TYPE__)
#ifdef __CLANG_ATOMIC_BOOL_LOCK_FREE
#define ATOMIC_BOOL_LOCK_FREE __CLANG_ATOMIC_BOOL_LOCK_FREE
#define ATOMIC_CHAR_LOCK_FREE __CLANG_ATOMIC_CHAR_LOCK_FREE
#define ATOMIC_CHAR16_T_LOCK_FREE __CLANG_ATOMIC_CHAR16_T_LOCK_FREE
#define ATOMIC_CHAR32_T_LOCK_FREE __CLANG_ATOMIC_CHAR32_T_LOCK_FREE
#define ATOMIC_WCHAR_T_LOCK_FREE __CLANG_ATOMIC_WCHAR_T_LOCK_FREE
#define ATOMIC_SHORT_LOCK_FREE __CLANG_ATOMIC_SHORT_LOCK_FREE
#define ATOMIC_INT_LOCK_FREE __CLANG_ATOMIC_INT_LOCK_FREE
#define ATOMIC_LONG_LOCK_FREE __CLANG_ATOMIC_LONG_LOCK_FREE
#define ATOMIC_LLONG_LOCK_FREE __CLANG_ATOMIC_LLONG_LOCK_FREE
#define ATOMIC_POINTER_LOCK_FREE __CLANG_ATOMIC_POINTER_LOCK_FREE
#else
#define ATOMIC_BOOL_LOCK_FREE __GCC_ATOMIC_BOOL_LOCK_FREE
#define ATOMIC_CHAR_LOCK_FREE __GCC_ATOMIC_CHAR_LOCK_FREE
#define ATOMIC_CHAR16_T_LOCK_FREE __GCC_ATOMIC_CHAR16_T_LOCK_FREE
#define ATOMIC_CHAR32_T_LOCK_FREE __GCC_ATOMIC_CHAR32_T_LOCK_FREE
#define ATOMIC_WCHAR_T_LOCK_FREE __GCC_ATOMIC_WCHAR_T_LOCK_FREE
#define ATOMIC_SHORT_LOCK_FREE __GCC_ATOMIC_SHORT_LOCK_FREE
#define ATOMIC_INT_LOCK_FREE __GCC_ATOMIC_INT_LOCK_FREE
#define ATOMIC_LONG_LOCK_FREE __GCC_ATOMIC_LONG_LOCK_FREE
#define ATOMIC_LLONG_LOCK_FREE __GCC_ATOMIC_LLONG_LOCK_FREE
#define ATOMIC_POINTER_LOCK_FREE __GCC_ATOMIC_POINTER_LOCK_FREE
#endif
/*!BEGIN libc/complex.h */
#define COSMOPOLITAN_LIBC_COMPLEX_H_
COSMOPOLITAN_C_START_
#if __STDC_VERSION__ + 0 >= 201112 && !defined(__STDC_NO_COMPLEX__)
#define complex _Complex
#define imaginary _Imaginary
double cabs(complex double) libcesque;
double carg(complex double) libcesque;
double cimag(complex double) libcesque;
double creal(complex double) libcesque;
float cabsf(complex float) libcesque;
float cargf(complex float) libcesque;
float cimagf(complex float) libcesque;
float crealf(complex float) libcesque;
long double cabsl(complex long double) libcesque;
long double cargl(complex long double) libcesque;
long double cimagl(complex long double) libcesque;
long double creall(complex long double) libcesque;
complex double cacos(complex double) libcesque;
complex double cacosh(complex double) libcesque;
complex double casin(complex double) libcesque;
complex double casinh(complex double) libcesque;
complex double catan(complex double) libcesque;
complex double catanh(complex double) libcesque;
complex double ccos(complex double) libcesque;
complex double ccosh(complex double) libcesque;
complex double cexp(complex double) libcesque;
complex double cexp2(complex double) libcesque;
complex double clog(complex double) libcesque;
complex double conj(complex double) libcesque;
complex double cpow(complex double, complex double) libcesque;
complex double cproj(complex double) libcesque;
complex double csin(complex double) libcesque;
complex double csinh(complex double) libcesque;
complex double csqrt(complex double) libcesque;
complex double ctan(complex double) libcesque;
complex double ctanh(complex double) libcesque;
complex float cacosf(complex float) libcesque;
complex float cacoshf(complex float) libcesque;
complex float casinf(complex float) libcesque;
complex float casinhf(complex float) libcesque;
complex float catanf(complex float) libcesque;
complex float catanhf(complex float) libcesque;
complex float ccosf(complex float) libcesque;
complex float ccoshf(complex float) libcesque;
complex float cexpf(complex float) libcesque;
complex float cexp2f(complex float) libcesque;
complex float clogf(complex float) libcesque;
complex float conjf(complex float) libcesque;
complex float cpowf(complex float, complex float) libcesque;
complex float cprojf(complex float) libcesque;
complex float csinf(complex float) libcesque;
complex float csinhf(complex float) libcesque;
complex float csqrtf(complex float) libcesque;
complex float ctanf(complex float) libcesque;
complex float ctanhf(complex float) libcesque;
complex long double cprojl(complex long double) libcesque;
complex long double csinhl(complex long double) libcesque;
complex long double csinl(complex long double) libcesque;
complex long double csqrtl(complex long double) libcesque;
complex long double ctanhl(complex long double) libcesque;
complex long double ctanl(complex long double) libcesque;
complex long double cacoshl(complex long double) libcesque;
complex long double cacosl(complex long double) libcesque;
complex long double casinhl(complex long double) libcesque;
complex long double casinl(complex long double) libcesque;
complex long double catanhl(complex long double) libcesque;
complex long double catanl(complex long double) libcesque;
complex long double ccoshl(complex long double) libcesque;
complex long double ccosl(complex long double) libcesque;
complex long double cexpl(complex long double) libcesque;
complex long double cexp2l(complex long double) libcesque;
complex long double clogl(complex long double) libcesque;
complex long double conjl(complex long double) libcesque;
complex long double cpowl(complex long double, complex long double) libcesque;
#ifndef __cplusplus
#define __CIMAG(x, t) \
(+(union { \
_Complex t __z; \
t __xy[2]; \
}){(_Complex t)(x)} \
.__xy[1])
#define creal(x) ((double)(x))
#define crealf(x) ((float)(x))
#define creall(x) ((long double)(x))
#define cimag(x) __CIMAG(x, double)
#define cimagf(x) __CIMAG(x, float)
#define cimagl(x) __CIMAG(x, long double)
#endif
#ifdef __GNUC__
#define _Complex_I (__extension__(0.0f + 1.0fi))
#else
#define _Complex_I (0.0f + 1.0fi)
#endif
#ifdef _Imaginary_I
#define __CMPLX(x, y, t) ((t)(x) + _Imaginary_I * (t)(y))
#elif defined(__clang__)
#define __CMPLX(x, y, t) (+(_Complex t){(t)(x), (t)(y)})
#else
#define __CMPLX(x, y, t) (__builtin_complex((t)(x), (t)(y)))
#endif
#define CMPLX(x, y) __CMPLX(x, y, double)
#define CMPLXF(x, y) __CMPLX(x, y, float)
#define CMPLXL(x, y) __CMPLX(x, y, long double)
#endif /* C11 */
COSMOPOLITAN_C_END_
/*!BEGIN libc/cosmo.h */
#define COSMOPOLITAN_LIBC_COSMO_H_
COSMOPOLITAN_C_START_
errno_t cosmo_once(_Atomic(uint32_t) *, void (*)(void));
int systemvpe(const char *, char *const[], char *const[]) libcesque;
char *GetProgramExecutableName(void);
void unleaf(void);
int __demangle(char *, const char *, size_t);
int __is_mangled(const char *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/cxxabi.h */
#define _CXXABI_H
COSMOPOLITAN_C_START_
#ifdef __cplusplus
namespace __cxxabiv1 {
#endif /* __cplusplus */
char *__cxa_demangle(const char *, char *, size_t *, int *);
int __cxa_atexit(void (*)(void *), void *, void *) paramsnonnull((1)) dontthrow;
int __cxa_thread_atexit(void (*)(void *), void *, void *) dontthrow;
void __cxa_finalize(void *);
#ifdef __cplusplus
} /* namespace __cxxabiv1 */
#endif /* __cplusplus */
COSMOPOLITAN_C_END_
/*!BEGIN libc/dce.h */
#ifndef COSMOPOLITAN_LIBC_DCE_H_
#define COSMOPOLITAN_LIBC_DCE_H_
/*─────────────────────────────────────────────────────────────────────────────╗
│ cosmopolitan § autotune » dead code elimination │
╚─────────────────────────────────────────────────────────────────────────────*/
#ifndef SUPPORT_VECTOR
#ifdef __x86_64__
/**
* Supported Platforms Tuning Knob (Runtime & Compile-Time)
* Tuning this bitmask will remove platform polyfills at compile-time.
*/
#define SUPPORT_VECTOR 255
#else
#define SUPPORT_VECTOR (_HOSTLINUX | _HOSTXNU | _HOSTFREEBSD)
#endif
#endif
#define _HOSTLINUX 1
#define _HOSTMETAL 2
#define _HOSTWINDOWS 4
#define _HOSTXNU 8
#define _HOSTOPENBSD 16
#define _HOSTFREEBSD 32
#define _HOSTNETBSD 64
#ifdef NDEBUG
#define NoDebug() 1
#else
#define NoDebug() 0
#endif
#ifdef MODE_DBG
#define IsModeDbg() 1
#else
#define IsModeDbg() 0
#endif
#ifdef TRUSTWORTHY
#define IsTrustworthy() 1
#else
#define IsTrustworthy() 0
#endif
#ifdef TINY
#define IsTiny() 1
#else
#define IsTiny() 0
#endif
#ifdef __OPTIMIZE__
#define IsOptimized() 1
#else
#define IsOptimized() 0
#endif
#ifdef __SANITIZE_ADDRESS__
#define IsAsan() 1
#else
#define IsAsan() 0
#endif
#ifdef __aarch64__
#define IsAarch64() 1
#define IsXnuSilicon() IsXnu()
#else
#define IsAarch64() 0
#define IsXnuSilicon() 0
#endif
#if defined(__x86_64__)
#define _ARCH_NAME "amd64"
#elif defined(__aarch64__)
#define _ARCH_NAME "arm64"
#elif defined(__powerpc64__)
#define _ARCH_NAME "ppc64"
#elif defined(__s390x__)
#define _ARCH_NAME "s390x"
#elif defined(__riscv)
#define _ARCH_NAME "riscv"
#endif
#define SupportsLinux() ((SUPPORT_VECTOR & _HOSTLINUX) == _HOSTLINUX)
#define SupportsMetal() ((SUPPORT_VECTOR & _HOSTMETAL) == _HOSTMETAL)
#define SupportsWindows() ((SUPPORT_VECTOR & _HOSTWINDOWS) == _HOSTWINDOWS)
#define SupportsXnu() ((SUPPORT_VECTOR & _HOSTXNU) == _HOSTXNU)
#define SupportsFreebsd() ((SUPPORT_VECTOR & _HOSTFREEBSD) == _HOSTFREEBSD)
#define SupportsOpenbsd() ((SUPPORT_VECTOR & _HOSTOPENBSD) == _HOSTOPENBSD)
#define SupportsNetbsd() ((SUPPORT_VECTOR & _HOSTNETBSD) == _HOSTNETBSD)
#define SupportsBsd() \
(!!(SUPPORT_VECTOR & (_HOSTXNU | _HOSTFREEBSD | _HOSTOPENBSD | _HOSTNETBSD)))
#define SupportsSystemv() \
(!!(SUPPORT_VECTOR & \
(_HOSTLINUX | _HOSTXNU | _HOSTOPENBSD | _HOSTFREEBSD | _HOSTNETBSD)))
#ifndef __ASSEMBLER__
#define IsLinux() (SupportsLinux() && (__hostos & _HOSTLINUX))
#define IsMetal() (SupportsMetal() && (__hostos & _HOSTMETAL))
#define IsWindows() (SupportsWindows() && (__hostos & _HOSTWINDOWS))
#define IsXnu() (SupportsXnu() && (__hostos & _HOSTXNU))
#define IsFreebsd() (SupportsFreebsd() && (__hostos & _HOSTFREEBSD))
#define IsOpenbsd() (SupportsOpenbsd() && (__hostos & _HOSTOPENBSD))
#define IsNetbsd() (SupportsNetbsd() && (__hostos & _HOSTNETBSD))
#define IsBsd() (IsXnu() || IsFreebsd() || IsOpenbsd() || IsNetbsd())
#else
/* clang-format off */
#define IsLinux() $_HOSTLINUX,__hostos(%rip)
#define IsMetal() $_HOSTMETAL,__hostos(%rip)
#define IsWindows() $_HOSTWINDOWS,__hostos(%rip)
#define IsBsd() $_HOSTXNU|_HOSTFREEBSD|_HOSTOPENBSD|_HOSTNETBSD,__hostos(%rip)
#define IsXnu() $_HOSTXNU,__hostos(%rip)
#define IsFreebsd() $_HOSTFREEBSD,__hostos(%rip)
#define IsOpenbsd() $_HOSTOPENBSD,__hostos(%rip)
#define IsNetbsd() $_HOSTNETBSD,__hostos(%rip)
/* clang-format on */
#endif
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const int __hostos;
int IsQemuUser(void);
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_DCE_H_ */
/*!BEGIN libc/errno.h */
#define COSMOPOLITAN_LIBC_ERRNO_H_
COSMOPOLITAN_C_START_
/**
* @fileoverview System Five error codes.
*
* This file defines the `errno` global variable. When system calls
* (e.g. read(), write(), etc.) fail they return -1 to indicate the
* failure, and that is *the only* error return value. System calls
* also update `errno` too whenever -1 is returned (otherwise errno
* isn't changed) to be a non-zero value holding one of the numbers
* below, in order to indicate why the system call failed.
*
* There is only one exception to the above rule; some system calls
* are documented with the `@returnserrno` tag, which means they'll
* return the error number rather than stuffing it in a global. You
* can usually spot these system calls easily since most of them'll
* have names like `posix_foo()` or `pthread_bar()`.
*
* @see libc/sysv/consts.sh for assigned numbers
* @see libc/sysv/dos2errno.sh for multimapped numbers
*/
#if defined(__GNUC__) && defined(__aarch64__) && !defined(__cplusplus)
/* this header is included by 700+ files; therefore we */
/* hand-roll &__get_tls()->tib_errno to avoid #include */
/* cosmopolitan uses x28 as the tls register b/c apple */
#define errno \
(*__extension__({ \
errno_t *__ep; \
__asm__("sub\t%0,x28,#192-0x3c" : "=r"(__ep)); \
__ep; \
}))
#else
#define errno (*__errno_location())
#endif
/**
* System call unavailable.
* @note kNtErrorInvalidFunction on NT
*/
extern const errno_t ENOSYS;
/**
* Operation not permitted.
* @note kNtErrorInvalidAccess on NT
*/
extern const errno_t EPERM;
/**
* No such file or directory.
*/
extern const errno_t ENOENT;
/**
* No such process.
*/
extern const errno_t ESRCH;
/**
* The greatest of all errnos.
*/
extern const errno_t EINTR;
/**
* Unix consensus.
*/
extern const errno_t EIO;
/**
* No such device or address.
*/
extern const errno_t ENXIO;
/**
* Argument list too long.
*/
extern const errno_t E2BIG;
/**
* Exec format error.
*/
extern const errno_t ENOEXEC;
/**
* Bad file descriptor.
*/
extern const errno_t EBADF;
/**
* No child process.
*/
extern const errno_t ECHILD;
/**
* Resource temporarily unavailable (e.g. SO_RCVTIMEO expired, too many
* processes, too much memory locked, read or write with O_NONBLOCK needs
* polling, etc.).
*/
extern const errno_t EAGAIN;
/**
* We require more vespene gas.
*/
extern const errno_t ENOMEM;
/**
* Permission denied.
*/
extern const errno_t EACCES;
/**
* Pointer passed to system call that would otherwise segfault.
*/
extern const errno_t EFAULT;
/**
* Block device required.
*/
extern const errno_t ENOTBLK;
/**
* Device or resource busy.
*/
extern const errno_t EBUSY;
/**
* File exists.
*/
extern const errno_t EEXIST;
/**
* Improper link.
*/
extern const errno_t EXDEV;
/**
* No such device.
*/
extern const errno_t ENODEV;
/**
* Not a directory.
*/
extern const errno_t ENOTDIR;
/**
* Is a a directory.
*/
extern const errno_t EISDIR;
/**
* Invalid argument.
*/
extern const errno_t EINVAL;
/**
* Too many open files in system.
*/
extern const errno_t ENFILE;
/**
* Too many open files.
*/
extern const errno_t EMFILE;
/**
* Inappropriate i/o control operation.
*/
extern const errno_t ENOTTY;
/**
* Won't open executable that's executing in write mode.
*/
extern const errno_t ETXTBSY;
/**
* File too large.
*/
extern const errno_t EFBIG;
/**
* No space left on device.
*/
extern const errno_t ENOSPC;
/**
* Disk quota exceeded.
*/
extern const errno_t EDQUOT;
/**
* Invalid seek.
*/
extern const errno_t ESPIPE;
/**
* Read-only filesystem.
*/
extern const errno_t EROFS;
/**
* Too many links.
*/
extern const errno_t EMLINK;
/**
* Broken pipe.
*/
extern const errno_t EPIPE;
/**
* Mathematics argument out of domain of function.
*/
extern const errno_t EDOM;
/**
* Result too large.
*/
extern const errno_t ERANGE;
/**
* Resource deadlock avoided.
*/
extern const errno_t EDEADLK;
/**
* Filename too long.
*/
extern const errno_t ENAMETOOLONG;
/**
* No locks available.
*/
extern const errno_t ENOLCK;
/**
* Directory not empty.
*/
extern const errno_t ENOTEMPTY;
/**
* Too many levels of symbolic links.
*/
extern const errno_t ELOOP;
/**
* No message error.
*/
extern const errno_t ENOMSG;
/**
* Identifier removed.
*/
extern const errno_t EIDRM;
/**
* Timer expired.
*/
extern const errno_t ETIME;
/**
* Protocol error.
*/
extern const errno_t EPROTO;
/**
* Overflow error.
*/
extern const errno_t EOVERFLOW;
/**
* Unicode decoding error.
*/
extern const errno_t EILSEQ;
/**
* Too many users.
*/
extern const errno_t EUSERS;
/**
* Not a socket.
*/
extern const errno_t ENOTSOCK;
/**
* Destination address required.
*/
extern const errno_t EDESTADDRREQ;
/**
* Message too long.
*/
extern const errno_t EMSGSIZE;
/**
* Protocol wrong type for socket.
*/
extern const errno_t EPROTOTYPE;
/**
* Protocol not available.
*/
extern const errno_t ENOPROTOOPT;
/**
* Protocol not supported.
*/
extern const errno_t EPROTONOSUPPORT;
/**
* Socket type not supported.
*/
extern const errno_t ESOCKTNOSUPPORT;
/**
* Operation not supported.
*/
extern const errno_t ENOTSUP;
/**
* Socket operation not supported.
*/
extern const errno_t EOPNOTSUPP;
/**
* Protocol family not supported.
*/
extern const errno_t EPFNOSUPPORT;
/**
* Address family not supported.
*/
extern const errno_t EAFNOSUPPORT;
/**
* Address already in use.
*/
extern const errno_t EADDRINUSE;
/**
* Address not available.
*/
extern const errno_t EADDRNOTAVAIL;
/**
* Network is down.
*/
extern const errno_t ENETDOWN;
/**
* Host is unreachable.
*/
extern const errno_t ENETUNREACH;
/**
* Connection reset by network.
*/
extern const errno_t ENETRESET;
/**
* Connection reset before accept.
*/
extern const errno_t ECONNABORTED;
/**
* Connection reset by client.
*/
extern const errno_t ECONNRESET;
/**
* No buffer space available.
*/
extern const errno_t ENOBUFS;
/**
* Socket is connected.
*/
extern const errno_t EISCONN;
/**
* Socket is not connected.
*/
extern const errno_t ENOTCONN;
/**
* Cannot send after transport endpoint shutdown.
*/
extern const errno_t ESHUTDOWN;
/**
* Too many references: cannot splice.
*/
extern const errno_t ETOOMANYREFS;
/**
* Connection timed out.
*/
extern const errno_t ETIMEDOUT;
/**
* Connection refused error.
*/
extern const errno_t ECONNREFUSED;
/**
* Host down error.
*/
extern const errno_t EHOSTDOWN;
/**
* Host unreachable error.
*/
extern const errno_t EHOSTUNREACH;
/**
* Connection already in progress.
*/
extern const errno_t EALREADY;
/**
* Operation already in progress.
*/
extern const errno_t EINPROGRESS;
/**
* Stale error.
*/
extern const errno_t ESTALE;
/**
* Remote error.
*/
extern const errno_t EREMOTE;
/**
* Bad message.
*/
extern const errno_t EBADMSG;
/**
* Operation canceled.
*/
extern const errno_t ECANCELED;
/**
* Owner died.
*/
extern const errno_t EOWNERDEAD;
/**
* State not recoverable.
*/
extern const errno_t ENOTRECOVERABLE;
/**
* No network.
*/
extern const errno_t ENONET;
/**
* Please restart syscall.
*/
extern const errno_t ERESTART;
/**
* Out of streams resources.
*/
extern const errno_t ENOSR;
/**
* No string.
*/
extern const errno_t ENOSTR;
/**
* No data.
*/
extern const errno_t ENODATA;
/**
* Multihop attempted.
*/
extern const errno_t EMULTIHOP;
/**
* Link severed.
*/
extern const errno_t ENOLINK;
/**
* No medium found.
*/
extern const errno_t ENOMEDIUM;
/**
* Wrong medium type.
*/
extern const errno_t EMEDIUMTYPE;
/**
* Inappropriate file type or format.
*/
extern const errno_t EFTYPE;
extern const errno_t EAUTH;
extern const errno_t EBADARCH;
extern const errno_t EBADEXEC;
extern const errno_t EBADMACHO;
extern const errno_t EBADRPC;
extern const errno_t EDEVERR;
extern const errno_t ENEEDAUTH;
extern const errno_t ENOATTR;
extern const errno_t ENOPOLICY;
extern const errno_t EPROCLIM;
extern const errno_t EPROCUNAVAIL;
extern const errno_t EPROGMISMATCH;
extern const errno_t EPROGUNAVAIL;
extern const errno_t EPWROFF;
extern const errno_t ERPCMISMATCH;
extern const errno_t ESHLIBVERS;
extern const errno_t EADV;
extern const errno_t EBADE;
extern const errno_t EBADFD;
extern const errno_t EBADR;
extern const errno_t EBADRQC;
extern const errno_t EBADSLT;
extern const errno_t ECHRNG;
extern const errno_t ECOMM;
extern const errno_t EDOTDOT;
extern const errno_t EHWPOISON;
extern const errno_t EISNAM;
extern const errno_t EKEYEXPIRED;
extern const errno_t EKEYREJECTED;
extern const errno_t EKEYREVOKED;
extern const errno_t EL2HLT;
extern const errno_t EL2NSYNC;
extern const errno_t EL3HLT;
extern const errno_t EL3RST;
extern const errno_t ELIBACC;
extern const errno_t ELIBBAD;
extern const errno_t ELIBEXEC;
extern const errno_t ELIBMAX;
extern const errno_t ELIBSCN;
extern const errno_t ELNRNG;
extern const errno_t ENAVAIL;
extern const errno_t ENOANO;
extern const errno_t ENOCSI;
extern const errno_t ENOKEY;
extern const errno_t ENOPKG;
extern const errno_t ENOTNAM;
extern const errno_t ENOTUNIQ;
extern const errno_t EREMCHG;
extern const errno_t EREMOTEIO;
extern const errno_t ERFKILL;
extern const errno_t ESRMNT;
extern const errno_t ESTRPIPE;
extern const errno_t EUCLEAN;
extern const errno_t EUNATCH;
extern const errno_t EXFULL;
#define E2BIG E2BIG
#define EACCES EACCES
#define EADDRINUSE EADDRINUSE
#define EADDRNOTAVAIL EADDRNOTAVAIL
#define EAFNOSUPPORT EAFNOSUPPORT
#define EAGAIN EAGAIN
#define EALREADY EALREADY
#define EBADF EBADF
#define EBADMSG EBADMSG
#define EBUSY EBUSY
#define ECANCELED ECANCELED
#define ECHILD ECHILD
#define ECONNABORTED ECONNABORTED
#define ECONNREFUSED ECONNREFUSED
#define ECONNRESET ECONNRESET
#define EDEADLK EDEADLK
#define EDESTADDRREQ EDESTADDRREQ
#define EDOM EDOM
#define EDQUOT EDQUOT
#define EEXIST EEXIST
#define EFAULT EFAULT
#define EFBIG EFBIG
#define EFTYPE EFTYPE
#define EHOSTDOWN EHOSTDOWN
#define EHOSTUNREACH EHOSTUNREACH
#define EIDRM EIDRM
#define EILSEQ EILSEQ
#define EINPROGRESS EINPROGRESS
#define EINTR EINTR
#define EINVAL EINVAL
#define EIO EIO
#define EISCONN EISCONN
#define EISDIR EISDIR
#define ELOOP ELOOP
#define EMEDIUMTYPE EMEDIUMTYPE
#define EMFILE EMFILE
#define EMLINK EMLINK
#define EMSGSIZE EMSGSIZE
#define EMULTIHOP EMULTIHOP
#define ENAMETOOLONG ENAMETOOLONG
#define ENETDOWN ENETDOWN
#define ENETRESET ENETRESET
#define ENETUNREACH ENETUNREACH
#define ENFILE ENFILE
#define ENOBUFS ENOBUFS
#define ENODATA ENODATA
#define ENODEV ENODEV
#define ENOENT ENOENT
#define ENOEXEC ENOEXEC
#define ENOLCK ENOLCK
#define ENOLINK ENOLINK
#define ENOMEDIUM ENOMEDIUM
#define ENOMEM ENOMEM
#define ENOMSG ENOMSG
#define ENONET ENONET
#define ENOPROTOOPT ENOPROTOOPT
#define ENOSPC ENOSPC
#define ENOSR ENOSR
#define ENOSTR ENOSTR
#define ENOSYS ENOSYS
#define ENOTBLK ENOTBLK
#define ENOTCONN ENOTCONN
#define ENOTDIR ENOTDIR
#define ENOTEMPTY ENOTEMPTY
#define ENOTRECOVERABLE ENOTRECOVERABLE
#define ENOTSOCK ENOTSOCK
#define ENOTSUP ENOTSUP
#define ENOTTY ENOTTY
#define ENXIO ENXIO
#define EOPNOTSUPP EOPNOTSUPP
#define EOVERFLOW EOVERFLOW
#define EOWNERDEAD EOWNERDEAD
#define EPERM EPERM
#define EPFNOSUPPORT EPFNOSUPPORT
#define EPIPE EPIPE
#define EPROTO EPROTO
#define EPROTONOSUPPORT EPROTONOSUPPORT
#define EPROTOTYPE EPROTOTYPE
#define ERANGE ERANGE
#define EREMOTE EREMOTE
#define ERESTART ERESTART
#define EROFS EROFS
#define ESHUTDOWN ESHUTDOWN
#define ESOCKTNOSUPPORT ESOCKTNOSUPPORT
#define ESPIPE ESPIPE
#define ESRCH ESRCH
#define ESTALE ESTALE
#define ETIME ETIME
#define ETIMEDOUT ETIMEDOUT
#define ETOOMANYREFS ETOOMANYREFS
#define ETXTBSY ETXTBSY
#define EUSERS EUSERS
#define EWOULDBLOCK EAGAIN
#define EXDEV EXDEV
extern errno_t __errno;
errno_t *__errno_location(void) dontthrow pureconst;
#if defined(_COSMO_SOURCE) || defined(_GNU_SOURCE)
extern char *program_invocation_short_name;
extern char *program_invocation_name;
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/inttypes.h */
#define COSMOPOLITAN_LIBC_INTTYPES_H_
typedef __INT_LEAST8_TYPE__ int_least8_t;
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
typedef __INT_LEAST16_TYPE__ int_least16_t;
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
typedef __INT_LEAST32_TYPE__ int_least32_t;
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
typedef __INT_LEAST64_TYPE__ int_least64_t;
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
typedef __INT_FAST8_TYPE__ int_fast8_t;
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
typedef __INT_FAST16_TYPE__ int_fast16_t;
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
typedef __INT_FAST32_TYPE__ int_fast32_t;
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
typedef __INT_FAST64_TYPE__ int_fast64_t;
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define __PRI8 "hh"
#if __SIZEOF_INT__ == 2
#define __PRI16 ""
#elif __SIZEOF_SHORT__ == 2
#define __PRI16 "h"
#elif __SIZEOF_LONG__ == 2
#define __PRI16 "l"
#endif
#if __SIZEOF_INT__ == 4
#define __PRI32 ""
#elif __SIZEOF_LONG__ == 4
#define __PRI32 "l"
#elif __SIZEOF_LONG_LONG__ == 4
#define __PRI32 "ll"
#endif
#if __SIZEOF_INT__ == 8
#define __PRI64 ""
#elif __SIZEOF_LONG__ == 8
#define __PRI64 "l"
#elif __SIZEOF_LONG_LONG__ == 8
#define __PRI64 "ll"
#endif
#if __SIZEOF_INT__ == 16
#define __PRI128 ""
#elif __SIZEOF_LONG__ == 16
#define __PRI128 "l"
#elif __SIZEOF_LONG_LONG__ == 16
#define __PRI128 "ll"
#elif __SIZEOF_INTMAX__ == 16
#define __PRI128 "j"
#else
#define __PRI128 "jj"
#endif
#if __SIZEOF_POINTER__ == __SIZEOF_INT__
#define __PRIPTR ""
#elif __SIZEOF_POINTER__ == __SIZEOF_LONG__
#define __PRIPTR "l"
#elif __SIZEOF_POINTER__ == __SIZEOF_LONG_LONG__
#define __PRIPTR "ll"
#endif
#if __INT_FAST16_WIDTH__ == 16
#define __PRIFAST16 "h"
#elif __INT_FAST16_WIDTH__ == 32
#define __PRIFAST16 ""
#else
#define __PRIFAST16 "l"
#endif
#if __INT_FAST32_WIDTH__ == 32
#define __PRIFAST32 ""
#else
#define __PRIFAST32 "l"
#endif
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » printf » decimal ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define PRId8 __PRI8 "d"
#define PRId16 __PRI16 "d"
#define PRId32 __PRI32 "d"
#define PRId64 __PRI64 "d"
#define PRId128 __PRI128 "d"
#define PRIdLEAST8 __PRI8 "d"
#define PRIdLEAST16 __PRI16 "d"
#define PRIdLEAST32 __PRI32 "d"
#define PRIdLEAST64 __PRI64 "d"
#define PRIdLEAST128 __PRI128 "d"
#define PRIdFAST8 __PRI8 "d"
#define PRIdFAST16 __PRIFAST16 "d"
#define PRIdFAST32 __PRIFAST32 "d"
#define PRIdFAST64 __PRI64 "d"
#define PRIdFAST128 __PRI128 "d"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » printf » unsigned decimal ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define PRIu8 __PRI8 "u"
#define PRIu16 __PRI16 "u"
#define PRIu32 __PRI32 "u"
#define PRIu64 __PRI64 "u"
#define PRIu128 __PRI128 "u"
#define PRIuLEAST8 __PRI8 "u"
#define PRIuLEAST16 __PRI16 "u"
#define PRIuLEAST32 __PRI32 "u"
#define PRIuLEAST64 __PRI64 "u"
#define PRIuLEAST128 __PRI128 "u"
#define PRIuFAST8 __PRI8 "u"
#define PRIuFAST16 __PRIFAST16 "u"
#define PRIuFAST32 __PRIFAST32 "u"
#define PRIuFAST64 __PRI64 "u"
#define PRIuFAST128 __PRI128 "u"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » printf » wut ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define PRIi8 __PRI8 "i"
#define PRIi16 __PRI16 "i"
#define PRIi32 __PRI32 "i"
#define PRIi64 __PRI64 "i"
#define PRIi128 __PRI128 "i"
#define PRIiLEAST8 __PRI8 "i"
#define PRIiLEAST16 __PRI16 "i"
#define PRIiLEAST32 __PRI32 "i"
#define PRIiLEAST64 __PRI64 "i"
#define PRIiLEAST128 __PRI128 "i"
#define PRIiFAST8 __PRI8 "i"
#define PRIiFAST16 __PRIFAST16 "i"
#define PRIiFAST32 __PRIFAST32 "i"
#define PRIiFAST64 __PRI64 "i"
#define PRIiFAST128 __PRI128 "i"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » printf » octal ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define PRIo8 __PRI8 "o"
#define PRIo16 __PRI16 "o"
#define PRIo32 __PRI32 "o"
#define PRIo64 __PRI64 "o"
#define PRIo128 __PRI128 "o"
#define PRIoLEAST8 __PRI8 "o"
#define PRIoLEAST16 __PRI16 "o"
#define PRIoLEAST32 __PRI32 "o"
#define PRIoLEAST64 __PRI64 "o"
#define PRIoLEAST128 __PRI128 "o"
#define PRIoFAST8 __PRI8 "o"
#define PRIoFAST16 __PRIFAST16 "o"
#define PRIoFAST32 __PRIFAST32 "o"
#define PRIoFAST64 __PRI64 "o"
#define PRIoFAST128 __PRI128 "o"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » printf » hexadecimal ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define PRIx8 __PRI8 "x"
#define PRIx16 __PRI16 "x"
#define PRIx32 __PRI32 "x"
#define PRIx64 __PRI64 "x"
#define PRIx128 __PRI128 "x"
#define PRIxLEAST8 __PRI8 "x"
#define PRIxLEAST16 __PRI16 "x"
#define PRIxLEAST32 __PRI32 "x"
#define PRIxLEAST64 __PRI64 "x"
#define PRIxLEAST128 __PRI128 "x"
#define PRIxFAST8 __PRI8 "x"
#define PRIxFAST16 __PRIFAST16 "x"
#define PRIxFAST32 __PRIFAST32 "x"
#define PRIxFAST64 __PRI64 "x"
#define PRIxFAST128 __PRI128 "x"
#define PRIX8 __PRI8 "X"
#define PRIX16 __PRI16 "X"
#define PRIX32 __PRI32 "X"
#define PRIX64 __PRI64 "X"
#define PRIX128 __PRI128 "X"
#define PRIXLEAST8 __PRI8 "X"
#define PRIXLEAST16 __PRI16 "X"
#define PRIXLEAST32 __PRI32 "X"
#define PRIXLEAST64 __PRI64 "X"
#define PRIXLEAST128 __PRI128 "X"
#define PRIXFAST8 __PRI8 "X"
#define PRIXFAST16 __PRIFAST16 "X"
#define PRIXFAST32 __PRIFAST32 "X"
#define PRIXFAST64 __PRI64 "X"
#define PRIXFAST128 __PRI128 "X"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » printf » binary ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define PRIb8 __PRI8 "b"
#define PRIb16 __PRI16 "b"
#define PRIb32 __PRI32 "b"
#define PRIb64 __PRI64 "b"
#define PRIb128 __PRI128 "b"
#define PRIbLEAST8 __PRI8 "b"
#define PRIbLEAST16 __PRI16 "b"
#define PRIbLEAST32 __PRI32 "b"
#define PRIbLEAST64 __PRI64 "b"
#define PRIbLEAST128 __PRI128 "b"
#define PRIbFAST8 __PRI8 "b"
#define PRIbFAST16 __PRIFAST16 "b"
#define PRIbFAST32 __PRIFAST32 "b"
#define PRIbFAST64 __PRI64 "b"
#define PRIbFAST128 __PRI128 "b"
#define PRIB8 __PRI8 "B"
#define PRIB16 __PRI16 "B"
#define PRIB32 __PRI32 "B"
#define PRIB64 __PRI64 "B"
#define PRIB128 __PRI128 "B"
#define PRIBLEAST8 __PRI8 "B"
#define PRIBLEAST16 __PRI16 "B"
#define PRIBLEAST32 __PRI32 "B"
#define PRIBLEAST64 __PRI64 "B"
#define PRIBLEAST128 __PRI128 "B"
#define PRIBFAST8 __PRI8 "B"
#define PRIBFAST16 __PRIFAST16 "B"
#define PRIBFAST32 __PRIFAST32 "B"
#define PRIBFAST64 __PRI64 "B"
#define PRIBFAST128 __PRI128 "B"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » printf » miscellaneous ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define PRIdMAX "jd"
#define PRIiMAX "ji"
#define PRIoMAX "jo"
#define PRIuMAX "ju"
#define PRIxMAX "jx"
#define PRIXMAX "jX"
#define PRIdPTR __PRIPTR "d"
#define PRIiPTR __PRIPTR "i"
#define PRIoPTR __PRIPTR "o"
#define PRIuPTR __PRIPTR "u"
#define PRIxPTR __PRIPTR "x"
#define PRIXPTR __PRIPTR "X"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » scanf » decimal ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define SCNd8 __PRI8 "d"
#define SCNd16 __PRI16 "d"
#define SCNd32 __PRI32 "d"
#define SCNd64 __PRI64 "d"
#define SCNd128 __PRI128 "d"
#define SCNdLEAST8 __PRI8 "d"
#define SCNdLEAST16 __PRI16 "d"
#define SCNdLEAST32 __PRI32 "d"
#define SCNdLEAST64 __PRI64 "d"
#define SCNdLEAST128 __PRI128 "d"
#define SCNdFAST8 __PRI8 "d"
#define SCNdFAST16 __PRIFAST16 "d"
#define SCNdFAST32 __PRIFAST32 "d"
#define SCNdFAST64 __PRI64 "d"
#define SCNdFAST128 __PRI128 "d"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » scanf » flexidecimal ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define SCNi8 __PRI8 "i"
#define SCNi16 __PRI16 "i"
#define SCNi32 __PRI32 "i"
#define SCNi64 __PRI64 "i"
#define SCNi128 __PRI128 "i"
#define SCNiLEAST8 __PRI8 "i"
#define SCNiLEAST16 __PRI16 "i"
#define SCNiLEAST32 __PRI32 "i"
#define SCNiLEAST64 __PRI64 "i"
#define SCNiLEAST128 __PRI128 "i"
#define SCNiFAST8 __PRI8 "i"
#define SCNiFAST16 __PRIFAST16 "i"
#define SCNiFAST32 __PRIFAST32 "i"
#define SCNiFAST64 __PRI64 "i"
#define SCNiFAST128 __PRI128 "i"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » scanf » unsigned decimal ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define SCNu8 __PRI8 "u"
#define SCNu16 __PRI16 "u"
#define SCNu32 __PRI32 "u"
#define SCNu64 __PRI64 "u"
#define SCNu128 __PRI128 "u"
#define SCNuLEAST8 __PRI8 "u"
#define SCNuLEAST16 __PRI16 "u"
#define SCNuLEAST32 __PRI32 "u"
#define SCNuLEAST64 __PRI64 "u"
#define SCNuLEAST128 __PRI128 "u"
#define SCNuFAST8 __PRI8 "u"
#define SCNuFAST16 __PRIFAST16 "u"
#define SCNuFAST32 __PRIFAST32 "u"
#define SCNuFAST64 __PRI64 "u"
#define SCNuFAST128 __PRI128 "u"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » scanf » octal ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define SCNo8 __PRI8 "o"
#define SCNo16 __PRI16 "o"
#define SCNo32 __PRI32 "o"
#define SCNo64 __PRI64 "o"
#define SCNo128 __PRI128 "o"
#define SCNoLEAST8 __PRI8 "o"
#define SCNoLEAST16 __PRI16 "o"
#define SCNoLEAST32 __PRI32 "o"
#define SCNoLEAST64 __PRI64 "o"
#define SCNoLEAST128 __PRI128 "o"
#define SCNoFAST8 __PRI8 "o"
#define SCNoFAST16 __PRIFAST16 "o"
#define SCNoFAST32 __PRIFAST32 "o"
#define SCNoFAST64 __PRI64 "o"
#define SCNoFAST128 __PRI128 "o"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » scanf » hexadecimal ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define SCNx8 __PRI8 "x"
#define SCNx16 __PRI16 "x"
#define SCNx32 __PRI32 "x"
#define SCNx64 __PRI64 "x"
#define SCNx128 __PRI128 "x"
#define SCNxLEAST8 __PRI8 "x"
#define SCNxLEAST16 __PRI16 "x"
#define SCNxLEAST32 __PRI32 "x"
#define SCNxLEAST64 __PRI64 "x"
#define SCNxLEAST128 __PRI128 "x"
#define SCNxFAST8 __PRI8 "x"
#define SCNxFAST16 __PRIFAST16 "x"
#define SCNxFAST32 __PRIFAST32 "x"
#define SCNxFAST64 __PRI64 "x"
#define SCNxFAST128 __PRI128 "x"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » scanf » binary ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define SCNb8 __PRI8 "b"
#define SCNb16 __PRI16 "b"
#define SCNb32 __PRI32 "b"
#define SCNb64 __PRI64 "b"
#define SCNb128 __PRI128 "b"
#define SCNbLEAST8 __PRI8 "b"
#define SCNbLEAST16 __PRI16 "b"
#define SCNbLEAST32 __PRI32 "b"
#define SCNbLEAST64 __PRI64 "b"
#define SCNbLEAST128 __PRI128 "b"
#define SCNbFAST8 __PRI8 "b"
#define SCNbFAST16 __PRIFAST16 "b"
#define SCNbFAST32 __PRIFAST32 "b"
#define SCNbFAST64 __PRI64 "b"
#define SCNbFAST128 __PRI128 "b"
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dismal format notation » scanf » miscellaneous ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define SCNdMAX "jd"
#define SCNiMAX "ji"
#define SCNoMAX "jo"
#define SCNuMAX "ju"
#define SCNxMAX "jx"
#define SCNdPTR __PRIPTR "d"
#define SCNiPTR __PRIPTR "i"
#define SCNoPTR __PRIPTR "o"
#define SCNuPTR __PRIPTR "u"
#define SCNxPTR __PRIPTR "x"
/*!BEGIN libc/limits.h */
#define COSMOPOLITAN_LIBC_LIMITS_H_
#define __STDC_LIMIT_MACROS
#define CHAR_BIT 8
#define PATH_MAX 1024
#define NAME_MAX 255
#define ARG_MAX 131074
#define UCHAR_MIN 0
#define UCHAR_MAX 255
#if '\200' < 0
#define CHAR_MIN '\200'
#define CHAR_MAX '\177'
#else
#define CHAR_MIN '\0'
#define CHAR_MAX '\377'
#endif
#define SCHAR_MAX __SCHAR_MAX__
#define SHRT_MAX __SHRT_MAX__
#define INT_MAX __INT_MAX__
#define LONG_MAX __LONG_MAX__
#define LLONG_MAX LONG_LONG_MAX
#define LONG_LONG_MAX __LONG_LONG_MAX__
#define SIZE_MAX __SIZE_MAX__
#define INT8_MAX __INT8_MAX__
#define INT16_MAX __INT16_MAX__
#define INT32_MAX __INT32_MAX__
#define INT64_MAX __INT64_MAX__
#define WINT_MAX __WINT_MAX__
#define WCHAR_MAX __WCHAR_MAX__
#define INTPTR_MAX __INTPTR_MAX__
#define PTRDIFF_MAX __PTRDIFF_MAX__
#define UINTPTR_MAX __UINTPTR_MAX__
#define UINT8_MAX __UINT8_MAX__
#define UINT16_MAX __UINT16_MAX__
#define UINT32_MAX __UINT32_MAX__
#define UINT64_MAX __UINT64_MAX__
#define INTMAX_MAX __INTMAX_MAX__
#define UINTMAX_MAX __UINTMAX_MAX__
#define SSIZE_MAX __INT64_MAX__
#define SCHAR_MIN (-SCHAR_MAX - 1)
#define SHRT_MIN (-SHRT_MAX - 1)
#define INT_MIN (-INT_MAX - 1)
#define LONG_MIN (-LONG_MAX - 1)
#define LLONG_MIN (-LLONG_MAX - 1)
#define LONG_LONG_MIN (-LONG_LONG_MAX - 1)
#define SIZE_MIN (-SIZE_MAX - 1)
#define INT8_MIN (-INT8_MAX - 1)
#define INT16_MIN (-INT16_MAX - 1)
#define INT32_MIN (-INT32_MAX - 1)
#define INT64_MIN (-INT64_MAX - 1)
#define INTMAX_MIN (-INTMAX_MAX - 1)
#define INTPTR_MIN (-INTPTR_MAX - 1)
#define WINT_MIN __WINT_MIN__
#define WCHAR_MIN (-WCHAR_MAX - 1)
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
#define USHRT_MAX 65535
#define UINT_MAX 0xffffffffu
#if __SIZEOF_LONG__ == 8
#define ULONG_MAX 0xfffffffffffffffful
#else
#define ULONG_MAX 0xfffffffful
#endif
#define ULLONG_MAX 0xffffffffffffffffull
#define ULONG_LONG_MAX 0xffffffffffffffffull
#define USHRT_MIN 0
#define UINT_MIN 0u
#define ULONG_MIN 0ul
#define ULLONG_MIN 0ull
#define ULONG_LONG_MIN 0ull
#define UINT8_MIN 0
#define UINT16_MIN 0
#define UINT32_MIN 0u
#define UINT64_MIN 0ull
#define UINTPTR_MIN 0ull
#define UINTMAX_MIN ((uintmax_t)0)
#define MB_CUR_MAX 4
#define MB_LEN_MAX 4
#ifdef _COSMO_SOURCE
#if __GNUC__ * 100 + __GNUC_MINOR__ >= 406 || defined(__llvm__)
#define INT128_MIN (-INT128_MAX - 1)
#define UINT128_MIN ((uint128_t)0)
#define INT128_MAX \
((int128_t)0x7fffffffffffffff << 64 | (int128_t)0xffffffffffffffff)
#define UINT128_MAX \
((uint128_t)0xffffffffffffffff << 64 | (uint128_t)0xffffffffffffffff)
#endif /* GCC 4.6+ */
#endif /* _COSMO_SOURCE */
#define SIG_ATOMIC_MIN INT32_MIN
#define SIG_ATOMIC_MAX INT32_MAX
#define FILESIZEBITS 64
#define SYMLOOP_MAX 40
#define TTY_NAME_MAX 32
#define HOST_NAME_MAX 255
#define TZNAME_MAX 6
#define WORD_BIT 32
#define SEM_VALUE_MAX 0x7fffffff
#define SEM_NSEMS_MAX 256
#define DELAYTIMER_MAX 0x7fffffff
#define MQ_PRIO_MAX 32768
#define LOGIN_NAME_MAX 256
#define NL_ARGMAX 9
#define NL_MSGMAX 32767
#define NL_SETMAX 255
#define NL_TEXTMAX 2048
#define INT_FAST8_MIN (-__INT_FAST8_MAX__ - 1)
#define INT_FAST16_MIN (-__INT_FAST16_MAX__ - 1)
#define INT_FAST32_MIN (-__INT_FAST32_MAX__ - 1)
#define INT_FAST64_MIN (-__INT_FAST64_MAX__ - 1)
#define INT_LEAST8_MIN (-__INT_LEAST8_MAX__ - 1)
#define INT_LEAST16_MIN (-__INT_LEAST16_MAX__ - 1)
#define INT_LEAST32_MIN (-__INT_LEAST32_MAX__ - 1)
#define INT_LEAST64_MIN (-__INT_LEAST64_MAX__ - 1)
#define INT_FAST8_MAX __INT_FAST8_MAX__
#define INT_FAST16_MAX __INT_FAST16_MAX__
#define INT_FAST32_MAX __INT_FAST32_MAX__
#define INT_FAST64_MAX __INT_FAST64_MAX__
#define INT_LEAST8_MAX __INT_LEAST8_MAX__
#define INT_LEAST16_MAX __INT_LEAST16_MAX__
#define INT_LEAST32_MAX __INT_LEAST32_MAX__
#define INT_LEAST64_MAX __INT_LEAST64_MAX__
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
#define BC_BASE_MAX 99
#define BC_DIM_MAX 2048
#define BC_SCALE_MAX 99
#define BC_STRING_MAX 1000
#define CHARCLASS_NAME_MAX 14
#define COLL_WEIGHTS_MAX 2
#define EXPR_NEST_MAX 32
#define LINE_MAX 4096
#define RE_DUP_MAX 255
#define LONG_BIT 64
#define NZERO 20
#define NL_LANGMAX 32
/*!BEGIN libc/literal.h */
#define COSMOPOLITAN_LIBC_LITERAL_H_
#define __STDC_CONSTANT_MACROS
#ifdef __INT8_C
#define INT8_C(c) __INT8_C(c)
#define UINT8_C(c) __UINT8_C(c)
#define INT16_C(c) __INT16_C(c)
#define UINT16_C(c) __UINT16_C(c)
#define INT32_C(c) __INT32_C(c)
#define UINT32_C(c) __UINT32_C(c)
#define INT64_C(c) __INT64_C(c)
#define UINT64_C(c) __UINT64_C(c)
#else
#define INT8_C(c) c
#define UINT8_C(c) c
#define INT16_C(c) c
#define UINT16_C(c) c
#define INT32_C(c) c
#define UINT32_C(c) c##U
#define INT64_C(c) c##L
#define UINT64_C(c) c##UL
#endif
#if UINTPTR_MAX == UINT64_MAX
#define INTMAX_C(c) c##L
#define UINTMAX_C(c) c##UL
#else
#define INTMAX_C(c) c##LL
#define UINTMAX_C(c) c##ULL
#endif
/*!BEGIN libc/math.h */
#define COSMOPOLITAN_LIBC_MATH_H_
/*─────────────────────────────────────────────────────────────────────────────╗
│ cosmopolitan § mathematics │
╚─────────────────────────────────────────────────────────────────────────────*/
#define M_E 2.7182818284590452354 /* 𝑒 */
#define M_LOG2E 1.4426950408889634074 /* log₂𝑒 */
#define M_LOG10E 0.43429448190325182765 /* log₁₀𝑒 */
#define M_LN2 0.69314718055994530942 /* logₑ2 */
#define M_LN10 2.30258509299404568402 /* logₑ10 */
#define M_PI 3.14159265358979323846 /* 𝜋 */
#define M_PI_2 1.57079632679489661923 /* 𝜋/2 */
#define M_PI_4 0.78539816339744830962 /* 𝜋/4 */
#define M_1_PI 0.31830988618379067154 /* 1/𝜋 */
#define M_2_PI 0.63661977236758134308 /* 2/𝜋 */
#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(𝜋) */
#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */
#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */
#if defined(_GNU_SOURCE) || defined(_COSMO_SOURCE)
#define M_Ef 2.7182818284590452354f /* 𝑒 */
#define M_LOG2Ef 1.4426950408889634074f /* log₂𝑒 */
#define M_LOG10Ef 0.43429448190325182765f /* log₁₀𝑒 */
#define M_LN2f 0.69314718055994530942f /* logₑ2 */
#define M_LN10f 2.30258509299404568402f /* logₑ10 */
#define M_PIf 3.14159265358979323846f /* 𝜋 */
#define M_PI_2f 1.57079632679489661923f /* 𝜋/2 */
#define M_PI_4f 0.78539816339744830962f /* 𝜋/4 */
#define M_1_PIf 0.31830988618379067154f /* 1/𝜋 */
#define M_2_PIf 0.63661977236758134308f /* 2/𝜋 */
#define M_2_SQRTPIf 1.12837916709551257390f /* 2/sqrt(𝜋) */
#define M_SQRT2f 1.41421356237309504880f /* sqrt(2) */
#define M_SQRT1_2f 0.70710678118654752440f /* 1/sqrt(2) */
#endif
#if defined(_GNU_SOURCE) || defined(_COSMO_SOURCE)
#define M_El 2.718281828459045235360287471352662498L /* 𝑒 */
#define M_LOG2El 1.442695040888963407359924681001892137L /* log₂𝑒 */
#define M_LOG10El 0.434294481903251827651128918916605082L /* log₁₀𝑒 */
#define M_LN2l 0.693147180559945309417232121458176568L /* logₑ2 */
#define M_LN10l 2.302585092994045684017991454684364208L /* logₑ10 */
#define M_PIl 3.141592653589793238462643383279502884L /* 𝜋 */
#define M_PI_2l 1.570796326794896619231321691639751442L /* 𝜋/2 */
#define M_PI_4l 0.785398163397448309615660845819875721L /* 𝜋/4 */
#define M_1_PIl 0.318309886183790671537767526745028724L /* 1/𝜋 */
#define M_2_PIl 0.636619772367581343075535053490057448L /* 2/𝜋 */
#define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(𝜋) */
#define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
#define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
#endif
#define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
#define DBL_DIG __DBL_DIG__
#define DBL_EPSILON __DBL_EPSILON__
#define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
#define DBL_IS_IEC_60559 __DBL_IS_IEC_60559__
#define DBL_MANT_DIG __DBL_MANT_DIG__
#define DBL_MANT_DIG __DBL_MANT_DIG__
#define DBL_MAX __DBL_MAX__
#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
#define DBL_MAX_EXP __DBL_MAX_EXP__
#define DBL_MIN __DBL_MIN__ /* 2.23e–308 ↔ 1.79e308 */
#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
#define DBL_MIN_EXP __DBL_MIN_EXP__
#define DBL_NORM_MAX __DBL_NORM_MAX__
#define DBL_TRUE_MIN __DBL_DENORM_MIN__
#define DECIMAL_DIG __LDBL_DECIMAL_DIG__
#define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
#define FLT_DIG __FLT_DIG__
#define FLT_EPSILON __FLT_EPSILON__
#define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
#define FLT_IS_IEC_60559 __FLT_IS_IEC_60559__
#define FLT_MANT_DIG __FLT_MANT_DIG__
#define FLT_MANT_DIG __FLT_MANT_DIG__
#define FLT_MAX __FLT_MAX__
#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
#define FLT_MAX_EXP __FLT_MAX_EXP__
#define FLT_MIN __FLT_MIN__ /* 1.18e–38 ↔ 3.40e38 */
#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
#define FLT_MIN_EXP __FLT_MIN_EXP__
#define FLT_NORM_MAX __FLT_NORM_MAX__
#define FLT_RADIX __FLT_RADIX__
#define FLT_TRUE_MIN __FLT_DENORM_MIN__
#define HLF_MAX 6.50e4f
#define HLF_MIN 3.10e-5f
#define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
#define LDBL_DIG __LDBL_DIG__
#define LDBL_EPSILON __LDBL_EPSILON__
#define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
#define LDBL_IS_IEC_60559 __LDBL_IS_IEC_60559__
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
#define LDBL_MAX __LDBL_MAX__
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
#define LDBL_MIN __LDBL_MIN__ /* 3.37e–4932 ↔ 1.18e4932 */
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
#define LDBL_NORM_MAX __LDBL_NORM_MAX__
#define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
#define FP_NAN 0
#define FP_INFINITE 1
#define FP_ZERO 2
#define FP_SUBNORMAL 3
#define FP_NORMAL 4
#define FP_ILOGB0 (-2147483647 - 1)
#define FP_ILOGBNAN (-2147483647 - 1)
#define MATH_ERRNO 1
#define MATH_ERREXCEPT 2
#ifdef __FAST_MATH__
#define math_errhandling 0
#elif defined(__NO_MATH_ERRNO__)
#define math_errhandling (MATH_ERREXCEPT)
#else
#define math_errhandling (MATH_ERRNO | MATH_ERREXCEPT)
#endif
#ifdef __FP_FAST_FMA
#define FP_FAST_FMA 1
#endif
#ifdef __FP_FAST_FMAF
#define FP_FAST_FMAF 1
#endif
#ifdef __FP_FAST_FMAL
#define FP_FAST_FMAL 1
#endif
COSMOPOLITAN_C_START_
#define NAN __builtin_nanf("")
#define INFINITY __builtin_inff()
#define HUGE_VAL __builtin_inf()
#define HUGE_VALF __builtin_inff()
#define HUGE_VALL __builtin_infl()
#if __FLT_EVAL_METHOD__ + 0 == 2
typedef long double float_t;
typedef long double double_t;
#else
typedef float float_t;
typedef double double_t;
#endif
#define isinf(x) __builtin_isinf(x)
#define isnan(x) __builtin_isnan(x)
#define isfinite(x) __builtin_isfinite(x)
#define isnormal(x) __builtin_isnormal(x)
#define isgreater(x, y) __builtin_isgreater(x, y)
#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y)
#define isless(x, y) __builtin_isless(x, y)
#define islessequal(x, y) __builtin_islessequal(x, y)
#define islessgreater(x, y) __builtin_islessgreater(x, y)
#define isunordered(x, y) __builtin_isunordered(x, y)
#define fpclassify(x) \
__builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
#define signbit(x) \
(sizeof(x) == sizeof(long double) ? __builtin_signbitl(x) \
: sizeof(x) == sizeof(float) ? __builtin_signbitf(x) \
: __builtin_signbit(x))
extern int signgam;
double acos(double) libcesque;
double acosh(double) libcesque;
double asin(double) libcesque;
double asinh(double) libcesque;
double atan(double) libcesque;
double atan2(double, double) libcesque;
double atanh(double) libcesque;
double cbrt(double) libcesque;
double ceil(double) libcesque;
double copysign(double, double) libcesque;
double cos(double) libcesque;
double cosh(double) libcesque;
double drem(double, double) libcesque;
double erf(double) libcesque;
double erfc(double) libcesque;
double exp(double) libcesque;
double exp10(double) libcesque;
double exp2(double) libcesque;
double expm1(double) libcesque;
double fabs(double) libcesque;
double fdim(double, double) libcesque;
double floor(double) libcesque;
double fma(double, double, double) libcesque;
double fmax(double, double) libcesque;
double fmin(double, double) libcesque;
double fmod(double, double) libcesque;
double hypot(double, double) libcesque;
double ldexp(double, int) libcesque;
double log(double) libcesque;
double log10(double) libcesque;
double log1p(double) libcesque;
double log2(double) libcesque;
double logb(double) libcesque;
double nearbyint(double) libcesque;
double nextafter(double, double) libcesque;
double nexttoward(double, long double) libcesque;
double pow(double, double) libcesque;
double pow10(double) libcesque;
double powi(double, int) libcesque;
double remainder(double, double) libcesque;
double rint(double) libcesque;
double round(double) libcesque;
double scalb(double, double) libcesque;
double scalbln(double, long int) libcesque;
double scalbn(double, int) libcesque;
double significand(double) libcesque;
double sin(double) libcesque;
double sinh(double) libcesque;
double sqrt(double) libcesque;
double tan(double) libcesque;
double tanh(double) libcesque;
double trunc(double) libcesque;
double tgamma(double) libcesque;
double lgamma(double) libcesque;
double lgamma_r(double, int *) libcesque;
int finite(double) libcesque;
float acosf(float) libcesque;
float acoshf(float) libcesque;
float asinf(float) libcesque;
float asinhf(float) libcesque;
float atan2f(float, float) libcesque;
float atanf(float) libcesque;
float atanhf(float) libcesque;
float cbrtf(float) libcesque;
float ceilf(float) libcesque;
float copysignf(float, float) libcesque;
float cosf(float) libcesque;
float coshf(float) libcesque;
float dremf(float, float) libcesque;
float erfcf(float) libcesque;
float erff(float) libcesque;
float exp10f(float) libcesque;
float exp2f(float) libcesque;
float expf(float) libcesque;
float expm1f(float) libcesque;
float fabsf(float) libcesque;
float fdimf(float, float) libcesque;
float floorf(float) libcesque;
float fmaf(float, float, float) libcesque;
float fmaxf(float, float) libcesque;
float fminf(float, float) libcesque;
float fmodf(float, float) libcesque;
float hypotf(float, float) libcesque;
float ldexpf(float, int) libcesque;
float lgammaf(float) libcesque;
float lgammaf_r(float, int *) libcesque;
float log10f(float) libcesque;
float log1pf(float) libcesque;
float log2f(float) libcesque;
float logbf(float) libcesque;
float logf(float) libcesque;
float nearbyintf(float) libcesque;
float nextafterf(float, float) libcesque;
float nexttowardf(float, long double) libcesque;
float pow10f(float) libcesque;
float powf(float, float) libcesque;
float powif(float, int) libcesque;
float remainderf(float, float) libcesque;
float rintf(float) libcesque;
float roundf(float) libcesque;
float scalbf(float, float) libcesque;
float scalblnf(float, long int) libcesque;
float scalbnf(float, int) libcesque;
float significandf(float) libcesque;
float sinf(float) libcesque;
float sinhf(float) libcesque;
float sqrtf(float) libcesque;
float tanf(float) libcesque;
float tanhf(float) libcesque;
float tgammaf(float) libcesque;
float truncf(float) libcesque;
int finitef(float) libcesque;
int finitel(long double) libcesque;
long double acoshl(long double) libcesque;
long double acosl(long double) libcesque;
long double asinhl(long double) libcesque;
long double asinl(long double) libcesque;
long double atan2l(long double, long double) libcesque;
long double atanhl(long double) libcesque;
long double atanl(long double) libcesque;
long double cbrtl(long double) libcesque;
long double ceill(long double) libcesque;
long double copysignl(long double, long double) libcesque;
long double coshl(long double) libcesque;
long double cosl(long double) libcesque;
long double dreml(long double, long double) libcesque;
long double erfcl(long double) libcesque;
long double erfl(long double) libcesque;
long double exp10l(long double) libcesque;
long double exp2l(long double) libcesque;
long double expl(long double) libcesque;
long double expm1l(long double) libcesque;
long double fabsl(long double) libcesque;
long double fdiml(long double, long double) libcesque;
long double floorl(long double) libcesque;
long double fmal(long double, long double, long double) libcesque;
long double fmaxl(long double, long double) libcesque;
long double fminl(long double, long double) libcesque;
long double fmodl(long double, long double) libcesque;
long double hypotl(long double, long double) libcesque;
long double ldexpl(long double, int) libcesque;
long double lgammal(long double) libcesque;
long double lgammal_r(long double, int *) libcesque;
long double log10l(long double) libcesque;
long double log1pl(long double) libcesque;
long double log2l(long double) libcesque;
long double logbl(long double) libcesque;
long double logl(long double) libcesque;
long double nearbyintl(long double) libcesque;
long double nextafterl(long double, long double) libcesque;
long double nexttowardl(long double, long double) libcesque;
long double pow10l(long double) libcesque;
long double powl(long double, long double) libcesque;
long double remainderl(long double, long double) libcesque;
long double rintl(long double) libcesque;
long double roundl(long double) libcesque;
long double scalbl(long double, long double) libcesque;
long double scalblnl(long double, long int) libcesque;
long double scalbnl(long double, int) libcesque;
long double significandl(long double) libcesque;
long double sinhl(long double) libcesque;
long double sinl(long double) libcesque;
long double sqrtl(long double) libcesque;
long double tanhl(long double) libcesque;
long double tanl(long double) libcesque;
long double tgammal(long double) libcesque;
long double truncl(long double) libcesque;
long lrint(double) libcesque;
long lrintf(float) libcesque;
long lrintl(long double) libcesque;
long lround(double) libcesque;
long lroundf(float) libcesque;
long lroundl(long double) libcesque;
int ilogbf(float) libcesque;
int ilogb(double) libcesque;
int ilogbl(long double) libcesque;
long long llrint(double) libcesque;
long long llrintf(float) libcesque;
long long llrintl(long double) libcesque;
long long llround(double) libcesque;
long long llroundf(float) libcesque;
long long llroundl(long double) libcesque;
double frexp(double, int *) libcesque;
double modf(double, double *) libcesque;
double nan(const char *) libcesque;
double remquo(double, double, int *) libcesque;
float frexpf(float, int *) libcesque;
float modff(float, float *) libcesque;
float nanf(const char *) libcesque;
float remquof(float, float, int *) libcesque;
long double frexpl(long double, int *) libcesque;
long double modfl(long double, long double *) libcesque;
long double nanl(const char *) libcesque;
long double remquol(long double, long double, int *) libcesque;
void sincos(double, double *, double *) libcesque;
void sincosf(float, float *, float *) libcesque;
void sincosl(long double, long double *, long double *) libcesque;
double fsumf(const float *, size_t) libcesque;
double fsum(const double *, size_t) libcesque;
double j0(double) libcesque;
double j1(double) libcesque;
double jn(int, double) libcesque;
float j0f(float) libcesque;
float j1f(float) libcesque;
float jnf(int, float) libcesque;
double y0(double) libcesque;
double y1(double) libcesque;
double yn(int, double) libcesque;
float y0f(float) libcesque;
float y1f(float) libcesque;
float ynf(int, float) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/paths.h */
#define COSMOPOLITAN_LIBC_PATHS_H_
#define _PATH_DEFPATH "/usr/local/bin:/bin:/usr/bin"
#define _PATH_STDPATH "/bin:/usr/bin:/sbin:/usr/sbin"
#define _PATH_BSHELL "/bin/sh"
#define _PATH_CONSOLE "/dev/console"
#define _PATH_DEVNULL "/dev/null"
#define _PATH_KLOG "/proc/kmsg"
#define _PATH_LASTLOG "/var/log/lastlog"
#define _PATH_MAILDIR "/var/mail"
#define _PATH_MAN "/usr/share/man"
#define _PATH_MNTTAB "/etc/fstab"
#define _PATH_MOUNTED "/etc/mtab"
#define _PATH_NOLOGIN "/etc/nologin"
#define _PATH_SENDMAIL "/usr/sbin/sendmail"
#define _PATH_SHADOW "/etc/shadow"
#define _PATH_SHELLS "/etc/shells"
#define _PATH_TTY "/dev/tty"
#define _PATH_UTMP "/dev/null/utmp"
#define _PATH_VI "/usr/bin/vi"
#define _PATH_WTMP "/dev/null/wtmp"
#define _PATH_DEV "/dev/"
#define _PATH_TMP "/tmp/"
#define _PATH_VARDB "/var/lib/misc/"
#define _PATH_VARRUN "/var/run/"
#define _PATH_VARTMP "/var/tmp/"
/*!BEGIN libc/serialize.h */
#define COSMOPOLITAN_SERIALIZE_H_
#ifdef _COSMO_SOURCE
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define __SWAPBE16(x) (x)
#define __SWAPBE32(x) (x)
#define __SWAPBE64(x) (x)
#else
#define __SWAPBE16(x) __builtin_bswap16(x)
#define __SWAPBE32(x) __builtin_bswap32(x)
#define __SWAPBE64(x) __builtin_bswap64(x)
#endif
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define __SWAPLE16(x) (x)
#define __SWAPLE32(x) (x)
#define __SWAPLE64(x) (x)
#else
#define __SWAPLE16(x) __builtin_bswap16(x)
#define __SWAPLE32(x) __builtin_bswap32(x)
#define __SWAPLE64(x) __builtin_bswap64(x)
#endif
#define READ16LE(P) \
(__extension__({ \
uint16_t __x; \
__builtin_memcpy(&__x, P, 16 / 8); \
__SWAPLE16(__x); \
}))
#define READ16BE(P) \
(__extension__({ \
uint16_t __x; \
__builtin_memcpy(&__x, P, 16 / 8); \
__SWAPBE16(__x); \
}))
#define READ32LE(P) \
(__extension__({ \
uint32_t __x; \
__builtin_memcpy(&__x, P, 32 / 8); \
__SWAPLE32(__x); \
}))
#define READ32BE(P) \
(__extension__({ \
uint32_t __x; \
__builtin_memcpy(&__x, P, 32 / 8); \
__SWAPBE32(__x); \
}))
#define READ64LE(P) \
(__extension__({ \
uint64_t __x; \
__builtin_memcpy(&__x, P, 64 / 8); \
__SWAPLE32(__x); \
}))
#define READ64BE(P) \
(__extension__({ \
uint64_t __x; \
__builtin_memcpy(&__x, P, 64 / 8); \
__SWAPBE64(__x); \
}))
#define WRITE16LE(P, X) \
(__extension__({ \
__typeof__(&(P)[0]) __p = (P); \
uint16_t __x = __SWAPLE16(X); \
__builtin_memcpy(__p, &__x, 16 / 8); \
__p + 16 / 8; \
}))
#define WRITE16BE(P, X) \
(__extension__({ \
__typeof__(&(P)[0]) __p = (P); \
uint16_t __x = __SWAPBE16(X); \
__builtin_memcpy(__p, &__x, 16 / 8); \
__p + 16 / 8; \
}))
#define WRITE32LE(P, X) \
(__extension__({ \
__typeof__(&(P)[0]) __p = (P); \
uint32_t __x = __SWAPLE32(X); \
__builtin_memcpy(__p, &__x, 32 / 8); \
__p + 32 / 8; \
}))
#define WRITE32BE(P, X) \
(__extension__({ \
__typeof__(&(P)[0]) __p = (P); \
uint32_t __x = __SWAPBE32(X); \
__builtin_memcpy(__p, &__x, 32 / 8); \
__p + 32 / 8; \
}))
#define WRITE64LE(P, X) \
(__extension__({ \
__typeof__(&(P)[0]) __p = (P); \
uint64_t __x = __SWAPLE64(X); \
__builtin_memcpy(__p, &__x, 64 / 8); \
__p + 64 / 8; \
}))
#define WRITE64BE(P, X) \
(__extension__({ \
__typeof__(&(P)[0]) __p = (P); \
uint64_t __x = __SWAPBE64(X); \
__builtin_memcpy(__p, &__x, 64 / 8); \
__p + 64 / 8; \
}))
#endif /* _COSMO_SOURCE */
/*!BEGIN libc/stdckdint.h */
#define COSMOPOLITAN_LIBC_STDCKDINT_H_
/* clang-format off */
/**
* @fileoverview C23 Checked Arithmetic
*
* This header defines three type generic functions:
*
* - `bool ckd_add(res, a, b)`
* - `bool ckd_sub(res, a, b)`
* - `bool ckd_mul(res, a, b)`
*
* Which allow integer arithmetic errors to be detected. There are many
* kinds of integer errors, e.g. overflow, truncation, etc. These funcs
* catch them all. Here's an example of how it works:
*
* uint32_t c;
* int32_t a = 0x7fffffff;
* int32_t b = 2;
* assert(!ckd_add(&c, a, b));
* assert(c == 0x80000001u);
*
* Experienced C / C++ users should find this example counter-intuitive
* because the expression `0x7fffffff + 2` not only overflows it's also
* undefined behavior. However here we see it's specified, and does not
* result in an error. That's because C23 checked arithmetic is not the
* arithmetic you're used to. The new standard changes the mathematics.
*
* C23 checked arithmetic is defined as performing the arithmetic using
* infinite precision and then checking if the resulting value will fit
* in the output type. Our example above did not result in an error due
* to `0x80000001` being a legal value for `uint32_t`.
*
* This implementation will use the GNU compiler builtins, when they're
* available, only if you don't use build flags like `-std=c11` because
* they define `__STRICT_ANSI__` and GCC extensions aren't really ANSI.
* Instead, you'll get a pretty good pure C11 and C++11 implementation.
*
* @see https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3096.pdf
* @version 0.1 (2023-07-22)
*/
#define __STDC_VERSION_STDCKDINT_H__ 202311L
#if ((defined(__llvm__) || \
(defined(__GNUC__) && __GNUC__ * 100 + __GNUC_MINOR__ >= 406)) && \
!defined(__STRICT_ANSI__))
#define __ckd_have_int128
#define __ckd_intmax __int128
#elif ((defined(__cplusplus) && __cplusplus >= 201103L) || \
(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L))
#define __ckd_intmax long long
#else
#define __ckd_intmax long
#endif
typedef signed __ckd_intmax __ckd_intmax_t;
typedef unsigned __ckd_intmax __ckd_uintmax_t;
#if (!defined(__STRICT_ANSI__) && \
((defined(__GNUC__) && __GNUC__ >= 5 && \
!defined(__chibicc__) && !defined(__ICC)) || \
(__has_builtin(__builtin_add_overflow) && \
__has_builtin(__builtin_sub_overflow) && \
__has_builtin(__builtin_mul_overflow))))
#define ckd_add(res, x, y) __builtin_add_overflow((x), (y), (res))
#define ckd_sub(res, x, y) __builtin_sub_overflow((x), (y), (res))
#define ckd_mul(res, x, y) __builtin_mul_overflow((x), (y), (res))
#elif defined(__cplusplus) && __cplusplus >= 201103L
template
inline bool ckd_add(__T *__res, __U __a, __V __b) {
static_assert(std::is_integral<__T>::value &&
std::is_integral<__U>::value &&
std::is_integral<__V>::value,
"non-integral types not allowed");
static_assert(!std::is_same<__T, bool>::value &&
!std::is_same<__U, bool>::value &&
!std::is_same<__V, bool>::value,
"checked booleans not supported");
static_assert(!std::is_same<__T, char>::value &&
!std::is_same<__U, char>::value &&
!std::is_same<__V, char>::value,
"unqualified char type is ambiguous");
__ckd_uintmax_t __x = __a;
__ckd_uintmax_t __y = __b;
__ckd_uintmax_t __z = __x + __y;
*__res = __z;
if (sizeof(__z) > sizeof(__U) && sizeof(__z) > sizeof(__V)) {
if (sizeof(__z) > sizeof(__T) || std::is_signed<__T>::value) {
return static_cast<__ckd_intmax_t>(__z) != static_cast<__T>(__z);
} else if (!std::is_same<__T, __ckd_uintmax_t>::value) {
return (__z != static_cast<__T>(__z) ||
((std::is_signed<__U>::value ||
std::is_signed<__V>::value) &&
static_cast<__ckd_intmax_t>(__z) < 0));
}
}
bool __truncated = false;
if (sizeof(__T) < sizeof(__ckd_intmax_t)) {
__truncated = __z != static_cast<__ckd_uintmax_t>(static_cast<__T>(__z));
}
switch (std::is_signed<__T>::value << 2 | //
std::is_signed<__U>::value << 1 | //
std::is_signed<__V>::value) {
case 0: // u = u + u
return __truncated | (__z < __x);
case 1: // u = u + s
__y ^= std::numeric_limits<__ckd_intmax_t>::min();
return __truncated |
(static_cast<__ckd_intmax_t>((__z ^ __x) &
(__z ^ __y)) < 0);
case 2: // u = s + u
__x ^= std::numeric_limits<__ckd_intmax_t>::min();
return __truncated |
(static_cast<__ckd_intmax_t>((__z ^ __x) &
(__z ^ __y)) < 0);
case 3: // u = s + s
return __truncated |
(static_cast<__ckd_intmax_t>(((__z | __x) & __y) |
((__z & __x) & ~__y)) < 0);
case 4: // s = u + u
return __truncated | (__z < __x) | (static_cast<__ckd_intmax_t>(__z) < 0);
case 5: // s = u + s
__y ^= std::numeric_limits<__ckd_intmax_t>::min();
return __truncated | (__x + __y < __y);
case 6: // s = s + u
__x ^= std::numeric_limits<__ckd_intmax_t>::min();
return __truncated | (__x + __y < __x);
case 7: // s = s + s
return __truncated |
(static_cast<__ckd_intmax_t>((__z ^ __x) &
(__z ^ __y)) < 0);
default:
for (;;) (void)0;
}
}
template
inline bool ckd_sub(__T *__res, __U __a, __V __b) {
static_assert(std::is_integral<__T>::value &&
std::is_integral<__U>::value &&
std::is_integral<__V>::value,
"non-integral types not allowed");
static_assert(!std::is_same<__T, bool>::value &&
!std::is_same<__U, bool>::value &&
!std::is_same<__V, bool>::value,
"checked booleans not supported");
static_assert(!std::is_same<__T, char>::value &&
!std::is_same<__U, char>::value &&
!std::is_same<__V, char>::value,
"unqualified char type is ambiguous");
__ckd_uintmax_t __x = __a;
__ckd_uintmax_t __y = __b;
__ckd_uintmax_t __z = __x - __y;
*__res = __z;
if (sizeof(__z) > sizeof(__U) && sizeof(__z) > sizeof(__V)) {
if (sizeof(__z) > sizeof(__T) || std::is_signed<__T>::value) {
return static_cast<__ckd_intmax_t>(__z) != static_cast<__T>(__z);
} else if (!std::is_same<__T, __ckd_uintmax_t>::value) {
return (__z != static_cast<__T>(__z) ||
((std::is_signed<__U>::value ||
std::is_signed<__V>::value) &&
static_cast<__ckd_intmax_t>(__z) < 0));
}
}
bool __truncated = false;
if (sizeof(__T) < sizeof(__ckd_intmax_t)) {
__truncated = __z != static_cast<__ckd_uintmax_t>(static_cast<__T>(__z));
}
switch (std::is_signed<__T>::value << 2 | //
std::is_signed<__U>::value << 1 | //
std::is_signed<__V>::value) {
case 0: // u = u - u
return __truncated | (__x < __y);
case 1: // u = u - s
__y ^= std::numeric_limits<__ckd_intmax_t>::min();
return __truncated |
(static_cast<__ckd_intmax_t>((__x ^ __y) &
(__z ^ __x)) < 0);
case 2: // u = s - u
return __truncated | (__y > __x) | (static_cast<__ckd_intmax_t>(__x) < 0);
case 3: // u = s - s
return __truncated |
(static_cast<__ckd_intmax_t>(((__z & __x) & __y) |
((__z | __x) & ~__y)) < 0);
case 4: // s = u - u
return __truncated |
((__x < __y) ^ (static_cast<__ckd_intmax_t>(__z) < 0));
case 5: // s = u - s
__y ^= std::numeric_limits<__ckd_intmax_t>::min();
return __truncated | (__x >= __y);
case 6: // s = s - u
__x ^= std::numeric_limits<__ckd_intmax_t>::min();
return __truncated | (__x < __y);
case 7: // s = s - s
return __truncated |
(static_cast<__ckd_intmax_t>((__x ^ __y) &
(__z ^ __x)) < 0);
default:
for (;;) (void)0;
}
}
template
inline bool ckd_mul(__T *__res, __U __a, __V __b) {
static_assert(std::is_integral<__T>::value &&
std::is_integral<__U>::value &&
std::is_integral<__V>::value,
"non-integral types not allowed");
static_assert(!std::is_same<__T, bool>::value &&
!std::is_same<__U, bool>::value &&
!std::is_same<__V, bool>::value,
"checked booleans not supported");
static_assert(!std::is_same<__T, char>::value &&
!std::is_same<__U, char>::value &&
!std::is_same<__V, char>::value,
"unqualified char type is ambiguous");
__ckd_uintmax_t __x = __a;
__ckd_uintmax_t __y = __b;
if ((sizeof(__U) * 8 - std::is_signed<__U>::value) +
(sizeof(__V) * 8 - std::is_signed<__V>::value) <=
(sizeof(__T) * 8 - std::is_signed<__T>::value)) {
if (sizeof(__ckd_uintmax_t) > sizeof(__T) || std::is_signed<__T>::value) {
__ckd_intmax_t __z = __x * __y;
return __z != (*__res = __z);
} else if (!std::is_same<__T, __ckd_uintmax_t>::value) {
__ckd_uintmax_t __z = __x * __y;
*__res = __z;
return (__z != static_cast<__T>(__z) ||
((std::is_signed<__U>::value ||
std::is_signed<__V>::value) &&
static_cast<__ckd_intmax_t>(__z) < 0));
}
}
switch (std::is_signed<__T>::value << 2 | //
std::is_signed<__U>::value << 1 | //
std::is_signed<__V>::value) {
case 0: { // u = u * u
__ckd_uintmax_t __z = __x * __y;
int __o = __x && __z / __x != __y;
*__res = __z;
return __o | (sizeof(__T) < sizeof(__z) &&
__z != static_cast<__ckd_uintmax_t>(*__res));
}
case 1: { // u = u * s
__ckd_uintmax_t __z = __x * __y;
int __o = __x && __z / __x != __y;
*__res = __z;
return (__o | ((static_cast<__ckd_intmax_t>(__y) < 0) & !!__x) |
(sizeof(__T) < sizeof(__z) &&
__z != static_cast<__ckd_uintmax_t>(*__res)));
}
case 2: { // u = s * u
__ckd_uintmax_t __z = __x * __y;
int __o = __x && __z / __x != __y;
*__res = __z;
return (__o | ((static_cast<__ckd_intmax_t>(__x) < 0) & !!__y) |
(sizeof(__T) < sizeof(__z) &&
__z != static_cast<__ckd_uintmax_t>(*__res)));
}
case 3: { // u = s * s
int __o = false;
if (static_cast<__ckd_intmax_t>(__x & __y) < 0) {
__x = -__x;
__y = -__y;
} else if (static_cast<__ckd_intmax_t>(__x ^ __y) < 0) {
__o = __x && __y;
}
__ckd_uintmax_t __z = __x * __y;
__o |= __x && __z / __x != __y;
*__res = __z;
return __o | (sizeof(__T) < sizeof(__z) &&
__z != static_cast<__ckd_uintmax_t>(*__res));
}
case 4: { // s = u * u
__ckd_uintmax_t __z = __x * __y;
int __o = __x && __z / __x != __y;
*__res = __z;
return (__o | (static_cast<__ckd_intmax_t>(__z) < 0) |
(sizeof(__T) < sizeof(__z) &&
__z != static_cast<__ckd_uintmax_t>(*__res)));
}
case 5: { // s = u * s
__ckd_uintmax_t __t = -__y;
__t = static_cast<__ckd_intmax_t>(__t) < 0 ? __y : __t;
__ckd_uintmax_t __p = __t * __x;
int __o = __t && __p / __t != __x;
int __n = static_cast<__ckd_intmax_t>(__y) < 0;
__ckd_uintmax_t __z = __n ? -__p : __p;
*__res = __z;
__ckd_uintmax_t __m = std::numeric_limits<__ckd_intmax_t>::max();
return (__o | (__p > __m + __n) |
(sizeof(__T) < sizeof(__z) &&
__z != static_cast<__ckd_uintmax_t>(*__res)));
}
case 6: { // s = s * u
__ckd_uintmax_t __t = -__x;
__t = static_cast<__ckd_intmax_t>(__t) < 0 ? __x : __t;
__ckd_uintmax_t __p = __t * __y;
int __o = __t && __p / __t != __y;
int __n = static_cast<__ckd_intmax_t>(__x) < 0;
__ckd_uintmax_t __z = __n ? -__p : __p;
*__res = __z;
__ckd_uintmax_t __m = std::numeric_limits<__ckd_intmax_t>::max();
return (__o | (__p > __m + __n) |
(sizeof(__T) < sizeof(__z) &&
__z != static_cast<__ckd_uintmax_t>(*__res)));
}
case 7: { // s = s * s
__ckd_uintmax_t __z = __x * __y;
*__res = __z;
return ((((static_cast<__ckd_intmax_t>(__y) < 0) &&
(static_cast<__ckd_intmax_t>(__x) ==
std::numeric_limits<__ckd_intmax_t>::min())) ||
(__y && ((static_cast<__ckd_intmax_t>(__z) /
static_cast<__ckd_intmax_t>(__y)) !=
static_cast<__ckd_intmax_t>(__x)))) |
(sizeof(__T) < sizeof(__z) &&
__z != static_cast<__ckd_uintmax_t>(*__res)));
}
default:
for (;;) (void)0;
}
}
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define ckd_add(res, a, b) __ckd_expr(add, (res), (a), (b))
#define ckd_sub(res, a, b) __ckd_expr(sub, (res), (a), (b))
#define ckd_mul(res, a, b) __ckd_expr(mul, (res), (a), (b))
#if defined(__GNUC__) || defined(__llvm__)
#define __ckd_inline \
extern __inline __attribute__((__gnu_inline__, \
__always_inline__, \
__artificial__))
#else
#define __ckd_inline static inline
#endif
#ifdef __ckd_have_int128
#define __ckd_generic_int128(x, y) , signed __int128: x, unsigned __int128: y
#else
#define __ckd_generic_int128(x, y)
#endif
#define __ckd_sign(T) \
((T)1 << (sizeof(T) * 8 - 1))
#define __ckd_is_signed(x) \
_Generic(x, \
signed char: 1, \
unsigned char: 0, \
signed short: 1, \
unsigned short: 0, \
signed int: 1, \
unsigned int: 0, \
signed long: 1, \
unsigned long: 0, \
signed long long: 1, \
unsigned long long: 0 \
__ckd_generic_int128(1, 0))
#define __ckd_expr(op, res, a, b) \
(_Generic(*res, \
signed char: __ckd_##op##_schar, \
unsigned char: __ckd_##op##_uchar, \
signed short: __ckd_##op##_sshort, \
unsigned short: __ckd_##op##_ushort, \
signed int: __ckd_##op##_sint, \
unsigned int: __ckd_##op##_uint, \
signed long: __ckd_##op##_slong, \
unsigned long: __ckd_##op##_ulong, \
signed long long: __ckd_##op##_slonger, \
unsigned long long: __ckd_##op##_ulonger \
__ckd_generic_int128( \
__ckd_##op##_sint128, \
__ckd_##op##_uint128))( \
res, a, b, \
__ckd_is_signed(a), \
__ckd_is_signed(b)))
#define __ckd_declare_add(S, T) \
__ckd_inline char S(void *__res, \
__ckd_uintmax_t __x, \
__ckd_uintmax_t __y, \
char __a_signed, \
char __b_signed) { \
__ckd_uintmax_t __z = __x + __y; \
*(T *)__res = __z; \
char __truncated = 0; \
if (sizeof(T) < sizeof(__ckd_intmax_t)) { \
__truncated = __z != (__ckd_uintmax_t)(T)__z; \
} \
switch (__ckd_is_signed((T)0) << 2 | \
__a_signed << 1 | __b_signed) { \
case 0: /* u = u + u */ \
return __truncated | (__z < __x); \
case 1: /* u = u + s */ \
__y ^= __ckd_sign(__ckd_uintmax_t); \
return __truncated | \
((__ckd_intmax_t)((__z ^ __x) & \
(__z ^ __y)) < 0); \
case 2: /* u = s + u */ \
__x ^= __ckd_sign(__ckd_uintmax_t); \
return __truncated | \
((__ckd_intmax_t)((__z ^ __x) & \
(__z ^ __y)) < 0); \
case 3: /* u = s + s */ \
return __truncated | \
((__ckd_intmax_t)(((__z | __x) & __y) | \
((__z & __x) & ~__y)) < 0); \
case 4: /* s = u + u */ \
return __truncated | (__z < __x) | ((__ckd_intmax_t)__z < 0); \
case 5: /* s = u + s */ \
__y ^= __ckd_sign(__ckd_uintmax_t); \
return __truncated | (__x + __y < __y); \
case 6: /* s = s + u */ \
__x ^= __ckd_sign(__ckd_uintmax_t); \
return __truncated | (__x + __y < __x); \
case 7: /* s = s + s */ \
return __truncated | \
((__ckd_intmax_t)((__z ^ __x) & \
(__z ^ __y)) < 0); \
default: \
for (;;) (void)0; \
} \
}
__ckd_declare_add(__ckd_add_schar, signed char)
__ckd_declare_add(__ckd_add_uchar, unsigned char)
__ckd_declare_add(__ckd_add_sshort, signed short)
__ckd_declare_add(__ckd_add_ushort, unsigned short)
__ckd_declare_add(__ckd_add_sint, signed int)
__ckd_declare_add(__ckd_add_uint, unsigned int)
__ckd_declare_add(__ckd_add_slong, signed long)
__ckd_declare_add(__ckd_add_ulong, unsigned long)
__ckd_declare_add(__ckd_add_slonger, signed long long)
__ckd_declare_add(__ckd_add_ulonger, unsigned long long)
#ifdef __ckd_have_int128
__ckd_declare_add(__ckd_add_sint128, signed __int128)
__ckd_declare_add(__ckd_add_uint128, unsigned __int128)
#endif
#define __ckd_declare_sub(S, T) \
__ckd_inline char S(void *__res, \
__ckd_uintmax_t __x, \
__ckd_uintmax_t __y, \
char __a_signed, \
char __b_signed) { \
__ckd_uintmax_t __z = __x - __y; \
*(T *)__res = __z; \
char __truncated = 0; \
if (sizeof(T) < sizeof(__ckd_intmax_t)) { \
__truncated = __z != (__ckd_uintmax_t)(T)__z; \
} \
switch (__ckd_is_signed((T)0) << 2 | \
__a_signed << 1 | __b_signed) { \
case 0: /* u = u - u */ \
return __truncated | (__x < __y); \
case 1: /* u = u - s */ \
__y ^= __ckd_sign(__ckd_uintmax_t); \
return __truncated | \
((__ckd_intmax_t)((__x ^ __y) & \
(__z ^ __x)) < 0); \
case 2: /* u = s - u */ \
return __truncated | (__y > __x) | ((__ckd_intmax_t)__x < 0); \
case 3: /* u = s - s */ \
return __truncated | \
((__ckd_intmax_t)(((__z & __x) & __y) | \
((__z | __x) & ~__y)) < 0); \
case 4: /* s = u - u */ \
return __truncated | ((__x < __y) ^ ((__ckd_intmax_t)__z < 0)); \
case 5: /* s = u - s */ \
__y ^= __ckd_sign(__ckd_uintmax_t); \
return __truncated | (__x >= __y); \
case 6: /* s = s - u */ \
__x ^= __ckd_sign(__ckd_uintmax_t); \
return __truncated | (__x < __y); \
case 7: /* s = s - s */ \
return __truncated | \
((__ckd_intmax_t)((__x ^ __y) & \
(__z ^ __x)) < 0); \
default: \
for (;;) (void)0; \
} \
}
__ckd_declare_sub(__ckd_sub_schar, signed char)
__ckd_declare_sub(__ckd_sub_uchar, unsigned char)
__ckd_declare_sub(__ckd_sub_sshort, signed short)
__ckd_declare_sub(__ckd_sub_ushort, unsigned short)
__ckd_declare_sub(__ckd_sub_sint, signed int)
__ckd_declare_sub(__ckd_sub_uint, unsigned int)
__ckd_declare_sub(__ckd_sub_slong, signed long)
__ckd_declare_sub(__ckd_sub_ulong, unsigned long)
__ckd_declare_sub(__ckd_sub_slonger, signed long long)
__ckd_declare_sub(__ckd_sub_ulonger, unsigned long long)
#ifdef __ckd_have_int128
__ckd_declare_sub(__ckd_sub_sint128, signed __int128)
__ckd_declare_sub(__ckd_sub_uint128, unsigned __int128)
#endif
#define __ckd_declare_mul(S, T) \
__ckd_inline char S(void *__res, \
__ckd_uintmax_t __x, \
__ckd_uintmax_t __y, \
char __a_signed, \
char __b_signed) { \
switch (__ckd_is_signed((T)0) << 2 | \
__a_signed << 1 | __b_signed) { \
case 0: { /* u = u * u */ \
__ckd_uintmax_t __z = __x * __y; \
int __o = __x && __z / __x != __y; \
*(T *)__res = __z; \
return __o | (sizeof(T) < sizeof(__z) && \
__z != (__ckd_uintmax_t)*(T *)__res); \
} \
case 1: { /* u = u * s */ \
__ckd_uintmax_t __z = __x * __y; \
int __o = __x && __z / __x != __y; \
*(T *)__res = __z; \
return (__o | (((__ckd_intmax_t)__y < 0) & !!__x) | \
(sizeof(T) < sizeof(__z) && \
__z != (__ckd_uintmax_t)*(T *)__res)); \
} \
case 2: { /* u = s * u */ \
__ckd_uintmax_t __z = __x * __y; \
int __o = __x && __z / __x != __y; \
*(T *)__res = __z; \
return (__o | (((__ckd_intmax_t)__x < 0) & !!__y) | \
(sizeof(T) < sizeof(__z) && \
__z != (__ckd_uintmax_t)*(T *)__res)); \
} \
case 3: { /* u = s * s */ \
int __o = 0; \
if ((__ckd_intmax_t)(__x & __y) < 0) { \
__x = -__x; \
__y = -__y; \
} else if ((__ckd_intmax_t)(__x ^ __y) < 0) { \
__o = __x && __y; \
} \
__ckd_uintmax_t __z = __x * __y; \
__o |= __x && __z / __x != __y; \
*(T *)__res = __z; \
return __o | (sizeof(T) < sizeof(__z) && \
__z != (__ckd_uintmax_t)*(T *)__res); \
} \
case 4: { /* s = u * u */ \
__ckd_uintmax_t __z = __x * __y; \
int __o = __x && __z / __x != __y; \
*(T *)__res = __z; \
return (__o | ((__ckd_intmax_t)(__z) < 0) | \
(sizeof(T) < sizeof(__z) && \
__z != (__ckd_uintmax_t)*(T *)__res)); \
} \
case 5: { /* s = u * s */ \
__ckd_uintmax_t __t = -__y; \
__t = (__ckd_intmax_t)(__t) < 0 ? __y : __t; \
__ckd_uintmax_t __p = __t * __x; \
int __o = __t && __p / __t != __x; \
int __n = (__ckd_intmax_t)__y < 0; \
__ckd_uintmax_t __z = __n ? -__p : __p; \
*(T *)__res = __z; \
__ckd_uintmax_t __m = __ckd_sign(__ckd_uintmax_t) - 1; \
return (__o | (__p > __m + __n) | \
(sizeof(T) < sizeof(__z) && \
__z != (__ckd_uintmax_t)*(T *)__res)); \
} \
case 6: { /* s = s * u */ \
__ckd_uintmax_t __t = -__x; \
__t = (__ckd_intmax_t)(__t) < 0 ? __x : __t; \
__ckd_uintmax_t __p = __t * __y; \
int __o = __t && __p / __t != __y; \
int __n = (__ckd_intmax_t)__x < 0; \
__ckd_uintmax_t __z = __n ? -__p : __p; \
*(T *)__res = __z; \
__ckd_uintmax_t __m = __ckd_sign(__ckd_uintmax_t) - 1; \
return (__o | (__p > __m + __n) | \
(sizeof(T) < sizeof(__z) && \
__z != (__ckd_uintmax_t)*(T *)__res)); \
} \
case 7: { /* s = s * s */ \
__ckd_uintmax_t __z = __x * __y; \
*(T *)__res = __z; \
return (((((__ckd_intmax_t)__y < 0) && \
(__x == __ckd_sign(__ckd_uintmax_t))) || \
(__y && (((__ckd_intmax_t)__z / \
(__ckd_intmax_t)__y) != \
(__ckd_intmax_t)__x))) | \
(sizeof(T) < sizeof(__z) && \
__z != (__ckd_uintmax_t)*(T *)__res)); \
} \
default: \
for (;;) (void)0; \
} \
}
__ckd_declare_mul(__ckd_mul_schar, signed char)
__ckd_declare_mul(__ckd_mul_uchar, unsigned char)
__ckd_declare_mul(__ckd_mul_sshort, signed short)
__ckd_declare_mul(__ckd_mul_ushort, unsigned short)
__ckd_declare_mul(__ckd_mul_sint, signed int)
__ckd_declare_mul(__ckd_mul_uint, unsigned int)
__ckd_declare_mul(__ckd_mul_slong, signed long)
__ckd_declare_mul(__ckd_mul_ulong, unsigned long)
__ckd_declare_mul(__ckd_mul_slonger, signed long long)
__ckd_declare_mul(__ckd_mul_ulonger, unsigned long long)
#ifdef __ckd_have_int128
__ckd_declare_mul(__ckd_mul_sint128, signed __int128)
__ckd_declare_mul(__ckd_mul_uint128, unsigned __int128)
#endif
#else
#pragma message "checked integer arithmetic unsupported in this environment"
#define ckd_add(res, x, y) (*(res) = (x) + (y), 0)
#define ckd_sub(res, x, y) (*(res) = (x) - (y), 0)
#define ckd_mul(res, x, y) (*(res) = (x) * (y), 0)
#endif /* GNU */
/* clang-format on */
/*!BEGIN libc/stdlib.h */
#define COSMOPOLITAN_LIBC_STDLIB_H_
COSMOPOLITAN_C_START_
char *fcvt(double, int, int *, int *) libcesque;
char *ecvt(double, int, int *, int *) libcesque;
char *gcvt(double, int, char *) libcesque;
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || \
defined(_COSMO_SOURCE)
void setkey(const char *) libcesque;
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/temp.h */
#define COSMOPOLITAN_LIBC_TEMP_H_
COSMOPOLITAN_C_START_
char *mktemp(char *) libcesque returnsnonnull paramsnonnull();
char *mkdtemp(char *) libcesque paramsnonnull() __wur;
int mkstemp(char *) libcesque paramsnonnull() __wur;
int mkstemps(char *, int) libcesque paramsnonnull() __wur;
#if defined(_GNU_SOURCE) || defined(_COSMO_SOURCE)
int mkostemp(char *, unsigned) libcesque paramsnonnull() __wur;
int mkostemps(char *, int, unsigned) libcesque paramsnonnull() __wur;
#endif
#ifdef _COSMO_SOURCE
int openatemp(int, char *, int, int, int) libcesque paramsnonnull() __wur;
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/time.h */
#define COSMOPOLITAN_LIBC_TIME_H_
#define TIME_UTC 1
COSMOPOLITAN_C_START_
struct tm {
int32_t tm_sec;
int32_t tm_min;
int32_t tm_hour;
int32_t tm_mday; /* 1-indexed */
int32_t tm_mon; /* 0-indexed */
int32_t tm_year; /* minus 1900 */
int32_t tm_wday;
int32_t tm_yday;
int32_t tm_isdst;
int64_t tm_gmtoff;
const char *tm_zone;
};
struct timezone {
int32_t tz_minuteswest;
int32_t tz_dsttime;
};
extern char *tzname[2];
extern long timezone;
extern int daylight;
void tzset(void) libcesque;
char *asctime(const struct tm *) libcesque;
char *asctime_r(const struct tm *, char *) libcesque;
char *strptime(const char *, const char *, struct tm *) libcesque;
int64_t mktime(struct tm *) libcesque;
int64_t timegm(struct tm *) libcesque;
int64_t timelocal(struct tm *) libcesque;
int64_t timeoff(struct tm *, long) libcesque;
size_t strftime(char *, size_t, const char *, const struct tm *) libcesque
strftimeesque(3) libcesque;
size_t wcsftime(wchar_t *, size_t, const wchar_t *,
const struct tm *) libcesque;
struct tm *gmtime(const int64_t *) libcesque;
struct tm *gmtime_r(const int64_t *, struct tm *) libcesque;
struct tm *localtime(const int64_t *) libcesque;
struct tm *localtime_r(const int64_t *, struct tm *) libcesque;
char *ctime(const int64_t *) libcesque;
char *ctime_r(const int64_t *, char *) libcesque;
double difftime(int64_t, int64_t)
pureconst libcesque;
int stime(const int64_t *) libcesque;
void tzset(void) libcesque;
#ifdef _COSMO_SOURCE
extern const char kWeekdayNameShort[7][4];
extern const char kWeekdayName[7][10];
extern const char kMonthNameShort[12][4];
extern const char kMonthName[12][10];
extern const unsigned short kMonthYearDay[2][12];
#define iso8601 __iso8601
char *iso8601(char[hasatleast 20], struct tm *) libcesque;
#define iso8601us __iso8601us
char *iso8601us(char[hasatleast 27], struct tm *, long) libcesque;
#endif /* _COSMO_SOURCE */
COSMOPOLITAN_C_END_
/*!BEGIN libc/type2str.h */
#define COSMOPOLITAN_LIBC_TYPE2STR_H_
#if __STDC_VERSION__ + 0 >= 201112
/* clang-format off */
#define _TYPE2STR(X) \
_Generic(X, \
_Bool: "_Bool", \
signed char: "signed char", \
unsigned char: "unsigned char", \
char: "char", \
short: "short", \
unsigned short: "unsigned short", \
int: "int", \
unsigned: "unsigned", \
long: "long", \
unsigned long: "unsigned long", \
long long: "long long", \
unsigned long long: "unsigned long long", \
__int128: "__int128", \
unsigned __int128: "unsigned __int128", \
float: "float", \
double: "double", \
long double: "long double")
#define _PRINTF_GENERIC(X, D, U) \
_Generic(X, \
_Bool: "hhh" U, \
signed char: "hh" D, \
unsigned char: "hh" U, \
char: "hh" D, \
short: "h" D, \
unsigned short: "h" U, \
int: D, \
unsigned: U, \
long: "l" D, \
unsigned long: "l" U, \
long long: "ll" D, \
unsigned long long: "ll" U, \
float: "f", \
double: "f", \
long double: "Lf")
/* clang-format on */
#endif /* C11 */
/*!BEGIN libc/unistd.h */
#define COSMOPOLITAN_LIBC_UNISTD_H_
COSMOPOLITAN_C_START_
#define _CS_PATH 0
size_t confstr(int, char *, size_t) libcesque;
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || \
defined(_COSMO_SOURCE)
void encrypt(char *, int) libcesque;
char *crypt(const char *, const char *) libcesque;
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/utime.h */
#define COSMOPOLITAN_LIBC_UTIME_H_
COSMOPOLITAN_C_START_
struct utimbuf {
int64_t actime; /* access time */
int64_t modtime; /* modified time */
};
int utime(const char *, const struct utimbuf *) libcesque;
#ifdef _COSMO_SOURCE
int sys_utime(const char *, const struct utimbuf *) libcesque;
#endif /* _COSMO_SOURCE */
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/typedef/u.h */
#define COSMOPOLITAN_LIBC_CALLS_TYPEDEF_U_H_
COSMOPOLITAN_C_START_
typedef unsigned char u_int8_t;
typedef unsigned short u_int16_t;
typedef unsigned u_int32_t;
typedef char *caddr_t;
typedef unsigned char u_char;
typedef unsigned short u_short, ushort;
typedef unsigned u_int, uint;
typedef unsigned long u_long, ulong;
typedef long long quad_t;
typedef unsigned long long u_quad_t;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/cpuset.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_CPUSET_H_
#define CPU_SETSIZE 1024
COSMOPOLITAN_C_START_
typedef struct cpu_set_t {
uint64_t __bits[16];
} cpu_set_t;
int sched_getcpu(void) libcesque;
int sched_getaffinity(int, size_t, cpu_set_t *) libcesque;
int sched_setaffinity(int, size_t, const cpu_set_t *) libcesque;
#define CPU_SET(i, s) ((s)->__bits[(i) / 64] |= 1ull << ((i) % 64))
#define CPU_CLR(i, s) ((s)->__bits[(i) / 64] &= ~(1ull << ((i) % 64)))
#define CPU_ISSET(i, s) (!!((s)->__bits[(i) / 64] & (1ull << ((i) % 64))))
void CPU_ZERO(cpu_set_t *) libcesque;
#define CPU_ZERO(x) CPU_ZERO(x)
int CPU_COUNT(cpu_set_t *) libcesque;
#define CPU_COUNT(x) CPU_COUNT(x)
int CPU_EQUAL(cpu_set_t *, cpu_set_t *) libcesque;
#define CPU_EQUAL(x, y) CPU_EQUAL(x, y)
void CPU_AND(cpu_set_t *, cpu_set_t *, cpu_set_t *) libcesque;
#define CPU_AND(x, y, z) CPU_AND(x, y, z)
void CPU_OR(cpu_set_t *, cpu_set_t *, cpu_set_t *) libcesque;
#define CPU_OR(x, y, z) CPU_OR(x, y, z)
void CPU_XOR(cpu_set_t *, cpu_set_t *, cpu_set_t *) libcesque;
#define CPU_XOR(x, y, z) CPU_XOR(x, y, z)
int CPU_COUNT_S(size_t, const cpu_set_t *) libcesque;
#define CPU_COUNT_S(x, y) CPU_COUNT_S(x, y)
#define CPU_ALLOC_SIZE(n) \
((((n) + (8 * sizeof(long) - 1)) & -(8 * sizeof(long))) / sizeof(long))
#define CPU_ALLOC(n) ((cpu_set_t *)calloc(1, CPU_ALLOC_SIZE(n)))
#define CPU_FREE(set) free(set)
#define CPU_ZERO_S(size, set) memset(set, 0, size)
#define CPU_EQUAL_S(size, set1, set2) (!memcmp(set1, set2, size))
#define _CPU_S(i, size, set, op) \
((i) / 8U >= (size) ? 0 \
: (((unsigned long *)(set))[(i) / 8 / sizeof(long)] op( \
1UL << ((i) % (8 * sizeof(long))))))
#define CPU_SET_S(i, size, set) _CPU_S(i, size, set, |=)
#define CPU_CLR_S(i, size, set) _CPU_S(i, size, set, &= ~)
#define CPU_ISSET_S(i, size, set) _CPU_S(i, size, set, &)
typedef cpu_set_t cpuset_t; /* for freebsd compatibility */
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/dirent.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_DIRENT_H_
COSMOPOLITAN_C_START_
struct dirent { /* linux getdents64 abi */
uint64_t d_ino; /* inode number */
int64_t d_off; /* implementation-dependent location number */
uint16_t d_reclen; /* byte length of this whole struct and string */
uint8_t d_type; /* DT_REG, DT_DIR, DT_UNKNOWN, DT_BLK, etc. */
char d_name[256]; /* NUL-terminated basename */
};
struct dirstream;
typedef struct dirstream DIR;
DIR *fdopendir(int) libcesque __wur;
DIR *opendir(const char *) libcesque __wur;
int closedir(DIR *) libcesque;
int dirfd(DIR *) libcesque;
long telldir(DIR *) libcesque;
struct dirent *readdir(DIR *) libcesque;
int readdir_r(DIR *, struct dirent *, struct dirent **) libcesque;
void rewinddir(DIR *) libcesque;
void seekdir(DIR *, long) libcesque;
int alphasort(const struct dirent **, const struct dirent **) libcesque;
int versionsort(const struct dirent **, const struct dirent **) libcesque;
int scandir(const char *, struct dirent ***, int (*)(const struct dirent *),
int (*)(const struct dirent **, const struct dirent **)) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/flock.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FLOCK_H_
COSMOPOLITAN_C_START_
struct flock { /* cosmopolitan abi */
int16_t l_type; /* F_RDLCK, F_WRLCK, F_UNLCK */
int16_t l_whence; /* SEEK_SET, SEEK_CUR, SEEK_END */
int64_t l_start; /* starting offset */
int64_t l_len; /* no. bytes (0 means to end of file) */
int32_t l_pid; /* lock owner */
int32_t l_sysid; /* remote system id or zero for local (freebsd) */
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/framebuffercolormap.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FRAMEBUFFERCOLORMAP_H_
struct FrameBufferColorMap {
uint32_t start;
uint32_t len;
uint16_t *red;
uint16_t *green;
uint16_t *blue;
uint16_t *transp;
};
/*!BEGIN libc/calls/struct/framebufferfixedscreeninfo.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FRAMEBUFFERFIXEDSCREENINFO_H_
struct FrameBufferFixedScreenInfo {
char id[16];
uint64_t smem_start;
uint32_t smem_len;
uint32_t type;
uint32_t type_aux;
uint32_t visual;
uint16_t xpanstep;
uint16_t ypanstep;
uint16_t ywrapstep;
uint32_t line_length;
uint64_t mmio_start;
uint32_t mmio_len;
uint32_t accel;
uint16_t capabilities;
uint16_t reserved[2];
};
/*!BEGIN libc/calls/struct/framebuffervirtualscreeninfo.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FRAMEBUFFERVIRTUALSCREENINFO_H_
struct FrameBufferBitField {
uint32_t offset;
uint32_t length;
uint32_t msb_right;
};
struct FrameBufferVirtualScreenInfo {
uint32_t xres;
uint32_t yres;
uint32_t xres_virtual;
uint32_t yres_virtual;
uint32_t xoffset;
uint32_t yoffset;
uint32_t bits_per_pixel;
uint32_t grayscale;
struct FrameBufferBitField red;
struct FrameBufferBitField green;
struct FrameBufferBitField blue;
struct FrameBufferBitField transp;
uint32_t nonstd;
uint32_t activate;
uint32_t height;
uint32_t width;
uint32_t accel_flags;
uint32_t pixclock;
uint32_t left_margin;
uint32_t right_margin;
uint32_t upper_margin;
uint32_t lower_margin;
uint32_t hsync_len;
uint32_t vsync_len;
uint32_t sync;
uint32_t vmode;
uint32_t rotate;
uint32_t colorspace;
uint32_t reserved[4];
};
/*!BEGIN libc/calls/struct/fsid.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_FSID_H_
COSMOPOLITAN_C_START_
typedef struct fsid_t {
uint32_t __val[2];
} fsid_t;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/iovec.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_IOVEC_H_
COSMOPOLITAN_C_START_
struct iovec {
void *iov_base;
size_t iov_len;
};
ssize_t preadv(int, struct iovec *, int, int64_t) libcesque;
ssize_t pwritev(int, const struct iovec *, int, int64_t) libcesque;
ssize_t readv(int, const struct iovec *, int) libcesque;
ssize_t vmsplice(int, const struct iovec *, int64_t, uint32_t) libcesque;
ssize_t writev(int, const struct iovec *, int) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/itimerval.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_ITIMERVAL_H_
/*!BEGIN libc/calls/struct/timeval.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMEVAL_H_
/*!BEGIN libc/calls/struct/timespec.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_TIMESPEC_H_
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
struct timespec {
int64_t tv_sec;
int64_t tv_nsec; /* nanoseconds */
};
int clock_getres(int, struct timespec *) libcesque;
int clock_gettime(int, struct timespec *) libcesque;
int clock_settime(int, const struct timespec *) libcesque;
int clock_nanosleep(int, int, const struct timespec *, struct timespec *);
int futimens(int, const struct timespec[2]) libcesque;
int nanosleep(const struct timespec *, struct timespec *) libcesque;
int utimensat(int, const char *, const struct timespec[2], int) libcesque;
int timespec_getres(struct timespec *, int) libcesque;
int timespec_get(struct timespec *, int) libcesque;
#ifdef _COSMO_SOURCE
int sys_clock_nanosleep(int, int, const struct timespec *, struct timespec *);
int cosmo_clock_nanosleep(int, int, const struct timespec *, struct timespec *);
#define timespec_zero ((struct timespec){0})
#define timespec_max ((struct timespec){0x7fffffffffffffff, 999999999})
libcesque int timespec_cmp(struct timespec, struct timespec) pureconst;
libcesque int64_t timespec_tomicros(struct timespec) pureconst;
libcesque int64_t timespec_tomillis(struct timespec) pureconst;
libcesque int64_t timespec_tonanos(struct timespec) pureconst;
libcesque struct timespec timespec_add(struct timespec,
struct timespec) pureconst;
libcesque struct timespec timespec_fromnanos(int64_t) pureconst;
libcesque struct timespec timespec_frommicros(int64_t) pureconst;
libcesque struct timespec timespec_frommillis(int64_t) pureconst;
libcesque struct timespec timespec_real(void) libcesque;
libcesque struct timespec timespec_mono(void) libcesque;
libcesque struct timespec timespec_sleep(struct timespec) libcesque;
libcesque int timespec_sleep_until(struct timespec) libcesque;
libcesque struct timespec timespec_sub(struct timespec,
struct timespec) pureconst;
libcesque struct timespec timespec_subz(struct timespec,
struct timespec) pureconst;
int sys_futex(int *, int, int, const struct timespec *, int *);
static inline struct timespec timespec_fromseconds(int64_t __x) {
return (struct timespec){__x};
}
static inline int timespec_iszero(struct timespec __ts) {
return !(__ts.tv_sec | __ts.tv_nsec);
}
static inline int timespec_isvalid(struct timespec __ts) {
return __ts.tv_sec >= 0 && __ts.tv_nsec + 0ull < 1000000000ull;
}
#endif /* _COSMO_SOURCE */
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
COSMOPOLITAN_C_START_
struct timeval {
int64_t tv_sec;
int64_t tv_usec; /* microseconds */
};
int futimes(int, const struct timeval[2]);
int futimesat(int, const char *, const struct timeval[2]);
int gettimeofday(struct timeval *, struct timezone *);
int settimeofday(const struct timeval *, const struct timezone *);
int lutimes(const char *, const struct timeval[2]);
int utimes(const char *, const struct timeval[2]);
#ifdef _COSMO_SOURCE
/* cosmopolitan libc's non-posix timevals library
removed by default due to emacs codebase clash */
#define timeval_zero ((struct timeval){0})
#define timeval_max ((struct timeval){0x7fffffffffffffff, 999999})
int timeval_cmp(struct timeval, struct timeval) pureconst;
struct timeval timeval_real(void);
struct timeval timeval_frommicros(int64_t) pureconst;
struct timeval timeval_frommillis(int64_t) pureconst;
struct timeval timeval_add(struct timeval, struct timeval) pureconst;
struct timeval timeval_sub(struct timeval, struct timeval) pureconst;
struct timeval timeval_subz(struct timeval, struct timeval) pureconst;
int64_t timeval_toseconds(struct timeval);
int64_t timeval_tomicros(struct timeval);
int64_t timeval_tomillis(struct timeval);
struct timeval timespec_totimeval(struct timespec) pureconst;
static inline struct timeval timeval_fromseconds(int64_t __x) {
return (struct timeval){__x};
}
static inline struct timespec timeval_totimespec(struct timeval __tv) {
return (struct timespec){__tv.tv_sec, __tv.tv_usec * 1000};
}
static inline int timeval_iszero(struct timeval __tv) {
return !(__tv.tv_sec | __tv.tv_usec);
}
static inline int timeval_isvalid(struct timeval __tv) {
return __tv.tv_sec >= 0 && __tv.tv_usec + 0ull < 1000000ull;
}
#endif /* _COSMO_SOURCE */
#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
#define timerisset(t) ((t)->tv_sec || (t)->tv_usec)
#define timerclear(t) ((t)->tv_sec = (t)->tv_usec = 0)
#define timercmp(s, t, op) \
((s)->tv_sec == (t)->tv_sec ? (s)->tv_usec op(t)->tv_usec \
: (s)->tv_sec op(t)->tv_sec)
#define timeradd(s, t, a) \
(void)((a)->tv_sec = (s)->tv_sec + (t)->tv_sec, \
((a)->tv_usec = (s)->tv_usec + (t)->tv_usec) >= 1000000 && \
((a)->tv_usec -= 1000000, (a)->tv_sec++))
#define timersub(s, t, a) \
(void)((a)->tv_sec = (s)->tv_sec - (t)->tv_sec, \
((a)->tv_usec = (s)->tv_usec - (t)->tv_usec) < 0 && \
((a)->tv_usec += 1000000, (a)->tv_sec--))
#endif
#ifdef _GNU_SOURCE
#define TIMEVAL_TO_TIMESPEC(tv, ts) \
((ts)->tv_sec = (tv)->tv_sec, (ts)->tv_nsec = (tv)->tv_usec * 1000, (void)0)
#define TIMESPEC_TO_TIMEVAL(tv, ts) \
((tv)->tv_sec = (ts)->tv_sec, (tv)->tv_usec = (ts)->tv_nsec / 1000, (void)0)
#endif
COSMOPOLITAN_C_END_
COSMOPOLITAN_C_START_
struct itimerval {
struct timeval it_interval; /* {0,0} means singleshot */
struct timeval it_value; /* {0,0} means disarm */
};
int getitimer(int, struct itimerval *);
int setitimer(int, const struct itimerval *, struct itimerval *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/metasigaltstack.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_METASIGALTSTACK_H_
/*!BEGIN libc/calls/struct/sigaltstack.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGALTSTACK_H_
COSMOPOLITAN_C_START_
struct sigaltstack {
void *ss_sp;
int ss_flags;
size_t ss_size;
};
typedef struct sigaltstack stack_t;
int sigaltstack(const struct sigaltstack *, struct sigaltstack *) libcesque;
COSMOPOLITAN_C_END_
COSMOPOLITAN_C_START_
struct sigaltstack_bsd {
void *ss_sp;
uint64_t ss_size;
int32_t ss_flags;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/rlimit.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_RLIMIT_H_
COSMOPOLITAN_C_START_
struct rlimit {
uint64_t rlim_cur; /* current (soft) limit in bytes */
uint64_t rlim_max; /* maximum limit in bytes */
};
int getrlimit(int, struct rlimit *) libcesque;
int setrlimit(int, const struct rlimit *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/rusage.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_RUSAGE_H_
COSMOPOLITAN_C_START_
struct rusage {
struct timeval ru_utime; /* user CPU time used */
struct timeval ru_stime; /* system CPU time used */
int64_t ru_maxrss; /* maximum resident set size in (kb) */
int64_t ru_ixrss; /* shared memory size (integral kb CLK_TCK) */
int64_t ru_idrss; /* unshared data size (integral kb CLK_TCK) */
int64_t ru_isrss; /* unshared stack size (integral kb CLK_TCK) */
int64_t ru_minflt; /* page reclaims */
int64_t ru_majflt; /* page faults */
int64_t ru_nswap; /* swaps */
int64_t ru_inblock; /* block input operations */
int64_t ru_oublock; /* block output operations */
int64_t ru_msgsnd; /* IPC messages sent */
int64_t ru_msgrcv; /* IPC messages received */
int64_t ru_nsignals; /* signals received */
int64_t ru_nvcsw; /* voluntary context switches */
int64_t ru_nivcsw; /* involuntary context switches */
};
int getrusage(int, struct rusage *) libcesque;
int wait3(int *, int, struct rusage *) libcesque;
int wait4(int, int *, int, struct rusage *) libcesque;
void rusage_add(struct rusage *, const struct rusage *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/sched_param.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SCHED_PARAM_H_
COSMOPOLITAN_C_START_
struct sched_param {
int32_t sched_priority;
};
int sched_get_priority_max(int) libcesque;
int sched_get_priority_min(int) libcesque;
int sched_getparam(int, struct sched_param *) libcesque;
int sched_getscheduler(int) libcesque;
int sched_rr_get_interval(int, struct timespec *) libcesque;
int sched_setparam(int, const struct sched_param *) libcesque;
int sched_setscheduler(int, int, const struct sched_param *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/sigaction.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGACTION_H_
/*!BEGIN libc/calls/struct/siginfo.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGINFO_H_
/*!BEGIN libc/calls/struct/sigval.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGVAL_H_
COSMOPOLITAN_C_START_
union sigval {
int32_t sival_int;
void *sival_ptr;
};
int sigqueue(int, int, const union sigval);
COSMOPOLITAN_C_END_
COSMOPOLITAN_C_START_
struct siginfo {
int32_t si_signo;
int32_t si_errno;
int32_t si_code; /* {SICODE,SEGV,ILL,FPE,POLL}_xxx */
union {
struct {
union {
struct {
/* signals sent by kill() and sigqueue() set these */
int32_t si_pid;
uint32_t si_uid;
};
struct {
/* SIGALRM sets these */
int32_t si_timerid;
int32_t si_overrun;
};
};
union {
union sigval si_value; /* provided by third arg of sigqueue(2) */
struct {
int32_t si_status;
int64_t si_utime;
int64_t si_stime;
};
};
};
struct {
void *si_addr;
int16_t si_addr_lsb;
union {
struct {
void *si_lower;
void *si_upper;
};
uint32_t si_pkey;
};
};
struct {
int64_t si_band; /* SIGPOLL */
int32_t si_fd;
};
struct {
void *si_call_addr;
int32_t si_syscall;
uint32_t si_arch;
};
char __ignoreme[128 - 2 * sizeof(int32_t) - sizeof(int64_t)];
};
};
typedef struct siginfo siginfo_t;
#ifdef _COSMO_SOURCE
void __minicrash(int, siginfo_t *, void *) libcesque;
char __is_stack_overflow(siginfo_t *, void *) libcesque;
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/sigset.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SIGSET_H_
COSMOPOLITAN_C_START_
typedef uint64_t sigset_t;
int sigaddset(sigset_t *, int) paramsnonnull();
int sigdelset(sigset_t *, int) paramsnonnull();
int sigemptyset(sigset_t *) paramsnonnull();
int sigfillset(sigset_t *) paramsnonnull();
int sigandset(sigset_t *, const sigset_t *, const sigset_t *) paramsnonnull();
int sigorset(sigset_t *, const sigset_t *, const sigset_t *) paramsnonnull();
int sigisemptyset(const sigset_t *) paramsnonnull() nosideeffect;
int sigismember(const sigset_t *, int) paramsnonnull() nosideeffect;
int sigcountset(const sigset_t *) paramsnonnull() nosideeffect;
int sigprocmask(int, const sigset_t *, sigset_t *);
int sigsuspend(const sigset_t *);
int sigpending(sigset_t *);
int pthread_sigmask(int, const sigset_t *, sigset_t *);
COSMOPOLITAN_C_END_
COSMOPOLITAN_C_START_
typedef void (*sighandler_t)(int);
typedef void (*sigaction_f)(int, struct siginfo *, void *);
struct sigaction {
union {
sighandler_t sa_handler;
sigaction_f sa_sigaction;
};
uint64_t sa_flags;
void (*sa_restorer)(void);
sigset_t sa_mask;
};
sighandler_t signal(int, sighandler_t) libcesque;
int sigaction(int, const struct sigaction *, struct sigaction *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/stat.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_H_
COSMOPOLITAN_C_START_
struct stat { /* cosmo abi */
uint64_t st_dev; /* 0: id of device with file */
uint64_t st_ino; /* 8: inode number in disk b-tree */
uint64_t st_nlink; /* 16: hard link count */
uint32_t st_mode; /* 24: octal file mask thing */
uint32_t st_uid; /* 28: user id of owner */
uint32_t st_gid; /* group id of owning group */
uint32_t st_flags; /* nt/xnu/bsd-only */
uint64_t st_rdev; /* id of device if a special file */
int64_t st_size; /* bytes in file */
int64_t st_blksize; /* preferred chunking for underlying filesystem */
int64_t st_blocks; /* number of 512-byte pages allocated to file */
struct timespec st_atim; /* access time */
struct timespec st_mtim; /* modified time */
struct timespec st_ctim; /* complicated time */
struct timespec st_birthtim;
uint64_t st_gen; /* xnu/bsd only */
};
int stat(const char *, struct stat *);
int lstat(const char *, struct stat *);
int fstat(int, struct stat *);
int fstatat(int, const char *, struct stat *, int);
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/stat.macros.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STAT_MACROS_H_
#define STAT_HAVE_NSEC 1
#define st_atime st_atim.tv_sec
#define st_mtime st_mtim.tv_sec
#define st_ctime st_ctim.tv_sec
#define st_atime_nsec st_atim.tv_nsec
#define st_mtime_nsec st_mtim.tv_nsec
#define st_ctime_nsec st_ctim.tv_nsec
#define st_atimensec st_atim.tv_nsec
#define st_mtimensec st_mtim.tv_nsec
#define st_ctimensec st_ctim.tv_nsec
#define st_birthtime st_birthtim.tv_sec
#define st_file_attributes st_flags
#define INIT_STRUCT_STAT_PADDING(st) (void)st
/*!BEGIN libc/calls/struct/statfs.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STATFS_H_
COSMOPOLITAN_C_START_
struct statfs { /* cosmo abi */
int64_t f_type; /* type of filesystem */
int64_t f_bsize; /* optimal transfer block size */
int64_t f_blocks; /* total data blocks in filesystem */
int64_t f_bfree; /* free blocks in filesystem */
int64_t f_bavail; /* free blocks available to unprivileged users */
int64_t f_files; /* total file nodes in filesystem */
int64_t f_ffree; /* free file nodes in filesystem */
fsid_t f_fsid; /* filesystem id */
int64_t f_namelen; /* maximum length of filenames */
int64_t f_frsize; /* fragment size */
int64_t f_flags; /* mount flags of filesystem 2.6.36 */
int64_t f_spare[4]; /* end of linux abi */
uint32_t f_owner;
char f_fstypename[16];
};
int statfs(const char *, struct statfs *) libcesque;
int fstatfs(int, struct statfs *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/statvfs.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_STATVFS_H_
COSMOPOLITAN_C_START_
struct statvfs {
unsigned long f_bsize; /* Filesystem block size */
unsigned long f_frsize; /* Fragment size */
uint64_t f_blocks; /* Size of fs in f_frsize units */
uint64_t f_bfree; /* Number of free blocks */
uint64_t f_bavail; /* Number of free blocks for unprivileged users */
uint64_t f_files; /* Number of inodes */
uint64_t f_ffree; /* Number of free inodes */
uint64_t f_favail; /* Number of free inodes for unprivileged users */
unsigned long f_fsid; /* Filesystem ID */
unsigned long f_flag; /* Mount flags */
unsigned long f_namemax; /* Maximum filename length */
};
int statvfs(const char *, struct statvfs *);
int fstatvfs(int, struct statvfs *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/sysinfo.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SYSINFO_H_
COSMOPOLITAN_C_START_
struct sysinfo {
int64_t uptime; /* seconds since boot */
uint64_t loads[3]; /* 1-5-15 min active process averages */
uint64_t totalram; /* system physical memory */
uint64_t freeram; /* amount of ram currently going to waste */
uint64_t sharedram; /* bytes w/ pages mapped into multiple progs */
uint64_t bufferram; /* lingering disk pages; see fadvise */
uint64_t totalswap; /* size of emergency memory */
uint64_t freeswap; /* hopefully equal to totalswap */
uint16_t procs; /* number of processes */
int16_t __ignore1; /* padding */
int32_t __ignore2; /* padding */
uint64_t totalhigh; /* wut */
uint64_t freehigh; /* wut */
uint32_t mem_unit; /* ram stuff above is multiples of this */
};
int sysinfo(struct sysinfo *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/termios.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_TERMIOS_H_
#define NCCS 20
COSMOPOLITAN_C_START_
struct termios { /* cosmo abi */
uint32_t c_iflag; /* input modes */
uint32_t c_oflag; /* output modes */
uint32_t c_cflag; /* control modes */
uint32_t c_lflag; /* local modes */
uint8_t c_cc[NCCS]; /* code mappings */
uint32_t _c_ispeed; /* use cfgetispeed() and cfsetispeed() */
uint32_t _c_ospeed; /* use cfgetospeed() and cfsetospeed() */
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/tms.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_TMS_H_
COSMOPOLITAN_C_START_
struct tms {
int64_t tms_utime; /* userspace time */
int64_t tms_stime; /* kernelspace time */
int64_t tms_cutime; /* children userspace time */
int64_t tms_cstime; /* children kernelspace time */
};
long times(struct tms *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/user_regs_struct.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_USER_REGS_STRUCT_H_
COSMOPOLITAN_C_START_
/**
* Linux Kernel user registers.
*
* @note superset of struct pt_regs
* @see ptrace() w/ PTRACE_SYSCALL
*/
struct user_regs_struct {
uint64_t r15;
uint64_t r14;
uint64_t r13;
uint64_t r12;
uint64_t rbp;
uint64_t rbx;
uint64_t r11;
uint64_t r10;
uint64_t r9;
uint64_t r8;
uint64_t rax;
uint64_t rcx;
uint64_t rdx;
uint64_t rsi;
uint64_t rdi;
uint64_t orig_rax;
uint64_t rip;
uint64_t cs;
uint64_t eflags;
uint64_t rsp;
uint64_t ss;
uint64_t fs_base;
uint64_t gs_base;
uint64_t ds;
uint64_t es;
uint64_t fs;
uint64_t gs;
};
struct useregs_struct_freebsd {
int64_t r15;
int64_t r14;
int64_t r13;
int64_t r12;
int64_t r11;
int64_t r10;
int64_t r9;
int64_t r8;
int64_t rdi;
int64_t rsi;
int64_t rbp;
int64_t rbx;
int64_t rdx;
int64_t rcx;
int64_t rax;
uint32_t trapno;
uint16_t fs;
uint16_t gs;
uint32_t err;
uint16_t es;
uint16_t ds;
int64_t rip;
int64_t cs;
int64_t rflags;
int64_t rsp;
int64_t ss;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/utsname.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_UTSNAME_H_
#define SYS_NMLN 150
COSMOPOLITAN_C_START_
struct utsname { /* cosmo abi */
char sysname[SYS_NMLN]; /* name of os */
char nodename[SYS_NMLN]; /* name of network node */
char release[SYS_NMLN]; /* release level */
char version[SYS_NMLN]; /* version level */
char machine[SYS_NMLN]; /* hardware type */
char domainname[SYS_NMLN]; /* domain name */
};
int uname(struct utsname *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/struct/winsize.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_WINSIZE_H_
COSMOPOLITAN_C_START_
struct winsize {
uint16_t ws_row;
uint16_t ws_col;
uint16_t ws_xpixel;
uint16_t ws_ypixel;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/cachestat.h */
#define COSMOPOLITAN_LIBC_CALLS_CACHESTAT_H_
COSMOPOLITAN_C_START_
struct cachestat_range {
uint64_t off;
uint64_t len;
};
struct cachestat {
/** Number of cached pages. */
uint64_t nr_cache;
/** Number of dirty pages */
uint64_t nr_dirty;
/** Number of pages marked for writeback. */
uint64_t nr_writeback;
/** Number of pages evicted from the cache. */
uint64_t nr_evicted;
/**
* Number of recently evicted pages.
* A page is recently evicted if its last eviction was recent enough that its
* reentry to the cache would indicate that it is actively being used by the
* system, and that there is memory pressure on the system.
*/
uint64_t nr_recently_evicted;
};
int cachestat(int, struct cachestat_range *, struct cachestat *, uint32_t);
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/calls.h */
#define COSMOPOLITAN_LIBC_CALLS_SYSCALLS_H_
#define _POSIX_VERSION 200809L
#define _POSIX2_VERSION _POSIX_VERSION
#define _XOPEN_VERSION 700
#define _POSIX_MAPPED_FILES _POSIX_VERSION
#define _POSIX_FSYNC _POSIX_VERSION
#define _POSIX_IPV6 _POSIX_VERSION
#define _POSIX_THREADS _POSIX_VERSION
#define _POSIX_THREAD_PROCESS_SHARED _POSIX_VERSION
#define _POSIX_THREAD_SAFE_FUNCTIONS _POSIX_VERSION
#define _POSIX_THREAD_ATTR_STACKADDR _POSIX_VERSION
#define _POSIX_THREAD_ATTR_STACKSIZE _POSIX_VERSION
#define _POSIX_THREAD_PRIORITY_SCHEDULING _POSIX_VERSION
#define _POSIX_THREAD_CPUTIME _POSIX_VERSION
#define _POSIX_TIMEOUTS _POSIX_VERSION
#define _POSIX_MONOTONIC_CLOCK _POSIX_VERSION
#define _POSIX_CPUTIME _POSIX_VERSION
#define _POSIX_BARRIERS _POSIX_VERSION
#define _POSIX_SPIN_LOCKS _POSIX_VERSION
#define _POSIX_READER_WRITER_LOCKS _POSIX_VERSION
#define _POSIX_SEMAPHORES _POSIX_VERSION
#define _POSIX_SHARED_MEMORY_OBJECTS _POSIX_VERSION
#define _POSIX_MEMLOCK_RANGE _POSIX_VERSION
#define _POSIX_SPAWN _POSIX_VERSION
#define NSIG 64
#define SEEK_SET 0 /* relative to beginning */
#define SEEK_CUR 1 /* relative to current position */
#define SEEK_END 2 /* relative to end */
#define __WALL 0x40000000 /* Wait on all children, regardless of type */
#define __WCLONE 0x80000000 /* Wait only on non-SIGCHLD children */
#define SIG_ERR ((void (*)(int))(-1))
#define SIG_DFL ((void (*)(int))0)
#define SIG_IGN ((void (*)(int))1)
#define CLOCKS_PER_SEC 1000000L
#define MAP_FAILED ((void *)-1)
#define WTERMSIG(x) (127 & (x))
#define WCOREDUMP(x) (128 & (x))
#define WIFEXITED(x) (!WTERMSIG(x))
#define WEXITSTATUS(x) ((x) >> 8)
#define WSTOPSIG(x) ((0xff00 & (x)) >> 8)
#define WIFSTOPPED(x) __wifstopped(x)
#define WIFSIGNALED(x) __wifsignaled(x)
#define WIFCONTINUED(x) __wifcontinued(x)
#define W_STOPCODE(x) ((x) << 8 | 0177)
#ifdef _COSMO_SOURCE
#define clone __clone
#define commandv __commandv
#define fileexists __fileexists
#define ischardev __ischardev
#define isdirectory __isdirectory
#define isexecutable __isexecutable
#define isregularfile __isregularfile
#define issymlink __issymlink
#define makedirs __makedirs
#define tmpfd __tmpfd
#endif
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § system calls ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
typedef int sig_atomic_t;
bool32 isatty(int) libcesque;
char *getcwd(char *, size_t) dontthrow;
char *realpath(const char *, char *) libcesque __wur;
char *ttyname(int) libcesque;
int access(const char *, int) libcesque;
int chdir(const char *) libcesque;
int chmod(const char *, unsigned) libcesque;
int chown(const char *, unsigned, unsigned) libcesque;
int chroot(const char *) libcesque;
int close(int) libcesque;
int close_range(unsigned, unsigned, unsigned) libcesque;
int closefrom(int) libcesque;
int creat(const char *, unsigned) libcesque;
int dup(int) libcesque;
int dup2(int, int) libcesque;
int dup3(int, int, int) libcesque;
int execl(const char *, const char *, ...) nullterminated() libcesque;
int execle(const char *, const char *, ...) nullterminated((1)) libcesque;
int execlp(const char *, const char *, ...) nullterminated() libcesque;
int execv(const char *, char *const[]) libcesque;
int execve(const char *, char *const[], char *const[]) libcesque;
int execvp(const char *, char *const[]) libcesque;
int faccessat(int, const char *, int, int) libcesque;
int fchdir(int) libcesque;
int fchmod(int, unsigned) libcesque;
int fchmodat(int, const char *, unsigned, int) libcesque;
int fchown(int, unsigned, unsigned) libcesque;
int fchownat(int, const char *, unsigned, unsigned, int) libcesque;
int fcntl(int, int, ...) libcesque;
int fdatasync(int) libcesque;
int fexecve(int, char *const[], char *const[]) libcesque;
int flock(int, int) libcesque;
int fork(void) libcesque;
int fsync(int) libcesque;
int ftruncate(int, int64_t) libcesque;
int getdomainname(char *, size_t) libcesque;
int getgroups(int, unsigned[]) libcesque;
int gethostname(char *, size_t) libcesque;
int getloadavg(double *, int) libcesque;
int getpgid(int) libcesque;
int getpgrp(void) libcesque nosideeffect;
int getpid(void) libcesque nosideeffect;
int getppid(void) libcesque;
int getpriority(int, unsigned) libcesque;
int getsid(int) nosideeffect libcesque;
int ioctl(int, unsigned long, ...) libcesque;
int issetugid(void) libcesque;
int kill(int, int) libcesque;
int killpg(int, int) libcesque;
int lchmod(const char *, unsigned) libcesque;
int lchown(const char *, unsigned, unsigned) libcesque;
int link(const char *, const char *) libcesque;
int linkat(int, const char *, int, const char *, int) libcesque;
int mincore(void *, size_t, unsigned char *) libcesque;
int mkdir(const char *, unsigned) libcesque;
int mkdirat(int, const char *, unsigned) libcesque;
int mknod(const char *, unsigned, uint64_t) libcesque;
int nice(int) libcesque;
int open(const char *, int, ...) libcesque;
int openat(int, const char *, int, ...) libcesque;
int pause(void) libcesque;
int pipe(int[hasatleast 2]) libcesque;
int pipe2(int[hasatleast 2], int) libcesque;
int posix_fadvise(int, int64_t, int64_t, int) libcesque;
int posix_madvise(void *, uint64_t, int) libcesque;
int raise(int) libcesque;
int reboot(int) libcesque;
int remove(const char *) libcesque;
int rename(const char *, const char *) libcesque;
int renameat(int, const char *, int, const char *) libcesque;
int rmdir(const char *) libcesque;
int sched_yield(void) libcesque;
int setegid(unsigned) libcesque;
int seteuid(unsigned) libcesque;
int setfsgid(unsigned) libcesque;
int setfsuid(unsigned) libcesque;
int setgid(unsigned) libcesque;
int setgroups(size_t, const unsigned[]) libcesque;
int setpgid(int, int) libcesque;
int setpgrp(void) libcesque;
int setpriority(int, unsigned, int) libcesque;
int setregid(unsigned, unsigned) libcesque;
int setreuid(unsigned, unsigned) libcesque;
int setsid(void) libcesque;
int setuid(unsigned) libcesque;
int shm_open(const char *, int, unsigned) libcesque;
int shm_unlink(const char *) libcesque;
int sigignore(int) libcesque;
int siginterrupt(int, int) libcesque;
int symlink(const char *, const char *) libcesque;
int symlinkat(const char *, int, const char *) libcesque;
int tcgetpgrp(int) libcesque;
int tcsetpgrp(int, int) libcesque;
int truncate(const char *, int64_t) libcesque;
int ttyname_r(int, char *, size_t) libcesque;
int unlink(const char *) libcesque;
int unlinkat(int, const char *, int) libcesque;
int usleep(uint64_t) libcesque;
int vfork(void) libcesque returnstwice;
int wait(int *) libcesque;
int waitpid(int, int *, int) libcesque;
int64_t clock(void) libcesque;
int64_t time(int64_t *) libcesque;
ssize_t copy_file_range(int, long *, int, long *, size_t, unsigned) libcesque;
ssize_t lseek(int, int64_t, int) libcesque;
ssize_t pread(int, void *, size_t, int64_t) libcesque;
ssize_t pwrite(int, const void *, size_t, int64_t) libcesque;
ssize_t read(int, void *, size_t) libcesque;
ssize_t readlink(const char *, char *, size_t) libcesque;
ssize_t readlinkat(int, const char *, char *, size_t) libcesque;
ssize_t write(int, const void *, size_t) libcesque;
unsigned alarm(unsigned) libcesque;
unsigned getegid(void) libcesque nosideeffect;
unsigned geteuid(void) libcesque nosideeffect;
unsigned getgid(void) libcesque nosideeffect;
unsigned getuid(void) libcesque;
unsigned sleep(unsigned) libcesque;
unsigned ualarm(unsigned, unsigned) libcesque;
unsigned umask(unsigned) libcesque;
void sync(void) libcesque;
#if defined(_COSMO_SOURCE) || defined(_GNU_SOURCE)
int syncfs(int) libcesque;
int prctl(int, ...) libcesque;
int gettid(void) libcesque;
int setresgid(unsigned, unsigned, unsigned) libcesque;
int setresuid(unsigned, unsigned, unsigned) libcesque;
int getresgid(unsigned *, unsigned *, unsigned *) libcesque;
int getresuid(unsigned *, unsigned *, unsigned *) libcesque;
char *get_current_dir_name(void) libcesque __wur;
ssize_t splice(int, int64_t *, int, int64_t *, size_t, unsigned) libcesque;
int memfd_create(const char *, unsigned int) libcesque;
int execvpe(const char *, char *const[], char *const[]) libcesque;
int euidaccess(const char *, int) libcesque;
int eaccess(const char *, int) libcesque;
int madvise(void *, uint64_t, int) libcesque;
int getcpu(unsigned *, unsigned *) libcesque;
#endif
#ifdef _COSMO_SOURCE
bool32 fdexists(int) libcesque;
bool32 fileexists(const char *) libcesque;
bool32 ischardev(int) libcesque;
bool32 isdirectory(const char *) libcesque;
bool32 isexecutable(const char *) libcesque;
bool32 isregularfile(const char *) libcesque;
bool32 issymlink(const char *) libcesque;
char *commandv(const char *, char *, size_t) libcesque;
int __getcwd(char *, size_t) libcesque;
int clone(void *, void *, size_t, int, void *, void *, void *, void *);
int fadvise(int, uint64_t, uint64_t, int) libcesque;
int makedirs(const char *, unsigned) libcesque;
int pivot_root(const char *, const char *) libcesque;
int pledge(const char *, const char *) libcesque;
int seccomp(unsigned, unsigned, void *) libcesque;
int sys_iopl(int) libcesque;
int sys_ioprio_get(int, int) libcesque;
int sys_ioprio_set(int, int, int) libcesque;
int sys_mlock(const void *, size_t) libcesque;
int sys_mlock2(const void *, size_t, int) libcesque;
int sys_mlockall(int) libcesque;
int sys_munlock(const void *, size_t) libcesque;
int sys_munlockall(void) libcesque;
int sys_personality(uint64_t) libcesque;
int sys_ptrace(int, ...) libcesque;
int sysctl(int *, unsigned, void *, size_t *, void *, size_t) libcesque;
int sysctlbyname(const char *, void *, size_t *, void *, size_t) libcesque;
int sysctlnametomib(const char *, int *, size_t *) libcesque;
int tmpfd(void) libcesque;
int touch(const char *, unsigned) libcesque;
int unveil(const char *, const char *) libcesque;
long ptrace(int, ...) libcesque;
ssize_t copyfd(int, int, size_t) libcesque;
ssize_t readansi(int, char *, size_t) libcesque;
ssize_t tinyprint(int, const char *, ...) libcesque nullterminated();
void shm_path_np(const char *, char[hasatleast 78]) libcesque;
#endif /* _COSMO_SOURCE */
int system(const char *) libcesque;
int __wifstopped(int) libcesque pureconst;
int __wifcontinued(int) libcesque pureconst;
int __wifsignaled(int) libcesque pureconst;
#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
#define lseek64 lseek
#define pread64 pread
#define pwrite64 pwrite
#define truncate64 truncate
#define ftruncate64 ftruncate
#define lockf64 lockf
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/ipc.h */
#define COSMOPOLITAN_LIBC_CALLS_IPC_H_
#define IPC_PRIVATE 0
#define IPC_RMID 0
#define IPC_SET 1
#define IPC_STAT 2
#define IPC_INFO 3
#define IPC_CREAT 01000
#define IPC_EXCL 02000
#define IPC_NOWAIT 04000
COSMOPOLITAN_C_START_
int ftok(const char *, int) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/landlock.h */
#define COSMOPOLITAN_LIBC_CALLS_LANDLOCK_H_
#define LANDLOCK_CREATE_RULESET_VERSION 0x0001ul
#define LANDLOCK_ACCESS_FS_EXECUTE 0x0001ul
#define LANDLOCK_ACCESS_FS_WRITE_FILE 0x0002ul
#define LANDLOCK_ACCESS_FS_READ_FILE 0x0004ul
#define LANDLOCK_ACCESS_FS_READ_DIR 0x0008ul
#define LANDLOCK_ACCESS_FS_REMOVE_DIR 0x0010ul
#define LANDLOCK_ACCESS_FS_REMOVE_FILE 0x0020ul
#define LANDLOCK_ACCESS_FS_MAKE_CHAR 0x0040ul
#define LANDLOCK_ACCESS_FS_MAKE_DIR 0x0080ul
#define LANDLOCK_ACCESS_FS_MAKE_REG 0x0100ul
#define LANDLOCK_ACCESS_FS_MAKE_SOCK 0x0200ul
#define LANDLOCK_ACCESS_FS_MAKE_FIFO 0x0400ul
#define LANDLOCK_ACCESS_FS_MAKE_BLOCK 0x0800ul
#define LANDLOCK_ACCESS_FS_MAKE_SYM 0x1000ul
/**
* Allow renaming or linking file to a different directory.
*
* @see https://lore.kernel.org/r/20220329125117.1393824-8-mic@digikod.net
* @see https://docs.kernel.org/userspace-api/landlock.html
* @note ABI 2+
*/
#define LANDLOCK_ACCESS_FS_REFER 0x2000ul
/**
* Control file truncation.
*
* @see
* https://lore.kernel.org/all/20221018182216.301684-1-gnoack3000@gmail.com/
* @see https://docs.kernel.org/userspace-api/landlock.html
* @note ABI 3+
*/
#define LANDLOCK_ACCESS_FS_TRUNCATE 0x4000ul
COSMOPOLITAN_C_START_
enum landlock_rule_type {
LANDLOCK_RULE_PATH_BENEATH = 1,
};
struct landlock_ruleset_attr {
uint64_t handled_access_fs;
};
struct thatispacked landlock_path_beneath_attr {
uint64_t allowed_access;
int32_t parent_fd;
};
int landlock_restrict_self(int, uint32_t);
int landlock_add_rule(int, enum landlock_rule_type, const void *, uint32_t);
int landlock_create_ruleset(const struct landlock_ruleset_attr *, size_t,
uint32_t);
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/makedev.h */
#define COSMOPOLITAN_LIBC_CALLS_MAKEDEV_H_
uint64_t makedev(uint32_t, uint32_t) libcesque;
uint32_t major(uint64_t) libcesque;
uint32_t minor(uint64_t) libcesque;
#define major(x) major(x)
#define minor(x) minor(x)
#define makedev(x, y) makedev(x, y)
/*!BEGIN libc/calls/mount.h */
#define COSMOPOLITAN_LIBC_CALLS_MOUNT_H_
COSMOPOLITAN_C_START_
int mount(const char *, const char *, const char *, unsigned long,
const void *);
int unmount(const char *, int);
#ifdef _GNU_SOURCE
int umount(const char *);
int umount2(const char *, int);
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/pledge.h */
#define COSMOPOLITAN_LIBC_CALLS_PLEDGE_H_
#define PLEDGE_PENALTY_KILL_THREAD 0x0000
#define PLEDGE_PENALTY_KILL_PROCESS 0x0001
#define PLEDGE_PENALTY_RETURN_EPERM 0x0002
#define PLEDGE_PENALTY_MASK 0x000f
#define PLEDGE_STDERR_LOGGING 0x0010
COSMOPOLITAN_C_START_
extern int __pledge_mode;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/sigtimedwait.h */
#define COSMOPOLITAN_LIBC_CALLS_SIGTIMEDWAIT_H_
COSMOPOLITAN_C_START_
int sigwait(const sigset_t *, int *);
int sigtimedwait(const sigset_t *, siginfo_t *, const struct timespec *);
int sigwaitinfo(const sigset_t *, siginfo_t *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/termios.h */
#define COSMOPOLITAN_LIBC_CALLS_TERMIOS_H_
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § teletypewriter control ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
int tcgetattr(int, struct termios *) libcesque;
int tcsetattr(int, int, const struct termios *) libcesque;
int openpty(int *, int *, char *, const struct termios *,
const struct winsize *) libcesque paramsnonnull((1, 2));
int forkpty(int *, char *, const struct termios *,
const struct winsize *) libcesque paramsnonnull((1, 2)) __wur;
char *ptsname(int) libcesque;
errno_t ptsname_r(int, char *, size_t) libcesque;
int grantpt(int) libcesque;
int unlockpt(int) libcesque;
int posix_openpt(int) libcesque __wur;
int tcdrain(int) libcesque;
int tcgetsid(int) libcesque;
int tcflow(int, int) libcesque;
int tcflush(int, int) libcesque;
int tcsetsid(int, int) libcesque;
int tcsendbreak(int, int) libcesque;
void cfmakeraw(struct termios *) libcesque;
int cfsetspeed(struct termios *, uint32_t) libcesque;
int cfsetospeed(struct termios *, uint32_t) libcesque;
int cfsetispeed(struct termios *, uint32_t) libcesque;
uint32_t cfgetospeed(const struct termios *) libcesque;
uint32_t cfgetispeed(const struct termios *) libcesque;
int tcsetwinsize(int, const struct winsize *) libcesque;
int tcgetwinsize(int, struct winsize *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/ttydefaults.h */
#define COSMOPOLITAN_LIBC_CALLS_TTYDEFAULTS_H_
/*!BEGIN libc/sysv/consts/termios.h */
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_TERMIOS_H_
COSMOPOLITAN_C_START_
#define EXTA B19200
#define EXTB B38400
extern const int _POSIX_VDISABLE;
extern const uint32_t BRKINT;
extern const uint32_t BS1;
extern const uint32_t BS2;
extern const uint32_t BSDLY;
extern const uint32_t CLOCAL;
extern const uint32_t CMSPAR;
extern const uint32_t CR1;
extern const uint32_t CR2;
extern const uint32_t CR3;
extern const uint32_t CRDLY;
extern const uint32_t CREAD;
extern const uint32_t CS5;
extern const uint32_t CS6;
extern const uint32_t CS7;
extern const uint32_t CS8;
extern const uint32_t CSIZE;
extern const uint32_t CSTOPB;
extern const uint32_t ECHOCTL;
extern const uint32_t ECHOE;
extern const uint32_t ECHOK;
extern const uint32_t ECHOKE;
extern const uint32_t ECHONL;
extern const uint32_t ECHOPRT;
extern const long EXTPROC;
extern const uint32_t FF1;
extern const uint32_t FF2;
extern const uint32_t FFDLY;
extern const uint32_t FLUSHO;
extern const uint32_t HUPCL;
extern const uint32_t ICANON;
extern const uint32_t ICRNL;
extern const uint32_t IEXTEN;
extern const uint32_t IGNBRK;
extern const uint32_t IGNCR;
extern const uint32_t IGNPAR;
extern const uint32_t IMAXBEL;
extern const uint32_t INLCR;
extern const uint32_t INPCK;
extern const uint32_t ISIG;
extern const uint32_t ISTRIP;
extern const uint32_t IUCLC;
extern const uint32_t IUTF8;
extern const uint32_t IXANY;
extern const uint32_t IXOFF;
extern const uint32_t IXON;
extern const uint32_t NL1;
extern const uint32_t NL2;
extern const uint32_t NL3;
extern const uint32_t NLDLY;
extern const uint32_t NOFLSH;
extern const uint32_t OCRNL;
extern const uint32_t OFDEL;
extern const uint32_t OFILL;
extern const uint32_t OLCUC;
extern const uint32_t ONLCR;
extern const uint32_t ONLRET;
extern const uint32_t ONOCR;
extern const uint32_t OPOST;
extern const uint32_t PARENB;
extern const uint32_t PARMRK;
extern const uint32_t PARODD;
extern const uint32_t PENDIN;
extern const uint32_t TAB1;
extern const uint32_t TAB2;
extern const uint32_t TAB3;
extern const uint32_t TABDLY;
extern const uint64_t TIOCCONS;
extern const uint64_t TIOCGETD;
extern const uint64_t TIOCGWINSZ;
extern const uint64_t TIOCNOTTY;
extern const uint64_t TIOCNXCL;
extern const uint64_t TIOCOUTQ;
extern const uint64_t TIOCSCTTY;
extern const uint64_t TIOCSETD;
extern const uint64_t TIOCSIG;
extern const uint64_t TIOCSPGRP;
extern const uint64_t TIOCSTI;
extern const uint64_t TIOCSWINSZ;
extern const long TOSTOP;
extern const uint8_t VDISCARD;
extern const uint8_t VEOF;
extern const uint8_t VEOL2;
extern const uint8_t VEOL;
extern const uint8_t VERASE;
extern const uint8_t VINTR;
extern const uint8_t VKILL;
extern const uint8_t VLNEXT;
extern const uint8_t VMIN;
extern const uint8_t VQUIT;
extern const uint8_t VREPRINT;
extern const uint8_t VSTART;
extern const uint8_t VSTOP;
extern const uint8_t VSUSP;
extern const uint8_t VSWTC;
extern const uint32_t VT1;
extern const uint32_t VT2;
extern const uint32_t VTDLY;
extern const uint8_t VTIME;
extern const uint8_t VWERASE;
extern const uint32_t XCASE;
extern const uint32_t XTABS;
extern const uint32_t CRTSCTS;
#define BRKINT 0x02
#define ICRNL 0x0100
#define IGNBRK 0x01
#define IGNCR 0x80
#define IGNPAR 0x04
#define IMAXBEL 0x2000
#define INLCR 0x40
#define INPCK 0x10
#define ISTRIP 0x20
#define IXANY 0x0800
#define OPOST 0x01
#define PARMRK 0x08
#define _POSIX_VDISABLE _POSIX_VDISABLE
#define NLDLY NLDLY
#define NL0 0
#define NL1 NL1
#define NL2 NL2
#define NL3 NL3
#define CRDLY CRDLY
#define CR0 0
#define CR1 CR1
#define CR2 CR2
#define CR3 CR3
#define TABDLY TABDLY
#define TAB0 0
#define TAB1 TAB1
#define TAB2 TAB2
#define TAB3 TAB3
#define XTABS XTABS
#define CRTSCTS CRTSCTS
#define BSDLY BSDLY
#define BS0 0
#define BS1 BS1
#define BS2 BS2
#define VTDLY VTDLY
#define VT0 0
#define VT1 VT1
#define VT2 VT2
#define FFDLY FFDLY
#define FF0 0
#define FF1 FF1
#define FF2 FF2
#define CLOCAL CLOCAL
#define CREAD CREAD
#define CS5 CS5
#define CS6 CS6
#define CS7 CS7
#define CS8 CS8
#define CSIZE CSIZE
#define CSTOPB CSTOPB
#define ECHO 8
#define ECHOCTL ECHOCTL
#define ECHOE ECHOE
#define ECHOK ECHOK
#define ECHOKE ECHOKE
#define ECHONL ECHONL
#define ECHOPRT ECHOPRT
#define EXTPROC EXTPROC
#define FLUSHO FLUSHO
#define HUPCL HUPCL
#define ICANON ICANON
#define IEXTEN IEXTEN
#define ISIG ISIG
#define IUCLC IUCLC
#define IUTF8 IUTF8
#define IXOFF IXOFF
#define IXON IXON
#define NOFLSH NOFLSH
#define OCRNL OCRNL
#define OFDEL OFDEL
#define OFILL OFILL
#define OLCUC OLCUC
#define ONLCR ONLCR
#define ONLRET ONLRET
#define ONOCR ONOCR
#define PARENB PARENB
#define PARODD PARODD
#define PENDIN PENDIN
#define TOSTOP TOSTOP
#define VDISCARD VDISCARD
#define VEOF VEOF
#define VEOL VEOL
#define VEOL2 VEOL2
#define VERASE VERASE
#define VINTR VINTR
#define VKILL VKILL
#define VLNEXT VLNEXT
#define VMIN VMIN
#define VQUIT VQUIT
#define VREPRINT VREPRINT
#define VSTART VSTART
#define VSTOP VSTOP
#define VSUSP VSUSP
#define VSWTC VSWTC
#define VTIME VTIME
#define VWERASE VWERASE
#define XCASE XCASE
/* terminal ioctls */
#define TIOCGWINSZ TIOCGWINSZ /* get tty dimensions */
#define TIOCSWINSZ TIOCSWINSZ /* set tty dimensions */
#define TIOCCONS TIOCCONS /* redirect terminal */
#define TIOCGETD TIOCGETD /* get line discipline */
#define TIOCSETD TIOCSETD /* set line discipline */
#define TIOCNOTTY TIOCNOTTY /* give up terminal */
#define TIOCNXCL TIOCNXCL /* disable exclusive mode */
#define TIOCOUTQ TIOCOUTQ /* bytes in output buffer */
#define TIOCSCTTY TIOCSCTTY /* make controlling terminal */
#define TIOCSIG TIOCSIG /* generate pty signal */
#define TIOCSTI TIOCSTI /* insert fake tty input */
/* tcsetattr() */
#define TCSANOW 0
#define TCSAFLUSH 2
#define TCSADRAIN 1
extern const unsigned long TCGETS; /* use tcgetattr() */
extern const unsigned long TCSETS; /* use tcsetattr() */
/* tcflush() */
extern const int TCIFLUSH;
extern const int TCOFLUSH;
extern const int TCIOFLUSH;
#define TCIFLUSH TCIFLUSH
#define TCOFLUSH TCOFLUSH
#define TCIOFLUSH TCIOFLUSH
/* tcflow() */
#define TCOOFF 0
#define TCOON 1
#define TCIOFF 2
#define TCION 3
COSMOPOLITAN_C_END_
#define TTYDEF_IFLAG (BRKINT | ISTRIP | ICRNL | IMAXBEL | IXON | IXANY)
#define TTYDEF_OFLAG (OPOST | ONLCR | XTABS)
#define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE | ECHOKE | ECHOCTL)
#define TTYDEF_CFLAG (CREAD | CS8 | HUPCL)
#define TTYDEF_SPEED (B9600)
#define CTRL(x) ((x) ^ 0100)
#define CEOF CTRL('D')
#define CERASE CTRL('?')
#define CINTR CTRL('C')
#define CKILL CTRL('U')
#define CQUIT CTRL('\\')
#define CSUSP CTRL('Z')
#define CDSUSP CTRL('Y')
#define CSTART CTRL('Q')
#define CSTOP CTRL('S')
#define CLNEXT CTRL('V')
#define CDISCARD CTRL('O')
#define CWERASE CTRL('W')
#define CREPRINT CTRL('R')
#define CEOT CEOF
#define CBRK CEOL
#define CRPRNT CREPRINT
#define CFLUSH CDISCARD
#define CEOL 255
#define CMIN 1
#define CTIME 0
/*!BEGIN libc/calls/ucontext.h */
#define COSMOPOLITAN_LIBC_CALLS_UCONTEXT_H_
COSMOPOLITAN_C_START_
#ifdef __x86_64__
#if defined(_GNU_SOURCE) || defined(_COSMO_SOURCE)
#define REG_R8 0
#define REG_R9 1
#define REG_R10 2
#define REG_R11 3
#define REG_R12 4
#define REG_R13 5
#define REG_R14 6
#define REG_R15 7
#define REG_RDI 8
#define REG_RSI 9
#define REG_RBP 10
#define REG_RBX 11
#define REG_RDX 12
#define REG_RAX 13
#define REG_RCX 14
#define REG_RSP 15
#define REG_RIP 16
#define REG_EFL 17
#define REG_CSGSFS 18
#define REG_ERR 19
#define REG_TRAPNO 20
#define REG_OLDMASK 21
#define REG_CR2 22
#endif
struct XmmRegister {
uint64_t u64[2];
};
struct FpuStackEntry {
uint16_t significand[4];
uint16_t exponent;
uint16_t padding[3];
};
struct thatispacked FpuState {
/* 8087 FPU Control Word
IM: Invalid Operation ───────────────┐
DM: Denormal Operand ───────────────┐│
ZM: Zero Divide ───────────────────┐││
OM: Overflow ─────────────────────┐│││
UM: Underflow ───────────────────┐││││
PM: Precision ──────────────────┐│││││
PC: Precision Control ───────┐ ││││││
{float,∅,double,long double}│ ││││││
RC: Rounding Control ──────┐ │ ││││││
{even, →-∞, →+∞, →0} │┌┤ ││││││
┌┤││ ││││││
d││││rr││││││
0b0000001001111111 */
uint16_t cwd;
/* 8087 FPU Status Word */
uint16_t swd;
uint16_t ftw;
uint16_t fop;
uint64_t rip;
uint64_t rdp;
/* SSE CONTROL AND STATUS REGISTER
IE: Invalid Operation Flag ──────────────┐
DE: Denormal Flag ──────────────────────┐│
ZE: Divide-by-Zero Flag ───────────────┐││
OE: Overflow Flag ────────────────────┐│││
UE: Underflow Flag ──────────────────┐││││
PE: Precision Flag ─────────────────┐│││││
DAZ: Denormals Are Zeros ──────────┐││││││
IM: Invalid Operation Mask ───────┐│││││││
DM: Denormal Operation Mask ─────┐││││││││
ZM: Divide-by-Zero Mask ────────┐│││││││││
OM: Overflow Mask ─────────────┐││││││││││
UM: Underflow Mask ───────────┐│││││││││││
PM: Precision Mask ──────────┐││││││││││││
RC: Rounding Control ───────┐│││││││││││││
{even, →-∞, →+∞, →0} ││││││││││││││
FTZ: Flush To Zero ───────┐ ││││││││││││││
│┌┤│││││││││││││
┌──────────────┐││││││││││││││││
│ reserved │││││││││││││││││
0b00000000000000000001111110000000 */
uint32_t mxcsr;
uint32_t mxcr_mask;
struct FpuStackEntry st[8];
struct XmmRegister xmm[16];
uint32_t __padding[24];
};
typedef long long greg_t;
typedef greg_t gregset_t[23];
typedef struct FpuState *fpregset_t;
#endif /* __x86_64__ */
struct sigcontext {
#ifdef __x86_64__
union {
struct {
uint64_t r8; /* 40 */
uint64_t r9; /* 48 */
uint64_t r10; /* 56 */
uint64_t r11; /* 64 */
uint64_t r12; /* 72 */
uint64_t r13; /* 80 */
uint64_t r14; /* 88 */
uint64_t r15; /* 96 */
uint64_t rdi; /* 104 */
uint64_t rsi; /* 112 */
uint64_t rbp; /* 120 */
uint64_t rbx; /* 128 */
uint64_t rdx; /* 136 */
uint64_t rax; /* 144 */
uint64_t rcx; /* 152 */
uint64_t rsp; /* 160 */
uint64_t rip; /* 168 */
uint64_t eflags; /* 176 */
uint16_t cs;
uint16_t gs;
uint16_t fs;
uint16_t __pad0;
uint64_t err;
uint64_t trapno;
uint64_t oldmask;
uint64_t cr2;
};
gregset_t gregs;
};
struct FpuState *fpregs; /* zero when no fpu context */
uint64_t __pad1[8];
#elif defined(__aarch64__)
uint64_t fault_address;
uint64_t regs[31];
uint64_t sp;
uint64_t pc;
uint64_t pstate;
uint8_t __reserved[4096] __attribute__((__aligned__(16)));
#endif /* __x86_64__ */
};
typedef struct sigcontext mcontext_t;
struct ucontext {
uint64_t uc_flags; /* don't use this */
struct ucontext *uc_link;
stack_t uc_stack;
#ifdef __x86_64__
struct sigcontext uc_mcontext;
sigset_t uc_sigmask;
uint64_t __pad[2];
struct FpuState __fpustate; /* for cosmo on non-linux */
#elif defined(__aarch64__)
sigset_t uc_sigmask;
uint8_t __unused[1024 / 8];
struct sigcontext uc_mcontext;
#endif
} forcealign(16);
typedef struct ucontext ucontext_t;
int getcontext(ucontext_t *) dontthrow;
int setcontext(const ucontext_t *) dontthrow;
int swapcontext(ucontext_t *, const ucontext_t *) dontthrow returnstwice;
void makecontext(ucontext_t *, void *, int, ...) dontthrow dontcallback;
void __sig_restore(const ucontext_t *) wontreturn;
COSMOPOLITAN_C_END_
/*!BEGIN libc/calls/weirdtypes.h */
#define COSMOPOLITAN_LIBC_CALLS_WEIRDTYPES_H_
/**
* @fileoverview Types we'd prefer hadn't been invented.
*/
typedef int64_t blkcnt_t;
typedef uint8_t cc_t;
typedef int64_t clock_t; /* uint64_t on xnu */
typedef uint64_t dev_t; /* int32_t on xnu */
typedef uint64_t fsblkcnt_t;
typedef int64_t fsfilcnt_t; /* uint32_t on xnu */
typedef uint32_t gid_t;
typedef int32_t id_t; /* int32_t on linux/freebsd/etc. */
typedef uint32_t in_addr_t;
typedef uint32_t in_addr_t;
typedef uint16_t in_port_t;
typedef uint64_t ino_t;
typedef int32_t key_t;
typedef int64_t loff_t;
typedef uint32_t mode_t; /* uint16_t on xnu */
typedef uint64_t nfds_t;
typedef int64_t off_t;
typedef int32_t pid_t;
typedef int64_t register_t;
typedef uint16_t sa_family_t; /* bsd:uint8_t */
typedef uint32_t socklen_t;
typedef uint32_t speed_t;
typedef uint32_t suseconds_t;
typedef uint64_t useconds_t; /* uint32_t on xnu */
typedef int64_t syscall_arg_t; /* uint64_t on xnu */
typedef uint32_t tcflag_t;
typedef int64_t time_t;
typedef void *timer_t;
typedef uint32_t uid_t;
typedef uint64_t rlim_t; /* int64_t on bsd */
typedef int32_t clockid_t;
#ifdef __x86_64__
typedef int64_t blksize_t; /* int32_t on xnu */
typedef uint64_t nlink_t;
#elif defined(__aarch64__)
typedef int32_t blksize_t;
typedef uint32_t nlink_t; /* uint16_t on xnu */
#endif
#define TIME_T_MAX __INT64_MAX__
#define TIME_T_MIN (-TIME_T_MAX - 1)
#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
#define F_GETLK64 F_GETLK
#define F_SETLK64 F_SETLK
#define F_SETLKW64 F_SETLKW
#define RLIM64_INFINITY RLIM_INFINITY
#define RLIM64_SAVED_CUR RLIM_SAVED_CUR
#define RLIM64_SAVED_MAX RLIM_SAVED_MAX
#define alphasort64 alphasort
#define blkcnt64_t blkcnt_t
#define dirent64 dirent
#define flock64 flock
#define fsfilcnt64_t fsfilcnt_t
#define fstat64 fstat
#define fstatat64 fstatat
#define fstatfs64 fstatfs
#define fstatvfs64 fstatvfs
#define getrlimit64 getrlimit
#define ino64_t ino_t
#define lockf64 lockf
#define lstat64 lstat
#define mmap64 mmap
#define off64_t off_t
#define open64 open
#define openat64 openat
#define posix_fadvise64 posix_fadvise
#define posix_fallocate64 posix_fallocate
#define readdir64 readdir
#define readdir64_r readdir_r
#define rlim64_t rlim_t
#define rlimit64 rlimit
#define scandir64 scandir
#define sendfile64 sendfile
#define setrlimit64 setrlimit
#define stat64 stat
#define statfs64 statfs
#define statvfs64 statvfs
#define versionsort64 versionsort
#endif
/*!BEGIN libc/elf/def.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_DEF_H_
/**
* @fileoverview Executable and Linkable Format Definitions.
*/
#define EI_NIDENT 16
#define EI_MAG0 0
#define EI_MAG1 1
#define EI_MAG2 2
#define EI_MAG3 3
#define ELFMAG "\177ELF"
#define ELFMAG0 0x7f
#define ELFMAG1 'E'
#define ELFMAG2 'L'
#define ELFMAG3 'F'
#define SELFMAG 4
#define EI_CLASS 4
#define ELFCLASSNONE 0
#define ELFCLASS32 1
#define ELFCLASS64 2
#define ELFCLASSNUM 3
#define EI_DATA 5
#define ELFDATANONE 0
#define ELFDATA2LSB 1
#define ELFDATA2MSB 2
#define ELFDATANUM 3
#define EI_VERSION 6
#define EI_OSABI 7
#define ELFOSABI_NONE 0
#define ELFOSABI_SYSV 0
#define ELFOSABI_HPUX 1
#define ELFOSABI_NETBSD 2
#define ELFOSABI_LINUX 3
#define ELFOSABI_GNU 3
#define ELFOSABI_SOLARIS 6
#define ELFOSABI_AIX 7
#define ELFOSABI_IRIX 8
#define ELFOSABI_FREEBSD 9
#define ELFOSABI_TRU64 10
#define ELFOSABI_MODESTO 11
#define ELFOSABI_OPENBSD 12
#define ELFOSABI_ARM 97
#define ELFOSABI_STANDALONE 255
#define EI_ABIVERSION 8
#define EI_PAD 9
#define ET_NONE 0
#define ET_REL 1
#define ET_EXEC 2
#define ET_DYN 3
#define ET_CORE 4
#define ET_NUM 5
#define ET_LOOS 0xfe00
#define ET_HIOS 0xfeff
#define ET_LOPROC 0xff00
#define ET_HIPROC 0xffff
#define EM_NONE 0
#define EM_M32 1
#define EM_386 3
#define EM_PPC64 21
#define EM_S390 22
#define EM_ARM 40
#define EM_NEXGEN32E 62
#define EM_X86_64 EM_NEXGEN32E
#define EM_IA32E EM_NEXGEN32E
#define EM_AMD64 EM_NEXGEN32E
#define EM_PDP11 65
#define EM_CRAYNV2 172
#define EM_L10M 180
#define EM_K10M 181
#define EM_AARCH64 183
#define EM_CUDA 190
#define EM_Z80 220
#define EM_RISCV 243
#define EM_BPF 247
/* the ape flag, "lol cat 5" */
#define EF_APE_MODERN 0x101ca75
#define EF_APE_MODERN_MASK 0x1ffffff
#define GRP_COMDAT 1
#define STN_UNDEF 0
#define EV_NONE 0
#define EV_CURRENT 1
#define EV_NUM 2
#define SYMINFO_NONE 0
#define SYMINFO_CURRENT 1
#define SYMINFO_NUM 2
#define SYMINFO_BT_SELF 0xffff
#define SYMINFO_BT_PARENT 0xfffe
#define SYMINFO_BT_LOWRESERVE 0xff00
#define SYMINFO_FLG_DIRECT 0x0001
#define SYMINFO_FLG_PASSTHRU 0x0002
#define SYMINFO_FLG_COPY 0x0004
#define SYMINFO_FLG_LAZYLOAD 0x0008
#define PT_NULL 0
#define PT_LOAD 1
#define PT_DYNAMIC 2
#define PT_INTERP 3
#define PT_NOTE 4
#define PT_SHLIB 5
#define PT_PHDR 6
#define PT_TLS 7
#define PT_NUM 8
#define PT_LOOS 0x60000000
#define PT_GNU_EH_FRAME 0x6474e550
#define PT_GNU_STACK 0x6474e551
#define PT_GNU_RELRO 0x6474e552
#define PT_LOSUNW 0x6ffffffa
#define PT_SUNWBSS 0x6ffffffa
#define PT_SUNWSTACK 0x6ffffffb
#define PT_HISUNW 0x6fffffff
#define PT_HIOS 0x6fffffff
#define PT_LOPROC 0x70000000
#define PT_HIPROC 0x7fffffff
#define PN_XNUM 0xffff
#define PF_X 1
#define PF_W 2
#define PF_R 4
#define PF_MASKOS 0x0ff00000
#define PF_MASKPROC 0xf0000000
#define R_X86_64_NONE 0
#define R_X86_64_64 1
#define R_X86_64_PC32 2
#define R_X86_64_GOT32 3
#define R_X86_64_PLT32 4
#define R_X86_64_COPY 5
#define R_X86_64_GLOB_DAT 6
#define R_X86_64_JUMP_SLOT 7
#define R_X86_64_RELATIVE 8
#define R_X86_64_GOTPCREL 9
#define R_X86_64_32 10
#define R_X86_64_32S 11
#define R_X86_64_16 12
#define R_X86_64_PC16 13
#define R_X86_64_8 14
#define R_X86_64_PC8 15
#define R_X86_64_DTPMOD64 16
#define R_X86_64_DTPOFF64 17
#define R_X86_64_TPOFF64 18
#define R_X86_64_TLSGD 19
#define R_X86_64_TLSLD 20
#define R_X86_64_DTPOFF32 21
#define R_X86_64_GOTTPOFF 22
#define R_X86_64_TPOFF32 23
#define R_X86_64_PC64 24
#define R_X86_64_GOTOFF64 25
#define R_X86_64_GOTPC32 26
#define R_X86_64_GOT64 27
#define R_X86_64_GOTPCREL64 28
#define R_X86_64_GOTPC64 29
#define R_X86_64_GOTPLT64 30
#define R_X86_64_PLTOFF64 31
#define R_X86_64_SIZE32 32
#define R_X86_64_SIZE64 33
#define R_X86_64_GOTPC32_TLSDESC 34
#define R_X86_64_TLSDESC_CALL 35
#define R_X86_64_TLSDESC 36
#define R_X86_64_IRELATIVE 37
#define R_X86_64_RELATIVE64 38
#define R_X86_64_GOTPCRELX 41 /* 6 bytes */
#define R_X86_64_REX_GOTPCRELX 42 /* 7 bytes */
#define R_X86_64_NUM 43
#define R_AARCH64_NONE 0
#define R_AARCH64_ABS64 257
#define R_AARCH64_ABS32 258
#define R_AARCH64_ABS16 259
#define R_AARCH64_PREL64 260
#define R_AARCH64_PREL32 261
#define R_AARCH64_PREL16 262
#define R_PPC_NONE 0
#define R_PPC_ADDR32 1
#define R_PPC_ADDR24 2
#define R_PPC_ADDR16 3
#define R_PPC_REL32 26
#define R_PPC64_NONE R_PPC_NONE
#define R_PPC64_ADDR32 R_PPC_ADDR32
#define R_PPC64_ADDR24 R_PPC_ADDR24
#define R_PPC64_ADDR16 R_PPC_ADDR16
#define R_PPC64_REL32 R_PPC_REL32
#define R_RISCV_NONE 0
#define R_RISCV_32 1
#define R_RISCV_64 2
#define R_RISCV_RELATIVE 3
#define R_390_NONE 0
#define R_390_8 1
#define R_390_12 2
#define R_390_16 3
#define R_390_32 4
#define R_390_PC32 5
#define STB_LOCAL 0
#define STB_GLOBAL 1
#define STB_WEAK 2
#define STB_NUM 3
#define STB_LOOS 10
#define STB_GNU_UNIQUE 10
#define STB_HIOS 12
#define STB_LOPROC 13
#define STB_HIPROC 15
#define STT_NOTYPE 0
#define STT_OBJECT 1
#define STT_FUNC 2
#define STT_SECTION 3
#define STT_FILE 4
#define STT_COMMON 5
#define STT_TLS 6
#define STT_NUM 7
#define STT_LOOS 10
#define STT_GNU_IFUNC 10
#define STT_HIOS 12
#define STT_LOPROC 13
#define STT_HIPROC 15
#define STV_DEFAULT 0
#define STV_INTERNAL 1
#define STV_HIDDEN 2
#define STV_PROTECTED 3
#define SHN_UNDEF 0
#define SHN_LORESERVE 0xff00
#define SHN_LOPROC 0xff00
#define SHN_BEFORE 0xff00
#define SHN_AFTER 0xff01
#define SHN_HIPROC 0xff1f
#define SHN_LOOS 0xff20
#define SHN_HIOS 0xff3f
#define SHN_ABS 0xfff1
#define SHN_COMMON 0xfff2
#define SHN_XINDEX 0xffff
#define SHN_HIRESERVE 0xffff
#define SHF_WRITE (1 << 0)
#define SHF_ALLOC (1 << 1)
#define SHF_EXECINSTR (1 << 2)
#define SHF_MERGE (1 << 4)
#define SHF_STRINGS (1 << 5)
#define SHF_INFO_LINK (1 << 6)
#define SHF_LINK_ORDER (1 << 7)
#define SHF_OS_NONCONFORMING (1 << 8)
#define SHF_GROUP (1 << 9)
#define SHF_TLS (1 << 10)
#define SHF_COMPRESSED (1 << 11)
#define SHF_MASKOS 0x0ff00000
#define SHF_MASKPROC 0xf0000000
#define SHF_ORDERED (1 << 30)
#define SHF_EXCLUDE (1U << 31)
#define ELFCOMPRESS_ZLIB 1
#define ELFCOMPRESS_LOOS 0x60000000
#define ELFCOMPRESS_HIOS 0x6fffffff
#define ELFCOMPRESS_LOPROC 0x70000000
#define ELFCOMPRESS_HIPROC 0x7fffffff
#define SHT_NULL 0
#define SHT_PROGBITS 1
#define SHT_SYMTAB 2
#define SHT_STRTAB 3
#define SHT_RELA 4
#define SHT_HASH 5
#define SHT_DYNAMIC 6
#define SHT_NOTE 7
#define SHT_NOBITS 8
#define SHT_REL 9
#define SHT_SHLIB 10
#define SHT_DYNSYM 11
#define SHT_INIT_ARRAY 14
#define SHT_FINI_ARRAY 15
#define SHT_PREINIT_ARRAY 16
#define SHT_GROUP 17
#define SHT_SYMTAB_SHNDX 18
#define SHT_NUM 19
#define SHT_LOOS 0x60000000
#define SHT_GNU_ATTRIBUTES 0x6ffffff5
#define SHT_GNU_HASH 0x6ffffff6
#define SHT_GNU_LIBLIST 0x6ffffff7
#define SHT_CHECKSUM 0x6ffffff8
#define SHT_LOSUNW 0x6ffffffa
#define SHT_SUNW_move 0x6ffffffa
#define SHT_SUNW_COMDAT 0x6ffffffb
#define SHT_SUNW_syminfo 0x6ffffffc
#define SHT_GNU_verdef 0x6ffffffd
#define SHT_GNU_verneed 0x6ffffffe
#define SHT_GNU_versym 0x6fffffff
#define SHT_HISUNW 0x6fffffff
#define SHT_HIOS 0x6fffffff
#define SHT_LOPROC 0x70000000
#define SHT_HIPROC 0x7fffffff
#define SHT_LOUSER 0x80000000
#define SHT_HIUSER 0x8fffffff
#define DT_NULL 0
#define DT_NEEDED 1
#define DT_PLTRELSZ 2
#define DT_PLTGOT 3
#define DT_HASH 4
#define DT_STRTAB 5
#define DT_SYMTAB 6
#define DT_RELA 7
#define DT_RELASZ 8
#define DT_RELAENT 9
#define DT_STRSZ 10
#define DT_SYMENT 11
#define DT_INIT 12
#define DT_FINI 13
#define DT_SONAME 14
#define DT_RPATH 15
#define DT_SYMBOLIC 16
#define DT_REL 17
#define DT_RELSZ 18
#define DT_RELENT 19
#define DT_PLTREL 20
#define DT_DEBUG 21
#define DT_TEXTREL 22
#define DT_JMPREL 23
#define DT_BIND_NOW 24
#define DT_INIT_ARRAY 25
#define DT_FINI_ARRAY 26
#define DT_INIT_ARRAYSZ 27
#define DT_FINI_ARRAYSZ 28
#define DT_RUNPATH 29
#define DT_FLAGS 30
#define DT_ENCODING 32
#define DT_PREINIT_ARRAY 32
#define DT_PREINIT_ARRAYSZ 33
#define DT_SYMTAB_SHNDX 34
#define DT_NUM 35
#define DT_LOOS 0x6000000d
#define DT_HIOS 0x6ffff000
#define DT_LOPROC 0x70000000
#define DT_HIPROC 0x7fffffff
#define DT_VALRNGLO 0x6ffffd00
#define DT_GNU_PRELINKED 0x6ffffdf5
#define DT_GNU_CONFLICTSZ 0x6ffffdf6
#define DT_GNU_LIBLISTSZ 0x6ffffdf7
#define DT_CHECKSUM 0x6ffffdf8
#define DT_PLTPADSZ 0x6ffffdf9
#define DT_MOVEENT 0x6ffffdfa
#define DT_MOVESZ 0x6ffffdfb
#define DT_FEATURE_1 0x6ffffdfc
#define DT_POSFLAG_1 0x6ffffdfd
#define DT_SYMINSZ 0x6ffffdfe
#define DT_SYMINENT 0x6ffffdff
#define DT_VALRNGHI 0x6ffffdff
#define DT_VALTAGIDX(tag) (DT_VALRNGHI - (tag))
#define DT_VALNUM 12
#define DT_ADDRRNGLO 0x6ffffe00
#define DT_GNU_HASH 0x6ffffef5
#define DT_TLSDESC_PLT 0x6ffffef6
#define DT_TLSDESC_GOT 0x6ffffef7
#define DT_GNU_CONFLICT 0x6ffffef8
#define DT_GNU_LIBLIST 0x6ffffef9
#define DT_CONFIG 0x6ffffefa
#define DT_DEPAUDIT 0x6ffffefb
#define DT_AUDIT 0x6ffffefc
#define DT_PLTPAD 0x6ffffefd
#define DT_MOVETAB 0x6ffffefe
#define DT_SYMINFO 0x6ffffeff
#define DT_ADDRRNGHI 0x6ffffeff
#define DT_ADDRTAGIDX(tag) (DT_ADDRRNGHI - (tag))
#define DT_ADDRNUM 11
#define DT_VERSYM 0x6ffffff0
#define DT_RELACOUNT 0x6ffffff9
#define DT_RELCOUNT 0x6ffffffa
#define DT_FLAGS_1 0x6ffffffb
#define DT_VERDEF 0x6ffffffc
#define DT_VERDEFNUM 0x6ffffffd
#define DT_VERNEED 0x6ffffffe
#define DT_VERNEEDNUM 0x6fffffff
#define DT_VERSIONTAGIDX(tag) (DT_VERNEEDNUM - (tag))
#define DT_VERSIONTAGNUM 16
#define DT_AUXILIARY 0x7ffffffd
#define DT_FILTER 0x7fffffff
#define DT_EXTRATAGIDX(tag) ((Elf32_Word) - ((Elf32_Sword)(tag) << 1 >> 1) - 1)
#define DT_EXTRANUM 3
#define VER_NEED_NONE 0
#define VER_NEED_CURRENT 1
#define VER_NEED_NUM 2
#define VER_FLG_WEAK 0x2
#define ELF_NOTE_SOLARIS "SUNW Solaris"
#define ELF_NOTE_GNU "GNU"
#define ELF_NOTE_PAGESIZE_HINT 1
#define ELF_NOTE_ABI NT_GNU_ABI_TAG
#define ELF_NOTE_OS_LINUX 0
#define ELF_NOTE_OS_GNU 1
#define ELF_NOTE_OS_SOLARIS2 2
#define ELF_NOTE_OS_FREEBSD 3
#define NT_GNU_ABI_TAG 1
#define NT_GNU_BUILD_ID 3
#define NT_GNU_GOLD_VERSION 4
#define EF_CPU32 0x00810000
#define DF_ORIGIN 0x00000001
#define DF_SYMBOLIC 0x00000002
#define DF_TEXTREL 0x00000004
#define DF_BIND_NOW 0x00000008
#define DF_STATIC_TLS 0x00000010
#define DF_1_NOW 0x00000001
#define DF_1_GLOBAL 0x00000002
#define DF_1_GROUP 0x00000004
#define DF_1_NODELETE 0x00000008
#define DF_1_LOADFLTR 0x00000010
#define DF_1_INITFIRST 0x00000020
#define DF_1_NOOPEN 0x00000040
#define DF_1_ORIGIN 0x00000080
#define DF_1_DIRECT 0x00000100
#define DF_1_TRANS 0x00000200
#define DF_1_INTERPOSE 0x00000400
#define DF_1_NODEFLIB 0x00000800
#define DF_1_NODUMP 0x00001000
#define DF_1_CONFALT 0x00002000
#define DF_1_ENDFILTEE 0x00004000
#define DF_1_DISPRELDNE 0x00008000
#define DF_1_DISPRELPND 0x00010000
#define DF_1_NODIRECT 0x00020000
#define DF_1_IGNMULDEF 0x00040000
#define DF_1_NOKSYMS 0x00080000
#define DF_1_NOHDR 0x00100000
#define DF_1_EDITED 0x00200000
#define DF_1_NORELOC 0x00400000
#define DF_1_SYMINTPOSE 0x00800000
#define DF_1_GLOBAUDIT 0x01000000
#define DF_1_SINGLETON 0x02000000
#define DF_1_STUB 0x04000000
#define DF_1_PIE 0x08000000
#define DTF_1_PARINIT 0x00000001
#define DTF_1_CONFEXP 0x00000002
#define DF_P1_LAZYLOAD 0x00000001
#define DF_P1_GROUPPERM 0x00000002
#define ELF64_ST_BIND(val) (((unsigned char)(val)) >> 4)
#define ELF64_ST_TYPE(val) ((val)&0xf)
#define ELF64_ST_INFO(bind, type) (((bind) << 4) + ((type)&0xf))
#define ELF64_ST_VISIBILITY(o) ((o)&0x03)
#define ELF64_R_SYM(i) ((i) >> 32)
#define ELF64_R_TYPE(i) ((i)&0xffffffff)
#define ELF64_R_INFO(sym, type) ((((Elf64_Xword)(sym)) << 32) + (type))
#define ELF64_M_SYM(info) ((info) >> 8)
#define ELF64_M_SIZE(info) ((unsigned char)(info))
#define ELF64_M_INFO(sym, size) (((sym) << 8) + (unsigned char)(size))
#define NT_PRSTATUS 1
#define NT_PRFPREG 2
#define NT_FPREGSET 2
#define NT_PRPSINFO 3
#define NT_PRXREG 4
#define NT_TASKSTRUCT 4
#define NT_PLATFORM 5
#define NT_AUXV 6
#define NT_GWINDOWS 7
#define NT_ASRS 8
#define NT_PSTATUS 10
#define NT_PSINFO 13
#define NT_PRCRED 14
#define NT_UTSNAME 15
#define NT_LWPSTATUS 16
#define NT_LWPSINFO 17
#define NT_PRFPXREG 20
#define NT_SIGINFO 0x53494749
#define NT_FILE 0x46494c45
#define NT_PRXFPREG 0x46e62b7f
#define NT_PPC_VMX 0x100
#define NT_PPC_SPE 0x101
#define NT_PPC_VSX 0x102
#define NT_PPC_TAR 0x103
#define NT_PPC_PPR 0x104
#define NT_PPC_DSCR 0x105
#define NT_PPC_EBB 0x106
#define NT_PPC_PMU 0x107
#define NT_PPC_TM_CGPR 0x108
#define NT_PPC_TM_CFPR 0x109
#define NT_PPC_TM_CVMX 0x10a
#define NT_PPC_TM_CVSX 0x10b
#define NT_PPC_TM_SPR 0x10c
#define NT_PPC_TM_CTAR 0x10d
#define NT_PPC_TM_CPPR 0x10e
#define NT_PPC_TM_CDSCR 0x10f
#define NT_X86_XSTATE 0x202
#define NT_S390_HIGH_GPRS 0x300
#define NT_S390_TIMER 0x301
#define NT_S390_TODCMP 0x302
#define NT_S390_TODPREG 0x303
#define NT_S390_CTRS 0x304
#define NT_S390_PREFIX 0x305
#define NT_S390_LAST_BREAK 0x306
#define NT_S390_SYSTEM_CALL 0x307
#define NT_S390_TDB 0x308
#define NT_S390_VXRS_LOW 0x309
#define NT_S390_VXRS_HIGH 0x30a
#define NT_S390_GS_CB 0x30b
#define NT_S390_GS_BC 0x30c
#define NT_S390_RI_CB 0x30d
#define NT_ARM_VFP 0x400
#define NT_ARM_TLS 0x401
#define NT_ARM_HW_BREAK 0x402
#define NT_ARM_HW_WATCH 0x403
#define NT_ARM_SYSTEM_CALL 0x404
#define NT_ARM_SVE 0x405
#define NT_ARM_PAC_MASK 0x406
#define NT_METAG_CBUF 0x500
#define NT_METAG_RPIPE 0x501
#define NT_METAG_TLS 0x502
#define NT_ARC_V2 0x600
#define NT_VMCOREDD 0x700
#define NT_VERSION 1
#define VER_DEF_NONE 0
#define VER_DEF_CURRENT 1
#define VER_DEF_NUM 2
#define VER_FLG_BASE 0x1
#define VER_FLG_WEAK 0x2
#define VER_NDX_LOCAL 0
#define VER_NDX_GLOBAL 1
#define VER_NDX_LORESERVE 0xff00
#define VER_NDX_ELIMINATE 0xff01
#define LL_NONE 0
#define LL_EXACT_MATCH (1 << 0)
#define LL_IGNORE_INT_VER (1 << 1)
#define LL_REQUIRE_MINOR (1 << 2)
#define LL_EXPORTS (1 << 3)
#define LL_DELAY_LOAD (1 << 4)
#define LL_DELTA (1 << 5)
#define R_BPF_NONE 0
#define R_BPF_MAP_FD 1
/*!BEGIN libc/elf/elf.h */
#define COSMOPOLITAN_LIBC_ELF_H_
/*!BEGIN libc/elf/struct/ehdr.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_EHDR_H_
/*!BEGIN libc/elf/scalar.h */
#define COSMOPOLITAN_LIBC_ELF_SCALAR_H_
#define Elf64_Addr uint64_t
#define Elf64_Half uint16_t
#define Elf64_Off uint64_t
#define Elf64_Section uint16_t
#define Elf64_Sword int32_t
#define Elf64_Sxword int64_t
#define Elf64_Versym Elf64_Half
#define Elf64_Word uint32_t
#define Elf64_Xword uint64_t
#define Elf_Symndx uint32_t
/*
* ELF header.
*/
typedef struct Elf64_Ehdr {
/*
* Leading bytes of ELF header.
*
* - `e_ident[0]` is always `127`
* - `e_ident[1]` is always `'E'`
* - `e_ident[2]` is always `'L'`
* - `e_ident[3]` is always `'F'`
*
* - `e_ident[EI_CLASS]` is mandatory and should be:
*
* - `ELFCLASSNONE64` if it's an Elf64 image
* - `ELFCLASSNONE32` if it's an Elf32 image
* - Otherwise we assume it's an Elf64 image
*
* - `e_ident[EI_DATA]` is advisory and could be:
*
* - `ELFDATANONE` isn't strictly valid
* - `ELFDATA2LSB` for little-endian
* - `ELFDATA2MSB` for big-endian
*
* - `e_ident[EI_VERSION]` is advisory and should be:
*
* - `EV_NONE` if it's zero or unspecified
* - `EV_CURRENT` for current ELF version (which is 1)
*
* - `e_ident[EI_OSABI]` is mandatory and could be:
*
* - `ELFOSABI_NONE` is zero
* - `ELFOSABI_GNU` is for GNU
* - `ELFOSABI_SYSV` used by GNU
* - `ELFOSABI_LINUX` doesn't care
* - `ELFOSABI_FREEBSD` does care (recommended)
* - `ELFOSABI_NETBSD` doesn't care (see `PT_NOTE`)
* - `ELFOSABI_OPENBSD` doesn't care (see `PT_NOTE`)
*
* - `e_ident[EI_ABIVERSION]` is advisory
*
*/
unsigned char e_ident[16];
/*
* ELF image type.
*
* This field is mandatory and should be one of:
*
* - `ET_REL` for `.o` object files
* - `ET_DYN` for `.so` files and `-pie` executables
* - `ET_EXEC` for statically-linked executables
*
*/
Elf64_Half e_type;
/*
* ELF machine type.
*
* This field is mandatory and could be one of:
*
* - `EM_M32` for Bellmac
* - `EM_X86_64` for Amd64
* - `EM_AARCH64` for Arm64
* - `EM_PPC64` for Raptors
* - `EM_RISCV` for Berkeley
* - `EM_S390` for System/360
*
*/
Elf64_Half e_machine;
/*
* ELF version.
*
* This field is advisory and could be:
*
* - `EV_NONE` if it's zero or unspecified
* - `EV_CURRENT` for current ELF version (which is 1)
*
* @see `e_ident[EI_VERSION]`
*/
Elf64_Word e_version;
/*
* ELF executable entrypoint.
*
* Static executables should use this field to store the virtual
* address of the _start() function. This field may be zero, for
* unspecified.
*/
Elf64_Addr e_entry;
/*
* `Elf64_Phdr` file offset.
*
* This field is mandatory. Object files should set it to zero.
*/
Elf64_Off e_phoff;
/*
* `Elf64_Shdr` file offset.
*
* This field is advisory.
*/
Elf64_Off e_shoff;
/*
* ELF flags.
*
* This field is advisory.
*/
Elf64_Word e_flags;
/*
* `Elf64_Ehdr` size.
*
* This field is advisory and should be 64.
*/
Elf64_Half e_ehsize;
/*
* `Elf64_Phdr` element size.
*
* This field *is* cared about and should be set to 56. Cosmopolitan
* permits larger values for the pleasure of it.
*/
Elf64_Half e_phentsize;
/*
* `Elf64_Phdr` array count.
*/
Elf64_Half e_phnum;
/*
* `Elf64_Shdr` element size.
*
* This field is advisory and should be set to 64. Cosmopolitan
* permits larger values for the pleasure of it.
*/
Elf64_Half e_shentsize;
/*
* `Elf64_Shdr` count.
*
* This field is advisory.
*/
Elf64_Half e_shnum;
/*
* Section header index of section name string table.
*/
Elf64_Half e_shstrndx;
} Elf64_Ehdr;
/*!BEGIN libc/elf/struct/phdr.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_PHDR_H_
typedef struct Elf64_Phdr {
Elf64_Word p_type;
Elf64_Word p_flags;
Elf64_Off p_offset;
Elf64_Addr p_vaddr;
Elf64_Addr p_paddr;
Elf64_Xword p_filesz;
Elf64_Xword p_memsz;
Elf64_Xword p_align;
} Elf64_Phdr;
/*!BEGIN libc/elf/struct/shdr.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_SHDR_H_
/**
* Section header.
* @see https://docs.oracle.com/cd/E19683-01/816-1386/chapter6-94076/index.html
*/
typedef struct Elf64_Shdr {
Elf64_Word sh_name;
Elf64_Word sh_type; /* SHT_{PROGBITS,NOBITS,STRTAB,SYMTAB,RELA,...} */
Elf64_Xword sh_flags; /* SHF_{WRITE,ALLOC,EXECINSTR,TLS,MERGE,STRINGS,,...} */
Elf64_Addr sh_addr;
Elf64_Off sh_offset;
Elf64_Xword sh_size;
/*
* Index of linked section header.
*
* If `sh_type` is `SHT_RELA` then `sh_link` holds the section header
* index of the associated symbol table.
*
* If `sh_type` is `SHT_SYMTAB` then `sh_link` holds the section
* header index of the associated string table.
*/
Elf64_Word sh_link;
/*
* If `sh_type` is `SHT_RELA` then `sh_info` contains the index of the
* section to which relocations apply.
*
* If `sh_type` is `SHT_SYMTAB` or `SHT_DYNSYM` then `sh_info`
* contains an index that's one greater than symbol table index of
* last `STB_LOCAL` symbol.
*/
Elf64_Word sh_info;
Elf64_Xword sh_addralign;
Elf64_Xword sh_entsize;
} Elf64_Shdr;
/*!BEGIN libc/elf/struct/sym.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_SYM_H_
typedef struct Elf64_Sym {
/*
* Symbol name.
*
* This value is a byte offset into the `.strtab` section. If this
* value is zero, then the symbol has no name.
*/
Elf64_Word st_name;
/*
* Symbol type and binding.
*
* This value may be created using:
*
* sym.st_info = ELF64_ST_INFO(bind, type);
*
* This value may be read using:
*
* int bind = ELF64_ST_BIND(sym.st_info);
* int type = ELF64_ST_TYPE(sym.st_info);
*
* Where `bind` is typically:
*
* - `STB_LOCAL`
* - `STB_GLOBAL`
* - `STB_WEAK`
*
* Where `type` is typically:
*
* - `STT_NOTYPE`
* - `STT_OBJECT`
* - `STT_FUNC`
* - `STT_SECTION`
* - `STT_FILE`
* - `STT_COMMON`
* - `STT_TLS`
*/
uint8_t st_info;
/*
* Symbol visibility.
*
* This value should be accessed using:
*
* int visibility = ELF64_ST_VISIBILITY(sym.st_other);
*
* Where `visibility` is typically:
*
* - `STV_DEFAULT`
* - `STV_INTERNAL`
* - `STV_HIDDEN`
* - `STV_PROTECTED`
*/
uint8_t st_other;
/*
* Symbol section.
*
* If `st_shndx` is within `(SHN_UNDEF,SHN_LORESERVE)` then it holds
* an index into the section header table.
*
* Otherwise `st_shndx` is usually one of the following magic numbers:
*
* - `SHN_UNDEF` means symbol is undefined
* - `SHN_ABS` means symbol is a linker integer
* - `SHN_COMMON` means symbol is defined traditionally
*/
Elf64_Section st_shndx;
/*
* Symbol value.
*
* If `e_type` is `ET_REL` and `st_shndx` is `SHN_COMMON`, then
* `st_value` holds the required symbol alignment, or ≤ 1 if no
* alignment is required.
*
* If `e_type` is `ET_REL` and `st_shndx` is a section index, then
* `st_value` holds a byte offset into the section memory.
*
* If `e_type` isn't `ET_REL` then `st_value` holds a virtual address.
*/
Elf64_Addr st_value;
/* byte length optionally set by .size directive */
Elf64_Xword st_size;
} Elf64_Sym;
#ifdef _COSMO_SOURCE
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § executable linkable format ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
/* clang-format off */
bool32 IsElfSymbolContent(const Elf64_Sym *);
bool32 IsElf64Binary(const Elf64_Ehdr *, size_t);
char *GetElfStringTable(const Elf64_Ehdr *, size_t, const char *);
Elf64_Sym *GetElfSymbols(const Elf64_Ehdr *, size_t, int, Elf64_Xword *);
Elf64_Shdr *GetElfSymbolTable(const Elf64_Ehdr *, size_t, int, Elf64_Xword *);
Elf64_Phdr *GetElfProgramHeaderAddress(const Elf64_Ehdr *, size_t, Elf64_Half);
Elf64_Shdr *GetElfSectionHeaderAddress(const Elf64_Ehdr *, size_t, Elf64_Half);
Elf64_Shdr *FindElfSectionByName(const Elf64_Ehdr *, size_t, char *, const char *);
char *GetElfString(const Elf64_Ehdr *, size_t, const char *, Elf64_Word);
void *GetElfSectionAddress(const Elf64_Ehdr *, size_t, const Elf64_Shdr *);
void *GetElfSegmentAddress(const Elf64_Ehdr *, size_t, const Elf64_Phdr *);
char *GetElfSectionName(const Elf64_Ehdr *, size_t, const Elf64_Shdr *);
char *GetElfSectionNameStringTable(const Elf64_Ehdr *, size_t);
COSMOPOLITAN_C_END_
#endif /* _COSMO_SOURCE */
/* clang-format on */
/*!BEGIN libc/elf/link.h */
#define COSMOPOLITAN_ELF_LINK_H_
/*!BEGIN libc/elf/struct/dyn.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_DYN_H_
typedef struct Elf64_Dyn {
Elf64_Sxword d_tag;
union {
Elf64_Xword d_val;
Elf64_Addr d_ptr;
} d_un;
} Elf64_Dyn;
COSMOPOLITAN_C_START_
#define ElfW(type) Elf64_##type
struct dl_phdr_info {
Elf64_Addr dlpi_addr;
const char *dlpi_name;
const Elf64_Phdr *dlpi_phdr;
Elf64_Half dlpi_phnum;
unsigned long long int dlpi_adds;
unsigned long long int dlpi_subs;
size_t dlpi_tls_modid;
void *dlpi_tls_data;
};
struct link_map {
Elf64_Addr l_addr;
char *l_name;
Elf64_Dyn *l_ld;
struct link_map *l_next;
struct link_map *l_prev;
};
struct r_debug {
int r_version;
struct link_map *r_map;
Elf64_Addr r_brk;
enum { RT_CONSISTENT, RT_ADD, RT_DELETE } r_state;
Elf64_Addr r_ldbase;
};
int dl_iterate_phdr(int (*)(struct dl_phdr_info *, size_t, void *), void *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/elf/struct/auxv.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_AUXV_H_
typedef struct Elf64_auxv_t {
uint64_t a_type;
union {
uint64_t a_val;
} a_un;
} Elf64_auxv_t;
/*!BEGIN libc/elf/struct/chdr.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_CHDR_H_
typedef struct Elf64_Chdr {
Elf64_Word ch_type;
Elf64_Word ch_reserved;
Elf64_Xword ch_size;
Elf64_Xword ch_addralign;
} Elf64_Chdr;
/*!BEGIN libc/elf/struct/lib.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_LIB_H_
typedef struct Elf64_Lib {
Elf64_Word l_name;
Elf64_Word l_time_stamp;
Elf64_Word l_checksum;
Elf64_Word l_version;
Elf64_Word l_flags;
} Elf64_Lib;
/*!BEGIN libc/elf/struct/move.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_MOVE_H_
typedef struct Elf64_Move {
Elf64_Xword m_value;
Elf64_Xword m_info;
Elf64_Xword m_poffset;
Elf64_Half m_repeat;
Elf64_Half m_stride;
} Elf64_Move;
/*!BEGIN libc/elf/struct/nhdr.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_NHDR_H_
typedef struct Elf64_Nhdr {
Elf64_Word n_namesz;
Elf64_Word n_descsz;
Elf64_Word n_type;
} Elf64_Nhdr;
/*!BEGIN libc/elf/struct/rel.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_REL_H_
/*
* ELF relocation.
*
* Relocations let us easily apply fixups to compiled object code. This
* data structure represents the contents of an `sh_type` w/ `SHT_REL`.
*
* @see Elf64_Rela
*/
typedef struct Elf64_Rel {
/*
* Location to be modified.
*
* If `e_type` is `ET_REL` then this is a section data byte offset.
*
* If `e_type` isn't `ET_REL` then this is a virtual address.
*/
Elf64_Addr r_offset;
/*
* Relocation type and symbol.
*
* This value may be created using:
*
* r_info = ELF64_R_INFO(sym, type);
*
* This value may be read using:
*
* Elf64_Word sym = ELF64_R_SYM(r_info);
* Elf64_Word type = ELF64_R_TYPE(r_info);
*
* Where `sym` is a symbol index, and `type` might be:
*
* - `R_X86_64_64`
* - `R_X86_64_PC32`
* - `R_X86_64_GOTPCRELX`
* - `R_AARCH64_ABS64`
*
* Each relocation type specifies a mathematical formula that's used
* to compute the appropriate value for the fixed-up object code. If
* it needs an addend, then this struct doesn't have one, but it can
* still be embedded by the compiler in the location to be modified.
*/
Elf64_Xword r_info;
} Elf64_Rel;
/*!BEGIN libc/elf/struct/rela.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_RELA_H_
/*
* ELF relocation w/ explicit addend.
*
* Relocations let us easily apply fixups to compiled object code. This
* data structure represents the contents of an `sh_type` w/ `SHT_RELA`
*
* @see Elf64_Rel
*/
typedef struct Elf64_Rela {
/*
* Location to be modified.
*
* If `e_type` is `ET_REL` then this is a section data byte offset.
*
* If `e_type` isn't `ET_REL` then this is a virtual address.
*/
Elf64_Addr r_offset;
/*
* Relocation type and symbol.
*
* This value may be created using:
*
* r_info = ELF64_R_INFO(sym, type);
*
* This value may be read using:
*
* Elf64_Word sym = ELF64_R_SYM(r_info);
* Elf64_Word type = ELF64_R_TYPE(r_info);
*
* Where `sym` is a symbol index, and `type` will likely be:
*
* - `R_X86_64_PC32`
* - `R_X86_64_PLT32`
* - `R_X86_64_32`
* - `R_X86_64_64`
* - `R_X86_64_32S`
* - `R_X86_64_8`
* - `R_X86_64_16`
* - `R_X86_64_DTPOFF32`
* - `R_X86_64_GOTPCREL`
* - `R_X86_64_PC16`
* - `R_X86_64_REX_GOTPCRELX`
* - `R_X86_64_TPOFF32`
*
*/
Elf64_Xword r_info;
/*
* Relocation parameter.
*
* Each relocation type has its own mathematical formula, which should
* incorporate this value in its own unique way.
*/
Elf64_Sxword r_addend;
} Elf64_Rela;
/*!BEGIN libc/elf/struct/syminfo.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_SYMINFO_H_
typedef struct Elf64_Syminfo {
Elf64_Half si_boundto;
Elf64_Half si_flags;
} Elf64_Syminfo;
/*!BEGIN libc/elf/struct/verdaux.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_VERDAUX_H_
typedef struct Elf64_Verdaux {
Elf64_Word vda_name;
Elf64_Word vda_next;
} Elf64_Verdaux;
/*!BEGIN libc/elf/struct/verdef.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_VERDEF_H_
typedef struct Elf64_Verdef {
Elf64_Half vd_version;
Elf64_Half vd_flags;
Elf64_Half vd_ndx;
Elf64_Half vd_cnt;
Elf64_Word vd_hash;
Elf64_Word vd_aux;
Elf64_Word vd_next;
} Elf64_Verdef;
/*!BEGIN libc/elf/struct/vernaux.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_VERNAUX_H_
typedef struct Elf64_Vernaux {
Elf64_Word vna_hash;
Elf64_Half vna_flags;
Elf64_Half vna_other;
Elf64_Word vna_name;
Elf64_Word vna_next;
} Elf64_Vernaux;
/*!BEGIN libc/elf/struct/verneed.h */
#define COSMOPOLITAN_LIBC_ELF_STRUCT_VERNEED_H_
typedef struct Elf64_Verneed {
Elf64_Half vn_version;
Elf64_Half vn_cnt;
Elf64_Word vn_file;
Elf64_Word vn_aux;
Elf64_Word vn_next;
} Elf64_Verneed;
/*!BEGIN libc/fmt/conv.h */
#define COSMOPOLITAN_LIBC_FMT_CONV_H_
COSMOPOLITAN_C_START_
int abs(int) libcesque pureconst;
long labs(long) libcesque pureconst;
long long llabs(long long) libcesque pureconst;
libcesque intmax_t imaxabs(intmax_t) pureconst;
int atoi(const char *) paramsnonnull() libcesque;
long atol(const char *) paramsnonnull() libcesque;
long long atoll(const char *) paramsnonnull() libcesque;
unsigned long strtoul(const char *, char **, int) libcesque paramsnonnull((1));
long long strtoll(const char *, char **, int) libcesque paramsnonnull((1));
unsigned long long strtoull(const char *, char **, int) paramsnonnull((1));
intmax_t strtoimax(const char *, char **, int) libcesque paramsnonnull((1));
uintmax_t strtoumax(const char *, char **, int) libcesque paramsnonnull((1));
intmax_t wcstoimax(const wchar_t *, wchar_t **, int) libcesque;
uintmax_t wcstoumax(const wchar_t *, wchar_t **, int) libcesque;
long wcstol(const wchar_t *, wchar_t **, int) libcesque;
unsigned long wcstoul(const wchar_t *, wchar_t **, int) libcesque;
long strtol(const char *, char **, int) paramsnonnull((1)) libcesque;
long sizetol(const char *, long) paramsnonnull() libcesque;
char *sizefmt(char *, uint64_t, uint64_t) libcesque;
long long wcstoll(const wchar_t *, wchar_t **, int) libcesque;
unsigned long long wcstoull(const wchar_t *, wchar_t **, int) libcesque;
int wcscoll(const wchar_t *, const wchar_t *) libcesque;
size_t wcsxfrm(wchar_t *, const wchar_t *, size_t) libcesque;
double atof(const char *) libcesque;
float strtof(const char *, char **) libcesque;
double strtod(const char *, char **) libcesque;
long double strtold(const char *, char **) libcesque;
float wcstof(const wchar_t *, wchar_t **) libcesque;
double wcstod(const wchar_t *, wchar_t **) libcesque;
long double wcstold(const wchar_t *, wchar_t **) libcesque;
#ifdef _COSMO_SOURCE
char *stripext(char *) libcesque;
char *stripexts(char *) libcesque;
#endif /* _COSMO_SOURCE */
typedef struct {
int quot;
int rem;
} div_t;
typedef struct {
long int quot;
long int rem;
} ldiv_t;
typedef struct {
long long int quot;
long long int rem;
} lldiv_t;
typedef struct {
intmax_t quot;
intmax_t rem;
} imaxdiv_t;
libcesque div_t div(int, int) pureconst;
libcesque ldiv_t ldiv(long, long) pureconst;
libcesque lldiv_t lldiv(long long, long long) pureconst;
libcesque imaxdiv_t imaxdiv(intmax_t, intmax_t) pureconst;
#if __STDC_VERSION__ + 0 >= 199901L
#define div(num, den) ((div_t){(num) / (den), (num) % (den)})
#define ldiv(num, den) ((ldiv_t){(num) / (den), (num) % (den)})
#define lldiv(num, den) ((lldiv_t){(num) / (den), (num) % (den)})
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/fmt/itoa.h */
#ifndef COSMOPOLITAN_LIBC_FMT_ITOA_H_
#define COSMOPOLITAN_LIBC_FMT_ITOA_H_
COSMOPOLITAN_C_START_
#define LengthInt64 __LengthInt64
#define LengthUint64 __LengthUint64
#define LengthInt64Thousands __LengthInt64Thousands
#define LengthUint64Thousands __LengthUint64Thousands
#define FormatInt32 __FormatInt32
#define FormatUint32 __FormatUint32
#define FormatInt64 __FormatInt64
#define FormatUint64 __FormatUint64
#define FormatInt64Thousands __FormatInt64Thousands
#define FormatUint64Thousands __FormatUint64Thousands
#define FormatOctal32 __FormatOctal32
#define FormatOctal64 __FormatOctal64
#define FormatBinary64 __FormatBinary64
#define FormatHex64 __FormatHex64
#define FormatFlex64 __FormatFlex64
#define uint64toarray_radix16 __uint64toarray_radix16
#define uint64toarray_fixed16 __uint64toarray_fixed16
#define uint64toarray_radix8 __uint64toarray_radix8
libcesque unsigned LengthInt64(int64_t) pureconst;
libcesque unsigned LengthUint64(uint64_t) pureconst;
libcesque unsigned LengthInt64Thousands(int64_t) pureconst;
libcesque unsigned LengthUint64Thousands(uint64_t) pureconst;
libcesque char *FormatInt32(char[hasatleast 12], int32_t);
libcesque char *FormatUint32(char[hasatleast 12], uint32_t);
libcesque char *FormatInt64(char[hasatleast 21], int64_t);
libcesque char *FormatUint64(char[hasatleast 21], uint64_t);
libcesque char *FormatInt64Thousands(char[hasatleast 27], int64_t);
libcesque char *FormatUint64Thousands(char[hasatleast 27], uint64_t);
libcesque char *FormatOctal32(char[hasatleast 13], uint32_t, bool32);
libcesque char *FormatOctal64(char[hasatleast 24], uint64_t, bool32);
libcesque char *FormatBinary64(char[hasatleast 67], uint64_t, char);
libcesque char *FormatHex64(char[hasatleast 19], uint64_t, char);
libcesque char *FormatFlex64(char[hasatleast 24], int64_t, char);
libcesque size_t uint64toarray_radix16(uint64_t, char[hasatleast 17]);
libcesque size_t uint64toarray_fixed16(uint64_t, char[hasatleast 17], uint8_t);
libcesque size_t uint64toarray_radix8(uint64_t, char[hasatleast 24]);
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_FMT_ITOA_H_ */
/*!BEGIN libc/fmt/leb128.h */
#ifndef COSMOPOLITAN_LIBC_FMT_LEB128_H_
#define COSMOPOLITAN_LIBC_FMT_LEB128_H_
COSMOPOLITAN_C_START_
#define sleb64 __sleb64
#define zleb64 __zleb64
#define uleb64 __uleb64
#define unzleb64 __unzleb64
#define unuleb64 __unuleb64
char *sleb64(char *, int64_t) libcesque;
char *zleb64(char[hasatleast 10], int64_t) libcesque;
char *uleb64(char[hasatleast 10], uint64_t) libcesque;
int unzleb64(const char *, size_t, int64_t *) libcesque;
int unuleb64(const char *, size_t, uint64_t *) libcesque;
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_FMT_LEB128_H_ */
/*!BEGIN libc/fmt/libgen.h */
#define COSMOPOLITAN_LIBC_FMT_LIBGEN_H_
COSMOPOLITAN_C_START_
char *dirname(char *) libcesque;
char *basename(char *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/dlopen/dlfcn.h */
#define COSMOPOLITAN_LIBC_DLFCN_H_
#define RTLD_LOCAL 0
#define RTLD_LAZY 1
#define RTLD_NOW 2
#define RTLD_GLOBAL 256
COSMOPOLITAN_C_START_
#define RTLD_NEXT ((void *)-1)
#define RTLD_DEFAULT ((void *)0)
char *dlerror(void) libcesque;
void *dlopen(const char *, int) libcesque;
void *dlsym(void *, const char *) libcesque;
int dlclose(void *) libcesque;
char *cosmo_dlerror(void) libcesque;
void *cosmo_dlopen(const char *, int) libcesque;
void *cosmo_dlsym(void *, const char *) libcesque;
void *cosmo_dltramp(void *) libcesque;
int cosmo_dlclose(void *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/asancodes.h */
#define COSMOPOLITAN_LIBC_INTRIN_ASANCODES_H_
#define kAsanScale 3
#define kAsanMagic 0x7fff8000
#define kAsanNullPage -1 /* ∅ 0xff */
#define kAsanProtected -2 /* P 0xfe */
#define kAsanHeapFree -3 /* F 0xfd */
#define kAsanHeapRelocated -4 /* R 0xfc */
#define kAsanAllocaOverrun -5 /* 𝑂 0xfb */
#define kAsanHeapUnderrun -6 /* U 0xfa */
#define kAsanHeapOverrun -7 /* O 0xf9 */
#define kAsanStackUnscoped -8 /* s 0xf8 */
#define kAsanStackOverflow -9 /* ! 0xf7 */
#define kAsanGlobalOrder -10 /* I 0xf6 */
#define kAsanStackFree -11 /* r 0xf5 */
#define kAsanStackPartial -12 /* p 0xf4 */
#define kAsanStackOverrun -13 /* o 0xf3 */
#define kAsanStackMiddle -14 /* m 0xf2 */
#define kAsanStackUnderrun -15 /* u 0xf1 */
#define kAsanAllocaUnderrun -16 /* 𝑈 0xf0 */
#define kAsanUnmapped -17 /* M 0xef */
#define kAsanGlobalRedzone -18 /* G 0xee */
#define kAsanGlobalGone -19 /* 𝐺 0xed */
#define kAsanGlobalUnderrun -20 /* μ 0xec */
#define kAsanGlobalOverrun -21 /* Ω 0xeb */
#define kAsanMmapSizeOverrun -22 /* Z 0xea */
/*!BEGIN libc/intrin/asmflag.h */
#define COSMOPOLITAN_LIBC_BITS_ASMFLAG_H_
/*
* Constraints for virtual machine flags.
* @note we beseech clang devs for flag constraints
*/
#ifdef __GCC_ASM_FLAG_OUTPUTS__ /* GCC6+ CLANG10+ */
#define CFLAG_CONSTRAINT "=@ccc"
#define CFLAG_ASM(OP) OP
#define ZFLAG_CONSTRAINT "=@ccz"
#define ZFLAG_ASM(OP) OP
#define OFLAG_CONSTRAINT "=@cco"
#define OFLAG_ASM(OP) OP
#define SFLAG_CONSTRAINT "=@ccs"
#define SFLAG_ASM(SP) SP
#define ABOVE_CONSTRAINT "=@cca" /* i.e. !ZF && !CF */
#define ABOVEFLAG_ASM(OP) OP
#else
#define CFLAG_CONSTRAINT "=q"
#define CFLAG_ASM(OP) OP "\n\tsetc\t%b0"
#define ZFLAG_CONSTRAINT "=q"
#define ZFLAG_ASM(OP) OP "\n\tsetz\t%b0"
#define OFLAG_CONSTRAINT "=q"
#define OFLAG_ASM(OP) OP "\n\tseto\t%b0"
#define SFLAG_CONSTRAINT "=q"
#define SFLAG_ASM(SP) OP "\n\tsets\t%b0"
#define ABOVE_CONSTRAINT "=@cca"
#define ABOVEFLAG_ASM(OP) OP "\n\tseta\t%b0"
#endif
/*!BEGIN libc/intrin/atomic.h */
#define COSMOPOLITAN_LIBC_BITS_ATOMIC_H_
/**
* @fileoverview Cosmopolitan C11 Atomics Library
*
* - Forty-two different ways to say MOV.
* - Fourteen different ways to say XCHG.
* - Twenty different ways to say LOCK CMPXCHG.
*
* @see libc/atomic.h
*/
typedef int memory_order;
enum {
memory_order_relaxed,
memory_order_consume,
memory_order_acquire,
memory_order_release,
memory_order_acq_rel,
memory_order_seq_cst,
};
#define ATOMIC_VAR_INIT(...) __VA_ARGS__
#define atomic_is_lock_free(obj) ((void)(obj), sizeof(obj) <= sizeof(void *))
#define atomic_flag atomic_bool
#define ATOMIC_FLAG_INIT ATOMIC_VAR_INIT(0)
#define atomic_flag_test_and_set_explicit(x, order) \
atomic_exchange_explicit(x, 1, order)
#define atomic_flag_clear_explicit(x, order) atomic_store_explicit(x, 0, order)
#define atomic_compare_exchange_strong(pObject, pExpected, desired) \
atomic_compare_exchange_strong_explicit( \
pObject, pExpected, desired, memory_order_seq_cst, memory_order_seq_cst)
#define atomic_compare_exchange_weak(pObject, pExpected, desired) \
atomic_compare_exchange_weak_explicit( \
pObject, pExpected, desired, memory_order_seq_cst, memory_order_seq_cst)
#define atomic_exchange(pObject, desired) \
atomic_exchange_explicit(pObject, desired, memory_order_seq_cst)
#define atomic_fetch_add(pObject, operand) \
atomic_fetch_add_explicit(pObject, operand, memory_order_seq_cst)
#define atomic_fetch_and(pObject, operand) \
atomic_fetch_and_explicit(pObject, operand, memory_order_seq_cst)
#define atomic_fetch_or(pObject, operand) \
atomic_fetch_or_explicit(pObject, operand, memory_order_seq_cst)
#define atomic_fetch_sub(pObject, operand) \
atomic_fetch_sub_explicit(pObject, operand, memory_order_seq_cst)
#define atomic_fetch_xor(pObject, operand) \
atomic_fetch_xor_explicit(pObject, operand, memory_order_seq_cst)
#define atomic_load(pObject) atomic_load_explicit(pObject, memory_order_seq_cst)
#define atomic_store(pObject, desired) \
atomic_store_explicit(pObject, desired, memory_order_seq_cst)
#define atomic_flag_test_and_set(x) \
atomic_flag_test_and_set_explicit(x, memory_order_seq_cst)
#define atomic_flag_clear(x) atomic_flag_clear_explicit(x, memory_order_seq_cst)
#if defined(__CLANG_ATOMIC_BOOL_LOCK_FREE)
#define atomic_init(obj, value) __c11_atomic_init(obj, value)
#define atomic_thread_fence(order) __c11_atomic_thread_fence(order)
#define atomic_signal_fence(order) __c11_atomic_signal_fence(order)
#define atomic_compare_exchange_strong_explicit(object, expected, desired, \
success, failure) \
__c11_atomic_compare_exchange_strong(object, expected, desired, success, \
failure)
#define atomic_compare_exchange_weak_explicit(object, expected, desired, \
success, failure) \
__c11_atomic_compare_exchange_weak(object, expected, desired, success, \
failure)
#define atomic_exchange_explicit(object, desired, order) \
__c11_atomic_exchange(object, desired, order)
#define atomic_fetch_add_explicit(object, operand, order) \
__c11_atomic_fetch_add(object, operand, order)
#define atomic_fetch_and_explicit(object, operand, order) \
__c11_atomic_fetch_and(object, operand, order)
#define atomic_fetch_or_explicit(object, operand, order) \
__c11_atomic_fetch_or(object, operand, order)
#define atomic_fetch_sub_explicit(object, operand, order) \
__c11_atomic_fetch_sub(object, operand, order)
#define atomic_fetch_xor_explicit(object, operand, order) \
__c11_atomic_fetch_xor(object, operand, order)
#define atomic_load_explicit(object, order) __c11_atomic_load(object, order)
#define atomic_store_explicit(object, desired, order) \
__c11_atomic_store(object, desired, order)
#elif (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 407
#define atomic_init(obj, value) ((void)(*(obj) = (value)))
#define atomic_thread_fence(order) __atomic_thread_fence(order)
#define atomic_signal_fence(order) __atomic_signal_fence(order)
#define atomic_compare_exchange_strong_explicit(pObject, pExpected, desired, \
success, failure) \
__atomic_compare_exchange_n(pObject, pExpected, desired, 0, success, failure)
#define atomic_compare_exchange_weak_explicit(pObject, pExpected, desired, \
success, failure) \
__atomic_compare_exchange_n(pObject, pExpected, desired, 1, success, failure)
#define atomic_exchange_explicit(pObject, desired, order) \
__atomic_exchange_n(pObject, desired, order)
#define atomic_fetch_add_explicit(pObject, operand, order) \
__atomic_fetch_add(pObject, operand, order)
#define atomic_fetch_and_explicit(pObject, operand, order) \
__atomic_fetch_and(pObject, operand, order)
#define atomic_fetch_or_explicit(pObject, operand, order) \
__atomic_fetch_or(pObject, operand, order)
#define atomic_fetch_sub_explicit(pObject, operand, order) \
__atomic_fetch_sub(pObject, operand, order)
#define atomic_fetch_xor_explicit(pObject, operand, order) \
__atomic_fetch_xor(pObject, operand, order)
#define atomic_load_explicit(pObject, order) __atomic_load_n(pObject, order)
#define atomic_store_explicit(pObject, desired, order) \
__atomic_store_n(pObject, desired, order)
#elif (__GNUC__ + 0) * 100 + (__GNUC_MINOR__ + 0) >= 401
#define atomic_init(obj, value) ((void)(*(obj) = (value)))
#define atomic_thread_fence(order) __sync_synchronize()
#define atomic_signal_fence(order) __asm__ volatile("" ::: "memory")
#define __atomic_apply_stride(object, operand) \
(((__typeof__(*(object)))0) + (operand))
#define atomic_compare_exchange_strong_explicit(object, expected, desired, \
success_order, failure_order) \
__extension__({ \
__typeof__(expected) __ep = (expected); \
__typeof__(*__ep) __e = *__ep; \
(void)(success_order); \
(void)(failure_order); \
(*__ep = __sync_val_compare_and_swap(object, __e, desired)) == __e; \
})
#define atomic_compare_exchange_weak_explicit(object, expected, desired, \
success_order, failure_order) \
atomic_compare_exchange_strong_explicit(object, expected, desired, \
success_order, failure_order)
#if __has_builtin(__sync_swap)
#define atomic_exchange_explicit(object, desired, order) \
((void)(order), __sync_swap(object, desired))
#else
#define atomic_exchange_explicit(object, desired, order) \
__extension__({ \
__typeof__(object) __o = (object); \
__typeof__(desired) __d = (desired); \
(void)(order); \
__sync_synchronize(); \
__sync_lock_test_and_set(__o, __d); \
})
#endif
#define atomic_fetch_add_explicit(object, operand, order) \
((void)(order), \
__sync_fetch_and_add(object, __atomic_apply_stride(object, operand)))
#define atomic_fetch_and_explicit(object, operand, order) \
((void)(order), __sync_fetch_and_and(object, operand))
#define atomic_fetch_or_explicit(object, operand, order) \
((void)(order), __sync_fetch_and_or(object, operand))
#define atomic_fetch_sub_explicit(object, operand, order) \
((void)(order), \
__sync_fetch_and_sub(object, __atomic_apply_stride(object, operand)))
#define atomic_fetch_xor_explicit(object, operand, order) \
((void)(order), __sync_fetch_and_xor(object, operand))
#define atomic_load_explicit(object, order) \
((void)(order), __sync_fetch_and_add(object, 0))
#define atomic_store_explicit(object, desired, order) \
((void)atomic_exchange_explicit(object, desired, order))
#elif defined(__GNUC__) && defined(__x86__) /* x86 with gcc 4.0 and earlier */
#define atomic_init(obj, value) ((void)(*(obj) = (value)))
#define atomic_thread_fence(order) __asm__ volatile("mfence" ::: "memory")
#define atomic_signal_fence(order) __asm__ volatile("" ::: "memory")
#define atomic_compare_exchange_strong_explicit(object, expected, desired, \
success_order, failure_order) \
__extension__({ \
char DidIt; \
__typeof__(object) IfThing = (object); \
__typeof__(IfThing) IsEqualToMe = (expected); \
__typeof__(*IfThing) ReplaceItWithMe = (desired), ax; \
(void)(success_order); \
(void)(failure_order); \
__asm__ volatile("lock cmpxchg\t%3,(%1)\n\t" \
"setz\t%b0" \
: "=q"(DidIt), "=r"(IfThing), "+a"(ax) \
: "r"(ReplaceItWithMe), "2"(*IsEqualToMe) \
: "memory", "cc"); \
*IsEqualToMe = ax; \
DidIt; \
})
#define atomic_compare_exchange_weak_explicit(object, expected, desired, \
success_order, failure_order) \
atomic_compare_exchange_strong_explicit(object, expected, desired, \
success_order, failure_order)
#define atomic_exchange_explicit(object, desired, order) \
__extension__({ \
__typeof__(object) __o = (object); \
__typeof__(*__o) __d = (desired); \
(void)(order); \
__asm__ volatile("xchg\t%0,%1" : "=r"(__d), "+m"(*__o) : "0"(__d)); \
__d; \
})
#define atomic_fetch_add_explicit(object, operand, order) \
__extension__({ \
__typeof__(object) __o = (object); \
__typeof__(*__o) __d = (desired); \
(void)(order); \
__asm__ volatile("lock xadd\t%0,%1" : "=r"(__d), "+m"(*__o) : "0"(__d)); \
__d; \
})
#define atomic_fetch_sub_explicit(object, operand, order) \
atomic_fetch_add_explicit(object, -(operand), order)
#define atomic_load_explicit(object, order) \
atomic_fetch_add_explicit(object, 0, order)
#define atomic_store_explicit(object, desired, order) \
((void)atomic_exchange_explicit(object, desired, order))
#else /* non-gcc or old gcc w/o x86 */
#error "atomic operations not supported with this compiler and/or architecture"
#endif
/*!BEGIN libc/intrin/bsf.h */
#ifndef COSMOPOLITAN_LIBC_NEXGEN32E_BSF_H_
#define COSMOPOLITAN_LIBC_NEXGEN32E_BSF_H_
COSMOPOLITAN_C_START_
libcesque int bsf(int) pureconst;
libcesque int bsfl(long) pureconst;
libcesque int bsfll(long long) pureconst;
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define bsf(x) __builtin_ctz(x)
#define bsfl(x) __builtin_ctzl(x)
#define bsfll(x) __builtin_ctzll(x)
#endif
/* deprecated */
#define _bsf(x) bsf(x)
#define _bsfl(x) bsfl(x)
#define _bsfll(x) bsfll(x)
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_NEXGEN32E_BSF_H_ */
/*!BEGIN libc/intrin/bsr.h */
#ifndef COSMOPOLITAN_LIBC_NEXGEN32E_BSR_H_
#define COSMOPOLITAN_LIBC_NEXGEN32E_BSR_H_
COSMOPOLITAN_C_START_
libcesque int bsr(int) pureconst;
libcesque int bsrl(long) pureconst;
libcesque int bsrll(long long) pureconst;
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define bsr(x) (__builtin_clz(x) ^ (sizeof(int) * 8 - 1))
#define bsrl(x) (__builtin_clzl(x) ^ (sizeof(long) * 8 - 1))
#define bsrll(x) (__builtin_clzll(x) ^ (sizeof(long long) * 8 - 1))
#endif
/* deprecated */
#define _bsr(x) bsr(x)
#define _bsrl(x) bsrl(x)
#define _bsrll(x) bsrll(x)
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_NEXGEN32E_BSR_H_ */
/*!BEGIN libc/intrin/bswap.h */
#define COSMOPOLITAN_LIBC_BITS_BSWAP_H_
COSMOPOLITAN_C_START_
libcesque uint16_t bswap_16(uint16_t) pureconst;
libcesque uint32_t bswap_32(uint32_t) pureconst;
libcesque uint64_t bswap_64(uint64_t) pureconst;
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define bswap_16(x) __builtin_bswap16(x)
#define bswap_32(x) __builtin_bswap32(x)
#define bswap_64(x) __builtin_bswap64(x)
#endif /* defined(__GNUC__) && !defined(__STRICT_ANSI__) */
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/cmpxchg.h */
#define COSMOPOLITAN_LIBC_INTRIN_CMPXCHG_H_
COSMOPOLITAN_C_START_
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && defined(__x86__)
#define _cmpxchg(IFTHING, ISEQUALTOME, REPLACEITWITHME) \
({ \
bool32 DidIt; \
autotype(IFTHING) IfThing = (IFTHING); \
typeof(*IfThing) IsEqualToMe = (ISEQUALTOME); \
typeof(*IfThing) ReplaceItWithMe = (REPLACEITWITHME); \
asm volatile(ZFLAG_ASM("cmpxchg\t%3,%1") \
: ZFLAG_CONSTRAINT(DidIt), "+m"(*IfThing), "+a"(IsEqualToMe) \
: "r"(ReplaceItWithMe) \
: "cc"); \
DidIt; \
})
#else
#define _cmpxchg(IFTHING, ISEQUALTOME, REPLACEITWITHME) \
(*(IFTHING) == (ISEQUALTOME) ? (*(IFTHING) = (REPLACEITWITHME), 1) : 0)
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/dll.h */
#ifndef COSMOPOLITAN_LIBC_INTRIN_DLL_H_
#define COSMOPOLITAN_LIBC_INTRIN_DLL_H_
#define dll_make_first __dll_make_first
#define dll_make_last __dll_make_last
#define dll_remove __dll_remove
#define dll_splice_after __dll_splice_after
COSMOPOLITAN_C_START_
#define DLL_CONTAINER(t, f, p) ((t *)(((char *)(p)) - offsetof(t, f)))
struct Dll {
struct Dll *next;
struct Dll *prev;
};
static inline void dll_init(struct Dll *e) {
e->next = e;
e->prev = e;
}
static inline int dll_is_alone(struct Dll *e) {
return e->next == e && e->prev == e;
}
static inline int dll_is_empty(struct Dll *list) {
return !list;
}
static inline struct Dll *dll_last(struct Dll *list) {
return list;
}
static inline struct Dll *dll_first(struct Dll *list) {
struct Dll *first = 0;
if (list) first = list->next;
return first;
}
static inline struct Dll *dll_next(struct Dll *list, struct Dll *e) {
struct Dll *next = 0;
if (e != list) next = e->next;
return next;
}
static inline struct Dll *dll_prev(struct Dll *list, struct Dll *e) {
struct Dll *prev = 0;
if (e != list->next) prev = e->prev;
return prev;
}
void dll_remove(struct Dll **, struct Dll *) paramsnonnull() libcesque;
void dll_make_last(struct Dll **, struct Dll *) paramsnonnull((1)) libcesque;
void dll_make_first(struct Dll **, struct Dll *) paramsnonnull((1)) libcesque;
void dll_splice_after(struct Dll *, struct Dll *) paramsnonnull((1)) libcesque;
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_INTRIN_DLL_H_ */
/*!BEGIN libc/intrin/hilbert.h */
#define COSMOPOLITAN_LIBC_BITS_HILBERT_H_
#ifdef _COSMO_SOURCE
COSMOPOLITAN_C_START_
#define hilbert __hilbert
#define unhilbert __unhilbert
libcesque long hilbert(long, long, long) pureconst;
libcesque axdx_t unhilbert(long, long) pureconst;
COSMOPOLITAN_C_END_
#endif /* _COSMO_SOURCE */
/*!BEGIN libc/intrin/kprintf.h */
#ifndef COSMOPOLITAN_LIBC_INTRIN_KPRINTF_H_
#define COSMOPOLITAN_LIBC_INTRIN_KPRINTF_H_
#define klog __klog
#define kprintf __kprintf
#define ksnprintf __ksnprintf
#define kvprintf __kvprintf
#define kvsnprintf __kvsnprintf
#define kloghandle __kloghandle
#define kisdangerous __kisdangerous
#define uprintf __uprintf
#define uvprintf __uvprintf
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
void kprintf(const char *, ...) libcesque;
size_t ksnprintf(char *, size_t, const char *, ...) libcesque;
void kvprintf(const char *, va_list) libcesque;
size_t kvsnprintf(char *, size_t, const char *, va_list) libcesque;
bool32 kisdangerous(const void *) libcesque;
void klog(const char *, size_t) libcesque;
void _klog_serial(const char *, size_t) libcesque;
long kloghandle(void) libcesque;
void uprintf(const char *, ...) libcesque;
void uvprintf(const char *, va_list) libcesque;
#ifndef TINY
#define KINFOF(FMT, ...) \
do { \
uprintf("\r\e[35m%s:%d: " FMT "\e[0m\n", __FILE__, __LINE__, \
##__VA_ARGS__); \
} while (0)
#define KWARNF(FMT, ...) \
do { \
uprintf("\r\e[94;49mwarn: %s:%d: " FMT "\e[0m\n", __FILE__, __LINE__, \
##__VA_ARGS__); \
} while (0)
#else
#define KINFOF(FMT, ...) ((void)0)
#define KWARNF(FMT, ...) ((void)0)
#endif
#define KDIEF(FMT, ...) \
do { \
kprintf("\r\e[30;101mfatal: %s:%d: " FMT "\e[0m\n", __FILE__, __LINE__, \
##__VA_ARGS__); \
for (;;) asm volatile("cli\n\thlt"); \
} while (0)
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* COSMOPOLITAN_LIBC_INTRIN_KPRINTF_H_ */
/*!BEGIN libc/intrin/likely.h */
#define COSMOPOLITAN_LIBC_BITS_LIKELY_H_
#ifdef _COSMO_SOURCE
#define LIKELY(x) __builtin_expect(!!(x), 1)
#define UNLIKELY(x) __builtin_expect(!!(x), 0)
#if __GNUC__ + 0 >= 9 && !defined(__chibicc__)
#define VERY_LIKELY(x) __builtin_expect_with_probability(!!(x), 1, 0.999)
#else
#define VERY_LIKELY(x) LIKELY(x)
#endif
#if __GNUC__ + 0 >= 9 && !defined(__chibicc__)
#define VERY_UNLIKELY(x) __builtin_expect_with_probability(!!(x), 0, 0.999)
#else
#define VERY_UNLIKELY(x) UNLIKELY(x)
#endif
#endif /* _COSMO_SOURCE */
/*!BEGIN libc/intrin/macros.h */
#define COSMOPOLITAN_LIBC_INTRIN_MACROS_H_
/*!BEGIN libc/nexgen32e/x86feature.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_X86FEATURE_H_
#ifdef __x86_64__
/*!BEGIN libc/nexgen32e/kcpuids.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_KCPUIDS_H_
#define KCPUIDS_0H 0
#define KCPUIDS_1H 1
#define KCPUIDS_2H 2
#define KCPUIDS_7H 3
#define KCPUIDS_80000001H 4
#define KCPUIDS_80000007H 5
#define KCPUIDS_16H 6
#define KCPUIDS_7H_1H 7
#define KCPUIDS_LEN 8
#define KCPUIDS_6H -1 /* TBD: Thermal and Power Management */
#define KCPUIDS_DH -1 /* TBD: Extended state features */
#define KCPUIDS_80000008H -1 /* TBD: AMD Miscellaneous */
#define KCPUIDS_8000000AH -1 /* TBD: AMD SVM */
#define KCPUIDS_EAX 0
#define KCPUIDS_EBX 1
#define KCPUIDS_ECX 2
#define KCPUIDS_EDX 3
#define KCPUIDS(LEAF, REG) _KCPUIDS(LEAF, REG)
#ifdef __ASSEMBLER__
#define _KCPUIDS(LEAF, REG) KCPUIDS_##LEAF * 16 + KCPUIDS_##REG * 4
#else
#define _KCPUIDS(LEAF, REG) kCpuids[KCPUIDS_##LEAF][KCPUIDS_##REG]
#endif
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const unsigned kCpuids[KCPUIDS_LEN][4];
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
/*!BEGIN libc/nexgen32e/x86compiler.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_X86COMPILER_H_
#ifdef __x86_64__
/**
* @fileoverview x86 cpu feature compile-time requirement detection.
* @see -march=native, -mavx2, etc.
*/
#ifdef __AES__
#define _X86_CC_AES 1
#else
#define _X86_CC_AES 0
#endif
#ifdef __AVX__
#define _X86_CC_AVX 1
#else
#define _X86_CC_AVX 0
#endif
#ifdef __AVX2__
#define _X86_CC_AVX2 1
#else
#define _X86_CC_AVX2 0
#endif
#ifdef __F16C__
#define _X86_CC_F16C 1
#else
#define _X86_CC_F16C 0
#endif
#ifdef __AVXVNNI__
#define _X86_CC_AVXVNNI 1
#else
#define _X86_CC_AVXVNNI 0
#endif
#ifdef __AVXVNNIINT8__
#define _X86_CC_AVXVNNIINT8 1
#else
#define _X86_CC_AVXVNNIINT8 0
#endif
#ifdef __AVXVNNIINT16__
#define _X86_CC_AVXVNNIINT16 1
#else
#define _X86_CC_AVXVNNIINT16 0
#endif
#ifdef __AVX512F__
#define _X86_CC_AVX512F 1
#else
#define _X86_CC_AVX512F 0
#endif
#ifdef __AVX512BF16__
#define _X86_CC_AVX512BF16 1
#else
#define _X86_CC_AVX512BF16 0
#endif
#ifdef __AVX512FP16__
#define _X86_CC_AVX512FP16 1
#else
#define _X86_CC_AVX512FP16 0
#endif
#ifdef __AVX512VBMI__
#define _X86_CC_AVX512VBMI 1
#else
#define _X86_CC_AVX512VBMI 0
#endif
#ifdef __AVX512VNNI__
#define _X86_CC_AVX512VNNI 1
#else
#define _X86_CC_AVX512VNNI 0
#endif
#ifdef __AVX5124VNNIW__
#define _X86_CC_AVX5124VNNIW 1
#else
#define _X86_CC_AVX5124VNNIW 0
#endif
#ifdef __ABM__
#define _X86_CC_ABM 1
#else
#define _X86_CC_ABM 0
#endif
#ifdef __BMI__
#define _X86_CC_BMI 1
#else
#define _X86_CC_BMI 0
#endif
#ifdef __BMI2__
#define _X86_CC_BMI2 1
#else
#define _X86_CC_BMI2 0
#endif
#ifdef __FMA__
#define _X86_CC_FMA 1
#else
#define _X86_CC_FMA 0
#endif
#ifdef __ADX__
#define _X86_CC_ADX 1
#else
#define _X86_CC_ADX 0
#endif
#ifdef __PCLMUL__
#define _X86_CC_PCLMUL 1
#else
#define _X86_CC_PCLMUL 0
#endif
#ifdef __POPCNT__
#define _X86_CC_POPCNT 1
#else
#define _X86_CC_POPCNT 0
#endif
#ifdef __RDRND__
#define _X86_CC_RDRND 1
#else
#define _X86_CC_RDRND 0
#endif
#ifdef __RDSEED__
#define _X86_CC_RDSEED 1
#else
#define _X86_CC_RDSEED 0
#endif
#ifdef __SHA__
#define _X86_CC_SHA 1
#else
#define _X86_CC_SHA 0
#endif
#ifdef __SSSE3__
#define _X86_CC_SSSE3 1
#else
#define _X86_CC_SSSE3 0
#endif
#ifdef __SSE__
#define _X86_CC_SSE 1
#else
#define _X86_CC_SSE 0
#endif
#ifdef __SSE2__
#define _X86_CC_SSE2 1
#else
#define _X86_CC_SSE2 0
#endif
#ifdef __SSE3__
#define _X86_CC_SSE3 1
#else
#define _X86_CC_SSE3 0
#endif
#ifdef __SSE4_1__
#define _X86_CC_SSE4_1 1
#else
#define _X86_CC_SSE4_1 0
#endif
#ifdef __SSE4_2__
#define _X86_CC_SSE4_2 1
#else
#define _X86_CC_SSE4_2 0
#endif
#ifdef __XSAVE__
#define _X86_CC_XSAVE 1
#else
#define _X86_CC_XSAVE 0
#endif
#ifdef __CLFLUSHOPT__
#define _X86_CC_CLFLUSHOPT 1
#else
#define _X86_CC_CLFLUSHOPT 0
#endif
#ifdef __RDPID__
#define _X86_CC_RDPID 1
#else
#define _X86_CC_RDPID 0
#endif
#endif /* __x86_64__ */
/* Returns true if x86 FEATURE is present.
This performs a runtime check in normal portable builds.
It's usually dead code eliminated for -march=native builds. */
#define X86_HAVE(FEATURE) _X86_HAVE(X86_##FEATURE)
/* Returns true if x86 FEATURE is present.
This will *always* perform a runtime check.
It's useful for checking compile-time cpu features are present. */
#define X86_CHECK(FEATURE) _X86_CHECK(X86_##FEATURE)
/* Returns true if x86 FEATURE is mandatory at build time.
This will never perform runtime checks; it's always constant. */
#define X86_NEED(FEATURE) _X86_NEED(X86_##FEATURE)
/* clang-format off */
/* --- FEATURE LEAF REG BIT COMPILE-TIME-DEFINE */
#define X86_ACC 1H, EDX, 29, 0
#define X86_ACPI 1H, EDX, 22, 0
#define X86_ADX 7H, EBX, 19, _X86_CC_ADX /* broadwell c. 2014 */
#define X86_AES 1H, ECX, 25, _X86_CC_AES /* westmere c. 2010 */
#define X86_APIC 1H, EDX, 9, 0
#define X86_ARCH_CAPABILITIES 7H, EDX, 29, 0
#define X86_AVX 1H, ECX, 28, _X86_CC_AVX /* sandybridge c. 2012 */
#define X86_AVX2 7H, EBX, 5, _X86_CC_AVX2 /* haswell c. 2013 */
#define X86_AVXVNNI 7H_1H, EAX, 4, _X86_CC_AVXVNNI
#define X86_AVXVNNIINT8 7H_1H, EDX, 4, _X86_CC_AVXVNNIINT8
#define X86_AVXVNNIINT16 7H_1H, EDX, 10, _X86_CC_AVXVNNIINT16
#define X86_AVX512BW 7H, EBX, 30, 0
#define X86_AVX512CD 7H, EBX, 28, 0
#define X86_AVX512DQ 7H, EBX, 17, 0
#define X86_AVX512ER 7H, EBX, 27, 0
#define X86_AVX512F 7H, EBX, 16, _X86_CC_AVX512F
#define X86_AVX512IFMA 7H, EBX, 21, 0
#define X86_AVX512PF 7H, EBX, 26, 0
#define X86_AVX512VBMI 7H, ECX, 1, _X86_CC_AVX512VBMI
#define X86_AVX512VL 7H, EBX, 31, 0
#define X86_AVX512_4FMAPS 7H, EDX, 3, 0
#define X86_AVX512_4VNNIW 7H, EDX, 2, _X86_CC_AVX5124VNNIW
#define X86_AVX512_FP16 7H, EDX, 23, _X86_CC_AVX512FP16
#define X86_AVX512_BF16 7H_1H, EAX, 5, _X86_CC_AVX512BF16
#define X86_AVX512_BITALG 7H, ECX, 12, 0
#define X86_AVX512_VBMI2 7H, ECX, 6, 0
#define X86_AVX512_VNNI 7H, ECX, 11, _X86_CC_AVX512VNNI
#define X86_AVX512_VP2INTERSECT 7H, EDX, 8, 0
#define X86_AVX512_VPOPCNTDQ 7H, ECX, 14, 0
#define X86_BMI 7H, EBX, 3, _X86_CC_BMI /* haswell c. 2013 */
#define X86_BMI2 7H, EBX, 8, _X86_CC_BMI2 /* haswell c. 2013 */
#define X86_CID 1H, ECX, 10, 0
#define X86_CLDEMOTE 7H, ECX, 25, 0
#define X86_CLFLUSH 1H, EDX, 19, _X86_CC_SSE2
#define X86_CLFLUSHOPT 7H, EBX, 23, _X86_CC_CLFLUSHOPT /* skylake/zen */
#define X86_CLWB 7H, EBX, 24, 0 /* skylake/zen2 */
#define X86_CMOV 1H, EDX, 15, 0
#define X86_CQM 7H, EBX, 12, 0
#define X86_CX16 1H, ECX, 13, 0
#define X86_CX8 1H, EDX, 8, 0
#define X86_DCA 1H, ECX, 18, 0
#define X86_DE 1H, EDX, 2, 0
#define X86_DS 1H, EDX, 21, 0
#define X86_DSCPL 1H, ECX, 4, 0
#define X86_DTES64 1H, ECX, 2, 0
#define X86_ERMS 7H, EBX, 9, 0 /* broaadwell c. 2014 */
#define X86_EST 1H, ECX, 7, 0
#define X86_F16C 1H, ECX, 29, _X86_CC_F16C
#define X86_FDP_EXCPTN_ONLY 7H, EBX, 6, 0
#define X86_FLUSH_L1D 7H, EDX, 28, 0
#define X86_FMA 1H, ECX, 12, _X86_CC_FMA /* haswell c. 2013 */
#define X86_FPU 1H, EDX, 0, 0
#define X86_FSGSBASE 7H, EBX, 0, 0
#define X86_FXSR 1H, EDX, 24, 0
#define X86_GBPAGES 80000001H, EDX, 26, 0
#define X86_GFNI 7H, ECX, 8, 0
#define X86_HLE 7H, EBX, 4, 0
#define X86_HT 1H, EDX, 28, 0
#define X86_HYPERVISOR 1H, ECX, 31, 0
#define X86_IA64 1H, EDX, 30, 0
#define X86_INTEL_PT 7H, EBX, 25, 0
#define X86_INTEL_STIBP 7H, EDX, 27, 0
#define X86_INVPCID 1H, EBX, 10, 0
#define X86_INVTSC 80000007H, EDX, 8, _X86_CC_POPCNT /* i.e. not a K8 */
#define X86_LA57 7H, ECX, 16, 0
#define X86_LAHF_LM 80000001H, ECX, 0, 0
#define X86_LM 80000001H, EDX, 29, 0
#define X86_MCA 1H, EDX, 14, 0
#define X86_MCE 1H, EDX, 7, 0
#define X86_MD_CLEAR 7H, EDX, 10, 0
#define X86_MMX 1H, EDX, 23, 0
#define X86_MOVBE 1H, ECX, 22, 0
#define X86_MOVDIR64B 7H, ECX, 28, 0
#define X86_MOVDIRI 7H, ECX, 27, 0
#define X86_MP 80000001H, EDX, 19, 0
#define X86_MPX 7H, EBX, 14, 0
#define X86_MSR 1H, EDX, 5, 0
#define X86_MTRR 1H, EDX, 12, 0
#define X86_MWAIT 1H, ECX, 3, 0
#define X86_NX 80000001H, EDX, 20, 0
#define X86_OSPKE 7H, ECX, 4, 0
#define X86_OSXSAVE 1H, ECX, 27, 0
#define X86_PAE 1H, EDX, 6, 0
#define X86_PAT 1H, EDX, 16, 0
#define X86_PBE 1H, EDX, 31, 0
#define X86_PCID 1H, ECX, 17, 0
#define X86_PCLMUL 1H, ECX, 1, _X86_CC_PCLMUL /* westmere c. 2010 */
#define X86_PCONFIG 7H, EDX, 18, 0
#define X86_PDCM 1H, ECX, 15, 0
#define X86_PGE 1H, EDX, 13, 0
#define X86_PKU 7H, ECX, 3, 0
#define X86_PN 1H, EDX, 18, 0
#define X86_POPCNT 1H, ECX, 23, _X86_CC_POPCNT /* nehalem c. 2008 */
#define X86_PSE 1H, EDX, 3, 0
#define X86_PSE36 1H, EDX, 17, 0
#define X86_RDPID 7H, ECX, 22, _X86_CC_RDPID /* cannonlake c. 2018 */
#define X86_RDRND 1H, ECX, 30, _X86_CC_RDRND /* ivybridge c. 2012 */
#define X86_RDSEED 7H, EBX, 18, _X86_CC_RDSEED /* broadwell c. 2014 */
#define X86_RDTSCP 80000001H, EDX, 27, 0
#define X86_RDT_A 7H, EBX, 15, 0
#define X86_RTM 7H, EBX, 11, 0
#define X86_SDBG 1H, ECX, 11, 0
#define X86_SELFSNOOP 1H, EDX, 27, 0
#define X86_SEP 1H, EDX, 11, 0
#define X86_SHA 7H, EBX, 29, _X86_CC_SHA /* goldmont (2016) */
#define X86_SMAP 7H, EBX, 20, 0
#define X86_SMEP 7H, EBX, 7, 0
#define X86_SMX 1H, ECX, 6, 0
#define X86_SPEC_CTRL 7H, EDX, 26, 0
#define X86_SPEC_CTRL_SSBD 7H, EDX, 31, 0
#define X86_SSE 1H, EDX, 25, _X86_CC_SSE /* pentium c. 1999 */
#define X86_SSE2 1H, EDX, 26, _X86_CC_SSE2 /* pentium c. 2001 */
#define X86_SSE3 1H, ECX, 0, _X86_CC_SSE3 /* k8 c. 2005 */
#define X86_SSE4_1 1H, ECX, 19, _X86_CC_SSE4_1 /* core c. 2006 */
#define X86_SSE4_2 1H, ECX, 20, _X86_CC_SSE4_2 /* nehalem c. 2008 */
#define X86_SSSE3 1H, ECX, 9, _X86_CC_SSSE3 /* westmere c. 2010 */
#define X86_SYSCALL 80000001H, EDX, 11, 0
#define X86_TM2 1H, ECX, 8, 0
#define X86_TME 7H, ECX, 13, 0
#define X86_TSC 1H, EDX, 4, 0
#define X86_TSC_ADJUST 7H, EBX, 1, 0
#define X86_TSC_DEADLINE_TIMER 1H, ECX, 24, 0
#define X86_TSX_FORCE_ABORT 7H, EDX, 13, 0
#define X86_UMIP 7H, ECX, 2, 0
#define X86_VAES 7H, ECX, 9, 0
#define X86_VME 1H, EDX, 1, 0
#define X86_VMX 1H, ECX, 5, 0
#define X86_VPCLMULQDQ 7H, ECX, 10, 0
#define X86_WAITPKG 7H, ECX, 5, 0
#define X86_X2APIC 1H, ECX, 21, 0
#define X86_XSAVE 1H, ECX, 26, _X86_CC_XSAVE /* sandybridge c. 2012 */
#define X86_XTPR 1H, ECX, 14, 0
#define X86_ZERO_FCS_FDS 7H, EBX, 13, 0
#define X86_JIT 80000001H, ECX, 31, 0 /* IsGenuineBlink() */
#define X86_HYBRID_CPU 7H, EDX, 15, 0 /* Has performance and efficiency cores */
/* clang-format on */
/* AMD specific features */
#define X86_ABM 80000001H, ECX, 5, _X86_CC_ABM
#define X86_3DNOW 80000001H, EDX, 31, 0
#define X86_3DNOWEXT 80000001H, EDX, 30, 0
#define X86_3DNOWPREFETCH 80000001H, ECX, 8, 0
#define X86_BPEXT 80000001H, ECX, 26, 0
#define X86_CMP_LEGACY 80000001H, ECX, 1, 0
#define X86_CR8_LEGACY 80000001H, ECX, 4, 0
#define X86_EXTAPIC 80000001H, ECX, 3, 0
#define X86_FMA4 80000001H, ECX, 16, 0
#define X86_FXSR_OPT 80000001H, EDX, 25, 0
#define X86_IBS 80000001H, ECX, 10, 0
#define X86_LWP 80000001H, ECX, 15, 0
#define X86_MISALIGNSSE 80000001H, ECX, 7, 0
#define X86_MMXEXT 80000001H, EDX, 22, 0
#define X86_MWAITX 80000001H, ECX, 29, 0
#define X86_NODEID_MSR 80000001H, ECX, 19, 0
#define X86_OSVW 80000001H, ECX, 9, 0
#define X86_OVERFLOW_RECOV 80000007H, EBX, 0, 0
#define X86_PERFCTR_CORE 80000001H, ECX, 23, 0
#define X86_PERFCTR_LLC 80000001H, ECX, 28, 0
#define X86_PERFCTR_NB 80000001H, ECX, 24, 0
#define X86_PTSC 80000001H, ECX, 27, 0
#define X86_SKINIT 80000001H, ECX, 12, 0
#define X86_SMCA 80000007H, EBX, 3, 0
#define X86_SSE4A 80000001H, ECX, 6, 0
#define X86_SUCCOR 80000007H, EBX, 1, 0
#define X86_SVM 80000001H, ECX, 2, 0
#define X86_TBM 80000001H, ECX, 21, 0
#define X86_TCE 80000001H, ECX, 17, 0
#define X86_TOPOEXT 80000001H, ECX, 22, 0
#define X86_WDT 80000001H, ECX, 13, 0
#define X86_XOP 80000001H, ECX, 11, 0
/* Defined but not loaded by kCpuids.S */
#define X86_ARAT 6H, EAX, 2, 0
#define X86_AVIC 8000000AH, EDX, 13, 0
#define X86_CLZERO 80000008H, EBX, 0, 0
#define X86_DECODEASSISTS 8000000AH, EDX, 7, 0
#define X86_DTHERM 6H, EAX, 0, 0
#define X86_FLUSHBYASID 8000000AH, EDX, 6, 0
#define X86_HWP 6H, EAX, 7, 0
#define X86_HWP_ACT_WINDOW 6H, EAX, 9, 0
#define X86_HWP_EPP 6H, EAX, 10, 0
#define X86_HWP_NOTIFY 6H, EAX, 8, 0
#define X86_HWP_PKG_REQ 6H, EAX, 11, 0
#define X86_IBPB 80000008H, EBX, 12, 0
#define X86_IBRS 80000008H, EBX, 14, 0
#define X86_IDA 6H, EAX, 1, 0
#define X86_IRPERF 80000008H, EBX, 1, 0
#define X86_LBRV 8000000AH, EDX, 1, 0
#define X86_NPT 8000000AH, EDX, 0, 0
#define X86_NRIPS 8000000AH, EDX, 3, 0
#define X86_PAUSEFILTER 8000000AH, EDX, 10, 0
#define X86_PFTHRESHOLD 8000000AH, EDX, 12, 0
#define X86_PLN 6H, EAX, 4, 0
#define X86_PTS 6H, EAX, 6, 0
#define X86_SSBD 80000008H, EBX, 24, 0
#define X86_SSB_NO 80000008H, EBX, 26, 0
#define X86_STIBP 80000008H, EBX, 15, 0
#define X86_STIBP_ALWAYS_ON 80000008H, EBX, 17, 0
#define X86_SVML 8000000AH, EDX, 2, 0
#define X86_TSCRATEMSR 8000000AH, EDX, 4, 0
#define X86_VGIF 8000000AH, EDX, 16, 0
#define X86_VIRT_SSBD 80000008H, EBX, 25, 0
#define X86_VMCBCLEAN 8000000AH, EDX, 5, 0
#define X86_V_VMSAVE_VMLOAD 8000000AH, EDX, 15, 0
#define X86_WBNOINVD 80000008H, EBX, 9, 0
#define X86_XGETBV1 DH, EAX, 2, 0
#define X86_XSAVEC DH, EAX, 1, 0
#define X86_XSAVEERPTR 80000008H, EBX, 2, 0
#define X86_XSAVEOPT DH, EAX, 0, 0
#define X86_XSAVES DH, EAX, 3, 0
#define X86_WORD(FEATURE) _X86_WORD(X86_##FEATURE)
#define X86_LEAF(FEATURE) _X86_LEAF(X86_##FEATURE)
#define X86_REG(FEATURE) _X86_REG(X86_##FEATURE)
#define X86_BIT(FEATURE) _X86_BIT(X86_##FEATURE)
#define _X86_CHECK(FEATURE) __X86_CHECK(FEATURE)
#define _X86_HAVE(FEATURE) __X86_HAVE(FEATURE)
#define _X86_NEED(FEATURE) __X86_NEED(FEATURE)
#define _X86_WORD(FEATURE) __X86_WORD(FEATURE)
#define _X86_LEAF(FEATURE) __X86_LEAF(FEATURE)
#define _X86_REG(FEATURE) __X86_REG(FEATURE)
#define _X86_BIT(FEATURE) __X86_BIT(FEATURE)
#define __X86_CHECK(LEAF, REG, BIT, MANDATORY) \
___X86_CHECK(LEAF, REG, BIT, MANDATORY)
#define __X86_HAVE(LEAF, REG, BIT, MANDATORY) \
___X86_HAVE(LEAF, REG, BIT, MANDATORY)
#define __X86_NEED(LEAF, REG, BIT, MANDATORY) MANDATORY
#define __X86_WORD(LEAF, REG, BIT, MANDATORY) KCPUIDS(LEAF, REG)
#define __X86_LEAF(LEAF, REG, BIT, MANDATORY) LEAF
#define __X86_REG(LEAF, REG, BIT, MANDATORY) REG
#define __X86_BIT(LEAF, REG, BIT, MANDATORY) BIT
#define ___X86_CHECK(LEAF, REG, BIT, MANDATORY) \
!!(KCPUIDS(LEAF, REG) & (1u << BIT))
#ifndef __ASSEMBLER__
#define ___X86_HAVE(LEAF, REG, BIT, MANDATORY) \
!!(MANDATORY || KCPUIDS(LEAF, REG) & (1u << BIT))
#else
#define ___X86_HAVE(LEAF, REG, BIT, MANDATORY) \
$1 << (BIT % 8), BIT / 8 + KCPUIDS(LEAF, REG)
#endif
#else
#define X86_HAVE(FEATURE) 0
#define X86_NEED(FEATURE) 0
#define X86_CHECK(FEATURE) 0
#endif /* __x86_64__ */
#define INTRIN_COMMUTATIVE "%"
#define INTRIN_NONCOMMUTATIVE
#if defined(__x86_64__) && !defined(__STRICT_ANSI__)
typedef char __intrin_xmm_t
__attribute__((__vector_size__(16), __aligned__(16), __may_alias__));
#define INTRIN_SSEVEX_X_X_X_(PURE, ISA, OP, FLAGS, A, B, C) \
do { \
if (X86_HAVE(ISA)) { \
__intrin_xmm_t *Xmm0 = (void *)(A); \
const __intrin_xmm_t *Xmm1 = (const __intrin_xmm_t *)(B); \
const __intrin_xmm_t *Xmm2 = (const __intrin_xmm_t *)(C); \
if (!X86_NEED(AVX)) { \
asm(OP "\t%1,%0" : "=x"(*Xmm0) : FLAGS "x"(*Xmm2), "0"(*Xmm1)); \
} else { \
asm("v" OP "\t%2,%1,%0" : "=x"(*Xmm0) : FLAGS "x"(*Xmm1), "x"(*Xmm2)); \
} \
} else { \
PURE(A, B, C); \
} \
} while (0)
#define INTRIN_SSEVEX_X_X_I_(PURE, ISA, OP, A, B, I) \
do { \
if (X86_HAVE(ISA)) { \
__intrin_xmm_t *Xmm0 = (void *)(A); \
const __intrin_xmm_t *Xmm1 = (const __intrin_xmm_t *)(B); \
if (!X86_NEED(AVX)) { \
asm(OP "\t%2,%1,%0" : "=x"(*Xmm0) : "x"(*Xmm1), "i"(I)); \
} else { \
asm("v" OP "\t%2,%1,%0" : "=x"(*Xmm0) : "x"(*Xmm1), "i"(I)); \
} \
} else { \
PURE(A, B, I); \
} \
} while (0)
#define INTRIN_SSEVEX_X_X_(PURE, ISA, OP, A, B) \
do { \
if (X86_HAVE(ISA)) { \
__intrin_xmm_t *Xmm0 = (void *)(A); \
const __intrin_xmm_t *Xmm1 = (const __intrin_xmm_t *)(B); \
if (!X86_NEED(AVX)) { \
asm(OP "\t%1,%0" : "=x"(*Xmm0) : "0"(*Xmm1)); \
} else { \
asm("v" OP "\t%1,%0" : "=x"(*Xmm0) : "x"(*Xmm1)); \
} \
} else { \
PURE(A, B); \
} \
} while (0)
#define INTRIN_SSEVEX_X_I_(PURE, ISA, OP, A, B, I) \
do { \
if (!IsModeDbg() && X86_HAVE(ISA)) { \
__intrin_xmm_t *Xmm0 = (void *)(A); \
const __intrin_xmm_t *Xmm1 = (const __intrin_xmm_t *)(B); \
if (!X86_NEED(AVX)) { \
asm(OP "\t%1,%0" : "=x"(*Xmm0) : "i"(I), "0"(*Xmm1)); \
} else { \
asm("v" OP "\t%2,%1,%0" : "=x"(*Xmm0) : "x"(*Xmm1), "i"(I)); \
} \
} else { \
PURE(A, B, I); \
} \
} while (0)
#else
#define INTRIN_SSEVEX_X_X_X_(PURE, ISA, OP, FLAGS, A, B, C) PURE(A, B, C)
#define INTRIN_SSEVEX_X_X_I_(PURE, ISA, OP, A, B, I) PURE(A, B, I)
#define INTRIN_SSEVEX_X_I_(PURE, ISA, OP, A, B, I) PURE(A, B, I)
#define INTRIN_SSEVEX_X_X_(PURE, ISA, OP, A, B) PURE(A, B)
#endif /* X86 && !ANSI */
/*!BEGIN libc/intrin/newbie.h */
#define COSMOPOLITAN_LIBC_BITS_NEWBIE_H_
#define BYTE_ORDER __BYTE_ORDER__
#define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
#define BIG_ENDIAN __ORDER_BIG_ENDIAN__
#define PDP_ENDIAN __ORDER_PDP_ENDIAN__
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
#define htobe16(x) bswap_16(x)
#define be16toh(x) bswap_16(x)
#define betoh16(x) bswap_16(x)
#define htobe32(x) bswap_32(x)
#define be32toh(x) bswap_32(x)
#define betoh32(x) bswap_32(x)
#define htobe64(x) bswap_64(x)
#define be64toh(x) bswap_64(x)
#define betoh64(x) bswap_64(x)
#define htole16(x) (uint16_t)(x)
#define le16toh(x) (uint16_t)(x)
#define letoh16(x) (uint16_t)(x)
#define htole32(x) (uint32_t)(x)
#define le32toh(x) (uint32_t)(x)
#define letoh32(x) (uint32_t)(x)
#define htole64(x) (uint64_t)(x)
#define le64toh(x) (uint64_t)(x)
#define letoh64(x) (uint64_t)(x)
#else
#define htobe16(x) (uint16_t)(x)
#define be16toh(x) (uint16_t)(x)
#define betoh16(x) (uint16_t)(x)
#define htobe32(x) (uint32_t)(x)
#define be32toh(x) (uint32_t)(x)
#define betoh32(x) (uint32_t)(x)
#define htobe64(x) (uint64_t)(x)
#define be64toh(x) (uint64_t)(x)
#define betoh64(x) (uint64_t)(x)
#define htole16(x) bswap_16(x)
#define le16toh(x) bswap_16(x)
#define letoh16(x) bswap_16(x)
#define htole32(x) bswap_32(x)
#define le32toh(x) bswap_32(x)
#define letoh32(x) bswap_32(x)
#define htole64(x) bswap_64(x)
#define le64toh(x) bswap_64(x)
#define letoh64(x) bswap_64(x)
#endif
/*!BEGIN libc/intrin/packsswb.h */
#define COSMOPOLITAN_LIBC_INTRIN_PACKSSWB_H_
COSMOPOLITAN_C_START_
void packsswb(int8_t[16], const int16_t[8], const int16_t[8]);
#define packsswb(A, B, C) \
INTRIN_SSEVEX_X_X_X_(packsswb, SSE2, "packsswb", INTRIN_NONCOMMUTATIVE, A, \
B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/packuswb.h */
#define COSMOPOLITAN_LIBC_INTRIN_PACKUSWB_H_
COSMOPOLITAN_C_START_
void packuswb(uint8_t[16], const int16_t[8], const int16_t[8]);
#define packuswb(A, B, C) \
INTRIN_SSEVEX_X_X_X_(packuswb, SSE2, "packuswb", INTRIN_NONCOMMUTATIVE, A, \
B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/paddw.h */
#define COSMOPOLITAN_LIBC_INTRIN_PADDW_H_
COSMOPOLITAN_C_START_
void paddw(int16_t[8], const int16_t[8], const int16_t[8]);
#define paddw(A, B, C) \
INTRIN_SSEVEX_X_X_X_(paddw, SSE2, "paddw", INTRIN_COMMUTATIVE, A, B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/palignr.h */
#define COSMOPOLITAN_LIBC_INTRIN_PALIGNR_H_
/*!BEGIN libc/str/str.h */
#define COSMOPOLITAN_LIBC_STR_STR_H_
#define INVALID_CODEPOINT 0xfffd
#define _tolower(u) (0040 | (u))
#define _toupper(u) (0137 & (u))
#ifdef _COSMO_SOURCE
#define chomp _chomp
#define chomp16 _chomp16
#define wchomp _wchomp
#define tpenc _tpenc
#define isutf8 _isutf8
#define istext _istext
#define startswith _startswith
#define startswithi _startswithi
#define endswith _endswith
#define wcsendswith _wcsendswith
#define wcsstartswith _wcsstartswith
#endif /* _COSMO_SOURCE */
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
int isascii(int) libcesque;
int isspace(int) libcesque;
int isalpha(int) libcesque;
int isdigit(int) libcesque;
int isalnum(int) libcesque;
int isxdigit(int) libcesque;
int isprint(int) libcesque;
int islower(int) libcesque;
int isupper(int) libcesque;
int isblank(int) libcesque;
int iscntrl(int) libcesque;
int isgraph(int) libcesque;
int tolower(int) libcesque;
int ispunct(int) libcesque;
int toupper(int) libcesque;
int toascii(int) libcesque;
int iswalnum(wint_t) libcesque;
int iswalpha(wint_t) libcesque;
int iswblank(wint_t) libcesque;
int iswcntrl(wint_t) libcesque;
int iswdigit(wint_t) libcesque;
int iswgraph(wint_t) libcesque;
int iswlower(wint_t) libcesque;
int iswspace(wint_t) libcesque;
int iswupper(wint_t) libcesque;
int iswxdigit(wint_t) libcesque;
int iswpunct(wint_t) libcesque;
int iswprint(wint_t) libcesque;
int iswseparator(wint_t) libcesque;
wint_t towlower(wint_t) libcesque;
wint_t towupper(wint_t) libcesque;
void *memset(void *, int, size_t) memcpyesque;
void *memmove(void *, const void *, size_t) memcpyesque;
void *memcpy(void *restrict, const void *restrict, size_t) memcpyesque;
void *mempcpy(void *restrict, const void *restrict, size_t) memcpyesque;
char *hexpcpy(char *restrict, const void *restrict, size_t) memcpyesque;
void *memccpy(void *restrict, const void *restrict, int, size_t) memcpyesque;
void explicit_bzero(void *, size_t);
int memcmp(const void *, const void *, size_t) strlenesque;
int timingsafe_bcmp(const void *, const void *, size_t) libcesque;
int timingsafe_memcmp(const void *, const void *, size_t) libcesque;
size_t strlen(const char *) strlenesque;
size_t strnlen(const char *, size_t) strlenesque;
size_t strnlen_s(const char *, size_t) libcesque;
char *strchr(const char *, int) strlenesque;
void *memchr(const void *, int, size_t) strlenesque;
char *strchrnul(const char *, int) strlenesque returnsnonnull;
void *rawmemchr(const void *, int) strlenesque returnsnonnull;
size_t wcslen(const wchar_t *) strlenesque;
size_t wcsnlen(const wchar_t *, size_t) strlenesque;
size_t wcsnlen_s(const wchar_t *, size_t) libcesque;
wchar_t *wcschr(const wchar_t *, wchar_t) strlenesque;
wchar_t *wmemchr(const wchar_t *, wchar_t, size_t) strlenesque;
wchar_t *wcschrnul(const wchar_t *, wchar_t)
strlenesque returnsnonnull;
char *strstr(const char *, const char *) strlenesque;
char *strcasestr(const char *, const char *) strlenesque;
wchar_t *wcsstr(const wchar_t *, const wchar_t *) strlenesque;
int strcmp(const char *, const char *) strlenesque;
int strncmp(const char *, const char *, size_t) strlenesque;
int wcscmp(const wchar_t *, const wchar_t *) strlenesque;
int wcsncmp(const wchar_t *, const wchar_t *, size_t) strlenesque;
int wmemcmp(const wchar_t *, const wchar_t *, size_t) strlenesque;
int strcasecmp(const char *, const char *) strlenesque;
int memcasecmp(const void *, const void *, size_t) strlenesque;
int wcscasecmp(const wchar_t *, const wchar_t *) strlenesque;
int strncasecmp(const char *, const char *, size_t) strlenesque;
int wcsncasecmp(const wchar_t *, const wchar_t *, size_t) strlenesque;
char *strrchr(const char *, int) strlenesque;
void *memrchr(const void *, int, size_t) strlenesque;
wchar_t *wcsrchr(const wchar_t *, wchar_t) strlenesque;
void *wmemrchr(const wchar_t *, wchar_t, size_t) strlenesque;
char *strpbrk(const char *, const char *) strlenesque;
wchar_t *wcspbrk(const wchar_t *, const wchar_t *) strlenesque;
size_t strspn(const char *, const char *) strlenesque;
size_t wcsspn(const wchar_t *, const wchar_t *) strlenesque;
size_t strcspn(const char *, const char *) strlenesque;
size_t wcscspn(const wchar_t *, const wchar_t *) strlenesque;
void *memfrob(void *, size_t) memcpyesque;
int strcoll(const char *, const char *) strlenesque;
char *strsep(char **, const char *) libcesque paramsnonnull();
char *stpcpy(char *, const char *) memcpyesque;
char *stpncpy(char *, const char *, size_t) memcpyesque;
char *strcat(char *, const char *) memcpyesque;
wchar_t *wcscat(wchar_t *, const wchar_t *) memcpyesque;
size_t strlcpy(char *, const char *, size_t) libcesque;
size_t strlcat(char *, const char *, size_t) libcesque;
size_t strxfrm(char *, const char *, size_t) libcesque;
char *strcpy(char *, const char *) memcpyesque;
wchar_t *wcscpy(wchar_t *, const wchar_t *) memcpyesque;
char *strncat(char *, const char *, size_t) memcpyesque;
wchar_t *wcsncat(wchar_t *, const wchar_t *, size_t) memcpyesque;
char *strncpy(char *, const char *, size_t) memcpyesque;
char *strtok(char *, const char *) paramsnonnull((2)) libcesque;
char *strtok_r(char *, const char *, char **) paramsnonnull((2, 3));
wchar_t *wcstok(wchar_t *, const wchar_t *, wchar_t **) paramsnonnull((2, 3));
int strverscmp(const char *, const char *) libcesque;
wchar_t *wmemset(wchar_t *, wchar_t, size_t) memcpyesque;
wchar_t *wmemcpy(wchar_t *, const wchar_t *, size_t) memcpyesque;
wchar_t *wmempcpy(wchar_t *, const wchar_t *, size_t) memcpyesque;
wchar_t *wmemmove(wchar_t *, const wchar_t *, size_t) memcpyesque;
void *memmem(const void *, size_t, const void *, size_t)
libcesque nosideeffect;
ssize_t strfmon(char *, size_t, const char *, ...) libcesque;
long a64l(const char *) libcesque;
char *l64a(long) libcesque;
typedef unsigned mbstate_t;
wchar_t *wcsncpy(wchar_t *, const wchar_t *, size_t) libcesque;
int mbtowc(wchar_t *, const char *, size_t) libcesque;
size_t mbrtowc(wchar_t *, const char *, size_t, mbstate_t *) libcesque;
size_t mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *) libcesque;
size_t mbstowcs(wchar_t *, const char *, size_t) libcesque;
size_t wcrtomb(char *, wchar_t, mbstate_t *) libcesque;
size_t c32rtomb(char *, char32_t, mbstate_t *) libcesque;
size_t mbrtoc32(char32_t *, const char *, size_t, mbstate_t *) libcesque;
size_t c16rtomb(char *, char16_t, mbstate_t *) libcesque;
size_t mbrtoc16(char16_t *, const char *, size_t, mbstate_t *) libcesque;
size_t mbrlen(const char *, size_t, mbstate_t *) libcesque;
size_t mbsnrtowcs(wchar_t *, const char **, size_t, size_t, mbstate_t *);
size_t wcsnrtombs(char *, const wchar_t **, size_t, size_t, mbstate_t *);
size_t wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *) libcesque;
size_t wcstombs(char *, const wchar_t *, size_t) libcesque;
int mbsinit(const mbstate_t *) libcesque;
int mblen(const char *, size_t) libcesque;
int wctomb(char *, wchar_t) libcesque;
int wctob(wint_t) libcesque;
wint_t btowc(int) libcesque;
typedef unsigned wctype_t;
wctype_t wctype(const char *) strlenesque;
pureconst int iswctype(wint_t, wctype_t) libcesque;
typedef const int *wctrans_t;
wctrans_t wctrans(const char *) libcesque;
wint_t towctrans(wint_t, wctrans_t) libcesque;
int getsubopt(char **, char *const *, char **) libcesque paramsnonnull();
char *strsignal(int) returnsnonnull libcesque;
char *strerror(int) returnsnonnull dontthrow dontcallback;
errno_t strerror_r(int, char *, size_t) libcesque;
char *__xpg_strerror_r(int, char *, size_t) libcesque;
#ifdef _COSMO_SOURCE
pureconst uint64_t tpenc(uint32_t) libcesque;
char *chomp(char *) libcesque;
wchar_t *wchomp(wchar_t *) libcesque;
uint64_t __fnv(const void *, size_t) strlenesque;
bool32 startswith(const char *, const char *) strlenesque;
bool32 startswithi(const char *, const char *) strlenesque;
bool32 endswith(const char *, const char *) strlenesque;
bool32 istext(const void *, size_t) libcesque;
bool32 isutf8(const void *, size_t) libcesque;
const char *strsignal_r(int, char[21]) returnsnonnull libcesque __wur;
char16_t *chomp16(char16_t *) libcesque;
size_t strlen16(const char16_t *) strlenesque;
size_t strnlen16(const char16_t *, size_t) strlenesque;
char16_t *strchr16(const char16_t *, int) strlenesque;
void *memchr16(const void *, int, size_t) strlenesque;
char16_t *strchrnul16(const char16_t *, int) strlenesque returnsnonnull;
void *rawmemchr16(const void *, int) strlenesque returnsnonnull;
char16_t *strstr16(const char16_t *, const char16_t *) strlenesque;
int strcmp16(const char16_t *, const char16_t *) strlenesque;
int strncmp16(const char16_t *, const char16_t *, size_t) strlenesque;
int strcasecmp16(const char16_t *, const char16_t *) strlenesque;
int strncasecmp16(const char16_t *, const char16_t *, size_t) strlenesque;
char16_t *strrchr16(const char16_t *, int) strlenesque;
void *memrchr16(const void *, int, size_t) strlenesque;
char16_t *strpbrk16(const char16_t *, const char16_t *) strlenesque;
size_t strspn16(const char16_t *, const char16_t *) strlenesque;
size_t strcspn16(const char16_t *, const char16_t *) strlenesque;
char16_t *strcat16(char16_t *, const char16_t *) memcpyesque;
char16_t *strcpy16(char16_t *, const char16_t *) memcpyesque;
char16_t *strncat16(char16_t *, const char16_t *, size_t) memcpyesque;
char16_t *memset16(char16_t *, char16_t, size_t) memcpyesque;
bool32 startswith16(const char16_t *, const char16_t *) strlenesque;
bool32 endswith16(const char16_t *, const char16_t *) strlenesque;
axdx_t tprecode8to16(char16_t *, size_t, const char *) libcesque;
axdx_t tprecode16to8(char *, size_t, const char16_t *) libcesque;
bool32 wcsstartswith(const wchar_t *, const wchar_t *) strlenesque;
bool32 wcsendswith(const wchar_t *, const wchar_t *) strlenesque;
char *__join_paths(char *, size_t, const char *, const char *) libcesque __wur;
int __mkntpathat(int, const char *, int, char16_t[hasatleast 1024]);
#endif /* _COSMO_SOURCE */
#if defined(_COSMO_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) || \
defined(_POSIX_SOURCE) || \
(defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE + 0 < 200809L) || \
(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE + 0 < 700)
int bcmp(const void *, const void *, size_t) strlenesque;
void bcopy(const void *, void *, size_t) memcpyesque;
void bzero(void *, size_t) memcpyesque;
char *index(const char *, int) strlenesque;
char *rindex(const char *, int) strlenesque;
#endif
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
COSMOPOLITAN_C_START_
void palignr(void *, const void *, const void *, unsigned long);
#if !defined(__STRICT_ANSI__) && !defined(__chibicc__) && defined(__x86_64__)
__intrin_xmm_t __palignrs(__intrin_xmm_t, __intrin_xmm_t);
#define palignr(C, B, A, I) \
do { \
if (__builtin_expect(!IsModeDbg() && X86_NEED(SSE) && X86_HAVE(SSSE3), \
1)) { \
__intrin_xmm_t *Xmm0 = (void *)(C); \
const __intrin_xmm_t *Xmm1 = (const __intrin_xmm_t *)(B); \
const __intrin_xmm_t *Xmm2 = (const __intrin_xmm_t *)(A); \
if (__builtin_constant_p(I)) { \
if (!X86_NEED(AVX)) { \
asm("palignr\t%2,%1,%0" \
: "=x"(*Xmm0) \
: "x"(*Xmm2), "i"(I), "0"(*Xmm1)); \
} else { \
asm("vpalignr\t%3,%2,%1,%0" \
: "=x"(*Xmm0) \
: "x"(*Xmm1), "x"(*Xmm2), "i"(I)); \
} \
} else { \
unsigned long Vimm = (I); \
typeof(__palignrs) *Fn; \
if (__builtin_expect(Vimm < 32, 1)) { \
Fn = (typeof(__palignrs) *)((uintptr_t)&__palignrs + Vimm * 8); \
*Xmm0 = Fn(*Xmm1, *Xmm2); \
} else { \
memset(Xmm0, 0, 16); \
} \
} \
} else { \
palignr(C, B, A, I); \
} \
} while (0)
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/pandn.h */
#define COSMOPOLITAN_LIBC_INTRIN_PANDN_H_
COSMOPOLITAN_C_START_
void pandn(uint64_t[2], const uint64_t[2], const uint64_t[2]);
#define pandn(A, B, C) \
INTRIN_SSEVEX_X_X_X_(pandn, SSE2, "pandn", INTRIN_NONCOMMUTATIVE, A, B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/pcmpgtb.h */
#define COSMOPOLITAN_LIBC_INTRIN_PCMPGTB_H_
COSMOPOLITAN_C_START_
void pcmpgtb(int8_t[16], const int8_t[16], const int8_t[16]);
#define pcmpgtb(A, B, C) \
INTRIN_SSEVEX_X_X_X_(pcmpgtb, SSE2, "pcmpgtb", INTRIN_NONCOMMUTATIVE, A, B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/pcmpgtw.h */
#define COSMOPOLITAN_LIBC_INTRIN_PCMPGTW_H_
COSMOPOLITAN_C_START_
void pcmpgtw(int16_t[8], const int16_t[8], const int16_t[8]);
#define pcmpgtw(A, B, C) \
INTRIN_SSEVEX_X_X_X_(pcmpgtw, SSE2, "pcmpgtw", INTRIN_NONCOMMUTATIVE, A, B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/pmaddubsw.h */
#define COSMOPOLITAN_LIBC_INTRIN_PMADDUBSW_H_
COSMOPOLITAN_C_START_
void pmaddubsw(int16_t[8], const uint8_t[16], const int8_t[16]);
#define pmaddubsw(W, B, C) \
INTRIN_SSEVEX_X_X_X_(pmaddubsw, SSSE3, "pmaddubsw", INTRIN_NONCOMMUTATIVE, \
W, B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/pmovmskb.h */
#define COSMOPOLITAN_LIBC_INTRIN_PMOVMSKB_H_
COSMOPOLITAN_C_START_
uint32_t pmovmskb(const uint8_t[16]);
#if defined(__x86_64__) && defined(__GNUC__)
#define pmovmskb(A) \
({ \
uint32_t Mask; \
if (!IsModeDbg() && X86_HAVE(SSE2)) { \
const __intrin_xmm_t *Xmm = (const __intrin_xmm_t *)(A); \
if (!X86_NEED(AVX)) { \
asm("pmovmskb\t%1,%0" : "=r"(Mask) : "x"(*Xmm)); \
} else { \
asm("vpmovmskb\t%1,%0" : "=r"(Mask) : "x"(*Xmm)); \
} \
} else { \
Mask = pmovmskb(A); \
} \
Mask; \
})
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/pmulhrsw.h */
#define COSMOPOLITAN_LIBC_INTRIN_PMULHRSW_H_
COSMOPOLITAN_C_START_
void pmulhrsw(int16_t a[8], const int16_t b[8], const int16_t c[8]);
#define pmulhrsw(A, B, C) \
INTRIN_SSEVEX_X_X_X_(pmulhrsw, SSSE3, "pmulhrsw", INTRIN_COMMUTATIVE, A, B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/popcnt.h */
#define COSMOPOLITAN_LIBC_BITS_POPCNT_H_
COSMOPOLITAN_C_START_
libcesque size_t _countbits(const void *, size_t);
libcesque unsigned long popcnt(unsigned long) pureconst;
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && defined(__x86_64__)
#define popcnt(X) \
(__builtin_constant_p(X) ? __builtin_popcountll(X) : ({ \
unsigned long PoP = (X); \
if (X86_HAVE(POPCNT)) { \
asm("popcnt\t%0,%0" : "+r"(PoP) : /* no inputs */ : "cc"); \
} else { \
PoP = (popcnt)(PoP); \
} \
PoP; \
}))
#else
#define popcnt(x) __builtin_popcountll(x)
#endif /* GNUC && !ANSI */
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/psraw.h */
#define COSMOPOLITAN_LIBC_INTRIN_PSRAW_H_
COSMOPOLITAN_C_START_
void psraw(int16_t[8], const int16_t[8], unsigned char) libcesque;
void psrawv(int16_t[8], const int16_t[8], const uint64_t[2]) libcesque;
#define psraw(A, B, I) INTRIN_SSEVEX_X_I_(psraw, SSE2, "psraw", A, B, I)
#define psrawv(A, B, C) \
INTRIN_SSEVEX_X_X_X_(psrawv, SSE2, "psraw", INTRIN_NONCOMMUTATIVE, A, B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/punpckhbw.h */
#define COSMOPOLITAN_LIBC_INTRIN_PUNPCKHBW_H_
COSMOPOLITAN_C_START_
void punpckhbw(uint8_t[16], const uint8_t[16], const uint8_t[16]);
#define punpckhbw(A, B, C) \
INTRIN_SSEVEX_X_X_X_(punpckhbw, SSE2, "punpckhbw", INTRIN_NONCOMMUTATIVE, A, \
B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/punpckhwd.h */
#define COSMOPOLITAN_LIBC_INTRIN_PUNPCKHWD_H_
COSMOPOLITAN_C_START_
void punpckhwd(uint16_t[8], const uint16_t[8], const uint16_t[8]);
#define punpckhwd(A, B, C) \
INTRIN_SSEVEX_X_X_X_(punpckhwd, SSE2, "punpckhwd", INTRIN_NONCOMMUTATIVE, A, \
B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/punpcklbw.h */
#define COSMOPOLITAN_LIBC_INTRIN_PUNPCKLBW_H_
COSMOPOLITAN_C_START_
void punpcklbw(uint8_t[16], const uint8_t[16], const uint8_t[16]);
#define punpcklbw(A, B, C) \
INTRIN_SSEVEX_X_X_X_(punpcklbw, SSE2, "punpcklbw", INTRIN_NONCOMMUTATIVE, A, \
B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/punpcklwd.h */
#define COSMOPOLITAN_LIBC_INTRIN_PUNPCKLWD_H_
COSMOPOLITAN_C_START_
void punpcklwd(uint16_t[8], const uint16_t[8], const uint16_t[8]);
#define punpcklwd(A, B, C) \
INTRIN_SSEVEX_X_X_X_(punpcklwd, SSE2, "punpcklwd", INTRIN_NONCOMMUTATIVE, A, \
B, C)
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/repmovsb.h */
#define COSMOPOLITAN_LIBC_INTRIN_REPMOVSB_H_
#ifdef _COSMO_SOURCE
forceinline void repmovsb(void **dest, const void **src, size_t cx) {
char *di = (char *)*dest;
const char *si = (const char *)*src;
while (cx) *di++ = *si++, cx--;
*dest = di, *src = si;
}
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#define repmovsb(DI, SI, CX) \
({ \
void *Di = *(DI); \
const void *Si = *(SI); \
size_t Cx = (CX); \
asm("rep movsb" \
: "=D"(Di), "=S"(Si), "=c"(Cx), "=m"(*(char(*)[Cx])Di) \
: "0"(Di), "1"(Si), "2"(Cx), "m"(*(const char(*)[Cx])Si)); \
*(DI) = Di, *(SI) = Si; \
})
#endif
#endif /* _COSMO_SOURCE */
/*!BEGIN libc/intrin/repstosb.h */
#define COSMOPOLITAN_LIBC_INTRIN_REPSTOSB_H_
#ifdef _COSMO_SOURCE
forceinline void *repstosb(void *dest, unsigned char al, size_t cx) {
unsigned char *di = (unsigned char *)dest;
while (cx) *di++ = al, cx--;
return di;
}
#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
#define repstosb(DI, AL, CX) \
({ \
void *Di = (DI); \
size_t Cx = (CX); \
unsigned char Al = (AL); \
asm("rep stosb %b5,(%0)" \
: "=D"(Di), "=c"(Cx), "=m"(*(char(*)[Cx])Di) \
: "0"(Di), "1"(Cx), "a"(Al)); \
Di; \
})
#endif
#endif /* _COSMO_SOURCE */
/*!BEGIN libc/intrin/ubsan.h */
#define COSMOPOLITAN_LIBC_INTRIN_UBSAN_H_
COSMOPOLITAN_C_START_
extern bool32 __ubsan_strict;
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/ulock.h */
#define COSMOPOLITAN_ULOCK_H_
COSMOPOLITAN_C_START_
/* both wake and wait take one of these */
#define UL_COMPARE_AND_WAIT 1 /* multi-thread */
#define UL_UNFAIR_LOCK 2
#define UL_COMPARE_AND_WAIT_SHARED 3 /* multi-thread/process */
#define UL_UNFAIR_LOCK64_SHARED 4
#define UL_COMPARE_AND_WAIT64 5
#define UL_COMPARE_AND_WAIT64_SHARED 6
#define ULF_WAKE_ALL 0x00000100
#define ULF_WAKE_THREAD 0x00000200 /* takes wake_value */
#define ULF_WAKE_ALLOW_NON_OWNER 0x00000400
#define ULF_WAIT_WORKQ_DATA_CONTENTION 0x00010000
#define ULF_WAIT_CANCEL_POINT 0x00020000 /* raises eintr */
#define ULF_WAIT_ADAPTIVE_SPIN 0x00040000
int ulock_wake(uint32_t, void *, uint64_t) libcesque;
int ulock_wait(uint32_t, void *, uint64_t, uint32_t) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/intrin/weaken.h */
#define COSMOPOLITAN_LIBC_BITS_WEAKEN_H_
#ifndef __chibicc__
#define _weaken(symbol) \
__extension__({ \
extern __typeof__(symbol) symbol __attribute__((__weak__)); \
&symbol; \
})
#else
#define _weaken(symbol) (&(symbol))
#endif
/*!BEGIN libc/intrin/x86.h */
#define COSMOPOLITAN_LIBC_INTRIN_X86_H_
COSMOPOLITAN_C_START_
enum VendorSignatures {
SIG_INTEL = 0x756e6547, /* Genu */
SIG_AMD = 0x68747541, /* Auth */
};
enum ProcessorVendors {
VENDOR_INTEL = 1,
VENDOR_AMD,
VENDOR_OTHER,
VENDOR_MAX
};
enum ProcessorTypes {
INTEL_BONNELL = 1,
INTEL_CORE2,
INTEL_COREI7,
AMDFAM10H,
AMDFAM15H,
INTEL_SILVERMONT,
INTEL_KNL,
AMD_BTVER1,
AMD_BTVER2,
AMDFAM17H,
INTEL_KNM,
INTEL_GOLDMONT,
INTEL_GOLDMONT_PLUS,
INTEL_TREMONT,
AMDFAM19H,
ZHAOXIN_FAM7H,
INTEL_SIERRAFOREST,
INTEL_GRANDRIDGE,
INTEL_CLEARWATERFOREST,
CPU_TYPE_MAX
};
enum ProcessorSubtypes {
INTEL_COREI7_NEHALEM = 1,
INTEL_COREI7_WESTMERE,
INTEL_COREI7_SANDYBRIDGE,
AMDFAM10H_BARCELONA,
AMDFAM10H_SHANGHAI,
AMDFAM10H_ISTANBUL,
AMDFAM15H_BDVER1,
AMDFAM15H_BDVER2,
AMDFAM15H_BDVER3,
AMDFAM15H_BDVER4,
AMDFAM17H_ZNVER1,
INTEL_COREI7_IVYBRIDGE,
INTEL_COREI7_HASWELL,
INTEL_COREI7_BROADWELL,
INTEL_COREI7_SKYLAKE,
INTEL_COREI7_SKYLAKE_AVX512,
INTEL_COREI7_CANNONLAKE,
INTEL_COREI7_ICELAKE_CLIENT,
INTEL_COREI7_ICELAKE_SERVER,
AMDFAM17H_ZNVER2,
INTEL_COREI7_CASCADELAKE,
INTEL_COREI7_TIGERLAKE,
INTEL_COREI7_COOPERLAKE,
INTEL_COREI7_SAPPHIRERAPIDS,
INTEL_COREI7_ALDERLAKE,
AMDFAM19H_ZNVER3,
INTEL_COREI7_ROCKETLAKE,
ZHAOXIN_FAM7H_LUJIAZUI,
AMDFAM19H_ZNVER4,
INTEL_COREI7_GRANITERAPIDS,
INTEL_COREI7_GRANITERAPIDS_D,
INTEL_COREI7_ARROWLAKE,
INTEL_COREI7_ARROWLAKE_S,
INTEL_COREI7_PANTHERLAKE,
CPU_SUBTYPE_MAX
};
enum ProcessorFeatures {
FEATURE_CMOV = 0,
FEATURE_MMX,
FEATURE_POPCNT,
FEATURE_SSE,
FEATURE_SSE2,
FEATURE_SSE3,
FEATURE_SSSE3,
FEATURE_SSE4_1,
FEATURE_SSE4_2,
FEATURE_AVX,
FEATURE_AVX2,
FEATURE_SSE4_A,
FEATURE_FMA4,
FEATURE_XOP,
FEATURE_FMA,
FEATURE_AVX512F,
FEATURE_BMI,
FEATURE_BMI2,
FEATURE_AES,
FEATURE_PCLMUL,
FEATURE_AVX512VL,
FEATURE_AVX512BW,
FEATURE_AVX512DQ,
FEATURE_AVX512CD,
FEATURE_AVX512ER,
FEATURE_AVX512PF,
FEATURE_AVX512VBMI,
FEATURE_AVX512IFMA,
FEATURE_AVX5124VNNIW,
FEATURE_AVX5124FMAPS,
FEATURE_AVX512VPOPCNTDQ,
FEATURE_AVX512VBMI2,
FEATURE_GFNI,
FEATURE_VPCLMULQDQ,
FEATURE_AVX512VNNI,
FEATURE_AVX512BITALG,
FEATURE_AVX512BF16,
FEATURE_AVX512VP2INTERSECT,
FEATURE_CMPXCHG16B = 46,
FEATURE_F16C = 49,
FEATURE_LAHF_LM = 54,
FEATURE_LM,
FEATURE_WP,
FEATURE_LZCNT,
FEATURE_MOVBE,
FEATURE_AVX512FP16 = 94,
FEATURE_X86_64_BASELINE,
FEATURE_X86_64_V2,
FEATURE_X86_64_V3,
FEATURE_X86_64_V4,
CPU_FEATURE_MAX
};
struct __processor_model {
unsigned __cpu_vendor;
unsigned __cpu_type;
unsigned __cpu_subtype;
unsigned __cpu_features[1];
const char *__cpu_march;
};
extern struct __processor_model __cpu_model;
const char *__cpu_march(unsigned);
COSMOPOLITAN_C_END_
/*!BEGIN libc/log/bsd.h */
#define COSMOPOLITAN_LIBC_LOG_BSD_H_
COSMOPOLITAN_C_START_
void err(int, const char *, ...) wontreturn;
void verr(int, const char *, va_list) wontreturn;
void errc(int, int, const char *, ...) wontreturn;
void verrc(int, int, const char *, va_list) wontreturn;
void errx(int, const char *, ...) wontreturn;
void verrx(int, const char *, va_list) wontreturn;
void warn(const char *, ...);
void vwarn(const char *, va_list);
void warnc(int, const char *, ...);
void vwarnc(int, const char *, va_list);
void warnx(const char *, ...);
void vwarnx(const char *, va_list);
void err_set_exit(void (*)(int));
COSMOPOLITAN_C_END_
/*!BEGIN libc/log/check.h */
#define COSMOPOLITAN_LIBC_LOG_CHECK_H_
COSMOPOLITAN_C_START_
#define CHECK(X, ...) __CHK(ne, !=, false, "false", !!(X), #X, "" __VA_ARGS__)
#define CHECK_EQ(Y, X, ...) __CHK(eq, ==, Y, #Y, X, #X, "" __VA_ARGS__)
#define CHECK_NE(Y, X, ...) __CHK(ne, !=, Y, #Y, X, #X, "" __VA_ARGS__)
#define CHECK_LE(Y, X, ...) __CHK(le, <=, Y, #Y, X, #X, "" __VA_ARGS__)
#define CHECK_LT(Y, X, ...) __CHK(lt, <, Y, #Y, X, #X, "" __VA_ARGS__)
#define CHECK_GE(Y, X, ...) __CHK(ge, >=, Y, #Y, X, #X, "" __VA_ARGS__)
#define CHECK_GT(Y, X, ...) __CHK(gt, >, Y, #Y, X, #X, "" __VA_ARGS__)
#define CHECK_NOTNULL(X, ...) __CHK(ne, !=, NULL, "NULL", X, #X, "" __VA_ARGS__)
#define DCHECK(X, ...) __DCHK(ne, !=, false, "false", !!(X), #X, "" __VA_ARGS__)
#define DCHECK_EQ(Y, X, ...) __DCHK(eq, ==, Y, #Y, X, #X, "" __VA_ARGS__)
#define DCHECK_NE(Y, X, ...) __DCHK(ne, !=, Y, #Y, X, #X, "" __VA_ARGS__)
#define DCHECK_LE(Y, X, ...) __DCHK(le, <=, Y, #Y, X, #X, "" __VA_ARGS__)
#define DCHECK_LT(Y, X, ...) __DCHK(lt, <, Y, #Y, X, #X, "" __VA_ARGS__)
#define DCHECK_GE(Y, X, ...) __DCHK(ge, >=, Y, #Y, X, #X, "" __VA_ARGS__)
#define DCHECK_GT(Y, X, ...) __DCHK(gt, >, Y, #Y, X, #X, "" __VA_ARGS__)
#define DCHECK_NOTNULL(X, ...) \
__DCHK(ne, !=, NULL, "NULL", X, #X, "" __VA_ARGS__)
#define CHECK_ALIGNED(BYTES, VAR, ...) \
do { \
if (((uintptr_t)VAR & ((BYTES)-1u))) { \
__check_fail_aligned(BYTES, (uintptr_t)VAR, __FILE__, __LINE__, \
"" __VA_ARGS__); \
__builtin_unreachable(); \
} \
VAR = (typeof(VAR))__builtin_assume_aligned(VAR, BYTES); \
} while (0)
#define DCHECK_ALIGNED(BYTES, VAR, ...) \
do { \
if (((uintptr_t)VAR & ((BYTES)-1u))) { \
__DCHK_ALIGNED(BYTES, (uintptr_t)VAR, "" __VA_ARGS__); \
__builtin_unreachable(); \
} \
VAR = (typeof(VAR))__builtin_assume_aligned(VAR, BYTES); \
} while (0)
#define __CHK(SUFFIX, OP, WANT, WANTSTR, GOT, GOTSTR, ...) \
do { \
autotype(GOT) Got = (GOT); \
autotype(WANT) Want = (WANT); \
if (!(Want OP Got)) { \
if (!NoDebug()) { \
__check_fail(#SUFFIX, #OP, (uint64_t)Want, (WANTSTR), (uint64_t)Got, \
(GOTSTR), __FILE__, __LINE__, __VA_ARGS__); \
} else { \
__check_fail_##SUFFIX((uint64_t)Want, (uint64_t)Got, __FILE__, \
__LINE__, 0, __VA_ARGS__); \
} \
__builtin_unreachable(); \
} \
} while (0)
#ifdef NDEBUG
#define __DCHK(SUFFIX, OP, WANT, WANTSTR, GOT, ...) \
do { \
autotype(GOT) Got = (GOT); \
autotype(WANT) Want = (WANT); \
if (!(Want OP Got)) { \
__builtin_unreachable(); \
} \
} while (0)
#else
#define __DCHK(SUFFIX, OP, WANT, WANTSTR, GOT, GOTSTR, ...) \
__CHK(SUFFIX, OP, WANT, WANTSTR, GOT, GOTSTR, __VA_ARGS__)
#endif /* NDEBUG */
#ifdef NDEBUG
#define __DCHK_ALIGNED(BYTES, VAR, ...)
#else
#define __DCHK_ALIGNED(BYTES, VAR, ...) \
__check_fail_aligned(BYTES, VAR, __FILE__, __LINE__, __VA_ARGS__)
#endif
void __check_fail(const char *, const char *, uint64_t, const char *, uint64_t,
const char *, const char *, int, const char *,
...) relegated wontreturn;
void __check_fail_eq(uint64_t, uint64_t, const char *, int, const char *,
const char *, ...) relegated wontreturn;
void __check_fail_ne(uint64_t, uint64_t, const char *, int, const char *,
const char *, ...) relegated wontreturn;
void __check_fail_le(uint64_t, uint64_t, const char *, int, const char *,
const char *, ...) relegated wontreturn;
void __check_fail_lt(uint64_t, uint64_t, const char *, int, const char *,
const char *, ...) relegated wontreturn;
void __check_fail_ge(uint64_t, uint64_t, const char *, int, const char *,
const char *, ...) relegated wontreturn;
void __check_fail_gt(uint64_t, uint64_t, const char *, int, const char *,
const char *, ...) relegated wontreturn;
void __check_fail_aligned(unsigned, uint64_t, const char *, int, const char *,
...) relegated wontreturn;
#ifdef __VSCODE_INTELLISENSE__
#undef __CHK
#define __CHK(...)
#undef __DCHK
#define __DCHK(...)
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/log/countbranch.h */
#define COSMOPOLITAN_LIBC_LOG_COUNTBRANCH_H_
COSMOPOLITAN_C_START_
#define COUNTBRANCH(x) COUNTBRANCH_(x, #x, STRINGIFY(__FILE__), __LINE__)
#define COUNTBRANCH_(x, xs, file, line) \
COUNTBRANCH__(x, STRINGIFY(xs), STRINGIFY(xs), file, line)
#define COUNTBRANCH__(x, xs, xss, file, line) \
({ \
bool Cond; \
struct countbranch *Info; \
asm(".section .rodata.str1.1,\"aMS\",@progbits,1\n\t" \
".balign\t1\n" \
"31338:\t" \
".asciz\t" xs "\n" \
"31339:\t" \
".asciz\t" xss "\n" \
"31340:\t" \
".asciz\t" file "\n\t" \
".previous\n\t" \
".section .yoink\n\t" \
"nopl\tcountbranch_data(%%rip)\n\t" \
".previous\n\t" \
".section .sort.data.countbranch.2,\"a\",@progbits\n\t" \
".balign\t8\n31337:\t" \
".quad\t0\n\t" \
".quad\t0\n\t" \
".quad\t31338b\n\t" \
".quad\t31339b\n\t" \
".quad\t31340b\n\t" \
".quad\t" #line "\n\t" \
".previous\n\t" \
"lea\t31337b(%%rip),%0" \
: "=r"(Info)); \
Cond = (x); \
++Info->total; \
if (Cond) ++Info->taken; \
Cond; \
})
struct countbranch {
long total;
long taken;
const char *code;
const char *xcode;
const char *file;
long line;
};
extern struct countbranch countbranch_data[];
void countbranch_report(void);
COSMOPOLITAN_C_END_
/*!BEGIN libc/log/countexpr.h */
#define COSMOPOLITAN_LIBC_LOG_COUNTEXPR_H_
/*!BEGIN libc/nexgen32e/bench.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_BENCH_H_
/*!BEGIN libc/nexgen32e/rdtsc.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_RDTSC_H_
COSMOPOLITAN_C_START_
/**
* Reads CPU timestamp counter.
*
* This macro inhibits compiler magic.
* This macro does not inhibit CPU magic.
*
* @see X86_HAVE(INVTSC)
*/
#define rdtsc() __RDTSC("rdtsc")
/**
* Reads CPU timestamp counter w/ full serialization.
*
* This macro inhibits CPU magic.
* This macro inhibits compiler magic.
*
* The clock isn't read until:
*
* 1. previous instructions finish executing; and
* 2. previous loads are globally visible; and
* 3. previous stores are globally visible.
*
* Later instructions won't dispatch until RDTSC completes.
*
* @see X86_HAVE(INVTSC)
*/
#define mfence_lfence_rdtsc_lfence() \
__RDTSC("mfence\n\tlfence\n\trdtsc\n\tlfence")
#ifdef __x86__
#define __RDTSC(ASM) \
({ \
uint64_t Rax, Rdx; \
asm volatile(ASM : "=a"(Rax), "=d"(Rdx) : /* no inputs */ : "memory"); \
Rdx << 32 | Rax; \
})
#elif defined(__aarch64__)
#define __RDTSC(ASM) \
({ \
uint64_t _Ts; \
asm volatile("mrs\t%0,cntvct_el0" : "=r"(_Ts)); \
_Ts * 48; /* the fudge factor */ \
})
#elif defined(__powerpc64__)
#define __RDTSC(ASM) \
({ \
uint64_t _Ts; \
asm volatile("mfspr\t%0,268" : "=r"(_Ts)); \
_Ts; \
})
#elif defined(__riscv)
#define __RDTSC(ASM) \
({ \
uint64_t _Ts; \
asm volatile("rdcycle\t%0" : "=r"(_Ts)); \
_Ts; \
})
#endif
COSMOPOLITAN_C_END_
/**
* @fileoverview NexGen32e Microbenchmarking.
*
* @see X86_HAVE(INVTSC)
* @see libc/testlib/bench.h
*/
#ifdef __x86__
#define __startbench() \
({ \
uint64_t Ticks; \
asm volatile("lfence\n\t" \
"push\t%%rbx\n\t" \
"cpuid\n\t" \
"pop\t%%rbx\n\t" \
"rdtsc\n\t" \
"shl\t%2,%%rdx\n\t" \
"or\t%%rdx,%0" \
: "=a"(Ticks) \
: "0"(0), "J"(32) \
: "rcx", "rdx", "memory", "cc"); \
Ticks; \
})
#define __endbench() \
({ \
uint64_t Ticks; \
asm volatile("rdtscp\n\t" \
"shl\t%1,%%rdx\n\t" \
"or\t%%rdx,%%rax\n\t" \
"mov\t%%rax,%0\n\t" \
"xor\t%%eax,%%eax\n\t" \
"push\t%%rbx\n\t" \
"cpuid\n\t" \
"pop\t%%rbx" \
: "=r"(Ticks) \
: "J"(32) \
: "rax", "rcx", "rdx", "memory", "cc"); \
Ticks; \
})
#else
#define __startbench() \
({ \
uint64_t _ts; \
asm volatile("isb" ::: "memory"); \
_ts = rdtsc(); \
asm volatile("isb" ::: "memory"); \
_ts; \
})
#define __endbench() \
({ \
uint64_t _ts; \
asm volatile("isb" ::: "memory"); \
_ts = rdtsc(); \
asm volatile("isb" ::: "memory"); \
_ts; \
})
#endif
#define __startbench_m() mfence_lfence_rdtsc_lfence()
#define __endbench_m() __startbench_m()
#define __marker() asm("nop")
#define __ordered() asm volatile("" ::: "memory")
#define __fakeread(X) asm volatile("" : /* no outputs */ : "g"(X))
#define __fakereadwrite(X) \
({ \
autotype(X) Res = (X); \
asm volatile("" : "=g"(Res) : "0"(X)); \
Res; \
})
COSMOPOLITAN_C_START_
/**
* Shows nanosecond timings histogram for expr at exit().
*/
#define COUNTEXPR(expr) \
COUNTEXPR_(expr, #expr, STRINGIFY(__FILE__), __LINE__, rdtsc, rdtsc, \
"COUNTEXPR")
/**
* Like COUNTEXPR() but can be used on function calls that return void.
*/
#define COUNTSTMT(stmt) \
(void)COUNTEXPR_((stmt, 0), #stmt, STRINGIFY(__FILE__), __LINE__, rdtsc, \
rdtsc, "COUNTSTMT")
/**
* Same as COUNTEXPR() but uses Intel's expensive measurement technique.
*/
#define BENCHEXPR(expr) \
COUNTEXPR_(expr, #expr, STRINGIFY(__FILE__), __LINE__, __startbench, \
__endbench, "BENCHEXPR")
#define COUNTEXPR_(expr, code, file, line, start, stop, macro) \
COUNTEXPR__(expr, STRINGIFY(code), file, line, start, stop, STRINGIFY(macro))
#define COUNTEXPR__(expr, code, file, line, start, stop, macro) \
({ \
struct countexpr *InfO; \
uint64_t t1_, t2_, TiCkS, NaNoS; \
t1_ = start(); \
asm volatile("" ::: "memory"); \
autotype(expr) ReS = (expr); \
asm volatile("" ::: "memory"); \
t2_ = stop(); \
TiCkS = t2_ >= t1_ ? t2_ - t1_ : ~t1_ + t2_ + 1; \
asm(".section .rodata.str1.1,\"aMS\",@progbits,1\n\t" \
".balign\t1\n" \
"31340:\t.asciz\t" file "\n\t" \
"31338:\t.asciz\t" code "\n" \
"31332:\t.asciz\t" macro "\n" \
".previous\n\t" \
".section .yoink\n\t" \
"nopl\tcountexpr_data(%%rip)\n\t" \
".previous\n\t" \
".section .sort.data.countexpr.2,\"a\",@progbits\n\t" \
".balign\t8\n31337:\t" \
".quad\t" #line "\n\t" \
".quad\t31340b\n\t" \
".quad\t31338b\n\t" \
".quad\t31332b\n\t" \
".rept\t65\n\t" \
".quad\t0\n\t" \
".endr\n\t" \
".previous\n\t" \
"lea\t31337b(%%rip),%0" \
: "=r"(InfO)); \
/* approximation of round(x*.323018) which is usually */ \
/* the ratio, between x86 rdtsc ticks and nanoseconds */ \
NaNoS = (TiCkS * 338709) >> 20; \
++InfO->logos[NaNoS ? bsrl(NaNoS) + 1 : 0]; \
ReS; \
})
struct countexpr {
long line; /* zero for last entry */
const char *file;
const char *code;
const char *macro;
long logos[65];
};
extern struct countexpr countexpr_data[];
void countexpr_report(void);
COSMOPOLITAN_C_END_
/*!BEGIN libc/log/gdb.h */
#define COSMOPOLITAN_LIBC_LOG_GDB_H_
/*!BEGIN libc/sysv/consts/nr.h */
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_NR_H_
#ifdef _COSMO_SOURCE
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
extern const int __NR_exit;
extern const int __NR_exit_group;
extern const int __NR_read;
extern const int __NR_write;
extern const int __NR_open;
extern const int __NR_close;
extern const int __NR_stat;
extern const int __NR_fstat;
extern const int __NR_lstat;
extern const int __NR_poll;
extern const int __NR_ppoll;
extern const int __NR_lseek;
extern const int __NR_mmap;
extern const int __NR_msync;
extern const int __NR_mprotect;
extern const int __NR_munmap;
extern const int __NR_sigaction;
extern const int __NR_sigprocmask;
extern const int __NR_ioctl;
extern const int __NR_pread;
extern const int __NR_pwrite;
extern const int __NR_readv;
extern const int __NR_writev;
extern const int __NR_access;
extern const int __NR_pipe;
extern const int __NR_select;
extern const int __NR_pselect;
extern const int __NR_pselect6;
extern const int __NR_sched_yield;
extern const int __NR_mremap;
extern const int __NR_mincore;
extern const int __NR_madvise;
extern const int __NR_shmget;
extern const int __NR_shmat;
extern const int __NR_shmctl;
extern const int __NR_dup;
extern const int __NR_dup2;
extern const int __NR_pause;
extern const int __NR_nanosleep;
extern const int __NR_getitimer;
extern const int __NR_setitimer;
extern const int __NR_alarm;
extern const int __NR_getpid;
extern const int __NR_sendfile;
extern const int __NR_socket;
extern const int __NR_connect;
extern const int __NR_accept;
extern const int __NR_sendto;
extern const int __NR_recvfrom;
extern const int __NR_sendmsg;
extern const int __NR_recvmsg;
extern const int __NR_shutdown;
extern const int __NR_bind;
extern const int __NR_listen;
extern const int __NR_getsockname;
extern const int __NR_getpeername;
extern const int __NR_socketpair;
extern const int __NR_setsockopt;
extern const int __NR_getsockopt;
extern const int __NR_fork;
extern const int __NR_vfork;
extern const int __NR_posix_spawn;
extern const int __NR_execve;
extern const int __NR_wait4;
extern const int __NR_kill;
extern const int __NR_killpg;
extern const int __NR_clone;
extern const int __NR_tkill;
extern const int __NR_futex;
extern const int __NR_set_robust_list;
extern const int __NR_get_robust_list;
extern const int __NR_uname;
extern const int __NR_semget;
extern const int __NR_semop;
extern const int __NR_semctl;
extern const int __NR_shmdt;
extern const int __NR_msgget;
extern const int __NR_msgsnd;
extern const int __NR_msgrcv;
extern const int __NR_msgctl;
extern const int __NR_fcntl;
extern const int __NR_flock;
extern const int __NR_fsync;
extern const int __NR_fdatasync;
extern const int __NR_truncate;
extern const int __NR_ftruncate;
extern const int __NR_getcwd;
extern const int __NR_chdir;
extern const int __NR_fchdir;
extern const int __NR_rename;
extern const int __NR_mkdir;
extern const int __NR_rmdir;
extern const int __NR_creat;
extern const int __NR_link;
extern const int __NR_unlink;
extern const int __NR_symlink;
extern const int __NR_readlink;
extern const int __NR_chmod;
extern const int __NR_fchmod;
extern const int __NR_chown;
extern const int __NR_fchown;
extern const int __NR_lchown;
extern const int __NR_umask;
extern const int __NR_gettimeofday;
extern const int __NR_getrlimit;
extern const int __NR_getrusage;
extern const int __NR_sysinfo;
extern const int __NR_times;
extern const int __NR_ptrace;
extern const int __NR_syslog;
extern const int __NR_getuid;
extern const int __NR_getgid;
extern const int __NR_getppid;
extern const int __NR_getpgrp;
extern const int __NR_setsid;
extern const int __NR_getsid;
extern const int __NR_getpgid;
extern const int __NR_setpgid;
extern const int __NR_geteuid;
extern const int __NR_getegid;
extern const int __NR_getgroups;
extern const int __NR_setgroups;
extern const int __NR_setreuid;
extern const int __NR_setregid;
extern const int __NR_setuid;
extern const int __NR_setgid;
extern const int __NR_setresuid;
extern const int __NR_setresgid;
extern const int __NR_getresuid;
extern const int __NR_getresgid;
extern const int __NR_sigpending;
extern const int __NR_sigsuspend;
extern const int __NR_sigaltstack;
extern const int __NR_mknod;
extern const int __NR_mknodat;
extern const int __NR_mkfifo;
extern const int __NR_mkfifoat;
extern const int __NR_statfs;
extern const int __NR_fstatfs;
extern const int __NR_getpriority;
extern const int __NR_setpriority;
extern const int __NR_mlock;
extern const int __NR_munlock;
extern const int __NR_mlockall;
extern const int __NR_munlockall;
extern const int __NR_setrlimit;
extern const int __NR_chroot;
extern const int __NR_sync;
extern const int __NR_acct;
extern const int __NR_settimeofday;
extern const int __NR_mount;
extern const int __NR_reboot;
extern const int __NR_quotactl;
extern const int __NR_setfsuid;
extern const int __NR_setfsgid;
extern const int __NR_capget;
extern const int __NR_capset;
extern const int __NR_sigtimedwait;
extern const int __NR_sigqueueinfo;
extern const int __NR_personality;
extern const int __NR_ustat;
extern const int __NR_sysfs;
extern const int __NR_sched_setparam;
extern const int __NR_sched_getparam;
extern const int __NR_sched_setscheduler;
extern const int __NR_sched_getscheduler;
extern const int __NR_sched_get_priority_max;
extern const int __NR_sched_get_priority_min;
extern const int __NR_sched_rr_get_interval;
extern const int __NR_vhangup;
extern const int __NR_modify_ldt;
extern const int __NR_pivot_root;
extern const int __NR__sysctl;
extern const int __NR_prctl;
extern const int __NR_arch_prctl;
extern const int __NR_adjtimex;
extern const int __NR_umount2;
extern const int __NR_swapon;
extern const int __NR_swapoff;
extern const int __NR_sethostname;
extern const int __NR_setdomainname;
extern const int __NR_iopl;
extern const int __NR_ioperm;
extern const int __NR_init_module;
extern const int __NR_delete_module;
extern const int __NR_gettid;
extern const int __NR_readahead;
extern const int __NR_setxattr;
extern const int __NR_fsetxattr;
extern const int __NR_getxattr;
extern const int __NR_fgetxattr;
extern const int __NR_listxattr;
extern const int __NR_flistxattr;
extern const int __NR_removexattr;
extern const int __NR_fremovexattr;
extern const int __NR_lsetxattr;
extern const int __NR_lgetxattr;
extern const int __NR_llistxattr;
extern const int __NR_lremovexattr;
extern const int __NR_sched_setaffinity;
extern const int __NR_sched_getaffinity;
extern const int __NR_cpuset_getaffinity;
extern const int __NR_cpuset_setaffinity;
extern const int __NR_io_setup;
extern const int __NR_io_destroy;
extern const int __NR_io_getevents;
extern const int __NR_io_submit;
extern const int __NR_io_cancel;
extern const int __NR_lookup_dcookie;
extern const int __NR_epoll_create;
extern const int __NR_epoll_wait;
extern const int __NR_epoll_ctl;
extern const int __NR_getdents;
extern const int __NR_set_tid_address;
extern const int __NR_restart_syscall;
extern const int __NR_semtimedop;
extern const int __NR_fadvise;
extern const int __NR_timer_create;
extern const int __NR_timer_settime;
extern const int __NR_timer_gettime;
extern const int __NR_timer_getoverrun;
extern const int __NR_timer_delete;
extern const int __NR_clock_settime;
extern const int __NR_clock_gettime;
extern const int __NR_clock_getres;
extern const int __NR_clock_nanosleep;
extern const int __NR_tgkill;
extern const int __NR_mbind;
extern const int __NR_set_mempolicy;
extern const int __NR_get_mempolicy;
extern const int __NR_mq_open;
extern const int __NR_mq_unlink;
extern const int __NR_mq_timedsend;
extern const int __NR_mq_timedreceive;
extern const int __NR_mq_notify;
extern const int __NR_mq_getsetattr;
extern const int __NR_kexec_load;
extern const int __NR_waitid;
extern const int __NR_add_key;
extern const int __NR_request_key;
extern const int __NR_keyctl;
extern const int __NR_ioprio_set;
extern const int __NR_ioprio_get;
extern const int __NR_inotify_init;
extern const int __NR_inotify_add_watch;
extern const int __NR_inotify_rm_watch;
extern const int __NR_openat;
extern const int __NR_mkdirat;
extern const int __NR_fchownat;
extern const int __NR_utime;
extern const int __NR_utimes;
extern const int __NR_futimesat;
extern const int __NR_futimes;
extern const int __NR_futimens;
extern const int __NR_fstatat;
extern const int __NR_unlinkat;
extern const int __NR_renameat;
extern const int __NR_linkat;
extern const int __NR_symlinkat;
extern const int __NR_readlinkat;
extern const int __NR_fchmodat;
extern const int __NR_faccessat;
extern const int __NR_unshare;
extern const int __NR_splice;
extern const int __NR_tee;
extern const int __NR_vmsplice;
extern const int __NR_migrate_pages;
extern const int __NR_move_pages;
extern const int __NR_preadv;
extern const int __NR_pwritev;
extern const int __NR_utimensat;
extern const int __NR_fallocate;
extern const int __NR_posix_fallocate;
extern const int __NR_accept4;
extern const int __NR_dup3;
extern const int __NR_pipe2;
extern const int __NR_epoll_pwait;
extern const int __NR_epoll_create1;
extern const int __NR_perf_event_open;
extern const int __NR_inotify_init1;
extern const int __NR_tgsigqueueinfo;
extern const int __NR_signalfd;
extern const int __NR_signalfd4;
extern const int __NR_eventfd;
extern const int __NR_eventfd2;
extern const int __NR_timerfd_create;
extern const int __NR_timerfd_settime;
extern const int __NR_timerfd_gettime;
extern const int __NR_recvmmsg;
extern const int __NR_fanotify_init;
extern const int __NR_fanotify_mark;
extern const int __NR_prlimit;
extern const int __NR_name_to_handle_at;
extern const int __NR_open_by_handle_at;
extern const int __NR_clock_adjtime;
extern const int __NR_syncfs;
extern const int __NR_sendmmsg;
extern const int __NR_setns;
extern const int __NR_getcpu;
extern const int __NR_process_vm_readv;
extern const int __NR_process_vm_writev;
extern const int __NR_kcmp;
extern const int __NR_finit_module;
extern const int __NR_sched_setattr;
extern const int __NR_sched_getattr;
extern const int __NR_renameat2;
extern const int __NR_seccomp;
extern const int __NR_getrandom;
extern const int __NR_memfd_create;
extern const int __NR_kexec_file_load;
extern const int __NR_bpf;
extern const int __NR_execveat;
extern const int __NR_userfaultfd;
extern const int __NR_membarrier;
extern const int __NR_mlock2;
extern const int __NR_copy_file_range;
extern const int __NR_preadv2;
extern const int __NR_pwritev2;
extern const int __NR_pkey_mprotect;
extern const int __NR_pkey_alloc;
extern const int __NR_pkey_free;
extern const int __NR_statx;
extern const int __NR_io_pgetevents;
extern const int __NR_rseq;
extern const int __NR_pidfd_send_signal;
extern const int __NR_io_uring_setup;
extern const int __NR_io_uring_enter;
extern const int __NR_io_uring_register;
extern const int __NR_pledge;
extern const int __NR_msyscall;
extern const int __NR_ktrace;
COSMOPOLITAN_C_END_
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
#endif /* _COSMO_SOURCE */
/*!BEGIN libc/sysv/consts/w.h */
#define COSMOPOLITAN_LIBC_SYSV_CONSTS_W_H_
COSMOPOLITAN_C_START_
extern const int WNOHANG;
extern const int WUNTRACED;
extern const int WCONTINUED;
#define WNOHANG 1
#define WUNTRACED WUNTRACED
#define WCONTINUED WCONTINUED
COSMOPOLITAN_C_END_
COSMOPOLITAN_C_START_
/**
* @fileoverview GDB Attach Support Code.
*
* The goal of these macros is to make the backtrace into the failing
* code as short as possible. It also helps avoid GDB getting confused
* about how we don't use its readability destroying unwind directives.
*/
extern volatile int g_gdbsync;
int gdbexec(const char *);
int AttachDebugger(intptr_t);
#define AttachDebugger(CONTINUE_TO_ADDR) /* shorten backtraces */ \
SYNCHRONIZE_DEBUGGER((AttachDebugger)(CONTINUE_TO_ADDR))
#define SYNCHRONIZE_DEBUGGER(PID) \
({ \
int Rc, Pid = (PID); \
if (Pid != -1) { \
while ((Rc = __inline_wait4(Pid, NULL, WNOHANG, NULL)) == 0) { \
if (g_gdbsync) { \
g_gdbsync = 0; \
if (Rc > 0) Pid = 0; \
break; \
} else { \
sched_yield(); \
} \
} \
} \
Pid; \
})
#ifdef __x86_64__
#define __inline_wait4(PID, OPT_OUT_WSTATUS, OPTIONS, OPT_OUT_RUSAGE) \
({ \
int64_t WaAx; \
if (!IsWindows()) { \
asm volatile("mov\t%5,%%r10\n\t" \
"syscall" \
: "=a"(WaAx) \
: "0"(__NR_wait4), "D"(PID), "S"(OPT_OUT_WSTATUS), \
"d"(OPTIONS), "g"(OPT_OUT_RUSAGE) \
: "rcx", "r8", "r9", "r10", "r11", "memory", "cc"); \
} else { \
WaAx = sys_wait4_nt(PID, OPT_OUT_WSTATUS, OPTIONS, OPT_OUT_RUSAGE); \
} \
WaAx; \
})
#else
#define __inline_wait4 wait4
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/log/log.h */
#ifndef COSMOPOLITAN_LIBC_LOG_LOG_H_
#define COSMOPOLITAN_LIBC_LOG_LOG_H_
/*!BEGIN libc/stdio/stdio.h */
#define COSMOPOLITAN_LIBC_STDIO_H_
#define EOF -1 /* end of file */
#define WEOF -1u /* end of file (multibyte) */
#define _IOFBF 0 /* fully buffered */
#define _IOLBF 1 /* line buffered */
#define _IONBF 2 /* no buffering */
#define L_tmpnam 20
#define L_ctermid 20
#define P_tmpdir "/tmp"
#define FILENAME_MAX 1024
#define FOPEN_MAX 1000
#define TMP_MAX 10000
#define BUFSIZ 4096
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § standard i/o ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
struct FILE;
typedef struct FILE FILE;
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
errno_t ferror(FILE *) libcesque paramsnonnull();
void clearerr(FILE *) libcesque paramsnonnull();
int feof(FILE *) libcesque paramsnonnull();
int getc(FILE *) libcesque paramsnonnull();
int putc(int, FILE *) libcesque paramsnonnull();
int fflush(FILE *) libcesque;
int fpurge(FILE *) libcesque;
int fgetc(FILE *) libcesque paramsnonnull();
char *fgetln(FILE *, size_t *) libcesque paramsnonnull((1));
int ungetc(int, FILE *) libcesque paramsnonnull();
int fileno(FILE *) libcesque paramsnonnull() nosideeffect;
int fputc(int, FILE *) libcesque paramsnonnull();
int fputs(const char *, FILE *) libcesque paramsnonnull();
int fputws(const wchar_t *, FILE *) libcesque paramsnonnull();
void flockfile(FILE *) libcesque paramsnonnull();
void funlockfile(FILE *) libcesque paramsnonnull();
int ftrylockfile(FILE *) libcesque paramsnonnull();
char *fgets(char *, int, FILE *) libcesque paramsnonnull();
wchar_t *fgetws(wchar_t *, int, FILE *) libcesque paramsnonnull();
wint_t putwc(wchar_t, FILE *) libcesque paramsnonnull();
wint_t fputwc(wchar_t, FILE *) libcesque paramsnonnull();
wint_t putwchar(wchar_t) libcesque;
wint_t getwchar(void) libcesque;
wint_t getwc(FILE *) libcesque paramsnonnull();
wint_t fgetwc(FILE *) libcesque paramsnonnull();
wint_t ungetwc(wint_t, FILE *) libcesque paramsnonnull();
int getchar(void) libcesque;
int putchar(int) libcesque;
int puts(const char *) libcesque;
ssize_t getline(char **, size_t *, FILE *) libcesque paramsnonnull();
ssize_t getdelim(char **, size_t *, int, FILE *) libcesque paramsnonnull();
FILE *fopen(const char *, const char *) libcesque paramsnonnull((2)) __wur;
FILE *fdopen(int, const char *) libcesque paramsnonnull() __wur;
FILE *fmemopen(void *, size_t, const char *) libcesque paramsnonnull((3)) __wur;
FILE *freopen(const char *, const char *, FILE *) paramsnonnull((2, 3));
size_t fread(void *, size_t, size_t, FILE *) libcesque paramsnonnull((4));
size_t fwrite(const void *, size_t, size_t, FILE *) paramsnonnull((4));
int fclose(FILE *) libcesque;
int fseek(FILE *, long, int) libcesque paramsnonnull();
long ftell(FILE *) libcesque paramsnonnull();
int fseeko(FILE *, int64_t, int) libcesque paramsnonnull();
int64_t ftello(FILE *) libcesque paramsnonnull();
void rewind(FILE *) libcesque paramsnonnull();
int fopenflags(const char *) libcesque paramsnonnull();
void setlinebuf(FILE *) libcesque;
void setbuf(FILE *, char *) libcesque;
void setbuffer(FILE *, char *, size_t) libcesque;
int setvbuf(FILE *, char *, int, size_t) libcesque;
int pclose(FILE *) libcesque;
char *ctermid(char *) libcesque;
void perror(const char *) libcesque relegated;
typedef uint64_t fpos_t;
char *gets(char *) libcesque paramsnonnull();
int fgetpos(FILE *, fpos_t *) libcesque paramsnonnull();
int fsetpos(FILE *, const fpos_t *) libcesque paramsnonnull();
FILE *tmpfile(void) libcesque __wur;
char *tmpnam(char *) libcesque __wur;
char *tmpnam_r(char *) libcesque __wur;
FILE *popen(const char *, const char *) libcesque;
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § standard i/o » formatting ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
int printf(const char *, ...) printfesque(1) paramsnonnull((1)) libcesque;
int vprintf(const char *, va_list) paramsnonnull() libcesque;
int fprintf(FILE *, const char *, ...) printfesque(2)
paramsnonnull((1, 2)) libcesque;
int vfprintf(FILE *, const char *, va_list) paramsnonnull() libcesque;
int scanf(const char *, ...) libcesque scanfesque(1);
int vscanf(const char *, va_list) libcesque;
int fscanf(FILE *, const char *, ...) libcesque scanfesque(2);
int vfscanf(FILE *, const char *, va_list) libcesque;
int snprintf(char *, size_t, const char *, ...) printfesque(3) libcesque;
int vsnprintf(char *, size_t, const char *, va_list) libcesque;
int sprintf(char *, const char *, ...) libcesque;
int vsprintf(char *, const char *, va_list) libcesque;
int fwprintf(FILE *, const wchar_t *, ...) libcesque;
int fwscanf(FILE *, const wchar_t *, ...) libcesque;
int swprintf(wchar_t *, size_t, const wchar_t *, ...) libcesque;
int swscanf(const wchar_t *, const wchar_t *, ...) libcesque;
int vfwprintf(FILE *, const wchar_t *, va_list) libcesque;
int vfwscanf(FILE *, const wchar_t *, va_list) libcesque;
int vswprintf(wchar_t *, size_t, const wchar_t *, va_list) libcesque;
int vswscanf(const wchar_t *, const wchar_t *, va_list) libcesque;
int vwprintf(const wchar_t *, va_list) libcesque;
int vwscanf(const wchar_t *, va_list) libcesque;
int wprintf(const wchar_t *, ...) libcesque;
int wscanf(const wchar_t *, ...) libcesque;
int fwide(FILE *, int) libcesque;
int sscanf(const char *, const char *, ...) libcesque scanfesque(2);
int vsscanf(const char *, const char *, va_list) libcesque;
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § standard i/o » allocating ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
int asprintf(char **, const char *, ...) printfesque(2)
paramsnonnull((1, 2)) libcesque;
int vasprintf(char **, const char *, va_list) paramsnonnull() libcesque;
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § standard i/o » without mutexes ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
int getc_unlocked(FILE *) libcesque paramsnonnull();
int puts_unlocked(const char *) libcesque;
int getchar_unlocked(void) libcesque;
int putc_unlocked(int, FILE *) libcesque paramsnonnull();
int putchar_unlocked(int) libcesque;
void clearerr_unlocked(FILE *) libcesque;
int feof_unlocked(FILE *) libcesque;
int ferror_unlocked(FILE *) libcesque;
int fileno_unlocked(FILE *) libcesque;
int fflush_unlocked(FILE *) libcesque;
int fgetc_unlocked(FILE *) libcesque;
int fputc_unlocked(int, FILE *) libcesque;
size_t fread_unlocked(void *, size_t, size_t, FILE *) libcesque;
size_t fwrite_unlocked(const void *, size_t, size_t, FILE *) libcesque;
char *fgets_unlocked(char *, int, FILE *) libcesque;
int fputs_unlocked(const char *, FILE *) libcesque;
wint_t getwc_unlocked(FILE *) libcesque;
wint_t getwchar_unlocked(void) libcesque;
wint_t fgetwc_unlocked(FILE *) libcesque;
wint_t fputwc_unlocked(wchar_t, FILE *) libcesque;
wint_t putwc_unlocked(wchar_t, FILE *) libcesque;
wint_t putwchar_unlocked(wchar_t) libcesque;
wchar_t *fgetws_unlocked(wchar_t *, int, FILE *) libcesque;
int fputws_unlocked(const wchar_t *, FILE *) libcesque;
wint_t ungetwc_unlocked(wint_t, FILE *) libcesque paramsnonnull();
int ungetc_unlocked(int, FILE *) libcesque paramsnonnull();
int fseek_unlocked(FILE *, int64_t, int) libcesque paramsnonnull();
ssize_t getdelim_unlocked(char **, size_t *, int, FILE *) paramsnonnull();
int fprintf_unlocked(FILE *, const char *, ...) printfesque(2) libcesque;
int vfprintf_unlocked(FILE *, const char *, va_list) paramsnonnull() libcesque;
COSMOPOLITAN_C_END_
#define kLogFatal 0
#define kLogError 1
#define kLogWarn 2
#define kLogInfo 3
#define kLogVerbose 4
#define kLogDebug 5
#define kLogNoise 6
/**
* Log level for compile-time DCE.
*/
#ifndef LOGGABLELEVEL
#ifndef TINY
#define LOGGABLELEVEL kLogNoise
/* #elif IsTiny() */
/* #define LOGGABLELEVEL kLogInfo */
#else
#define LOGGABLELEVEL kLogVerbose
#endif
#endif
#ifdef TINY
#define _LOG_TINY 1
#else
#define _LOG_TINY 0
#endif
COSMOPOLITAN_C_START_
extern FILE *__log_file;
int __watch(void *, size_t);
void __die(void) relegated wontreturn; /* print backtrace and abort() */
void _meminfo(int); /* shows malloc statistics &c. */
void _memsummary(int); /* light version of same thing */
const char *commandvenv(const char *, const char *);
const char *GetAddr2linePath(void);
const char *GetGdbPath(void);
bool32 IsDebuggerPresent(bool32);
bool32 IsRunningUnderMake(void);
char *GetSymbolByAddr(int64_t);
void PrintGarbage(void);
void PrintGarbageNumeric(FILE *);
void PrintWindowsMemory(const char *, size_t);
#ifndef __STRICT_ANSI__
#define _LOG_UNLIKELY(x) __builtin_expect(!!(x), 0)
extern unsigned __log_level; /* log level for runtime check */
#define LOGGABLE(LEVEL) \
((!__builtin_constant_p(LEVEL) || (LEVEL) <= LOGGABLELEVEL) && \
(LEVEL) <= __log_level)
// log a message with the specified log level (not checking if LOGGABLE)
#define LOGF(LEVEL, FMT, ...) \
do { \
if (!_LOG_TINY) _log_untrace(); \
flogf(LEVEL, __FILE__, __LINE__, NULL, FMT, ##__VA_ARGS__); \
if (!_LOG_TINY) _log_retrace(); \
} while (0)
// report an error without backtrace and debugger invocation
#define FATALF(FMT, ...) \
do { \
if (!_LOG_TINY) _log_untrace(); \
flogf(kLogError, __FILE__, __LINE__, NULL, FMT, ##__VA_ARGS__); \
_log_exit(1); \
} while (0)
#define DIEF(FMT, ...) \
do { \
if (!_LOG_TINY) _log_untrace(); \
ffatalf(kLogFatal, __FILE__, __LINE__, NULL, FMT, ##__VA_ARGS__); \
__builtin_unreachable(); \
} while (0)
#define ERRORF(FMT, ...) \
do { \
if (LOGGABLE(kLogError)) { \
LOGF(kLogError, FMT, ##__VA_ARGS__); \
} \
} while (0)
#define WARNF(FMT, ...) \
do { \
if (LOGGABLE(kLogWarn)) { \
LOGF(kLogWarn, FMT, ##__VA_ARGS__); \
} \
} while (0)
#define INFOF(FMT, ...) \
do { \
if (LOGGABLE(kLogInfo)) { \
LOGF(kLogInfo, FMT, ##__VA_ARGS__); \
} \
} while (0)
#define VERBOSEF(FMT, ...) \
do { \
if (LOGGABLE(kLogVerbose)) { \
if (!_LOG_TINY) _log_untrace(); \
fverbosef(kLogVerbose, __FILE__, __LINE__, NULL, FMT, ##__VA_ARGS__); \
if (!_LOG_TINY) _log_retrace(); \
} \
} while (0)
#define DEBUGF(FMT, ...) \
do { \
if (_LOG_UNLIKELY(LOGGABLE(kLogDebug))) { \
if (!_LOG_TINY) _log_untrace(); \
fdebugf(kLogDebug, __FILE__, __LINE__, NULL, FMT, ##__VA_ARGS__); \
if (!_LOG_TINY) _log_retrace(); \
} \
} while (0)
#define NOISEF(FMT, ...) \
do { \
if (_LOG_UNLIKELY(LOGGABLE(kLogNoise))) { \
if (!_LOG_TINY) _log_untrace(); \
fnoisef(kLogNoise, __FILE__, __LINE__, NULL, FMT, ##__VA_ARGS__); \
if (!_LOG_TINY) _log_retrace(); \
} \
} while (0)
#define FLOGF(F, FMT, ...) \
do { \
if (LOGGABLE(kLogInfo)) { \
if (!_LOG_TINY) _log_untrace(); \
flogf(kLogInfo, __FILE__, __LINE__, F, FMT, ##__VA_ARGS__); \
if (!_LOG_TINY) _log_retrace(); \
} \
} while (0)
#define FWARNF(F, FMT, ...) \
do { \
if (LOGGABLE(kLogWarn)) { \
if (!_LOG_TINY) _log_untrace(); \
flogf(kLogWarn, __FILE__, __LINE__, F, FMT, ##__VA_ARGS__); \
if (!_LOG_TINY) _log_retrace(); \
} \
} while (0)
#define FFATALF(F, FMT, ...) \
do { \
if (!_LOG_TINY) _log_untrace(); \
flogf(kLogError, __FILE__, __LINE__, F, FMT, ##__VA_ARGS__); \
_log_exit(1); \
} while (0)
#define FDEBUGF(F, FMT, ...) \
do { \
if (_LOG_UNLIKELY(LOGGABLE(kLogDebug))) { \
if (!_LOG_TINY) _log_untrace(); \
fdebugf(kLogDebug, __FILE__, __LINE__, F, FMT, ##__VA_ARGS__); \
if (!_LOG_TINY) _log_retrace(); \
} \
} while (0)
#define FNOISEF(F, FMT, ...) \
do { \
if (_LOG_UNLIKELY(LOGGABLE(kLogNoise))) { \
if (!_LOG_TINY) _log_untrace(); \
fnoisef(kLogNoise, __FILE__, __LINE__, F, FMT, ##__VA_ARGS__); \
if (!_LOG_TINY) _log_retrace(); \
} \
} while (0)
#define LOGIFNEG1(FORM) \
({ \
int e = _log_get_errno(); \
autotype(FORM) Ax = (FORM); \
if (_LOG_UNLIKELY(Ax == (typeof(Ax))(-1)) && LOGGABLE(kLogWarn)) { \
if (!_LOG_TINY) _log_untrace(); \
_log_errno(__FILE__, __LINE__, #FORM); \
if (!_LOG_TINY) _log_retrace(); \
_log_set_errno(e); \
} \
Ax; \
})
#define LOGIFNULL(FORM) \
({ \
int e = _log_get_errno(); \
autotype(FORM) Ax = (FORM); \
if (Ax == NULL && LOGGABLE(kLogWarn)) { \
if (!_LOG_TINY) _log_untrace(); \
_log_errno(__FILE__, __LINE__, #FORM); \
if (!_LOG_TINY) _log_retrace(); \
_log_set_errno(e); \
} \
Ax; \
})
void _log_errno(const char *, int, const char *) relegated;
int _log_get_errno(void);
void _log_set_errno(int);
void _log_untrace(void);
void _log_retrace(void);
void _log_exit(int) wontreturn;
#define ARGS unsigned, const char *, int, FILE *, const char *
#define ATTR paramsnonnull((5)) printfesque(5)
#define ATTRV paramsnonnull((5))
void flogf(ARGS, ...) ATTR libcesque;
void vflogf(ARGS, va_list) ATTRV libcesque;
void fverbosef(ARGS, ...) asm("flogf") ATTR relegated libcesque;
void vfverbosef(ARGS, va_list) asm("vflogf") ATTRV relegated libcesque;
void fdebugf(ARGS, ...) asm("flogf") ATTR relegated libcesque;
void vfdebugf(ARGS, va_list) asm("vflogf") ATTRV relegated libcesque;
void fnoisef(ARGS, ...) asm("flogf") ATTR relegated libcesque;
void vfnoisef(ARGS, va_list) asm("vflogf") ATTRV relegated libcesque;
void ffatalf(ARGS, ...) asm("flogf") ATTR relegated wontreturn libcesque;
void vffatalf(ARGS, va_list) asm("vflogf") ATTRV relegated wontreturn libcesque;
#undef ARGS
#undef ATTR
#undef ATTRV
#endif /* __STRICT_ANSI__ */
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_LOG_LOG_H_ */
/*!BEGIN libc/log/traceme.h */
#define COSMOPOLITAN_LIBC_LOG_TRACEME_H_
COSMOPOLITAN_C_START_
extern int traceme;
COSMOPOLITAN_C_END_
/*!BEGIN libc/mem/alg.h */
#define COSMOPOLITAN_LIBC_ALG_ALG_H_
COSMOPOLITAN_C_START_
void *bsearch(const void *, const void *, size_t, size_t,
int (*)(const void *, const void *)) paramsnonnull() nosideeffect;
void *bsearch_r(const void *, const void *, size_t, size_t,
int (*)(const void *, const void *, void *), void *)
paramsnonnull((1, 2, 5)) nosideeffect;
void djbsort(int32_t *, size_t) libcesque;
void qsort3(void *, size_t, size_t, int (*)(const void *, const void *))
paramsnonnull();
void qsort(void *, size_t, size_t, int (*)(const void *, const void *))
paramsnonnull();
void qsort_r(void *, size_t, size_t,
int (*)(const void *, const void *, void *), void *)
paramsnonnull((1, 4));
void smoothsort(void *, size_t, size_t, int (*)(const void *, const void *));
void smoothsort_r(void *, size_t, size_t,
int (*)(const void *, const void *, void *), void *);
int heapsort(void *, size_t, size_t, int (*)(const void *, const void *));
int heapsort_r(void *, size_t, size_t,
int (*)(const void *, const void *, void *), void *);
int mergesort(void *, size_t, size_t, int (*)(const void *, const void *));
int mergesort_r(void *, size_t, size_t,
int (*)(const void *, const void *, void *), void *);
int radix_sort_int32(int32_t *, size_t) libcesque;
int radix_sort_int64(int64_t *, size_t) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/mem/alloca.h */
#define COSMOPOLITAN_LIBC_MEM_ALLOCA_H_
#define alloca(size) __builtin_alloca(size)
/*!BEGIN libc/mem/critbit0.h */
#define COSMOPOLITAN_LIBC_ALG_CRITBIT0_H_
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § data structures » critical bit tree (for c strings) ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
struct critbit0 {
void *root;
size_t count;
};
bool critbit0_contains(struct critbit0 *, const char *) libcesque nosideeffect
paramsnonnull();
int critbit0_insert(struct critbit0 *, const char *) paramsnonnull();
bool critbit0_delete(struct critbit0 *, const char *) libcesque paramsnonnull();
void critbit0_clear(struct critbit0 *) libcesque paramsnonnull();
char *critbit0_get(struct critbit0 *, const char *);
intptr_t critbit0_allprefixed(struct critbit0 *, const char *,
intptr_t (*)(const char *, void *), void *)
paramsnonnull((1, 2, 3)) libcesque;
int critbit0_emplace(struct critbit0 *, const void *, size_t) paramsnonnull();
COSMOPOLITAN_C_END_
/*!BEGIN libc/mem/gc.h */
#ifndef COSMOPOLITAN_LIBC_MEM_GC_H_
#define COSMOPOLITAN_LIBC_MEM_GC_H_
COSMOPOLITAN_C_START_
libcesque void _gc_free(void *);
libcesque void __defer(void *, void *, void *);
libcesque void gclongjmp(void *, int) wontreturn;
#define gc(THING) defer((void *)_gc_free, (void *)(THING))
#define _gc(THING) defer((void *)_gc_free, (void *)(THING))
#define defer(FN, ARG) \
({ \
autotype(ARG) Arg = (ARG); \
/* prevent weird opts like tail call */ \
__asm__ volatile("" : "+g"(Arg) : : "memory"); \
__defer(__builtin_frame_address(0), FN, Arg); \
__asm__ volatile("" : "+g"(Arg) : : "memory"); \
Arg; \
})
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_MEM_GC_H_ */
/*!BEGIN libc/mem/mem.h */
#define COSMOPOLITAN_LIBC_MEM_MEM_H_
#define M_TRIM_THRESHOLD (-1)
#define M_GRANULARITY (-2)
#define M_MMAP_THRESHOLD (-3)
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § dynamic memory ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
void free(void *) libcesque;
void *malloc(size_t) attributeallocsize((1)) mallocesque;
void *calloc(size_t, size_t) attributeallocsize((1, 2)) mallocesque;
void *memalign(size_t, size_t) attributeallocalign((1))
attributeallocsize((2)) returnspointerwithnoaliases libcesque __wur;
void *realloc(void *, size_t) reallocesque;
void *realloc_in_place(void *, size_t) reallocesque;
void *reallocarray(void *, size_t, size_t) __wur;
void *valloc(size_t) attributeallocsize((1)) vallocesque;
void *pvalloc(size_t) vallocesque;
char *strdup(const char *) paramsnonnull() mallocesque;
char *strndup(const char *, size_t) paramsnonnull() mallocesque;
void *aligned_alloc(size_t, size_t) attributeallocalign((1))
attributeallocsize((2)) returnspointerwithnoaliases libcesque __wur;
int posix_memalign(void **, size_t, size_t) libcesque;
int mallopt(int, int) libcesque;
int malloc_trim(size_t) libcesque;
size_t bulk_free(void **, size_t) libcesque;
size_t malloc_usable_size(void *) libcesque;
void **independent_calloc(size_t, size_t, void **) libcesque;
void **independent_comalloc(size_t, size_t *, void **) libcesque;
wchar_t *wcsdup(const wchar_t *) strlenesque __wur;
struct mallinfo {
size_t arena; /* non-mmapped space allocated from system */
size_t ordblks; /* number of free chunks */
size_t smblks; /* always 0 */
size_t hblks; /* always 0 */
size_t hblkhd; /* space in mmapped regions */
size_t usmblks; /* maximum total allocated space */
size_t fsmblks; /* always 0 */
size_t uordblks; /* total allocated space */
size_t fordblks; /* total free space */
size_t keepcost; /* releasable (via malloc_trim) space */
};
struct mallinfo mallinfo(void) libcesque;
size_t malloc_footprint(void) libcesque;
size_t malloc_max_footprint(void) libcesque;
size_t malloc_footprint_limit(void) libcesque;
size_t malloc_set_footprint_limit(size_t) libcesque;
void malloc_inspect_all(void (*)(void *, void *, size_t, void *), void *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nexgen32e/cachesize.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_CACHESIZE_H_
#define kCpuCacheTypeData 1
#define kCpuCacheTypeInstruction 2
#define kCpuCacheTypeUnified 3
COSMOPOLITAN_C_START_
unsigned _getcachesize(int, int);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nexgen32e/crc32.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_CRC32_H_
COSMOPOLITAN_C_START_
extern const uint32_t kCrc32cTab[256];
void crc32init(uint32_t[hasatleast 256], uint32_t);
uint32_t crc32c(uint32_t, const void *, size_t) nosideeffect;
COSMOPOLITAN_C_END_
/*!BEGIN libc/nexgen32e/ffs.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_FFS_H_
COSMOPOLITAN_C_START_
int ffs(int) pureconst;
int ffsl(long) pureconst;
int ffsll(long long) pureconst;
#ifdef __GNUC__
#define ffs(u) __builtin_ffs(u)
#define ffsl(u) __builtin_ffsl(u)
#define ffsll(u) __builtin_ffsll(u)
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/nexgen32e/kompressor.h */
#define COSMOPOLITAN_LIBC_KOMPRESSOR_KOMPRESSOR_H_
#ifdef _COSMO_SOURCE
#define rldecode __rldecode
#define rldecode2 __rldecode2
#define lz4check __lz4check
#define lz4cpy __lz4cpy
#define lz4len __lz4len
#define lz4decode __lz4decode
COSMOPOLITAN_C_START_
struct RlDecode {
uint8_t repititions;
uint8_t byte;
};
void rldecode(void *dest, const struct RlDecode *);
void rldecode2(void *dest, const struct RlDecode *);
const uint8_t *lz4check(const void *data);
void *lz4cpy(void *dest, const void *blockdata, size_t blocksize);
size_t lz4len(const void *blockdata, size_t blocksize);
void *lz4decode(void *dest, const void *src);
COSMOPOLITAN_C_END_
#endif /* _COSMO_SOURCE */
/*!BEGIN libc/nexgen32e/lz4.h */
#define COSMOPOLITAN_LIBC_LZ4_H_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § lz4 ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
LZ4 is a brilliant framing format for REP MOVSB designed by Yann Collet.
@see https://github.com/lz4/lz4/blob/master/doc/lz4_Frame_format.md
@see https://github.com/lz4/lz4/blob/master/doc/lz4_Block_format.md
@see http://ticki.github.io/blog/how-lz4-works/ */
#define LZ4_EOF 0
#define LZ4_VERSION 1
#define LZ4_MAGICNUMBER 0x184D2204
#define LZ4_SKIPPABLE0 0x184D2A50
#define LZ4_SKIPPABLEMASK 0xFFFFFFF0
#define LZ4_MAXHEADERSIZE (MAGICNUMBER_SIZE + 2 + 8 + 4 + 1)
#define LZ4_BLOCKMAXSIZE_64KB 4
#define LZ4_BLOCKMAXSIZE_256KB 5
#define LZ4_BLOCKMAXSIZE_1MB 6
#define LZ4_BLOCKMAXSIZE_4MB 7
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § lz4 » frames ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define LZ4_MAGIC(FRAME) READ32LE(FRAME)
#define LZ4_FRAME_VERSION(FRAME) ((_LZ4_FRAME_FLG(FRAME) >> 6) & 3)
#define LZ4_FRAME_BLOCKINDEPENDENCE(FRAME) ((_LZ4_FRAME_FLG(FRAME) >> 5) & 1)
#define LZ4_FRAME_BLOCKCHECKSUMFLAG(FRAME) ((_LZ4_FRAME_FLG(FRAME) >> 4) & 1)
#define LZ4_FRAME_BLOCKCONTENTSIZEFLAG(FRAME) ((_LZ4_FRAME_FLG(FRAME) >> 3) & 1)
#define LZ4_FRAME_BLOCKCONTENTCHECKSUMFLAG(FRAME) \
((_LZ4_FRAME_FLG(FRAME) >> 2) & 1)
#define LZ4_FRAME_DICTIONARYIDFLAG(FRAME) ((_LZ4_FRAME_FLG(FRAME) >> 0) & 1)
#define LZ4_FRAME_BLOCKMAXSIZE(FRAME) ((_LZ4_FRAME_BD(FRAME) >> 4) & 7)
#define LZ4_FRAME_RESERVED1(FRAME) ((_LZ4_FRAME_FLG(FRAME) >> 1) & 1)
#define LZ4_FRAME_RESERVED2(FRAME) ((_LZ4_FRAME_BD(FRAME) >> 7) & 1)
#define LZ4_FRAME_RESERVED3(FRAME) ((_LZ4_FRAME_BD(FRAME) >> 0) & 15)
#define LZ4_FRAME_BLOCKCONTENTSIZE(FRAME) \
(LZ4_FRAME_BLOCKCONTENTSIZEFLAG(FRAME) ? READ64LE((FRAME) + 4 + 1 + 1) : 0)
#define LZ4_FRAME_DICTIONARYID(FRAME) \
(LZ4_FRAME_DICTIONARYIDFLAG(FRAME) \
? READ32LE(((FRAME) + 4 + 1 + 1 + \
8 * LZ4_FRAME_BLOCKCONTENTSIZEFLAG(FRAME))) \
: 0)
#define LZ4_FRAME_HEADERCHECKSUM(FRAME) \
(*((FRAME) + 4 + 1 + 1 + 8 * LZ4_FRAME_BLOCKCONTENTSIZEFLAG(FRAME) + \
4 * LZ4_FRAME_DICTIONARYIDFLAG(FRAME)))
#define LZ4_FRAME_HEADERSIZE(FRAME) \
(4 + 1 + 1 + 8 * LZ4_FRAME_BLOCKCONTENTSIZEFLAG(FRAME) + \
4 * LZ4_FRAME_DICTIONARYIDFLAG(FRAME) + 1)
#define _LZ4_FRAME_FLG(FRAME) (*((FRAME) + 4))
#define _LZ4_FRAME_BD(FRAME) (*((FRAME) + 5))
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § lz4 » blocks ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define LZ4_BLOCK_DATA(block) (block + sizeof(uint32_t))
#define LZ4_BLOCK_DATASIZE(block) (READ32LE(block) & 0x7fffffff)
#define LZ4_BLOCK_ISEOF(block) (READ32LE(block) == LZ4_EOF)
#define LZ4_BLOCK_ISCOMPRESSED(block) ((READ32LE(block) & 0x80000000) == 0)
#define LZ4_BLOCK_SIZE(frame, block) \
(sizeof(uint32_t) + LZ4_BLOCK_DATASIZE(block) + \
(LZ4_FRAME_BLOCKCHECKSUMFLAG(frame) ? sizeof(uint8_t) : 0))
COSMOPOLITAN_C_END_
/*!BEGIN libc/nexgen32e/nexgen32e.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_NEXGEN32E_H_
COSMOPOLITAN_C_START_
extern long kHalfCache3;
extern const uint64_t kTens[20];
extern const uint32_t kSha256[64];
extern const uint64_t kSha512[80];
extern const unsigned char kTensIndex[64];
void CheckStackIsAligned(void);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nexgen32e/nt2sysv.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_NT2SYSV_H_
/*!BEGIN libc/nexgen32e/trampoline.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_TRAMPOLINE_H_
#define TRAMPOLINE(FUNCTION, THUNK) \
({ \
typeof(FUNCTION) *Tramp; \
asm(".section .text.trampoline\n" \
"183:\n\t" \
"mov\t%1,%%eax\n\t" \
"jmp\t" #THUNK "\n\t" \
".previous\n\t" \
"mov\t$183b,%k0" \
: "=r"(Tramp) \
: "i"(FUNCTION)); \
Tramp; \
})
/**
* Creates function to thunk FUNCTION from MSX64 to System V ABI.
*
* This macro should be used when specifying callbacks in the WIN32 API.
*/
#define NT2SYSV(FUNCTION) TRAMPOLINE(FUNCTION, __nt2sysv)
/*!BEGIN libc/nexgen32e/rdtscp.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_RDTSCP_H_
COSMOPOLITAN_C_START_
#define TSC_AUX_CORE(MSR) ((MSR) & 0xfff)
#define TSC_AUX_NODE(MSR) (((MSR) >> 12) & 0xfff)
/**
* Reads CPU timestamp counter and IA32_TSC_AUX.
*
* This macro inhibits compiler magic.
* This macro does not inhibit CPU magic.
*
* @see X86_HAVE(RDTSCP)
*/
#define rdtscp(OPT_OUT_IA32_TSC_AUX) \
({ \
uint64_t Rax, Rdx; \
uint32_t Ecx, *EcxOut; \
asm volatile("rdtscp" \
: "=a"(Rax), "=c"(Ecx), "=d"(Rdx) \
: /* no inputs */ \
: "memory"); \
EcxOut = (OPT_OUT_IA32_TSC_AUX); \
if (EcxOut) *EcxOut = Ecx; \
Rdx << 32 | Rax; \
})
/**
* Reads timestamp counter auxiliary model specific register value.
*/
#define rdpid() \
({ \
long Msr; \
bool32 Ok; \
Ok = false; \
if (X86_HAVE(RDPID)) { \
asm volatile("rdpid\t%0" : "=r"(Msr) : /* no inputs */ : "memory"); \
Ok = true; \
} else if (IsLinux()) { \
char *p = (char *)0x7b; \
asm volatile(ZFLAG_ASM("lsl\t%2,%1") \
: ZFLAG_CONSTRAINT(Ok), "=r"(Msr) \
: "r"(p) \
: "memory"); \
} \
if (!Ok && X86_HAVE(RDTSCP)) { \
asm volatile("rdtscp" \
: "=c"(Msr) \
: /* no inputs */ \
: "eax", "edx", "memory"); \
Ok = true; \
} \
if (!Ok) { \
Msr = -1; \
} \
Msr; \
})
COSMOPOLITAN_C_END_
/*!BEGIN libc/nexgen32e/sha.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_SHA_H_
COSMOPOLITAN_C_START_
void sha1_transform_avx2(uint32_t[hasatleast 5], const void *, unsigned);
void sha1_transform_ni(uint32_t[hasatleast 5], const void *, unsigned);
void sha256_transform_rorx(uint32_t[hasatleast 8], const void *, unsigned);
void sha256_transform_ni(uint32_t[hasatleast 8], const void *, unsigned);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nexgen32e/stackframe.h */
#ifndef COSMOPOLITAN_LIBC_NEXGEN32E_STACKFRAME_H_
#define COSMOPOLITAN_LIBC_NEXGEN32E_STACKFRAME_H_
COSMOPOLITAN_C_START_
struct StackFrame {
struct StackFrame *next;
intptr_t addr;
};
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_NEXGEN32E_STACKFRAME_H_ */
/*!BEGIN libc/nexgen32e/x86info.h */
#define COSMOPOLITAN_LIBC_NEXGEN32E_X86INFO_H_
#define kX86CpuStepping ((KCPUIDS(1H, EAX) >> 0) & 15)
#define kX86CpuModelid ((KCPUIDS(1H, EAX) >> 4) & 15)
#define kX86CpuFamilyid ((KCPUIDS(1H, EAX) >> 8) & 15)
#define kX86CpuType ((KCPUIDS(1H, EAX) >> 12) & 3)
#define kX86CpuExtmodelid ((KCPUIDS(1H, EAX) >> 16) & 15)
#define kX86CpuExtfamilyid ((KCPUIDS(1H, EAX) >> 20) & 255)
#define kX86CpuFamily \
(kX86CpuFamilyid + (kX86CpuFamilyid == 15 ? kX86CpuExtfamilyid : 0))
#define kX86CpuModel \
(kX86CpuModelid | \
(kX86CpuFamilyid == 6 || kX86CpuFamilyid == 15 ? kX86CpuExtmodelid : 0) \
<< 4)
#define kX86ProcessorModelKey \
(kX86CpuExtfamilyid << 12 | kX86CpuFamilyid << 8 | kX86CpuExtmodelid << 4 | \
kX86CpuModelid)
#define X86_MARCH_UNKNOWN 0
#define X86_MARCH_CORE2 1
#define X86_MARCH_NEHALEM 2
#define X86_MARCH_WESTMERE 3
#define X86_MARCH_SANDYBRIDGE 4
#define X86_MARCH_IVYBRIDGE 5
#define X86_MARCH_HASWELL 6
#define X86_MARCH_BROADWELL 7
#define X86_MARCH_SKYLAKE 8
#define X86_MARCH_KABYLAKE 9
#define X86_MARCH_CANNONLAKE 10
#define X86_MARCH_ICELAKE 11
#define X86_MARCH_TIGERLAKE 12
#define X86_MARCH_BONNELL 13
#define X86_MARCH_SALTWELL 14
#define X86_MARCH_SILVERMONT 15
#define X86_MARCH_AIRMONT 16
#define X86_MARCH_GOLDMONT 17
#define X86_MARCH_GOLDMONTPLUS 18
#define X86_MARCH_TREMONT 19
#define X86_MARCH_KNIGHTSLANDING 20
#define X86_MARCH_KNIGHTSMILL 21
#define X86_MARCH_SAPPHIRERAPIDS 22
#define X86_MARCH_ALDERLAKE 23
#define X86_MARCH_COMETLAKE 24
#define X86_MARCH_RAPTORLAKE 25
#define X86_MARCH_ROCKETLAKE 26
#define X86_GRADE_UNKNOWN 0
#define X86_GRADE_APPLIANCE 1
#define X86_GRADE_MOBILE 2
#define X86_GRADE_TABLET 3
#define X86_GRADE_DESKTOP 4
#define X86_GRADE_CLIENT 5
#define X86_GRADE_DENSITY 6
#define X86_GRADE_SERVER 7
#define X86_GRADE_SCIENCE 8
struct X86ProcessorModel {
short key;
unsigned char march;
unsigned char grade;
};
extern const size_t kX86ProcessorModelCount;
extern const struct X86ProcessorModel kX86ProcessorModels[];
const struct X86ProcessorModel *getx86processormodel(short) nosideeffect;
/*!BEGIN libc/nt/enum/accessmask.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_ACCESSMASK_H_
#define kNtGenericRead 0x80000000u
#define kNtGenericWrite 0x40000000u
#define kNtGenericExecute 0x20000000u
#define kNtGenericAll 0x10000000u
#define kNtDelete 0x00010000u
#define kNtReadControl 0x00020000u
#define kNtWriteDac 0x00040000u
#define kNtWriteOwner 0x00080000u
#define kNtSynchronize 0x00100000u
#define kNtStandardRightsRequired 0x000F0000u
#define kNtStandardRightsRead kNtReadControl
#define kNtStandardRightsWrite kNtReadControl
#define kNtStandardRightsExecute kNtReadControl
#define kNtStandardRightsAll 0x001F0000u
#define kNtSpecificRightsAll 0x0000FFFFu
#define kNtAccessSystemSecurity 0x01000000u
#define kNtMaximumAllowed 0x02000000u
#define kNtFileReadData 0x0001u
#define kNtFileListDirectory 0x0001u
#define kNtFileWriteData 0x0002u
#define kNtFileAddFile 0x0002u
#define kNtFileAppendData 0x0004u
#define kNtFileAddSubdirectory 0x0004u
#define kNtFileCreatePipeInstance 0x0004u
#define kNtFileReadEa 0x0008u
#define kNtFileWriteEa 0x0010u
#define kNtFileExecute 0x0020u
#define kNtFileTraverse 0x0020u
#define kNtFileDeleteChild 0x0040u
#define kNtFileReadAttributes 0x0080u
#define kNtFileWriteAttributes 0x0100u
#define kNtFileAllAccess (kNtStandardRightsRequired | kNtSynchronize | 0x1FFu)
#define kNtFileGenericRead \
(kNtStandardRightsRead | kNtFileReadData | kNtFileReadAttributes | \
kNtFileReadEa | kNtSynchronize)
#define kNtFileGenericWrite \
(kNtStandardRightsWrite | kNtFileWriteData | kNtFileWriteAttributes | \
kNtFileWriteEa | kNtFileAppendData | kNtSynchronize)
#define kNtFileGenericExecute \
(kNtStandardRightsExecute | kNtFileReadAttributes | kNtFileExecute | \
kNtSynchronize)
#define kNtTokenAssignPrimary 0x0001u
#define kNtTokenDuplicate 0x0002u
#define kNtTokenImpersonate 0x0004u
#define kNtTokenQuery 0x0008u
#define kNtTokenQuerySource 0x0010u
#define kNtTokenAdjustPrivileges 0x0020u
#define kNtTokenAdjustGroups 0x0040u
#define kNtTokenAdjustDefault 0x0080u
#define kNtTokenAdjustSessionid 0x0100u
#define kNtTokenAllAccessP \
(kNtStandardRightsRequired | kNtTokenAssignPrimary | kNtTokenDuplicate | \
kNtTokenImpersonate | kNtTokenQuery | kNtTokenQuerySource | \
kNtTokenAdjustPrivileges | kNtTokenAdjustGroups | kNtTokenAdjustDefault)
#define kNtTokenAllAccess kNtTokenAllAccessP | kNtTokenAdjustSessionid
#define kNtTokenRead kNtStandardRightsRead | kNtTokenQuery
#define kNtTokenWrite \
(kNtStandardRightsWrite | kNtTokenAdjustPrivileges | kNtTokenAdjustGroups | \
kNtTokenAdjustDefault)
#define kNtTokenExecute kNtStandardRightsExecute
#define kNtTokenTrustConstraintMask \
(kNtStandardRightsRead | kNtTokenQuery | kNtTokenQuerySource)
#define kNtTokenAccessPseudoHandleWin8 kNtTokenQuery | kNtTokenQuerySource
#define kNtTokenAccessPseudoHandle kNtTokenAccessPseudoHandleWin8
/*!BEGIN libc/nt/enum/afd.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_AFD_H_
#define kNtAfdPollReceive 0x0001
#define kNtAfdPollReceiveExpedited 0x0002
#define kNtAfdPollSend 0x0004
#define kNtAfdPollDisconnect 0x0008
#define kNtAfdPollAbort 0x0010
#define kNtAfdPollLocalClose 0x0020
#define kNtAfdPollAccept 0x0080
#define kNtAfdPollConnectFail 0x0100
/*!BEGIN libc/nt/enum/bitblt.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_BITBLT_H_
#define kNtSrccopy 0x00CC0020u /* src */
#define kNtSrcpaint 0x00EE0086u /* src | dst */
#define kNtSrcand 0x008800C6u /* src & dst */
#define kNtSrcinvert 0x00660046u /* src ^ dst */
#define kNtSrcerase 0x00440328u /* src & ~dst */
#define kNtNotsrccopy 0x00330008u /* ~src */
#define kNtNotsrcerase 0x001100A6u /* ~src & ~dst */
#define kNtMergecopy 0x00C000CAu /* (src & pattern) */
#define kNtMergepaint 0x00BB0226u /* ~src | dst */
#define kNtPatcopy 0x00F00021u /* pat */
#define kNtPatpaint 0x00FB0A09u /* wut */
#define kNtPatinvert 0x005A0049u /* pat ^ dst */
#define kNtDstinvert 0x00550009u /* ~dst */
#define kNtBlackness 0x00000042u /* black */
#define kNtWhiteness 0x00FF0062u /* white */
/*!BEGIN libc/nt/enum/callback.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_CALLBACK_H_
#define kNtCallbackChunkFinished 0
#define kNtCallbackStreamSwitch 1
/*!BEGIN libc/nt/enum/color.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_COLOR_H_
#define kNtColorScrollbar 0
#define kNtColorBackground 1
#define kNtColorActivecaption 2
#define kNtColorInactivecaption 3
#define kNtColorMenu 4
#define kNtColorWindow 5
#define kNtColorWindowframe 6
#define kNtColorMenutext 7
#define kNtColorWindowtext 8
#define kNtColorCaptiontext 9
#define kNtColorActiveborder 10
#define kNtColorInactiveborder 11
#define kNtColorAppworkspace 12
#define kNtColorHighlight 13
#define kNtColorHighlighttext 14
#define kNtColorBtnface 15
#define kNtColorBtnshadow 16
#define kNtColorGraytext 17
#define kNtColorBtntext 18
#define kNtColorInactivecaptiontext 19
#define kNtColorBtnhighlight 20
#define kNtColor3ddkshadow 21
#define kNtColor3dlight 22
#define kNtColorInfotext 23
#define kNtColorInfobk 24
#define kNtColorHotlight 26
#define kNtColorGradientactivecaption 27
#define kNtColorGradientinactivecaption 28
#define kNtColorMenuhilight 29
#define kNtColorMenubar 30
/*!BEGIN libc/nt/enum/computernameformat.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_COMPUTERNAMEFORMAT_H_
#define kNtComputerNameNetBios 0
#define kNtComputerNameDnsHostname 1
#define kNtComputerNameDnsDomain 2
#define kNtComputerNameDnsFullyQualified 3
#define kNtComputerNamePhysicalNetBios 4
#define kNtComputerNamePhysicalDnsHostname 5
#define kNtComputerNamePhysicalDnsDomain 6
#define kNtComputerNamePhysicalDnsFullyQualified 7
#define kNtComputerName_MAX 8
/*!BEGIN libc/nt/enum/consolemodeflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_CONSOLEMODEFLAGS_H_
/* input mode */
#define kNtEnableProcessedInput 0x0001u
#define kNtEnableLineInput 0x0002u
#define kNtEnableEchoInput 0x0004u
#define kNtEnableWindowInput 0x0008u
#define kNtEnableMouseInput 0x0010u
#define kNtEnableInsertMode 0x0020u
#define kNtEnableQuickEditMode 0x0040u
#define kNtEnableExtendedFlags 0x0080u
#define kNtEnableAutoPosition 0x0100u
#define kNtEnableVirtualTerminalInput 0x0200u
/* output mode */
#define kNtEnableProcessedOutput 0x0001u
#define kNtEnableWrapAtEolOutput 0x0002u
#define kNtEnableVirtualTerminalProcessing 0x0004u
#define kNtDisableNewlineAutoReturn 0x0008u
#define kNtEnableLvbGridWorldwide 0x0010u
/*!BEGIN libc/nt/enum/consoleselectionflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_CONSOLESELECTIONFLAGS_H_
#define kNtConsoleNoSelection 0x0000u
#define kNtConsoleSelectionInProgress 0x0001u
#define kNtConsoleSelectionNotEmpty 0x0002u
#define kNtConsoleMouseSelection 0x0004u
#define kNtConsoleMouseDown 0x0008u
/*!BEGIN libc/nt/enum/context.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_CONTEXT_H_
#define kNtContextAmd64 0x00100000
#define kNtContextControl (kNtContextAmd64 | 0x00000001)
#define kNtContextInteger (kNtContextAmd64 | 0x00000002)
#define kNtContextSegments (kNtContextAmd64 | 0x00000004)
#define kNtContextFloatingPoint (kNtContextAmd64 | 0x00000008)
#define kNtContextDebugRegisters (kNtContextAmd64 | 0x00000010)
#define kNtContextFull \
(kNtContextControl | kNtContextInteger | kNtContextFloatingPoint)
#define kNtContextAll \
(kNtContextControl | kNtContextInteger | kNtContextSegments | \
kNtContextFloatingPoint | kNtContextDebugRegisters)
#define kNtContextXstate (kNtContextAmd64 | 0x00000040)
/*!BEGIN libc/nt/enum/copyfile.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_COPYFILE_H_
#define kNtCopyFileFailIfExists 0x00000001
#define kNtCopyFileRestartable 0x00000002
#define kNtCopyFileOpenSourceForWrite 0x00000004
#define kNtCopyFileAllowDecryptedDestination 0x00000008
#define kNtCopyFileCopySymlink 0x00000800
#define kNtCopyFileNoBuffering 0x00001000
#define kNtCopyFileRequestSecurityPrivileges 0x00002000 /* Win8+ */
#define kNtCopyFileResumeFromPause 0x00004000 /* Win8+ */
#define kNtCopyFileRequestSecurityPrivileges 0x00002000 /* Win8+ */
#define kNtCopyFileNoOffload 0x00040000 /* Win8+ */
#define kNtCopyFileIgnoreEdpBlock 0x00400000 /* Win10+ */
#define kNtCopyFileIgnoreSourceEncryption 0x00800000 /* Win10+ */
/*!BEGIN libc/nt/enum/creationdisposition.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_CREATIONDISPOSITION_H_
#define kNtCreateNew 1
#define kNtCreateAlways 2
#define kNtOpenExisting 3
#define kNtOpenAlways 4
#define kNtTruncateExisting 5
/*!BEGIN libc/nt/enum/cs.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_CS_H_
#define kNtCsVredraw 0x00000001
#define kNtCsHredraw 0x00000002
#define kNtCsDblclks 0x00000008
#define kNtCsOwndc 0x00000020
#define kNtCsClassdc 0x00000040
#define kNtCsParentdc 0x00000080
#define kNtCsNoclose 0x00000200
#define kNtCsSavebits 0x00000800
#define kNtCsBytealignclient 0x00001000
#define kNtCsBytealignwindow 0x00002000
#define kNtCsGlobalclass 0x00004000
#define kNtCsIme 0x00010000
#define kNtCsDropshadow 0x00020000
/*!BEGIN libc/nt/enum/ctrlevent.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_CTRLEVENT_H_
#define kNtCtrlCEvent 0 /* SIGINT */
#define kNtCtrlBreakEvent 1 /* SIGQUIT */
#define kNtCtrlCloseEvent 2 /* SIGHUP */
#define kNtCtrlLogoffEvent 5 /* SIGTERM */
#define kNtCtrlShutdownEvent 6
/*!BEGIN libc/nt/enum/cw.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_CW_H_
#define kNtCwUsedefault ((int)0x80000000)
/*!BEGIN libc/nt/enum/dialogresult.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_DIALOGRESULT_H_
#define kNtIdok 1
#define kNtIdcancel 2
#define kNtIdabort 3
#define kNtIdretry 4
#define kNtIdignore 5
#define kNtIdyes 6
#define kNtIdno 7
#define kNtIdclose 8
#define kNtIdhelp 9
#define kNtIdtryagain 10
#define kNtIdcontinue 11
/*!BEGIN libc/nt/enum/errormodeflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_ERRORMODEFLAGS_H_
#define kNtErrorModeDefault 0x0
#define kNtSemFailcriticalerrors 0x1
#define kNtSemNogpfaulterrorbox 0x2
#define kNtSemNoopenfileerrorbox 0x8000
/*!BEGIN libc/nt/enum/event.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_EVENT_H_
#define kNtEventSystemSound 0x0001
#define kNtEventSystemAlert 0x0002
#define kNtEventSystemForeground 0x0003
#define kNtEventSystemMenustart 0x0004
#define kNtEventSystemMenuend 0x0005
#define kNtEventSystemMenupopupstart 0x0006
#define kNtEventSystemMenupopupend 0x0007
#define kNtEventSystemCapturestart 0x0008
#define kNtEventSystemCaptureend 0x0009
#define kNtEventSystemMovesizestart 0x000A
#define kNtEventSystemMovesizeend 0x000B
#define kNtEventSystemContexthelpstart 0x000C
#define kNtEventSystemContexthelpend 0x000D
#define kNtEventSystemDragdropstart 0x000E
#define kNtEventSystemDragdropend 0x000F
#define kNtEventSystemDialogstart 0x0010
#define kNtEventSystemDialogend 0x0011
#define kNtEventSystemScrollingstart 0x0012
#define kNtEventSystemScrollingend 0x0013
#define kNtEventSystemSwitchstart 0x0014
#define kNtEventSystemSwitchend 0x0015
#define kNtEventSystemMinimizestart 0x0016
#define kNtEventSystemMinimizeend 0x0017
#define kNtEventConsoleCaret 0x4001
#define kNtEventConsoleUpdateRegion 0x4002
#define kNtEventConsoleUpdateSimple 0x4003
#define kNtEventConsoleUpdateScroll 0x4004
#define kNtEventConsoleLayout 0x4005
#define kNtEventConsoleStartApplication 0x4006
#define kNtEventConsoleEndApplication 0x4007
#define kNtEventObjectCreate 0x8000
#define kNtEventObjectDestroy 0x8001
#define kNtEventObjectShow 0x8002
#define kNtEventObjectHide 0x8003
#define kNtEventObjectReorder 0x8004
#define kNtEventObjectFocus 0x8005
#define kNtEventObjectSelection 0x8006
#define kNtEventObjectSelectionadd 0x8007
#define kNtEventObjectSelectionremove 0x8008
#define kNtEventObjectSelectionwithin 0x8009
#define kNtEventObjectStatechange 0x800A
#define kNtEventObjectLocationchange 0x800B
#define kNtEventObjectNamechange 0x800C
#define kNtEventObjectDescriptionchange 0x800D
#define kNtEventObjectValuechange 0x800E
#define kNtEventObjectParentchange 0x800F
#define kNtEventObjectHelpchange 0x8010
#define kNtEventObjectDefactionchange 0x8011
#define kNtEventObjectAcceleratorchange 0x8012
/*!BEGIN libc/nt/enum/eventtype.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_EVENTTYPE_H_
#define kNtNotificationEvent 0
#define kNtSynchronizationEvent 1
/*!BEGIN libc/nt/enum/exceptionhandleractions.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_EXCEPTIONHANDLERACTIONS_H_
#define kNtExceptionExecuteHandler 0x1u
#define kNtExceptionContinueExecution 0xffffffffu
#define kNtExceptionContinueSearch 0x0u
/*!BEGIN libc/nt/enum/fileflagandattributes.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FILEFLAGANDATTRIBUTES_H_
/**
* MS-DOS File Attributes.
*
* @see GetFileInformationByHandle()
* @see libc/sysv/consts.sh
*/
#define kNtFileAttributeReadonly 0x00000001u
#define kNtFileAttributeHidden 0x00000002u
#define kNtFileAttributeSystem 0x00000004u
#define kNtFileAttributeVolumelabel 0x00000008u
#define kNtFileAttributeDirectory 0x00000010u
#define kNtFileAttributeArchive 0x00000020u
/**
* NT File Attributes.
*/
#define kNtFileAttributeDevice 0x00000040u
#define kNtFileAttributeNormal 0x00000080u
#define kNtFileAttributeTemporary 0x00000100u
#define kNtFileAttributeSparseFile 0x00000200u
#define kNtFileAttributeReparsePoint 0x00000400u
#define kNtFileAttributeCompressed 0x00000800u
#define kNtFileAttributeOffline 0x00001000u
#define kNtFileAttributeNotContentIndexed 0x00002000u
#define kNtFileAttributeEncrypted 0x00004000u
/**
* NT File Flags.
*/
#define kNtFileFlagWriteThrough 0x80000000u
#define kNtFileFlagOverlapped 0x40000000u
#define kNtFileFlagNoBuffering 0x20000000u
#define kNtFileFlagRandomAccess 0x10000000u
#define kNtFileFlagSequentialScan 0x08000000u
#define kNtFileFlagDeleteOnClose 0x04000000u
#define kNtFileFlagBackupSemantics 0x02000000u
#define kNtFileFlagPosixSemantics 0x01000000u
#define kNtFileFlagOpenReparsePoint 0x00200000u
#define kNtFileFlagOpenNoRecall 0x00100000u
#define kNtFileFlagFirstPipeInstance 0x00080000u
/*!BEGIN libc/nt/enum/fileinfobyhandleclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FILEINFOBYHANDLECLASS_H_
#define kNtFileBasicInfo 0 /* struct NtFileBasicInformation */
#define kNtFileStandardInfo 1 /* struct NtFileStandardInformation */
#define kNtFileNameInfo 2 /* struct NtFileNameInformation */
#define kNtFileStreamInfo 7 /* struct NtFileStreamInformation */
#define kNtFileCompressionInfo 8 /* struct NtFileCompressionInfo */
#define kNtFileAttributeTagInfo 9 /* struct NtFileAttributeTagInformation */
#define kNtFileIdBothDirectoryInfo 10
#define kNtFileIdBothDirectoryRestartInfo 11
#define kNtFileRemoteProtocolInfo 13
#define kNtFileFullDirectoryInfo 14 /* NtFileFullDirectoryInformation */
#define kNtFileFullDirectoryRestartInfo 15
#define kNtFileStorageInfo 16 /* win8+ */
#define kNtFileAlignmentInfo 17 /* win8+ */
#define kNtFileIdInfo 18 /* win8+ */
#define kNtFileIdExtdDirectoryInfo 19 /* win8+ */
#define kNtFileIdExtdDirectoryRestartInfo 20 /* win8+ */
#define kNtFileRenameInfo 4
#define kNtFileDispositionInfo 5
#define kNtFileAllocationInfo 6
#define kNtFileEndOfFileInfo 7
#define kNtFileIoPriorityHintInfo 13
#define kNtFileDispositionInfoEx 22 /* win10+ */
#define kNtFileRenameInfoEx 23 /* win10+ */
/*!BEGIN libc/nt/enum/fileinformationclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FILEINFORMATIONCLASS_H_
#define kNtFileDirectoryInformation 1 /*→ struct NtFileDirectoryInformation */
#define kNtFileFullDirectoryInformation 2 /*→ etc. */
#define kNtFileBothDirectoryInformation 3
#define kNtFileBasicInformation 4
#define kNtFileStandardInformation 5
#define kNtFileInternalInformation 6
#define kNtFileEaInformation 7
#define kNtFileAccessInformation 8
#define kNtFileNameInformation 9
#define kNtFileRenameInformation 10
#define kNtFileLinkInformation 11
#define kNtFileNamesInformation 12
#define kNtFileDispositionInformation 13
#define kNtFilePositionInformation 14
#define kNtFileFullEaInformation 15
#define kNtFileModeInformation 16
#define kNtFileAlignmentInformation 17
#define kNtFileAllInformation 18
#define kNtFileAllocationInformation 19
#define kNtFileEndOfFileInformation 20
#define kNtFileAlternateNameInformation 21
#define kNtFileStreamInformation 22
#define kNtFilePipeInformation 23
#define kNtFilePipeLocalInformation 24
#define kNtFilePipeRemoteInformation 25
#define kNtFileMailslotQueryInformation 26
#define kNtFileMailslotSetInformation 27
#define kNtFileCompressionInformation 28
#define kNtFileObjectIdInformation 29
#define kNtFileCompletionInformation 30
#define kNtFileMoveClusterInformation 31
#define kNtFileQuotaInformation 32
#define kNtFileReparsePointInformation 33
#define kNtFileNetworkOpenInformation 34
#define kNtFileAttributeTagInformation 35
#define kNtFileTrackingInformation 36
#define kNtFileIdBothDirectoryInformation 37
#define kNtFileIdFullDirectoryInformation 38
#define kNtFileValidDataLengthInformation 39
#define kNtFileShortNameInformation 40
#define kNtFileInformation_MAX 40
/*!BEGIN libc/nt/enum/filelockflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FILELOCKFLAGS_H_
#define kNtLockfileFailImmediately 1
#define kNtLockfileExclusiveLock 2
/*!BEGIN libc/nt/enum/filemapflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FILEMAPFLAGS_H_
#define kNtFileMapCopy 0x00000001u
#define kNtFileMapWrite 0x00000002u
#define kNtFileMapRead 0x00000004u
#define kNtFileMapExecute 0x00000020u
#define kNtFileMapReserve 0x80000000u
#define kNtFileMapTargetsInvalid 0x40000000u
#define kNtFileMapLargePages 0x20000000u
/*!BEGIN libc/nt/enum/filemovemethod.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FILEMOVEMETHOD_H_
#define kNtFileBegin 0
#define kNtFileCurrent 1
#define kNtFileEnd 2
/*!BEGIN libc/nt/enum/filesharemode.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FILESHAREFLAGS_H_
#define kNtFileShareExclusive 0x00000000u
#define kNtFileShareRead 0x00000001u
#define kNtFileShareWrite 0x00000002u
#define kNtFileShareDelete 0x00000004u
/*!BEGIN libc/nt/enum/filetype.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FILETYPE_H_
#define kNtFileTypeUnknown 0x0000
#define kNtFileTypeDisk 0x0001 /* @see S_ISBLK() */
#define kNtFileTypeChar 0x0002 /* @see S_ISCHR() */
#define kNtFileTypePipe 0x0003 /* @see S_ISFIFO() */
#define kNtFileTypeRemote 0x8000 /* unused -MSDN */
/*!BEGIN libc/nt/enum/fillattribute.h */
#define COSMOPOLITAN_LIBC_NT_NTFILLATTRIBUTE_H_
#define kNtForegroundBlue 0x0001
#define kNtForegroundGreen 0x0002
#define kNtForegroundRed 0x0004
#define kNtForegroundIntensity 0x0008
#define kNtBackgroundBlue 0x0010
#define kNtBackgroundGreen 0x0020
#define kNtBackgroundRed 0x0040
#define kNtBackgroundIntensity 0x0080
/*!BEGIN libc/nt/enum/findexinfolevels.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FINDEXINFOLEVELS_H_
#define kNtFindExInfoStandard 0
#define kNtFindExInfoBasic 1
#define kNtFindExInfoMaxInfoLevel 2
/*!BEGIN libc/nt/enum/findexsearchops.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FINDEXSEARCHOPS_H_
#define kNtFindExSearchNameMatch 0
#define kNtFindExSearchLimitToDirectories 1
#define kNtFindExSearchLimitToDevices 2
#define kNtFindExSearchMaxSearchOp 3
/*!BEGIN libc/nt/enum/formatmessageflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FORMATMESSAGEFLAGS_H_
#define kNtFormatMessageAllocateBuffer 0x100
#define kNtFormatMessageIgnoreInserts 0x200
#define kNtFormatMessageFromString 0x400
#define kNtFormatMessageFromHmodule 0x800
#define kNtFormatMessageFromSystem 0x1000
#define kNtFormatMessageArgumentArray 0x2000
#define kNtFormatMessageMaxWidthMask 0xff
/*!BEGIN libc/nt/enum/fsctl.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FSCTL_H_
#define kNtFsctlDisableLocalBuffering 0x000902B8u
#define kNtFsctlFilePrefetch 0x00090120u
#define kNtFsctlFilesystemGetStatistics 0x00090060u
#define kNtFsctlGetCompression 0x0009003Cu
#define kNtFsctlGetNtfsFileRecord 0x00090068u
#define kNtFsctlGetNtfsVolumeData 0x00090064u
#define kNtFsctlQueryAllocatedRanges 0x000940CFu
#define kNtFsctlScrubData 0x000902B0u
#define kNtFsctlSetCompression 0x0009C040u
#define kNtFsctlSetSparse 0x000900C4u
#define kNtFsctlSetZeroData 0x000980C8u
#define kNtFsctlGetReparsePoint 0x000900a8u
#define kNtFsctlSetReparsePoint 0x000900a4u
/*!BEGIN libc/nt/enum/fsinformationclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_FSINFORMATIONCLASS_H_
#define kNtFileFsVolumeInformation 1
#define kNtFileFsLabelInformation 2
#define kNtFileFsSizeInformation 3
#define kNtFileFsDeviceInformation 4
#define kNtFileFsAttributeInformation 5
#define kNtFileFsControlInformation 6
#define kNtFileFsFullSizeInformation 7
#define kNtFileFsObjectIdInformation 8
#define kNtFileFsDriverPathInformation 9
#define kNtFileFsInformation_MAX 10
/*!BEGIN libc/nt/enum/getfileexinfolevels.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_GETFILEEXINFOLEVELS_H_
#define kNtGetFileExInfoStandard 0
/*!BEGIN libc/nt/enum/heap.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_HEAP_H_
#define kNtHeapNoSerialize 1
#define kNtHeapGenerateExceptions 4
#define kNtHeapZeroMemory 8
#define kNtHeapReallocInPlaceOnly 16
/*!BEGIN libc/nt/enum/ht.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_HT_H_
#define kNtHterror -2
#define kNtHttransparent -1
#define kNtHtnowhere 0
#define kNtHtclient 1
#define kNtHtcaption 2
#define kNtHtsysmenu 3
#define kNtHtgrowbox 4
#define kNtHtsize kNtHtgrowbox
#define kNtHtmenu 5
#define kNtHthscroll 6
#define kNtHtvscroll 7
#define kNtHtminbutton 8
#define kNtHtmaxbutton 9
#define kNtHtleft 10
#define kNtHtright 11
#define kNtHttop 12
#define kNtHttopleft 13
#define kNtHttopright 14
#define kNtHtbottom 15
#define kNtHtbottomleft 16
#define kNtHtbottomright 17
#define kNtHtborder 18
#define kNtHtreduce kNtHtminbutton
#define kNtHtzoom kNtHtmaxbutton
#define kNtHtsizefirst kNtHtleft
#define kNtHtsizelast kNtHtbottomright
#define kNtHtobject 19
#define kNtHtclose 20
#define kNtHthelp 21
/*!BEGIN libc/nt/enum/idc.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_IDC_H_
COSMOPOLITAN_C_START_
#define kNtIdcArrow ((const char16_t *)32512)
#define kNtIdcIbeam ((const char16_t *)32513)
#define kNtIdcWait ((const char16_t *)32514)
#define kNtIdcCross ((const char16_t *)32515)
#define kNtIdcUparrow ((const char16_t *)32516)
#define kNtIdcSizenwse ((const char16_t *)32642)
#define kNtIdcSizenesw ((const char16_t *)32643)
#define kNtIdcSizewe ((const char16_t *)32644)
#define kNtIdcSizens ((const char16_t *)32645)
#define kNtIdcSizeall ((const char16_t *)32646)
#define kNtIdcNo ((const char16_t *)32648)
#define kNtIdcHand ((const char16_t *)32649)
#define kNtIdcHelp ((const char16_t *)32651)
#define kNtIdcPin ((const char16_t *)32671)
#define kNtIdcPerson ((const char16_t *)32672)
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/enum/imageauxsymboltype.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_IMAGEAUXSYMBOLTYPE_H_
#define kNtImageAuxSymbolTypeTokenDef 1
/*!BEGIN libc/nt/enum/importobjectnametype.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_IMPORTOBJECTNAMETYPE_H_
enum NtImportObjectNameType {
IMPORT_OBJECT_ORDINAL,
IMPORT_OBJECT_NAME,
IMPORT_OBJECT_NAME_NO_PREFIX,
IMPORT_OBJECT_NAME_UNDECORATE,
IMPORT_OBJECT_NAME_EXPORTAS
};
/*!BEGIN libc/nt/enum/importobjecttype.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_IMPORTOBJECTTYPE_H_
enum NtImportObjectType {
IMPORT_OBJECT_CODE,
IMPORT_OBJECT_DATA,
IMPORT_OBJECT_CONST
};
/*!BEGIN libc/nt/enum/io.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_IO_H_
#define kNtIoReparseTagSymlink 0xa000000c
#define kNtIoReparseTagMountPoint 0xa0000003
/*!BEGIN libc/nt/enum/ioctl.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_IOCTL_H_
#define kNtIoctlDiskGetDriveGeometry 0x00070000u
#define kNtIoctlAfdPoll 0x00012024u
/*!BEGIN libc/nt/enum/jobobjectinfoclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_JOBOBJECTINFOCLASS_H_
#define kNtJobObjectBasicAccountingInformation 1
#define kNtJobObjectBasicLimitInformation 2
#define kNtJobObjectBasicProcessIdList 3
#define kNtJobObjectBasicUIRestrictions 4
#define kNtJobObjectSecurityLimitInformation 5
#define kNtJobObjectEndOfJobTimeInformation 6
#define kNtJobObjectAssociateCompletionPortInformation 7
#define kNtJobObjectBasicAndIoAccountingInformation 8
#define kNtJobObjectExtendedLimitInformation 9
#define kNtJobObjectJobSetInformation 10
/*!BEGIN libc/nt/enum/keyaccess.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_KEYACCESS_H_
#define kNtKeyRead 0x00020019
#define kNtKeyWrite 0x00020006
#define kNtKeyExecute 0x00020019
#define kNtKeyAllAccess 0x000f003f
/*!BEGIN libc/nt/enum/keyedevent.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_KEYEDEVENT_H_
#define kNtKeyedeventWait 0x00000001u
#define kNtKeyedeventWake 0x00000002u
#define kNtKeyedeventAllAccess \
(kNtStandardRightsRequired | kNtKeyedeventWait | kNtKeyedeventWake)
/*!BEGIN libc/nt/enum/keyinformationclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_KEYINFORMATIONCLASS_H_
#define kNtKeyBasicInformation 0
#define kNtKeyNodeInformation 1
#define kNtKeyFullInformation 2
#define kNtKeyNameInformation 3
/*!BEGIN libc/nt/enum/kwaitreason.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_KWAITREASON_H_
#define kNtExecutive 0
#define kNtFreePage 1
#define kNtPageIn 2
#define kNtPoolAllocation 3
#define kNtDelayExecution 4
#define kNtSuspended 5
#define kNtUserRequest 6
#define kNtWrExecutive 7
#define kNtWrFreePage 8
#define kNtWrPageIn 9
#define kNtWrPoolAllocation 10
#define kNtWrDelayExecution 11
#define kNtWrSuspended 12
#define kNtWrUserRequest 13
#define kNtWrEventPair 14
#define kNtWrQueue 15
#define kNtWrLpcReceive 16
#define kNtWrLpcReply 17
#define kNtWrVirtualMemory 18
#define kNtWrPageOut 19
#define kNtWrRendezvous 20
#define kNtSpare2 21
#define kNtSpare3 22
#define kNtSpare4 23
#define kNtSpare5 24
#define kNtSpare6 25
#define kNtWrKernel 26
#define kNtMaximumWaitReason 27
/*!BEGIN libc/nt/enum/lang.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_LANG_H_
#define MAKELANGID(p, s) ((((uint16_t)(s)) << 10) | (uint16_t)(p))
#define kNtLangNeutral 0x00
#define kNtLangInvariant 0x7f
#define kNtLangAfrikaans 0x36
#define kNtLangAlbanian 0x1c
#define kNtLangAlsatian 0x84
#define kNtLangAmharic 0x5e
#define kNtLangArabic 0x01
#define kNtLangArmenian 0x2b
#define kNtLangAssamese 0x4d
#define kNtLangAzeri 0x2c
#define kNtLangAzerbaijani 0x2c
#define kNtLangBangla 0x45
#define kNtLangBashkir 0x6d
#define kNtLangBasque 0x2d
#define kNtLangBelarusian 0x23
#define kNtLangBengali 0x45
#define kNtLangBreton 0x7e
#define kNtLangBosnian 0x1a
#define kNtLangBosnianNeutral 0x781a
#define kNtLangBulgarian 0x02
#define kNtLangCatalan 0x03
#define kNtLangCentralKurdish 0x92
#define kNtLangCherokee 0x5c
#define kNtLangChinese 0x04
#define kNtLangChineseSimplified 0x04
#define kNtLangChineseTraditional 0x7c04
#define kNtLangCorsican 0x83
#define kNtLangCroatian 0x1a
#define kNtLangCzech 0x05
#define kNtLangDanish 0x06
#define kNtLangDari 0x8c
#define kNtLangDivehi 0x65
#define kNtLangDutch 0x13
#define kNtLangEnglish 0x09
#define kNtLangEstonian 0x25
#define kNtLangFaeroese 0x38
#define kNtLangFarsi 0x29
#define kNtLangFilipino 0x64
#define kNtLangFinnish 0x0b
#define kNtLangFrench 0x0c
#define kNtLangFrisian 0x62
#define kNtLangFulah 0x67
#define kNtLangGalician 0x56
#define kNtLangGeorgian 0x37
#define kNtLangGerman 0x07
#define kNtLangGreek 0x08
#define kNtLangGreenlandic 0x6f
#define kNtLangGujarati 0x47
#define kNtLangHausa 0x68
#define kNtLangHawaiian 0x75
#define kNtLangHebrew 0x0d
#define kNtLangHindi 0x39
#define kNtLangHungarian 0x0e
#define kNtLangIcelandic 0x0f
#define kNtLangIgbo 0x70
#define kNtLangIndonesian 0x21
#define kNtLangInuktitut 0x5d
#define kNtLangIrish 0x3c
#define kNtLangItalian 0x10
#define kNtLangJapanese 0x11
#define kNtLangKannada 0x4b
#define kNtLangKashmiri 0x60
#define kNtLangKazak 0x3f
#define kNtLangKhmer 0x53
#define kNtLangKiche 0x86
#define kNtLangKinyarwanda 0x87
#define kNtLangKonkani 0x57
#define kNtLangKorean 0x12
#define kNtLangKyrgyz 0x40
#define kNtLangLao 0x54
#define kNtLangLatvian 0x26
#define kNtLangLithuanian 0x27
#define kNtLangLowerSorbian 0x2e
#define kNtLangLuxembourgish 0x6e
#define kNtLangMacedonian 0x2f
#define kNtLangMalay 0x3e
#define kNtLangMalayalam 0x4c
#define kNtLangMaltese 0x3a
#define kNtLangManipuri 0x58
#define kNtLangMaori 0x81
#define kNtLangMapudungun 0x7a
#define kNtLangMarathi 0x4e
#define kNtLangMohawk 0x7c
#define kNtLangMongolian 0x50
#define kNtLangNepali 0x61
#define kNtLangNorwegian 0x14
#define kNtLangOccitan 0x82
#define kNtLangOdia 0x48
#define kNtLangOriya 0x48
#define kNtLangPashto 0x63
#define kNtLangPersian 0x29
#define kNtLangPolish 0x15
#define kNtLangPortuguese 0x16
#define kNtLangPular 0x67
#define kNtLangPunjabi 0x46
#define kNtLangQuechua 0x6b
#define kNtLangRomanian 0x18
#define kNtLangRomansh 0x17
#define kNtLangRussian 0x19
#define kNtLangSakha 0x85
#define kNtLangSami 0x3b
#define kNtLangSanskrit 0x4f
#define kNtLangScottishGaelic 0x91
#define kNtLangSerbian 0x1a
#define kNtLangSerbianNeutral 0x7c1a
#define kNtLangSindhi 0x59
#define kNtLangSinhalese 0x5b
#define kNtLangSlovak 0x1b
#define kNtLangSlovenian 0x24
#define kNtLangSotho 0x6c
#define kNtLangSpanish 0x0a
#define kNtLangSwahili 0x41
#define kNtLangSwedish 0x1d
#define kNtLangSyriac 0x5a
#define kNtLangTajik 0x28
#define kNtLangTamazight 0x5f
#define kNtLangTamil 0x49
#define kNtLangTatar 0x44
#define kNtLangTelugu 0x4a
#define kNtLangThai 0x1e
#define kNtLangTibetan 0x51
#define kNtLangTigrigna 0x73
#define kNtLangTigrinya 0x73
#define kNtLangTswana 0x32
#define kNtLangTurkish 0x1f
#define kNtLangTurkmen 0x42
#define kNtLangUighur 0x80
#define kNtLangUkrainian 0x22
#define kNtLangUpperSorbian 0x2e
#define kNtLangUrdu 0x20
#define kNtLangUzbek 0x43
#define kNtLangValencian 0x03
#define kNtLangVietnamese 0x2a
#define kNtLangWelsh 0x52
#define kNtLangWolof 0x88
#define kNtLangXhosa 0x34
#define kNtLangYakut 0x85
#define kNtLangYi 0x78
#define kNtLangYoruba 0x6a
#define kNtLangZulu 0x35
#define kNtSublangNeutral 0x00
#define kNtSublangDefault 0x01
#define kNtSublangSysDefault 0x02
#define kNtSublangCustomDefault 0x03
#define kNtSublangCustomUnspecified 0x04
#define kNtSublangUiCustomDefault 0x05
#define kNtSublangAfrikaansSouthAfrica 0x01
#define kNtSublangAlbanianAlbania 0x01
#define kNtSublangAlsatianFrance 0x01
#define kNtSublangAmharicEthiopia 0x01
#define kNtSublangArabicSaudiArabia 0x01
#define kNtSublangArabicIraq 0x02
#define kNtSublangArabicEgypt 0x03
#define kNtSublangArabicLibya 0x04
#define kNtSublangArabicAlgeria 0x05
#define kNtSublangArabicMorocco 0x06
#define kNtSublangArabicTunisia 0x07
#define kNtSublangArabicOman 0x08
#define kNtSublangArabicYemen 0x09
#define kNtSublangArabicSyria 0x0a
#define kNtSublangArabicJordan 0x0b
#define kNtSublangArabicLebanon 0x0c
#define kNtSublangArabicKuwait 0x0d
#define kNtSublangArabicUae 0x0e
#define kNtSublangArabicBahrain 0x0f
#define kNtSublangArabicQatar 0x10
#define kNtSublangArmenianArmenia 0x01
#define kNtSublangAssameseIndia 0x01
#define kNtSublangAzeriLatin 0x01
#define kNtSublangAzeriCyrillic 0x02
#define kNtSublangAzerbaijaniAzerbaijanLatin 0x01
#define kNtSublangAzerbaijaniAzerbaijanCyrillic 0x02
#define kNtSublangBanglaIndia 0x01
#define kNtSublangBanglaBangladesh 0x02
#define kNtSublangBashkirRussia 0x01
#define kNtSublangBasqueBasque 0x01
#define kNtSublangBelarusianBelarus 0x01
#define kNtSublangBengaliIndia 0x01
#define kNtSublangBengaliBangladesh 0x02
#define kNtSublangBosnianBosniaHerzegovinaLatin 0x05
#define kNtSublangBosnianBosniaHerzegovinaCyrillic 0x08
#define kNtSublangBretonFrance 0x01
#define kNtSublangBulgarianBulgaria 0x01
#define kNtSublangCatalanCatalan 0x01
#define kNtSublangCentralKurdishIraq 0x01
#define kNtSublangCherokeeCherokee 0x01
#define kNtSublangChineseTraditional 0x01
#define kNtSublangChineseSimplified 0x02
#define kNtSublangChineseHongkong 0x03
#define kNtSublangChineseSingapore 0x04
#define kNtSublangChineseMacau 0x05
#define kNtSublangCorsicanFrance 0x01
#define kNtSublangCzechCzechRepublic 0x01
#define kNtSublangCroatianCroatia 0x01
#define kNtSublangCroatianBosniaHerzegovinaLatin 0x04
#define kNtSublangDanishDenmark 0x01
#define kNtSublangDariAfghanistan 0x01
#define kNtSublangDivehiMaldives 0x01
#define kNtSublangDutch 0x01
#define kNtSublangDutchBelgian 0x02
#define kNtSublangEnglishUs 0x01
#define kNtSublangEnglishUk 0x02
#define kNtSublangEnglishAus 0x03
#define kNtSublangEnglishCan 0x04
#define kNtSublangEnglishNz 0x05
#define kNtSublangEnglishEire 0x06
#define kNtSublangEnglishSouthAfrica 0x07
#define kNtSublangEnglishJamaica 0x08
#define kNtSublangEnglishCaribbean 0x09
#define kNtSublangEnglishBelize 0x0a
#define kNtSublangEnglishTrinidad 0x0b
#define kNtSublangEnglishZimbabwe 0x0c
#define kNtSublangEnglishPhilippines 0x0d
#define kNtSublangEnglishIndia 0x10
#define kNtSublangEnglishMalaysia 0x11
#define kNtSublangEnglishSingapore 0x12
#define kNtSublangEstonianEstonia 0x01
#define kNtSublangFaeroeseFaroeIslands 0x01
#define kNtSublangFilipinoPhilippines 0x01
#define kNtSublangFinnishFinland 0x01
#define kNtSublangFrench 0x01
#define kNtSublangFrenchBelgian 0x02
#define kNtSublangFrenchCanadian 0x03
#define kNtSublangFrenchSwiss 0x04
#define kNtSublangFrenchLuxembourg 0x05
#define kNtSublangFrenchMonaco 0x06
#define kNtSublangFrisianNetherlands 0x01
#define kNtSublangFulahSenegal 0x02
#define kNtSublangGalicianGalician 0x01
#define kNtSublangGeorgianGeorgia 0x01
#define kNtSublangGerman 0x01
#define kNtSublangGermanSwiss 0x02
#define kNtSublangGermanAustrian 0x03
#define kNtSublangGermanLuxembourg 0x04
#define kNtSublangGermanLiechtenstein 0x05
#define kNtSublangGreekGreece 0x01
#define kNtSublangGreenlandicGreenland 0x01
#define kNtSublangGujaratiIndia 0x01
#define kNtSublangHausaNigeriaLatin 0x01
#define kNtSublangHawaiianUs 0x01
#define kNtSublangHebrewIsrael 0x01
#define kNtSublangHindiIndia 0x01
#define kNtSublangHungarianHungary 0x01
#define kNtSublangIcelandicIceland 0x01
#define kNtSublangIgboNigeria 0x01
#define kNtSublangIndonesianIndonesia 0x01
#define kNtSublangInuktitutCanada 0x01
#define kNtSublangInuktitutCanadaLatin 0x02
#define kNtSublangIrishIreland 0x02
#define kNtSublangItalian 0x01
#define kNtSublangItalianSwiss 0x02
#define kNtSublangJapaneseJapan 0x01
#define kNtSublangKannadaIndia 0x01
#define kNtSublangKashmiriSasia 0x02
#define kNtSublangKashmiriIndia 0x02
#define kNtSublangKazakKazakhstan 0x01
#define kNtSublangKhmerCambodia 0x01
#define kNtSublangKicheGuatemala 0x01
#define kNtSublangKinyarwandaRwanda 0x01
#define kNtSublangKonkaniIndia 0x01
#define kNtSublangKorean 0x01
#define kNtSublangKyrgyzKyrgyzstan 0x01
#define kNtSublangLaoLao 0x01
#define kNtSublangLatvianLatvia 0x01
#define kNtSublangLithuanian 0x01
#define kNtSublangLowerSorbianGermany 0x02
#define kNtSublangLuxembourgishLuxembourg 0x01
#define kNtSublangMacedonianMacedonia 0x01
#define kNtSublangMalayMalaysia 0x01
#define kNtSublangMalayBruneiDarussalam 0x02
#define kNtSublangMalayalamIndia 0x01
#define kNtSublangMalteseMalta 0x01
#define kNtSublangMaoriNewZealand 0x01
#define kNtSublangMapudungunChile 0x01
#define kNtSublangMarathiIndia 0x01
#define kNtSublangMohawkMohawk 0x01
#define kNtSublangMongolianCyrillicMongolia 0x01
#define kNtSublangMongolianPrc 0x02
#define kNtSublangNepaliIndia 0x02
#define kNtSublangNepaliNepal 0x01
#define kNtSublangNorwegianBokmal 0x01
#define kNtSublangNorwegianNynorsk 0x02
#define kNtSublangOccitanFrance 0x01
#define kNtSublangOdiaIndia 0x01
#define kNtSublangOriyaIndia 0x01
#define kNtSublangPashtoAfghanistan 0x01
#define kNtSublangPersianIran 0x01
#define kNtSublangPolishPoland 0x01
#define kNtSublangPortuguese 0x02
#define kNtSublangPortugueseBrazilian 0x01
#define kNtSublangPularSenegal 0x02
#define kNtSublangPunjabiIndia 0x01
#define kNtSublangPunjabiPakistan 0x02
#define kNtSublangQuechuaBolivia 0x01
#define kNtSublangQuechuaEcuador 0x02
#define kNtSublangQuechuaPeru 0x03
#define kNtSublangRomanianRomania 0x01
#define kNtSublangRomanshSwitzerland 0x01
#define kNtSublangRussianRussia 0x01
#define kNtSublangSakhaRussia 0x01
#define kNtSublangSamiNorthernNorway 0x01
#define kNtSublangSamiNorthernSweden 0x02
#define kNtSublangSamiNorthernFinland 0x03
#define kNtSublangSamiLuleNorway 0x04
#define kNtSublangSamiLuleSweden 0x05
#define kNtSublangSamiSouthernNorway 0x06
#define kNtSublangSamiSouthernSweden 0x07
#define kNtSublangSamiSkoltFinland 0x08
#define kNtSublangSamiInariFinland 0x09
#define kNtSublangSanskritIndia 0x01
#define kNtSublangScottishGaelic 0x01
#define kNtSublangSerbianBosniaHerzegovinaLatin 0x06
#define kNtSublangSerbianBosniaHerzegovinaCyrillic 0x07
#define kNtSublangSerbianMontenegroLatin 0x0b
#define kNtSublangSerbianMontenegroCyrillic 0x0c
#define kNtSublangSerbianSerbiaLatin 0x09
#define kNtSublangSerbianSerbiaCyrillic 0x0a
#define kNtSublangSerbianCroatia 0x01
#define kNtSublangSerbianLatin 0x02
#define kNtSublangSerbianCyrillic 0x03
#define kNtSublangSindhiIndia 0x01
#define kNtSublangSindhiPakistan 0x02
#define kNtSublangSindhiAfghanistan 0x02
#define kNtSublangSinhaleseSriLanka 0x01
#define kNtSublangSothoNorthernSouthAfrica 0x01
#define kNtSublangSlovakSlovakia 0x01
#define kNtSublangSlovenianSlovenia 0x01
#define kNtSublangSpanish 0x01
#define kNtSublangSpanishMexican 0x02
#define kNtSublangSpanishModern 0x03
#define kNtSublangSpanishGuatemala 0x04
#define kNtSublangSpanishCostaRica 0x05
#define kNtSublangSpanishPanama 0x06
#define kNtSublangSpanishDominicanRepublic 0x07
#define kNtSublangSpanishVenezuela 0x08
#define kNtSublangSpanishColombia 0x09
#define kNtSublangSpanishPeru 0x0a
#define kNtSublangSpanishArgentina 0x0b
#define kNtSublangSpanishEcuador 0x0c
#define kNtSublangSpanishChile 0x0d
#define kNtSublangSpanishUruguay 0x0e
#define kNtSublangSpanishParaguay 0x0f
#define kNtSublangSpanishBolivia 0x10
#define kNtSublangSpanishElSalvador 0x11
#define kNtSublangSpanishHonduras 0x12
#define kNtSublangSpanishNicaragua 0x13
#define kNtSublangSpanishPuertoRico 0x14
#define kNtSublangSpanishUs 0x15
#define kNtSublangSwahiliKenya 0x01
#define kNtSublangSwedish 0x01
#define kNtSublangSwedishFinland 0x02
#define kNtSublangSyriacSyria 0x01
#define kNtSublangTajikTajikistan 0x01
#define kNtSublangTamazightAlgeriaLatin 0x02
#define kNtSublangTamazightMoroccoTifinagh 0x04
#define kNtSublangTamilIndia 0x01
#define kNtSublangTamilSriLanka 0x02
#define kNtSublangTatarRussia 0x01
#define kNtSublangTeluguIndia 0x01
#define kNtSublangThaiThailand 0x01
#define kNtSublangTibetanPrc 0x01
#define kNtSublangTigrignaEritrea 0x02
#define kNtSublangTigrinyaEritrea 0x02
#define kNtSublangTigrinyaEthiopia 0x01
#define kNtSublangTswanaBotswana 0x02
#define kNtSublangTswanaSouthAfrica 0x01
#define kNtSublangTurkishTurkey 0x01
#define kNtSublangTurkmenTurkmenistan 0x01
#define kNtSublangUighurPrc 0x01
#define kNtSublangUkrainianUkraine 0x01
#define kNtSublangUpperSorbianGermany 0x01
#define kNtSublangUrduPakistan 0x01
#define kNtSublangUrduIndia 0x02
#define kNtSublangUzbekLatin 0x01
#define kNtSublangUzbekCyrillic 0x02
#define kNtSublangValencianValencia 0x02
#define kNtSublangVietnameseVietnam 0x01
#define kNtSublangWelshUnitedKingdom 0x01
#define kNtSublangWolofSenegal 0x01
#define kNtSublangXhosaSouthAfrica 0x01
#define kNtSublangYakutRussia 0x01
#define kNtSublangYiPrc 0x01
#define kNtSublangYorubaNigeria 0x01
#define kNtSublangZuluSouthAfrica 0x01
/*!BEGIN libc/nt/enum/loadlibrarysearch.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_LOADLIBRARYSEARCH_H_
#define kNtLoadLibrarySearchApplicationDir 0x00000200u
#define kNtLoadLibrarySearchSearchSystem32 0x00000800u
#define kNtLoadLibrarySearchUserDirs 0x00000400u
#define kNtLoadLibrarySearchDefaultDirs 0x00001000u
/*!BEGIN libc/nt/enum/lockfile.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_LOCKFILE_H_
#define kNtLockfileFailImmediately 1
#define kNtLockfileExclusiveLock 2
/*!BEGIN libc/nt/enum/mb.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_MB_H_
#define kNtMbOk 0x00000000
#define kNtMbOkcancel 0x00000001
#define kNtMbAbortretryignore 0x00000002
#define kNtMbYesnocancel 0x00000003
#define kNtMbYesno 0x00000004
#define kNtMbRetrycancel 0x00000005
#define kNtMbCanceltrycontinue 0x00000006
#define kNtMbIconhand 0x00000010
#define kNtMbIconquestion 0x00000020
#define kNtMbIconexclamation 0x00000030
#define kNtMbIconasterisk 0x00000040
#define kNtMbUsericon 0x00000080
#define kNtMbIconwarning kNtMbIconexclamation
#define kNtMbIconerror kNtMbIconhand
#define kNtMbIconinformation kNtMbIconasterisk
#define kNtMbIconstop kNtMbIconhand
#define kNtMbDefbutton1 0x00000000
#define kNtMbDefbutton2 0x00000100
#define kNtMbDefbutton3 0x00000200
#define kNtMbDefbutton4 0x00000300
#define kNtMbApplmodal 0x00000000
#define kNtMbSystemmodal 0x00001000
#define kNtMbTaskmodal 0x00002000
#define kNtMbHelp 0x00004000
#define kNtMbNofocus 0x00008000
#define kNtMbSetforeground 0x00010000
#define kNtMbDefaultDesktopOnly 0x00020000
#define kNtMbTopmost 0x00040000
#define kNtMbRight 0x00080000
#define kNtMbRtlreading 0x00100000
#define kNtMbServiceNotification 0x00200000
#define kNtMbServiceNotificationNt3x 0x00040000
#define kNtMbTypemask 0x0000000F
#define kNtMbIconmask 0x000000F0
#define kNtMbDefmask 0x00000F00
#define kNtMbModemask 0x00003000
#define kNtMbMiscmask 0x0000C000
/*!BEGIN libc/nt/enum/memflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_MEMFLAGS_H_
#define kNtMemCommit 0x1000 /* perform physical memory reservation step */
#define kNtMemReserve 0x2000 /* perform virtual memory reservation step */
#define kNtMemDecommit 0x4000
#define kNtMemRelease 0x8000
#define kNtMemFree 0x10000
#define kNtMemPrivate 0x20000
#define kNtMemMapped 0x40000
#define kNtMemReset 0x80000
#define kNtMemTopDown 0x100000
#define kNtMemWriteWatch 0x200000
#define kNtMemPhysical 0x400000
#define kNtMemImage 0x1000000
#define kNtMemLargePages 0x20000000
#define kNtMem4mbPages 0x80000000
#define kNtMemReplacePlaceholder 0x00004000
/*!BEGIN libc/nt/enum/memoryinformationclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_MEMORYINFORMATIONCLASS_H_
#define kNtMemoryBasicInformation 0
#define kNtMemoryWorkingSetList 1
#define kNtMemorySectionName 2
#define kNtMemoryBasicVlmInformation 3
/*!BEGIN libc/nt/enum/mf.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_MF_H_
#define kNtMfInsert 0x00000000
#define kNtMfChange 0x00000080
#define kNtMfAppend 0x00000100
#define kNtMfDelete 0x00000200
#define kNtMfRemove 0x00001000
#define kNtMfBycommand 0x00000000
#define kNtMfByposition 0x00000400
#define kNtMfSeparator 0x00000800
#define kNtMfEnabled 0x00000000
#define kNtMfGrayed 0x00000001
#define kNtMfDisabled 0x00000002
#define kNtMfUnchecked 0x00000000
#define kNtMfChecked 0x00000008
#define kNtMfUsecheckbitmaps 0x00000200
#define kNtMfString 0x00000000
#define kNtMfBitmap 0x00000004
#define kNtMfOwnerdraw 0x00000100
#define kNtMfPopup 0x00000010
#define kNtMfMenubarbreak 0x00000020
#define kNtMfMenubreak 0x00000040
#define kNtMfUnhilite 0x00000000
#define kNtMfHilite 0x00000080
#define kNtMfDefault 0x00001000
#define kNtMfSysmenu 0x00002000
#define kNtMfHelp 0x00004000
#define kNtMfRightjustify 0x00004000
#define kNtMfMouseselect 0x00008000
/*!BEGIN libc/nt/enum/mk.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_MK_H_
#define kNtMkLbutton 0x0001
#define kNtMkRbutton 0x0002
#define kNtMkShift 0x0004
#define kNtMkControl 0x0008
#define kNtMkMbutton 0x0010
#define kNtMkXbutton1 0x0020
#define kNtMkXbutton2 0x0040
/*!BEGIN libc/nt/enum/movefileexflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_MOVEFILEEXFLAGS_H_
#define kNtMovefileReplaceExisting 1
#define kNtMovefileCopyAllowed 2
#define kNtMovefileDelayUntilReboot 4
#define kNtMovefileWriteThrough 8
#define kNtMovefileCreateHardlink 16
#define kNtMovefileFailIfNotTrackable 32
/*!BEGIN libc/nt/enum/objectinformationclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_OBJECTINFORMATIONCLASS_H_
#define kNtObjectBasicInformation 0 /*→ struct NtObjectBasicInformation */
#define kNtObjectNameInformation 1 /*→ etc. */
#define kNtObjectTypeInformation 2
#define kNtObjectAllInformation 3
#define kNtObjectDataInformation 4
/*!BEGIN libc/nt/enum/offerpriority.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_OFFERPRIORITY_H_
/* TODO(jart): Are these values correct? */
#define kNtVmOfferPriorityVeryLow 1 /* 0x00001000? */
#define kNtVmOfferPriorityLow 2 /* 0x00002000? */
#define kNtVmOfferPriorityBelowNormal 3 /* 0x00002000? */
#define kNtVmOfferPriorityNormal 4 /* 0x00002000? */
/*!BEGIN libc/nt/enum/ofn.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_OFN_H_
#define kNtOfnReadonly 0x00000001
#define kNtOfnOverwriteprompt 0x00000002
#define kNtOfnHidereadonly 0x00000004
#define kNtOfnNochangedir 0x00000008
#define kNtOfnShowhelp 0x00000010
#define kNtOfnEnablehook 0x00000020
#define kNtOfnEnabletemplate 0x00000040
#define kNtOfnEnabletemplatehandle 0x00000080
#define kNtOfnNovalidate 0x00000100
#define kNtOfnAllowmultiselect 0x00000200
#define kNtOfnExtensiondifferent 0x00000400
#define kNtOfnPathmustexist 0x00000800
#define kNtOfnFilemustexist 0x00001000
#define kNtOfnCreateprompt 0x00002000
#define kNtOfnShareaware 0x00004000
#define kNtOfnNoreadonlyreturn 0x00008000
#define kNtOfnNotestfilecreate 0x00010000
#define kNtOfnNonetworkbutton 0x00020000
#define kNtOfnNolongnames 0x00040000
#define kNtOfnExplorer 0x00080000
#define kNtOfnNodereferencelinks 0x00100000
#define kNtOfnLongnames 0x00200000
#define kNtOfnEnableincludenotify 0x00400000
#define kNtOfnEnablesizing 0x00800000
#define kNtOfnDontaddtorecent 0x02000000
#define kNtOfnForceshowhidden 0x10000000
/*!BEGIN libc/nt/enum/pageflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_PAGEFLAGS_H_
/* Pick One */
#define kNtPageNoaccess 0x001
#define kNtPageReadonly 0x002
#define kNtPageReadwrite 0x004
#define kNtPageWritecopy 0x008
#define kNtPageExecute 0x010
#define kNtPageExecuteRead 0x020
#define kNtPageExecuteReadwrite 0x040
#define kNtPageExecuteWritecopy 0x080
#define kNtPageGuard 0x100
#define kNtPageNocache 0x200
#define kNtPageWritecombine 0x400
/* These may be OR'd */
#define kNtSecReserve 0x04000000
#define kNtSecCommit 0x08000000 /* default */
#define kNtSecImageNoExecute 0x11000000
#define kNtSecImage 0x01000000
#define kNtSecNocache 0x10000000
#define kNtSecLargePages 0x80000000
#define kNtSecWritecombine 0x40000000
/*!BEGIN libc/nt/enum/pdh.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_PDH_H_
#define kNtPdhFmtRaw 0x00000010u
#define kNtPdhFmtAnsi 0x00000020u
#define kNtPdhFmtUnicode 0x00000040u
#define kNtPdhFmtLong 0x00000100u
#define kNtPdhFmtDouble 0x00000200u
#define kNtPdhFmtLarge 0x00000400u
#define kNtPdhFmtNoscale 0x00001000u
#define kNtPdhFmt1000 0x00002000u
#define kNtPdhFmtNodata 0x00004000u
#define kNtPdhFmtNocap100 0x00008000u
#define kNtPerfDetailCostly 0x00010000u
#define kNtPerfDetailStandard 0x0000FFFFu
/*!BEGIN libc/nt/enum/processaccess.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_PROCESSACCESS_H_
#define kNtProcessCreateProcess 0x0080u
#define kNtProcessCreateThread 0x0002u
#define kNtProcessDupHandle 0x0040u
#define kNtProcessQueryInformation 0x0400u
#define kNtProcessQueryLimitedInformation 0x1000u
#define kNtProcessSetInformation 0x0200u
#define kNtProcessSetQuota 0x0100u
#define kNtProcessSuspendResume 0x0800u
#define kNtProcessTerminate 0x0001u
#define kNtProcessVmOperation 0x0008u
#define kNtProcessVmRead 0x0010u
#define kNtProcessVmWrite 0x0020u
#define kNtProcessSynchronize kNtSynchronize
#define kNtProcessAllAccess \
(kNtStandardRightsRequired | kNtSynchronize | 0xffffu)
/*!BEGIN libc/nt/enum/processcreationflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_PROCESSCREATIONFLAGS_H_
#define kNtIdlePriorityClass 0x00000040u
#define kNtBelowNormalPriorityClass 0x00004000u
#define kNtNormalPriorityClass 0x00000020u
#define kNtAboveNormalPriorityClass 0x00008000u
#define kNtHighPriorityClass 0x00000080u
#define kNtRealtimePriorityClass 0x00000100u
#define kNtDebugProcess 0x00000001u
#define kNtDebugOnlyThisProcess 0x00000002u
#define kNtCreateSuspended 0x00000004u
#define kNtDetachedProcess 0x00000008u
#define kNtCreateNewConsole 0x00000010u
#define kNtCreateNewProcessGroup 0x00000200u
#define kNtCreateUnicodeEnvironment 0x00000400u
#define kNtCreateSeparateWowVdm 0x00000800u
#define kNtCreateSharedWowVdm 0x00001000u
#define kNtCreateForcedos 0x00002000u
#define kNtInheritParentAffinity 0x00010000u
#define kNtCreateProtectedProcess 0x00040000u
#define kNtExtendedStartupinfoPresent 0x00080000u
#define kNtProcessModeBackgroundBegin 0x00100000u
#define kNtProcessModeBackgroundEnd 0x00200000u
#define kNtCreateSecureProcess 0x00400000u
#define kNtCreateBreakawayFromJob 0x01000000u
#define kNtCreatePreserveCodeAuthzLevel 0x02000000u
#define kNtCreateDefaultErrorMode 0x04000000u
#define kNtCreateNoWindow 0x08000000u
#define kNtProfileUser 0x10000000u
#define kNtProfileKernel 0x20000000u
#define kNtProfileServer 0x40000000u
#define kNtCreateIgnoreSystemDefault 0x80000000u
#define kNtStackSizeParamIsAReservation 0x00010000
/*!BEGIN libc/nt/enum/processinfoclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_PROCESSINFOCLASS_H_
#define kNtProcessBasicInformation 0
#define kNtProcessQuotaLimits 1
#define kNtProcessIoCounters 2
#define kNtProcessVmCounters 3
#define kNtProcessTimes 4
#define kNtProcessBasePriority 5
#define kNtProcessRaisePriority 6
#define kNtProcessDebugPort 7
#define kNtProcessExceptionPort 8
#define kNtProcessAccessToken 9
#define kNtProcessWow64Information 26
#define kNtProcessImageFileName 27
/*!BEGIN libc/nt/enum/procthreadattributes.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_PROCTHREADATTRIBUTES_H_
#define kNtProcThreadAttributeReplaceValue 1
#define kNtProcThreadAttributeHandleList 0x00020002
/*!BEGIN libc/nt/enum/progress.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_PROGRESS_H_
#define kNtProgressContinue 0
#define kNtProgressCancel 1
#define kNtProgressStop 2
#define kNtProgressQuiet 3
/*!BEGIN libc/nt/enum/pseudoconsole.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_PSEUDOCONSOLE_H_
#define kNtPseudoconsoleInheritCursor 1
/*!BEGIN libc/nt/enum/pwr.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_PWR_H_
#define kNtPwrOk 1
#define kNtPwrFail (-1)
#define kNtPwrSuspendrequest 1
#define kNtPwrSuspendresume 2
#define kNtPwrCriticalresume 3
/*!BEGIN libc/nt/enum/rdw.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_RDW_H_
#define kNtRdwInvalidate 0x0001
#define kNtRdwInternalpaint 0x0002
#define kNtRdwErase 0x0004
#define kNtRdwValidate 0x0008
#define kNtRdwNointernalpaint 0x0010
#define kNtRdwNoerase 0x0020
#define kNtRdwNochildren 0x0040
#define kNtRdwAllchildren 0x0080
#define kNtRdwUpdatenow 0x0100
#define kNtRdwErasenow 0x0200
#define kNtRdwFrame 0x0400
#define kNtRdwNoframe 0x0800
/*!BEGIN libc/nt/enum/reggetvalueflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_REGGETVALUEFLAGS_H_
#define kNtRrfRtRegNone 0x00000001
#define kNtRrfRtRegSz 0x00000002
#define kNtRrfRtRegExpandSz 0x00000004
#define kNtRrfRtRegBinary 0x00000008
#define kNtRrfRtRegDword 0x00000010
#define kNtRrfRtRegMultiSz 0x00000020
#define kNtRrfRtRegQword 0x00000040
#define kNtRrfRtDword (kNtRrfRtRegBinary | kNtRrfRtRegDword)
#define kNtRrfRtQword (kNtRrfRtRegBinary | kNtRrfRtRegQword)
#define kNtRrfRtAny 0x0000ffff
#define kNtRrfSubkeyWow6464key 0x00010000
#define kNtRrfSubkeyWow6432key 0x00020000
#define kNtRrfWow64Mask 0x00030000
#define kNtRrfNoexpand 0x10000000
#define kNtRrfZeroonfailure 0x20000000
/*!BEGIN libc/nt/enum/regtype.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_REGTYPE_H_
#define kNtRegNone 0
#define kNtRegSz 1 /* UTF-16 string */
#define kNtRegExpandSz 2 /* UTF-16 string w/ env vars refs */
#define kNtRegBinary 3
#define kNtRegDword 4
#define kNtRegDwordBigEndian 5
#define kNtRegLink 6
#define kNtRegMultiSz 7 /* UTF-16 double-nul-terminated */
#define kNtRegResourceList 8
#define kNtRegFullResourceDescriptor 9
#define kNtRegResourceRequirementsList 10
#define kNtRegQword 11
/*!BEGIN libc/nt/enum/replacefile.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_REPLACEFILE_H_
#define kNtReplacefileWriteThrough 1
#define kNtReplacefileIgnoreMergeErrors 2
#define kNtReplacefileIgnoreAclErrors 4
/*!BEGIN libc/nt/enum/sc.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SC_H_
#define kNtScSize 0xF000
#define kNtScMove 0xF010
#define kNtScMinimize 0xF020
#define kNtScMaximize 0xF030
#define kNtScNextwindow 0xF040
#define kNtScPrevwindow 0xF050
#define kNtScClose 0xF060
#define kNtScVscroll 0xF070
#define kNtScHscroll 0xF080
#define kNtScMousemenu 0xF090
#define kNtScKeymenu 0xF100
#define kNtScArrange 0xF110
#define kNtScRestore 0xF120
#define kNtScTasklist 0xF130
#define kNtScScreensave 0xF140
#define kNtScHotkey 0xF150
#define kNtScDefault 0xF160
#define kNtScMonitorpower 0xF170
#define kNtScContexthelp 0xF180
#define kNtScSeparator 0xF00F
/*!BEGIN libc/nt/enum/sectioninformationclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SECTIONINFORMATIONCLASS_H_
#define kNtSectionBasicInformation 0
#define kNtSectionImageInformation 1
/*!BEGIN libc/nt/enum/sectioninherit.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SECTIONINHERIT_H_
enum NtSectionInherit { kNtViewShare = 1, kNtViewUnmap = 2 };
/*!BEGIN libc/nt/enum/sectionmapflags.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SECTIONMAPFLAGS_H_
#define kNtSectionQuery 0x0001
#define kNtSectionMapWrite 0x0002
#define kNtSectionMapRead 0x0004
#define kNtSectionMapExecute 0x0008
#define kNtSectionExtendSize 0x0010
#define kNtSectionMapExecuteExplicit 0x0020
/*!BEGIN libc/nt/enum/securityimpersonationlevel.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SECURITYIMPERSONATIONLEVEL_H_
#define kNtSecurityAnonymous 0
#define kNtSecurityIdentification 1
#define kNtSecurityImpersonation 2
#define kNtSecurityDelegation 3
/*!BEGIN libc/nt/enum/securityinformation.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SECURITYINFORMATION_H_
#define kNtOwnerSecurityInformation 0x00000001
#define kNtGroupSecurityInformation 0x00000002
#define kNtDaclSecurityInformation 0x00000004
#define kNtSaclSecurityInformation 0x00000008
#define kNtLabelSecurityInformation 0x00000010
#define kNtAttributeSecurityInformation 0x00000020
#define kNtScopeSecurityInformation 0x00000040
#define kNtProcessTrustLabelSecurityInformation 0x00000080
#define kNtAccessFilterSecurityInformation 0x00000100
#define kNtBackupSecurityInformation 0x00010000
#define kNtProtectedDaclSecurityInformation 0x80000000
#define kNtProtectedSaclSecurityInformation 0x40000000
#define kNtUnprotectedDaclSecurityInformation 0x20000000
#define kNtUnprotectedSaclSecurityInformation 0x10000000
/*!BEGIN libc/nt/enum/signal.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SIGNAL_H_
#define kNtSignalBreakpoint 0x80000003u
#define kNtSignalIllegalInstruction 0xC000001Du
#define kNtSignalPrivInstruction 0xC0000096u
#define kNtSignalGuardPage 0x80000001u
#define kNtSignalAccessViolation 0xC0000005u
#define kNtSignalInPageError 0xC0000006u
#define kNtSignalInvalidHandle 0xC0000008u
#define kNtSignalInvalidParameter 0xC000000du
#define kNtSignalFltDenormalOperand 0xC000008Du
#define kNtSignalFltDivideByZero 0xC000008Eu
#define kNtSignalFltInexactResult 0xC000008Fu
#define kNtSignalFltInvalidOperation 0xC0000090u
#define kNtSignalFltOverflow 0xC0000091u
#define kNtSignalFltStackCheck 0xC0000092u
#define kNtSignalFltUnderflow 0xC0000093u
#define kNtSignalIntegerDivideByZero 0xC0000094u
#define kNtSignalDllNotFound 0xC0000135u
#define kNtSignalOrdinalNotFound 0xC0000138u
#define kNtSignalEntrypointNotFound 0xC0000139u
#define kNtSignalControlCExit 0xC000013Au
#define kNtSignalDllInitFailed 0xC0000142u
#define kNtSignalFloatMultipleFaults 0xC00002B4u
#define kNtSignalFloatMultipleTraps 0xC00002B5u
#define kNtSignalAssertionFailure 0xC0000420u
/*!BEGIN libc/nt/enum/sio.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SIO_H_
#define kNtSioAbsorbRtralert 0x98000005u
#define kNtSioAcquirePortReservation 0x98000064u
#define kNtSioAddressListChange 0x28000017u
#define kNtSioAddressListQuery 0x48000016u
#define kNtSioAddressListSort 0xc8000019u
#define kNtSioApplyTransportSetting 0x98000013u
#define kNtSioAssociateHandle 0x88000001u
#define kNtSioAssociatePortReservation 0x98000066u
#define kNtSioBaseHandle 0x48000022u
#define kNtSioBspHandlePoll 0x4800001Du
#define kNtSioDeletePeerTargetName 0x980000cbu
#define kNtSioEnableCircularQueueing 0x28000002u
#define kNtSioFindRoute 0x48000003u
#define kNtSioFlush 0x28000004u
#define kNtSioGetBroadcastAddress 0x48000005u
#define kNtSioGetExtensionFunctionPointer 0xc8000006u
#define kNtSioGetGroupQos 0xc8000008u
#define kNtSioGetInterfaceList 0x4008747fu
#define kNtSioGetMultipleExtensionFunctionPointer 0xc8000024u
#define kNtSioGetQos 0xc8000007u
#define kNtSioIndexAddMcast 0x9800000au
#define kNtSioIndexBind 0x98000008u
#define kNtSioIndexDelMcast 0x9800000bu
#define kNtSioIndexMcastif 0x98000009u
#define kNtSioKeepaliveVals 0x98000004u
#define kNtSioLimitBroadcasts 0x98000007u
#define kNtSioLoopbackFastPath 0x98000010u
#define kNtSioMulticastScope 0x8800000au
#define kNtSioMultipointLoopback 0x88000009u
#define kNtSioQueryRssProcessorInfo 0x48000025u
#define kNtSioQueryRssScalabilityInfo 0x580000d2u
#define kNtSioQuerySecurity 0xd80000c9u
#define kNtSioQueryTargetPnpHandle 0x48000018u
#define kNtSioQueryTransportSetting 0x98000014u
#define kNtSioQueryWfpAleEndpointHandle 0x580000cdu
#define kNtSioQueryWfpConnectionRedirectContext 0x980000ddu
#define kNtSioQueryWfpConnectionRedirectRecords 0x980000dcu
#define kNtSioRcvall 0x98000001u
#define kNtSioRcvallIf 0x9800000eu
#define kNtSioRcvallIgmpmcast 0x98000003u
#define kNtSioRcvallMcast 0x98000002u
#define kNtSioRcvallMcastIf 0x9800000du
#define kNtSioReleasePortReservation 0x98000065u
#define kNtSioReserved1 0x8800001au
#define kNtSioReserved2 0x88000021u
#define kNtSioRoutingInterfaceChange 0x88000015u
#define kNtSioRoutingInterfaceQuery 0xc8000014u
#define kNtSioSetGroupQos 0x8800000cu
#define kNtSioSetPeerTargetName 0x980000cau
#define kNtSioSetPriorityHint 0x98000018u
#define kNtSioSetQos 0x8800000bu
#define kNtSioSetSecurity 0x980000c8u
#define kNtSioSetWfpConnectionRedirectRecords 0x980000deu
#define kNtSioSocketCloseNotify 0x9800000du
#define kNtSioSocketUsageNotification 0x980000ccu
#define kNtSioTcpInfo 0xd8000027u
#define kNtSioTcpInitialRto 0x98000011u
#define kNtSioTcpSetAckFrequency 0x98000017u
#define kNtSioTcpSetIcw 0x98000016u
#define kNtSioTranslateHandle 0xc800000du
#define kNtSioUcastIf 0x98000006u
#define kNtSioUdpConnreset 0x9800000cu
#define kNtSioUdpNetreset 0x9800000fu
/*!BEGIN libc/nt/enum/size.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SIZE_H_
#define kNtSizeRestored 0
#define kNtSizeMinimized 1
#define kNtSizeMaximized 2
#define kNtSizeMaxshow 3
#define kNtSizeMaxhide 4
/*!BEGIN libc/nt/enum/startf.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_STARTF_H_
#define kNtStartfUseshowwindow 0x00000001 /* otherwise wShowWindow ignored */
#define kNtStartfUsesize 0x00000002 /* otherwise dwX / dwY ignored */
#define kNtStartfUseposition 0x00000004 /* otherwise dwX/YSize ignored */
#define kNtStartfUsecountchars 0x00000008 /* otherwise dwX/YCountChars ign. */
#define kNtStartfUsefillattribute 0x00000010 /* etc. */
#define kNtStartfRunfullscreen 0x00000020
#define kNtStartfForceonfeedback 0x00000040
#define kNtStartfForceofffeedback 0x00000080
#define kNtStartfUsestdhandles 0x00000100 /* otherwise hStd... ignored */
#define kNtStartfUsehotkey 0x00000200
#define kNtStartfTitleislinkname 0x00000800
#define kNtStartfTitleisappid 0x00001000
#define kNtStartfPreventpinning 0x00002000
#define kNtStartfUntrustedsource 0x00008000
/*!BEGIN libc/nt/enum/statfs.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_STATFS_H_
COSMOPOLITAN_C_START_
#define kNtFileCasePreservedNames 0x00000002
#define kNtFileCaseSensitiveSearch 0x00000001
#define kNtFileFileCompression 0x00000010
#define kNtFileNamedStreams 0x00040000
#define kNtFilePersistentAcls 0x00000008
#define kNtFileReadOnlyVolume 0x00080000 /* ST_RDONLY */
#define kNtFileSequentialWriteOnce 0x00100000
#define kNtFileSupportsEncryption 0x00020000
#define kNtFileSupportsExtendedAttributes 0x00800000
#define kNtFileSupportsHardLinks 0x00400000
#define kNtFileSupportsObjectIds 0x00010000
#define kNtFileSupportsOpenByFileId 0x01000000
#define kNtFileSupportsReparsePoints 0x00000080
#define kNtFileSupportsSparseFiles 0x00000040
#define kNtFileSupportsTransactions 0x00200000
#define kNtFileSupportsUsnJournal 0x02000000
#define kNtFileUnicodeOnDisk 0x00000004
#define kNtFileVolumeIsCompressed 0x00008000
#define kNtFileVolumeQuotas 0x00000020
#define kNtFileSupportsBlockRefcounting 0x08000000
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/enum/status.h */
#define COSMOPOLITAN_LIBC_NT_STATUS_H_
/* high two bits = {success,informational,warning,error} */
#define kNtStatusSuccess 0x00000000 /* success statuses */
#define kNtStatusWait0 0x00000000
#define kNtStatusAbandonedWait0 0x00000080
#define kNtStatusUserApc 0x000000C0
#define kNtStatusTimeout 0x00000102
#define kNtStatusPending 0x00000103
#define kNtStatusGuardPageViolation 0x80000001 /* warning statuses */
#define kNtStatusDatatypeMisalignment 0x80000002
#define kNtStatusBreakpoint 0x80000003
#define kNtStatusSingleStep 0x80000004
#define kNtStatusLongjump 0x80000026
#define kNtStatusUnwindConsolidate 0x80000029
#define kNtStatusAccessViolation 0xC0000005 /* error statuses */
#define kNtStatusInPageError 0xC0000006
#define kNtStatusInvalidHandle 0xC0000008
#define kNtStatusInvalidParameter 0xC000000D
#define kNtStatusNoMemory 0xC0000017
#define kNtStatusIllegalInstruction 0xC000001D
#define kNtStatusNoncontinuableException 0xC0000025
#define kNtStatusInvalidDisposition 0xC0000026
#define kNtStatusArrayBoundsExceeded 0xC000008C
#define kNtStatusFloatDenormalOperand 0xC000008D
#define kNtStatusFloatDivideByZero 0xC000008E
#define kNtStatusFloatInexactResult 0xC000008F
#define kNtStatusFloatInvalidOperation 0xC0000090
#define kNtStatusFloatOverflow 0xC0000091
#define kNtStatusFloatStackCheck 0xC0000092
#define kNtStatusFloatUnderflow 0xC0000093
#define kNtStatusIntegerDivideBYZero 0xC0000094
#define kNtStatusIntegerOverflow 0xC0000095
#define kNtStatusPrivilegedInstruction 0xC0000096
#define kNtStatusStackOverflow 0xC00000FD
#define kNtStatusDllNotFound 0xC0000135
#define kNtStatusOrdinalNotFound 0xC0000138
#define kNtStatusEntrypointNotFound 0xC0000139
#define kNtStatusControlCExit 0xC000013A
#define kNtStatusDllInitFailed 0xC0000142
#define kNtStatusFloatMultipleFaults 0xC00002B4
#define kNtStatusFloatMultipleTraps 0xC00002B5
#define kNtStatusRegNatConsumption 0xC00002C9
#define kNtStatusHeapCorruption 0xC0000374
#define kNtStatusStackBufferOverrun 0xC0000409
#define kNtStatusInvalidCruntimeParameter 0xC0000417
#define kNtStatusAssertionFailure 0xC0000420
#define kNtStatusEnclaveViolation 0xC00004A2
#define kNtStatusSegmentNotification 0x40000005
#define kNtStatusFatalAppExit 0x40000015
#define kNtStatusNotFound 0xC0000225
#define kNtStatusCancelled 0xC0000120
#define kNtDbgExceptionHandled 0x00010001
#define kNtDbgContinue 0x00010002
#define kNtDbgReplyLater 0x40010001
#define kNtDbgTerminateThread 0x40010003
#define kNtDbgTerminateProcess 0x40010004
#define kNtDbgControlC 0x40010005
#define kNtDbgPrintexceptionC 0x40010006
#define kNtDbgRipexception 0x40010007
#define kNtDbgControlBreak 0x40010008
#define kNtDbgCommandException 0x40010009
#define kNtDbgPrintexceptionWideC 0x4001000A
#define kNtDbgExceptionNotHandled 0x80010001
#define kNtStillActive kNtStatusPending
#if !(__ASSEMBLER__ + __LINKER__ + 0)
typedef uint32_t NtStatus;
#define NtSuccess(s) ((NtStatus)(s) >= 0)
#define NtInformation(s) (NtSeverity(s) == 1)
#define NtWarning(s) (NtSeverity(s) == 2)
#define NtError(s) (NtSeverity(s) == 3)
#define NtCode(s) ((NtStatus)(s)&0xffff)
#define NtSeverity(s) ((NtStatus)(s) >> 30)
#define NtFacility(s) (((NtStatus)(s) >> 16) & 0xfff)
#define NtFacilityCode(s) ((NtStatus)(s)&0x0FFFFFFF)
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
/*!BEGIN libc/nt/enum/sw.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SW_H_
#define kNtSwHide 0
#define kNtSwShownormal 1
#define kNtSwNormal 1
#define kNtSwShowminimized 2
#define kNtSwShowmaximized 3
#define kNtSwMaximize 3
#define kNtSwShownoactivate 4
#define kNtSwShow 5
#define kNtSwMinimize 6
#define kNtSwShowminnoactive 7
#define kNtSwShowna 8
#define kNtSwRestore 9
#define kNtSwShowdefault 10
#define kNtSwForceminimize 11
/*!BEGIN libc/nt/enum/symboliclink.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SYMBOLICLINK_H_
#define kNtSymbolicLinkFlagDirectory 1
#define kNtSymbolicLinkFlagAllowUnprivilegedCreate 2
/*!BEGIN libc/nt/enum/systeminformationclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SYSTEMINFORMATIONCLASS_H_
#define kNtSystemBasicInformation 0
#define kNtSystemProcessorInformation 1
#define kNtSystemPerformanceInformation 2
#define kNtSystemTimeOfDayInformation 3
#define kNtSystemProcessInformation 5
#define kNtSystemProcessorTimes 8
#define kNtSystemGlobalFlag 9
#define kNtSystemModuleInformation 11
#define kNtSystemLockInformation 12
#define kNtSystemHandleInformation 16
#define kNtSystemObjectInformation 17
#define kNtSystemInterruptInformation 23
#define kNtSystemExceptionInformation 33
#define kNtSystemRegistryQuotaInformation 37
#define kNtSystemLookasideInformation 45
/*!BEGIN libc/nt/enum/th32cs.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_TH32CS_H_
#define kNtTh32csInherit 0x80000000
#define kNtTh32csSnapheaplist 0x00000001
#define kNtTh32csSnapmodule 0x00000008
#define kNtTh32csSnapmodule32 0x00000010
#define kNtTh32csSnapprocess 0x00000002
#define kNtTh32csSnapthread 0x00000004
/*!BEGIN libc/nt/enum/threadaccess.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_THREADACCESS_H_
#define kNtThreadTerminate 0x0001
#define kNtThreadSuspendResume 0x0002
#define kNtThreadGetContext 0x0008
#define kNtThreadSetContext 0x0010
#define kNtThreadQueryInformation 0x0040
#define kNtThreadSetInformation 0x0020
#define kNtThreadSetThreadToken 0x0080
#define kNtThreadImpersonate 0x0100
#define kNtThreadDirectImpersonation 0x0200
#define kNtThreadSetLimitedInformation 0x0400
#define kNtThreadQueryLimitedInformation 0x0800
#define kNtThreadResume 0x1000
#define kNtThreadAllAccess (kNtStandardRightsRequired | kNtSynchronize | 0xFFFF)
/*!BEGIN libc/nt/enum/threadinfoclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_THREADINFOCLASS_H_
enum NtThreadInfoClass {
kNtThreadBasicInformation,
kNtThreadTimes,
kNtThreadPriority,
kNtThreadBasePriority,
kNtThreadAffinityMask,
kNtThreadImpersonationToken,
kNtThreadDescriptorTableEntry,
kNtThreadEnableAlignmentFaultFixup,
kNtThreadEventPair_Reusable,
kNtThreadQuerySetWin32StartAddress,
kNtThreadZeroTlsCell,
kNtThreadPerformanceCount,
kNtThreadAmILastThread,
kNtThreadIdealProcessor,
kNtThreadPriorityBoost,
kNtThreadSetTlsArrayAddress,
kNtThreadIsIoPending,
kNtThreadHideFromDebugger,
kNtThreadInfoClass_MAX
};
/*!BEGIN libc/nt/enum/threadpriority.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_THREADPRIORITY_H_
#define kNtThreadBasePriorityIdle (-15)
#define kNtThreadBasePriorityMin (-2)
#define kNtThreadBasePriorityMax 2
#define kNtThreadBasePriorityLowrt 15
#define kNtThreadPriorityIdle kNtThreadBasePriorityIdle
#define kNtThreadPriorityLowest kNtThreadBasePriorityMin
#define kNtThreadPriorityBelowNormal (kNtThreadPriorityLowest + 1)
#define kNtThreadPriorityNormal 0
#define kNtThreadPriorityAboveNormal (kNtThreadPriorityHighest - 1)
#define kNtThreadPriorityHighest kNtThreadBasePriorityMax
#define kNtThreadPriorityTimeCritical kNtThreadBasePriorityLowrt
/*!BEGIN libc/nt/enum/threadstate.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_THREADSTATE_H_
#define kNtStateInitialized 0
#define kNtStateReady 1
#define kNtStateRunning 2
#define kNtStateStandby 3
#define kNtStateTerminated 4
#define kNtStateWait 5
#define kNtStateTransition 6
#define kNtStateUnknown 7
/*!BEGIN libc/nt/enum/timezoneid.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_TIMEZONEID_H_
#define kNtTimeZoneIdUnknown 0
#define kNtTimeZoneIdStandard 1
#define kNtTimeZoneIdDaylight 2
/*!BEGIN libc/nt/enum/tokeninformationclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_TOKENINFORMATIONCLASS_H_
#define kNtTokenUser 1
#define kNtTokenGroups 2
#define kNtTokenPrivileges 3
#define kNtTokenOwner 4
#define kNtTokenPrimaryGroup 5
#define kNtTokenDefaultDacl 6
#define kNtTokenSource 7
#define kNtTokenType 8
#define kNtTokenImpersonationLevel 9
#define kNtTokenStatistics 10
#define kNtTokenRestrictedSids 11
#define kNtTokenSessionId 12
#define kNtTokenGroupsAndPrivileges 13
#define kNtTokenSessionReference 14
#define kNtTokenSandBoxInert 15
#define kNtTokenAuditPolicy 16
#define kNtTokenOrigin 17
#define kNtTokenInfoClass_MAX 18
/*!BEGIN libc/nt/enum/tokentype.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_TOKENTYPE_H_
#define kNtTokenPrimary 1
#define kNtTokenImpersonation 2
/*!BEGIN libc/nt/enum/tpm.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_TPM_H_
#define kNtTpmLeftbutton 0x00000
#define kNtTpmRightbutton 0x00002
#define kNtTpmLeftalign 0x00000
#define kNtTpmCenteralign 0x00004
#define kNtTpmRightalign 0x00008
#define kNtTpmTopalign 0x00000
#define kNtTpmVcenteralign 0x00010
#define kNtTpmBottomalign 0x00020
#define kNtTpmHorizontal 0x00000
#define kNtTpmVertical 0x00040
#define kNtTpmNonotify 0x00080
#define kNtTpmReturncmd 0x00100
#define kNtTpmRecurse 0x00001
#define kNtTpmHorposanimation 0x00400
#define kNtTpmHorneganimation 0x00800
#define kNtTpmVerposanimation 0x01000
#define kNtTpmVerneganimation 0x02000
#define kNtTpmNoanimation 0x04000
#define kNtTpmLayoutrtl 0x08000
#define kNtTpmWorkarea 0x10000
/*!BEGIN libc/nt/enum/valueinformationclass.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_VALUEINFORMATIONCLASS_H_
#define kNtKeyValueBasicInformation 0
#define kNtKeyValueFullInformation 1
#define kNtKeyValuePartialInformation 2
#define kNtKeyValueFullInformationAlign64 3
#define kNtKeyValuePartialInformationAlign64 4
/*!BEGIN libc/nt/enum/version.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_VERSION_H_
/**
* Known versions of the New Technology executive.
* @see IsAtLeastWindows10()
* @see NtGetVersion()
*/
#define kNtVersionWindows10 0x0a00
#define kNtVersionWindows81 0x0603
#define kNtVersionWindows8 0x0602
#define kNtVersionWindows7 0x0601
#define kNtVersionWindowsVista 0x0600 /* intended baseline */
#define kNtVersionWindowsXp64 0x0502 /* end of the road */
#define kNtVersionWindowsXp 0x0501 /* snowball's chance */
#define kNtVersionWindows2000 0x0500 /* the golden age */
#define kNtVersionFuture 0x0b00
/*!BEGIN libc/nt/enum/vk.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_VK_H_
#define kNtVkLbutton 0x01
#define kNtVkRbutton 0x02
#define kNtVkCancel 0x03
#define kNtVkMbutton 0x04
#define kNtVkXbutton1 0x05
#define kNtVkXbutton2 0x06
#define kNtVkBack 0x08
#define kNtVkTab 0x09
#define kNtVkClear 0x0C
#define kNtVkReturn 0x0D
#define kNtVkShift 0x10
#define kNtVkControl 0x11
#define kNtVkMenu 0x12 /* alt? */
#define kNtVkPause 0x13
#define kNtVkCapital 0x14
#define kNtVkKana 0x15
#define kNtVkHangul 0x15
#define kNtVkJunja 0x17
#define kNtVkFinal 0x18
#define kNtVkHanja 0x19
#define kNtVkKanji 0x19
#define kNtVkEscape 0x1B
#define kNtVkConvert 0x1C
#define kNtVkNonconvert 0x1D
#define kNtVkAccept 0x1E
#define kNtVkModechange 0x1F
#define kNtVkSpace 0x20
#define kNtVkPrior 0x21 /* page up */
#define kNtVkNext 0x22 /* page down */
#define kNtVkEnd 0x23
#define kNtVkHome 0x24
#define kNtVkLeft 0x25
#define kNtVkUp 0x26
#define kNtVkRight 0x27
#define kNtVkDown 0x28
#define kNtVkSelect 0x29
#define kNtVkPrint 0x2A
#define kNtVkExecute 0x2B
#define kNtVkSnapshot 0x2C
#define kNtVkInsert 0x2D
#define kNtVkDelete 0x2E
#define kNtVkHelp 0x2F
#define kNtVkLwin 0x5B
#define kNtVkRwin 0x5C
#define kNtVkApps 0x5D
#define kNtVkSleep 0x5F
#define kNtVkNumpad0 0x60
#define kNtVkNumpad1 0x61
#define kNtVkNumpad2 0x62
#define kNtVkNumpad3 0x63
#define kNtVkNumpad4 0x64
#define kNtVkNumpad5 0x65
#define kNtVkNumpad6 0x66
#define kNtVkNumpad7 0x67
#define kNtVkNumpad8 0x68
#define kNtVkNumpad9 0x69
#define kNtVkMultiply 0x6A
#define kNtVkAdd 0x6B
#define kNtVkSeparator 0x6C
#define kNtVkSubtract 0x6D
#define kNtVkDecimal 0x6E
#define kNtVkDivide 0x6F
#define kNtVkF1 0x70
#define kNtVkF2 0x71
#define kNtVkF3 0x72
#define kNtVkF4 0x73
#define kNtVkF5 0x74
#define kNtVkF6 0x75
#define kNtVkF7 0x76
#define kNtVkF8 0x77
#define kNtVkF9 0x78
#define kNtVkF10 0x79
#define kNtVkF11 0x7A
#define kNtVkF12 0x7B
#define kNtVkF13 0x7C
#define kNtVkF14 0x7D
#define kNtVkF15 0x7E
#define kNtVkF16 0x7F
#define kNtVkF17 0x80
#define kNtVkF18 0x81
#define kNtVkF19 0x82
#define kNtVkF20 0x83
#define kNtVkF21 0x84
#define kNtVkF22 0x85
#define kNtVkF23 0x86
#define kNtVkF24 0x87
#define kNtVkNumlock 0x90
#define kNtVkScroll 0x91
#define kNtVkLshift 0xA0
#define kNtVkRshift 0xA1
#define kNtVkLcontrol 0xA2
#define kNtVkRcontrol 0xA3
#define kNtVkLmenu 0xA4
#define kNtVkRmenu 0xA5
#define kNtVkBrowserBack 0xA6
#define kNtVkBrowserForward 0xA7
#define kNtVkBrowserRefresh 0xA8
#define kNtVkBrowserStop 0xA9
#define kNtVkBrowserSearch 0xAA
#define kNtVkBrowserFavorites 0xAB
#define kNtVkBrowserHome 0xAC
#define kNtVkVolumeMute 0xAD
#define kNtVkVolumeDown 0xAE
#define kNtVkVolumeUp 0xAF
#define kNtVkMediaNextTrack 0xB0
#define kNtVkMediaPrevTrack 0xB1
#define kNtVkMediaStop 0xB2
#define kNtVkMediaPlayPause 0xB3
#define kNtVkLaunchMail 0xB4
#define kNtVkLaunchMediaSelect 0xB5
#define kNtVkLaunchApp1 0xB6
#define kNtVkLaunchApp2 0xB7
#define kNtVkOem_1 0xBA
#define kNtVkOemPlus 0xBB
#define kNtVkOemComma 0xBC
#define kNtVkOemMinus 0xBD
#define kNtVkOemPeriod 0xBE
#define kNtVkOem_2 0xBF
#define kNtVkOem_3 0xC0
#define kNtVkGamepadA 0xC3
#define kNtVkGamepadB 0xC4
#define kNtVkGamepadX 0xC5
#define kNtVkGamepadY 0xC6
#define kNtVkGamepadRightShoulder 0xC7
#define kNtVkGamepadLeftShoulder 0xC8
#define kNtVkGamepadLeftTrigger 0xC9
#define kNtVkGamepadRightTrigger 0xCA
#define kNtVkGamepadDpadUp 0xCB
#define kNtVkGamepadDpadDown 0xCC
#define kNtVkGamepadDpadLeft 0xCD
#define kNtVkGamepadDpadRight 0xCE
#define kNtVkGamepadMenu 0xCF
#define kNtVkGamepadView 0xD0
#define kNtVkGamepadLeftThumbstickButton 0xD1
#define kNtVkGamepadRightThumbstickButton 0xD2
#define kNtVkGamepadLeftThumbstickUp 0xD3
#define kNtVkGamepadLeftThumbstickDown 0xD4
#define kNtVkGamepadLeftThumbstickRight 0xD5
#define kNtVkGamepadLeftThumbstickLeft 0xD6
#define kNtVkGamepadRightThumbstickUp 0xD7
#define kNtVkGamepadRightThumbstickDown 0xD8
#define kNtVkGamepadRightThumbstickRight 0xD9
#define kNtVkGamepadRightThumbstickLeft 0xDA
#define kNtVkOem_4 0xDB
#define kNtVkOem_5 0xDC
#define kNtVkOem_6 0xDD
#define kNtVkOem_7 0xDE
#define kNtVkOem_8 0xDF
#define kNtVkOemAx 0xE1
#define kNtVkOem_102 0xE2
#define kNtVkIcoHelp 0xE3
#define kNtVkIco_00 0xE4
#define kNtVkProcesskey 0xE5
#define kNtVkIcoClear 0xE6
#define kNtVkPacket 0xE7
#define kNtVkOemReset 0xE9
#define kNtVkOemJump 0xEA
#define kNtVkOemPa1 0xEB
#define kNtVkOemPa2 0xEC
#define kNtVkOemPa3 0xED
#define kNtVkOemWsctrl 0xEE
#define kNtVkOemCusel 0xEF
#define kNtVkOemAttn 0xF0
#define kNtVkOemFinish 0xF1
#define kNtVkOemCopy 0xF2
#define kNtVkOemAuto 0xF3
#define kNtVkOemEnlw 0xF4
#define kNtVkOemBacktab 0xF5
#define kNtVkAttn 0xF6
#define kNtVkCrsel 0xF7
#define kNtVkExsel 0xF8
#define kNtVkEreof 0xF9
#define kNtVkPlay 0xFA
#define kNtVkZoom 0xFB
#define kNtVkNoname 0xFC
#define kNtVkPa1 0xFD
#define kNtVkOemClear 0xFE
/*!BEGIN libc/nt/enum/wa.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_WA_H_
#define kNtWaInactive 0
#define kNtWaActive 1
#define kNtWaClickactive 2
/*!BEGIN libc/nt/enum/wait.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_WAIT_H_
#define kNtWaitFailed 0xffffffffu
#define kNtWaitTimeout 0x00000102u
#define kNtWaitAbandoned 0x00000080u
/*!BEGIN libc/nt/enum/wm.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_WM_H_
#define kNtWmNull 0x0000
#define kNtWmCreate 0x0001
#define kNtWmDestroy 0x0002
#define kNtWmMove 0x0003
#define kNtWmSize 0x0005
#define kNtWmActivate 0x0006
#define kNtWmSetfocus 0x0007
#define kNtWmKillfocus 0x0008
#define kNtWmEnable 0x000A
#define kNtWmSetredraw 0x000B
#define kNtWmSettext 0x000C
#define kNtWmGettext 0x000D
#define kNtWmGettextlength 0x000E
#define kNtWmPaint 0x000F
#define kNtWmClose 0x0010
#define kNtWmQueryendsession 0x0011
#define kNtWmQueryopen 0x0013
#define kNtWmEndsession 0x0016
#define kNtWmQuit 0x0012
#define kNtWmErasebkgnd 0x0014
#define kNtWmSyscolorchange 0x0015
#define kNtWmShowwindow 0x0018
#define kNtWmWininichange 0x001A
#define kNtWmSettingchange kNtWmWininichange
#define kNtWmDevmodechange 0x001B
#define kNtWmActivateapp 0x001C
#define kNtWmFontchange 0x001D
#define kNtWmTimechange 0x001E
#define kNtWmCancelmode 0x001F
#define kNtWmSetcursor 0x0020
#define kNtWmMouseactivate 0x0021
#define kNtWmChildactivate 0x0022
#define kNtWmQueuesync 0x0023
#define kNtWmGetminmaxinfo 0x0024
#define kNtWmPainticon 0x0026
#define kNtWmIconerasebkgnd 0x0027
#define kNtWmNextdlgctl 0x0028
#define kNtWmSpoolerstatus 0x002A
#define kNtWmDrawitem 0x002B
#define kNtWmMeasureitem 0x002C
#define kNtWmDeleteitem 0x002D
#define kNtWmVkeytoitem 0x002E
#define kNtWmChartoitem 0x002F
#define kNtWmSetfont 0x0030
#define kNtWmGetfont 0x0031
#define kNtWmSethotkey 0x0032
#define kNtWmGethotkey 0x0033
#define kNtWmQuerydragicon 0x0037
#define kNtWmCompareitem 0x0039
#define kNtWmGetobject 0x003D
#define kNtWmCompacting 0x0041
#define kNtWmWindowposchanging 0x0046
#define kNtWmWindowposchanged 0x0047
#define kNtWmPower 0x0048
#define kNtWmCopydata 0x004A
#define kNtWmCanceljournal 0x004B
#define kNtWmNotify 0x004E
#define kNtWmInputlangchangerequest 0x0050
#define kNtWmInputlangchange 0x0051
#define kNtWmTcard 0x0052
#define kNtWmHelp 0x0053
#define kNtWmUserchanged 0x0054
#define kNtWmNotifyformat 0x0055
#define kNtWmContextmenu 0x007B
#define kNtWmStylechanging 0x007C
#define kNtWmStylechanged 0x007D
#define kNtWmDisplaychange 0x007E
#define kNtWmGeticon 0x007F
#define kNtWmSeticon 0x0080
#define kNtWmNccreate 0x0081
#define kNtWmNcdestroy 0x0082
#define kNtWmNccalcsize 0x0083
#define kNtWmNchittest 0x0084
#define kNtWmNcpaint 0x0085
#define kNtWmNcactivate 0x0086
#define kNtWmGetdlgcode 0x0087
#define kNtWmNcmousemove 0x00A0
#define kNtWmNclbuttondown 0x00A1
#define kNtWmNclbuttonup 0x00A2
#define kNtWmNclbuttondblclk 0x00A3
#define kNtWmNcrbuttondown 0x00A4
#define kNtWmNcrbuttonup 0x00A5
#define kNtWmNcrbuttondblclk 0x00A6
#define kNtWmNcmbuttondown 0x00A7
#define kNtWmNcmbuttonup 0x00A8
#define kNtWmNcmbuttondblclk 0x00A9
#define kNtWmNcxbuttondown 0x00AB
#define kNtWmNcxbuttonup 0x00AC
#define kNtWmNcxbuttondblclk 0x00AD
#define kNtWmKeyfirst 0x0100
#define kNtWmKeydown 0x0100
#define kNtWmKeyup 0x0101
#define kNtWmChar 0x0102
#define kNtWmDeadchar 0x0103
#define kNtWmSyskeydown 0x0104
#define kNtWmSyskeyup 0x0105
#define kNtWmSyschar 0x0106
#define kNtWmSysdeadchar 0x0107
#define kNtWmUnichar 0x0109
#define kNtWmKeylast 0x0109
#define kNtWmInitdialog 0x0110
#define kNtWmCommand 0x0111
#define kNtWmSyscommand 0x0112
#define kNtWmTimer 0x0113
#define kNtWmHscroll 0x0114
#define kNtWmVscroll 0x0115
#define kNtWmInitmenu 0x0116
#define kNtWmInitmenupopup 0x0117
#define kNtWmGesture 0x0119
#define kNtWmGesturenotify 0x011A
#define kNtWmMenuselect 0x011F
#define kNtWmMenuchar 0x0120
#define kNtWmEnteridle 0x0121
#define kNtWmMenurbuttonup 0x0122
#define kNtWmMenudrag 0x0123
#define kNtWmMenugetobject 0x0124
#define kNtWmUninitmenupopup 0x0125
#define kNtWmMenucommand 0x0126
#define kNtWmChangeuistate 0x0127
#define kNtWmUpdateuistate 0x0128
#define kNtWmQueryuistate 0x0129
#define kNtWmMousefirst 0x0200
#define kNtWmMousemove 0x0200
#define kNtWmLbuttondown 0x0201
#define kNtWmLbuttonup 0x0202
#define kNtWmLbuttondblclk 0x0203
#define kNtWmRbuttondown 0x0204
#define kNtWmRbuttonup 0x0205
#define kNtWmRbuttondblclk 0x0206
#define kNtWmMbuttondown 0x0207
#define kNtWmMbuttonup 0x0208
#define kNtWmMbuttondblclk 0x0209
#define kNtWmMousewheel 0x020A
#define kNtWmXbuttondown 0x020B
#define kNtWmXbuttonup 0x020C
#define kNtWmXbuttondblclk 0x020D
#define kNtWmMousehwheel 0x020E
#define kNtWmMouselast 0x020E
#define kNtWmParentnotify 0x0210
#define kNtWmEntermenuloop 0x0211
#define kNtWmExitmenuloop 0x0212
#define kNtWmNextmenu 0x0213
#define kNtWmSizing 0x0214
#define kNtWmCapturechanged 0x0215
#define kNtWmMoving 0x0216
#define kNtWmPowerbroadcast 0x0218
#define kNtWmMdicreate 0x0220
#define kNtWmMdidestroy 0x0221
#define kNtWmMdiactivate 0x0222
#define kNtWmMdirestore 0x0223
#define kNtWmMdinext 0x0224
#define kNtWmMdimaximize 0x0225
#define kNtWmMditile 0x0226
#define kNtWmMdicascade 0x0227
#define kNtWmMdiiconarrange 0x0228
#define kNtWmMdigetactive 0x0229
#define kNtWmMdisetmenu 0x0230
#define kNtWmEntersizemove 0x0231
#define kNtWmExitsizemove 0x0232
#define kNtWmDropfiles 0x0233
#define kNtWmMdirefreshmenu 0x0234
#define kNtWmCut 0x0300
#define kNtWmCopy 0x0301
#define kNtWmPaste 0x0302
#define kNtWmClear 0x0303
#define kNtWmUndo 0x0304
#define kNtWmRenderformat 0x0305
#define kNtWmRenderallformats 0x0306
#define kNtWmDestroyclipboard 0x0307
#define kNtWmDrawclipboard 0x0308
#define kNtWmPaintclipboard 0x0309
#define kNtWmVscrollclipboard 0x030A
#define kNtWmSizeclipboard 0x030B
#define kNtWmAskcbformatname 0x030C
#define kNtWmChangecbchain 0x030D
#define kNtWmHscrollclipboard 0x030E
#define kNtWmQuerynewpalette 0x030F
#define kNtWmPaletteischanging 0x0310
#define kNtWmPalettechanged 0x0311
#define kNtWmHotkey 0x0312
/*!BEGIN libc/nt/enum/ws.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_WS_H_
#define kNtWsOverlapped 0x00000000
#define kNtWsPopup 0x80000000
#define kNtWsChild 0x40000000
#define kNtWsMinimize 0x20000000
#define kNtWsVisible 0x10000000
#define kNtWsDisabled 0x08000000
#define kNtWsClipsiblings 0x04000000
#define kNtWsClipchildren 0x02000000
#define kNtWsMaximize 0x01000000
#define kNtWsCaption 0x00C00000
#define kNtWsBorder 0x00800000
#define kNtWsDlgframe 0x00400000
#define kNtWsVscroll 0x00200000
#define kNtWsHscroll 0x00100000
#define kNtWsSysmenu 0x00080000
#define kNtWsThickframe 0x00040000
#define kNtWsGroup 0x00020000
#define kNtWsTabstop 0x00010000
#define kNtWsMinimizebox 0x00020000
#define kNtWsMaximizebox 0x00010000
#define kNtWsTiled kNtWsOverlapped
#define kNtWsIconic kNtWsMinimize
#define kNtWsSizebox kNtWsThickframe
#define kNtWsTiledwindow kNtWsOverlappedwindow
#define kNtWsOverlappedwindow \
(kNtWsOverlapped | kNtWsCaption | kNtWsSysmenu | kNtWsThickframe | \
kNtWsMinimizebox | kNtWsMaximizebox)
#define kNtWsPopupwindow (kNtWsPopup | kNtWsBorder | kNtWsSysmenu)
#define kNtWsExDlgmodalframe 0x00000001
#define kNtWsExNoparentnotify 0x00000004
#define kNtWsExTopmost 0x00000008
#define kNtWsExAcceptfiles 0x00000010
#define kNtWsExTransparent 0x00000020
#define kNtWsExMdichild 0x00000040
#define kNtWsExToolwindow 0x00000080
#define kNtWsExWindowedge 0x00000100
#define kNtWsExClientedge 0x00000200
#define kNtWsExContexthelp 0x00000400
#define kNtWsExRight 0x00001000
#define kNtWsExLeft 0x00000000
#define kNtWsExRtlreading 0x00002000
#define kNtWsExLtrreading 0x00000000
#define kNtWsExLeftscrollbar 0x00004000
#define kNtWsExRightscrollbar 0x00000000
#define kNtWsExControlparent 0x00010000
#define kNtWsExStaticedge 0x00020000
#define kNtWsExAppwindow 0x00040000
#define kNtWsExNoinheritlayout 0x00100000
#define kNtWsExNoredirectionbitmap 0x00200000
#define kNtWsExLayoutrtl 0x00400000
#define kNtWsExComposited 0x02000000
#define kNtWsExNoactivate 0x08000000
#define kNtWsExOverlappedwindow (kNtWsExWindowedge | kNtWsExClientedge)
#define kNtWsExPalettewindow \
(kNtWsExWindowedge | kNtWsExToolwindow | kNtWsExTopmost)
/*!BEGIN libc/nt/enum/wsa.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_WSA_H_
/*!BEGIN libc/nt/errors.h */
#define COSMOPOLITAN_NT_ERRORS_H_
#define kNtNoError 0
#define kNtErrorInsufficientBuffer 122
#define kNtErrorSuccess 0
#define kNtErrorInvalidFunction 1 /* ENOSYS */
#define kNtErrorFileNotFound 2 /* ENOENT */
#define kNtErrorPathNotFound 3 /* ENOTDIR */
#define kNtErrorTooManyOpenFiles 4 /* EMFILE */
#define kNtErrorAccessDenied 5 /* EACCES */
#define kNtErrorInvalidHandle 6 /* EBADF */
#define kNtErrorArenaTrashed 7
#define kNtErrorNotEnoughMemory 8
#define kNtErrorInvalidBlock 9
#define kNtErrorBadEnvironment 10
#define kNtErrorBadFormat 11
#define kNtErrorInvalidAccess 12 /* EPERM */
#define kNtErrorInvalidData 13
#define kNtErrorOutofmemory 14 /* ENOMEM */
#define kNtErrorInvalidDrive 15
#define kNtErrorCurrentDirectory 16
#define kNtErrorNotSameDevice 17
#define kNtErrorNoMoreFiles 18
#define kNtErrorWriteProtect 19
#define kNtErrorBadUnit 20
#define kNtErrorNotReady 21
#define kNtErrorBadCommand 22
#define kNtErrorCrc 23
#define kNtErrorBadLength 24
#define kNtErrorSeek 25 /* ESPIPE */
#define kNtErrorNotDosDisk 26 /* ENOTBLK */
#define kNtErrorSectorNotFound 27
#define kNtErrorOutOfPaper 28
#define kNtErrorWriteFault 29
#define kNtErrorReadFault 30
#define kNtErrorGenFailure 31
#define kNtErrorSharingViolation 32
#define kNtErrorLockViolation 33
#define kNtErrorWrongDisk 34
#define kNtErrorSharingBufferExceeded 36
#define kNtErrorHandleEof 38 /* w/ GetOverlappedResult() */
#define kNtErrorHandleDiskFull 39
#define kNtErrorNotSupported 50
#define kNtErrorRemNotList 51
#define kNtErrorDupName 52
#define kNtErrorBadNetpath 53
#define kNtErrorNetworkBusy 54
#define kNtErrorDevNotExist 55
#define kNtErrorTooManyCmds 56
#define kNtErrorAdapHdwErr 57
#define kNtErrorBadNetResp 58
#define kNtErrorUnexpNetErr 59
#define kNtErrorBadRemAdap 60
#define kNtErrorPrintqFull 61
#define kNtErrorNoSpoolSpace 62
#define kNtErrorPrintCancelled 63
#define kNtErrorNetnameDeleted 64
#define kNtErrorNetworkAccessDenied 65
#define kNtErrorBadDevType 66
#define kNtErrorBadNetName 67
#define kNtErrorTooManyNames 68
#define kNtErrorTooManySess 69
#define kNtErrorSharingPaused 70
#define kNtErrorReqNotAccep 71
#define kNtErrorRedirPaused 72
#define kNtErrorFileExists 80 /* EEXIST */
#define kNtErrorCannotMake 82
#define kNtErrorFailI24 83
#define kNtErrorOutOfStructures 84
#define kNtErrorAlreadyAssigned 85
#define kNtErrorInvalidPassword 86
#define kNtErrorInvalidParameter 87 /* EINVAL */
#define kNtErrorNetWriteFault 88
#define kNtErrorNoProcSlots 89
#define kNtErrorTooManySemaphores 100
#define kNtErrorExclSemAlreadyOwned 101
#define kNtErrorSemIsSet 102
#define kNtErrorTooManySemRequests 103
#define kNtErrorInvalidAtInterruptTime 104
#define kNtErrorSemOwnerDied 105 /* EOWNERDEAD */
#define kNtErrorSemUserLimit 106
#define kNtErrorDiskChange 107
#define kNtErrorDriveLocked 108
#define kNtErrorBrokenPipe 109 /* EPIPE; happens on ReadFile() too */
#define kNtErrorOpenFailed 110
#define kNtErrorBufferOverflow 111
#define kNtErrorDiskFull 112 /* ENOSPC */
#define kNtErrorNoMoreSearchHandles 113
#define kNtErrorInvalidTargetHandle 114 /* EBADF */
#define kNtErrorInvalidCategory 117 /* ENOATTR */
#define kNtErrorInvalidVerifySwitch 118
#define kNtErrorBadDriverLevel 119
#define kNtErrorCallNotImplemented 120
#define kNtErrorSemTimeout 121
#define kNtErrorInsufficientBuffer 122
#define kNtErrorInvalidName 123
#define kNtErrorInvalidLevel 124
#define kNtErrorNoVolumeLabel 125
#define kNtErrorModNotFound 126
#define kNtErrorProcNotFound 127
#define kNtErrorWaitNoChildren 128 /* ECHILD */
#define kNtErrorChildNotComplete 129
#define kNtErrorDirectAccessHandle 130 /* EBADF */
#define kNtErrorNegativeSeek 131
#define kNtErrorSeekOnDevice 132
#define kNtErrorIsJoinTarget 133
#define kNtErrorIsJoined 134
#define kNtErrorIsSubsted 135
#define kNtErrorNotJoined 136
#define kNtErrorNotSubsted 137
#define kNtErrorJoinToJoin 138
#define kNtErrorSubstToSubst 139
#define kNtErrorJoinToSubst 140
#define kNtErrorSubstToJoin 141
#define kNtErrorBusyDrive 142
#define kNtErrorSameDrive 143
#define kNtErrorDirNotRoot 144
#define kNtErrorDirNotEmpty 145
#define kNtErrorIsSubstPath 146
#define kNtErrorIsJoinPath 147
#define kNtErrorPathBusy 148 /* ETXTBSY */
#define kNtErrorIsSubstTarget 149
#define kNtErrorSystemTrace 150
#define kNtErrorInvalidEventCount 151
#define kNtErrorTooManyMuxwaiters 152
#define kNtErrorInvalidListFormat 153
#define kNtErrorLabelTooLong 154
#define kNtErrorTooManyTcbs 155
#define kNtErrorSignalRefused 156
#define kNtErrorDiscarded 157
#define kNtErrorNotLocked 158 /* ENOLCK */
#define kNtErrorBadThreadidAddr 159
#define kNtErrorBadArguments 160
#define kNtErrorBadPathname 161
#define kNtErrorSignalPending 162
#define kNtErrorMaxThrdsReached 164
#define kNtErrorLockFailed 167
#define kNtErrorBusy 170 /* EBUSY */
#define kNtErrorDeviceSupportInProgress 171
#define kNtErrorCancelViolation 173
#define kNtErrorAtomicLocksNotSupported 174
#define kNtErrorInvalidSegmentNumber 180
#define kNtErrorInvalidOrdinal 182
#define kNtErrorAlreadyExists 183 /* EEXIST */
#define kNtErrorInvalidFlagNumber 186
#define kNtErrorSemNotFound 187
#define kNtErrorInvalidStartingCodeseg 188
#define kNtErrorInvalidStackseg 189
#define kNtErrorInvalidModuletype 190
#define kNtErrorInvalidExeSignature 191
#define kNtErrorExeMarkedInvalid 192 /* EBADEXEC */
#define kNtErrorBadExeFormat 193 /* ENOEXEC */
#define kNtErrorIteratedDataExceeds_64k 194
#define kNtErrorInvalidMinallocsize 195
#define kNtErrorDynlinkFromInvalidRing 196
#define kNtErrorIoplNotEnabled 197
#define kNtErrorInvalidSegdpl 198
#define kNtErrorAutodatasegExceeds_64k 199
#define kNtErrorRing2segMustBeMovable 200
#define kNtErrorRelocChainXeedsSeglim 201
#define kNtErrorInfloopInRelocChain 202
#define kNtErrorEnvvarNotFound 203
#define kNtErrorNoSignalSent 205
#define kNtErrorFilenameExcedRange 206 /* ENAMETOOLONG */
#define kNtErrorRing2StackInUse 207
#define kNtErrorMetaExpansionTooLong 208
#define kNtErrorInvalidSignalNumber 209
#define kNtErrorThread_1Inactive 210
#define kNtErrorLocked 212
#define kNtErrorTooManyModules 214
#define kNtErrorNestingNotAllowed 215
#define kNtErrorExeMachineTypeMismatch 216 /* EBADARCH */
#define kNtErrorExeCannotModifySignedBinary 217
#define kNtErrorExeCannotModifyStrongSignedBinary 218
#define kNtErrorFileCheckedOut 220
#define kNtErrorCheckoutRequired 221
#define kNtErrorBadFileType 222 /* EFTYPE */
#define kNtErrorFileTooLarge 223 /* EFBIG */
#define kNtErrorFormsAuthRequired 224 /* ENEEDAUTH */
#define kNtErrorVirusInfected 225
#define kNtErrorVirusDeleted 226
#define kNtErrorPipeLocal 229
#define kNtErrorBadPipe 230
#define kNtErrorPipeBusy 231
#define kNtErrorNoData 232
#define kNtErrorPipeNotConnected 233
#define kNtErrorMoreData 234
#define kNtErrorNoWorkDone 235
#define kNtErrorVcDisconnected 240
#define kNtErrorInvalidEaName 254
#define kNtErrorEaListInconsistent 255
#define kNtErrorNoMoreItems 259
#define kNtErrorCannotCopy 266
#define kNtErrorDirectory 267 /* EISDIR */
#define kNtErrorEasDidntFit 275
#define kNtErrorEaFileCorrupt 276
#define kNtErrorEaTableFull 277
#define kNtErrorInvalidEaHandle 278
#define kNtErrorEasNotSupported 282
#define kNtErrorNotOwner 288
#define kNtErrorTooManyPosts 298
#define kNtErrorPartialCopy 299
#define kNtErrorOplockNotGranted 300
#define kNtErrorInvalidOplockProtocol 301
#define kNtErrorDiskTooFragmented 302
#define kNtErrorDeletePending 303
#define kNtErrorIncompatibleWithGlobalShortNameRegistrySetting 304
#define kNtErrorShortNamesNotEnabledOnVolume 305
#define kNtErrorSecurityStreamIsInconsistent 306
#define kNtErrorInvalidLockRange 307
#define kNtErrorImageSubsystemNotPresent 308
#define kNtErrorNotificationGuidAlreadyDefined 309
#define kNtErrorInvalidExceptionHandler 310
#define kNtErrorDuplicatePrivileges 311
#define kNtErrorNoRangesProcessed 312
#define kNtErrorNotAllowedOnSystemFile 313
#define kNtErrorDiskResourcesExhausted 314
#define kNtErrorInvalidToken 315
#define kNtErrorDeviceFeatureNotSupported 316
#define kNtErrorMrMidNotFound 317
#define kNtErrorScopeNotFound 318
#define kNtErrorUndefinedScope 319
#define kNtErrorInvalidCap 320
#define kNtErrorDeviceUnreachable 321
#define kNtErrorDeviceNoResources 322
#define kNtErrorDataChecksumError 323
#define kNtErrorIntermixedKernelEaOperation 324
#define kNtErrorFileLevelTrimNotSupported 326
#define kNtErrorOffsetAlignmentViolation 327
#define kNtErrorInvalidFieldInParameterList 328
#define kNtErrorOperationInProgress 329 /* EPROGUNAVAIL */
#define kNtErrorBadDevicePath 330
#define kNtErrorTooManyDescriptors 331 /* ENFILE */
#define kNtErrorScrubDataDisabled 332
#define kNtErrorNotRedundantStorage 333
#define kNtErrorResidentFileNotSupported 334
#define kNtErrorCompressedFileNotSupported 335
#define kNtErrorDirectoryNotSupported 336
#define kNtErrorNotReadFromCopy 337
#define kNtErrorFtWriteFailure 338
#define kNtErrorFtDiScanRequired 339
#define kNtErrorInvalidKernelInfoVersion 340
#define kNtErrorInvalidPepInfoVersion 341
#define kNtErrorObjectNotExternallyBacked 342
#define kNtErrorExternalBackingProviderUnknown 343
#define kNtErrorCompressionNotBeneficial 344
#define kNtErrorStorageTopologyIdMismatch 345
#define kNtErrorBlockedByParentalControls 346
#define kNtErrorBlockTooManyReferences 347
#define kNtErrorMarkedToDisallowWrites 348
#define kNtErrorEnclaveFailure 349
#define kNtErrorFailNoactionReboot 350
#define kNtErrorFailShutdown 351
#define kNtErrorFailRestart 352
#define kNtErrorMaxSessionsReached 353
#define kNtErrorNetworkAccessDeniedEdp 354
#define kNtErrorDeviceHintNameBufferTooSmall 355
#define kNtErrorEdpPolicyDeniesOperation 356
#define kNtErrorEdpDplPolicyCantBeSatisfied 357
#define kNtErrorCloudFileSyncRootMetadataCorrupt 358
#define kNtErrorDeviceInMaintenance 359
#define kNtErrorNotSupportedOnDax 360
#define kNtErrorDaxMappingExists 361
#define kNtErrorCloudFileProviderNotRunning 362
#define kNtErrorCloudFileMetadataCorrupt 363
#define kNtErrorCloudFileMetadataTooLarge 364
#define kNtErrorCloudFilePropertyBlobTooLarge 365
#define kNtErrorCloudFilePropertyBlobChecksumMismatch 366
#define kNtErrorChildProcessBlocked 367
#define kNtErrorStorageLostDataPersistence 368
#define kNtErrorFileSystemVirtualizationUnavailable 369
#define kNtErrorFileSystemVirtualizationMetadataCorrupt 370
#define kNtErrorFileSystemVirtualizationBusy 371
#define kNtErrorFileSystemVirtualizationProviderUnknown 372
#define kNtErrorGdiHandleLeak 373
#define kNtErrorCloudFileTooManyPropertyBlobs 374
#define kNtErrorCloudFilePropertyVersionNotSupported 375
#define kNtErrorNotACloudFile 376
#define kNtErrorCloudFileNotInSync 377
#define kNtErrorCloudFileAlreadyConnected 378
#define kNtErrorCloudFileNotSupported 379
#define kNtErrorCloudFileInvalidRequest 380
#define kNtErrorCloudFileReadOnlyVolume 381
#define kNtErrorCloudFileConnectedProviderOnly 382
#define kNtErrorCloudFileValidationFailed 383
#define kNtErrorSmb1NotAvailable 384
#define kNtErrorFileSystemVirtualizationInvalidOperation 385
#define kNtErrorCloudFileAuthenticationFailed 386
#define kNtErrorCloudFileInsufficientResources 387
#define kNtErrorCloudFileNetworkUnavailable 388
#define kNtErrorCloudFileUnsuccessful 389
#define kNtErrorCloudFileNotUnderSyncRoot 390
#define kNtErrorCloudFileInUse 391
#define kNtErrorCloudFilePinned 392
#define kNtErrorCloudFileRequestAborted 393
#define kNtErrorCloudFilePropertyCorrupt 394
#define kNtErrorCloudFileAccessDenied 395
#define kNtErrorCloudFileIncompatibleHardlinks 396
#define kNtErrorCloudFilePropertyLockConflict 397
#define kNtErrorCloudFileRequestCanceled 398
#define kNtErrorExternalSyskeyNotSupported 399
#define kNtErrorThreadModeAlreadyBackground 400
#define kNtErrorThreadModeNotBackground 401
#define kNtErrorProcessModeAlreadyBackground 402
#define kNtErrorProcessModeNotBackground 403
#define kNtErrorCloudFileProviderTerminated 404
#define kNtErrorNotACloudSyncRoot 405
#define kNtErrorFileProtectedUnderDpl 406
#define kNtErrorVolumeNotClusterAligned 407
#define kNtErrorNoPhysicallyAlignedFreeSpaceFound 408
#define kNtErrorAppxFileNotEncrypted 409
#define kNtErrorRwrawEncryptedFileNotEncrypted 410
#define kNtErrorRwrawEncryptedInvalidEdatainfoFileoffset 411
#define kNtErrorRwrawEncryptedInvalidEdatainfoFilerange 412
#define kNtErrorRwrawEncryptedInvalidEdatainfoParameter 413
#define kNtErrorLinuxSubsystemNotPresent 414
#define kNtErrorCapauthzNotDevunlocked 450
#define kNtErrorCapauthzChangeType 451
#define kNtErrorCapauthzNotProvisioned 452
#define kNtErrorCapauthzNotAuthorized 453
#define kNtErrorCapauthzNoPolicy 454
#define kNtErrorCapauthzDbCorrupted 455
#define kNtErrorCapauthzSccdInvalidCatalog 456
#define kNtErrorCapauthzSccdNoAuthEntity 457
#define kNtErrorCapauthzSccdParseError 458
#define kNtErrorCapauthzSccdDevModeRequired 459
#define kNtErrorCapauthzSccdNoCapabilityMatch 460
#define kNtErrorPnpQueryRemoveDeviceTimeout 480
#define kNtErrorPnpQueryRemoveRelatedDeviceTimeout 481
#define kNtErrorPnpQueryRemoveUnrelatedDeviceTimeout 482
#define kNtErrorDeviceHardwareError 483 /* EDEVERR */
#define kNtErrorInvalidAddress 487 /* EFAULT */
#define kNtErrorVrfCfgEnabled 1183
#define kNtErrorPartitionTerminating 1184
#define kNtErrorUserProfileLoad 500
#define kNtErrorArithmeticOverflow 534 /* EOVERFLOW */
#define kNtErrorPipeConnected 535
#define kNtErrorPipeListening 536
#define kNtErrorVerifierStop 537
#define kNtErrorAbiosError 538
#define kNtErrorWx86Warning 539
#define kNtErrorWx86Error 540
#define kNtErrorTimerNotCanceled 541
#define kNtErrorUnwind 542
#define kNtErrorBadStack 543
#define kNtErrorInvalidUnwindTarget 544
#define kNtErrorInvalidPortAttributes 545
#define kNtErrorPortMessageTooLong 546
#define kNtErrorInvalidQuotaLower 547
#define kNtErrorDeviceAlreadyAttached 548
#define kNtErrorInstructionMisalignment 549
#define kNtErrorProfilingNotStarted 550
#define kNtErrorProfilingNotStopped 551
#define kNtErrorCouldNotInterpret 552
#define kNtErrorProfilingAtLimit 553
#define kNtErrorCantWait 554
#define kNtErrorCantTerminateSelf 555
#define kNtErrorUnexpectedMmCreateErr 556
#define kNtErrorUnexpectedMmMapError 557
#define kNtErrorUnexpectedMmExtendErr 558
#define kNtErrorBadFunctionTable 559
#define kNtErrorNoGuidTranslation 560
#define kNtErrorInvalidLdtSize 561
#define kNtErrorInvalidLdtOffset 563
#define kNtErrorInvalidLdtDescriptor 564
#define kNtErrorTooManyThreads 565
#define kNtErrorThreadNotInProcess 566 /* ESRCH */
#define kNtErrorPagefileQuotaExceeded 567
#define kNtErrorLogonServerConflict 568
#define kNtErrorSynchronizationRequired 569
#define kNtErrorNetOpenFailed 570
#define kNtErrorIoPrivilegeFailed 571
#define kNtErrorControlCExit 572
#define kNtErrorMissingSystemfile 573
#define kNtErrorUnhandledException 574
#define kNtErrorAppInitFailure 575
#define kNtErrorPagefileCreateFailed 576
#define kNtErrorInvalidImageHash 577
#define kNtErrorNoPagefile 578
#define kNtErrorIllegalFloatContext 579
#define kNtErrorNoEventPair 580
#define kNtErrorDomainCtrlrConfigError 581
#define kNtErrorIllegalCharacter 582 /* EILSEQ */
#define kNtErrorUndefinedCharacter 583
#define kNtErrorFloppyVolume 584
#define kNtErrorBiosFailedToConnectInterrupt 585
#define kNtErrorBackupController 586
#define kNtErrorMutantLimitExceeded 587
#define kNtErrorFsDriverRequired 588
#define kNtErrorCannotLoadRegistryFile 589
#define kNtErrorDebugAttachFailed 590
#define kNtErrorSystemProcessTerminated 591
#define kNtErrorDataNotAccepted 592
#define kNtErrorVdmHardError 593
#define kNtErrorDriverCancelTimeout 594
#define kNtErrorReplyMessageMismatch 595 /* EPROGMISMATCH */
#define kNtErrorLostWritebehindData 596
#define kNtErrorClientServerParametersInvalid 597
#define kNtErrorNotTinyStream 598
#define kNtErrorStackOverflowRead 599
#define kNtErrorConvertToLarge 600
#define kNtErrorFoundOutOfScope 601
#define kNtErrorAllocateBucket 602
#define kNtErrorMarshallOverflow 603
#define kNtErrorInvalidVariant 604
#define kNtErrorBadCompressionBuffer 605
#define kNtErrorAuditFailed 606
#define kNtErrorTimerResolutionNotSet 607
#define kNtErrorInsufficientLogonInfo 608
#define kNtErrorBadDllEntrypoint 609
#define kNtErrorBadServiceEntrypoint 610
#define kNtErrorIpAddressConflict1 611
#define kNtErrorIpAddressConflict2 612
#define kNtErrorRegistryQuotaLimit 613
#define kNtErrorNoCallbackActive 614
#define kNtErrorPwdTooShort 615
#define kNtErrorPwdTooRecent 616
#define kNtErrorPwdHistoryConflict 617
#define kNtErrorUnsupportedCompression 618
#define kNtErrorInvalidHwProfile 619
#define kNtErrorInvalidPlugplayDevicePath 620
#define kNtErrorQuotaListInconsistent 621
#define kNtErrorEvaluationExpiration 622
#define kNtErrorIllegalDllRelocation 623
#define kNtErrorDllInitFailedLogoff 624
#define kNtErrorValidateContinue 625
#define kNtErrorNoMoreMatches 626
#define kNtErrorRangeListConflict 627
#define kNtErrorServerSidMismatch 628
#define kNtErrorCantEnableDenyOnly 629
#define kNtErrorFloatMultipleFaults 630
#define kNtErrorFloatMultipleTraps 631
#define kNtErrorNointerface 632
#define kNtErrorDriverFailedSleep 633
#define kNtErrorCorruptSystemFile 634
#define kNtErrorCommitmentMinimum 635
#define kNtErrorPnpRestartEnumeration 636
#define kNtErrorSystemImageBadSignature 637
#define kNtErrorPnpRebootRequired 638
#define kNtErrorInsufficientPower 639 /* EPWROFF */
#define kNtErrorMultipleFaultViolation 640
#define kNtErrorSystemShutdown 641
#define kNtErrorPortNotSet 642
#define kNtErrorDsVersionCheckFailure 643
#define kNtErrorRangeNotFound 644
#define kNtErrorNotSafeModeDriver 646
#define kNtErrorFailedDriverEntry 647
#define kNtErrorDeviceEnumerationError 648
#define kNtErrorMountPointNotResolved 649
#define kNtErrorInvalidDeviceObjectParameter 650
#define kNtErrorMcaOccured 651
#define kNtErrorDriverDatabaseError 652
#define kNtErrorSystemHiveTooLarge 653
#define kNtErrorDriverFailedPriorUnload 654
#define kNtErrorVolsnapPrepareHibernate 655
#define kNtErrorHibernationFailure 656
#define kNtErrorPwdTooLong 657
#define kNtErrorFileSystemLimitation 665
#define kNtErrorAssertionFailure 668
#define kNtErrorAcpiError 669
#define kNtErrorWowAssertion 670
#define kNtErrorPnpBadMpsTable 671
#define kNtErrorPnpTranslationFailed 672
#define kNtErrorPnpIrqTranslationFailed 673
#define kNtErrorPnpInvalidId 674
#define kNtErrorWakeSystemDebugger 675
#define kNtErrorHandlesClosed 676
#define kNtErrorExtraneousInformation 677
#define kNtErrorRxactCommitNecessary 678
#define kNtErrorMediaCheck 679
#define kNtErrorGuidSubstitutionMade 680
#define kNtErrorStoppedOnSymlink 681
#define kNtErrorLongjump 682
#define kNtErrorPlugplayQueryVetoed 683
#define kNtErrorUnwindConsolidate 684
#define kNtErrorRegistryHiveRecovered 685
#define kNtErrorDllMightBeInsecure 686
#define kNtErrorDllMightBeIncompatible 687
#define kNtErrorDbgExceptionNotHandled 688
#define kNtErrorDbgReplyLater 689
#define kNtErrorDbgUnableToProvideHandle 690
#define kNtErrorDbgTerminateThread 691
#define kNtErrorDbgTerminateProcess 692
#define kNtErrorDbgControlC 693
#define kNtErrorDbgPrintexceptionC 694
#define kNtErrorDbgRipexception 695
#define kNtErrorDbgControlBreak 696
#define kNtErrorDbgCommandException 697
#define kNtErrorObjectNameExists 698
#define kNtErrorThreadWasSuspended 699
#define kNtErrorImageNotAtBase 700
#define kNtErrorRxactStateCreated 701
#define kNtErrorSegmentNotification 702
#define kNtErrorBadCurrentDirectory 703
#define kNtErrorFtReadRecoveryFromBackup 704
#define kNtErrorFtWriteRecovery 705
#define kNtErrorImageMachineTypeMismatch 706
#define kNtErrorReceivePartial 707
#define kNtErrorReceiveExpedited 708
#define kNtErrorReceivePartialExpedited 709
#define kNtErrorEventDone 710
#define kNtErrorEventPending 711
#define kNtErrorCheckingFileSystem 712
#define kNtErrorFatalAppExit 713
#define kNtErrorPredefinedHandle 714
#define kNtErrorWasUnlocked 715
#define kNtErrorServiceNotification 716
#define kNtErrorWasLocked 717
#define kNtErrorLogHardError 718
#define kNtErrorAlreadyWin32 719
#define kNtErrorImageMachineTypeMismatchExe 720
#define kNtErrorNoYieldPerformed 721
#define kNtErrorTimerResumeIgnored 722
#define kNtErrorArbitrationUnhandled 723
#define kNtErrorCardbusNotSupported 724
#define kNtErrorMpProcessorMismatch 725
#define kNtErrorHibernated 726
#define kNtErrorResumeHibernation 727
#define kNtErrorFirmwareUpdated 728
#define kNtErrorDriversLeakingLockedPages 729
#define kNtErrorWakeSystem 730
#define kNtErrorWait_1 731
#define kNtErrorWait_2 732
#define kNtErrorWait_3 733
#define kNtErrorWait_63 734
#define kNtErrorAbandonedWait_0 735
#define kNtErrorAbandonedWait_63 736
#define kNtErrorUserApc 737
#define kNtErrorKernelApc 738
#define kNtErrorAlerted 739
#define kNtErrorElevationRequired 740
#define kNtErrorReparse 741
#define kNtErrorOplockBreakInProgress 742
#define kNtErrorVolumeMounted 743
#define kNtErrorRxactCommitted 744
#define kNtErrorNotifyCleanup 745
#define kNtErrorPrimaryTransportConnectFailed 746
#define kNtErrorPageFaultTransition 747
#define kNtErrorPageFaultDemandZero 748
#define kNtErrorPageFaultCopyOnWrite 749
#define kNtErrorPageFaultGuardPage 750
#define kNtErrorPageFaultPagingFile 751
#define kNtErrorCachePageLocked 752
#define kNtErrorCrashDump 753
#define kNtErrorBufferAllZeros 754
#define kNtErrorReparseObject 755
#define kNtErrorResourceRequirementsChanged 756
#define kNtErrorTranslationComplete 757
#define kNtErrorNothingToTerminate 758
#define kNtErrorProcessNotInJob 759
#define kNtErrorProcessInJob 760
#define kNtErrorVolsnapHibernateReady 761
#define kNtErrorFsfilterOpCompletedSuccessfully 762
#define kNtErrorInterruptVectorAlreadyConnected 763
#define kNtErrorInterruptStillConnected 764
#define kNtErrorWaitForOplock 765
#define kNtErrorDbgExceptionHandled 766
#define kNtErrorDbgContinue 767
#define kNtErrorCallbackPopStack 768
#define kNtErrorCompressionDisabled 769
#define kNtErrorCantfetchbackwards 770
#define kNtErrorCantscrollbackwards 771
#define kNtErrorRowsnotreleased 772
#define kNtErrorBadAccessorFlags 773
#define kNtErrorErrorsEncountered 774
#define kNtErrorNotCapable 775
#define kNtErrorRequestOutOfSequence 776
#define kNtErrorVersionParseError 777
#define kNtErrorBadstartposition 778
#define kNtErrorMemoryHardware 779
#define kNtErrorDiskRepairDisabled 780
#define kNtErrorInsufficientResourceForSpecifiedSharedSectionSize 781
#define kNtErrorSystemPowerstateTransition 782
#define kNtErrorSystemPowerstateComplexTransition 783
#define kNtErrorMcaException 784
#define kNtErrorAccessAuditByPolicy 785
#define kNtErrorAccessDisabledNoSaferUiByPolicy 786
#define kNtErrorAbandonHiberfile 787
#define kNtErrorLostWritebehindDataNetworkDisconnected 788
#define kNtErrorLostWritebehindDataNetworkServerError 789
#define kNtErrorLostWritebehindDataLocalDiskError 790
#define kNtErrorBadMcfgTable 791
#define kNtErrorDiskRepairRedirected 792
#define kNtErrorDiskRepairUnsuccessful 793
#define kNtErrorCorruptLogOverfull 794
#define kNtErrorCorruptLogCorrupted 795
#define kNtErrorCorruptLogUnavailable 796
#define kNtErrorCorruptLogDeletedFull 797
#define kNtErrorCorruptLogCleared 798
#define kNtErrorOrphanNameExhausted 799
#define kNtErrorOplockSwitchedToNewHandle 800
#define kNtErrorCannotGrantRequestedOplock 801
#define kNtErrorCannotBreakOplock 802
#define kNtErrorOplockHandleClosed 803
#define kNtErrorNoAceCondition 804
#define kNtErrorInvalidAceCondition 805
#define kNtErrorFileHandleRevoked 806
#define kNtErrorImageAtDifferentBase 807
#define kNtErrorEncryptedIoNotPossible 808
#define kNtErrorFileMetadataOptimizationInProgress 809
#define kNtErrorQuotaActivity 810
#define kNtErrorHandleRevoked 811
#define kNtErrorCallbackInvokeInline 812
#define kNtErrorCpuSetInvalid 813
#define kNtErrorEnclaveNotTerminated 814
#define kNtErrorEnclaveViolation 815
#define kNtErrorEaAccessDenied 994
#define kNtErrorOperationAborted 995
#define kNtErrorIoIncomplete 996
#define kNtErrorIoPending 997
#define kNtErrorNoaccess 998
#define kNtErrorSwaperror 999
#define kNtErrorStackOverflow 1001
#define kNtErrorInvalidMessage 1002
#define kNtErrorCanNotComplete 1003
#define kNtErrorInvalidFlags 1004
#define kNtErrorUnrecognizedVolume 1005
#define kNtErrorFileInvalid 1006
#define kNtErrorFullscreenMode 1007
#define kNtErrorNoToken 1008
#define kNtErrorBaddb 1009
#define kNtErrorBadkey 1010
#define kNtErrorCantopen 1011
#define kNtErrorCantread 1012
#define kNtErrorCantwrite 1013
#define kNtErrorRegistryRecovered 1014
#define kNtErrorRegistryCorrupt 1015
#define kNtErrorRegistryIoFailed 1016
#define kNtErrorNotRegistryFile 1017
#define kNtErrorKeyDeleted 1018
#define kNtErrorNoLogSpace 1019
#define kNtErrorKeyHasChildren 1020
#define kNtErrorChildMustBeVolatile 1021
#define kNtErrorNotifyEnumDir 1022
#define kNtErrorDependentServicesRunning 1051
#define kNtErrorInvalidServiceControl 1052
#define kNtErrorServiceRequestTimeout 1053
#define kNtErrorServiceNoThread 1054
#define kNtErrorServiceDatabaseLocked 1055
#define kNtErrorServiceAlreadyRunning 1056
#define kNtErrorInvalidServiceAccount 1057
#define kNtErrorServiceDisabled 1058
#define kNtErrorCircularDependency 1059
#define kNtErrorServiceDoesNotExist 1060
#define kNtErrorServiceCannotAcceptCtrl 1061
#define kNtErrorServiceNotActive 1062
#define kNtErrorFailedServiceControllerConnect 1063
#define kNtErrorExceptionInService 1064
#define kNtErrorDatabaseDoesNotExist 1065
#define kNtErrorServiceSpecificError 1066
#define kNtErrorProcessAborted 1067
#define kNtErrorServiceDependencyFail 1068
#define kNtErrorServiceLogonFailed 1069
#define kNtErrorServiceStartHang 1070
#define kNtErrorInvalidServiceLock 1071
#define kNtErrorServiceMarkedForDelete 1072
#define kNtErrorServiceExists 1073
#define kNtErrorAlreadyRunningLkg 1074
#define kNtErrorServiceDependencyDeleted 1075
#define kNtErrorBootAlreadyAccepted 1076
#define kNtErrorServiceNeverStarted 1077
#define kNtErrorDuplicateServiceName 1078
#define kNtErrorDifferentServiceAccount 1079
#define kNtErrorCannotDetectDriverFailure 1080
#define kNtErrorCannotDetectProcessAbort 1081
#define kNtErrorNoRecoveryProgram 1082
#define kNtErrorServiceNotInExe 1083
#define kNtErrorNotSafebootService 1084
#define kNtErrorEndOfMedia 1100
#define kNtErrorFilemarkDetected 1101
#define kNtErrorBeginningOfMedia 1102
#define kNtErrorSetmarkDetected 1103
#define kNtErrorNoDataDetected 1104
#define kNtErrorPartitionFailure 1105
#define kNtErrorInvalidBlockLength 1106
#define kNtErrorDeviceNotPartitioned 1107
#define kNtErrorUnableToLockMedia 1108
#define kNtErrorUnableToUnloadMedia 1109
#define kNtErrorMediaChanged 1110
#define kNtErrorBusReset 1111
#define kNtErrorNoMediaInDrive 1112 /* ENXIO */
#define kNtErrorNoUnicodeTranslation 1113
#define kNtErrorDllInitFailed 1114
#define kNtErrorShutdownInProgress 1115
#define kNtErrorNoShutdownInProgress 1116
#define kNtErrorIoDevice 1117 /* EIO */
#define kNtErrorSerialNoDevice 1118 /* ENOTTY */
#define kNtErrorIrqBusy 1119
#define kNtErrorMoreWrites 1120
#define kNtErrorCounterTimeout 1121
#define kNtErrorFloppyIdMarkNotFound 1122
#define kNtErrorFloppyWrongCylinder 1123
#define kNtErrorFloppyUnknownError 1124
#define kNtErrorFloppyBadRegisters 1125
#define kNtErrorDiskRecalibrateFailed 1126
#define kNtErrorDiskOperationFailed 1127
#define kNtErrorDiskResetFailed 1128
#define kNtErrorEomOverflow 1129
#define kNtErrorNotEnoughServerMemory 1130
#define kNtErrorPossibleDeadlock 1131 /* EDEADLK */
#define kNtErrorMappedAlignment 1132
#define kNtErrorSetPowerStateVetoed 1140
#define kNtErrorSetPowerStateFailed 1141
#define kNtErrorTooManyLinks 1142
#define kNtErrorOldWinVersion 1150
#define kNtErrorAppWrongOs 1151
#define kNtErrorSingleInstanceApp 1152
#define kNtErrorRmodeApp 1153
#define kNtErrorInvalidDll 1154
#define kNtErrorNoAssociation 1155
#define kNtErrorDdeFail 1156
#define kNtErrorDllNotFound 1157
#define kNtErrorNoMoreUserHandles 1158
#define kNtErrorMessageSyncOnly 1159
#define kNtErrorSourceElementEmpty 1160
#define kNtErrorDestinationElementFull 1161
#define kNtErrorIllegalElementAddress 1162
#define kNtErrorMagazineNotPresent 1163
#define kNtErrorDeviceReinitializationNeeded 1164
#define kNtErrorDeviceRequiresCleaning 1165
#define kNtErrorDeviceDoorOpen 1166
#define kNtErrorDeviceNotConnected 1167
#define kNtErrorNotFound 1168
#define kNtErrorNoMatch 1169
#define kNtErrorSetNotFound 1170
#define kNtErrorPointNotFound 1171
#define kNtErrorNoTrackingService 1172
#define kNtErrorNoVolumeId 1173
#define kNtErrorUnableToRemoveReplaced 1175
#define kNtErrorUnableToMoveReplacement 1176
#define kNtErrorUnableToMoveReplacement_2 1177
#define kNtErrorJournalDeleteInProgress 1178
#define kNtErrorJournalNotActive 1179
#define kNtErrorPotentialFileFound 1180
#define kNtErrorJournalEntryDeleted 1181
#define kNtErrorShutdownIsScheduled 1190
#define kNtErrorShutdownUsersLoggedOn 1191
#define kNtErrorBadDevice 1200 /* ENODEV */
#define kNtErrorConnectionUnavail 1201
#define kNtErrorDeviceAlreadyRemembered 1202
#define kNtErrorNoNetOrBadPath 1203
#define kNtErrorBadProvider 1204
#define kNtErrorCannotOpenProfile 1205
#define kNtErrorBadProfile 1206
#define kNtErrorNotContainer 1207
#define kNtErrorExtendedError 1208
#define kNtErrorInvalidGroupname 1209
#define kNtErrorInvalidComputername 1210
#define kNtErrorInvalidEventname 1211
#define kNtErrorInvalidDomainname 1212
#define kNtErrorInvalidServicename 1213
#define kNtErrorInvalidNetname 1214
#define kNtErrorInvalidSharename 1215
#define kNtErrorInvalidPasswordname 1216
#define kNtErrorInvalidMessagename 1217
#define kNtErrorInvalidMessagedest 1218
#define kNtErrorSessionCredentialConflict 1219
#define kNtErrorRemoteSessionLimitExceeded 1220
#define kNtErrorDupDomainname 1221
#define kNtErrorNoNetwork 1222
#define kNtErrorCancelled 1223 /* ECANCELED */
#define kNtErrorUserMappedFile 1224
#define kNtErrorConnectionRefused 1225
#define kNtErrorGracefulDisconnect 1226
#define kNtErrorAddressAlreadyAssociated 1227
#define kNtErrorAddressNotAssociated 1228
#define kNtErrorConnectionInvalid 1229
#define kNtErrorConnectionActive 1230
#define kNtErrorNetworkUnreachable 1231
#define kNtErrorHostUnreachable 1232
#define kNtErrorProtocolUnreachable 1233 /* multimapped to ENETUNREACH */
#define kNtErrorPortUnreachable 1234
#define kNtErrorRequestAborted 1235
#define kNtErrorConnectionAborted 1236
#define kNtErrorRetry 1237
#define kNtErrorConnectionCountLimit 1238
#define kNtErrorLoginTimeRestriction 1239
#define kNtErrorLoginWkstaRestriction 1240
#define kNtErrorIncorrectAddress 1241
#define kNtErrorAlreadyRegistered 1242
#define kNtErrorServiceNotFound 1243
#define kNtErrorNotAuthenticated 1244 /* EAUTH */
#define kNtErrorNotLoggedOn 1245
#define kNtErrorContinue 1246
#define kNtErrorAlreadyInitialized 1247
#define kNtErrorNoMoreDevices 1248
#define kNtErrorNoSuchSite 1249
#define kNtErrorDomainControllerExists 1250
#define kNtErrorOnlyIfConnected 1251
#define kNtErrorOverrideNochanges 1252
#define kNtErrorBadUserProfile 1253
#define kNtErrorNotSupportedOnSbs 1254
#define kNtErrorServerShutdownInProgress 1255
#define kNtErrorHostDown 1256
#define kNtErrorNonAccountSid 1257
#define kNtErrorNonDomainSid 1258
#define kNtErrorApphelpBlock 1259
#define kNtErrorAccessDisabledByPolicy 1260
#define kNtErrorRegNatConsumption 1261
#define kNtErrorCscshareOffline 1262
#define kNtErrorPkinitFailure 1263
#define kNtErrorSmartcardSubsystemFailure 1264
#define kNtErrorDowngradeDetected 1265
#define kNtErrorMachineLocked 1271
#define kNtErrorSmbGuestLogonBlocked 1272
#define kNtErrorCallbackSuppliedInvalidData 1273
#define kNtErrorSyncForegroundRefreshRequired 1274
#define kNtErrorDriverBlocked 1275
#define kNtErrorInvalidImportOfNonDll 1276
#define kNtErrorAccessDisabledWebblade 1277
#define kNtErrorAccessDisabledWebbladeTamper 1278
#define kNtErrorRecoveryFailure 1279
#define kNtErrorAlreadyFiber 1280
#define kNtErrorAlreadyThread 1281
#define kNtErrorStackBufferOverrun 1282
#define kNtErrorParameterQuotaExceeded 1283
#define kNtErrorDebuggerInactive 1284
#define kNtErrorDelayLoadFailed 1285
#define kNtErrorVdmDisallowed 1286
#define kNtErrorUnidentifiedError 1287 /* EIDRM */
#define kNtErrorInvalidCruntimeParameter 1288
#define kNtErrorBeyondVdl 1289
#define kNtErrorIncompatibleServiceSidType 1290
#define kNtErrorDriverProcessTerminated 1291
#define kNtErrorImplementationLimit 1292
#define kNtErrorProcessIsProtected 1293
#define kNtErrorServiceNotifyClientLagging 1294
#define kNtErrorDiskQuotaExceeded 1295
#define kNtErrorContentBlocked 1296
#define kNtErrorIncompatibleServicePrivilege 1297
#define kNtErrorAppHang 1298
#define kNtErrorInvalidLabel 1299
#define kNtErrorNotAllAssigned 1300
#define kNtErrorSomeNotMapped 1301
#define kNtErrorNoQuotasForAccount 1302
#define kNtErrorLocalUserSessionKey 1303
#define kNtErrorNullLmPassword 1304
#define kNtErrorUnknownRevision 1305
#define kNtErrorRevisionMismatch 1306
#define kNtErrorInvalidOwner 1307
#define kNtErrorInvalidPrimaryGroup 1308
#define kNtErrorNoImpersonationToken 1309
#define kNtErrorCantDisableMandatory 1310
#define kNtErrorNoLogonServers 1311
#define kNtErrorNoSuchLogonSession 1312
#define kNtErrorNoSuchPrivilege 1313
#define kNtErrorPrivilegeNotHeld 1314
#define kNtErrorInvalidAccountName 1315
#define kNtErrorUserExists 1316
#define kNtErrorNoSuchUser 1317
#define kNtErrorGroupExists 1318
#define kNtErrorNoSuchGroup 1319
#define kNtErrorMemberInGroup 1320
#define kNtErrorMemberNotInGroup 1321
#define kNtErrorLastAdmin 1322
#define kNtErrorWrongPassword 1323
#define kNtErrorIllFormedPassword 1324
#define kNtErrorPasswordRestriction 1325
#define kNtErrorLogonFailure 1326
#define kNtErrorAccountRestriction 1327
#define kNtErrorInvalidLogonHours 1328
#define kNtErrorInvalidWorkstation 1329
#define kNtErrorPasswordExpired 1330
#define kNtErrorAccountDisabled 1331
#define kNtErrorNoneMapped 1332
#define kNtErrorTooManyLuidsRequested 1333
#define kNtErrorLuidsExhausted 1334
#define kNtErrorInvalidSubAuthority 1335
#define kNtErrorInvalidAcl 1336
#define kNtErrorInvalidSid 1337
#define kNtErrorInvalidSecurityDescr 1338
#define kNtErrorBadInheritanceAcl 1340
#define kNtErrorServerDisabled 1341
#define kNtErrorServerNotDisabled 1342
#define kNtErrorInvalidIdAuthority 1343
#define kNtErrorAllottedSpaceExceeded 1344
#define kNtErrorInvalidGroupAttributes 1345
#define kNtErrorBadImpersonationLevel 1346
#define kNtErrorCantOpenAnonymous 1347
#define kNtErrorBadValidationClass 1348
#define kNtErrorBadTokenType 1349
#define kNtErrorNoSecurityOnObject 1350
#define kNtErrorCantAccessDomainInfo 1351
#define kNtErrorInvalidServerState 1352
#define kNtErrorInvalidDomainState 1353
#define kNtErrorInvalidDomainRole 1354
#define kNtErrorNoSuchDomain 1355
#define kNtErrorDomainExists 1356
#define kNtErrorDomainLimitExceeded 1357
#define kNtErrorInternalDbCorruption 1358
#define kNtErrorInternalError 1359
#define kNtErrorGenericNotMapped 1360
#define kNtErrorBadDescriptorFormat 1361
#define kNtErrorNotLogonProcess 1362
#define kNtErrorLogonSessionExists 1363
#define kNtErrorNoSuchPackage 1364
#define kNtErrorBadLogonSessionState 1365
#define kNtErrorLogonSessionCollision 1366
#define kNtErrorInvalidLogonType 1367
#define kNtErrorCannotImpersonate 1368
#define kNtErrorRxactInvalidState 1369
#define kNtErrorRxactCommitFailure 1370
#define kNtErrorSpecialAccount 1371
#define kNtErrorSpecialGroup 1372
#define kNtErrorSpecialUser 1373
#define kNtErrorMembersPrimaryGroup 1374
#define kNtErrorTokenAlreadyInUse 1375
#define kNtErrorNoSuchAlias 1376
#define kNtErrorMemberNotInAlias 1377
#define kNtErrorMemberInAlias 1378
#define kNtErrorAliasExists 1379
#define kNtErrorLogonNotGranted 1380
#define kNtErrorTooManySecrets 1381
#define kNtErrorSecretTooLong 1382
#define kNtErrorInternalDbError 1383
#define kNtErrorTooManyContextIds 1384
#define kNtErrorLogonTypeNotGranted 1385
#define kNtErrorNtCrossEncryptionRequired 1386
#define kNtErrorNoSuchMember 1387
#define kNtErrorInvalidMember 1388
#define kNtErrorTooManySids 1389
#define kNtErrorLmCrossEncryptionRequired 1390
#define kNtErrorNoInheritance 1391
#define kNtErrorFileCorrupt 1392
#define kNtErrorDiskCorrupt 1393
#define kNtErrorNoUserSessionKey 1394
#define kNtErrorLicenseQuotaExceeded 1395
#define kNtErrorWrongTargetName 1396
#define kNtErrorMutualAuthFailed 1397
#define kNtErrorTimeSkew 1398
#define kNtErrorCurrentDomainNotAllowed 1399
#define kNtErrorInvalidWindowHandle 1400
#define kNtErrorInvalidMenuHandle 1401
#define kNtErrorInvalidCursorHandle 1402
#define kNtErrorInvalidAccelHandle 1403
#define kNtErrorInvalidHookHandle 1404
#define kNtErrorInvalidDwpHandle 1405
#define kNtErrorTlwWithWschild 1406
#define kNtErrorCannotFindWndClass 1407
#define kNtErrorWindowOfOtherThread 1408
#define kNtErrorHotkeyAlreadyRegistered 1409
#define kNtErrorClassAlreadyExists 1410
#define kNtErrorClassDoesNotExist 1411
#define kNtErrorClassHasWindows 1412
#define kNtErrorInvalidIndex 1413
#define kNtErrorInvalidIconHandle 1414
#define kNtErrorPrivateDialogIndex 1415
#define kNtErrorListboxIdNotFound 1416
#define kNtErrorNoWildcardCharacters 1417
#define kNtErrorClipboardNotOpen 1418
#define kNtErrorHotkeyNotRegistered 1419
#define kNtErrorWindowNotDialog 1420
#define kNtErrorControlIdNotFound 1421
#define kNtErrorInvalidComboboxMessage 1422
#define kNtErrorWindowNotCombobox 1423
#define kNtErrorInvalidEditHeight 1424
#define kNtErrorDcNotFound 1425
#define kNtErrorInvalidHookFilter 1426
#define kNtErrorInvalidFilterProc 1427
#define kNtErrorHookNeedsHmod 1428
#define kNtErrorGlobalOnlyHook 1429
#define kNtErrorJournalHookSet 1430
#define kNtErrorHookNotInstalled 1431
#define kNtErrorInvalidLbMessage 1432
#define kNtErrorSetcountOnBadLb 1433
#define kNtErrorLbWithoutTabstops 1434
#define kNtErrorDestroyObjectOfOtherThread 1435
#define kNtErrorChildWindowMenu 1436
#define kNtErrorNoSystemMenu 1437
#define kNtErrorInvalidMsgboxStyle 1438
#define kNtErrorInvalidSpiValue 1439
#define kNtErrorScreenAlreadyLocked 1440
#define kNtErrorHwndsHaveDiffParent 1441
#define kNtErrorNotChildWindow 1442
#define kNtErrorInvalidGwCommand 1443
#define kNtErrorInvalidThreadId 1444
#define kNtErrorNonMdichildWindow 1445
#define kNtErrorPopupAlreadyActive 1446
#define kNtErrorNoScrollbars 1447
#define kNtErrorInvalidScrollbarRange 1448
#define kNtErrorInvalidShowwinCommand 1449
#define kNtErrorNoSystemResources 1450
#define kNtErrorNonpagedSystemResources 1451
#define kNtErrorPagedSystemResources 1452
#define kNtErrorWorkingSetQuota 1453
#define kNtErrorPagefileQuota 1454
#define kNtErrorCommitmentLimit 1455
#define kNtErrorMenuItemNotFound 1456
#define kNtErrorInvalidKeyboardHandle 1457
#define kNtErrorHookTypeNotAllowed 1458
#define kNtErrorRequiresInteractiveWindowstation 1459
#define kNtErrorTimeout 1460 /* ETIMEDOUT */
#define kNtErrorInvalidMonitorHandle 1461
#define kNtErrorIncorrectSize 1462
#define kNtErrorSymlinkClassDisabled 1463
#define kNtErrorSymlinkNotSupported 1464
#define kNtErrorXmlParseError 1465
#define kNtErrorXmldsigError 1466
#define kNtErrorRestartApplication 1467
#define kNtErrorWrongCompartment 1468
#define kNtErrorAuthipFailure 1469
#define kNtErrorNoNvramResources 1470
#define kNtErrorNotGuiProcess 1471
#define kNtErrorEventlogFileCorrupt 1500
#define kNtErrorEventlogCantStart 1501
#define kNtErrorLogFileFull 1502
#define kNtErrorEventlogFileChanged 1503
#define kNtErrorContainerAssigned 1504
#define kNtErrorJobNoContainer 1505
#define kNtErrorInvalidTaskName 1550
#define kNtErrorInvalidTaskIndex 1551
#define kNtErrorThreadAlreadyInTask 1552
#define kNtErrorInstallServiceFailure 1601
#define kNtErrorInstallUserexit 1602
#define kNtErrorInstallFailure 1603
#define kNtErrorInstallSuspend 1604
#define kNtErrorUnknownProduct 1605
#define kNtErrorUnknownFeature 1606
#define kNtErrorUnknownComponent 1607
#define kNtErrorUnknownProperty 1608
#define kNtErrorInvalidHandleState 1609
#define kNtErrorBadConfiguration 1610
#define kNtErrorIndexAbsent 1611
#define kNtErrorInstallSourceAbsent 1612
#define kNtErrorInstallPackageVersion 1613
#define kNtErrorProductUninstalled 1614
#define kNtErrorBadQuerySyntax 1615
#define kNtErrorInvalidField 1616
#define kNtErrorDeviceRemoved 1617
#define kNtErrorInstallAlreadyRunning 1618
#define kNtErrorInstallPackageOpenFailed 1619
#define kNtErrorInstallPackageInvalid 1620
#define kNtErrorInstallUiFailure 1621
#define kNtErrorInstallLogFailure 1622
#define kNtErrorInstallLanguageUnsupported 1623
#define kNtErrorInstallTransformFailure 1624
#define kNtErrorInstallPackageRejected 1625
#define kNtErrorFunctionNotCalled 1626 /* EBADRPC */
#define kNtErrorFunctionFailed 1627 /* ERPCMISMATCH */
#define kNtErrorInvalidTable 1628
#define kNtErrorDatatypeMismatch 1629
#define kNtErrorUnsupportedType 1630
#define kNtErrorCreateFailed 1631
#define kNtErrorInstallTempUnwritable 1632
#define kNtErrorInstallPlatformUnsupported 1633
#define kNtErrorInstallNotused 1634
#define kNtErrorPatchPackageOpenFailed 1635
#define kNtErrorPatchPackageInvalid 1636
#define kNtErrorPatchPackageUnsupported 1637
#define kNtErrorProductVersion 1638
#define kNtErrorInvalidCommandLine 1639 /* E2BIG */
#define kNtErrorInstallRemoteDisallowed 1640
#define kNtErrorSuccessRebootInitiated 1641
#define kNtErrorPatchTargetNotFound 1642
#define kNtErrorPatchPackageRejected 1643
#define kNtErrorInstallTransformRejected 1644
#define kNtErrorInstallRemoteProhibited 1645
#define kNtErrorPatchRemovalUnsupported 1646
#define kNtErrorUnknownPatch 1647
#define kNtErrorPatchNoSequence 1648
#define kNtErrorPatchRemovalDisallowed 1649
#define kNtErrorInvalidPatchXml 1650
#define kNtErrorPatchManagedAdvertisedProduct 1651
#define kNtErrorInstallServiceSafeboot 1652
#define kNtErrorFailFastException 1653
#define kNtErrorInstallRejected 1654
#define kNtErrorDynamicCodeBlocked 1655
#define kNtErrorNotSameObject 1656
#define kNtErrorStrictCfgViolation 1657
#define kNtErrorSetContextDenied 1660
#define kNtErrorCrossPartitionViolation 1661
#define kNtErrorInvalidUserBuffer 1784
#define kNtErrorUnrecognizedMedia 1785
#define kNtErrorNoTrustLsaSecret 1786
#define kNtErrorNoTrustSamAccount 1787
#define kNtErrorTrustedDomainFailure 1788
#define kNtErrorTrustedRelationshipFailure 1789
#define kNtErrorTrustFailure 1790
#define kNtErrorNetlogonNotStarted 1792
#define kNtErrorAccountExpired 1793
#define kNtErrorRedirectorHasOpenHandles 1794
#define kNtErrorPrinterDriverAlreadyInstalled 1795
#define kNtErrorUnknownPort 1796
#define kNtErrorUnknownPrinterDriver 1797
#define kNtErrorUnknownPrintprocessor 1798
#define kNtErrorInvalidSeparatorFile 1799
#define kNtErrorInvalidPriority 1800
#define kNtErrorInvalidPrinterName 1801
#define kNtErrorPrinterAlreadyExists 1802
#define kNtErrorInvalidPrinterCommand 1803
#define kNtErrorInvalidDatatype 1804
#define kNtErrorInvalidEnvironment 1805
#define kNtErrorNologonInterdomainTrustAccount 1807
#define kNtErrorNologonWorkstationTrustAccount 1808
#define kNtErrorNologonServerTrustAccount 1809
#define kNtErrorDomainTrustInconsistent 1810
#define kNtErrorServerHasOpenHandles 1811
#define kNtErrorResourceDataNotFound 1812
#define kNtErrorResourceTypeNotFound 1813
#define kNtErrorResourceNameNotFound 1814
#define kNtErrorResourceLangNotFound 1815
#define kNtErrorNotEnoughQuota 1816 /* EDQUOT */
#define kNtErrorInvalidTime 1901
#define kNtErrorInvalidFormName 1902
#define kNtErrorInvalidFormSize 1903
#define kNtErrorAlreadyWaiting 1904
#define kNtErrorPrinterDeleted 1905
#define kNtErrorInvalidPrinterState 1906
#define kNtErrorPasswordMustChange 1907
#define kNtErrorDomainControllerNotFound 1908
#define kNtErrorAccountLockedOut 1909
#define kNtErrorNoSitename 1919
#define kNtErrorCantAccessFile 1920
#define kNtErrorCantResolveFilename 1921
#define kNtErrorKmDriverBlocked 1930
#define kNtErrorContextExpired 1931
#define kNtErrorPerUserTrustQuotaExceeded 1932
#define kNtErrorAllUserTrustQuotaExceeded 1933
#define kNtErrorUserDeleteTrustQuotaExceeded 1934
#define kNtErrorAuthenticationFirewallFailed 1935
#define kNtErrorRemotePrintConnectionsBlocked 1936
#define kNtErrorNtlmBlocked 1937
#define kNtErrorPasswordChangeRequired 1938
#define kNtErrorLostModeLogonRestriction 1939
#define kNtErrorInvalidPixelFormat 2000
#define kNtErrorBadDriver 2001
#define kNtErrorInvalidWindowStyle 2002
#define kNtErrorMetafileNotSupported 2003
#define kNtErrorTransformNotSupported 2004
#define kNtErrorClippingNotSupported 2005
#define kNtErrorInvalidCmm 2010
#define kNtErrorInvalidProfile 2011
#define kNtErrorTagNotFound 2012
#define kNtErrorTagNotPresent 2013
#define kNtErrorDuplicateTag 2014
#define kNtErrorProfileNotAssociatedWithDevice 2015
#define kNtErrorProfileNotFound 2016
#define kNtErrorInvalidColorspace 2017
#define kNtErrorIcmNotEnabled 2018
#define kNtErrorDeletingIcmXform 2019
#define kNtErrorInvalidTransform 2020
#define kNtErrorColorspaceMismatch 2021
#define kNtErrorInvalidColorindex 2022
#define kNtErrorProfileDoesNotMatchDevice 2023
#define kNtErrorConnectedOtherPassword 2108
#define kNtErrorConnectedOtherPasswordDefault 2109
#define kNtErrorBadUsername 2202
#define kNtErrorNotConnected 2250
#define kNtErrorOpenFiles 2401
#define kNtErrorActiveConnections 2402
#define kNtErrorDeviceInUse 2404
#define kNtErrorUnknownPrintMonitor 3000
#define kNtErrorPrinterDriverInUse 3001
#define kNtErrorSpoolFileNotFound 3002
#define kNtErrorSplNoStartdoc 3003
#define kNtErrorSplNoAddjob 3004
#define kNtErrorPrintProcessorAlreadyInstalled 3005
#define kNtErrorPrintMonitorAlreadyInstalled 3006
#define kNtErrorInvalidPrintMonitor 3007
#define kNtErrorPrintMonitorInUse 3008
#define kNtErrorPrinterHasJobsQueued 3009
#define kNtErrorSuccessRebootRequired 3010
#define kNtErrorSuccessRestartRequired 3011
#define kNtErrorPrinterNotFound 3012
#define kNtErrorPrinterDriverWarned 3013
#define kNtErrorPrinterDriverBlocked 3014
#define kNtErrorPrinterDriverPackageInUse 3015
#define kNtErrorCoreDriverPackageNotFound 3016
#define kNtErrorFailRebootRequired 3017
#define kNtErrorFailRebootInitiated 3018
#define kNtErrorPrinterDriverDownloadNeeded 3019
#define kNtErrorPrintJobRestartRequired 3020
#define kNtErrorInvalidPrinterDriverManifest 3021
#define kNtErrorPrinterNotShareable 3022
#define kNtErrorRequestPaused 3050
#define kNtErrorAppexecConditionNotSatisfied 3060
#define kNtErrorAppexecHandleInvalidated 3061
#define kNtErrorAppexecInvalidHostGeneration 3062
#define kNtErrorAppexecUnexpectedProcessRegistration 3063
#define kNtErrorAppexecInvalidHostState 3064
#define kNtErrorAppexecNoDonor 3065
#define kNtErrorAppexecHostIdMismatch 3066
#define kNtErrorIoReissueAsCached 3950
#define kNtErrorWinsInternal 4000
#define kNtErrorCanNotDelLocalWins 4001
#define kNtErrorStaticInit 4002
#define kNtErrorIncBackup 4003
#define kNtErrorFullBackup 4004
#define kNtErrorRecNonExistent 4005
#define kNtErrorRplNotAllowed 4006
#define kNtErrorDhcpAddressConflict 4100
#define kNtErrorWmiGuidNotFound 4200
#define kNtErrorWmiInstanceNotFound 4201
#define kNtErrorWmiItemidNotFound 4202
#define kNtErrorWmiTryAgain 4203
#define kNtErrorWmiDpNotFound 4204
#define kNtErrorWmiUnresolvedInstanceRef 4205
#define kNtErrorWmiAlreadyEnabled 4206
#define kNtErrorWmiGuidDisconnected 4207
#define kNtErrorWmiServerUnavailable 4208
#define kNtErrorWmiDpFailed 4209
#define kNtErrorWmiInvalidMof 4210
#define kNtErrorWmiInvalidReginfo 4211
#define kNtErrorWmiAlreadyDisabled 4212
#define kNtErrorWmiReadOnly 4213
#define kNtErrorWmiSetFailure 4214
#define kNtErrorNotAppcontainer 4250
#define kNtErrorAppcontainerRequired 4251
#define kNtErrorNotSupportedInAppcontainer 4252
#define kNtErrorInvalidPackageSidLength 4253
#define kNtErrorInvalidMedia 4300
#define kNtErrorInvalidLibrary 4301
#define kNtErrorInvalidMediaPool 4302
#define kNtErrorDriveMediaMismatch 4303
#define kNtErrorMediaOffline 4304
#define kNtErrorLibraryOffline 4305
#define kNtErrorEmpty 4306 /* ENOMSG */
#define kNtErrorNotEmpty 4307
#define kNtErrorMediaUnavailable 4308
#define kNtErrorResourceDisabled 4309
#define kNtErrorInvalidCleaner 4310
#define kNtErrorUnableToClean 4311
#define kNtErrorObjectNotFound 4312
#define kNtErrorDatabaseFailure 4313
#define kNtErrorDatabaseFull 4314
#define kNtErrorMediaIncompatible 4315
#define kNtErrorResourceNotPresent 4316
#define kNtErrorInvalidOperation 4317
#define kNtErrorMediaNotAvailable 4318
#define kNtErrorDeviceNotAvailable 4319
#define kNtErrorRequestRefused 4320
#define kNtErrorInvalidDriveObject 4321
#define kNtErrorLibraryFull 4322
#define kNtErrorMediumNotAccessible 4323
#define kNtErrorUnableToLoadMedium 4324
#define kNtErrorUnableToInventoryDrive 4325
#define kNtErrorUnableToInventorySlot 4326
#define kNtErrorUnableToInventoryTransport 4327
#define kNtErrorTransportFull 4328
#define kNtErrorControllingIeport 4329
#define kNtErrorUnableToEjectMountedMedia 4330
#define kNtErrorCleanerSlotSet 4331
#define kNtErrorCleanerSlotNotSet 4332
#define kNtErrorCleanerCartridgeSpent 4333
#define kNtErrorUnexpectedOmid 4334
#define kNtErrorCantDeleteLastItem 4335
#define kNtErrorMessageExceedsMaxSize 4336
#define kNtErrorVolumeContainsSysFiles 4337
#define kNtErrorIndigenousType 4338
#define kNtErrorNoSupportingDrives 4339
#define kNtErrorCleanerCartridgeInstalled 4340
#define kNtErrorIeportFull 4341
#define kNtErrorFileOffline 4350
#define kNtErrorRemoteStorageNotActive 4351
#define kNtErrorRemoteStorageMediaError 4352
#define kNtErrorNotAReparsePoint 4390
#define kNtErrorReparseAttributeConflict 4391
#define kNtErrorInvalidReparseData 4392
#define kNtErrorReparseTagInvalid 4393
#define kNtErrorReparseTagMismatch 4394
#define kNtErrorReparsePointEncountered 4395
#define kNtErrorAppDataNotFound 4400
#define kNtErrorAppDataExpired 4401
#define kNtErrorAppDataCorrupt 4402
#define kNtErrorAppDataLimitExceeded 4403
#define kNtErrorAppDataRebootRequired 4404
#define kNtErrorSecurebootRollbackDetected 4420
#define kNtErrorSecurebootPolicyViolation 4421
#define kNtErrorSecurebootInvalidPolicy 4422
#define kNtErrorSecurebootPolicyPublisherNotFound 4423
#define kNtErrorSecurebootPolicyNotSigned 4424
#define kNtErrorSecurebootNotEnabled 4425
#define kNtErrorSecurebootFileReplaced 4426
#define kNtErrorSecurebootPolicyNotAuthorized 4427
#define kNtErrorSecurebootPolicyUnknown 4428
#define kNtErrorSecurebootPolicyMissingAntirollbackversion 4429
#define kNtErrorSecurebootPlatformIdMismatch 4430
#define kNtErrorSecurebootPolicyRollbackDetected 4431
#define kNtErrorSecurebootPolicyUpgradeMismatch 4432
#define kNtErrorSecurebootRequiredPolicyFileMissing 4433
#define kNtErrorSecurebootNotBasePolicy 4434
#define kNtErrorSecurebootNotSupplementalPolicy 4435
#define kNtErrorOffloadReadFltNotSupported 4440
#define kNtErrorOffloadWriteFltNotSupported 4441
#define kNtErrorOffloadReadFileNotSupported 4442
#define kNtErrorOffloadWriteFileNotSupported 4443
#define kNtErrorAlreadyHasStreamId 4444
#define kNtErrorSmrGarbageCollectionRequired 4445
#define kNtErrorWofWimHeaderCorrupt 4446
#define kNtErrorWofWimResourceTableCorrupt 4447
#define kNtErrorWofFileResourceTableCorrupt 4448
#define kNtErrorVolumeNotSisEnabled 4500
#define kNtErrorSystemIntegrityRollbackDetected 4550
#define kNtErrorSystemIntegrityPolicyViolation 4551
#define kNtErrorSystemIntegrityInvalidPolicy 4552
#define kNtErrorSystemIntegrityPolicyNotSigned 4553
#define kNtErrorVsmNotInitialized 4560
#define kNtErrorVsmDmaProtectionNotInUse 4561
#define kNtErrorPlatformManifestNotAuthorized 4570
#define kNtErrorPlatformManifestInvalid 4571
#define kNtErrorPlatformManifestFileNotAuthorized 4572
#define kNtErrorPlatformManifestCatalogNotAuthorized 4573
#define kNtErrorPlatformManifestBinaryIdNotFound 4574
#define kNtErrorPlatformManifestNotActive 4575
#define kNtErrorPlatformManifestNotSigned 4576
#define kNtErrorDependentResourceExists 5001
#define kNtErrorDependencyNotFound 5002
#define kNtErrorDependencyAlreadyExists 5003
#define kNtErrorResourceNotOnline 5004
#define kNtErrorHostNodeNotAvailable 5005
#define kNtErrorResourceNotAvailable 5006
#define kNtErrorResourceNotFound 5007
#define kNtErrorShutdownCluster 5008
#define kNtErrorCantEvictActiveNode 5009
#define kNtErrorObjectAlreadyExists 5010
#define kNtErrorObjectInList 5011
#define kNtErrorGroupNotAvailable 5012
#define kNtErrorGroupNotFound 5013
#define kNtErrorGroupNotOnline 5014
#define kNtErrorHostNodeNotResourceOwner 5015
#define kNtErrorHostNodeNotGroupOwner 5016
#define kNtErrorResmonCreateFailed 5017
#define kNtErrorResmonOnlineFailed 5018
#define kNtErrorResourceOnline 5019
#define kNtErrorQuorumResource 5020
#define kNtErrorNotQuorumCapable 5021
#define kNtErrorClusterShuttingDown 5022
#define kNtErrorInvalidState 5023
#define kNtErrorResourcePropertiesStored 5024
#define kNtErrorNotQuorumClass 5025
#define kNtErrorCoreResource 5026
#define kNtErrorQuorumResourceOnlineFailed 5027
#define kNtErrorQuorumlogOpenFailed 5028
#define kNtErrorClusterlogCorrupt 5029
#define kNtErrorClusterlogRecordExceedsMaxsize 5030
#define kNtErrorClusterlogExceedsMaxsize 5031
#define kNtErrorClusterlogChkpointNotFound 5032
#define kNtErrorClusterlogNotEnoughSpace 5033
#define kNtErrorQuorumOwnerAlive 5034
#define kNtErrorNetworkNotAvailable 5035
#define kNtErrorNodeNotAvailable 5036
#define kNtErrorAllNodesNotAvailable 5037
#define kNtErrorResourceFailed 5038
#define kNtErrorClusterInvalidNode 5039
#define kNtErrorClusterNodeExists 5040
#define kNtErrorClusterJoinInProgress 5041
#define kNtErrorClusterNodeNotFound 5042
#define kNtErrorClusterLocalNodeNotFound 5043
#define kNtErrorClusterNetworkExists 5044
#define kNtErrorClusterNetworkNotFound 5045
#define kNtErrorClusterNetinterfaceExists 5046
#define kNtErrorClusterNetinterfaceNotFound 5047
#define kNtErrorClusterInvalidRequest 5048
#define kNtErrorClusterInvalidNetworkProvider 5049
#define kNtErrorClusterNodeDown 5050
#define kNtErrorClusterNodeUnreachable 5051
#define kNtErrorClusterNodeNotMember 5052
#define kNtErrorClusterJoinNotInProgress 5053
#define kNtErrorClusterInvalidNetwork 5054
#define kNtErrorClusterNodeUp 5056
#define kNtErrorClusterIpaddrInUse 5057
#define kNtErrorClusterNodeNotPaused 5058
#define kNtErrorClusterNoSecurityContext 5059
#define kNtErrorClusterNetworkNotInternal 5060
#define kNtErrorClusterNodeAlreadyUp 5061
#define kNtErrorClusterNodeAlreadyDown 5062
#define kNtErrorClusterNetworkAlreadyOnline 5063
#define kNtErrorClusterNetworkAlreadyOffline 5064
#define kNtErrorClusterNodeAlreadyMember 5065
#define kNtErrorClusterLastInternalNetwork 5066
#define kNtErrorClusterNetworkHasDependents 5067
#define kNtErrorInvalidOperationOnQuorum 5068
#define kNtErrorDependencyNotAllowed 5069
#define kNtErrorClusterNodePaused 5070
#define kNtErrorNodeCantHostResource 5071
#define kNtErrorClusterNodeNotReady 5072
#define kNtErrorClusterNodeShuttingDown 5073
#define kNtErrorClusterJoinAborted 5074
#define kNtErrorClusterIncompatibleVersions 5075
#define kNtErrorClusterMaxnumOfResourcesExceeded 5076
#define kNtErrorClusterSystemConfigChanged 5077
#define kNtErrorClusterResourceTypeNotFound 5078
#define kNtErrorClusterRestypeNotSupported 5079
#define kNtErrorClusterResnameNotFound 5080
#define kNtErrorClusterNoRpcPackagesRegistered 5081
#define kNtErrorClusterOwnerNotInPreflist 5082
#define kNtErrorClusterDatabaseSeqmismatch 5083
#define kNtErrorResmonInvalidState 5084
#define kNtErrorClusterGumNotLocker 5085
#define kNtErrorQuorumDiskNotFound 5086
#define kNtErrorDatabaseBackupCorrupt 5087
#define kNtErrorClusterNodeAlreadyHasDfsRoot 5088
#define kNtErrorResourcePropertyUnchangeable 5089
#define kNtErrorNoAdminAccessPoint 5090
#define kNtErrorClusterMembershipInvalidState 5890
#define kNtErrorClusterQuorumlogNotFound 5891
#define kNtErrorClusterMembershipHalt 5892
#define kNtErrorClusterInstanceIdMismatch 5893
#define kNtErrorClusterNetworkNotFoundForIp 5894
#define kNtErrorClusterPropertyDataTypeMismatch 5895
#define kNtErrorClusterEvictWithoutCleanup 5896
#define kNtErrorClusterParameterMismatch 5897
#define kNtErrorNodeCannotBeClustered 5898
#define kNtErrorClusterWrongOsVersion 5899
#define kNtErrorClusterCantCreateDupClusterName 5900
#define kNtErrorCluscfgAlreadyCommitted 5901
#define kNtErrorCluscfgRollbackFailed 5902
#define kNtErrorCluscfgSystemDiskDriveLetterConflict 5903
#define kNtErrorClusterOldVersion 5904
#define kNtErrorClusterMismatchedComputerAcctName 5905
#define kNtErrorClusterNoNetAdapters 5906
#define kNtErrorClusterPoisoned 5907
#define kNtErrorClusterGroupMoving 5908
#define kNtErrorClusterResourceTypeBusy 5909
#define kNtErrorResourceCallTimedOut 5910
#define kNtErrorInvalidClusterIpv6Address 5911
#define kNtErrorClusterInternalInvalidFunction 5912
#define kNtErrorClusterParameterOutOfBounds 5913
#define kNtErrorClusterPartialSend 5914
#define kNtErrorClusterRegistryInvalidFunction 5915
#define kNtErrorClusterInvalidStringTermination 5916
#define kNtErrorClusterInvalidStringFormat 5917
#define kNtErrorClusterDatabaseTransactionInProgress 5918
#define kNtErrorClusterDatabaseTransactionNotInProgress 5919
#define kNtErrorClusterNullData 5920
#define kNtErrorClusterPartialRead 5921
#define kNtErrorClusterPartialWrite 5922
#define kNtErrorClusterCantDeserializeData 5923
#define kNtErrorDependentResourcePropertyConflict 5924
#define kNtErrorClusterNoQuorum 5925
#define kNtErrorClusterInvalidIpv6Network 5926
#define kNtErrorClusterInvalidIpv6TunnelNetwork 5927
#define kNtErrorQuorumNotAllowedInThisGroup 5928
#define kNtErrorDependencyTreeTooComplex 5929
#define kNtErrorExceptionInResourceCall 5930
#define kNtErrorClusterRhsFailedInitialization 5931
#define kNtErrorClusterNotInstalled 5932
#define kNtErrorClusterResourcesMustBeOnlineOnTheSameNode 5933
#define kNtErrorClusterMaxNodesInCluster 5934
#define kNtErrorClusterTooManyNodes 5935
#define kNtErrorClusterObjectAlreadyUsed 5936
#define kNtErrorNoncoreGroupsFound 5937
#define kNtErrorFileShareResourceConflict 5938
#define kNtErrorClusterEvictInvalidRequest 5939
#define kNtErrorClusterSingletonResource 5940
#define kNtErrorClusterGroupSingletonResource 5941
#define kNtErrorClusterResourceProviderFailed 5942
#define kNtErrorClusterResourceConfigurationError 5943
#define kNtErrorClusterGroupBusy 5944
#define kNtErrorClusterNotSharedVolume 5945
#define kNtErrorClusterInvalidSecurityDescriptor 5946
#define kNtErrorClusterSharedVolumesInUse 5947
#define kNtErrorClusterUseSharedVolumesApi 5948
#define kNtErrorClusterBackupInProgress 5949
#define kNtErrorNonCsvPath 5950
#define kNtErrorCsvVolumeNotLocal 5951
#define kNtErrorClusterWatchdogTerminating 5952
#define kNtErrorClusterResourceVetoedMoveIncompatibleNodes 5953
#define kNtErrorClusterInvalidNodeWeight 5954
#define kNtErrorClusterResourceVetoedCall 5955
#define kNtErrorResmonSystemResourcesLacking 5956
#define kNtErrorClusterResourceVetoedMoveNotEnoughResourcesOnSource 5958
#define kNtErrorClusterGroupQueued 5959
#define kNtErrorClusterResourceLockedStatus 5960
#define kNtErrorClusterSharedVolumeFailoverNotAllowed 5961
#define kNtErrorClusterNodeDrainInProgress 5962
#define kNtErrorClusterDiskNotConnected 5963
#define kNtErrorDiskNotCsvCapable 5964
#define kNtErrorResourceNotInAvailableStorage 5965
#define kNtErrorClusterSharedVolumeRedirected 5966
#define kNtErrorClusterSharedVolumeNotRedirected 5967
#define kNtErrorClusterCannotReturnProperties 5968
#define kNtErrorClusterResourceIsInMaintenanceMode 5970
#define kNtErrorClusterAffinityConflict 5971
#define kNtErrorClusterResourceIsReplicaVirtualMachine 5972
#define kNtErrorClusterUpgradeIncompatibleVersions 5973
#define kNtErrorClusterUpgradeFixQuorumNotSupported 5974
#define kNtErrorClusterUpgradeRestartRequired 5975
#define kNtErrorClusterUpgradeInProgress 5976
#define kNtErrorClusterUpgradeIncomplete 5977
#define kNtErrorClusterNodeInGracePeriod 5978
#define kNtErrorClusterCsvIoPauseTimeout 5979
#define kNtErrorNodeNotActiveClusterMember 5980
#define kNtErrorClusterResourceNotMonitored 5981
#define kNtErrorClusterResourceDoesNotSupportUnmonitored 5982
#define kNtErrorClusterResourceIsReplicated 5983
#define kNtErrorClusterNodeIsolated 5984
#define kNtErrorClusterNodeQuarantined 5985
#define kNtErrorClusterDatabaseUpdateConditionFailed 5986
#define kNtErrorClusterSpaceDegraded 5987
#define kNtErrorClusterTokenDelegationNotSupported 5988
#define kNtErrorClusterCsvInvalidHandle 5989
#define kNtErrorClusterCsvSupportedOnlyOnCoordinator 5990
#define kNtErrorGroupsetNotAvailable 5991
#define kNtErrorGroupsetNotFound 5992
#define kNtErrorGroupsetCantProvide 5993
#define kNtErrorClusterFaultDomainParentNotFound 5994
#define kNtErrorClusterFaultDomainInvalidHierarchy 5995
#define kNtErrorClusterFaultDomainFailedS2dValidation 5996
#define kNtErrorClusterFaultDomainS2dConnectivityLoss 5997
#define kNtErrorClusterInvalidInfrastructureFileserverName 5998
#define kNtErrorClustersetManagementClusterUnreachable 5999
#define kNtErrorEncryptionFailed 6000
#define kNtErrorDecryptionFailed 6001
#define kNtErrorFileEncrypted 6002
#define kNtErrorNoRecoveryPolicy 6003
#define kNtErrorNoEfs 6004
#define kNtErrorWrongEfs 6005
#define kNtErrorNoUserKeys 6006
#define kNtErrorFileNotEncrypted 6007
#define kNtErrorNotExportFormat 6008
#define kNtErrorFileReadOnly 6009 /* EROFS */
#define kNtErrorDirEfsDisallowed 6010
#define kNtErrorEfsServerNotTrusted 6011
#define kNtErrorBadRecoveryPolicy 6012
#define kNtErrorEfsAlgBlobTooBig 6013
#define kNtErrorVolumeNotSupportEfs 6014
#define kNtErrorEfsDisabled 6015
#define kNtErrorEfsVersionNotSupport 6016
#define kNtErrorCsEncryptionInvalidServerResponse 6017
#define kNtErrorCsEncryptionUnsupportedServer 6018
#define kNtErrorCsEncryptionExistingEncryptedFile 6019
#define kNtErrorCsEncryptionNewEncryptedFile 6020
#define kNtErrorCsEncryptionFileNotCse 6021
#define kNtErrorEncryptionPolicyDeniesOperation 6022
#define kNtErrorNoBrowserServersFound 6118
#define kNtErrorLogSectorInvalid 6600
#define kNtErrorLogSectorParityInvalid 6601
#define kNtErrorLogSectorRemapped 6602
#define kNtErrorLogBlockIncomplete 6603
#define kNtErrorLogInvalidRange 6604 /* ERANGE */
#define kNtErrorLogBlocksExhausted 6605
#define kNtErrorLogReadContextInvalid 6606
#define kNtErrorLogRestartInvalid 6607
#define kNtErrorLogBlockVersion 6608
#define kNtErrorLogBlockInvalid 6609
#define kNtErrorLogReadModeInvalid 6610
#define kNtErrorLogNoRestart 6611
#define kNtErrorLogMetadataCorrupt 6612
#define kNtErrorLogMetadataInvalid 6613
#define kNtErrorLogMetadataInconsistent 6614
#define kNtErrorLogReservationInvalid 6615
#define kNtErrorLogCantDelete 6616
#define kNtErrorLogContainerLimitExceeded 6617
#define kNtErrorLogStartOfLog 6618
#define kNtErrorLogPolicyAlreadyInstalled 6619
#define kNtErrorLogPolicyNotInstalled 6620
#define kNtErrorLogPolicyInvalid 6621
#define kNtErrorLogPolicyConflict 6622
#define kNtErrorLogPinnedArchiveTail 6623
#define kNtErrorLogRecordNonexistent 6624
#define kNtErrorLogRecordsReservedInvalid 6625
#define kNtErrorLogSpaceReservedInvalid 6626
#define kNtErrorLogTailInvalid 6627
#define kNtErrorLogFull 6628
#define kNtErrorCouldNotResizeLog 6629
#define kNtErrorLogMultiplexed 6630
#define kNtErrorLogDedicated 6631
#define kNtErrorLogArchiveNotInProgress 6632
#define kNtErrorLogArchiveInProgress 6633
#define kNtErrorLogEphemeral 6634
#define kNtErrorLogNotEnoughContainers 6635
#define kNtErrorLogClientAlreadyRegistered 6636
#define kNtErrorLogClientNotRegistered 6637
#define kNtErrorLogFullHandlerInProgress 6638
#define kNtErrorLogContainerReadFailed 6639
#define kNtErrorLogContainerWriteFailed 6640
#define kNtErrorLogContainerOpenFailed 6641
#define kNtErrorLogContainerStateInvalid 6642
#define kNtErrorLogStateInvalid 6643
#define kNtErrorLogPinned 6644
#define kNtErrorLogMetadataFlushFailed 6645
#define kNtErrorLogInconsistentSecurity 6646
#define kNtErrorLogAppendedFlushFailed 6647
#define kNtErrorLogPinnedReservation 6648
#define kNtErrorInvalidTransaction 6700
#define kNtErrorTransactionNotActive 6701
#define kNtErrorTransactionRequestNotValid 6702
#define kNtErrorTransactionNotRequested 6703
#define kNtErrorTransactionAlreadyAborted 6704
#define kNtErrorTransactionAlreadyCommitted 6705
#define kNtErrorTmInitializationFailed 6706
#define kNtErrorResourcemanagerReadOnly 6707
#define kNtErrorTransactionNotJoined 6708
#define kNtErrorTransactionSuperiorExists 6709
#define kNtErrorCrmProtocolAlreadyExists 6710
#define kNtErrorTransactionPropagationFailed 6711
#define kNtErrorCrmProtocolNotFound 6712
#define kNtErrorTransactionInvalidMarshallBuffer 6713
#define kNtErrorCurrentTransactionNotValid 6714
#define kNtErrorTransactionNotFound 6715
#define kNtErrorResourcemanagerNotFound 6716
#define kNtErrorEnlistmentNotFound 6717
#define kNtErrorTransactionmanagerNotFound 6718
#define kNtErrorTransactionmanagerNotOnline 6719
#define kNtErrorTransactionmanagerRecoveryNameCollision 6720
#define kNtErrorTransactionNotRoot 6721
#define kNtErrorTransactionObjectExpired 6722
#define kNtErrorTransactionResponseNotEnlisted 6723
#define kNtErrorTransactionRecordTooLong 6724
#define kNtErrorImplicitTransactionNotSupported 6725
#define kNtErrorTransactionIntegrityViolated 6726
#define kNtErrorTransactionmanagerIdentityMismatch 6727
#define kNtErrorRmCannotBeFrozenForSnapshot 6728
#define kNtErrorTransactionMustWritethrough 6729
#define kNtErrorTransactionNoSuperior 6730
#define kNtErrorHeuristicDamagePossible 6731
#define kNtErrorTransactionalConflict 6800
#define kNtErrorRmNotActive 6801
#define kNtErrorRmMetadataCorrupt 6802
#define kNtErrorDirectoryNotRm 6803
#define kNtErrorTransactionsUnsupportedRemote 6805
#define kNtErrorLogResizeInvalidSize 6806
#define kNtErrorObjectNoLongerExists 6807
#define kNtErrorStreamMiniversionNotFound 6808
#define kNtErrorStreamMiniversionNotValid 6809
#define kNtErrorMiniversionInaccessibleFromSpecifiedTransaction 6810
#define kNtErrorCantOpenMiniversionWithModifyIntent 6811
#define kNtErrorCantCreateMoreStreamMiniversions 6812
#define kNtErrorRemoteFileVersionMismatch 6814
#define kNtErrorHandleNoLongerValid 6815
#define kNtErrorNoTxfMetadata 6816
#define kNtErrorLogCorruptionDetected 6817
#define kNtErrorCantRecoverWithHandleOpen 6818
#define kNtErrorRmDisconnected 6819
#define kNtErrorEnlistmentNotSuperior 6820
#define kNtErrorRecoveryNotNeeded 6821
#define kNtErrorRmAlreadyStarted 6822
#define kNtErrorFileIdentityNotPersistent 6823
#define kNtErrorCantBreakTransactionalDependency 6824
#define kNtErrorCantCrossRmBoundary 6825
#define kNtErrorTxfDirNotEmpty 6826
#define kNtErrorIndoubtTransactionsExist 6827
#define kNtErrorTmVolatile 6828
#define kNtErrorRollbackTimerExpired 6829
#define kNtErrorTxfAttributeCorrupt 6830
#define kNtErrorEfsNotAllowedInTransaction 6831
#define kNtErrorTransactionalOpenNotAllowed 6832
#define kNtErrorLogGrowthFailed 6833
#define kNtErrorTransactedMappingUnsupportedRemote 6834
#define kNtErrorTxfMetadataAlreadyPresent 6835
#define kNtErrorTransactionScopeCallbacksNotSet 6836
#define kNtErrorTransactionRequiredPromotion 6837
#define kNtErrorCannotExecuteFileInTransaction 6838
#define kNtErrorTransactionsNotFrozen 6839
#define kNtErrorTransactionFreezeInProgress 6840
#define kNtErrorNotSnapshotVolume 6841
#define kNtErrorNoSavepointWithOpenFiles 6842
#define kNtErrorDataLostRepair 6843
#define kNtErrorSparseNotAllowedInTransaction 6844
#define kNtErrorTmIdentityMismatch 6845
#define kNtErrorFloatedSection 6846
#define kNtErrorCannotAcceptTransactedWork 6847
#define kNtErrorCannotAbortTransactions 6848
#define kNtErrorBadClusters 6849
#define kNtErrorCompressionNotAllowedInTransaction 6850
#define kNtErrorVolumeDirty 6851
#define kNtErrorNoLinkTrackingInTransaction 6852
#define kNtErrorOperationNotSupportedInTransaction 6853
#define kNtErrorExpiredHandle 6854
#define kNtErrorTransactionNotEnlisted 6855
#define kNtErrorCtxWinstationNameInvalid 7001
#define kNtErrorCtxInvalidPd 7002
#define kNtErrorCtxPdNotFound 7003
#define kNtErrorCtxWdNotFound 7004
#define kNtErrorCtxCannotMakeEventlogEntry 7005
#define kNtErrorCtxServiceNameCollision 7006
#define kNtErrorCtxClosePending 7007
#define kNtErrorCtxNoOutbuf 7008
#define kNtErrorCtxModemInfNotFound 7009
#define kNtErrorCtxInvalidModemname 7010
#define kNtErrorCtxModemResponseError 7011
#define kNtErrorCtxModemResponseTimeout 7012
#define kNtErrorCtxModemResponseNoCarrier 7013
#define kNtErrorCtxModemResponseNoDialtone 7014
#define kNtErrorCtxModemResponseBusy 7015
#define kNtErrorCtxModemResponseVoice 7016
#define kNtErrorCtxTdError 7017
#define kNtErrorCtxWinstationNotFound 7022
#define kNtErrorCtxWinstationAlreadyExists 7023
#define kNtErrorCtxWinstationBusy 7024
#define kNtErrorCtxBadVideoMode 7025
#define kNtErrorCtxGraphicsInvalid 7035
#define kNtErrorCtxLogonDisabled 7037
#define kNtErrorCtxNotConsole 7038
#define kNtErrorCtxClientQueryTimeout 7040
#define kNtErrorCtxConsoleDisconnect 7041
#define kNtErrorCtxConsoleConnect 7042
#define kNtErrorCtxShadowDenied 7044
#define kNtErrorCtxWinstationAccessDenied 7045
#define kNtErrorCtxInvalidWd 7049
#define kNtErrorCtxShadowInvalid 7050
#define kNtErrorCtxShadowDisabled 7051
#define kNtErrorCtxClientLicenseInUse 7052
#define kNtErrorCtxClientLicenseNotSet 7053
#define kNtErrorCtxLicenseNotAvailable 7054
#define kNtErrorCtxLicenseClientInvalid 7055
#define kNtErrorCtxLicenseExpired 7056
#define kNtErrorCtxShadowNotRunning 7057
#define kNtErrorCtxShadowEndedByModeChange 7058
#define kNtErrorActivationCountExceeded 7059
#define kNtErrorCtxWinstationsDisabled 7060
#define kNtErrorCtxEncryptionLevelRequired 7061
#define kNtErrorCtxSessionInUse 7062
#define kNtErrorCtxNoForceLogoff 7063
#define kNtErrorCtxAccountRestriction 7064
#define kNtErrorRdpProtocolError 7065 /* EPROTO */
#define kNtErrorCtxCdmConnect 7066
#define kNtErrorCtxCdmDisconnect 7067
#define kNtErrorCtxSecurityLayerError 7068
#define kNtErrorTsIncompatibleSessions 7069
#define kNtErrorTsVideoSubsystemError 7070
#define kNtErrorDsNotInstalled 8200
#define kNtErrorDsMembershipEvaluatedLocally 8201
#define kNtErrorDsNoAttributeOrValue 8202
#define kNtErrorDsInvalidAttributeSyntax 8203
#define kNtErrorDsAttributeTypeUndefined 8204
#define kNtErrorDsAttributeOrValueExists 8205
#define kNtErrorDsBusy 8206
#define kNtErrorDsUnavailable 8207
#define kNtErrorDsNoRidsAllocated 8208
#define kNtErrorDsNoMoreRids 8209
#define kNtErrorDsIncorrectRoleOwner 8210
#define kNtErrorDsRidmgrInitError 8211
#define kNtErrorDsObjClassViolation 8212
#define kNtErrorDsCantOnNonLeaf 8213
#define kNtErrorDsCantOnRdn 8214
#define kNtErrorDsCantModObjClass 8215
#define kNtErrorDsCrossDomMoveError 8216
#define kNtErrorDsGcNotAvailable 8217
#define kNtErrorSharedPolicy 8218
#define kNtErrorPolicyObjectNotFound 8219
#define kNtErrorPolicyOnlyInDs 8220
#define kNtErrorPromotionActive 8221
#define kNtErrorNoPromotionActive 8222
#define kNtErrorDsOperationsError 8224
#define kNtErrorDsProtocolError 8225
#define kNtErrorDsTimelimitExceeded 8226
#define kNtErrorDsSizelimitExceeded 8227
#define kNtErrorDsAdminLimitExceeded 8228
#define kNtErrorDsCompareFalse 8229
#define kNtErrorDsCompareTrue 8230
#define kNtErrorDsAuthMethodNotSupported 8231
#define kNtErrorDsStrongAuthRequired 8232
#define kNtErrorDsInappropriateAuth 8233
#define kNtErrorDsAuthUnknown 8234
#define kNtErrorDsReferral 8235
#define kNtErrorDsUnavailableCritExtension 8236
#define kNtErrorDsConfidentialityRequired 8237
#define kNtErrorDsInappropriateMatching 8238
#define kNtErrorDsConstraintViolation 8239
#define kNtErrorDsNoSuchObject 8240
#define kNtErrorDsAliasProblem 8241
#define kNtErrorDsInvalidDnSyntax 8242
#define kNtErrorDsIsLeaf 8243
#define kNtErrorDsAliasDerefProblem 8244
#define kNtErrorDsUnwillingToPerform 8245
#define kNtErrorDsLoopDetect 8246
#define kNtErrorDsNamingViolation 8247
#define kNtErrorDsObjectResultsTooLarge 8248
#define kNtErrorDsAffectsMultipleDsas 8249
#define kNtErrorDsServerDown 8250
#define kNtErrorDsLocalError 8251
#define kNtErrorDsEncodingError 8252
#define kNtErrorDsDecodingError 8253
#define kNtErrorDsFilterUnknown 8254
#define kNtErrorDsParamError 8255
#define kNtErrorDsNotSupported 8256
#define kNtErrorDsNoResultsReturned 8257
#define kNtErrorDsControlNotFound 8258
#define kNtErrorDsClientLoop 8259
#define kNtErrorDsReferralLimitExceeded 8260
#define kNtErrorDsSortControlMissing 8261
#define kNtErrorDsOffsetRangeError 8262
#define kNtErrorDsRidmgrDisabled 8263
#define kNtErrorDsRootMustBeNc 8301
#define kNtErrorDsAddReplicaInhibited 8302
#define kNtErrorDsAttNotDefInSchema 8303
#define kNtErrorDsMaxObjSizeExceeded 8304
#define kNtErrorDsObjStringNameExists 8305
#define kNtErrorDsNoRdnDefinedInSchema 8306
#define kNtErrorDsRdnDoesntMatchSchema 8307
#define kNtErrorDsNoRequestedAttsFound 8308
#define kNtErrorDsUserBufferToSmall 8309
#define kNtErrorDsAttIsNotOnObj 8310
#define kNtErrorDsIllegalModOperation 8311
#define kNtErrorDsObjTooLarge 8312
#define kNtErrorDsBadInstanceType 8313
#define kNtErrorDsMasterdsaRequired 8314
#define kNtErrorDsObjectClassRequired 8315
#define kNtErrorDsMissingRequiredAtt 8316
#define kNtErrorDsAttNotDefForClass 8317
#define kNtErrorDsAttAlreadyExists 8318
#define kNtErrorDsCantAddAttValues 8320
#define kNtErrorDsSingleValueConstraint 8321
#define kNtErrorDsRangeConstraint 8322
#define kNtErrorDsAttValAlreadyExists 8323
#define kNtErrorDsCantRemMissingAtt 8324
#define kNtErrorDsCantRemMissingAttVal 8325
#define kNtErrorDsRootCantBeSubref 8326
#define kNtErrorDsNoChaining 8327
#define kNtErrorDsNoChainedEval 8328
#define kNtErrorDsNoParentObject 8329
#define kNtErrorDsParentIsAnAlias 8330
#define kNtErrorDsCantMixMasterAndReps 8331
#define kNtErrorDsChildrenExist 8332
#define kNtErrorDsObjNotFound 8333
#define kNtErrorDsAliasedObjMissing 8334
#define kNtErrorDsBadNameSyntax 8335
#define kNtErrorDsAliasPointsToAlias 8336
#define kNtErrorDsCantDerefAlias 8337
#define kNtErrorDsOutOfScope 8338
#define kNtErrorDsObjectBeingRemoved 8339
#define kNtErrorDsCantDeleteDsaObj 8340
#define kNtErrorDsGenericError 8341
#define kNtErrorDsDsaMustBeIntMaster 8342
#define kNtErrorDsClassNotDsa 8343
#define kNtErrorDsInsuffAccessRights 8344
#define kNtErrorDsIllegalSuperior 8345
#define kNtErrorDsAttributeOwnedBySam 8346
#define kNtErrorDsNameTooManyParts 8347
#define kNtErrorDsNameTooLong 8348
#define kNtErrorDsNameValueTooLong 8349
#define kNtErrorDsNameUnparseable 8350
#define kNtErrorDsNameTypeUnknown 8351
#define kNtErrorDsNotAnObject 8352
#define kNtErrorDsSecDescTooShort 8353
#define kNtErrorDsSecDescInvalid 8354
#define kNtErrorDsNoDeletedName 8355
#define kNtErrorDsSubrefMustHaveParent 8356
#define kNtErrorDsNcnameMustBeNc 8357
#define kNtErrorDsCantAddSystemOnly 8358
#define kNtErrorDsClassMustBeConcrete 8359
#define kNtErrorDsInvalidDmd 8360
#define kNtErrorDsObjGuidExists 8361
#define kNtErrorDsNotOnBacklink 8362
#define kNtErrorDsNoCrossrefForNc 8363
#define kNtErrorDsShuttingDown 8364
#define kNtErrorDsUnknownOperation 8365
#define kNtErrorDsInvalidRoleOwner 8366
#define kNtErrorDsCouldntContactFsmo 8367
#define kNtErrorDsCrossNcDnRename 8368
#define kNtErrorDsCantModSystemOnly 8369
#define kNtErrorDsReplicatorOnly 8370
#define kNtErrorDsObjClassNotDefined 8371
#define kNtErrorDsObjClassNotSubclass 8372
#define kNtErrorDsNameReferenceInvalid 8373
#define kNtErrorDsCrossRefExists 8374
#define kNtErrorDsCantDelMasterCrossref 8375
#define kNtErrorDsSubtreeNotifyNotNcHead 8376
#define kNtErrorDsNotifyFilterTooComplex 8377
#define kNtErrorDsDupRdn 8378
#define kNtErrorDsDupOid 8379
#define kNtErrorDsDupMapiId 8380
#define kNtErrorDsDupSchemaIdGuid 8381
#define kNtErrorDsDupLdapDisplayName 8382
#define kNtErrorDsSemanticAttTest 8383
#define kNtErrorDsSyntaxMismatch 8384
#define kNtErrorDsExistsInMustHave 8385
#define kNtErrorDsExistsInMayHave 8386
#define kNtErrorDsNonexistentMayHave 8387
#define kNtErrorDsNonexistentMustHave 8388
#define kNtErrorDsAuxClsTestFail 8389
#define kNtErrorDsNonexistentPossSup 8390
#define kNtErrorDsSubClsTestFail 8391
#define kNtErrorDsBadRdnAttIdSyntax 8392
#define kNtErrorDsExistsInAuxCls 8393
#define kNtErrorDsExistsInSubCls 8394
#define kNtErrorDsExistsInPossSup 8395
#define kNtErrorDsRecalcschemaFailed 8396
#define kNtErrorDsTreeDeleteNotFinished 8397
#define kNtErrorDsCantDelete 8398
#define kNtErrorDsAttSchemaReqId 8399
#define kNtErrorDsBadAttSchemaSyntax 8400
#define kNtErrorDsCantCacheAtt 8401
#define kNtErrorDsCantCacheClass 8402
#define kNtErrorDsCantRemoveAttCache 8403
#define kNtErrorDsCantRemoveClassCache 8404
#define kNtErrorDsCantRetrieveDn 8405
#define kNtErrorDsMissingSupref 8406
#define kNtErrorDsCantRetrieveInstance 8407
#define kNtErrorDsCodeInconsistency 8408
#define kNtErrorDsDatabaseError 8409
#define kNtErrorDsGovernsidMissing 8410
#define kNtErrorDsMissingExpectedAtt 8411
#define kNtErrorDsNcnameMissingCrRef 8412
#define kNtErrorDsSecurityCheckingError 8413
#define kNtErrorDsSchemaNotLoaded 8414
#define kNtErrorDsSchemaAllocFailed 8415
#define kNtErrorDsAttSchemaReqSyntax 8416
#define kNtErrorDsGcverifyError 8417
#define kNtErrorDsDraSchemaMismatch 8418
#define kNtErrorDsCantFindDsaObj 8419
#define kNtErrorDsCantFindExpectedNc 8420
#define kNtErrorDsCantFindNcInCache 8421
#define kNtErrorDsCantRetrieveChild 8422
#define kNtErrorDsSecurityIllegalModify 8423
#define kNtErrorDsCantReplaceHiddenRec 8424
#define kNtErrorDsBadHierarchyFile 8425
#define kNtErrorDsBuildHierarchyTableFailed 8426
#define kNtErrorDsConfigParamMissing 8427
#define kNtErrorDsCountingAbIndicesFailed 8428
#define kNtErrorDsHierarchyTableMallocFailed 8429
#define kNtErrorDsInternalFailure 8430
#define kNtErrorDsUnknownError 8431
#define kNtErrorDsRootRequiresClassTop 8432
#define kNtErrorDsRefusingFsmoRoles 8433
#define kNtErrorDsMissingFsmoSettings 8434
#define kNtErrorDsUnableToSurrenderRoles 8435
#define kNtErrorDsDraGeneric 8436
#define kNtErrorDsDraInvalidParameter 8437
#define kNtErrorDsDraBusy 8438
#define kNtErrorDsDraBadDn 8439
#define kNtErrorDsDraBadNc 8440
#define kNtErrorDsDraDnExists 8441
#define kNtErrorDsDraInternalError 8442
#define kNtErrorDsDraInconsistentDit 8443
#define kNtErrorDsDraConnectionFailed 8444
#define kNtErrorDsDraBadInstanceType 8445
#define kNtErrorDsDraOutOfMem 8446
#define kNtErrorDsDraMailProblem 8447
#define kNtErrorDsDraRefAlreadyExists 8448
#define kNtErrorDsDraRefNotFound 8449
#define kNtErrorDsDraObjIsRepSource 8450
#define kNtErrorDsDraDbError 8451
#define kNtErrorDsDraNoReplica 8452
#define kNtErrorDsDraAccessDenied 8453
#define kNtErrorDsDraNotSupported 8454
#define kNtErrorDsDraRpcCancelled 8455
#define kNtErrorDsDraSourceDisabled 8456
#define kNtErrorDsDraSinkDisabled 8457
#define kNtErrorDsDraNameCollision 8458
#define kNtErrorDsDraSourceReinstalled 8459
#define kNtErrorDsDraMissingParent 8460
#define kNtErrorDsDraPreempted 8461
#define kNtErrorDsDraAbandonSync 8462
#define kNtErrorDsDraShutdown 8463
#define kNtErrorDsDraIncompatiblePartialSet 8464
#define kNtErrorDsDraSourceIsPartialReplica 8465
#define kNtErrorDsDraExtnConnectionFailed 8466
#define kNtErrorDsInstallSchemaMismatch 8467
#define kNtErrorDsDupLinkId 8468
#define kNtErrorDsNameErrorResolving 8469
#define kNtErrorDsNameErrorNotFound 8470
#define kNtErrorDsNameErrorNotUnique 8471
#define kNtErrorDsNameErrorNoMapping 8472
#define kNtErrorDsNameErrorDomainOnly 8473
#define kNtErrorDsNameErrorNoSyntacticalMapping 8474
#define kNtErrorDsConstructedAttMod 8475
#define kNtErrorDsWrongOmObjClass 8476
#define kNtErrorDsDraReplPending 8477
#define kNtErrorDsDsRequired 8478
#define kNtErrorDsInvalidLdapDisplayName 8479
#define kNtErrorDsNonBaseSearch 8480
#define kNtErrorDsCantRetrieveAtts 8481
#define kNtErrorDsBacklinkWithoutLink 8482
#define kNtErrorDsEpochMismatch 8483
#define kNtErrorDsSrcNameMismatch 8484
#define kNtErrorDsSrcAndDstNcIdentical 8485
#define kNtErrorDsDstNcMismatch 8486
#define kNtErrorDsNotAuthoritiveForDstNc 8487
#define kNtErrorDsSrcGuidMismatch 8488
#define kNtErrorDsCantMoveDeletedObject 8489
#define kNtErrorDsPdcOperationInProgress 8490
#define kNtErrorDsCrossDomainCleanupReqd 8491
#define kNtErrorDsIllegalXdomMoveOperation 8492
#define kNtErrorDsCantWithAcctGroupMembershps 8493
#define kNtErrorDsNcMustHaveNcParent 8494
#define kNtErrorDsCrImpossibleToValidate 8495
#define kNtErrorDsDstDomainNotNative 8496
#define kNtErrorDsMissingInfrastructureContainer 8497
#define kNtErrorDsCantMoveAccountGroup 8498
#define kNtErrorDsCantMoveResourceGroup 8499
#define kNtErrorDsInvalidSearchFlag 8500
#define kNtErrorDsNoTreeDeleteAboveNc 8501
#define kNtErrorDsCouldntLockTreeForDelete 8502
#define kNtErrorDsCouldntIdentifyObjectsForTreeDelete 8503
#define kNtErrorDsSamInitFailure 8504
#define kNtErrorDsSensitiveGroupViolation 8505
#define kNtErrorDsCantModPrimarygroupid 8506
#define kNtErrorDsIllegalBaseSchemaMod 8507
#define kNtErrorDsNonsafeSchemaChange 8508
#define kNtErrorDsSchemaUpdateDisallowed 8509
#define kNtErrorDsCantCreateUnderSchema 8510
#define kNtErrorDsInstallNoSrcSchVersion 8511
#define kNtErrorDsInstallNoSchVersionInInifile 8512
#define kNtErrorDsInvalidGroupType 8513
#define kNtErrorDsNoNestGlobalgroupInMixeddomain 8514
#define kNtErrorDsNoNestLocalgroupInMixeddomain 8515
#define kNtErrorDsGlobalCantHaveLocalMember 8516
#define kNtErrorDsGlobalCantHaveUniversalMember 8517
#define kNtErrorDsUniversalCantHaveLocalMember 8518
#define kNtErrorDsGlobalCantHaveCrossdomainMember 8519
#define kNtErrorDsLocalCantHaveCrossdomainLocalMember 8520
#define kNtErrorDsHavePrimaryMembers 8521
#define kNtErrorDsStringSdConversionFailed 8522
#define kNtErrorDsNamingMasterGc 8523
#define kNtErrorDsDnsLookupFailure 8524
#define kNtErrorDsCouldntUpdateSpns 8525
#define kNtErrorDsCantRetrieveSd 8526
#define kNtErrorDsKeyNotUnique 8527
#define kNtErrorDsWrongLinkedAttSyntax 8528
#define kNtErrorDsSamNeedBootkeyPassword 8529
#define kNtErrorDsSamNeedBootkeyFloppy 8530
#define kNtErrorDsCantStart 8531
#define kNtErrorDsInitFailure 8532
#define kNtErrorDsNoPktPrivacyOnConnection 8533
#define kNtErrorDsSourceDomainInForest 8534
#define kNtErrorDsDestinationDomainNotInForest 8535
#define kNtErrorDsDestinationAuditingNotEnabled 8536
#define kNtErrorDsCantFindDcForSrcDomain 8537
#define kNtErrorDsSrcObjNotGroupOrUser 8538
#define kNtErrorDsSrcSidExistsInForest 8539
#define kNtErrorDsSrcAndDstObjectClassMismatch 8540
#define kNtErrorSamInitFailure 8541
#define kNtErrorDsDraSchemaInfoShip 8542
#define kNtErrorDsDraSchemaConflict 8543
#define kNtErrorDsDraEarlierSchemaConflict 8544
#define kNtErrorDsDraObjNcMismatch 8545
#define kNtErrorDsNcStillHasDsas 8546
#define kNtErrorDsGcRequired 8547
#define kNtErrorDsLocalMemberOfLocalOnly 8548
#define kNtErrorDsNoFpoInUniversalGroups 8549
#define kNtErrorDsCantAddToGc 8550
#define kNtErrorDsNoCheckpointWithPdc 8551
#define kNtErrorDsSourceAuditingNotEnabled 8552
#define kNtErrorDsCantCreateInNondomainNc 8553
#define kNtErrorDsInvalidNameForSpn 8554
#define kNtErrorDsFilterUsesContructedAttrs 8555
#define kNtErrorDsUnicodepwdNotInQuotes 8556
#define kNtErrorDsMachineAccountQuotaExceeded 8557
#define kNtErrorDsMustBeRunOnDstDc 8558
#define kNtErrorDsSrcDcMustBeSp4OrGreater 8559
#define kNtErrorDsCantTreeDeleteCriticalObj 8560
#define kNtErrorDsInitFailureConsole 8561
#define kNtErrorDsSamInitFailureConsole 8562
#define kNtErrorDsForestVersionTooHigh 8563
#define kNtErrorDsDomainVersionTooHigh 8564
#define kNtErrorDsForestVersionTooLow 8565
#define kNtErrorDsDomainVersionTooLow 8566
#define kNtErrorDsIncompatibleVersion 8567
#define kNtErrorDsLowDsaVersion 8568
#define kNtErrorDsNoBehaviorVersionInMixeddomain 8569
#define kNtErrorDsNotSupportedSortOrder 8570
#define kNtErrorDsNameNotUnique 8571
#define kNtErrorDsMachineAccountCreatedPrent4 8572
#define kNtErrorDsOutOfVersionStore 8573
#define kNtErrorDsIncompatibleControlsUsed 8574
#define kNtErrorDsNoRefDomain 8575
#define kNtErrorDsReservedLinkId 8576
#define kNtErrorDsLinkIdNotAvailable 8577
#define kNtErrorDsAgCantHaveUniversalMember 8578
#define kNtErrorDsModifydnDisallowedByInstanceType 8579
#define kNtErrorDsNoObjectMoveInSchemaNc 8580
#define kNtErrorDsModifydnDisallowedByFlag 8581
#define kNtErrorDsModifydnWrongGrandparent 8582
#define kNtErrorDsNameErrorTrustReferral 8583
#define kNtErrorNotSupportedOnStandardServer 8584
#define kNtErrorDsCantAccessRemotePartOfAd 8585
#define kNtErrorDsCrImpossibleToValidateV2 8586
#define kNtErrorDsThreadLimitExceeded 8587
#define kNtErrorDsNotClosest 8588
#define kNtErrorDsCantDeriveSpnWithoutServerRef 8589
#define kNtErrorDsSingleUserModeFailed 8590
#define kNtErrorDsNtdscriptSyntaxError 8591
#define kNtErrorDsNtdscriptProcessError 8592
#define kNtErrorDsDifferentReplEpochs 8593
#define kNtErrorDsDrsExtensionsChanged 8594
#define kNtErrorDsReplicaSetChangeNotAllowedOnDisabledCr 8595
#define kNtErrorDsNoMsdsIntid 8596
#define kNtErrorDsDupMsdsIntid 8597
#define kNtErrorDsExistsInRdnattid 8598
#define kNtErrorDsAuthorizationFailed 8599
#define kNtErrorDsInvalidScript 8600
#define kNtErrorDsRemoteCrossrefOpFailed 8601
#define kNtErrorDsCrossRefBusy 8602
#define kNtErrorDsCantDeriveSpnForDeletedDomain 8603
#define kNtErrorDsCantDemoteWithWriteableNc 8604
#define kNtErrorDsDuplicateIdFound 8605
#define kNtErrorDsInsufficientAttrToCreateObject 8606
#define kNtErrorDsGroupConversionError 8607
#define kNtErrorDsCantMoveAppBasicGroup 8608
#define kNtErrorDsCantMoveAppQueryGroup 8609
#define kNtErrorDsRoleNotVerified 8610
#define kNtErrorDsWkoContainerCannotBeSpecial 8611
#define kNtErrorDsDomainRenameInProgress 8612
#define kNtErrorDsExistingAdChildNc 8613
#define kNtErrorDsReplLifetimeExceeded 8614
#define kNtErrorDsDisallowedInSystemContainer 8615
#define kNtErrorDsLdapSendQueueFull 8616
#define kNtErrorDsDraOutScheduleWindow 8617
#define kNtErrorDsPolicyNotKnown 8618
#define kNtErrorNoSiteSettingsObject 8619
#define kNtErrorNoSecrets 8620
#define kNtErrorNoWritableDcFound 8621
#define kNtErrorDsNoServerObject 8622
#define kNtErrorDsNoNtdsaObject 8623
#define kNtErrorDsNonAsqSearch 8624
#define kNtErrorDsAuditFailure 8625
#define kNtErrorDsInvalidSearchFlagSubtree 8626
#define kNtErrorDsInvalidSearchFlagTuple 8627
#define kNtErrorDsHierarchyTableTooDeep 8628
#define kNtErrorDsDraCorruptUtdVector 8629
#define kNtErrorDsDraSecretsDenied 8630
#define kNtErrorDsReservedMapiId 8631
#define kNtErrorDsMapiIdNotAvailable 8632
#define kNtErrorDsDraMissingKrbtgtSecret 8633
#define kNtErrorDsDomainNameExistsInForest 8634
#define kNtErrorDsFlatNameExistsInForest 8635
#define kNtErrorInvalidUserPrincipalName 8636
#define kNtErrorDsOidMappedGroupCantHaveMembers 8637
#define kNtErrorDsOidNotFound 8638
#define kNtErrorDsDraRecycledTarget 8639
#define kNtErrorDsDisallowedNcRedirect 8640
#define kNtErrorDsHighAdldsFfl 8641
#define kNtErrorDsHighDsaVersion 8642
#define kNtErrorDsLowAdldsFfl 8643
#define kNtErrorDomainSidSameAsLocalWorkstation 8644
#define kNtErrorDsUndeleteSamValidationFailed 8645
#define kNtErrorIncorrectAccountType 8646
#define kNtErrorDsSpnValueNotUniqueInForest 8647
#define kNtErrorDsUpnValueNotUniqueInForest 8648
#define kNtErrorDsMissingForestTrust 8649
#define kNtErrorDsValueKeyNotUnique 8650
#define kNtErrorIpsecQmPolicyExists 13000
#define kNtErrorIpsecQmPolicyNotFound 13001
#define kNtErrorIpsecQmPolicyInUse 13002
#define kNtErrorIpsecMmPolicyExists 13003
#define kNtErrorIpsecMmPolicyNotFound 13004
#define kNtErrorIpsecMmPolicyInUse 13005
#define kNtErrorIpsecMmFilterExists 13006
#define kNtErrorIpsecMmFilterNotFound 13007
#define kNtErrorIpsecTransportFilterExists 13008
#define kNtErrorIpsecTransportFilterNotFound 13009
#define kNtErrorIpsecMmAuthExists 13010
#define kNtErrorIpsecMmAuthNotFound 13011
#define kNtErrorIpsecMmAuthInUse 13012
#define kNtErrorIpsecDefaultMmPolicyNotFound 13013
#define kNtErrorIpsecDefaultMmAuthNotFound 13014
#define kNtErrorIpsecDefaultQmPolicyNotFound 13015
#define kNtErrorIpsecTunnelFilterExists 13016
#define kNtErrorIpsecTunnelFilterNotFound 13017
#define kNtErrorIpsecMmFilterPendingDeletion 13018
#define kNtErrorIpsecTransportFilterPendingDeletion 13019
#define kNtErrorIpsecTunnelFilterPendingDeletion 13020
#define kNtErrorIpsecMmPolicyPendingDeletion 13021
#define kNtErrorIpsecMmAuthPendingDeletion 13022
#define kNtErrorIpsecQmPolicyPendingDeletion 13023
#define kNtErrorIpsecIkeNegStatusBegin 13800
#define kNtErrorIpsecIkeAuthFail 13801
#define kNtErrorIpsecIkeAttribFail 13802
#define kNtErrorIpsecIkeNegotiationPending 13803
#define kNtErrorIpsecIkeGeneralProcessingError 13804
#define kNtErrorIpsecIkeTimedOut 13805
#define kNtErrorIpsecIkeNoCert 13806
#define kNtErrorIpsecIkeSaDeleted 13807
#define kNtErrorIpsecIkeSaReaped 13808
#define kNtErrorIpsecIkeMmAcquireDrop 13809
#define kNtErrorIpsecIkeQmAcquireDrop 13810
#define kNtErrorIpsecIkeQueueDropMm 13811
#define kNtErrorIpsecIkeQueueDropNoMm 13812
#define kNtErrorIpsecIkeDropNoResponse 13813
#define kNtErrorIpsecIkeMmDelayDrop 13814
#define kNtErrorIpsecIkeQmDelayDrop 13815
#define kNtErrorIpsecIkeError 13816
#define kNtErrorIpsecIkeCrlFailed 13817
#define kNtErrorIpsecIkeInvalidKeyUsage 13818
#define kNtErrorIpsecIkeInvalidCertType 13819
#define kNtErrorIpsecIkeNoPrivateKey 13820
#define kNtErrorIpsecIkeSimultaneousRekey 13821
#define kNtErrorIpsecIkeDhFail 13822
#define kNtErrorIpsecIkeCriticalPayloadNotRecognized 13823
#define kNtErrorIpsecIkeInvalidHeader 13824
#define kNtErrorIpsecIkeNoPolicy 13825
#define kNtErrorIpsecIkeInvalidSignature 13826
#define kNtErrorIpsecIkeKerberosError 13827
#define kNtErrorIpsecIkeNoPublicKey 13828
#define kNtErrorIpsecIkeProcessErr 13829
#define kNtErrorIpsecIkeProcessErrSa 13830
#define kNtErrorIpsecIkeProcessErrProp 13831
#define kNtErrorIpsecIkeProcessErrTrans 13832
#define kNtErrorIpsecIkeProcessErrKe 13833
#define kNtErrorIpsecIkeProcessErrId 13834
#define kNtErrorIpsecIkeProcessErrCert 13835
#define kNtErrorIpsecIkeProcessErrCertReq 13836
#define kNtErrorIpsecIkeProcessErrHash 13837
#define kNtErrorIpsecIkeProcessErrSig 13838
#define kNtErrorIpsecIkeProcessErrNonce 13839
#define kNtErrorIpsecIkeProcessErrNotify 13840
#define kNtErrorIpsecIkeProcessErrDelete 13841
#define kNtErrorIpsecIkeProcessErrVendor 13842
#define kNtErrorIpsecIkeInvalidPayload 13843
#define kNtErrorIpsecIkeLoadSoftSa 13844
#define kNtErrorIpsecIkeSoftSaTornDown 13845
#define kNtErrorIpsecIkeInvalidCookie 13846
#define kNtErrorIpsecIkeNoPeerCert 13847
#define kNtErrorIpsecIkePeerCrlFailed 13848
#define kNtErrorIpsecIkePolicyChange 13849
#define kNtErrorIpsecIkeNoMmPolicy 13850
#define kNtErrorIpsecIkeNotcbpriv 13851
#define kNtErrorIpsecIkeSecloadfail 13852
#define kNtErrorIpsecIkeFailsspinit 13853
#define kNtErrorIpsecIkeFailqueryssp 13854
#define kNtErrorIpsecIkeSrvacqfail 13855
#define kNtErrorIpsecIkeSrvquerycred 13856
#define kNtErrorIpsecIkeGetspifail 13857
#define kNtErrorIpsecIkeInvalidFilter 13858
#define kNtErrorIpsecIkeOutOfMemory 13859
#define kNtErrorIpsecIkeAddUpdateKeyFailed 13860
#define kNtErrorIpsecIkeInvalidPolicy 13861
#define kNtErrorIpsecIkeUnknownDoi 13862
#define kNtErrorIpsecIkeInvalidSituation 13863
#define kNtErrorIpsecIkeDhFailure 13864
#define kNtErrorIpsecIkeInvalidGroup 13865
#define kNtErrorIpsecIkeEncrypt 13866
#define kNtErrorIpsecIkeDecrypt 13867
#define kNtErrorIpsecIkePolicyMatch 13868
#define kNtErrorIpsecIkeUnsupportedId 13869
#define kNtErrorIpsecIkeInvalidHash 13870
#define kNtErrorIpsecIkeInvalidHashAlg 13871
#define kNtErrorIpsecIkeInvalidHashSize 13872
#define kNtErrorIpsecIkeInvalidEncryptAlg 13873
#define kNtErrorIpsecIkeInvalidAuthAlg 13874
#define kNtErrorIpsecIkeInvalidSig 13875
#define kNtErrorIpsecIkeLoadFailed 13876
#define kNtErrorIpsecIkeRpcDelete 13877
#define kNtErrorIpsecIkeBenignReinit 13878
#define kNtErrorIpsecIkeInvalidResponderLifetimeNotify 13879
#define kNtErrorIpsecIkeInvalidMajorVersion 13880
#define kNtErrorIpsecIkeInvalidCertKeylen 13881
#define kNtErrorIpsecIkeMmLimit 13882
#define kNtErrorIpsecIkeNegotiationDisabled 13883
#define kNtErrorIpsecIkeQmLimit 13884
#define kNtErrorIpsecIkeMmExpired 13885
#define kNtErrorIpsecIkePeerMmAssumedInvalid 13886
#define kNtErrorIpsecIkeCertChainPolicyMismatch 13887
#define kNtErrorIpsecIkeUnexpectedMessageId 13888
#define kNtErrorIpsecIkeInvalidAuthPayload 13889
#define kNtErrorIpsecIkeDosCookieSent 13890
#define kNtErrorIpsecIkeShuttingDown 13891
#define kNtErrorIpsecIkeCgaAuthFailed 13892
#define kNtErrorIpsecIkeProcessErrNatoa 13893
#define kNtErrorIpsecIkeInvalidMmForQm 13894
#define kNtErrorIpsecIkeQmExpired 13895
#define kNtErrorIpsecIkeTooManyFilters 13896
#define kNtErrorIpsecIkeNegStatusEnd 13897
#define kNtErrorIpsecIkeKillDummyNapTunnel 13898
#define kNtErrorIpsecIkeInnerIpAssignmentFailure 13899
#define kNtErrorIpsecIkeRequireCpPayloadMissing 13900
#define kNtErrorIpsecKeyModuleImpersonationNegotiationPending 13901
#define kNtErrorIpsecIkeCoexistenceSuppress 13902
#define kNtErrorIpsecIkeRatelimitDrop 13903
#define kNtErrorIpsecIkePeerDoesntSupportMobike 13904
#define kNtErrorIpsecIkeAuthorizationFailure 13905
#define kNtErrorIpsecIkeStrongCredAuthorizationFailure 13906
#define kNtErrorIpsecIkeAuthorizationFailureWithOptionalRetry 13907
#define kNtErrorIpsecIkeStrongCredAuthorizationAndCertmapFailure 13908
#define kNtErrorIpsecIkeNegStatusExtendedEnd 13909
#define kNtErrorIpsecBadSpi 13910
#define kNtErrorIpsecSaLifetimeExpired 13911
#define kNtErrorIpsecWrongSa 13912
#define kNtErrorIpsecReplayCheckFailed 13913
#define kNtErrorIpsecInvalidPacket 13914
#define kNtErrorIpsecIntegrityCheckFailed 13915
#define kNtErrorIpsecClearTextDrop 13916
#define kNtErrorIpsecAuthFirewallDrop 13917
#define kNtErrorIpsecThrottleDrop 13918
#define kNtErrorIpsecDospBlock 13925
#define kNtErrorIpsecDospReceivedMulticast 13926
#define kNtErrorIpsecDospInvalidPacket 13927
#define kNtErrorIpsecDospStateLookupFailed 13928
#define kNtErrorIpsecDospMaxEntries 13929
#define kNtErrorIpsecDospKeymodNotAllowed 13930
#define kNtErrorIpsecDospNotInstalled 13931
#define kNtErrorIpsecDospMaxPerIpRatelimitQueues 13932
#define kNtErrorSxsSectionNotFound 14000
#define kNtErrorSxsCantGenActctx 14001
#define kNtErrorSxsInvalidActctxdataFormat 14002
#define kNtErrorSxsAssemblyNotFound 14003
#define kNtErrorSxsManifestFormatError 14004
#define kNtErrorSxsManifestParseError 14005
#define kNtErrorSxsActivationContextDisabled 14006
#define kNtErrorSxsKeyNotFound 14007
#define kNtErrorSxsVersionConflict 14008
#define kNtErrorSxsWrongSectionType 14009
#define kNtErrorSxsThreadQueriesDisabled 14010
#define kNtErrorSxsProcessDefaultAlreadySet 14011
#define kNtErrorSxsUnknownEncodingGroup 14012
#define kNtErrorSxsUnknownEncoding 14013
#define kNtErrorSxsInvalidXmlNamespaceUri 14014
#define kNtErrorSxsRootManifestDependencyNotInstalled 14015
#define kNtErrorSxsLeafManifestDependencyNotInstalled 14016
#define kNtErrorSxsInvalidAssemblyIdentityAttribute 14017
#define kNtErrorSxsManifestMissingRequiredDefaultNamespace 14018
#define kNtErrorSxsManifestInvalidRequiredDefaultNamespace 14019
#define kNtErrorSxsPrivateManifestCrossPathWithReparsePoint 14020
#define kNtErrorSxsDuplicateDllName 14021
#define kNtErrorSxsDuplicateWindowclassName 14022
#define kNtErrorSxsDuplicateClsid 14023
#define kNtErrorSxsDuplicateIid 14024
#define kNtErrorSxsDuplicateTlbid 14025
#define kNtErrorSxsDuplicateProgid 14026
#define kNtErrorSxsDuplicateAssemblyName 14027
#define kNtErrorSxsFileHashMismatch 14028
#define kNtErrorSxsPolicyParseError 14029
#define kNtErrorSxsXmlEMissingquote 14030
#define kNtErrorSxsXmlECommentsyntax 14031
#define kNtErrorSxsXmlEBadstartnamechar 14032
#define kNtErrorSxsXmlEBadnamechar 14033
#define kNtErrorSxsXmlEBadcharinstring 14034
#define kNtErrorSxsXmlEXmldeclsyntax 14035
#define kNtErrorSxsXmlEBadchardata 14036
#define kNtErrorSxsXmlEMissingwhitespace 14037
#define kNtErrorSxsXmlEExpectingtagend 14038
#define kNtErrorSxsXmlEMissingsemicolon 14039
#define kNtErrorSxsXmlEUnbalancedparen 14040
#define kNtErrorSxsXmlEInternalerror 14041
#define kNtErrorSxsXmlEUnexpectedWhitespace 14042
#define kNtErrorSxsXmlEIncompleteEncoding 14043
#define kNtErrorSxsXmlEMissingParen 14044
#define kNtErrorSxsXmlEExpectingclosequote 14045
#define kNtErrorSxsXmlEMultipleColons 14046
#define kNtErrorSxsXmlEInvalidDecimal 14047
#define kNtErrorSxsXmlEInvalidHexidecimal 14048
#define kNtErrorSxsXmlEInvalidUnicode 14049
#define kNtErrorSxsXmlEWhitespaceorquestionmark 14050
#define kNtErrorSxsXmlEUnexpectedendtag 14051
#define kNtErrorSxsXmlEUnclosedtag 14052
#define kNtErrorSxsXmlEDuplicateattribute 14053
#define kNtErrorSxsXmlEMultipleroots 14054
#define kNtErrorSxsXmlEInvalidatrootlevel 14055
#define kNtErrorSxsXmlEBadxmldecl 14056
#define kNtErrorSxsXmlEMissingroot 14057
#define kNtErrorSxsXmlEUnexpectedeof 14058
#define kNtErrorSxsXmlEBadperefinsubset 14059
#define kNtErrorSxsXmlEUnclosedstarttag 14060
#define kNtErrorSxsXmlEUnclosedendtag 14061
#define kNtErrorSxsXmlEUnclosedstring 14062
#define kNtErrorSxsXmlEUnclosedcomment 14063
#define kNtErrorSxsXmlEUncloseddecl 14064
#define kNtErrorSxsXmlEUnclosedcdata 14065
#define kNtErrorSxsXmlEReservednamespace 14066
#define kNtErrorSxsXmlEInvalidencoding 14067
#define kNtErrorSxsXmlEInvalidswitch 14068
#define kNtErrorSxsXmlEBadxmlcase 14069
#define kNtErrorSxsXmlEInvalidStandalone 14070
#define kNtErrorSxsXmlEUnexpectedStandalone 14071
#define kNtErrorSxsXmlEInvalidVersion 14072
#define kNtErrorSxsXmlEMissingequals 14073
#define kNtErrorSxsProtectionRecoveryFailed 14074
#define kNtErrorSxsProtectionPublicKeyTooShort 14075
#define kNtErrorSxsProtectionCatalogNotValid 14076
#define kNtErrorSxsUntranslatableHresult 14077
#define kNtErrorSxsProtectionCatalogFileMissing 14078
#define kNtErrorSxsMissingAssemblyIdentityAttribute 14079
#define kNtErrorSxsInvalidAssemblyIdentityAttributeName 14080
#define kNtErrorSxsAssemblyMissing 14081
#define kNtErrorSxsCorruptActivationStack 14082
#define kNtErrorSxsCorruption 14083
#define kNtErrorSxsEarlyDeactivation 14084
#define kNtErrorSxsInvalidDeactivation 14085
#define kNtErrorSxsMultipleDeactivation 14086
#define kNtErrorSxsProcessTerminationRequested 14087
#define kNtErrorSxsReleaseActivationContext 14088
#define kNtErrorSxsSystemDefaultActivationContextEmpty 14089
#define kNtErrorSxsInvalidIdentityAttributeValue 14090
#define kNtErrorSxsInvalidIdentityAttributeName 14091
#define kNtErrorSxsIdentityDuplicateAttribute 14092
#define kNtErrorSxsIdentityParseError 14093
#define kNtErrorMalformedSubstitutionString 14094
#define kNtErrorSxsIncorrectPublicKeyToken 14095
#define kNtErrorUnmappedSubstitutionString 14096
#define kNtErrorSxsAssemblyNotLocked 14097
#define kNtErrorSxsComponentStoreCorrupt 14098
#define kNtErrorAdvancedInstallerFailed 14099
#define kNtErrorXmlEncodingMismatch 14100
#define kNtErrorSxsManifestIdentitySameButContentsDifferent 14101
#define kNtErrorSxsIdentitiesDifferent 14102
#define kNtErrorSxsAssemblyIsNotADeployment 14103
#define kNtErrorSxsFileNotPartOfAssembly 14104
#define kNtErrorSxsManifestTooBig 14105
#define kNtErrorSxsSettingNotRegistered 14106
#define kNtErrorSxsTransactionClosureIncomplete 14107
#define kNtErrorSmiPrimitiveInstallerFailed 14108
#define kNtErrorGenericCommandFailed 14109
#define kNtErrorSxsFileHashMissing 14110
#define kNtErrorEvtInvalidChannelPath 15000
#define kNtErrorEvtInvalidQuery 15001
#define kNtErrorEvtPublisherMetadataNotFound 15002
#define kNtErrorEvtEventTemplateNotFound 15003
#define kNtErrorEvtInvalidPublisherName 15004
#define kNtErrorEvtInvalidEventData 15005
#define kNtErrorEvtChannelNotFound 15007
#define kNtErrorEvtMalformedXmlText 15008
#define kNtErrorEvtSubscriptionToDirectChannel 15009
#define kNtErrorEvtConfigurationError 15010
#define kNtErrorEvtQueryResultStale 15011
#define kNtErrorEvtQueryResultInvalidPosition 15012
#define kNtErrorEvtNonValidatingMsxml 15013
#define kNtErrorEvtFilterAlreadyscoped 15014
#define kNtErrorEvtFilterNoteltset 15015
#define kNtErrorEvtFilterInvarg 15016
#define kNtErrorEvtFilterInvtest 15017
#define kNtErrorEvtFilterInvtype 15018
#define kNtErrorEvtFilterParseerr 15019
#define kNtErrorEvtFilterUnsupportedop 15020
#define kNtErrorEvtFilterUnexpectedtoken 15021
#define kNtErrorEvtInvalidOperationOverEnabledDirectChannel 15022
#define kNtErrorEvtInvalidChannelPropertyValue 15023
#define kNtErrorEvtInvalidPublisherPropertyValue 15024
#define kNtErrorEvtChannelCannotActivate 15025
#define kNtErrorEvtFilterTooComplex 15026
#define kNtErrorEvtMessageNotFound 15027
#define kNtErrorEvtMessageIdNotFound 15028
#define kNtErrorEvtUnresolvedValueInsert 15029
#define kNtErrorEvtUnresolvedParameterInsert 15030
#define kNtErrorEvtMaxInsertsReached 15031
#define kNtErrorEvtEventDefinitionNotFound 15032
#define kNtErrorEvtMessageLocaleNotFound 15033
#define kNtErrorEvtVersionTooOld 15034
#define kNtErrorEvtVersionTooNew 15035
#define kNtErrorEvtCannotOpenChannelOfQuery 15036
#define kNtErrorEvtPublisherDisabled 15037
#define kNtErrorEvtFilterOutOfRange 15038
#define kNtErrorEcSubscriptionCannotActivate 15080
#define kNtErrorEcLogDisabled 15081
#define kNtErrorEcCircularForwarding 15082
#define kNtErrorEcCredstoreFull 15083
#define kNtErrorEcCredNotFound 15084
#define kNtErrorEcNoActiveChannel 15085
#define kNtErrorMuiFileNotFound 15100
#define kNtErrorMuiInvalidFile 15101
#define kNtErrorMuiInvalidRcConfig 15102
#define kNtErrorMuiInvalidLocaleName 15103
#define kNtErrorMuiInvalidUltimatefallbackName 15104
#define kNtErrorMuiFileNotLoaded 15105
#define kNtErrorResourceEnumUserStop 15106
#define kNtErrorMuiIntlsettingsUilangNotInstalled 15107
#define kNtErrorMuiIntlsettingsInvalidLocaleName 15108
#define kNtErrorMrmRuntimeNoDefaultOrNeutralResource 15110
#define kNtErrorMrmInvalidPriconfig 15111
#define kNtErrorMrmInvalidFileType 15112
#define kNtErrorMrmUnknownQualifier 15113
#define kNtErrorMrmInvalidQualifierValue 15114
#define kNtErrorMrmNoCandidate 15115
#define kNtErrorMrmNoMatchOrDefaultCandidate 15116
#define kNtErrorMrmResourceTypeMismatch 15117
#define kNtErrorMrmDuplicateMapName 15118
#define kNtErrorMrmDuplicateEntry 15119
#define kNtErrorMrmInvalidResourceIdentifier 15120
#define kNtErrorMrmFilepathTooLong 15121
#define kNtErrorMrmUnsupportedDirectoryType 15122
#define kNtErrorMrmInvalidPriFile 15126
#define kNtErrorMrmNamedResourceNotFound 15127
#define kNtErrorMrmMapNotFound 15135
#define kNtErrorMrmUnsupportedProfileType 15136
#define kNtErrorMrmInvalidQualifierOperator 15137
#define kNtErrorMrmIndeterminateQualifierValue 15138
#define kNtErrorMrmAutomergeEnabled 15139
#define kNtErrorMrmTooManyResources 15140
#define kNtErrorMrmUnsupportedFileTypeForMerge 15141
#define kNtErrorMrmUnsupportedFileTypeForLoadUnloadPriFile 15142
#define kNtErrorMrmNoCurrentViewOnThread 15143
#define kNtErrorDifferentProfileResourceManagerExist 15144
#define kNtErrorOperationNotAllowedFromSystemComponent 15145
#define kNtErrorMrmDirectRefToNonDefaultResource 15146
#define kNtErrorMrmGenerationCountMismatch 15147
#define kNtErrorPriMergeVersionMismatch 15148
#define kNtErrorPriMergeMissingSchema 15149
#define kNtErrorPriMergeLoadFileFailed 15150
#define kNtErrorPriMergeAddFileFailed 15151
#define kNtErrorPriMergeWriteFileFailed 15152
#define kNtErrorPriMergeMultiplePackageFamiliesNotAllowed 15153
#define kNtErrorPriMergeMultipleMainPackagesNotAllowed 15154
#define kNtErrorPriMergeBundlePackagesNotAllowed 15155
#define kNtErrorPriMergeMainPackageRequired 15156
#define kNtErrorPriMergeResourcePackageRequired 15157
#define kNtErrorPriMergeInvalidFileName 15158
#define kNtErrorMcaInvalidCapabilitiesString 15200
#define kNtErrorMcaInvalidVcpVersion 15201
#define kNtErrorMcaMonitorViolatesMccsSpecification 15202
#define kNtErrorMcaMccsVersionMismatch 15203
#define kNtErrorMcaUnsupportedMccsVersion 15204
#define kNtErrorMcaInternalError 15205
#define kNtErrorMcaInvalidTechnologyTypeReturned 15206
#define kNtErrorMcaUnsupportedColorTemperature 15207
#define kNtErrorAmbiguousSystemDevice 15250
#define kNtErrorSystemDeviceNotFound 15299
#define kNtErrorHashNotSupported 15300
#define kNtErrorHashNotPresent 15301
#define kNtErrorSecondaryIcProviderNotRegistered 15321
#define kNtErrorGpioClientInformationInvalid 15322
#define kNtErrorGpioVersionNotSupported 15323
#define kNtErrorGpioInvalidRegistrationPacket 15324
#define kNtErrorGpioOperationDenied 15325
#define kNtErrorGpioIncompatibleConnectMode 15326
#define kNtErrorGpioInterruptAlreadyUnmasked 15327
#define kNtErrorCannotSwitchRunlevel 15400
#define kNtErrorInvalidRunlevelSetting 15401
#define kNtErrorRunlevelSwitchTimeout 15402
#define kNtErrorRunlevelSwitchAgentTimeout 15403
#define kNtErrorRunlevelSwitchInProgress 15404
#define kNtErrorServicesFailedAutostart 15405
#define kNtErrorComTaskStopPending 15501
#define kNtErrorInstallOpenPackageFailed 15600
#define kNtErrorInstallPackageNotFound 15601
#define kNtErrorInstallInvalidPackage 15602
#define kNtErrorInstallResolveDependencyFailed 15603
#define kNtErrorInstallOutOfDiskSpace 15604
#define kNtErrorInstallNetworkFailure 15605
#define kNtErrorInstallRegistrationFailure 15606
#define kNtErrorInstallDeregistrationFailure 15607
#define kNtErrorInstallCancel 15608
#define kNtErrorInstallFailed 15609
#define kNtErrorRemoveFailed 15610
#define kNtErrorPackageAlreadyExists 15611
#define kNtErrorNeedsRemediation 15612
#define kNtErrorInstallPrerequisiteFailed 15613
#define kNtErrorPackageRepositoryCorrupted 15614
#define kNtErrorInstallPolicyFailure 15615
#define kNtErrorPackageUpdating 15616
#define kNtErrorDeploymentBlockedByPolicy 15617
#define kNtErrorPackagesInUse 15618
#define kNtErrorRecoveryFileCorrupt 15619
#define kNtErrorInvalidStagedSignature 15620
#define kNtErrorDeletingExistingApplicationdataStoreFailed 15621
#define kNtErrorInstallPackageDowngrade 15622
#define kNtErrorSystemNeedsRemediation 15623
#define kNtErrorAppxIntegrityFailureClrNgen 15624
#define kNtErrorResiliencyFileCorrupt 15625
#define kNtErrorInstallFirewallServiceNotRunning 15626
#define kNtErrorPackageMoveFailed 15627
#define kNtErrorInstallVolumeNotEmpty 15628
#define kNtErrorInstallVolumeOffline 15629
#define kNtErrorInstallVolumeCorrupt 15630
#define kNtErrorNeedsRegistration 15631
#define kNtErrorInstallWrongProcessorArchitecture 15632
#define kNtErrorDevSideloadLimitExceeded 15633
#define kNtErrorInstallOptionalPackageRequiresMainPackage 15634
#define kNtErrorPackageNotSupportedOnFilesystem 15635
#define kNtErrorPackageMoveBlockedByStreaming 15636
#define kNtErrorInstallOptionalPackageApplicationidNotUnique 15637
#define kNtErrorPackageStagingOnhold 15638
#define kNtErrorInstallInvalidRelatedSetUpdate 15639
#define kNtErrorPackagesReputationCheckFailed 15643
#define kNtErrorPackagesReputationCheckTimedout 15644
#define kNtErrorStateLoadStoreFailed 15800
#define kNtErrorStateGetVersionFailed 15801
#define kNtErrorStateSetVersionFailed 15802
#define kNtErrorStateStructuredResetFailed 15803
#define kNtErrorStateOpenContainerFailed 15804
#define kNtErrorStateCreateContainerFailed 15805
#define kNtErrorStateDeleteContainerFailed 15806
#define kNtErrorStateReadSettingFailed 15807
#define kNtErrorStateWriteSettingFailed 15808
#define kNtErrorStateDeleteSettingFailed 15809
#define kNtErrorStateQuerySettingFailed 15810
#define kNtErrorStateReadCompositeSettingFailed 15811
#define kNtErrorStateWriteCompositeSettingFailed 15812
#define kNtErrorStateEnumerateContainerFailed 15813
#define kNtErrorStateEnumerateSettingsFailed 15814
#define kNtErrorStateCompositeSettingValueSizeLimitExceeded 15815
#define kNtErrorStateSettingValueSizeLimitExceeded 15816
#define kNtErrorStateSettingNameSizeLimitExceeded 15817
#define kNtErrorStateContainerNameSizeLimitExceeded 15818
#define kNtErrorApiUnavailable 15841 /* EPROCUNAVAIL */
#define kNtWaitIoCompletion 0xc0
/* WinSock Error Codes: 10000-11999 */
#define WSABASEERR 10000
#define WSAEINTR 10004
#define WSAEBADF 10009
#define WSAEACCES 10013
#define WSAEFAULT 10014
#define WSAEINVAL 10022
#define WSAEMFILE 10024
#define WSAEWOULDBLOCK 10035
#define WSAEINPROGRESS 10036
#define WSAEALREADY 10037
#define WSAENOTSOCK 10038
#define WSAEDESTADDRREQ 10039
#define WSAEMSGSIZE 10040
#define WSAEPROTOTYPE 10041
#define WSAENOPROTOOPT 10042
#define WSAEPROTONOSUPPORT 10043
#define WSAESOCKTNOSUPPORT 10044
#define WSAEOPNOTSUPP 10045
#define WSAEPFNOSUPPORT 10046
#define WSAEAFNOSUPPORT 10047
#define WSAEADDRINUSE 10048
#define WSAEADDRNOTAVAIL 10049
#define WSAENETDOWN 10050
#define WSAENETUNREACH 10051
#define WSAENETRESET 10052
#define WSAECONNABORTED 10053
#define WSAECONNRESET 10054
#define WSAENOBUFS 10055
#define WSAEISCONN 10056
#define WSAENOTCONN 10057
#define WSAESHUTDOWN 10058
#define WSAETOOMANYREFS 10059
#define WSAETIMEDOUT 10060
#define WSAECONNREFUSED 10061
#define WSAELOOP 10062
#define WSAENAMETOOLONG 10063
#define WSAEHOSTDOWN 10064
#define WSAEHOSTUNREACH 10065
#define WSAENOTEMPTY 10066
#define WSAEPROCLIM 10067
#define WSAEUSERS 10068
#define WSAEDQUOT 10069
#define WSAESTALE 10070
#define WSAEREMOTE 10071
#define WSASYSNOTREADY 10091
#define WSAVERNOTSUPPORTED 10092
#define WSANOTINITIALISED 10093
#define WSAEDISCON 10101
#define WSAENOMORE 10102
#define WSAECANCELLED 10103
#define WSAEINVALIDPROCTABLE 10104
#define WSAEINVALIDPROVIDER 10105
#define WSAEPROVIDERFAILEDINIT 10106
#define WSASYSCALLFAILURE 10107
#define WSASERVICE_NOT_FOUND 10108
#define WSATYPE_NOT_FOUND 10109
#define WSA_E_NO_MORE 10110
#define WSA_E_CANCELLED 10111
#define WSAEREFUSED 10112
#define WSAHOST_NOT_FOUND 11001
#define WSATRY_AGAIN 11002
#define WSANO_RECOVERY 11003
#define WSANO_DATA 11004
#define WSA_QOS_RECEIVERS 11005
#define WSA_QOS_SENDERS 11006
#define WSA_QOS_NO_SENDERS 11007
#define WSA_QOS_NO_RECEIVERS 11008
#define WSA_QOS_REQUEST_CONFIRMED 11009
#define WSA_QOS_ADMISSION_FAILURE 11010
#define WSA_QOS_POLICY_FAILURE 11011
#define WSA_QOS_BAD_STYLE 11012
#define WSA_QOS_BAD_OBJECT 11013
#define WSA_QOS_TRAFFIC_CTRL_ERROR 11014
#define WSA_QOS_GENERIC_ERROR 11015
#define WSA_QOS_ESERVICETYPE 11016
#define WSA_QOS_EFLOWSPEC 11017
#define WSA_QOS_EPROVSPECBUF 11018
#define WSA_QOS_EFILTERSTYLE 11019
#define WSA_QOS_EFILTERTYPE 11020
#define WSA_QOS_EFILTERCOUNT 11021
#define WSA_QOS_EOBJLENGTH 11022
#define WSA_QOS_EFLOWCOUNT 11023
#define WSA_QOS_EUNKOWNPSOBJ 11024
#define WSA_QOS_EPOLICYOBJ 11025
#define WSA_QOS_EFLOWDESC 11026
#define WSA_QOS_EPSFLOWSPEC 11027
#define WSA_QOS_EPSFILTERSPEC 11028
#define WSA_QOS_ESDMODEOBJ 11029
#define WSA_QOS_ESHAPERATEOBJ 11030
#define WSA_QOS_RESERVED_PETYPE 11031
#define WSA_SECURE_HOST_NOT_FOUND 11032
#define WSA_IPSEC_NAME_POLICY_ERROR 11033
#define WSA_WAIT_FAILED -1u
#define WSA_WAIT_EVENT_0 0
#define WSA_WAIT_IO_COMPLETION 0xc0
#define WSA_WAIT_TIMEOUT 258
#define WSA_MAXIMUM_WAIT_EVENTS 64
#define WSA_IO_PENDING 997
#define kNtWsaInvalidHandle kNtErrorInvalidHandle
#define kNtWsaNotEnoughMemory kNtErrorNotEnoughMemory
#define kNtWsaInvalidParameter kNtErrorInvalidParameter
#define kNtWsaIoPending kNtErrorIoPending
#define kNtWsaIoIncomplete kNtErrorIoIncomplete
#define kNtWsaOperationAborted kNtErrorOperationAborted
/*!BEGIN libc/nt/enum/wsaid.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_WSAID_H_
COSMOPOLITAN_C_START_
#define WSAID_WSAPOLL \
{ \
0x18C76F85, 0xDC66, 0x4964, { \
0x97, 0x2E, 0x23, 0xC2, 0x72, 0x38, 0x31, 0x2B \
} \
}
#define WSAID_WSARECVMSG \
{ \
0xf689d7c8, 0x6f1f, 0x436b, { \
0x8a, 0x53, 0xe5, 0x4f, 0xe3, 0x51, 0xc3, 0x22 \
} \
}
#define WSAID_WSASENDMSG \
{ \
0xa441e712, 0x754f, 0x43ca, { \
0x84, 0xa7, 0x0d, 0xee, 0x44, 0xcf, 0x60, 0x6d \
} \
}
#define WSAID_CONNECTEX \
{ \
0x25a207b9, 0xddf3, 0x4660, { \
0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e \
} \
}
#define WSAID_ACCEPTEX \
{ \
0xb5367df1, 0xcbac, 0x11cf, { \
0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 \
} \
}
#define WSAID_GETACCEPTEXSOCKADDRS \
{ \
0xb5367df2, 0xcbac, 0x11cf, { \
0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 \
} \
}
#define WSAID_TRANSMITFILE \
{ \
0xb5367df0, 0xcbac, 0x11cf, { \
0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92 \
} \
}
#define WSAID_TRANSMITPACKETS \
{ \
0xd9689da0, 0x1f90, 0x11d3, { \
0x99, 0x71, 0x00, 0xc0, 0x4f, 0x68, 0xc8, 0x76 \
} \
}
#define WSAID_DISCONNECTEX \
{ \
0x7fda2e11, 0x8630, 0x436f, { \
0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57 \
} \
}
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/enum/wt.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_WT_H_
#define kNtWtExecutedefault 0x00000000u
#define kNtWtExecuteonlyonce 0x00000008u
#define kNtWtExecuteintimerthread 0x00000020u
#define kNtWtExecuteinpersistentthread 0x00000080u
#define kNtWtExecutelongfunction 0x00000010u
#define kNtWtTransferImpersonation 0𝔵00000100𝔲
/*!BEGIN libc/nt/struct/acl.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_ACL_H_
struct NtAcl {
uint8_t AclRevision;
uint8_t Sbz1;
uint16_t AclSize;
uint16_t AceCount;
uint16_t Sbz2;
};
/*!BEGIN libc/nt/struct/afd.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_AFD_H_
COSMOPOLITAN_C_START_
struct NtAfdPollHandleInfo {
int64_t Handle;
uint32_t Events;
NtStatus Status;
};
struct NtAfdPollInfo {
int64_t Timeout;
uint32_t NumberOfHandles;
uint32_t Exclusive;
struct NtAfdPollHandleInfo Handles[1];
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/ansistring.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_ANSISTRING_H_
struct NtAnsiString {
unsigned short Length;
unsigned short MaximumLength;
char *Buffer;
};
/*!BEGIN libc/nt/struct/byhandlefileinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_BYHANDLEFILEINFORMATION_H_
/*!BEGIN libc/nt/struct/filetime.h */
#define COSMOPOLITAN_LIBC_NT_FILETIME_H_
struct NtFileTime {
uint32_t dwLowDateTime;
uint32_t dwHighDateTime;
};
struct NtByHandleFileInformation {
uint32_t dwFileAttributes; /* ←NtFileFlagAndAttributes */
struct NtFileTime ftCreationFileTime;
struct NtFileTime ftLastAccessFileTime;
struct NtFileTime ftLastWriteFileTime;
uint32_t dwVolumeSerialNumber;
uint32_t nFileSizeHigh;
uint32_t nFileSizeLow;
uint32_t nNumberOfLinks;
uint32_t nFileIndexHigh;
uint32_t nFileIndexLow;
};
/*!BEGIN libc/nt/struct/charinfo.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_CHARINFO_H_
struct NtCharInfo {
union {
char16_t UnicodeChar;
char AsciiChar;
} Char;
uint16_t Attributes;
};
/*!BEGIN libc/nt/struct/clientid.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_CLIENTID_H_
struct NtClientId {
void *UniqueProcess;
void *UniqueThread;
};
/*!BEGIN libc/nt/struct/consolecursorinfo.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_CONSOLECURSORINFO_H_
struct NtConsoleCursorInfo {
uint32_t dwSize;
bool32 bVisible;
};
/*!BEGIN libc/nt/struct/consolescreenbufferinfo.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_CONSOLESCREENBUFFERINFO_H_
/*!BEGIN libc/nt/struct/coord.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_COORD_H_
struct NtCoord {
int16_t X;
int16_t Y;
};
/*!BEGIN libc/nt/struct/smallrect.h */
#define COSMOPOLITAN_LIBC_NT_ENUM_SMALLRECT_H_
struct NtSmallRect {
int16_t Left;
int16_t Top;
int16_t Right;
int16_t Bottom;
};
struct NtConsoleScreenBufferInfo {
struct NtCoord dwSize;
struct NtCoord dwCursorPosition;
uint16_t wAttributes;
struct NtSmallRect srWindow;
struct NtCoord dwMaximumWindowSize;
};
/*!BEGIN libc/nt/struct/consolescreenbufferinfoex.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_CONSOLESCREENBUFFERINFOEX_H_
struct NtConsoleScreenBufferInfoEx {
uint32_t cbSize; /* sizeof(struct NtConsoleScreenBufferInfoEx) */
struct NtCoord dwSize;
struct NtCoord dwCursorPosition;
uint16_t wAttributes; /* kNt{Foreground,Background}... */
struct NtSmallRect srWindow;
struct NtCoord dwMaximumWindowSize;
uint16_t wPopupAttributes;
bool32 bFullscreenSupported;
uint32_t ColorTable[16]; /* 0x00BBGGRR */
};
/*!BEGIN libc/nt/struct/consoleselectioninfo.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_CONSOLESELECTIONINFO_H_
struct NtConsoleSelectionInfo {
uint32_t dwFlags;
struct NtCoord dwSelectionAnchor;
struct NtSmallRect srSelection;
};
/*!BEGIN libc/nt/struct/context.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_CONTEXT_H_
struct NtM128A {
uint64_t Low;
int64_t High;
};
struct NtXmmSaveArea32 { /* basically same as struct FpuState */
uint16_t ControlWord;
uint16_t StatusWord;
uint8_t TagWord;
uint8_t Reserved1;
uint16_t ErrorOpcode;
uint32_t ErrorOffset;
uint16_t ErrorSelector;
uint16_t Reserved2;
uint32_t DataOffset;
uint16_t DataSelector;
uint16_t Reserved3;
uint32_t MxCsr;
uint32_t MxCsr_Mask;
struct NtM128A FloatRegisters[8];
struct NtM128A XmmRegisters[16];
uint8_t Reserved4[96];
};
struct NtContext {
uint64_t P1Home, P2Home, P3Home, P4Home, P5Home, P6Home;
uint32_t ContextFlags;
uint32_t MxCsr;
uint16_t SegCs, SegDs, SegEs, SegFs, SegGs, SegSs;
uint32_t EFlags;
uint64_t Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
uint64_t Rax, Rcx, Rdx, Rbx, Rsp, Rbp, Rsi, Rdi;
uint64_t R8, R9, R10, R11, R12, R13, R14, R15;
uint64_t Rip;
union {
struct NtXmmSaveArea32 FltSave;
struct NtXmmSaveArea32 FloatSave;
struct {
struct NtM128A Header[2];
struct NtM128A Legacy[8];
struct NtM128A Xmm0, Xmm1, Xmm2, Xmm3, Xmm4, Xmm5, Xmm6, Xmm7;
struct NtM128A Xmm8, Xmm9, Xmm10, Xmm11, Xmm12, Xmm13, Xmm14, Xmm15;
};
};
struct NtM128A VectorRegister[26];
uint64_t VectorControl;
uint64_t DebugControl;
uint64_t LastBranchToRip;
uint64_t LastBranchFromRip;
uint64_t LastExceptionToRip;
uint64_t LastExceptionFromRip;
} forcealign(16);
/*!BEGIN libc/nt/struct/criticalsection.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_CRITICALSECTION_H_
/*!BEGIN libc/nt/struct/criticalsectiondebug.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_CRITICALSECTIONDEBUG_H_
/*!BEGIN libc/nt/struct/linkedlist.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_LINKEDLIST_H_
/**
* Dynamic linked list overlay.
*/
struct NtLinkedList {
struct NtLinkedList *Next;
struct NtLinkedList *Prev;
};
struct NtCriticalSectionDebug {
uint16_t Type;
uint16_t CreatorBackTraceIndex;
struct NtCriticalSection *CriticalSection;
struct NtLinkedList ProcessLocksList;
uint32_t EntryCount;
uint32_t ContentionCount;
uint32_t Spare[2];
};
struct NtCriticalSection {
struct NtCriticalSectionDebug *DebugInfo;
int32_t LockCount;
int32_t RecursionCount;
void *OwningThread;
void *LockSemaphore;
uintptr_t SpinCount;
};
/*!BEGIN libc/nt/struct/drawtextparams.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_DRAWTEXTPARAMS_H_
COSMOPOLITAN_C_START_
struct NtDrawTextParams {
uint32_t cbSize;
int32_t iTabLength;
int32_t iLeftMargin;
int32_t iRightMargin;
uint32_t uiLengthDrawn;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/dynamictimezoneinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_DYNAMICTIMEZONEINFORMATION_H_
/*!BEGIN libc/nt/struct/systemtime.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMTIME_H_
struct NtSystemTime {
uint16_t wYear;
uint16_t wMonth;
uint16_t wDayOfWeek;
uint16_t wDay;
uint16_t wHour;
uint16_t wMinute;
uint16_t wSecond;
uint16_t wMilliseconds;
};
struct NtDynamicTimeZoneInformation {
int32_t Bias;
char16_t StandardName[32];
struct NtSystemTime StandardDate;
int32_t StandardBias;
char16_t DaylightName[32];
struct NtSystemTime DaylightDate;
int32_t DaylightBias;
char16_t TimeZoneKeyName[128];
bool32 DynamicDaylightTimeDisabled;
};
/*!BEGIN libc/nt/struct/editmenu.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_EDITMENU_H_
struct NtEditMenu {
int64_t hmenu;
uint16_t idEdit;
uint16_t idCut;
uint16_t idCopy;
uint16_t idPaste;
uint16_t idClear;
uint16_t idUndo;
};
/*!BEGIN libc/nt/struct/exceptionframe.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_EXCEPTIONFRAME_H_
struct NtExceptionFrame {
struct NtExceptionFrame *Prev;
};
/*!BEGIN libc/nt/struct/fdset.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FDSET_H_
COSMOPOLITAN_C_START_
struct NtFdSet {
uint32_t fd_count;
int64_t fd_array[64];
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/fileaccessinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEACCESSINFORMATION_H_
struct NtFileAccessInformation {
uint32_t AccessFlags;
};
/*!BEGIN libc/nt/struct/filealignmentinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEALIGNMENTINFORMATION_H_
struct NtFileAlignmentInformation {
uint32_t AlignmentRequirement;
};
/*!BEGIN libc/nt/struct/fileallinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEALLINFORMATION_H_
/*!BEGIN libc/nt/struct/filebasicinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEBASICINFORMATION_H_
struct NtFileBasicInformation {
int64_t CreationTime; /* in 100ns units */
int64_t LastAccessTime; /* in 100ns units */
int64_t LastWriteTime; /* in 100ns units */
int64_t ChangeTime; /* in 100ns units */
uint32_t FileAttributes; /* kNtFileAttributeXXX */
};
/*!BEGIN libc/nt/struct/fileeainformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEEAINFORMATION_H_
struct NtFileEaInformation {
uint32_t EaSize;
};
/*!BEGIN libc/nt/struct/fileinternalinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEINTERNALINFORMATION_H_
struct NtFileInternalInformation {
int64_t IndexNumber;
};
/*!BEGIN libc/nt/struct/filemodeinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEMODEINFORMATION_H_
struct NtFileModeInformation {
uint32_t Mode;
};
/*!BEGIN libc/nt/struct/filenameinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILENAMEINFORMATION_H_
struct NtFileNameInformation {
uint32_t FileNameLength;
char16_t FileName[1];
};
/*!BEGIN libc/nt/struct/filepositioninformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEPOSITIONINFORMATION_H_
struct NtFilePositionInformation {
int64_t CurrentByteOffset;
};
/*!BEGIN libc/nt/struct/filestandardinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILESTANDARDINFORMATION_H_
struct NtFileStandardInformation {
int64_t AllocationSize;
int64_t EndOfFile;
uint32_t NumberOfLinks;
bool32 DeletePending;
bool32 Directory;
};
struct NtFileAllInformation {
struct NtFileBasicInformation BasicInformation;
struct NtFileStandardInformation StandardInformation;
struct NtFileInternalInformation InternalInformation;
struct NtFileEaInformation EaInformation;
struct NtFileAccessInformation AccessInformation;
struct NtFilePositionInformation PositionInformation;
struct NtFileModeInformation ModeInformation;
struct NtFileAlignmentInformation AlignmentInformation;
struct NtFileNameInformation NameInformation;
};
/*!BEGIN libc/nt/struct/fileallocationinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEALLOCATIONINFORMATION_H_
struct NtFileAllocationInformation {
int64_t AllocationSize;
};
/*!BEGIN libc/nt/struct/fileattributetaginformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEATTRIBUTETAGINFORMATION_H_
struct NtFileAttributeTagInformation {
uint32_t FileAttributes;
uint32_t ReparseTag;
};
/*!BEGIN libc/nt/struct/filebasicinfo.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEBASICINFO_H_
struct NtFileBasicInfo {
int64_t CreationTime; /* in 100ns units */
int64_t LastAccessTime; /* in 100ns units */
int64_t LastWriteTime; /* in 100ns units */
int64_t ChangeTime; /* in 100ns units */
uint32_t FileAttributes; /* kNtFileAttributeXXX */
};
/*!BEGIN libc/nt/struct/filebothdirectoryinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEBOTHDIRECTORYINFORMATION_H_
COSMOPOLITAN_C_START_
struct NtFileBothDirectoryInformation {
uint32_t NextEntryOffset;
uint32_t FileIndex;
int64_t CreationTime;
int64_t LastAccessTime;
int64_t LastWriteTime;
int64_t ChangeTime;
int64_t EndOfFile;
int64_t AllocationSize;
uint32_t FileAttributes;
uint32_t FileNameLength;
uint32_t EaSize;
unsigned char ShortNameLength;
char16_t ShortName[12];
char16_t FileName[1];
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/filecompressioninfo.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILECOMPRESSIONINFO_H_
struct NtFileCompressionInfo {
int64_t CompressedFileSize;
uint16_t CompressionFormat;
uint8_t CompressionUnitShift;
uint8_t ChunkShift;
uint8_t ClusterShift;
uint8_t Reserved[3];
};
/*!BEGIN libc/nt/struct/filedirectoryinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEDIRECTORYINFORMATION_H_
struct NtFileDirectoryInformation {
uint32_t NextEntryOffset;
uint32_t FileIndex;
int64_t CreationTime;
int64_t LastAccessTime;
int64_t LastWriteTime;
int64_t ChangeTime;
int64_t EndOfFile;
int64_t AllocationSize;
uint32_t FileAttributes;
uint32_t FileNameLength;
char16_t FileName[1];
};
/*!BEGIN libc/nt/struct/filedispositioninformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEDISPOSITIONINFORMATION_H_
struct NtFileDispositionInformation {
bool32 DoDeleteFile;
};
/*!BEGIN libc/nt/struct/fileendoffileinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEENDOFFILEINFORMATION_H_
struct FileEndOfFileInformation {
int64_t EndOfFile;
};
/*!BEGIN libc/nt/struct/filefsfullsizeinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEFSFULLSIZEINFORMATION_H_
COSMOPOLITAN_C_START_
struct NtFileFsFullSizeInformation {
int64_t TotalAllocationUnits;
int64_t CallerAvailableAllocationUnits;
int64_t ActualAvailableAllocationUnits;
uint32_t SectorsPerAllocationUnit;
uint32_t BytesPerSector;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/filefulldirectoryinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEFULLDIRECTORYINFORMATION_H_
struct NtFileFullDirectoryInformation {
uint32_t NextEntryOffset;
uint32_t FileIndex;
int64_t CreationTime;
int64_t LastAccessTime;
int64_t LastWriteTime;
int64_t ChangeTime;
int64_t EndOfFile;
int64_t AllocationSize;
uint32_t FileAttributes;
uint32_t FileNameLength;
uint32_t EaSize;
char16_t FileName[1];
};
/*!BEGIN libc/nt/struct/filefulleainformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEFULLEAINFORMATION_H_
struct NtFileFullEaInformation {
uint32_t NextEntryOffset;
uint8_t Flags;
uint8_t EaNameLength;
uint16_t EaValueLength;
char EaName[1];
};
/*!BEGIN libc/nt/struct/filemailslotqueryinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEMAILSLOTQUERYINFORMATION_H_
struct NtFileMailslotQueryInformation {
uint32_t MaximumMessageSize;
uint32_t MailslotQuota;
uint32_t NextMessageSize;
uint32_t MessagesAvailable;
int64_t ReadTimeout;
};
/*!BEGIN libc/nt/struct/filemailslotsetinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEMAILSLOTSETINFORMATION_H_
struct NtFileMailslotSetInformation {
int64_t ReadTimeout;
};
/*!BEGIN libc/nt/struct/filenamesinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILENAMESINFORMATION_H_
struct NtFileNamesInformation {
uint32_t NextEntryOffset;
uint32_t FileIndex;
uint32_t FileNameLength;
char16_t FileName[1];
};
/*!BEGIN libc/nt/struct/filenetworkopeninformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILENETWORKOPENINFORMATION_H_
struct NtFileNetworkOpenInformation {
int64_t CreationTime;
int64_t LastAccessTime;
int64_t LastWriteTime;
int64_t ChangeTime;
int64_t AllocationSize;
int64_t EndOfFile;
uint32_t FileAttributes;
};
/*!BEGIN libc/nt/struct/filepipelocalinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEPIPELOCALINFORMATION_H_
struct NtFilePipeLocalInformation {
uint32_t NamedPipeType;
uint32_t NamedPipeConfiguration;
uint32_t MaximumInstances;
uint32_t CurrentInstances;
uint32_t InboundQuota;
uint32_t ReadDataAvailable;
uint32_t OutboundQuota;
uint32_t WriteQuotaAvailable;
uint32_t NamedPipeState;
uint32_t NamedPipeEnd;
};
/*!BEGIN libc/nt/struct/filerenameinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILERENAMEINFORMATION_H_
struct NtFileRenameInformation {
bool32 Replace;
void *RootDir;
uint32_t FileNameLength;
char16_t FileName[1];
};
/*!BEGIN libc/nt/struct/filesegmentelement.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILESEGMENTELEMENT_H_
union NtFileSegmentElement {
void *Buffer;
uint64_t Alignment;
};
/*!BEGIN libc/nt/struct/filestreaminformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILESTREAMINFORMATION_H_
struct NtFileStreamInformation {
uint32_t NextEntryOffset;
uint32_t StreamNameLength;
int64_t StreamSize;
int64_t StreamAllocationSize;
char16_t StreamName[1];
};
/*!BEGIN libc/nt/struct/filezerodatainformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FILEZERODATAINFORMATION_H_
struct NtFileZeroDataInformation {
uint64_t FileOffset;
uint64_t BeyondFinalZero;
};
/*!BEGIN libc/nt/struct/fpodata.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_FPODATA_H_
struct NtFpoData {
/* TODO(jart): No bitfields. */
uint32_t ulOffStart;
uint32_t cbProcSize;
uint32_t cdwLocals;
uint16_t cdwParams;
uint16_t cbProlog : 8;
uint16_t cbRegs : 3;
uint16_t fHasSEH : 1;
uint16_t fUseBP : 1;
uint16_t reserved : 1;
uint16_t cbFrame : 2;
};
/*!BEGIN libc/nt/struct/genericmapping.h */
#define COSMOPOLITAN_LIBC_NT_GENERICMAPPING_H_
struct NtGenericMapping {
unsigned int GenericRead;
unsigned int GenericWrite;
unsigned int GenericExecute;
unsigned int GenericAll;
};
/*!BEGIN libc/nt/struct/guid.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_GUID_H_
COSMOPOLITAN_C_START_
struct NtGuid {
uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
uint8_t Data4[8];
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/inputrecord.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_INPUTRECORD_H_
struct NtKeyEventRecord {
bool32 bKeyDown;
uint16_t wRepeatCount;
uint16_t wVirtualKeyCode;
uint16_t wVirtualScanCode;
union {
uint16_t UnicodeChar;
char AsciiChar;
} uChar;
unsigned int dwControlKeyState;
#define kNtRightAltPressed 0x0001
#define kNtLeftAltPressed 0x0002
#define kNtRightCtrlPressed 0x0004
#define kNtLeftCtrlPressed 0x0008
#define kNtShiftPressed 0x0010
#define kNtNumlockOn 0x0020
#define kNtScrolllockOn 0x0040
#define kNtCapslockOn 0x0080
#define kNtEnhancedKey 0x0100
};
struct NtMouseEventRecord {
struct NtCoord dwMousePosition;
uint32_t dwButtonState;
#define kNtFromLeft1stButtonPressed 0x0001
#define kNtRightmostButtonPressed 0x0002
#define kNtFromLeft2ndButtonPressed 0x0004
#define kNtFromLeft3rdButtonPressed 0x0008
#define kNtFromLeft4thButtonPressed 0x0010
uint32_t dwControlKeyState;
uint32_t dwEventFlags;
#define kNtMouseMoved 0x0001
#define kNtDoubleClick 0x0002
#define kNtMouseWheeled 0x0004
#define kNtMouseHwheeled 0x0008
};
struct NtWindowBufferSizeRecord {
struct NtCoord dwSize;
};
struct NtMenuEventRecord {
uint32_t dwCommandId;
};
struct NtFocusEventRecord {
bool32 bSetFocus;
};
struct NtInputRecord {
uint16_t EventType;
#define kNtKeyEvent 0x0001
#define kNtMouseEvent 0x0002
#define kNtWindowBufferSizeEvent 0x0004
#define kNtMenuEvent 0x0008
#define kNtFocusEvent 0x0010
union {
struct NtKeyEventRecord KeyEvent;
struct NtMouseEventRecord MouseEvent;
struct NtWindowBufferSizeRecord WindowBufferSizeEvent;
struct NtMenuEventRecord MenuEvent;
struct NtFocusEventRecord FocusEvent;
} Event;
};
/*!BEGIN libc/nt/struct/iocounters.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_IOCOUNTERS_H_
struct NtIoCounters {
uint64_t ReadOperationCount;
uint64_t WriteOperationCount;
uint64_t OtherOperationCount;
uint64_t ReadTransferCount;
uint64_t WriteTransferCount;
uint64_t OtherTransferCount;
};
/*!BEGIN libc/nt/struct/iostatusblock.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_IOSTATUSBLOCK_H_
struct NtIoStatusBlock {
union {
NtStatus Status;
void *Pointer; /* reserved for internal use */
};
uint32_t *Information; /* request dependent */
};
/*!BEGIN libc/nt/struct/iovec.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_IOVEC_H_
COSMOPOLITAN_C_START_
struct NtIovec {
uint32_t len;
char *buf;
};
void DescribeIovNt(const struct NtIovec *, uint32_t, ssize_t);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/ipadapteraddresses.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_IP_ADAPTER_ADDRESSES_H_
/*!BEGIN libc/nt/winsock.h */
#define COSMOPOLITAN_LIBC_NT_WINSOCK_H_
/*!BEGIN libc/nt/struct/overlapped.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_OVERLAPPED_H_
struct NtOverlapped {
uintptr_t Internal;
uintptr_t InternalHigh;
union {
struct {
uint32_t Offset;
uint32_t OffsetHigh;
};
int64_t Pointer;
};
int64_t hEvent;
};
/*!BEGIN libc/nt/struct/pollfd.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_POLLFD_H_
struct sys_pollfd_nt {
int64_t handle;
int16_t events;
int16_t revents;
};
/*!BEGIN libc/nt/struct/timeval.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_TIMEVAL_H_
COSMOPOLITAN_C_START_
struct NtTimeval {
int32_t tv_sec; /* [sic] */
int32_t tv_usec;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/thunk/msabi.h */
#define COSMOPOLITAN_LIBC_NT_THUNK_MSABI_H_
#ifdef __x86_64__
#if (__GNUC__ * 100 + __GNUC_MINOR__ >= 408 || \
(__has_attribute(__ms_abi__) || defined(__llvm__)))
/**
* Defines function as using Microsoft x64 calling convention.
*
* This can be used to define prototypes that allow modern compilers to
* generate code that calls MS ABI functions directly, without needing
* to jump through the assembly thunks.
*/
#define __msabi __attribute__((__ms_abi__))
#endif
/*
* Returns true if header should provide MS-ABI overrides.
*/
#ifndef ShouldUseMsabiAttribute
#if defined(__msabi) && defined(NDEBUG) && !defined(__PG__) && !defined(FTRACE)
#define ShouldUseMsabiAttribute() 1
#else
#define ShouldUseMsabiAttribute() 0
#endif
#endif
#else
#define __msabi
#ifndef ShouldUseMsabiAttribute
#define ShouldUseMsabiAttribute() 0
#endif
#endif /* __x86_64__ */
/*!BEGIN libc/sock/sock.h */
#define COSMOPOLITAN_LIBC_SOCK_SOCK_H_
COSMOPOLITAN_C_START_
#define INET_ADDRSTRLEN 22
#define IFHWADDRLEN 6
libcesque uint16_t htons(uint16_t) pureconst;
libcesque uint16_t ntohs(uint16_t) pureconst;
libcesque uint32_t htonl(uint32_t) pureconst;
libcesque uint32_t ntohl(uint32_t) pureconst;
#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
#define htons(x) __builtin_bswap16(x)
#define ntohs(x) __builtin_bswap16(x)
#define htonl(x) __builtin_bswap32(x)
#define ntohl(x) __builtin_bswap32(x)
#endif
const char *inet_ntop(int, const void *, char *, uint32_t) libcesque;
int inet_pton(int, const char *, void *) libcesque;
uint32_t inet_addr(const char *) libcesque;
libcesque uint32_t *GetHostIps(void) __wur;
int socket(int, int, int) libcesque;
int listen(int, int) libcesque;
int shutdown(int, int) libcesque;
ssize_t send(int, const void *, size_t, int) libcesque;
ssize_t recv(int, void *, size_t, int) libcesque;
ssize_t sendfile(int, int, int64_t *, size_t) libcesque;
int getsockopt(int, int, int, void *, uint32_t *) libcesque;
int setsockopt(int, int, int, const void *, uint32_t) libcesque;
int socketpair(int, int, int, int[2]) libcesque;
int sockatmark(int) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/sockaddr.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_SOCKADDR_H_
COSMOPOLITAN_C_START_
struct sockaddr { /* Linux+NT ABI */
uint16_t sa_family; /* AF_XXX */
char sa_data[14];
};
struct in_addr { /* ARPA ABI */
/* e.g. 127|0<<8|0<<16|1<<24 or inet_pton(AF_INET, "127.0.0.1", &s_addr) */
uint32_t s_addr;
};
struct sockaddr_in { /* Linux+NT ABI */
uint16_t sin_family; /* AF_XXX */
uint16_t sin_port; /* htons(XXX) i.e. big endian */
struct in_addr sin_addr;
uint8_t sin_zero[8];
};
struct sockaddr_un {
uint16_t sun_family; /* AF_UNIX */
char sun_path[108]; /* path */
};
struct sockaddr_storage {
union {
uint16_t ss_family;
intptr_t __ss_align;
char __ss_storage[128];
};
};
int inet_aton(const char *, struct in_addr *);
char *inet_ntoa(struct in_addr);
int accept(int, struct sockaddr *, uint32_t *);
int accept4(int, struct sockaddr *, uint32_t *, int);
int bind(int, const struct sockaddr *, uint32_t);
int connect(int, const struct sockaddr *, uint32_t);
int getsockname(int, struct sockaddr *, uint32_t *);
int getpeername(int, struct sockaddr *, uint32_t *);
ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, uint32_t *);
ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *,
uint32_t);
COSMOPOLITAN_C_END_
/* ░▓█████████████████████████████████████████████▓▒
░█▓░░░░░░░░░▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▒░
░█▓░ ░▒▒▒▒ ▓██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▓▒▒
░█▓░ ░▓▓▓▒ ▓██▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██▓▒▒
░█▓░ ░▓██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▒▒
░███████████████████████████████████████████████▓▒▒
░█▓░ ▒█▓▒▒
░█▓░ ▒█▓▒▒
░█▓░ ░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░ ▒█▓▒▒
░█▓░ ░▒░ ▒█▓░ ▒█▓▒▒
░█▓░ ░░░░ ░░░░░░░░ ▒▓▓▓▒░ ▒█▓▒▒
░█▓░ ░░░░ ░░░░░▒▒▓███▓░░░░░░░░▒▓▓▓▓▒ ▒█▓▒▒
░█▓░ ░▒▒ ░░░░░░░▒▒████▓░░░░░░░░░░▒██▓ ▒█▓▒▒
░█▓░ ░▒▒ ░░░░░░░▒▒▓▓▓▓▓░░░░░░░░░▒▒██▓ ▒█▓▒▒
░█▓░ ░▒▒ ░░▒▒▒▒░░░░░ ░▒▒▒▒░░░░░▒▒██▓ ▒█▓▒▒
░█▓░ ░▒▒ ░░▒▓█▓░░░░░░░▒▓██▓░░░░▒▒██▓ ▒█▓▒▒
░█▓░ ░▒▒ ░░▒▓█▓░░░░░░░▒▓██▓░░░░▒▒██▓ ▒█▓▒▒
░█▓░ ░▒▒ ░░▒▓█▓░░░░░░░▒▓██▓░░░░▒▒██▓ ░▓█▓▒▒▒▒
░█▓░ ░▒▒ ░░▒▓█▓░░░░░░░▒▓██▓░░░░░▒██▓ ░████▓▒░
░█▓░ ░░░░░░░░▒▒░░░░░░░░░▒▒░░░▒▒▓▓▒░░ ░░▓███▓▒░
░█▓░ ░░░░░░░░░░░░░░░░░░░░░░▒▓▓▓▒░ ▒████▓▒░░░░░░
░█▓░ ░░▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒░░ ░▓▓▓▓██▒░░░░░░░░
░█▓░ ▒█████████████████▒ ▓█▓▒░ ▒█▓ ░█▓ ░▓▓░
░█▓░ ░▓████▒░ ▒█▓▒░ ░░░░░░░ ▓█▓░
░█▓░ ░▓████▒░ ░▒░ ░░░░░░░░░░░ ░█▓
░█▓ ▒███▓▒▒░ ░░░░░░░░░░░░░░░ ▒▓▓
░██████████████████████████████████████▓▒▓█▓░ ░░░░░░░░░░░░░░░░░░ ▒█▓
▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒░ ░░░░░░░░░░░░░░░░░░░░▒█▓
░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░▒██▒▒▒░░░░░░░░░░░░░░░░░░░░░▒█▓
░██▒▒▒▒▒░░░░░░░░░░░░░░░░░░░▒█▓
░▓▓▓▒▒▒▒▒▒░░░░░░░░░░░░░░░░▒▓█▓
░▓▓▓▒▒▒▒▒▒░░░░░░░░░░░▒▒▒▒▓▓▒
░██▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ░█▓
▒█▓▒▒▒▒▒▒▒▒▒▒▒██▓▒░ ░█▓
▒█████████████▓▒▒░ ░██▒
╔────────────────────────────────────────────────────────────────▀▀▀▀───▀▀▀▀─│─╗
│ cosmopolitan § new technology » winsock ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define kNtWsaFlagOverlapped 0x01
#define kNtWsaFlagNoHandleInherit 0x80
#define kNtCompEqual 0
#define kNtCompNotless 1
#define kNtTfDisconnect 0x01
#define kNtTfReuseSocket 0x02
#define kNtTfWriteBehind 0x04
#define kNtTfUseDefaultWorker 0x00
#define kNtTfUseSystemThread 0x10
#define kNtTfUseKernelApc 0x20
#define kNtSoConnectTime 0x700C
#define kNtSoUpdateAcceptContext 0x700B
#define kNtSoUpdateConnectContext 0x7010
#define kNtNspNotifyImmediately 0
#define kNtNspNotifyHwnd 1
#define kNtNspNotifyEvent 2
#define kNtNspNotifyPort 3
#define kNtNspNotifyApc 4
COSMOPOLITAN_C_START_
struct NtMsgHdr {
struct sockaddr *name;
int32_t namelen;
struct NtIovec *lpBuffers;
uint32_t dwBufferCount;
struct NtIovec Control;
uint32_t dwFlags;
};
struct NtWsaData {
uint16_t wVersion;
uint16_t wHighVersion;
uint16_t iMaxSockets;
uint16_t iMaxUdpDg;
char *lpVendorInfo;
char szDescription[257];
char szSystemStatus[129];
};
struct NtSocketAddress {
struct sockaddr *lpSockaddr;
int32_t iSockaddrLength;
};
struct NtSocketAddressList {
int32_t iAddressCount;
struct NtSocketAddress Address[1];
};
struct NtAddrInfoEx { /* win8+ */
int32_t ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
int32_t ai_family; /* PF_XXX */
int32_t ai_socktype; /* SOCK_XXX */
int32_t ai_protocol;
uint64_t ai_addrlen;
char16_t *ai_canonname;
struct sockaddr *ai_addr;
void *ai_blob;
uint64_t ai_bloblen;
struct NtGuid *ai_provider;
struct NtAddrInfoEx *ai_next;
int32_t ai_version; /* v2 */
char16_t *ai_fqdn; /* v2 */
int32_t ai_interfaceindex; /* v3 */
int64_t ai_resolutionhandle; /* v4 */
};
struct NtWsaProtocolChain {
int32_t ChainLen;
uint32_t ChainEntries[7];
};
struct NtWsaProtocolInfo {
uint32_t dwServiceFlags1;
uint32_t dwServiceFlags2;
uint32_t dwServiceFlags3;
uint32_t dwServiceFlags4;
uint32_t dwProviderFlags;
struct NtGuid ProviderId;
uint32_t dwCatalogEntryId;
struct NtWsaProtocolChain ProtocolChain;
int32_t iVersion;
int32_t iAddressFamily;
int32_t iMaxSockAddr;
int32_t iMinSockAddr;
int32_t iSocketType;
int32_t iProtocol;
int32_t iProtocolMaxOffset;
int32_t iNetworkByteOrder;
int32_t iSecurityScheme;
uint32_t dwMessageSize;
uint32_t dwProviderReserved;
char16_t szProtocol[256];
};
struct NtFlowSpec {
uint32_t TokenRate; /* bytes/sec */
uint32_t TokenBucketSize; /* bytes */
uint32_t PeakBandwidth; /* bytes/sec */
uint32_t Latency; /* µs */
uint32_t DelayVariation; /* µs */
uint32_t ServiceType; /* kNtServicetypeXxx */
uint32_t MaxSduSize; /* bytes */
uint32_t MinimumPolicedSize; /* bytes */
};
struct NtQos {
struct NtFlowSpec SendingFlowspec;
struct NtFlowSpec ReceivingFlowspec;
struct NtIovec ProviderSpecific;
};
struct NtWsaVersion {
uint32_t dwVersion;
int ecHow;
};
struct NtAfProtocols {
int32_t iAddressFamily;
int32_t iProtocol;
};
struct NtBlob {
uint32_t cbSize;
uint8_t pBlobData;
};
struct NtCsAddrInfo {
struct NtSocketAddress LocalAddr;
struct NtSocketAddress RemoteAddr;
int32_t iSocketType;
int32_t iProtocol;
};
struct NtWsaQuerySet {
uint32_t dwSize; /* of this */
char16_t *lpszServiceInstanceName;
struct NtGuid *lpServiceClassId;
struct NtWsaVersion *lpVersion;
char16_t *lpszComment;
uint32_t dwNameSpace;
struct NtGuid *lpNSProviderId;
char16_t *lpszContext;
uint32_t dwNumberOfProtocols;
struct NtAfProtocols *lpafpProtocols /*[dwNumberOfProtocols]*/;
char16_t *lpszQueryString;
uint32_t dwNumberOfCsAddrs;
struct NtCsAddrInfo *lpcsaBuffer /*[dwNumberOfCsAddrs]*/;
uint32_t dwOutputFlags;
struct NtBlob *lpBlob;
};
struct NtWsaNamespaceInfoEx {
struct NtGuid NSProviderId;
uint32_t dwNameSpace;
bool32 fActive;
uint32_t dwVersion;
char16_t *lpszIdentifier;
struct NtBlob *ProviderSpecific;
};
struct NtWsansClassInfo {
char16_t *lpszName;
uint32_t dwNameSpace;
uint32_t dwValueType;
uint32_t dwValueSize;
void *lpValue;
};
struct NtWsaServiceClassInfo {
struct NtGuid *lpServiceClassId;
char16_t *lpszServiceClassName;
uint32_t dwCount;
struct NtWsansClassInfo *lpClassInfos;
};
struct NtWsaNetworkEvents {
int32_t lNetworkEvents;
int32_t iErrorCode[10];
};
struct NtTransmitFileBuffers {
void *Head;
uint32_t HeadLength;
void *Tail;
uint32_t TailLength;
};
typedef int (*NtConditionProc)(
const struct NtIovec *lpCallerId, const struct NtIovec *lpCallerData,
struct NtQos *inout_lpSQOS, struct NtQos *inout_lpGQOS,
const struct NtIovec *lpCalleeId, const struct NtIovec *lpCalleeData,
uint32_t *out_group, const uint32_t *dwCallbackData);
typedef void (*NtWsaOverlappedCompletionRoutine)(
uint32_t dwError, uint32_t cbTransferred,
const struct NtOverlapped *lpOverlapped, uint32_t dwFlags);
struct NtWsaCompletion {
int Type;
union {
struct {
int64_t hWnd;
uint32_t uMsg;
uintptr_t context;
} WindowMessage;
struct {
struct NtOverlapped *lpOverlapped;
} Event;
struct {
struct NtOverlapped *lpOverlapped;
NtWsaOverlappedCompletionRoutine lpfnCompletionProc;
} Apc;
struct {
struct NtOverlapped *lpOverlapped;
int64_t hPort;
uint32_t Key;
} Port;
} Parameters;
};
struct NtInterfaceInfo {
uint64_t iiFlags;
struct sockaddr_in iiAddress;
struct sockaddr_in iiBroadcastAddress;
struct sockaddr_in iiNetmask;
};
/**
* Winsock2 prototypes.
*
* @note Some of the functions exported by WS2_32.DLL, e.g. bind(),
* overlap with the names used by System V. Prototypes for these
* functions are declared within their respective wrappers.
*/
int32_t WSAStartup(uint16_t wVersionRequested, struct NtWsaData *lpWSAData)
paramsnonnull();
int WSACleanup(void);
int WSAGetLastError(void) nosideeffect;
void WSASetLastError(int);
int64_t __sys_socket_nt(int, int, int);
int __sys_bind_nt(uint64_t, const void *, int);
int __sys_closesocket_nt(uint64_t);
int __sys_getpeername_nt(uint64_t, void *, uint32_t *);
int __sys_getsockname_nt(uint64_t, void *, uint32_t *);
int __sys_getsockopt_nt(uint64_t, int, int, void *, uint32_t *);
int __sys_ioctlsocket_nt(uint64_t, int32_t, uint32_t *);
int __sys_listen_nt(uint64_t, int);
int __sys_setsockopt_nt(uint64_t, int, int, const void *, int);
int __sys_shutdown_nt(uint64_t, int);
int __sys_select_nt(int, struct NtFdSet *, struct NtFdSet *, struct NtFdSet *,
struct NtTimeval *);
uint64_t WSASocket(int af, int type, int protocol,
const struct NtWsaProtocolInfo *opt_lpProtocolInfo,
const uint32_t opt_group, uint32_t dwFlags) __wur;
int WSAConnect(uint64_t s, const struct sockaddr *name, const int namelen,
const struct NtIovec *opt_lpCallerData,
struct NtIovec *opt_out_lpCalleeData,
const struct NtQos *opt_lpSQOS, const struct NtQos *opt_lpGQOS)
paramsnonnull((2));
bool32 WSAConnectByName(uint64_t s, const char16_t *nodename,
const char16_t *servicename,
uint32_t *opt_inout_LocalAddressLength,
struct sockaddr *out_LocalAddress,
uint32_t *opt_inout_RemoteAddressLength,
struct sockaddr *out_RemoteAddress,
const struct NtTimeval *opt_timeout,
struct NtOverlapped *__Reserved) paramsnonnull((2, 3));
bool32 WSAConnectByList(uint64_t s,
const struct NtSocketAddressList *SocketAddress,
uint32_t *opt_inout_LocalAddressLength,
struct sockaddr *out_LocalAddress,
uint32_t *opt_inout_RemoteAddressLength,
struct sockaddr *out_RemoteAddress,
const struct NtTimeval *opt_timeout,
struct NtOverlapped *__Reserved) paramsnonnull((2));
int64_t WSAAccept(uint64_t s, struct sockaddr *out_addr,
int32_t *opt_inout_addrlen,
const NtConditionProc opt_lpfnCondition,
const uint32_t *opt_dwCallbackData) paramsnonnull((2)) __wur;
int WSASend(uint64_t s, const struct NtIovec *lpBuffers, uint32_t dwBufferCount,
uint32_t *opt_out_lpNumberOfBytesSent, uint32_t dwFlags,
struct NtOverlapped *opt_inout_lpOverlapped,
const NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((2));
int WSASendMsg(int64_t Handle, const struct NtMsgHdr *lpMsg, uint32_t dwFlags,
uint32_t *opt_out_lpNumberOfBytesSent,
struct NtOverlapped *opt_inout_lpOverlapped,
const NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((2));
int WSASendTo(uint64_t s, const struct NtIovec *lpBuffers,
uint32_t dwBufferCount,
uint32_t *opt_out_lpNumberOfBytesSent /* opt if !overlapped */,
uint32_t dwFlags, const void *opt_tosockaddr,
int32_t tosockaddrlen,
struct NtOverlapped *opt_inout_lpOverlapped,
const NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((2));
int WSAPoll(struct sys_pollfd_nt *inout_fdArray, uint32_t nfds,
signed timeout_ms) paramsnonnull();
int WSARecv(uint64_t s, const struct NtIovec *inout_lpBuffers,
uint32_t dwBufferCount, uint32_t *opt_out_lpNumberOfBytesRecvd,
uint32_t *inout_lpFlags,
struct NtOverlapped *opt_inout_lpOverlapped,
const NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((2, 5));
int WSARecvFrom(uint64_t s, const struct NtIovec *inout_lpBuffers,
uint32_t dwBufferCount, uint32_t *opt_out_lpNumberOfBytesRecvd,
uint32_t *inout_lpFlags, void *out_fromsockaddr,
uint32_t *opt_inout_fromsockaddrlen,
struct NtOverlapped *opt_inout_lpOverlapped,
const NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((2, 5));
int WSARecvDisconnect(uint64_t s, struct NtIovec *out_InboundDisconnectData);
int WSASendDisconnect(int64_t s, struct NtIovec *opt_OutboundDisconnectData);
int WSADuplicateSocket(uint64_t s, uint32_t dwProcessId,
struct NtWsaProtocolInfo *out_lpProtocolInfo)
paramsnonnull((3));
int WSAIoctl(uint64_t s, uint32_t dwIoControlCode, const void *lpvInBuffer,
uint32_t cbInBuffer, void *out_lpvOutBuffer, uint32_t cbOutBuffer,
uint32_t *out_lpcbBytesReturned,
struct NtOverlapped *opt_inout_lpOverlapped,
const NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((5, 7));
int WSANSPIoctl(int64_t hLookup, uint32_t dwControlCode,
const void *lpvInBuffer, uint32_t cbInBuffer,
void *out_lpvOutBuffer, uint32_t cbOutBuffer,
uint32_t *out_lpcbBytesReturned,
const struct NtWsaCompletion *opt_lpCompletion)
paramsnonnull((3, 5, 7));
int64_t WSACreateEvent(void) __wur;
bool32 WSACloseEvent(const int64_t hEvent);
bool32 WSAResetEvent(const int64_t hEvent);
bool32 WSASetEvent(const int64_t hEvent);
int WSAEventSelect(uint64_t s, const int64_t opt_hEventObject,
long lNetworkEvents);
uint32_t WSAWaitForMultipleEvents(uint32_t cEvents, const int64_t *lphEvents,
bool32 fWaitAll, uint32_t dwTimeout_ms,
bool32 fAlertable) paramsnonnull();
int WSAEnumNetworkEvents(uint64_t s, const int64_t hEventObject,
struct NtWsaNetworkEvents *out_lpNetworkEvents)
paramsnonnull();
bool32 WSAGetOverlappedResult(uint64_t s,
const struct NtOverlapped *lpOverlapped,
uint32_t *out_lpcbTransfer, bool32 fWait,
uint32_t *out_lpdwFlags) paramsnonnull();
int WSAEnumProtocols(const int32_t *opt_lpiProtocols,
struct NtWsaProtocolInfo *out_lpProtocolBuffer,
uint32_t *inout_lpdwBufferLength) paramsnonnull();
bool32 WSAGetQOSByName(uint64_t s, const struct NtIovec *lpQOSName,
struct NtQos *out_lpQOS) paramsnonnull();
uint64_t WSAJoinLeaf(uint64_t s, const struct sockaddr *name, const int namelen,
const struct NtIovec *opt_lpCallerData,
struct NtIovec *opt_out_lpCalleeData,
const struct NtQos *opt_lpSQOS,
const struct NtQos *opt_lpGQOS, uint32_t dwFlags)
paramsnonnull((2, 4));
int WSALookupServiceBegin(const struct NtWsaQuerySet *lpqsRestrictions,
uint32_t dwControlFlags, int64_t *out_lphLookup)
paramsnonnull();
int WSALookupServiceNext(const int64_t hLookup, uint32_t dwControlFlags,
uint32_t *inout_lpdwBufferLength,
struct NtWsaQuerySet *out_lpqsResults) paramsnonnull();
int WSALookupServiceEnd(int64_t hLookup);
int WSAAddressToString(const struct sockaddr *lpsaAddress,
uint32_t dwAddressLength,
const struct NtWsaProtocolInfo *opt_lpProtocolInfo,
char16_t *out_lpszAddressString,
uint32_t *inout_lpdwAddressStringLength)
paramsnonnull((1, 4, 5));
int WSAStringToAddress(const char16_t *AddressString, int AddressFamily,
const struct NtWsaProtocolInfo *opt_lpProtocolInfo,
struct sockaddr *out_lpAddress,
int *inout_lpAddressLength) paramsnonnull((1, 3, 4));
int WSAEnumNameSpaceProvidersEx(uint32_t *inout_lpdwBufferLength,
struct NtWsaNamespaceInfoEx *out_lpnspBuffer)
paramsnonnull();
int WSAProviderConfigChange(
int64_t *inout_lpNotificationHandle,
struct NtOverlapped *opt_inout_lpOverlapped,
NtWsaOverlappedCompletionRoutine opt_lpCompletionRoutine)
paramsnonnull((1));
int WSAInstallServiceClass(
const struct NtWsaServiceClassInfo *lpServiceClassInfo) paramsnonnull();
int WSARemoveServiceClass(const struct NtGuid *lpServiceClassId)
paramsnonnull();
int WSAGetServiceClassInfo(const struct NtGuid *lpProviderId,
const struct NtGuid *lpServiceClassId,
uint32_t *inout_lpdwBufSize,
struct NtWsaServiceClassInfo *out_lpServiceClassInfo)
paramsnonnull((1, 2, 3));
int WSASetService(const struct NtWsaQuerySet *lpqsRegInfo, int essoperation,
uint32_t dwControlFlags) paramsnonnull();
int /* success==0 */ WSAGetServiceClassNameByClassId(
const struct NtGuid *lpServiceClassId, char16_t *out_lpszServiceClassName,
uint32_t *inout_lpdwBufferLength) paramsnonnull();
void GetAcceptExSockaddrs(
const void *lpOutputBuffer /*[recvsize+addrsize+addrlen]*/,
uint32_t dwReceiveDataLength, uint32_t dwLocalAddressLength,
uint32_t dwRemoteAddressLength,
struct sockaddr **out_LocalSockaddr /*[*LocalSockaddrLength]*/,
int *out_LocalSockaddrLength,
struct sockaddr **out_RemoteSockaddr /*[*RemoteSockaddrLength]*/,
int *out_RemoteSockaddrLength);
bool32 DisconnectEx(int64_t s, struct NtOverlapped *inout_opt_lpOverlapped,
uint32_t dwFlags, uint32_t dwReserved);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/winsock.inc */
extern typeof(WSAGetLastError) *const __imp_WSAGetLastError __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/* Constants ----------------------------------------------------------- */
#define kNtMaxAdapterAddressLength 8
#define kNtMaxDnsSuffixStringLength 256
#define kNtMaxDhcpv6DuidLength 130
/* Values for the 'Flags' parameter of GetAdaptersAddresses */
#define kNtGaaFlagSkipUnicast 0x0001
#define kNtGaaFlagSkipAnycast 0x0002
#define kNtGaaFlagSkipMulticast 0x0004
#define kNtGaaFlagSkipDnsServer 0x0008
#define kNtGaaFlagIncludePrefix 0x0010
#define kNtGaaFlagSkipFriendlyName 0x0020
#define kNtGaaFlagIncludeWinsInfo 0x0040
#define kNtGaaFlagIncludeGateways 0x0080
#define kNtGaaFlagIncludeAllInterfaces 0x0100
#define kNtGaaFlagIncludeAllCompartments 0x0200
#define kNtGaaFlagIncludeTunnelBindingorder 0x0400
#define kNtGaaFlagSkipDnsInfo 0x0800
/* Values for the IfType parameter
* See:
* https://docs.microsoft.com/en-us/windows/win32/api/iptypes/ns-iptypes-ip_adapter_addresses_lh
*/
#define kNtIfTypeOther 1
#define kNtIfTypeEthernetCsmacd 6
#define kNtIfTypeIso88025Tokenring 9
#define kNtIfTypePpp 23
#define kNtIfTypeSoftwareLoopback 24
#define kNtIfTypeAtm 37
#define kNtIfTypeIeee80211 71 /* wifi */
#define kNtIfTypeTunnel 131
#define kNtIfTypeIeee1394 144 /* firewire */
#define kNtIpAdapterDdnsEnabled 0x0001
#define kNtIpAdapterRegisterAdapterSuffix 0x0002
#define kNtIpAdapterDhcpv4Enabled 0x0004
#define kNtIpAdapterReceiveOnly 0x0008
#define kNtIpAdapterNoMulticast 0x0010
#define kNtIpAdapterIpv6OtherStatefulConfig 0x0020
#define kNtIpAdapterNetbiosOverTcpipEnabled 0x0040
#define kNtIpAdapterIpv4Enabled 0x0080
#define kNtIpAdapterIpv6Enabled 0x0100
#define kNtIpAdapterIpv6Managed 0x0200
#define kNtIpPrefixOriginOther 0
#define kNtIpPrefixOriginManual 1
#define kNtIpPrefixOriginWellKnown 2
#define kNtIpPrefixOriginDhcp 3
#define kNtIpPrefixOriginRouterAdvertisement 4
#define kNtIpPrefixOriginUnchanged 16
#define kNtIpSuffixOriginOther 0
#define kNtIpSuffixOriginManual 1
#define kNtIpSuffixOriginWellKnown 2
#define kNtIpSuffixOriginDhcp 3
#define kNtIpSuffixOriginLinkLayerAddress 4
#define kNtIpSuffixOriginRandom 5
#define kNtIpSuffixOriginUnchanged 16
#define kNtIpDadStateInvalid 0
#define kNtIpDadStateTentative 1
#define kNtIpDadStateDuplicate 2
#define kNtIpDadStateDeprecated 3
#define kNtIpDadStatePreferred 4
#define kNtIfOperStatusUp 1
#define kNtIfOperStatusDown 2
#define kNtIfOperStatusTesting 3
#define kNtIfOperStatusUnknown 4
#define kNtIfOperStatusDormant 5
#define kNtIfOperStatusNotPresent 6
#define kNtIfOperStatusLowerLayerDown 7
#define kNtNetIfConnectionDedicated 1
#define kNtNetIfConnectionPassive 2
#define kNtNetIfConnectionDemand 3
#define kNtNetIfConnectionMaximum 4
#define kNtTunnelTypeNone 0
#define kNtTunnelTypeOther 1
#define kNtTunnelTypeDirect 2
#define kNtTunnelType6to4 11
#define kNtTunnelTypeIsatap 13
#define kNtTunnelTypeTeredo 14
#define kNtTunnelTypeIphttps 15
COSMOPOLITAN_C_START_
/* Inner Types --------------------------------------------------------- */
struct NtIpAdapterUnicastAddress {
uint32_t Length;
uint32_t Flags;
struct NtIpAdapterUnicastAddress *Next;
struct NtSocketAddress Address;
uint32_t PrefixOrigin; /* kNtIpPrefixOrigin... */
uint32_t SuffixOrigin; /* kNtIpSuffixOrigin... */
uint32_t DadState; /* kNtIpDadState... */
uint32_t ValidLifetime;
uint32_t PreferredLifetime;
uint32_t LeaseLifetime;
uint8_t OnLinkPrefixLength;
};
struct NtIpAdapterAnycastAddress {
uint32_t Length;
uint32_t Flags;
struct NtIpAdapterAnycastAddress *Next;
struct NtSocketAddress Address;
};
struct NtIpAdapterMulticastAddress {
uint32_t Length;
uint32_t Flags;
struct NtIpAdapterMulticastAddress *Next;
struct NtSocketAddress Address;
};
struct NtIpAdapterDnsServerAddress {
uint32_t Length;
uint32_t Reserved;
struct NtIpAdapterDnsServerAddress *Next;
struct NtSocketAddress Address;
};
struct NtIpAdapterPrefix {
uint32_t Length;
uint32_t Flags;
struct NtIpAdapterPrefix *Next;
struct NtSocketAddress Address;
uint32_t PrefixLength;
};
struct NtIpAdapterWinsServerAddress {
uint32_t Length;
uint32_t Reserved;
struct NtIpAdapterWinsServerAddress *Next;
struct NtSocketAddress Address;
};
struct NtIpAdapterGatewayAddress {
uint32_t Length;
uint32_t Reserved;
struct NtIpAdapterGatewayAddress *Next;
struct NtSocketAddress Address;
};
struct NtIpAdapterDnsSuffix {
struct NtIpAdapterDnsSuffix *Next;
uint16_t String[kNtMaxDnsSuffixStringLength];
};
/* Top level ----------------------------------------------------------- */
struct NtIpAdapterAddresses {
uint32_t Length;
uint32_t IfIndex;
struct NtIpAdapterAddresses *Next;
char *AdapterName;
struct NtIpAdapterUnicastAddress *FirstUnicastAddress;
struct NtIpAdapterAnycastAddress *FirstAnycastAddress;
struct NtIpAdapterMulticastAddress *FirstMulticastAddress;
struct NtIpAdapterDnsServerAddress *FirstDnsServerAddress;
uint16_t *DnsSuffix;
uint16_t *Description;
uint16_t *FriendlyName;
uint8_t PhysicalAddress[kNtMaxAdapterAddressLength];
uint32_t PhysicalAddressLength;
uint32_t Flags; /* kNtIpAdapter... */
uint32_t Mtu;
uint32_t IfType; /* kNtIfType... */
uint32_t OperStatus; /* kNtIfOperStatus... */
uint32_t Ipv6IfIndex;
uint32_t ZoneIndices[16];
struct NtIpAdapterPrefix *FirstPrefix;
uint64_t TransmitLinkSpeed;
uint64_t ReceiveLinkSpeed;
struct NtIpAdapterWinsServerAddress *FirstWinsServerAddress;
struct NtIpAdapterGatewayAddress *FirstGatewayAddress;
uint32_t Ipv4Metric;
uint32_t Ipv6Metric;
uint64_t Luid; /* reserved(24bits),NetLuidIndex(24b),IfType(16b) */
struct NtSocketAddress Dhcpv4Server;
uint32_t CompartmentId;
struct NtGuid NetworkGuid;
uint32_t ConnectionType; /* kNtNetIfConnection... */
uint32_t TunnelType; /* kNtTunnelType... */
struct NtSocketAddress Dhcpv6Server;
uint8_t Dhcpv6ClientDuid[kNtMaxDhcpv6DuidLength];
uint32_t Dhcpv6ClientDuidLength;
uint32_t Dhcpv6Iaid;
struct NtIpAdapterDnsSuffix *FirstDnsSuffix;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/kernelusertimes.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_KERNELUSERTIMES_H_
struct NtKernelUserTimes {
uint64_t CreateFileTime;
uint64_t ExitFileTime;
int64_t KernelTime;
int64_t UserTime;
};
/*!BEGIN libc/nt/struct/ldr.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_LDR_H_
struct NtLdr {
uint32_t SizeOfThis; /* msdn:reserved */
uint32_t IsInitialized; /* msdn:reserved */
void *SsHandle; /* msdn:reserved */
struct NtLinkedList InLoadOrderModuleList; /* msdn:reserved */
struct NtLinkedList /*∩NtLdrDataTableEntry*/ InMemoryOrderModuleList;
struct NtLinkedList InInitOrderModuleList; /* msdn:reserved */
};
/*!BEGIN libc/nt/struct/ldrdatatableentry.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_LDRDATATABLEENTRY_H_
/*!BEGIN libc/nt/struct/unicodestring.h */
#define COSMOPOLITAN_LIBC_NT_UNICODE_H_
struct NtUnicodeString {
uint16_t Length;
uint16_t MaxLength;
char16_t *Data;
};
struct NtLdrDataTableEntry {
struct NtLinkedList InLoadOrderLinks; /* msdn:reserved */
struct NtLinkedList InMemoryOrderLinks;
struct NtLinkedList InInitOrderLinks; /* msdn:reserved */
void *DllBase;
void *EntryPoint;
union {
uint32_t SizeOfImage;
unsigned char SizeOfImagePadding[__SIZEOF_POINTER__];
};
struct NtUnicodeString FullDllName;
struct NtUnicodeString BaseDllName;
uint32_t Flags;
uint16_t Load_Count;
uint16_t TlsIndex;
union {
struct NtLinkedList HashLinks;
struct {
void *SectionPointer;
uint32_t CheckSum;
};
};
union {
void *LoadedImports;
uint32_t TimeDateStamp;
};
void *EntryPointActivationContext;
void *PatchInformation;
struct NtLinkedList ForwarderLinks;
struct NtLinkedList ServiceTagLinks;
struct NtLinkedList StaticLinks;
void *ContextInformation;
uintptr_t OriginalBase;
int64_t LoadTime;
};
/*!BEGIN libc/nt/struct/linger.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_LINGER_H_
COSMOPOLITAN_C_START_
struct linger_nt {
uint16_t l_onoff; /* on/off */
uint16_t l_linger; /* seconds */
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/luid.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_LUID_H_
struct NtLuid {
uint32_t LowPart;
int32_t HighPart;
};
/*!BEGIN libc/nt/struct/luidandattributes.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_LUIDANDATTRIBUTES_H_
struct NtLuidAndAttributes {
struct NtLuid Luid;
uint32_t Attributes;
};
/*!BEGIN libc/nt/struct/memextendedparameter.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_MEMEXTENDEDPARAMETER_H_
#define kNtMemExtendedParameterTypeBits 8
#define kNtMemExtendedParameterInvalidType 0
#define kNtMemExtendedParameterAddressRequirements 1
#define kNtMemExtendedParameterNumaNode 2
#define kNtMemExtendedParameterPartitionHandle 3
#define kNtMemExtendedParameterUserPhysicalHandle 4
#define kNtMemExtendedParameterAttributeFlags 5
#define kNtMemExtendedParameterMax 6
#define kNtMemExtendedParameterGraphics 0x00000001
#define kNtMemExtendedParameterNonpaged 0x00000002
#define kNtMemExtendedParameterZeroPagesOptional 0x00000004
#define kNtMemExtendedParameterNonpagedLarge 0x00000008
#define kNtMemExtendedParameterNonpagedHuge 0x00000010
struct NtMemExtendedParameter {
struct {
uint64_t Type : kNtMemExtendedParameterTypeBits;
uint64_t Reserved : 64 - kNtMemExtendedParameterTypeBits;
} DUMMYSTRUCTNAME;
union {
uint64_t ULong64;
void *Pointer;
size_t Size;
intptr_t Handle;
unsigned ULong;
} DUMMYUNIONNAME;
};
/*!BEGIN libc/nt/struct/memorybasicinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_MEMORYBASICINFORMATION_H_
struct NtMemoryBasicInformation {
void *BaseAddress;
void *AllocationBase;
uint32_t AllocationProtect;
uint64_t RegionSize;
uint32_t State;
uint32_t Protect;
uint32_t Type;
};
/*!BEGIN libc/nt/struct/memoryrangeentry.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_MEMORYRANGEENTRY_H_
struct NtMemoryRangeEntry {
void *VirtualAddress;
size_t NumberOfBytes;
};
/*!BEGIN libc/nt/struct/memorystatusex.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_MEMORYSTATUSEX_H_
struct NtMemoryStatusEx {
uint32_t dwLength;
uint32_t dwMemoryLoad;
uint64_t ullTotalPhys;
uint64_t ullAvailPhys;
uint64_t ullTotalPageFile;
uint64_t ullAvailPageFile;
uint64_t ullTotalVirtual;
uint64_t ullAvailVirtual;
uint64_t ullAvailExtendedVirtual;
};
/*!BEGIN libc/nt/struct/msg.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_MSG_H_
/*!BEGIN libc/nt/struct/point.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_POINT_H_
struct NtPoint {
int32_t x;
int32_t y;
};
struct NtMsg {
int64_t hwnd;
uint32_t dwMessage;
uint64_t wParam;
int64_t lParam;
uint32_t dwTime;
struct NtPoint pt;
};
/*!BEGIN libc/nt/struct/nonpageddebuginfo.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_NONPAGEDDEBUGINFO_H_
struct NtNonPagedDebugInfo {
uint16_t Signature;
uint16_t Flags;
uint32_t Size;
uint16_t Machine;
uint16_t Characteristics;
uint32_t TimeDateStamp;
uint32_t CheckSum;
uint32_t SizeOfImage;
uint64_t ImageBase;
};
/*!BEGIN libc/nt/struct/ntexceptionpointers.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_NTEXCEPTIONPOINTERS_H_
/*!BEGIN libc/nt/struct/ntexceptionrecord.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_NTEXCEPTIONRECORD_H_
#define kNtExceptionMaximumParameters 15
#define kNtExceptionNoncontinuable 1
struct NtExceptionRecord {
uint32_t ExceptionCode; /* kNtException... */
uint32_t ExceptionFlags; /* kNtExceptionNoncontinuable */
struct NtExceptionRecord *ExceptionRecord; /* nested exceptions */
void *ExceptionAddress; /* %rip */
uint32_t NumberParameters; /* #ExceptionInformation */
uint64_t ExceptionInformation[kNtExceptionMaximumParameters];
};
struct NtExceptionPointers {
struct NtExceptionRecord *ExceptionRecord;
struct NtContext *ContextRecord;
};
/*!BEGIN libc/nt/struct/objectallinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_OBJECTALLINFORMATION_H_
/*!BEGIN libc/nt/struct/objecttypeinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_OBJECTTYPEINFORMATION_H_
struct NtObjectTypeInformation {
struct NtUnicodeString TypeName;
uint32_t TotalNumberOfObjects;
uint32_t TotalNumberOfHandles;
uint32_t TotalPagedPoolUsage;
uint32_t TotalNonPagedPoolUsage;
uint32_t TotalNamePoolUsage;
uint32_t TotalHandleTableUsage;
uint32_t HighWaterNumberOfObjects;
uint32_t HighWaterNumberOfHandles;
uint32_t HighWaterPagedPoolUsage;
uint32_t HighWaterNonPagedPoolUsage;
uint32_t HighWaterNamePoolUsage;
uint32_t HighWaterHandleTableUsage;
uint32_t InvalidAttributes;
struct NtGenericMapping GenericMapping;
uint32_t ValidAccessMask;
bool32 SecurityRequired;
bool32 MaintainHandleCount;
uint32_t PoolType;
uint32_t DefaultPagedPoolCharge;
uint32_t DefaultNonPagedPoolCharge;
};
struct NtObjectAllInformation {
uint32_t NumberOfObjects;
struct NtObjectTypeInformation ObjectTypeInformation[1];
};
/*!BEGIN libc/nt/struct/objectattributes.h */
#define COSMOPOLITAN_LIBC_NT_I_OBJECTATTRIBUTES_H_
/*!BEGIN libc/nt/struct/rtluserprocessparameters.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_RTLUSERPROCESSPARAMETERS_H_
struct NtRtlUserProcessParameters {
uint32_t MaximumLength;
uint32_t Length;
uint32_t Flags;
uint32_t DebugFlags;
int64_t ConsoleHandle;
uint32_t ConsoleFlags;
int64_t StdInputHandle;
int64_t StdOutputHandle;
int64_t StdErrorHandle;
struct NtUnicodeString *CurrentDirectoryPath;
int64_t CurrentDirectoryHandle;
struct NtUnicodeString *DllPath;
struct NtUnicodeString *ImagePathName;
struct NtUnicodeString *CommandLine;
void *Environment;
uint32_t StartingPositionLeft;
uint32_t StartingPositionTop;
uint32_t Width;
uint32_t Height;
uint32_t CharWidth;
uint32_t CharHeight;
uint32_t ConsoleTextAttributes;
uint32_t WindowFlags;
uint32_t ShowWindowFlags;
struct NtUnicodeString *WindowTitle;
struct NtUnicodeString *DesktopName;
struct NtUnicodeString *ShellInfo;
struct NtUnicodeString *RuntimeData;
};
/*!BEGIN libc/nt/struct/securityattributes.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SECURITYATTRIBUTES_H_
/*!BEGIN libc/nt/struct/securitydescriptor.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SECURITYDESCRIPTOR_H_
struct NtSecurityDescriptor {
uint8_t Revision;
uint8_t Sbz1;
uint16_t Control;
void *Owner;
void *Group;
struct NtAcl *Sacl;
struct NtAcl *Dacl;
};
struct NtSecurityAttributes {
uint32_t nLength;
struct NtSecurityDescriptor *lpSecurityDescriptor;
bool32 bInheritHandle;
};
const char *DescribeNtSecurityAttributes(char[32],
const struct NtSecurityAttributes *);
#define DescribeNtSecurityAttributes(x) \
DescribeNtSecurityAttributes(alloca(32), x)
struct NtObjectAttributes {
uint32_t Length;
int64_t RootDirectory;
const struct NtUnicodeString *ObjectName;
uint32_t Attributes; /* OBJ_INHERIT, etc. */
struct NtSecurityDescriptor *SecurityDescriptor;
void *SecurityQualityOfService;
};
/*!BEGIN libc/nt/struct/objectbasicinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_OBJECTBASICINFORMATION_H_
struct NtObjectBasicInformation {
uint32_t Attributes;
uint32_t GrantedAccess;
uint32_t HandleCount;
uint32_t PointerCount;
uint32_t PagedPoolUsage;
uint32_t NonPagedPoolUsage;
uint32_t Reserved[3];
uint32_t NameInformationLength;
uint32_t TypeInformationLength;
uint32_t SecurityDescriptorLength;
int64_t CreateTime;
};
/*!BEGIN libc/nt/struct/objectnameinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_OBJECTNAMEINFORMATION_H_
struct NtObjectNameInformation {
struct NtUnicodeString Name;
};
/*!BEGIN libc/nt/struct/openfilename.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_OPENFILENAME_H_
struct NtOpenFilename {
uint32_t lStructSize;
int64_t hwndOwner;
int64_t hInstance;
const char16_t *lpstrFilter;
char16_t *lpstrCustomFilter;
uint32_t nMaxCustFilter;
uint32_t nFilterIndex;
char16_t *lpstrFile;
uint32_t nMaxFile;
char16_t *lpstrFileTitle;
uint32_t nMaxFileTitle;
const char16_t *lpstrInitialDir;
const char16_t *lpstrTitle;
uint32_t Flags;
uint16_t nFileOffset;
uint16_t nFileExtension;
const char16_t *lpstrDefExt;
intptr_t lCustData;
uint64_t (*lpfnHook)(int64_t, uint32_t, uint64_t, int64_t);
const char16_t *lpTemplateName;
void *pvReserved;
uint32_t dwReserved;
uint32_t FlagsEx;
};
/*!BEGIN libc/nt/struct/osversioninfo.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_OSVERSIONINFO_H_
COSMOPOLITAN_C_START_
struct NtOsVersionInfo {
uint32_t dwOSVersionInfoSize;
uint32_t dwMajorVersion;
uint32_t dwMinorVersion;
uint32_t dwBuildNumber;
uint32_t dwPlatformId;
char16_t szCSDVersion[128];
uint16_t wServicePackMajor;
uint16_t wServicePackMinor;
uint16_t wSuiteMask;
uint8_t wProductType;
uint8_t wReserved;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/overlappedentry.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_OVERLAPPEDENTRY_H_
COSMOPOLITAN_C_START_
struct NtOverlappedEntry {
uint64_t lpCompletionKey;
struct NtOverlapped *lpOverlapped;
uint32_t *Internal;
uint32_t dwNumberOfBytesTransferred;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/paintstruct.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_PAINTSTRUCT_H_
/*!BEGIN libc/nt/struct/rect.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_RECT_H_
struct NtRect {
int32_t left;
int32_t top;
int32_t right;
int32_t bottom;
};
struct NtPaintStruct {
int64_t hdc;
bool32 fErase;
struct NtRect rcPaint;
bool32 fRestore;
bool32 fIncUpdate;
uint8_t rgbReserved[32];
};
/*!BEGIN libc/nt/struct/pdhfmtcountervalue.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_PDHFMTCOUNTERVALUE_H_
COSMOPOLITAN_C_START_
struct NtPdhFmtCountervalue {
uint32_t CStatus;
union {
int32_t longValue;
double doubleValue;
int64_t largeValue;
const char *AnsiStringValue;
const char16_t *WideStringValue;
};
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/peb.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_PEB_H_
struct NtPeb {
union {
struct {
unsigned char InheritedAddressSpace;
unsigned char ReadImageFileExecOptions;
unsigned char BeingDebugged;
unsigned char __wut1;
};
uint64_t __wut2;
};
uint64_t Mutant;
uint64_t ImageBaseAddress;
struct NtLdr *Ldr;
uint64_t ProcessParameters;
uint64_t SubSystemData;
uint64_t ProcessHeap;
uint64_t FastPebLock;
uint64_t __wut3;
uint64_t __wut4;
uint64_t __wut5;
union {
uint64_t KernelCallbackTable;
uint64_t UserSharedInfoPtr;
};
uint32_t SystemReserved;
uint32_t __wut6;
uint64_t __wut7;
uint64_t TlsExpansionCounter;
uint64_t TlsBitmap;
uint32_t TlsBitmapBits[2];
uint64_t ReadOnlySharedMemoryBase;
uint64_t __wut8;
uint64_t ReadOnlyStaticServerData;
uint64_t AnsiCodePageData;
uint64_t OemCodePageData;
uint64_t UnicodeCaseTableData;
uint32_t NumberOfProcessors;
#ifdef __x86_64__
uint32_t NtGlobalFlag;
#else
uint64_t NtGlobalFlag;
#endif
int64_t CriticalSectionTimeout;
uint64_t HeapSegmentReserve;
uint64_t HeapSegmentCommit;
uint64_t HeapDeCommitTotalFreeThreshold;
uint64_t HeapDeCommitFreeBlockThreshold;
uint32_t NumberOfHeaps;
uint32_t MaximumNumberOfHeaps;
uint64_t ProcessHeaps;
uint64_t GdiSharedHandleTable;
uint64_t ProcessStarterHelper;
uint64_t GdiDCAttributeList;
uint64_t LoaderLock;
union {
struct {
uint32_t OSMajorVersion;
uint32_t OSMinorVersion;
};
uint64_t OSVersion;
};
uint16_t OSBuildNumber;
uint16_t OSCSDVersion;
uint32_t OSPlatformId;
uint32_t ImageSubsystem;
uint32_t ImageSubsystemMajorVersion;
uint64_t ImageSubsystemMinorVersion;
union {
uint64_t ImageProcessAffinityMask;
uint64_t ActiveProcessAffinityMask;
};
uint64_t GdiHandleBuffer[38 - __SIZEOF_POINTER__];
uint64_t PostProcessInitRoutine;
uint64_t TlsExpansionBitmap;
uint32_t TlsExpansionBitmapBits[32];
uint64_t SessionId;
uint64_t AppCompatFlags;
uint64_t AppCompatFlagsUser;
uint64_t pShimData;
uint64_t AppCompatInfo;
struct NtUnicodeString CSDVersion;
uint64_t ActivationContextData;
uint64_t ProcessAssemblyStorageMap;
uint64_t SystemDefaultActivationContextData;
uint64_t SystemAssemblyStorageMap;
uint64_t MinimumStackCommit;
};
/*!BEGIN libc/nt/struct/privilegeset.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_PRIVILEGESET_H_
struct NtPrivilegeSet {
uint32_t PrivilegeCount;
uint32_t Control;
struct NtLuidAndAttributes Privilege[1];
};
/*!BEGIN libc/nt/struct/processbasicinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_PROCESSBASICINFORMATION_H_
struct NtProcessBasicInformation {
int32_t ExitStatus;
struct NtPeb *PebBaseAddress;
uint32_t *AffinityMask;
int32_t BasePriority;
int64_t UniqueProcessId;
int64_t InheritedFromUniqueProcessId;
};
/*!BEGIN libc/nt/struct/processentry32.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_PROCESSENTRY32_H_
struct NtProcessEntry32 {
uint32_t dwSize;
uint32_t cntUsage; /* unused */
uint32_t th32ProcessID;
uint64_t th32DefaultHeapID; /* unused */
uint32_t th32ModuleID; /* unused */
uint32_t cntThreads;
uint32_t th32ParentProcessID;
int32_t cPriClassBase;
uint32_t dwFlags; /* unused */
char16_t szExeFile[260];
};
/*!BEGIN libc/nt/struct/processinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_PROCESSINFORMATION_H_
struct NtProcessInformation {
int64_t hProcess;
int64_t hThread;
uint32_t dwProcessId;
uint32_t dwThreadId;
};
/*!BEGIN libc/nt/struct/processmemorycounters.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_PROCESSMEMORYCOUNTERS_H_
COSMOPOLITAN_C_START_
struct NtProcessMemoryCountersEx {
uint32_t cb; /* count bytes */
uint32_t PageFaultCount;
uint64_t PeakWorkingSetSize;
uint64_t WorkingSetSize;
uint64_t QuotaPeakPagedPoolUsage;
uint64_t QuotaPagedPoolUsage;
uint64_t QuotaPeakNonPagedPoolUsage;
uint64_t QuotaNonPagedPoolUsage;
uint64_t PagefileUsage;
uint64_t PeakPagefileUsage;
uint64_t PrivateUsage;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/processornumber.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_PROCESSORNUMBER_H_
COSMOPOLITAN_C_START_
struct NtProcessorNumber {
uint16_t Group;
uint8_t Number;
uint8_t Reserved;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/procthreadattributelist.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_PROCTHREADATTRIBUTELIST_H_
struct NtProcThreadAttributeList;
/*!BEGIN libc/nt/struct/reparsedatabuffer.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_REPARSEDATABUFFER_H_
COSMOPOLITAN_C_START_
struct NtReparseDataBuffer {
uint32_t ReparseTag;
uint16_t ReparseDataLength;
uint16_t Reserved;
union {
struct {
uint16_t SubstituteNameOffset;
uint16_t SubstituteNameLength;
uint16_t PrintNameOffset;
uint16_t PrintNameLength;
uint32_t Flags;
char16_t PathBuffer[1];
} SymbolicLinkReparseBuffer;
struct {
uint16_t SubstituteNameOffset;
uint16_t SubstituteNameLength;
uint16_t PrintNameOffset;
uint16_t PrintNameLength;
char16_t PathBuffer[1];
} MountPointReparseBuffer;
struct {
uint8_t DataBuffer[1];
} GenericReparseBuffer;
};
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/rtluserprocessinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_RTLUSERPROCESSINFORMATION_H_
/*!BEGIN libc/nt/struct/sectionimageinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SECTIONIMAGEINFORMATION_H_
struct NtSectionImageInformation {
void *EntryPoint;
uint32_t Unknown1;
uint32_t StackReserve;
uint32_t StackCommit;
uint32_t Subsystem;
uint16_t MinorSubsystemVersion;
uint16_t MajorSubsystemVersion;
uint32_t Unknown2;
uint32_t Characteristics;
uint16_t ImageNumber;
uint32_t IsExecutable;
uint8_t __wut1;
uint32_t __wut2[3];
};
struct NtRtlUserProcessInformation {
uint32_t SizeOfThis;
int64_t ProcessHandle;
int64_t ThreadHandle;
struct NtClientId ClientId;
struct NtSectionImageInformation ImageInformation;
};
/*!BEGIN libc/nt/struct/size.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SIZE_H_
COSMOPOLITAN_C_START_
struct NtSize {
int32_t cx;
int32_t cy;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/startupinfo.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_STARTUPINFO_H_
struct NtStartupInfo {
uint32_t cb /* = sizeof(struct NtStartupInfo) */;
uint16_t *lpReserved;
char16_t *lpDesktop;
char16_t *lpTitle; /* title of *new* console window only */
uint32_t dwX; /* position of window on screen */
uint32_t dwY;
uint32_t dwXSize;
uint32_t dwYSize;
uint32_t dwXCountChars; /* used to dimension the dos terminal */
uint32_t dwYCountChars;
uint32_t dwFillAttribute;
uint32_t dwFlags;
uint16_t wShowWindow;
uint16_t cbReserved2;
uint8_t *lpReserved2;
union {
struct {
int64_t hStdInput;
int64_t hStdOutput;
int64_t hStdError;
};
int64_t stdiofds[3];
};
};
/*!BEGIN libc/nt/struct/startupinfoex.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_STARTUPINFOEX_H_
struct NtStartupInfoEx {
struct NtStartupInfo StartupInfo;
struct NtProcThreadAttributeList *lpAttributeList;
};
/*!BEGIN libc/nt/struct/systembasicinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMBASICINFORMATION_H_
struct NtSystemBasicInformation {
unsigned char Reserved1[4];
uint32_t MaximumIncrement;
uint32_t PhysicalPageSize;
uint32_t NumberOfPhysicalPages;
uint32_t LowestPhysicalPage;
uint32_t HighestPhysicalPage;
uint32_t AllocationGranularity;
uint32_t LowestUserAddress;
uint32_t HighestUserAddress;
uint32_t ActiveProcessors;
char NumberOfProcessors;
};
/*!BEGIN libc/nt/struct/systemexceptioninformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMEXCEPTIONINFORMATION_H_
struct NtSystemExceptionInformation {
unsigned char Reserved1[16];
};
/*!BEGIN libc/nt/struct/systemhandleentry.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMHANDLEENTRY_H_
struct NtSystemHandleEntry {
uint32_t OwnerPid;
unsigned char ObjectType;
unsigned char HandleFlags;
unsigned short HandleValue;
void *ObjectPointer;
uint32_t AccessMask;
};
/*!BEGIN libc/nt/struct/systemhandleinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMHANDLEINFORMATION_H_
struct NtSystemHandleInformation {
uint32_t Count;
struct NtSystemHandleEntry Handle[1];
};
/*!BEGIN libc/nt/struct/systeminfo.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMINFO_H_
struct NtSystemInfo {
union {
uint32_t dwOemId;
struct {
uint16_t wProcessorArchitecture;
uint16_t wReserved;
};
};
uint32_t dwPageSize;
void *lpMinimumApplicationAddress;
void *lpMaximumApplicationAddress;
uintptr_t dwActiveProcessorMask;
uint32_t dwNumberOfProcessors;
uint32_t dwProcessorType;
uint32_t dwAllocationGranularity;
uint16_t wProcessorLevel;
uint16_t wProcessorRevision;
};
/*!BEGIN libc/nt/struct/systeminterruptinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMINTERRUPTINFORMATION_H_
struct NtSystemInterruptInformation {
unsigned char Reserved1[24];
};
/*!BEGIN libc/nt/struct/systemlookasideinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMLOOKASIDEINFORMATION_H_
struct NtSystemLookasideInformation {
unsigned char Reserved1[32];
};
/*!BEGIN libc/nt/struct/systemperformanceinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMPERFORMANCEINFORMATION_H_
struct NtSystemPerformanceInformation {
int64_t IdleTime;
int64_t ReadTransferCount;
int64_t WriteTransferCount;
int64_t OtherTransferCount;
uint32_t ReadOperationCount;
uint32_t WriteOperationCount;
uint32_t OtherOperationCount;
uint32_t AvailablePages;
uint32_t TotalCommittedPages;
uint32_t TotalCommitLimit;
uint32_t PeakCommitment;
uint32_t PageFaults;
uint32_t WriteCopyFaults;
uint32_t TransitionFaults;
uint32_t CacheTransitionFaults;
uint32_t DemandZeroFaults;
uint32_t PagesRead;
uint32_t PageReadIos;
uint32_t CacheReads;
uint32_t CacheIos;
uint32_t PagefilePagesWritten;
uint32_t PagefilePageWriteIos;
uint32_t MappedFilePagesWritten;
uint32_t MappedFilePageWriteIos;
uint32_t PagedPoolUsage;
uint32_t NonPagedPoolUsage;
uint32_t PagedPoolAllocs;
uint32_t PagedPoolFrees;
uint32_t NonPagedPoolAllocs;
uint32_t NonPagedPoolFrees;
uint32_t TotalFreeSystemPtes;
uint32_t SystemCodePage;
uint32_t TotalSystemDriverPages;
uint32_t TotalSystemCodePages;
uint32_t SmallNonPagedLookasideListAllocateHits;
uint32_t SmallPagedLookasideListAllocateHits;
uint32_t Reserved3;
uint32_t MmSystemCachePage;
uint32_t PagedPoolPage;
uint32_t SystemDriverPage;
uint32_t FastReadNoWait;
uint32_t FastReadWait;
uint32_t FastReadResourceMiss;
uint32_t FastReadNotPossible;
uint32_t FastMdlReadNoWait;
uint32_t FastMdlReadWait;
uint32_t FastMdlReadResourceMiss;
uint32_t FastMdlReadNotPossible;
uint32_t MapDataNoWait;
uint32_t MapDataWait;
uint32_t MapDataNoWaitMiss;
uint32_t MapDataWaitMiss;
uint32_t PinMappedDataCount;
uint32_t PinReadNoWait;
uint32_t PinReadWait;
uint32_t PinReadNoWaitMiss;
uint32_t PinReadWaitMiss;
uint32_t CopyReadNoWait;
uint32_t CopyReadWait;
uint32_t CopyReadNoWaitMiss;
uint32_t CopyReadWaitMiss;
uint32_t MdlReadNoWait;
uint32_t MdlReadWait;
uint32_t MdlReadNoWaitMiss;
uint32_t MdlReadWaitMiss;
uint32_t ReadAheadIos;
uint32_t LazyWriteIos;
uint32_t LazyWritePages;
uint32_t DataFlushes;
uint32_t DataPages;
uint32_t ContextSwitches;
uint32_t FirstLevelTbFills;
uint32_t SecondLevelTbFills;
uint32_t SystemCalls;
};
/*!BEGIN libc/nt/struct/systemprocessinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMPROCESSINFORMATION_H_
/*!BEGIN libc/nt/struct/vmcounters.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_VMCOUNTERS_H_
struct NtVmCounters {
size_t PeakVirtualSize;
size_t VirtualSize;
uint32_t PageFaultCount;
size_t PeakWorkingSetSize;
size_t WorkingSetSize;
size_t QuotaPeakPagedPoolUsage;
size_t QuotaPagedPoolUsage;
size_t QuotaPeakNonPagedPoolUsage;
size_t QuotaNonPagedPoolUsage;
size_t PagefileUsage;
size_t PeakPagefileUsage;
};
struct NtSystemProcessInformation {
uint32_t NextEntryOffset;
uint32_t NumberOfThreads;
int64_t Reserved[3];
int64_t CreateTime;
int64_t UserTime;
int64_t KernelTime;
struct NtUnicodeString ImageName;
int32_t BasePriority;
int64_t UniqueProcessId;
int64_t InheritedFromUniqueProcessId;
uint32_t HandleCount;
uint32_t SessionId;
uint32_t PageDirectoryBase;
struct NtVmCounters VirtualMemoryCounters;
size_t PrivatePageCount;
struct NtIoCounters IoCounters;
};
/*!BEGIN libc/nt/struct/systemprocessorinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMPROCESSORINFORMATION_H_
struct NtSystemProcessorInformation {
unsigned short ProcessorArchitecture;
unsigned short ProcessorLevel;
unsigned short ProcessorRevision;
unsigned short Unknown;
uint32_t FeatureBits;
};
/*!BEGIN libc/nt/struct/systemprocessorperformanceinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMPROCESSORPERFORMANCEINFORMATION_H_
struct NtSystemProcessorPerformanceInformation {
int64_t IdleTime;
int64_t KernelTime;
int64_t UserTime;
int64_t Reserved1[2];
uint32_t Reserved2;
};
/*!BEGIN libc/nt/struct/systemregistryquotainformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMREGISTRYQUOTAINFORMATION_H_
struct NtSystemRegistryQuotaInformation {
uint32_t RegistryQuotaAllowed;
uint32_t RegistryQuotaUsed;
void *Reserved1;
};
/*!BEGIN libc/nt/struct/systemthreads.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMTHREADS_H_
struct NtSystemThreads {
int64_t KernelTime;
int64_t UserTime;
int64_t CreateTime;
uint32_t WaitTime;
void *StartAddress;
struct NtClientId ClientId;
int32_t Priority;
int32_t BasePriority;
uint32_t ContextSwitchCount;
int State;
uint32_t WaitReason;
};
/*!BEGIN libc/nt/struct/systemtimeofdayinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_SYSTEMTIMEOFDAYINFORMATION_H_
struct NtSystemTimeofdayInformation {
int64_t BootTime;
int64_t CurrentTime;
int64_t TimeZoneBias;
uint32_t CurrentTimeZoneId;
unsigned char Reserved1[20];
};
/*!BEGIN libc/nt/struct/teb.h */
#define COSMOPOLITAN_LIBC_NT_TEB_H_
#ifdef __GNUC__
/*
* These macros address directly into NT's TEB a.k.a. TIB
* Any function that does this needs the `dontasan` keyword
*/
#define NtGetPeb() ((__seg_gs struct NtPeb *)0x60)
#define NtGetTeb() ((void *)*(__seg_gs uintptr_t *)0x30)
#define NtGetPid() (*(__seg_gs uint32_t *)0x40)
#define NtGetTid() (*(__seg_gs uint32_t *)0x48)
#define NtGetErr() (*(__seg_gs int *)0x68)
#define _NtGetSeh() ((void *)*(__seg_gs uintptr_t *)0x00)
#define _NtGetStackHigh() ((void *)*(__seg_gs uintptr_t *)0x08)
#define _NtGetStackLow() ((void *)*(__seg_gs uintptr_t *)0x10)
#define _NtGetSubsystemTib() ((void *)*(__seg_gs uintptr_t *)0x18)
#define _NtGetFib() ((void *)*(__seg_gs uintptr_t *)0x20)
#define _NtGetEnv() ((char16_t *)*(__seg_gs intptr_t *)0x38)
#define _NtGetRpc() ((void *)*(__seg_gs uintptr_t *)0x50)
#define _NtGetTls() ((void *)*(__seg_gs uintptr_t *)0x58)
#endif /* __GNUC__ */
/*!BEGIN libc/nt/struct/timezoneinformation.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_TIMEZONEINFORMATION_H_
struct NtTimeZoneInformation {
int Bias; /* in minutes e.g. +480 for -8:00 */
char16_t StandardName[32]; /* e.g. "Pacific Standard Time" */
struct NtSystemTime StandardDate;
int StandardBias;
char16_t DaylightName[32]; /* e.g. "Pacific Daylight Time" */
struct NtSystemTime DaylightDate;
int DaylightBias; /* e.g. -60 */
};
/*!BEGIN libc/nt/struct/tokenprivileges.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_TOKENPRIVILEGES_H_
struct NtTokenPrivileges {
uint32_t PrivilegeCount;
struct NtLuidAndAttributes Privileges[1];
};
/*!BEGIN libc/nt/struct/userstack.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_NTUSERSTACK_H_
struct NtUserStack {
void *FixedStackBase;
void *FixedStackLimit;
void *ExpandableStackBase;
void *ExpandableStackLimit;
void *ExpandableStackBottom;
};
/*!BEGIN libc/nt/struct/valent.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_VALENT_H_
struct NtValent {
char16_t *ve_valuename;
uint32_t ve_valuelen;
uintptr_t ve_valueptr;
uint32_t ve_type;
};
/*!BEGIN libc/nt/struct/win32fileattributedata.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_WIN32FILEATTRIBUTEDATA_H_
struct NtWin32FileAttributeData {
uint32_t dwFileAttributes; /* ←NtFileFlagAndAttributes */
struct NtFileTime ftCreationTime;
struct NtFileTime ftLastAccessTime;
struct NtFileTime ftLastWriteTime;
uint32_t nFileSizeHigh;
uint32_t nFileSizeLow;
};
/*!BEGIN libc/nt/struct/win32finddata.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_WIN32FINDDATA_H_
struct NtWin32FindData {
uint32_t dwFileAttributes;
struct NtFileTime ftCreationTime;
struct NtFileTime ftLastAccessTime;
struct NtFileTime ftLastWriteTime;
uint32_t nFileSizeHigh;
uint32_t nFileSizeLow;
uint32_t dwReserved0;
uint32_t dwReserved1;
char16_t cFileName[260];
char16_t cAlternateFileName[14];
uint32_t dwFileType; /* obsolete */
uint32_t dwCreatorType; /* obsolete */
uint16_t wFinderFlags; /* obsolete */
};
/*!BEGIN libc/nt/struct/windowplacement.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_WINDOWPLACEMENT_H_
struct NtWindowPlacement {
uint32_t length;
uint32_t flags;
uint32_t showCmd;
struct NtPoint ptMinPosition;
struct NtPoint ptMaxPosition;
struct NtRect rcNormalPosition;
struct NtRect rcDevice;
};
/*!BEGIN libc/nt/struct/wndclass.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_WNDCLASS_H_
/*!BEGIN libc/nt/typedef/wndproc.h */
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_WNDPROC_H_
COSMOPOLITAN_C_START_
typedef int64_t (*NtWndProc)(int64_t, uint32_t, uint64_t, int64_t);
COSMOPOLITAN_C_END_
COSMOPOLITAN_C_START_
struct NtWndClass {
uint32_t style;
NtWndProc lpfnWndProc;
int32_t cbClsExtra;
int32_t cbWndExtra;
int64_t hInstance;
int64_t hIcon;
int64_t hCursor;
int64_t hbrBackground;
const char16_t *lpszMenuName;
const char16_t *lpszClassName;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/struct/wndclassex.h */
#define COSMOPOLITAN_LIBC_NT_STRUCT_WNDCLASSEX_H_
COSMOPOLITAN_C_START_
struct NtWndClassEx {
uint32_t cbSize;
uint32_t style;
NtWndProc lpfnWndProc;
int32_t cbClsExtra;
int32_t cbWndExtra;
int64_t hInstance;
int64_t hIcon;
int64_t hCursor;
int64_t hbrBackground;
const char16_t *lpszMenuName;
const char16_t *lpszClassName;
int64_t hIconSm;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/typedef/exceptionhandler.h */
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_EXCEPTIONHANDLER_H_
COSMOPOLITAN_C_START_
typedef unsigned (*NtExceptionHandler)(struct NtExceptionRecord *,
struct NtExceptionFrame *,
struct NtContext *, void *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/typedef/handlerroutine.h */
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_HANDLERROUTINE_H_
typedef bool32 (*NtHandlerRoutine)(uint32_t);
/*!BEGIN libc/nt/typedef/hookproc.h */
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_HOOKPROC_H_
typedef intptr_t (*NtHookProc)(int code, uintptr_t wParam, intptr_t lParam);
/*!BEGIN libc/nt/typedef/imagetlscallback.h */
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_IMAGETLSCALLBACK_H_
typedef void (*NtImageTlsCallback)(void *DllHandle, uint32_t Reason,
void *Reserved);
/*!BEGIN libc/nt/typedef/ioapcroutine.h */
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_IOAPCROUTINE_H_
typedef void (*NtIoApcRoutine)(void *ApcContext,
struct NtIoStatusBlock *IoStatusBlock,
uint32_t Reserved);
/*!BEGIN libc/nt/typedef/pknormalroutine.h */
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_PKNORMALROUTINE_H_
typedef void (*NtPkNormalRoutine)(void *NormalContext, void *SystemArgument1,
void *SystemArgument2);
/*!BEGIN libc/nt/typedef/timerproc.h */
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_TIMERPROC_H_
typedef void (*NtTimerProc)(int64_t, uint32_t, uintptr_t, uint32_t);
/*!BEGIN libc/nt/typedef/wambda.h */
#define COSMOPOLITAN_LIBC_NT_WAMBDA_H_
COSMOPOLITAN_C_START_
typedef intptr_t (*wambda)();
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/typedef/wndenumproc.h */
#define COSMOPOLITAN_LIBC_NT_TYPEDEF_WNDENUMPROC_H_
typedef int (*NtWndEnumProc)(int64_t foo, intptr_t bar);
/*!BEGIN libc/nt/nt/debug.h */
#define COSMOPOLITAN_LIBC_NT_NT_DEBUG_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale » debugging ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
NtStatus NtContinue(struct NtContext *Context, int32_t TestAlert);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/nt/file.h */
#define COSMOPOLITAN_LIBC_NT_NT_FILE_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale » files ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
struct NtIoStatusBlock;
struct NtObjectAttributes;
NtStatus NtClose(int64_t handle);
NtStatus NtCreateFile(int64_t *out_FileHandle, uint32_t DesiredAccess,
const struct NtObjectAttributes *ObjectAttributes,
struct NtIoStatusBlock *out_IoStatusBlock,
int64_t *opt_AllocationSize, uint32_t FileAttributes,
uint32_t ShareAccess, uint32_t CreateDisposition,
uint32_t CreateOptions, void *opt_EaBuffer,
uint32_t EaLength);
NtStatus NtReadFile(int64_t FileHandle, void *opt_Event,
NtIoApcRoutine opt_ApcRoutine, void *opt_ApcContext,
struct NtIoStatusBlock *out_IoStatusBlock, void *out_Buffer,
uint32_t Length, int64_t *opt_ByteOffset,
uint32_t *opt_Key);
NtStatus NtWriteFile(int64_t FileHandle, void *opt_Event,
NtIoApcRoutine opt_ApcRoutine, void *opt_ApcContext,
struct NtIoStatusBlock *out_IoStatusBlock,
const void *Buffer, uint32_t Length,
int64_t *opt_ByteOffset, uint32_t *opt_Key);
NtStatus NtDuplicateObject(int64_t SourceProcessHandle, void *SourceHandle,
void *TargetProcessHandle,
void **opt_out_TargetHandle, uint32_t DesiredAcess,
uint32_t Attributes, uint32_t options_t);
NtStatus NtQueryInformationFile(int64_t FileHandle,
struct NtIoStatusBlock *out_IoStatusBlock,
void *out_FileInformation,
uint32_t FileInformationLength,
uint32_t FileInformationClass);
NtStatus NtSetInformationFile(int64_t FileHandle,
struct NtIoStatusBlock *out_IoStatusBlock,
void *FileInformation,
uint32_t FileInformationLength,
uint32_t FileInformationClass);
NtStatus NtDeviceIoControlFile(
int64_t FileHandle, int64_t opt_Event, NtIoApcRoutine opt_ApcRoutine,
void *opt_ApcContext, struct NtIoStatusBlock *out_IoStatusBlock,
uint32_t IoControlCode, void *opt_InputBuffer, uint32_t InputBufferLength,
void *opt_out_OutputBuffer, uint32_t OutputBufferLength);
NtStatus NtCancelIoFileEx(int64_t FileHandle,
struct NtIoStatusBlock *IoRequestToCancel,
struct NtIoStatusBlock *IoStatusBlock);
NtStatus RtlNtStatusToDosError(NtStatus Status);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/ntfile.inc */
#define NtQueryInformationFile(...) __imp_NtQueryInformationFile(__VA_ARGS__)
extern typeof(NtQueryInformationFile) *const
__imp_NtQueryInformationFile __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/nt/ipc.h */
#define COSMOPOLITAN_LIBC_NT_NT_IPC_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale » ipc ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
struct NtIoStatusBlock;
struct NtObjectAttributes;
NtStatus NtCreateNamedPipeFile(int64_t *out_FileHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
struct NtIoStatusBlock *out_IoStatusBlock,
uint32_t ShareAccess, uint32_t CreateDisposition,
uint32_t CreateOptions, int32_t TypeMessage,
int32_t ReadmodeMessage, int32_t Nonblocking,
uint32_t MaxInstances, uint32_t InBufferSize,
uint32_t OutBufferSize,
int64_t *opt_DefaultTimeout);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/nt/key.h */
#define COSMOPOLITAN_LIBC_NT_NT_EVENT_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale » files ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
NtStatus NtCreateKeyedEvent(int64_t *KeyedEventHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
uint32_t Flags);
NtStatus NtReleaseKeyedEvent(int64_t KeyedEventHandle, void *KeyValue,
bool32 Alertable, int64_t *Timeout);
NtStatus NtWaitForKeyedEvent(int64_t KeyedEventHandle, void *KeyValue,
bool32 Alertable, int64_t *Timeout);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/nt/loader.h */
#define COSMOPOLITAN_LIBC_NT_NT_LOADER_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale » loader ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
struct NtAnsiString;
struct NtLdrDataTableEntry;
struct NtUnicodeString;
NtStatus LdrLoadDll(const char16_t *opt_PathToFile, uint32_t *opt_Flags,
struct NtUnicodeString *ModuleFileName,
void **out_ModuleHandle);
NtStatus LdrUnloadDll(void *ModuleHandle);
NtStatus LdrGetProcedureAddress(void *ModuleHandle,
struct NtAnsiString *opt_ProcedureName,
uint32_t opt_Ordinal,
wambda *out_ProcedureAddress);
NtStatus LdrGetDllHandle(const char16_t *opt_PathToFile, uint32_t opt_Unused,
struct NtUnicodeString *ModuleFileName,
void **out_ModuleHandle);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/nt/memory.h */
#define COSMOPOLITAN_LIBC_NT_NT_MEMORY_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale » memory ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
NtStatus NtAllocateVirtualMemory(int64_t ProcessHandle,
void **inout_BaseAddress, uint32_t dwZeroBits,
uint32_t *inout_AllocationSize,
uint32_t dwMemAllocationType,
uint32_t dwPageProtect);
NtStatus NtFreeVirtualMemory(int64_t ProcessHandle, void **inout_BaseAddress,
size_t *inout_FreeSize, uint32_t FreeType);
NtStatus NtQueryVirtualMemory(int64_t ProcessHandle, const void *BaseAddress,
int MemoryInformationClass,
void *out_MemoryInformation,
size_t MemoryInformationLength,
size_t *opt_out_ReturnLength);
NtStatus NtProtectVirtualMemory(int64_t ProcessHandle, void **inout_BaseAddress,
uint32_t *inout_ProtectSize,
uint32_t NewProtect, uint32_t *out_OldProtect);
NtStatus NtWriteVirtualMemory(int64_t ProcessHandle, void *BaseAddress,
const void *Buffer, size_t BufferLength,
size_t *opt_out_ReturnLength);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/nt/process.h */
#define COSMOPOLITAN_LIBC_NT_NT_PROCESS_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale » processes ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
struct NtClientId;
struct NtObjectAttributes;
struct NtRtlUserProcessInformation;
struct NtRtlUserProcessParameters;
struct NtSecurityDescriptor;
struct NtUnicodeString;
NtStatus NtCreateProcess(int64_t *out_ProcessHandle, uint32_t dwDesiredAccess,
struct NtObjectAttributes *opt_ObjectAttributes,
void *InheritFromProcessHandle, int32_t InheritHandles,
void *opt_SectionHandle, void *opt_DebugPort,
void *opt_ExceptionPort);
NtStatus NtTerminateProcess(int64_t opt_ProcessHandle, int32_t ExitStatus);
NtStatus NtQueryInformationProcess(int64_t ProcessHandle,
int ProcessInformationClass,
void *out_ProcessInformation,
uint32_t ProcessInformationLength,
uint32_t *opt_out_ReturnLength);
NtStatus NtOpenProcessToken(int64_t ProcessToken, uint32_t DesiredAccess,
int64_t *out_TokenHandle);
NtStatus NtOpenProcess(int64_t *out_ProcessHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
struct NtClientId *ClientId);
NtStatus RtlCreateProcessParameters(
struct NtRtlUserProcessParameters **out_ProcessParameters,
struct NtUnicodeString *ImageFile, struct NtUnicodeString *opt_DllPath,
struct NtUnicodeString *opt_CurrentDirectory,
struct NtUnicodeString *opt_CommandLine, uint32_t CreationFlags,
struct NtUnicodeString *opt_WindowTitle,
struct NtUnicodeString *opt_Desktop, struct NtUnicodeString *opt_Reserved,
struct NtUnicodeString *opt_Reserved2);
NtStatus RtlDestroyProcessParameters(
struct NtRtlUserProcessParameters *ProcessParameters);
NtStatus RtlCloneUserProcess(
uint32_t ProcessFlags,
struct NtSecurityDescriptor *opt_ProcessSecurityDescriptor,
struct NtSecurityDescriptor *opt_ThreadSecurityDescriptor,
void *opt_DebugPort,
struct NtRtlUserProcessInformation *ProcessInformation);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/nt/thunk/process.inc */
#define NtQueryInformationProcess(...) \
__imp_NtQueryInformationProcess(__VA_ARGS__)
extern typeof(NtQueryInformationProcess) *const
__imp_NtQueryInformationProcess __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/nt/sections.h */
#define COSMOPOLITAN_LIBC_NT_NT_SECTIONS_H_
COSMOPOLITAN_C_START_
NtStatus NtCreateSection(int64_t *out_SectionHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
int64_t *opt_SectionSize, uint32_t Protect,
uint32_t Attributes, int64_t FileHandle);
NtStatus NtOpenSection(int64_t *out_SectionHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes);
NtStatus NtMapViewOfSection(int64_t SectionHandle, int64_t ProcessHandle,
void **inout_BaseAddress, uint32_t *ZeroBits,
size_t CommitSize, int64_t *opt_inout_SectionOffset,
size_t *inout_ViewSize, int InheritDisposition,
uint32_t AllocationType, uint32_t Protect);
NtStatus NtUnmapViewOfSection(int64_t ProcessHandle, void *BaseAddress);
NtStatus NtQuerySection(int64_t SectionHandle, int SectionInformationClass,
void *out_SectionInformation,
uint32_t SectionInformationLength,
uint32_t *opt_out_ResultLength);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/nt/signing.h */
#define COSMOPOLITAN_LIBC_NT_NT_SIGNING_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale » code signing ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
NtStatus CsrClientCallServer(void *inout_Message, void *unknown,
uint32_t Opcode, uint32_t Size);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/nt/thread.h */
#define COSMOPOLITAN_LIBC_NT_NT_THREAD_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale » threads ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
struct NtClientId;
struct NtContext;
struct NtObjectAttributes;
struct NtUserStack;
NtStatus NtCreateThread(int64_t *out_ThreadHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
int64_t ProcessHandle, struct NtClientId *out_ClientId,
struct NtContext *ThreadContext,
struct NtUserStack *UserStack, int32_t CreateSuspended);
NtStatus NtTerminateThread(void *opt_ThreadHandle, int32_t ExitStatus);
NtStatus NtOpenThread(int64_t *out_ThreadHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
struct NtClientId *ClientId);
NtStatus NtQueryInformationThread(int64_t ThreadHandle,
enum NtThreadInfoClass ThreadInformationClass,
void *out_ThreadInformation,
uint32_t ThreadInformationLength,
uint32_t *opt_out_ReturnLength);
NtStatus NtGetContextThread(int64_t ThreadHandle,
struct NtContext *out_Context);
NtStatus NtSetContextThread(int64_t ThreadHandle, struct NtContext *Context);
NtStatus NtSuspendThread(int64_t ThreadHandle,
uint32_t *opt_out_PreviousSuspendCount);
NtStatus NtResumeThread(int64_t ThreadHandle,
uint32_t *opt_out_PreviousSuspendCount);
NtStatus NtOpenThreadToken(int64_t ThreadHandle, uint32_t DesiredAccess,
int32_t OpenAsSelf, int64_t *out_TokenHandle);
NtStatus NtSetInformationThread(int64_t ThreadHandle,
enum NtThreadInfoClass ThreadInformationClass,
void *ThreadInformation,
uint32_t ThreadInformationLength);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/nt/time.h */
#define COSMOPOLITAN_LIBC_NT_NT_THREAD_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale » time ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
NtStatus NtDelayExecution(bool32 alertable, int64_t *AbsCobolOrNegRelHectoNano);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/nt/thunk/time.inc */
#define NtDelayExecution(...) __imp_NtDelayExecution(__VA_ARGS__)
extern typeof(NtDelayExecution) *const __imp_NtDelayExecution __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/accounting.h */
#define COSMOPOLITAN_LIBC_NT_ACCOUNTING_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » accounting ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
uint32_t GetMaximumProcessorCount(uint16_t GroupNumber);
int GetUserName(char16_t (*buf)[257], uint32_t *in_out_size);
bool32 GlobalMemoryStatusEx(struct NtMemoryStatusEx *lpBuffer);
int32_t GetExitCodeProcess(int64_t hProcess, uint32_t *lpExitCode);
int32_t GetProcessHandleCount(int64_t hProcess, uint32_t *pdwHandleCount);
bool32 GetSystemTimes(struct NtFileTime *opt_out_lpIdleTime,
struct NtFileTime *opt_out_lpKernelTime,
struct NtFileTime *opt_out_lpUserTime);
bool32 GetProcessTimes(int64_t hProcess,
struct NtFileTime *out_lpCreationFileTime,
struct NtFileTime *out_lpExitFileTime,
struct NtFileTime *out_lpKernelFileTime,
struct NtFileTime *out_lpUserFileTime);
bool32 GetThreadTimes(int64_t hThread,
struct NtFileTime *out_lpCreationFileTime,
struct NtFileTime *out_lpExitFileTime,
struct NtFileTime *out_lpKernelFileTime,
struct NtFileTime *out_lpUserFileTime);
int32_t GetProcessIoCounters(int64_t hProcess,
struct NtIoCounters *lpIoCounters);
int32_t GetProcessWorkingSetSize(int64_t hProcess,
uint64_t *lpMinimumWorkingSetSize,
uint64_t *lpMaximumWorkingSetSize);
int32_t GetProcessWorkingSetSizeEx(int64_t hProcess,
uint64_t *lpMinimumWorkingSetSize,
uint64_t *lpMaximumWorkingSetSize,
uint32_t *Flags);
int32_t SetProcessWorkingSetSize(int64_t hProcess,
uint64_t dwMinimumWorkingSetSize,
uint64_t dwMaximumWorkingSetSize);
int32_t SetProcessWorkingSetSizeEx(int64_t hProcess,
uint64_t dwMinimumWorkingSetSize,
uint64_t dwMaximumWorkingSetSize,
uint32_t Flags);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/accounting.inc */
#define GetProcessTimes(...) __imp_GetProcessTimes(__VA_ARGS__)
extern typeof(GetProcessTimes) *const __imp_GetProcessTimes __msabi;
#define GetThreadTimes(...) __imp_GetThreadTimes(__VA_ARGS__)
extern typeof(GetThreadTimes) *const __imp_GetThreadTimes __msabi;
#define GetUserName(...) __imp_GetUserNameW(__VA_ARGS__)
extern typeof(GetUserName) *const __imp_GetUserNameW __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/automation.h */
#define COSMOPOLITAN_LIBC_NT_AUTOMATION_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » aol hacking ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
COSMOPOLITAN_C_START_
int64_t GetShellWindow(void);
int64_t GetDesktopWindow(void);
int64_t GetParent(int64_t hWnd);
int64_t SetParent(int64_t hWndChild, int64_t hWndNewParent);
int32_t EnumChildWindows(int64_t hWndParent, NtWndEnumProc lpEnumFunc,
intptr_t lParam);
int64_t FindWindow(const char16_t *lpClassName, const char16_t *lpWindowName);
int64_t FindWindowEx(int64_t hWndParent, int64_t hWndChildAfter,
const char16_t *lpszClass, const char16_t *lpszWindow);
int64_t GetWindow(int64_t hWnd, uint32_t uCmd);
int64_t SetWindowsHook(int nFilterType, NtHookProc pfnFilterProc);
int32_t UnhookWindowsHook(int nCode, NtHookProc pfnFilterProc);
int64_t SetWindowsHookEx(int idHook, NtHookProc lpfn, int64_t hmod,
uint32_t dwThreadId);
int32_t UnhookWindowsHookEx(int64_t hhk);
intptr_t CallNextHookEx(int64_t hhk, int nCode, uintptr_t wParam,
intptr_t lParam);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/codegen.h */
#define COSMOPOLITAN_LIBC_NT_CODEGEN_H_
/*!BEGIN libc/nt/comdlg.h */
#define COSMOPOLITAN_LIBC_NT_COMDLG_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » common dialogs ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
COSMOPOLITAN_C_START_
bool32 GetOpenFileName(struct NtOpenFilename *arg);
bool32 GetSaveFileName(struct NtOpenFilename *arg);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/comms.h */
#define COSMOPOLITAN_LIBC_NT_COMMS_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » communications ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
bool32 PurgeComm(int64_t hFile, uint32_t dwFlags);
bool32 TransmitCommChar(int64_t hFile, char cChar);
bool32 ClearCommBreak(int64_t hFile);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/console.h */
#define COSMOPOLITAN_LIBC_NT_CONSOLE_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » console ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define kNtAttachParentProcess -1u
COSMOPOLITAN_C_START_
bool32 WriteConsoleOutput(int64_t hConsoleOutput,
const struct NtCharInfo *lpBuffer,
struct NtCoord dwBufferSize,
struct NtCoord dwBufferCoord,
struct NtSmallRect *lpWriteRegion);
bool32 ReadConsoleInput(int64_t hConsoleInput, struct NtInputRecord *lpBuffer,
uint32_t nLength, uint32_t *lpNumberOfEventsRead);
bool32 PeekConsoleInput(int64_t hConsoleInput, struct NtInputRecord *lpBuffer,
uint32_t nLength, uint32_t *lpNumberOfEventsRead);
bool32 GetNumberOfConsoleInputEvents(int64_t hConsoleInput,
uint32_t *lpNumberOfEvents);
bool32 ReadConsoleOutput(int64_t hConsoleOutput, struct NtCharInfo *lpBuffer,
struct NtCoord dwBufferSize,
struct NtCoord dwBufferCoord,
struct NtSmallRect *lpReadRegion);
bool32 WriteConsoleInput(int64_t hConsoleInput,
const struct NtInputRecord *lpBuffer, uint32_t nLength,
uint32_t *lpNumberOfEventsWritten);
bool32 FlushConsoleInputBuffer(int64_t hConsoleInput);
int64_t GetConsoleWindow(void);
bool32 GetConsoleMode(int64_t hConsoleHandle, uint32_t *lpMode);
bool32 SetConsoleMode(int64_t hConsoleHandle, uint32_t dwMode);
int32_t AllocConsole(void);
int32_t FreeConsole(void);
int32_t AttachConsole(uint32_t dwProcessId);
uint32_t GetConsoleTitle(char16_t *lpConsoleTitle, uint32_t nSize);
int32_t SetConsoleTitle(const char16_t *lpConsoleTitle);
bool32 GetConsoleScreenBufferInfo(
int64_t hConsoleOutput,
struct NtConsoleScreenBufferInfo *out_lpConsoleScreenBufferInfo);
bool32 GetConsoleScreenBufferInfoEx(
int64_t hConsoleOutput,
struct NtConsoleScreenBufferInfoEx *in_out_lpConsoleScreenBufferInfo);
bool32 SetConsoleScreenBufferInfoEx(
int64_t hConsoleOutput,
const struct NtConsoleScreenBufferInfoEx *lpConsoleScreenBufferInfo);
bool32 SetConsoleScreenBufferSize(int64_t lpConsoleOutput,
struct NtCoord dwSize);
struct NtCoord GetLargestConsoleWindowSize(int64_t hConsoleHandle);
int32_t ReadConsole(int64_t hConsoleInput, void *lpBuffer,
uint32_t nNumberOfCharsToRead,
uint32_t *lpNumberOfCharsRead, void *lpReserved);
int32_t WriteConsole(int64_t hConsoleOutput, const void *lpBuffer,
uint32_t nNumberOfCharsToWrite,
uint32_t *lpNumberOfCharsWritten, void *lpReserved)
paramsnonnull((2, 4));
bool32 GetNumberOfConsoleMouseButtons(uint32_t *out_lpNumberOfMouseButtons)
paramsnonnull();
bool32 GetConsoleSelectionInfo(
struct NtConsoleSelectionInfo *out_lpConsoleSelectionInfo);
uint32_t WaitForInputIdle(int64_t hProcess, uint32_t dwMilliseconds);
uint32_t GetConsoleCP(void);
bool32 SetConsoleCP(uint32_t wCodePageID);
bool32 SetConsoleOutputCP(uint32_t wCodePageID);
uint32_t GetConsoleOutputCP(void);
bool32 SetConsoleCtrlHandler(NtHandlerRoutine opt_HandlerRoutine, bool32 Add);
bool32 GenerateConsoleCtrlEvent(uint32_t dwCtrlEvent,
uint32_t dwProcessGroupId);
bool32 GetConsoleCursorInfo(
int64_t hConsoleOutput,
struct NtConsoleCursorInfo *out_lpConsoleCursorInfo);
bool32 SetConsoleCursorInfo(
int64_t hConsoleOutput,
const struct NtConsoleCursorInfo *lpConsoleCursorInfo);
long CreatePseudoConsole(struct NtCoord size, int64_t hInput, int64_t hOutput,
uint32_t dwFlags, int64_t *out_phPC);
long ResizePseudoConsole(int64_t hPC, struct NtCoord size);
void ClosePseudoConsole(int64_t hPC);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/console.inc */
#define GetConsoleMode(...) __imp_GetConsoleMode(__VA_ARGS__)
extern typeof(GetConsoleMode) *const __imp_GetConsoleMode __msabi;
#define SetConsoleCP(...) __imp_SetConsoleCP(__VA_ARGS__)
extern typeof(SetConsoleCP) *const __imp_SetConsoleCP __msabi;
#define GetConsoleCP(...) __imp_GetConsoleCP(__VA_ARGS__)
extern typeof(GetConsoleCP) *const __imp_GetConsoleCP __msabi;
#define SetConsoleCtrlHandler(...) __imp_SetConsoleCtrlHandler(__VA_ARGS__)
extern typeof(SetConsoleCtrlHandler) *const __imp_SetConsoleCtrlHandler __msabi;
#define SetConsoleMode(...) __imp_SetConsoleMode(__VA_ARGS__)
extern typeof(SetConsoleMode) *const __imp_SetConsoleMode __msabi;
#define SetConsoleOutputCP(...) __imp_SetConsoleOutputCP(__VA_ARGS__)
extern typeof(SetConsoleOutputCP) *const __imp_SetConsoleOutputCP __msabi;
#define GetConsoleOutputCP(...) __imp_GetConsoleOutputCP(__VA_ARGS__)
extern typeof(GetConsoleOutputCP) *const __imp_GetConsoleOutputCP __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/createfile.h */
#define COSMOPOLITAN_LIBC_NT_CREATEFILE_H_
COSMOPOLITAN_C_START_
int64_t CreateFile(
const char16_t *lpFileName, uint32_t dwDesiredAccess, uint32_t dwShareMode,
const struct NtSecurityAttributes *opt_lpSecurityAttributes,
int dwCreationDisposition,
uint32_t dwFlagsAndAttributes, /* libc/nt/enum/fileflagandattributes.h */
int64_t opt_hTemplateFile) paramsnonnull((1));
int64_t CreateFileA(
const char *lpFileName, uint32_t dwDesiredAccess, uint32_t dwShareMode,
const struct NtSecurityAttributes *opt_lpSecurityAttributes,
int dwCreationDisposition,
uint32_t dwFlagsAndAttributes, /* libc/nt/enum/fileflagandattributes.h */
int64_t opt_hTemplateFile) paramsnonnull((1));
int GetNtOpenFlags(int, int, uint32_t *, uint32_t *, uint32_t *, uint32_t *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/debug.h */
#define COSMOPOLITAN_LIBC_NT_DEBUG_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » debugging ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
/* Some of these APIs were moved to system.h and libc.h */
int32_t DebugBreakProcess(void *Process);
int32_t DebugActiveProcess(uint32_t dwProcessId);
int32_t DebugActiveProcessStop(uint32_t dwProcessId);
int32_t CheckRemoteDebuggerPresent(int64_t hProcess, int *pbDebuggerPresent);
int32_t ContinueDebugEvent(uint32_t dwProcessId, uint32_t dwThreadId,
uint32_t dwContinueStatus);
void FatalExit(int uExitCode);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/dll.h */
#define COSMOPOLITAN_LIBC_NT_DLL_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » dynamic link libraries ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
int64_t LoadLibrary(const char16_t *lpLibFileName);
int64_t LoadLibraryA(const char *lpLibFileName);
int64_t LoadLibraryEx(const char16_t *lpLibFileName, int64_t hFile,
uint32_t dwFlags);
uint32_t GetModuleFileNameA(int64_t hModule, char *lpFilename, uint32_t nSize);
intptr_t GetModuleHandle(const char *opt_lpModuleName);
intptr_t GetModuleHandleW(const char16_t *opt_lpModuleName);
void *GetProcAddress(int64_t hModule, const char *lpProcName);
int32_t FreeResource(int64_t hResData);
intptr_t LockResource(int64_t hResData);
int32_t FreeLibrary(int64_t hLibModule);
void *AddDllDirectory(const char16_t *NewDirectory);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/efi.h */
#define COSMOPOLITAN_LIBC_NT_EFI_H_
/*
▐██ ░█████████▓ ▐██▌ ██▓░ ▐█▌ ▐██ ░██░ ▓█▌ ▓██▒ ▓██
▐██ ░██░ ▒█▓██░ ████░ ▐█▌ ▐██ ░██░ ▓█▌ ▓███░ ▓███
▐██ ░██░ ██░▐█▓ ██▒▓█░ ▐█▌ ▐██ ░██░ ▓█▌ ▓█▌▓█░ ▓█▒██
▐██ ░██░ ▐█▌ ▓█▌ ██░░▓█░▐█▌ ▐██ ░██░ ▓█▌ ▓█▌░█▓▓█▒░██
▐██ ░██░ ▒██▓█████░ ██░ ░▓▓▓█▌ ▐██ ░██░ ██░ ▓█▌ ░██▌ ░██
▐██ ░██░ ▓█▌ ▓█▓ ██░ ░███▌ ▐██ ▐██▄▄▄▓█▓ ▓█▌ ░██
╔────────────────────────────────────────────────────────────────────────────│─╗
│ αcτµαlly pδrταblε εxεcµταblε § the unified extensible firmware interface ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define EFI_SUCCESS 0x8000000000000000
#define EFI_LOAD_ERROR 0x8000000000000001
#define EFI_INVALID_PARAMETER 0x8000000000000002
#define EFI_UNSUPPORTED 0x8000000000000003
#define EFI_BAD_BUFFER_SIZE 0x8000000000000004
#define EFI_BUFFER_TOO_SMALL 0x8000000000000005
#define EFI_NOT_READY 0x8000000000000006
#define EFI_DEVICE_ERROR 0x8000000000000007
#define EFI_WRITE_PROTECTED 0x8000000000000008
#define EFI_OUT_OF_RESOURCES 0x8000000000000009
#define EFI_VOLUME_CORRUPTED 0x800000000000000a
#define EFI_VOLUME_FULL 0x800000000000000b
#define EFI_NO_MEDIA 0x800000000000000c
#define EFI_MEDIA_CHANGED 0x800000000000000d
#define EFI_NOT_FOUND 0x800000000000000e
#define EFI_ACCESS_DENIED 0x800000000000000f
#define EFI_NO_RESPONSE 0x8000000000000010
#define EFI_NO_MAPPING 0x8000000000000011
#define EFI_TIMEOUT 0x8000000000000012
#define EFI_NOT_STARTED 0x8000000000000013
#define EFI_ALREADY_STARTED 0x8000000000000014
#define EFI_ABORTED 0x8000000000000015
#define EFI_ICMP_ERROR 0x8000000000000016
#define EFI_TFTP_ERROR 0x8000000000000017
#define EFI_PROTOCOL_ERROR 0x8000000000000018
#define EFI_VARIABLE_NON_VOLATILE 0x00000001
#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008
#define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010
#define EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS 0x00000020
#define EFI_VARIABLE_APPEND_WRITE 0x00000040
#define EFI_MEMORY_UC 0x0000000000000001U
#define EFI_MEMORY_WC 0x0000000000000002U
#define EFI_MEMORY_WT 0x0000000000000004U
#define EFI_MEMORY_WB 0x0000000000000008U
#define EFI_MEMORY_UCE 0x0000000000000010U
#define EFI_MEMORY_WP 0x0000000000001000U
#define EFI_MEMORY_RP 0x0000000000002000U
#define EFI_MEMORY_XP 0x0000000000004000U
#define EFI_MEMORY_RO 0x0000000000020000U
#define EFI_MEMORY_NV 0x0000000000008000U
#define EFI_MEMORY_MORE_RELIABLE 0x0000000000010000U
#define EFI_MEMORY_RUNTIME 0x8000000000000000U
#define EFI_OPTIONAL_PTR 0x00000001
#define EFI_SCAN_NULL 0x0000
#define EFI_SCAN_UP 0x0001
#define EFI_SCAN_DOWN 0x0002
#define EFI_SCAN_RIGHT 0x0003
#define EFI_SCAN_LEFT 0x0004
#define EFI_SCAN_HOME 0x0005
#define EFI_SCAN_END 0x0006
#define EFI_SCAN_INSERT 0x0007
#define EFI_SCAN_DELETE 0x0008
#define EFI_SCAN_PAGE_UP 0x0009
#define EFI_SCAN_PAGE_DOWN 0x000A
#define EFI_SCAN_F1 0x000B
#define EFI_SCAN_F2 0x000C
#define EFI_SCAN_F3 0x000D
#define EFI_SCAN_F4 0x000E
#define EFI_SCAN_F5 0x000F
#define EFI_SCAN_F6 0x0010
#define EFI_SCAN_F7 0x0011
#define EFI_SCAN_F8 0x0012
#define EFI_SCAN_F9 0x0013
#define EFI_SCAN_F10 0x0014
#define EFI_SCAN_ESC 0x0017
#define EFI_EVT_TIMER 0x80000000
#define EFI_EVT_RUNTIME 0x40000000
#define EFI_EVT_NOTIFY_WAIT 0x00000100
#define EFI_EVT_NOTIFY_SIGNAL 0x00000200
#define EFI_EVT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
#define EFI_EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
#define EFI_EVT_RUNTIME_CONTEXT 0x20000000
#define LOADED_IMAGE_PROTOCOL \
{ \
0x5B1B31A1, 0x9562, 0x11d2, { \
0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \
} \
}
#define GRAPHICS_OUTPUT_PROTOCOL \
{ \
0x9042A9DE, 0x23DC, 0x4A38, { \
0x96, 0xFB, 0x7A, 0xDE, 0xD0, 0x80, 0x51, 0x6A \
} \
}
#define ACPI_20_TABLE_GUID \
{ \
0x8868E871, 0xE4F1, 0x11D3, { \
0xBC, 0x22, 0x00, 0x80, 0xC7, 0x3C, 0x88, 0x81 \
} \
}
#define ACPI_10_TABLE_GUID \
{ \
0xEB9D2D30, 0x2D88, 0x11D3, { \
0x9A, 0x16, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D \
} \
}
COSMOPOLITAN_C_START_
#if defined(__GNUC__) && __GNUC__ >= 6 && !defined(__chibicc__) && \
defined(__x86_64__)
#define EFIAPI __attribute__((__ms_abi__))
#else
#define EFIAPI /* TODO(jart): fix me */
#endif
#define EFI_STATUS uint64_t
#define EFI_EVENT uintptr_t
#define EFI_HANDLE uintptr_t
typedef struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
typedef struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL;
typedef enum {
EfiReservedMemoryType,
EfiLoaderCode,
EfiLoaderData,
EfiBootServicesCode,
EfiBootServicesData,
EfiRuntimeServicesCode,
EfiRuntimeServicesData,
EfiConventionalMemory,
EfiUnusableMemory,
EfiACPIReclaimMemory,
EfiACPIMemoryNVS,
EfiMemoryMappedIO,
EfiMemoryMappedIOPortSpace,
EfiPalCode,
EfiPersistentMemory,
EfiMaxMemoryType
} EFI_MEMORY_TYPE;
typedef enum {
EfiResetCold,
EfiResetWarm,
EfiResetShutdown,
EfiResetPlatformSpecific
} EFI_RESET_TYPE;
typedef enum {
AllocateAnyPages,
AllocateMaxAddress,
AllocateAddress,
MaxAllocateType
} EFI_ALLOCATE_TYPE;
typedef enum {
TimerCancel,
TimerPeriodic,
TimerRelative,
} EFI_TIMER_DELAY;
typedef struct {
uint32_t Resolution;
uint32_t Accuracy;
bool32 SetsToZero;
} EFI_TIME_CAPABILITIES;
typedef struct {
uint32_t Data1;
uint16_t Data2;
uint16_t Data3;
uint8_t Data4[8];
} EFI_GUID;
typedef struct {
uint16_t Year;
uint8_t Month;
uint8_t Day;
uint8_t Hour;
uint8_t Minute;
uint8_t Second;
uint8_t Pad1;
uint32_t Nanosecond;
int16_t TimeZone;
uint8_t Daylight;
uint8_t Pad2;
} EFI_TIME;
typedef struct {
uint32_t Type;
uint64_t PhysicalStart;
uint64_t VirtualStart;
uint64_t NumberOfPages;
uint64_t Attribute;
} EFI_MEMORY_DESCRIPTOR;
typedef struct {
EFI_GUID VendorGuid;
void *VendorTable;
} EFI_CONFIGURATION_TABLE;
typedef struct {
EFI_GUID CapsuleGuid;
uint32_t HeaderSize;
uint32_t Flags;
uint32_t CapsuleImageSize;
} EFI_CAPSULE_HEADER;
typedef struct {
uint16_t ScanCode;
char16_t UnicodeChar;
} EFI_INPUT_KEY;
typedef struct {
int32_t MaxMode;
int32_t Mode;
int32_t Attribute;
int32_t CursorColumn;
int32_t CursorRow;
bool32 CursorVisible;
} EFI_SIMPLE_TEXT_OUTPUT_MODE;
typedef enum {
PixelRedGreenBlueReserved8BitPerColor,
PixelBlueGreenRedReserved8BitPerColor,
PixelBitMask,
PixelBltOnly,
PixelFormatMax
} EFI_GRAPHICS_PIXEL_FORMAT;
typedef struct {
uint32_t RedMask;
uint32_t GreenMask;
uint32_t BlueMask;
uint32_t ReservedMask;
} EFI_PIXEL_BITMASK;
typedef struct {
uint32_t Version;
uint32_t HorizontalResolution;
uint32_t VerticalResolution;
EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
EFI_PIXEL_BITMASK PixelInformation;
uint32_t PixelsPerScanLine;
} EFI_GRAPHICS_OUTPUT_MODE_INFORMATION;
typedef struct {
uint8_t Blue;
uint8_t Green;
uint8_t Red;
uint8_t Reserved;
} EFI_GRAPHICS_OUTPUT_BLT_PIXEL;
typedef enum {
EfiBltVideoFill,
EfiBltVideoToBltBuffer,
EfiBltBufferToVideo,
EfiBltVideoToVideo,
EfiGraphicsOutputBltOperationMax
} EFI_GRAPHICS_OUTPUT_BLT_OPERATION;
typedef struct {
uint32_t MaxMode;
uint32_t Mode;
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
uint32_t SizeOfInfo;
uint64_t FrameBufferBase;
uint32_t FrameBufferSize;
} EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE;
typedef struct {
uint64_t Signature;
uint32_t Revision;
uint32_t HeaderSize;
uint32_t CRC32;
uint32_t Reserved;
} EFI_TABLE_HEADER;
typedef struct {
uint8_t Type;
uint8_t SubType;
uint8_t Length[2];
} EFI_DEVICE_PATH_PROTOCOL;
typedef EFI_STATUS(EFIAPI *EFI_EXIT)(EFI_HANDLE ImageHandle,
EFI_STATUS ExitStatus,
uintptr_t ExitDataSize,
char16_t *opt_ExitData);
typedef EFI_STATUS(EFIAPI *EFI_GET_VARIABLE)(char16_t *VariableName,
EFI_GUID *VendorGuid,
uint32_t *outopt_Attributes,
uintptr_t *inout_DataSize,
void *outopt_Data);
typedef EFI_STATUS(EFIAPI *EFI_SET_VARIABLE)(char16_t *VariableName,
EFI_GUID *VendorGuid,
uint32_t Attributes,
uintptr_t DataSize, void *Data);
typedef EFI_STATUS(EFIAPI *EFI_GET_NEXT_VARIABLE_NAME)(
uintptr_t *inout_VariableNameSize, char16_t *inout_VariableName,
EFI_GUID *inout_VendorGuid);
typedef EFI_STATUS(EFIAPI *EFI_QUERY_VARIABLE_INFO)(
uint32_t Attributes, uint64_t *out_MaximumVariableStorageSize,
uint64_t *out_RemainingVariableStorageSize,
uint64_t *out_MaximumVariableSize);
typedef EFI_STATUS(EFIAPI *EFI_ALLOCATE_PAGES)(EFI_ALLOCATE_TYPE Type,
EFI_MEMORY_TYPE MemoryType,
uintptr_t Pages,
uint64_t *inout_Memory);
typedef EFI_STATUS(EFIAPI *EFI_FREE_PAGES)(uint64_t Memory, uintptr_t Pages);
typedef EFI_STATUS(EFIAPI *EFI_GET_MEMORY_MAP)(
uintptr_t *inout_MemoryMapSize, EFI_MEMORY_DESCRIPTOR *inout_MemoryMap,
uintptr_t *out_MapKey, uintptr_t *out_DescriptorSize,
uint32_t *out_DescriptorVersion);
typedef EFI_STATUS(EFIAPI *EFI_ALLOCATE_POOL)(EFI_MEMORY_TYPE PoolType,
uintptr_t Size, void *out_Buffer);
typedef EFI_STATUS(EFIAPI *EFI_FREE_POOL)(void *Buffer);
typedef void(EFIAPI *EFI_SET_MEM)(void *Buffer, uintptr_t Size, uint8_t Value);
typedef void(EFIAPI *EFI_COPY_MEM)(void *Destination, void *Source,
uintptr_t Length);
typedef EFI_STATUS(EFIAPI *EFI_CHECK_EVENT)(EFI_EVENT Event);
typedef EFI_STATUS(EFIAPI *EFI_CLOSE_EVENT)(EFI_EVENT Event);
typedef EFI_STATUS(EFIAPI *EFI_SIGNAL_EVENT)(EFI_EVENT Event);
typedef EFI_STATUS(EFIAPI *EFI_WAIT_FOR_EVENT)(uintptr_t NumberOfEvents,
EFI_EVENT *Events,
uintptr_t *out_Index);
typedef EFI_STATUS(EFIAPI *EFI_SET_TIMER)(EFI_EVENT Event, EFI_TIMER_DELAY Type,
uint64_t TriggerTime);
typedef void(EFIAPI *EFI_EVENT_NOTIFY)(EFI_EVENT Event, void *Context);
typedef EFI_STATUS(EFIAPI *EFI_CREATE_EVENT)(uint32_t Type, uintptr_t NotifyTpl,
EFI_EVENT_NOTIFY NotifyFunction,
void *NotifyContext,
EFI_EVENT *out_Event);
typedef EFI_STATUS(EFIAPI *EFI_CREATE_EVENT_EX)(
uint32_t Type, uintptr_t NotifyTpl, EFI_EVENT_NOTIFY opt_NotifyFunction,
const void *opt_NotifyContext, const EFI_GUID *opt_EventGroup,
EFI_EVENT *out_Event);
typedef EFI_STATUS(EFIAPI *EFI_UPDATE_CAPSULE)(
EFI_CAPSULE_HEADER **CapsuleHeaderArray, uintptr_t CapsuleCount,
uint64_t opt_ScatterGatherList);
typedef EFI_STATUS(EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES)(
EFI_CAPSULE_HEADER **CapsuleHeaderArray, uintptr_t CapsuleCount,
uint64_t *out_MaximumCapsuleSize, EFI_RESET_TYPE *out_ResetType);
typedef EFI_STATUS(EFIAPI *EFI_GET_WAKEUP_TIME)(bool32 *out_Enabled,
bool32 *out_Pending,
EFI_TIME *out_Time);
typedef EFI_STATUS(EFIAPI *EFI_SET_WAKEUP_TIME)(bool32 Enable,
EFI_TIME *opt_Time);
typedef EFI_STATUS(EFIAPI *EFI_SET_WATCHDOG_TIMER)(uintptr_t Timeout,
uint64_t WatchdogCode,
uintptr_t DataSize,
char16_t *opt_WatchdogData);
typedef EFI_STATUS(EFIAPI *EFI_LOCATE_PROTOCOL)(EFI_GUID *Protocol,
void *Registration,
void *Interface);
typedef EFI_STATUS(EFIAPI *EFI_SET_TIME)(EFI_TIME *Time);
typedef EFI_STATUS(EFIAPI *EFI_GET_TIME)(
EFI_TIME *out_Time, EFI_TIME_CAPABILITIES *outopt_Capabilities);
typedef EFI_STATUS(EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT)(
uint32_t *out_HighCount);
typedef EFI_STATUS(EFIAPI *EFI_STALL)(uintptr_t Microseconds);
typedef EFI_STATUS(EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT)(uint64_t *out_Count);
typedef EFI_STATUS(EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP)(
uintptr_t MemoryMapSize, uintptr_t DescriptorSize,
uint32_t DescriptorVersion, EFI_MEMORY_DESCRIPTOR *VirtualMap);
typedef void(EFIAPI *EFI_RESET_SYSTEM)(EFI_RESET_TYPE ResetType,
EFI_STATUS ResetStatus,
uintptr_t DataSize, void *opt_ResetData);
typedef EFI_STATUS(EFIAPI *EFI_CONVERT_POINTER)(uintptr_t DebugDisposition,
void **inout_Address);
typedef EFI_STATUS(EFIAPI *EFI_INPUT_RESET)(
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, bool32 ExtendedVerification);
typedef EFI_STATUS(EFIAPI *EFI_INPUT_READ_KEY)(
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *This, EFI_INPUT_KEY *out_Key);
typedef EFI_STATUS(EFIAPI *EFI_TEXT_RESET)(
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, bool32 ExtendedVerification);
typedef EFI_STATUS(EFIAPI *EFI_TEXT_STRING)(
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, char16_t *String);
typedef EFI_STATUS(EFIAPI *EFI_TEXT_TEST_STRING)(
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, char16_t *String);
typedef EFI_STATUS(EFIAPI *EFI_TEXT_QUERY_MODE)(
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, uint64_t ModeNumber,
uint64_t *out_Columns, uint64_t *out_Rows);
typedef EFI_STATUS(EFIAPI *EFI_TEXT_SET_MODE)(
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, uint64_t ModeNumber);
typedef EFI_STATUS(EFIAPI *EFI_TEXT_SET_ATTRIBUTE)(
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, uint64_t Attribute);
typedef EFI_STATUS(EFIAPI *EFI_TEXT_CLEAR_SCREEN)(
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This);
typedef EFI_STATUS(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION)(
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, uint64_t Column, uint64_t Row);
typedef EFI_STATUS(EFIAPI *EFI_TEXT_ENABLE_CURSOR)(
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This, bool32 Visible);
typedef EFI_STATUS(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE)(
EFI_GRAPHICS_OUTPUT_PROTOCOL *This, uint32_t ModeNumber,
uint32_t *SizeOfInfo, EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info);
typedef EFI_STATUS(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE)(
EFI_GRAPHICS_OUTPUT_PROTOCOL *This, uint32_t ModeNumber);
typedef EFI_STATUS(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT)(
EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer,
EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation, uint32_t SourceX,
uint32_t SourceY, uint32_t DestinationX, uint32_t DestinationY,
uint32_t Width, uint32_t Height, uint32_t Delta);
typedef EFI_STATUS(EFIAPI *EFI_HANDLE_PROTOCOL)(EFI_HANDLE Handle,
EFI_GUID *Protocol,
void *out_Interface);
typedef EFI_STATUS(EFIAPI *EFI_IMAGE_LOAD)(bool32 BootPolicy,
EFI_HANDLE ParentImageHandle,
EFI_DEVICE_PATH_PROTOCOL *DevicePath,
void *opt_SourceBuffer,
uintptr_t SourceSize,
EFI_HANDLE *out_ImageHandle);
typedef EFI_STATUS(EFIAPI *EFI_IMAGE_UNLOAD)(EFI_HANDLE ImageHandle);
typedef EFI_STATUS(EFIAPI *EFI_EXIT_BOOT_SERVICES)(EFI_HANDLE ImageHandle,
uintptr_t MapKey);
typedef struct {
EFI_TABLE_HEADER Hdr;
EFI_GET_TIME GetTime;
EFI_SET_TIME SetTime;
EFI_GET_WAKEUP_TIME GetWakeupTime;
EFI_SET_WAKEUP_TIME SetWakeupTime;
EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap;
EFI_CONVERT_POINTER ConvertPointer;
EFI_GET_VARIABLE GetVariable;
EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName;
EFI_SET_VARIABLE SetVariable;
EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount;
EFI_RESET_SYSTEM ResetSystem;
EFI_UPDATE_CAPSULE UpdateCapsule;
EFI_QUERY_CAPSULE_CAPABILITIES QueryCapsuleCapabilities;
EFI_QUERY_VARIABLE_INFO QueryVariableInfo;
} EFI_RUNTIME_SERVICES;
typedef struct {
EFI_TABLE_HEADER Hdr;
void *RaiseTPL;
void *RestoreTPL;
EFI_ALLOCATE_PAGES AllocatePages;
EFI_FREE_PAGES FreePages;
EFI_GET_MEMORY_MAP GetMemoryMap;
EFI_ALLOCATE_POOL AllocatePool;
EFI_FREE_POOL FreePool;
EFI_CREATE_EVENT CreateEvent;
EFI_SET_TIMER SetTimer;
EFI_WAIT_FOR_EVENT WaitForEvent;
EFI_SIGNAL_EVENT SignalEvent;
EFI_CLOSE_EVENT CloseEvent;
EFI_CHECK_EVENT CheckEvent;
void *InstallProtocolInterface;
void *ReinstallProtocolInterface;
void *UninstallProtocolInterface;
EFI_HANDLE_PROTOCOL HandleProtocol;
void *Reserved;
void *RegisterProtocolNotify;
void *LocateHandle;
void *LocateDevicePath;
void *InstallConfigurationTable;
EFI_IMAGE_LOAD LoadImage;
void *StartImage;
EFI_EXIT Exit;
EFI_IMAGE_UNLOAD UnloadImage;
EFI_EXIT_BOOT_SERVICES ExitBootServices;
EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount;
EFI_STALL Stall;
EFI_SET_WATCHDOG_TIMER SetWatchdogTimer;
void *ConnectController;
void *DisconnectController;
void *OpenProtocol;
void *CloseProtocol;
void *OpenProtocolInformation;
void *ProtocolsPerHandle;
void *LocateHandleBuffer;
EFI_LOCATE_PROTOCOL LocateProtocol;
void *InstallMultipleProtocolInterfaces;
void *UninstallMultipleProtocolInterfaces;
void *CalculateCrc32;
EFI_COPY_MEM CopyMem;
EFI_SET_MEM SetMem;
EFI_CREATE_EVENT_EX CreateEventEx;
} EFI_BOOT_SERVICES;
typedef struct {
EFI_TABLE_HEADER Hdr;
char16_t *FirmwareVendor;
uint32_t FirmwareRevision;
EFI_HANDLE ConsoleInHandle;
EFI_SIMPLE_TEXT_INPUT_PROTOCOL *ConIn;
EFI_HANDLE ConsoleOutHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *ConOut;
EFI_HANDLE StandardErrorHandle;
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *StdErr;
EFI_RUNTIME_SERVICES *RuntimeServices;
EFI_BOOT_SERVICES *BootServices;
uintptr_t NumberOfTableEntries;
EFI_CONFIGURATION_TABLE *ConfigurationTable;
} EFI_SYSTEM_TABLE;
struct _EFI_SIMPLE_TEXT_INPUT_PROTOCOL {
EFI_INPUT_RESET Reset;
EFI_INPUT_READ_KEY ReadKeyStroke;
EFI_EVENT WaitForKey;
};
struct _EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL {
EFI_TEXT_RESET Reset;
EFI_TEXT_STRING OutputString;
EFI_TEXT_TEST_STRING TestString;
EFI_TEXT_QUERY_MODE QueryMode;
EFI_TEXT_SET_MODE SetMode;
EFI_TEXT_SET_ATTRIBUTE SetAttribute;
EFI_TEXT_CLEAR_SCREEN ClearScreen;
EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition;
EFI_TEXT_ENABLE_CURSOR EnableCursor;
EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
};
struct _EFI_GRAPHICS_OUTPUT_PROTOCOL {
EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE QueryMode;
EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE SetMode;
EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT Blt;
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode;
};
typedef struct {
uint32_t Revision;
EFI_HANDLE ParentHandle;
EFI_SYSTEM_TABLE *SystemTable;
EFI_HANDLE DeviceHandle;
EFI_DEVICE_PATH_PROTOCOL *FilePath;
void *Reserved;
uint32_t LoadOptionsSize;
void *LoadOptions;
void *ImageBase;
uint64_t ImageSize;
EFI_MEMORY_TYPE ImageCodeType;
EFI_MEMORY_TYPE ImageDataType;
EFI_IMAGE_UNLOAD Unload;
} EFI_LOADED_IMAGE;
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/events.h */
#define COSMOPOLITAN_LIBC_NT_EVENTS_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » events ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
COSMOPOLITAN_C_START_
int32_t GetMessage(struct NtMsg *lpMsg, int64_t hWnd, uint32_t wMsgFilterMin,
uint32_t wMsgFilterMax);
int32_t TranslateMessage(const struct NtMsg *lpMsg);
intptr_t DispatchMessage(const struct NtMsg *lpMsg);
void PostQuitMessage(int nExitCode);
bool32 GetCursorPos(struct NtPoint *lpPoint);
int64_t SendMessage(int64_t hWnd, uint32_t Msg, uint64_t wParam,
int64_t lParam);
#define EVENTLOG_SUCCESS 0x00000000
#define EVENTLOG_ERROR_TYPE 0x00000001
#define EVENTLOG_WARNING_TYPE 0x00000002
#define EVENTLOG_INFORMATION_TYPE 0x00000004
#define EVENTLOG_AUDIT_SUCCESS 0x00000008
#define EVENTLOG_AUDIT_FAILURE 0x00000010
int32_t ReportEventA(int64_t handle, uint16_t wType, uint16_t wCategory,
uint32_t dwEventID, const char *lpUserId,
uint16_t wNumStrings, uint32_t dwDataSize,
const char **lpStrings, void **lpRawData);
int64_t RegisterEventSource(const char16_t *lpUNCServerName,
const char16_t *lpSourceName);
int32_t DeregisterEventSource(uint64_t handle);
int64_t CreateEvent(const struct NtSecurityAttributes *opt_lpEventAttributes,
bool32 bManualReset, bool32 bInitialState,
const char16_t *opt_lpName);
int64_t CreateEventA(const struct NtSecurityAttributes *opt_lpEventAttributes,
bool32 bManualReset, bool32 bInitialState,
const char *opt_lpName);
int64_t CreateEventEx(const struct NtSecurityAttributes *lpEventAttributes,
const char16_t *lpName, uint32_t dwFlags,
uint32_t dwDesiredAccess);
int32_t SetEvent(int64_t hEvent);
int32_t ResetEvent(int64_t hEvent);
int32_t PulseEvent(int64_t hEvent);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/files.h */
#define COSMOPOLITAN_LIBC_NT_FILES_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » files ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define kNtHandleFlagInherit 1 /* SetHandleInformation */
#define kNtHandleFlagProtectFromClose 2
#define kNtFindFirstExCaseSensitive 1
#define kNtFindFirstExLargeFetch 2
#define kNtDuplicateCloseSource 1
#define kNtDuplicateSameAccess 2
COSMOPOLITAN_C_START_
intptr_t LoadResource(int64_t hModule, int64_t hResInfo);
uint32_t SetHandleCount(uint32_t uNumber);
uint32_t GetLogicalDrives(void);
bool32 FlushFileBuffers(int64_t hFile);
int64_t ReOpenFile(int64_t hOriginalFile, uint32_t dwDesiredAccess,
uint32_t dwShareMode, uint32_t dwFlagsAndAttributes);
bool32 DeleteFile(const char16_t *lpFileName) paramsnonnull();
bool32 CopyFile(const char16_t *lpExistingFileName,
const char16_t *lpNewFileName, bool32 bFailIfExists)
paramsnonnull();
bool32 MoveFile(const char16_t *lpExistingFileName,
const char16_t *lpNewFileName) paramsnonnull();
bool32 MoveFileEx(const char16_t *lpExistingFileName,
const char16_t *opt_lpNewFileName, int dwFlags)
paramsnonnull((1));
bool32 SetCurrentDirectory(const char16_t *lpPathName);
uint32_t GetCurrentDirectory(uint32_t nBufferLength, char16_t *out_lpBuffer);
bool32 CreateDirectory(const char16_t *lpPathName,
const struct NtSecurityAttributes *lpSecurityAttributes);
bool32 RemoveDirectory(const char16_t *lpPathName);
bool32 DuplicateHandle(int64_t hSourceProcessHandle, int64_t hSourceHandle,
int64_t hTargetProcessHandle, int64_t *lpTargetHandle,
uint32_t dwDesiredAccess, bool32 bInheritHandle,
uint32_t dwOptions);
bool32 GetHandleInformation(int64_t hObject, uint32_t *out_lpdwFlags);
bool32 SetHandleInformation(int64_t hObject, uint32_t dwMask, uint32_t dwFlags);
int GetFileType(int64_t hFile);
bool32 GetFileInformationByHandleEx(int64_t hFile,
uint32_t FileInformationClass,
void *out_lpFileInformation,
uint32_t dwBufferSize);
bool32 GetFileInformationByHandle(
int64_t hFile, struct NtByHandleFileInformation *lpFileInformation);
bool32 SetFileInformationByHandle(int64_t hFile, int FileInformationClass,
const void *lpFileInformation,
uint32_t dwBufferSize);
uint32_t GetFileAttributes(const char16_t *lpFileName);
bool32 GetFileAttributesEx(
const char16_t *lpFileName, int fInfoLevelId /* kNtGetFileExInfoStandard */,
void *out_lpFileInformation /* → struct NtWin32FileAttributeData * */)
paramsnonnull();
uint32_t GetCompressedFileSize(const char16_t *lpFileName,
uint32_t *lpFileSizeHigh);
bool32 SetFileAttributes(const char16_t *lpFileName, uint32_t dwFileAttributes);
bool32 GetFileTime(int64_t hFile, struct NtFileTime *opt_lpCreationFileTime,
struct NtFileTime *opt_lpLastAccessFileTime,
struct NtFileTime *opt_lpLastWriteFileTime);
bool32 SetFileTime(int64_t hFile,
const struct NtFileTime *opt_lpCreationFileTime,
const struct NtFileTime *opt_lpLastAccessFileTime,
const struct NtFileTime *opt_lpLastWriteFileTime);
bool32 DeviceIoControl(int64_t hDevice, uint32_t dwIoControlCode,
void *lpInBuffer, uint32_t nInBufferSize,
void *lpOutBuffer, uint32_t nOutBufferSize,
uint32_t *lpBytesReturned,
struct NtOverlapped *lpOverlapped);
bool32 LockFile(int64_t hFile, uint32_t dwFileOffsetLow,
uint32_t dwFileOffsetHigh, uint32_t nNumberOfBytesToLockLow,
uint32_t nNumberOfBytesToLockHigh);
bool32 UnlockFile(int64_t hFile, uint32_t dwFileOffsetLow,
uint32_t dwFileOffsetHigh, uint32_t nNumberOfBytesToUnlockLow,
uint32_t nNumberOfBytesToUnlockHigh);
bool32 LockFileEx(int64_t hFile, uint32_t dwFlags, uint32_t dwReserved,
uint32_t nNumberOfBytesToLockLow,
uint32_t nNumberOfBytesToLockHigh,
struct NtOverlapped *lpOverlapped) paramsnonnull();
bool32 UnlockFileEx(int64_t hFile, uint32_t dwReserved,
uint32_t nNumberOfBytesToUnlockLow,
uint32_t nNumberOfBytesToUnlockHigh,
struct NtOverlapped *lpOverlapped) paramsnonnull();
bool32 CreateHardLink(const char16_t *lpFileName,
const char16_t *lpExistingFileName,
const struct NtSecurityAttributes *reserved)
paramsnonnull((1, 2));
bool32 CreateSymbolicLink(const char16_t *lpSymlinkFileName,
const char16_t *lpTargetPathName, uint32_t dwFlags)
paramsnonnull();
bool32 SetEndOfFile(int64_t hFile);
bool32 SetFileValidData(int64_t hFile, int64_t ValidDataLength);
bool32 GetFileSecurity(const char16_t *lpFileName,
uint32_t RequestedInformation,
struct NtSecurityDescriptor *pSecurityDescriptor,
uint32_t nLength, uint32_t *lpnLengthNeeded);
bool32 OpenProcessToken(int64_t hProcessHandle, uint32_t dwDesiredAccess,
int64_t *out_hTokenHandle);
bool32 DuplicateToken(int64_t hExistingTokenHandle, int dwImpersonationLevel,
int64_t *out_hDuplicateTokenHandle);
bool32 DuplicateTokenEx(int64_t hExistingToken, unsigned int dwDesiredAccess,
const struct NtSecurityAttributes *lpTokenAttributes,
int ImpersonationLevel, int TokenType,
int64_t *out_phNewToken);
bool32 AccessCheck(struct NtSecurityDescriptor *pSecurityDescriptor,
int64_t ClientToken, unsigned int DesiredAccess,
struct NtGenericMapping *lpGenericMapping,
struct NtPrivilegeSet *lpPrivilegeSet,
unsigned int *PrivilegeSetLength,
unsigned int *GrantedAccess, bool32 *AccessStatus);
void MapGenericMask(uint32_t *AccessMask,
struct NtGenericMapping *GenericMapping);
int64_t FindFirstFile(const char16_t *lpFileName,
struct NtWin32FindData *out_lpFindFileData);
int64_t FindFirstFileEx(const char16_t *lpFileName, int fInfoLevelId,
void *out_lpFindFileData, int fSearchOp,
void *reserved_lpSearchFilter,
uint32_t dwAdditionalFlags);
bool32 FindNextFile(int64_t hFindFile,
struct NtWin32FindData *out_lpFindFileData);
bool32 FindClose(int64_t hFindFile);
int64_t FindFirstVolume(char16_t *out_lpszVolumeName, uint32_t cchBufferLength);
bool32 FindNextVolume(int64_t inout_hFindVolume, char16_t *out_lpszVolumeName,
uint32_t cchBufferLength);
bool32 FindVolumeClose(int64_t hFindVolume);
bool32 ReadFileScatter(
int64_t hFileOpenedWithOverlappedAndNoBuffering,
const union NtFileSegmentElement
aNullTerminatedPageAlignedSizedSegmentArray[],
uint32_t nNumberOfBytesToReadThatsMultipleOfFileVolumeSectorSize,
uint32_t *lpReserved, struct NtOverlapped *inout_lpOverlapped)
paramsnonnull();
bool32 WriteFileGather(int64_t hFileOpenedWithOverlappedAndNoBuffering,
const union NtFileSegmentElement aSegmentArray[],
uint32_t nNumberOfBytesToWrite, uint32_t *lpReserved,
struct NtOverlapped inout_lpOverlapped) paramsnonnull();
#define kNtFileNameNormalized 0x0
#define kNtFileNameOpened 0x8
#define kNtVolumeNameDos 0x0 /* e.g. \\?\C:\Users\jart */
#define kNtVolumeNameGuid 0x1 /* e.g. \\?\Volume{ea38-etc.}\Users\jart */
#define kNtVolumeNameNt 0x2 /* e.g. \Device\HarddiskVolume4\Users\jart */
#define kNtVolumeNameNone 0x4 /* e.g. \Users\jart */
uint32_t GetFinalPathNameByHandle(int64_t hFile, char16_t *out_path,
uint32_t arraylen, uint32_t flags);
uint32_t GetFullPathName(const char16_t *lpFileName, uint32_t nBufferLength,
char16_t *lpBuffer, char16_t **lpFilePart);
bool32 GetOverlappedResult(int64_t hFile, struct NtOverlapped *lpOverlapped,
uint32_t *lpNumberOfBytesTransferred, bool32 bWait);
bool32 GetOverlappedResultEx(int64_t hFile, struct NtOverlapped *lpOverlapped,
uint32_t *lpNumberOfBytesTransferred,
uint32_t dwMilliseconds, bool32 bAlertable);
bool32 GetVolumePathName(const char16_t *lpszFileName,
char16_t *lpszVolumePathName,
uint32_t cchBufferLength);
bool32 GetVolumeInformationByHandle(int64_t hFile,
char16_t *opt_out_lpVolumeNameBuffer,
uint32_t nVolumeNameSize,
uint32_t *opt_out_lpVolumeSerialNumber,
uint32_t *opt_out_lpMaximumComponentLength,
uint32_t *opt_out_lpFileSystemFlags,
char16_t *opt_out_lpFileSystemNameBuffer,
uint32_t nFileSystemNameSize);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/files.inc */
#define CopyFile(...) __imp_CopyFileW(__VA_ARGS__)
extern typeof(CopyFile) *const __imp_CopyFileW __msabi;
#define GetFileType(...) __imp_GetFileType(__VA_ARGS__)
extern typeof(GetFileType) *const __imp_GetFileType __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/iocp.h */
#define COSMOPOLITAN_LIBC_NT_IOCP_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » i/o completion ports ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define kNtFileSkipCompletionPortOnSuccess 1
#define kNtFileSkipSetEventOnHandle 2
COSMOPOLITAN_C_START_
typedef void (*NtOverlappedCompletionRoutine)(
uint32_t dwErrorCode, uint32_t dwNumberOfBytesTransfered,
struct NtOverlapped *inout_lpOverlapped);
int64_t CreateIoCompletionPort(int64_t FileHandleOrNeg1,
int64_t opt_ExistingCompletionPortOrZero,
uint64_t CompletionKey,
uint32_t NumberOfConcurrentThreads);
bool32 GetQueuedCompletionStatus(int64_t CompletionPort,
uint32_t *lpNumberOfBytesTransferred,
uint64_t *out_lpCompletionKey,
struct NtOverlapped **out_lpOverlapped,
uint32_t dwMilliseconds);
bool32 GetQueuedCompletionStatusEx(
int64_t CompletionPort,
struct NtOverlappedEntry *out_lpCompletionPortEntries, uint32_t ulCount,
uint32_t *out_ulNumEntriesRemoved, uint32_t dwMilliseconds,
bool32 fAlertable);
bool32 PostQueuedCompletionStatus(int64_t CompletionPort,
uint32_t dwNumberOfBytesTransferred,
uint64_t dwCompletionKey,
struct NtOverlapped *opt_lpOverlapped);
bool32 SetFileCompletionNotificationModes(int64_t FileHandle,
unsigned char Flags);
bool32 ReadFileEx(int64_t hFile, void *lpBuffer, uint32_t nNumberOfBytesToRead,
uint32_t *lpNumberOfBytesRead,
struct NtOverlapped *opt_lpOverlapped,
NtOverlappedCompletionRoutine lpCompletionRoutine);
bool32 WriteFileEx(int64_t hFile, const void *lpBuffer,
uint32_t nNumberOfBytesToWrite,
struct NtOverlapped *lpOverlapped,
NtOverlappedCompletionRoutine lpCompletionRoutine);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/ipc.h */
#define COSMOPOLITAN_LIBC_NT_IPC_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » ipc ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
/* CreateNamedPipe:dwOpenMode */
#define kNtPipeAccessInbound 0x00000001
#define kNtPipeAccessOutbound 0x00000002
#define kNtPipeAccessDuplex 0x00000003
/* CreateNamedPipe::dwPipeMode */
#define kNtPipeWait 0x00000000
#define kNtPipeNowait 0x00000001
#define kNtPipeReadmodeByte 0x00000000
#define kNtPipeReadmodeMessage 0x00000002
#define kNtPipeTypeByte 0x00000000
#define kNtPipeTypeMessage 0x00000004
#define kNtPipeAcceptRemoteClients 0x00000000
#define kNtPipeRejectRemoteClients 0x00000008
/* CreateNamedPipe::nMaxInstances */
#define kNtPipeUnlimitedInstances 255
/* GetNamedPipeInfo */
#define kNtPipeClientEnd 0x00000000
#define kNtPipeServerEnd 0x00000001
COSMOPOLITAN_C_START_
bool32 CreatePipe(int64_t *out_hReadPipe, int64_t *out_hWritePipe,
const struct NtSecurityAttributes *opt_lpPipeAttributes,
uint32_t nSize) paramsnonnull((1, 2));
int64_t CreateNamedPipe(
const char16_t *lpName, uint32_t dwOpenMode, uint32_t dwPipeMode,
uint32_t nMaxInstances, uint32_t nOutBufferSize, uint32_t nInBufferSize,
uint32_t nDefaultTimeOut,
const struct NtSecurityAttributes *opt_lpSecurityAttributes)
paramsnonnull((1));
bool32 CallNamedPipe(const char16_t *lpNamedPipeName, void *lpInBuffer,
uint32_t nInBufferSize, void *lpOutBuffer,
uint32_t nOutBufferSize, uint32_t *lpBytesRead,
uint32_t nTimeOut);
bool32 ConnectNamedPipe(int64_t hNamedPipe, struct NtOverlapped *lpOverlapped);
bool32 WaitNamedPipe(const char16_t *lpNamedPipeName, uint32_t nTimeOut);
bool32 DisconnectNamedPipe(int64_t hNamedPipe);
bool32 SetNamedPipeHandleState(int64_t hNamedPipe, uint32_t *lpMode,
uint32_t *lpMaxCollectionCount,
uint32_t *lpCollectDataTimeout);
bool32 PeekNamedPipe(int64_t hNamedPipe, void *lpBuffer, uint32_t nBufferSize,
uint32_t *opt_lpBytesRead, uint32_t *opt_lpTotalBytesAvail,
uint32_t *opt_lpBytesLeftThisMessage);
bool32 TransactNamedPipe(int64_t hNamedPipe, void *lpInBuffer,
uint32_t nInBufferSize, void *lpOutBuffer,
uint32_t nOutBufferSize, uint32_t *lpBytesRead,
struct NtOverlapped *lpOverlapped);
bool32 GetNamedPipeInfo(int64_t hNamedPipe, uint32_t *opt_out_lpFlags,
uint32_t *opt_out_lpOutBufferSize,
uint32_t *opt_out_lpInBufferSize,
uint32_t *opt_out_lpMaxInstances);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/iphlpapi.h */
#define COSMOPOLITAN_LIBC_NT_IPHLPAPI_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » ip helper api ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
uint32_t GetAdaptersAddresses(uint32_t Family, uint32_t Flags, void *Reserved,
struct NtIpAdapterAddresses *AdapterAddresses,
uint32_t *SizePointer);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/memory.h */
#define COSMOPOLITAN_LIBC_NT_MEMORY_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » memory ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define kNtNumaNoPreferredNode 0xffffffffu
COSMOPOLITAN_C_START_
void *LocalFree(void *hMem);
int64_t CreateFileMapping(
int64_t opt_hFile,
const struct NtSecurityAttributes *opt_lpFileMappingAttributes,
uint32_t flProtect, uint32_t dwMaximumSizeHigh, uint32_t dwMaximumSizeLow,
const char16_t *opt_lpName);
int64_t CreateFileMappingNuma(
int64_t opt_hFile,
const struct NtSecurityAttributes *opt_lpFileMappingAttributes,
uint32_t flProtect, uint32_t dwMaximumSizeHigh, uint32_t dwMaximumSizeLow,
const char16_t *opt_lpName, uint32_t nndDesiredNumaNode);
void *MapViewOfFileEx(int64_t hFileMappingObject, uint32_t dwDesiredAccess,
uint32_t dwFileOffsetHigh, uint32_t dwFileOffsetLow,
size_t dwNumberOfBytesToMap,
void *opt_lpDesiredBaseAddress);
void *MapViewOfFileExNuma(int64_t hFileMappingObject, uint32_t dwDesiredAccess,
uint32_t dwFileOffsetHigh, uint32_t dwFileOffsetLow,
size_t dwNumberOfBytesToMap,
void *opt_lpDesiredBaseAddress,
uint32_t nndDesiredNumaNode);
bool32 UnmapViewOfFile(const void *lpBaseAddress);
bool32 FlushViewOfFile(const void *lpBaseAddress,
size_t dwNumberOfBytesToFlush);
void *VirtualAlloc(void *opt_lpAddress, uint64_t dwSize,
uint32_t flAllocationType, uint32_t flProtect);
bool32 VirtualFree(void *lpAddress, uint64_t dwSize, uint32_t dwFreeType);
bool32 VirtualProtect(void *lpAddress, uint64_t dwSize, uint32_t flNewProtect,
uint32_t *lpflOldProtect) paramsnonnull();
bool32 VirtualLock(const void *lpAddress, size_t dwSize);
bool32 VirtualUnlock(const void *lpAddress, size_t dwSize);
uint64_t VirtualQuery(const void *lpAddress,
struct NtMemoryBasicInformation *lpBuffer,
uint64_t dwLength);
void *VirtualAllocEx(int64_t hProcess, void *lpAddress, uint64_t dwSize,
uint32_t flAllocationType, uint32_t flProtect);
int64_t GetProcessHeap(void);
void *HeapAlloc(int64_t hHeap, uint32_t dwFlags, size_t dwBytes) __wur;
bool32 HeapFree(int64_t hHeap, uint32_t dwFlags, void *opt_lpMem);
void *HeapReAlloc(int64_t hHeap, uint32_t dwFlags, void *lpMem,
size_t dwBytes) __wur;
void *GlobalAlloc(uint32_t uFlags, uint64_t dwBytes) __wur;
void *GlobalFree(void *hMem);
/**
* @param AllocationType
* - kNtMemReserve
* - kNtMemReplacePlaceholder
* - kNtMemLargePages
*/
void *MapViewOfFile3(
intptr_t FileMapping, intptr_t Process, void *opt_BaseAddress,
uint64_t Offset, size_t ViewSize, unsigned AllocationType,
unsigned PageProtection,
struct NtMemExtendedParameter *in_out_opt_ExtendedParameters,
unsigned ParameterCount);
void *VirtualAlloc2(
intptr_t opt_Process, void *opt_BaseAddress, size_t Size,
unsigned AllocationType, unsigned PageProtection,
struct NtMemExtendedParameter *in_out_opt_ExtendedParameters,
unsigned ParameterCount);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/memory.inc */
extern typeof(LocalFree) *const __imp_LocalFree __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/messagebox.h */
#define COSMOPOLITAN_LIBC_NT_MESSAGEBOX_H_
COSMOPOLITAN_C_START_
int MessageBox(int64_t hWnd, const char16_t *lpText, const char16_t *lpCaption,
uint32_t mbType);
int MessageBoxEx(int64_t hWnd, const char16_t *lpText,
const char16_t *lpCaption, uint32_t mbType,
uint16_t wLanguageId);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/ntdll.h */
#define COSMOPOLITAN_LIBC_NT_NTDLL_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » beyond the pale ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│─╝
“The functions and structures in [for these APIs] are internal to
the operating system and subject to change from one release of
Windows to the next, and possibly even between service packs for
each release.” ──Quoth MSDN */
#define __nt_system_call_dispatcher (wambda *)0x7ffe0308
extern const struct NtUnicodeString *const RtlNtdllName;
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § new technology » beyond the pale » eponymous runtime ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define NT_PROCESS_FLAGS_CREATE_SUSPENDED 0x00000001
#define NT_PROCESS_FLAGS_INHERIT_HANDLES 0x00000002
#define NT_PROCESS_FLAGS_NO_SYNCHRONIZE 0x00000004
#define NT_RTL_CLONE_PARENT 0
#define NT_RTL_CLONE_CHILD 297
NtStatus NtCallbackReturn(void *opt_Result, uint32_t ResultLength,
int32_t Status);
NtStatus NtTestAlert(void);
NtStatus NtOpenFile(int64_t *out_FileHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
struct NtIoStatusBlock *out_IoStatusBlock,
uint32_t ShareAccess, uint32_t OpenOptions);
NtStatus NtQueryInformationToken(int64_t TokenHandle,
uint32_t TokenInformationClass,
void *out_TokenInformation,
uint32_t TokenInformationLength,
uint32_t *out_ReturnLength);
NtStatus NtYieldExecution(void);
NtStatus NtQuerySystemInformation(uint32_t info_class, void *out_info,
uint32_t info_size,
uint32_t *out_bytes_received);
NtStatus NtReadVirtualMemory(int64_t ProcessHandle, const void *BaseAddress,
void *out_Buffer, size_t BufferLength,
size_t *opt_out_ReturnLength);
NtStatus NtCreateTimer(void **out_TimerHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
uint32_t TimerType);
NtStatus NtSetTimer(void *TimerHandle, int64_t *DueTime, void *TimerApcRoutine,
void *TimerContext, int32_t Resume, int32_t Period,
int32_t *out_PreviousState);
NtStatus NtQueryObject(void *ObjectHandle, int ObjectInformationClass,
void *out_ObjectInformation,
uint32_t ObjectInformationLength,
uint32_t *opt_out_ReturnLength);
NtStatus NtQueryFullAttributesFile(
struct NtObjectAttributes *attributes,
struct NtFileNetworkOpenInformation *out_info);
NtStatus NtCreateKey(void **out_KeyHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
uint32_t TitleIndex, struct NtUnicodeString *opt_Class,
uint32_t CreateOptions, uint32_t *opt_out_Disposition);
NtStatus NtOpenKey(void **out_KeyHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes);
NtStatus NtSetValueKey(void *KeyHandle, struct NtUnicodeString *ValueName,
uint32_t opt_TitleIndex, uint32_t Type, void *Data,
uint32_t DataSize);
NtStatus NtDeleteKey(void *KeyHandle);
NtStatus NtQueryValueKey(void *KeyHandle, struct NtUnicodeString *ValueName,
int KeyValueInformationClass,
void *out_KeyValueInformation, uint32_t Length,
uint32_t *out_ResultLength);
NtStatus NtFlushKey(void *KeyHandle);
NtStatus NtEnumerateKey(int64_t hkey, uint32_t index, int info_class,
void *out_key_info, uint32_t key_info_size,
uint32_t *out_bytes_received);
NtStatus NtEnumerateValueKey(int64_t hKey, uint32_t index, int info_class,
void *out_key_info, uint32_t key_info_size,
uint32_t *out_bytes_received);
NtStatus NtQuerySystemTime(int64_t *SystemTime);
NtStatus NtDeleteFile(struct NtObjectAttributes *ObjectAttributes);
NtStatus NtFlushBuffersFile(int64_t FileHandle,
struct NtIoStatusBlock *out_IoStatusBlock);
NtStatus NtCreateIoCompletion(void **out_IoCompletionHandle,
uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
uint32_t NumberOfConcurrentThreads);
NtStatus NtRaiseHardError(int32_t ErrorStatus, uint32_t NumberOfArguments,
uint32_t UnicodeStringArgumentsMask, void *Arguments,
uint32_t MessageBoxType,
uint32_t *out_MessageBoxResult);
NtStatus NtRaiseException(struct NtExceptionRecord *ExceptionRecord,
struct NtContext *Context, int32_t SearchFrames);
NtStatus NtCreateEvent(void **out_EventHandle, uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes,
int EventType, int32_t InitialState);
NtStatus NtWaitForSingleObject(void *ObjectHandle, int32_t Alertable,
int64_t *TimeOut);
NtStatus NtSetEvent(void *EventHandle, int32_t *opt_out_PreviousState);
NtStatus NtClearEvent(void *EventHandle);
NtStatus NtSignalAndWaitForSingleObject(void *ObjectToSignal,
void *WaitableObject, int32_t Alertable,
int64_t *opt_Time);
NtStatus NtQueryPerformanceCounter(int64_t *out_PerformanceCount,
int64_t *opt_out_PerformanceFrequency);
NtStatus NtFsControlFile(int64_t FileHandle, void *opt_Event,
NtIoApcRoutine opt_ApcRoutine, void *opt_ApcContext,
struct NtIoStatusBlock *out_IoStatusBlock,
uint32_t FsControlCode, void *opt_InputBuffer,
uint32_t InputBufferLength, void *opt_out_OutputBuffer,
uint32_t OutputBufferLength);
NtStatus NtCancelIoFile(int64_t FileHandle,
struct NtIoStatusBlock *out_IoStatusBlock);
NtStatus NtCreateProfile(void **out_ProfileHandle, int64_t ProcessHandle,
void *Base, uint32_t Size, uint32_t BucketShift,
uint32_t *Buffer, uint32_t BufferLength, int Source,
uint32_t ProcessorMask);
NtStatus NtSetIntervalProfile(uint32_t Interval, int Source);
NtStatus NtQueryIntervalProfile(int Source, uint32_t *out_Interval);
NtStatus NtStartProfile(void *ProfileHandle);
NtStatus NtStopProfile(void *ProfileHandle);
NtStatus NtCreateDirectoryObject(int64_t *out_DirectoryHandle,
uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes);
NtStatus NtOpenDirectoryObject(int64_t *out_DirectoryHandle,
uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes);
NtStatus NtOpenSymbolicLinkObject(int64_t *out_DirectoryHandle,
uint32_t DesiredAccess,
struct NtObjectAttributes *ObjectAttributes);
NtStatus NtQuerySymbolicLinkObject(int64_t DirectoryHandle,
struct NtUnicodeString *inout_TargetName,
uint32_t *opt_out_ReturnLength);
NtStatus ZwAreMappedFilesTheSame(void *Address1, void *Address2);
NtStatus NtQueryVolumeInformationFile(int64_t FileHandle,
struct NtIoStatusBlock *out_IoStatusBlock,
void *out_FsInformation, uint32_t Length,
uint32_t FsInformationClass);
NtStatus NtQuerySecurityObject(
int64_t handle, int RequestedInformation,
struct NtSecurityDescriptor *out_SecurityDescriptor,
uint32_t SecurityDescriptorLength, uint32_t *out_ReturnLength);
NtStatus NtQueueApcThread(int64_t ThreadHandle, NtPkNormalRoutine ApcRoutine,
void *opt_ApcContext, void *opt_Argument1,
void *opt_Argument2);
NtStatus NtFlushInstructionCache(int64_t ProcessHandle, void *opt_BaseAddress,
size_t FlushSize);
NtStatus NtQueryAttributesFile(const struct NtObjectAttributes *object,
struct NtFileBasicInformation *file_information);
NtStatus NtQueryDirectoryFile(
int64_t FileHandle, void *opt_Event, NtIoApcRoutine opt_ApcRoutine,
void *opt_ApcContext, struct NtIoStatusBlock *out_IoStatusBlock,
void *out_FileInformation, uint32_t FileInformationLength,
uint32_t FileInformationClass, int32_t ReturnSingleEntry,
struct NtUnicodeString *opt_FileName, int32_t RestartScan);
NtStatus NtFlushVirtualMemory(int64_t ProcessHandle, void **inout_BaseAddress,
uint32_t **inout_FlushSize,
struct NtIoStatusBlock *out_IoStatusBlock);
NtStatus NtQueryInformationJobObject(void *JobHandle, int JobInformationClass,
void *out_JobInformation,
uint32_t JobInformationLength,
uint32_t *opt_out_ReturnLength);
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § new technology » beyond the pale » runtime library ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
NtStatus RtlInitializeCriticalSection(struct NtCriticalSection *out_crit);
NtStatus RtlDeleteCriticalSection(struct NtCriticalSection *crit);
NtStatus RtlEnterCriticalSection(struct NtCriticalSection *inout_crit);
NtStatus RtlLeaveCriticalSection(struct NtCriticalSection *inout_crit);
NtStatus RtlTryEnterCriticalSection(struct NtCriticalSection *inout_crit);
NtStatus RtlInitUnicodeString(struct NtUnicodeString *inout_DestinationString,
const char16_t *SourceString);
void RtlFreeUnicodeString(struct NtUnicodeString **string);
NtStatus RtlQueryEnvironmentVariable_U(char16_t *Environment,
struct NtUnicodeString *Name,
struct NtUnicodeString *Value);
NtStatus RtlConvertSidToUnicodeString(struct NtUnicodeString *out_UnicodeString,
void *Sid,
int32_t AllocateDestinationString);
void *RtlCreateHeap(uint32_t flags, void *base, size_t reserve_sz,
size_t commit_sz, void *lock, void *params);
NtStatus RtlDestroyHeap(void *base);
void *RtlAllocateHeap(int64_t heap, uint32_t flags, size_t size);
void *RtlReAllocateHeap(int64_t heap, uint32_t flags, void *ptr, size_t size);
NtStatus RtlFreeHeap(int64_t heap, uint32_t flags, void *ptr);
size_t RtlSizeHeap(int64_t heap, uint32_t flags, void *ptr);
NtStatus RtlValidateHeap(int64_t heap, uint32_t flags, void *ptr);
NtStatus RtlLockHeap(int64_t heap);
NtStatus RtlUnlockHeap(int64_t heap);
NtStatus RtlGetProcessHeaps(uint32_t count, void **out_Heaps);
NtStatus RtlWalkHeap(int64_t heap, void *out_Info);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/ntdll.inc */
#define NtYieldExecution(...) __imp_NtYieldExecution(__VA_ARGS__)
extern typeof(NtYieldExecution) *const __imp_NtYieldExecution __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/ntdllimport.h */
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
│ vi: set noet ft=asm ts=8 sw=8 fenc=utf-8 :vi │
╞══════════════════════════════════════════════════════════════════════════════╡
│ Copyright 2020 Justine Alexandra Roberts Tunney │
│ │
│ Permission to use, copy, modify, and/or distribute this software for │
│ any purpose with or without fee is hereby granted, provided that the │
│ above copyright notice and this permission notice appear in all copies. │
│ │
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
│ PERFORMANCE OF THIS SOFTWARE. │
╚─────────────────────────────────────────────────────────────────────────────*/
#define COSMOPOLITAN_LIBC_NT_NTDLLIMPORT_H_
#ifdef __ASSEMBLER__
/* clang-format off */
.macro .ntimp fn:req name:req
#ifdef __x86_64__
.yoink _init_ntdll
.initbss 202,_init_ntdll.\fn
__imp_\fn:
.quad 0
.endobj __imp_\fn,globl,hidden
.previous
.initro 202,_init_ntdll.2.\fn
.quad RVA(.L\fn)
.previous
.section .rodata.str1.1,"aSM",@progbits,1
.L\fn:
.asciz "\fn"
.previous
#elif defined(__aarch64__)
.section .data.nt.\fn,"aw",@progbits
.globl __imp_\fn
.balign 8
__imp_\fn:
.quad \name
.weak \name
#endif
.endm
/* clang-format on */
#endif /* __ASSEMBLER__ */
/*!BEGIN libc/nt/paint.h */
#define COSMOPOLITAN_LIBC_NT_PAINT_H_
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § new technology » cpu graphics ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
int64_t BeginPaint(int64_t hWnd, struct NtPaintStruct *lpPaint);
int32_t EndPaint(int64_t hWnd, const struct NtPaintStruct *lpPaint);
int32_t BitBlt(int64_t hdc, int x, int y, int cx, int cy, int64_t hdcSrc,
int x1, int y1, uint32_t rop);
int32_t GetClientRect(int64_t hWnd, struct NtRect *lpRect);
int32_t GetWindowRect(int64_t hWnd, struct NtRect *lpRect);
int32_t SetBkMode(int64_t hdc, int mode);
uint32_t SetTextColor(int64_t hdc, uint32_t color);
uint32_t SetTextAlign(int64_t hdc, uint32_t align);
int32_t SetTextJustification(int64_t hdc, int extra, int count);
int32_t DrawText(int64_t hdc, const char16_t *lpchText, int cchText,
struct NtRect *lprc, uint32_t format);
int32_t DrawTextEx(int64_t hdc, char16_t *lpchText, int cchText,
struct NtRect *lprc, uint32_t format,
struct NtDrawTextParams *lpdtp);
int32_t FillRect(int64_t hDC, const struct NtRect *lpRC, int64_t hBrush);
uint32_t GetPixel(int64_t hdc, int x, int y);
uint32_t SetPixel(int64_t hdc, int x, int y, uint32_t color);
bool32 RedrawWindow(int64_t hWnd, const struct NtRect *opt_lprcUpdate,
int64_t opt_hrgnUpdate, uint32_t rdwFlags);
int64_t CreateCompatibleDC(int64_t hdc);
int64_t CreateCompatibleBitmap(int64_t hdc, int cx, int cy);
int64_t SelectObject(int64_t hdc, int64_t h);
bool32 DeleteObject(int64_t ho);
bool32 DeleteDC(int64_t hdc);
int SaveDC(int64_t hdc);
bool32 RestoreDC(int64_t hdc, int nSavedDC);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/paint.inc */
#define SetPixel(...) __imp_SetPixel(__VA_ARGS__)
#define GetPixel(...) __imp_GetPixel(__VA_ARGS__)
extern typeof(SetPixel) *const __imp_SetPixel __msabi;
extern typeof(GetPixel) *const __imp_GetPixel __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/pdh.h */
#define COSMOPOLITAN_LIBC_NT_PDH_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » performance counters ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
COSMOPOLITAN_C_START_
int PdhOpenQuery(const char16_t *opt_szDataSource, uint32_t *dwUserData,
int64_t *out_phQuery);
int PdhAddEnglishCounter(int64_t hQuery, const char16_t *szFullCounterPath,
uint32_t *dwUserData, int64_t *out_phCounter);
int PdhCollectQueryDataEx(int64_t hQuery, uint32_t dwIntervalTime,
int64_t hNewDataEvent);
int PdhGetFormattedCounterValue(int64_t hCounter, uint32_t dwFormat,
uint32_t *out_opt_lpdwType,
struct NtPdhFmtCountervalue *out_pValue);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/privilege.h */
#define COSMOPOLITAN_LIBC_NT_PRIVILEGE_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » check your privilege ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define kNtSePrivilegeEnabledByDefault 0x00000001u
#define kNtSePrivilegeEnabled 0x00000002u
#define kNtSePrivilegeRemoved 0x00000004u
#define kNtSePrivilegeUsedForAccess 0x80000000u
COSMOPOLITAN_C_START_
bool32 LookupPrivilegeValue(const char16_t *opt_lpSystemName,
const char16_t *lpName, struct NtLuid *out_lpLuid);
bool32 AdjustTokenPrivileges(int64_t TokenHandle, bool32 DisableAllPrivileges,
const struct NtTokenPrivileges *opt_NewState,
uint32_t BufferLength,
struct NtTokenPrivileges *opt_out_PreviousState,
uint32_t *opt_out_ReturnLength);
bool32 ImpersonateSelf(int kNtSecurityImpersonationLevel);
bool32 RevertToSelf(void);
bool32 OpenThreadToken(intptr_t ThreadHandle, uint32_t DesiredAccess,
bool32 OpenAsSelf, intptr_t *TokenHandle);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/process.h */
#define COSMOPOLITAN_LIBC_NT_PROCESS_H_
/*!BEGIN libc/nt/startupinfo.h */
#define COSMOPOLITAN_LIBC_NT_NTSTARTUPINFO_H_
COSMOPOLITAN_C_START_
#define kNtProcThreadAttributeParentProcess 0x00020000
#define kNtProcThreadAttributeHandleList 0x00020002
void GetStartupInfo(struct NtStartupInfo *lpStartupInfo);
bool32 InitializeProcThreadAttributeList(
struct NtProcThreadAttributeList *opt_inout_lpAttributeList,
uint32_t dwAttributeCount, uint32_t reserved_dwFlags, size_t *inout_lpSize);
bool32 UpdateProcThreadAttribute(
struct NtProcThreadAttributeList *inout_lpAttributeList, uint32_t dwFlags,
uint64_t Attribute, const void *lpValue, size_t cbSize,
void *reserved_lpPreviousValue, size_t *reserved_lpReturnSize);
void DeleteProcThreadAttributeList(
struct NtProcThreadAttributeList *inout_lpAttributeList);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/startupinfo.inc */
#define GetStartupInfo(...) __imp_GetStartupInfoW(__VA_ARGS__)
extern typeof(GetStartupInfo) *const __imp_GetStartupInfoW __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » processes ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
COSMOPOLITAN_C_START_
bool32 CreateProcess(const char16_t *opt_lpApplicationName,
char16_t *lpCommandLine,
const struct NtSecurityAttributes *opt_lpProcessAttributes,
const struct NtSecurityAttributes *opt_lpThreadAttributes,
bool32 bInheritHandles, uint32_t dwCreationFlags,
void *opt_lpEnvironment,
const char16_t *opt_lpCurrentDirectory,
const struct NtStartupInfo *lpStartupInfo,
struct NtProcessInformation *opt_out_lpProcessInformation)
paramsnonnull((9));
uint32_t GetThreadId(int64_t hThread); /* cf. NT_TID */
uint32_t GetProcessId(int64_t hProcess); /* cf. NT_PID */
void SetLastError(uint32_t dwErrCode);
uint32_t FormatMessage(uint32_t dwFlags, const void *lpSource,
uint32_t dwMessageId, uint32_t dwLanguageId,
char16_t *lpBuffer, uint32_t nSize, va_list *Arguments);
uint32_t FormatMessageA(uint32_t dwFlags, const void *lpSource,
uint32_t dwMessageId, uint32_t dwLanguageId,
char *lpBuffer, uint32_t nSize, va_list *Arguments);
int64_t OpenProcess(uint32_t dwDesiredAccess, bool32 bInheritHandle,
uint32_t dwProcessId);
uint32_t GetCurrentProcessId(void); /* %gs:0x40 */
uint32_t GetEnvironmentVariable(const char16_t *lpName, char16_t *lpBuffer,
uint32_t nSize);
uint32_t SetEnvironmentVariable(const char16_t *lpName,
const char16_t *lpValue);
int32_t SetEnvironmentStrings(char16_t *NewEnvironment);
bool32 GetProcessAffinityMask(int64_t hProcess, uint64_t *lpProcessAffinityMask,
uint64_t *lpSystemAffinityMask);
uint64_t /*bool32*/ SetProcessAffinityMask(int64_t hProcess,
uint64_t dwProcessAffinityMask);
/* e.g. kNtAboveNormalPriorityClass, kNtHighPriorityClass */
uint32_t GetPriorityClass(int64_t hProcess);
bool32 SetPriorityClass(int64_t hProcess, uint32_t dwPriorityClass);
bool32 SetProcessPriorityBoost(int64_t hProcess, bool32 bDisablePriorityBoost);
bool32 GetProcessPriorityBoost(int64_t hProcess, bool32 *pDisablePriorityBoost);
bool32 GetProcessMemoryInfo(
int64_t hProcess, struct NtProcessMemoryCountersEx *out_ppsmemCounters,
uint32_t cb);
int64_t CreateToolhelp32Snapshot(uint32_t dwFlags, uint32_t th32ProcessID);
bool32 Process32First(int64_t hSnapshot, struct NtProcessEntry32 *in_out_lppe);
bool32 Process32Next(int64_t hSnapshot, struct NtProcessEntry32 *out_lppe);
bool32 EnumProcesses(uint32_t *out_lpidProcess, uint32_t cb,
uint32_t *out_lpcbNeeded) paramsnonnull();
bool32 EnumProcessModules(int64_t hProcess, int64_t *out_lphModule, uint32_t cb,
uint32_t *out_lpcbNeeded) paramsnonnull();
bool32 EnumProcessModulesEx(int64_t hProcess, int64_t *out_lphModule,
uint32_t cb, uint32_t *out_lpcbNeeded,
uint32_t dwFilterFlag) paramsnonnull();
uint32_t GetModuleBaseName(int64_t hProcess, int64_t opt_hModule,
char16_t *out_lpBaseName, uint32_t nSize)
paramsnonnull();
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/process.inc */
#define GetEnvironmentVariable(...) __imp_GetEnvironmentVariableW(__VA_ARGS__)
extern typeof(GetEnvironmentVariable) *const __imp_GetEnvironmentVariableW
__msabi;
#define SetEnvironmentVariable(...) __imp_SetEnvironmentVariableW(__VA_ARGS__)
extern typeof(SetEnvironmentVariable) *const __imp_SetEnvironmentVariableW
__msabi;
#define GetPriorityClass(...) __imp_GetPriorityClass(__VA_ARGS__)
extern typeof(GetPriorityClass) *const __imp_GetPriorityClass __msabi;
#define SetPriorityClass(...) __imp_SetPriorityClass(__VA_ARGS__)
extern typeof(SetPriorityClass) *const __imp_SetPriorityClass __msabi;
#define GetCurrentProcessId(...) __imp_GetCurrentProcessId(__VA_ARGS__)
extern typeof(GetCurrentProcessId) *const __imp_GetCurrentProcessId __msabi;
extern typeof(FormatMessage) *const __imp_FormatMessageW __msabi;
extern typeof(SetLastError) *const __imp_SetLastError __msabi;
extern typeof(FormatMessage) *const __imp_FormatMessage __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/registry.h */
#define COSMOPOLITAN_LIBC_NT_REGISTRY_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » registry ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#define kNtMaxKeyNameChars 255
#define kNtMaxValueNameChars 16383
#define kNtMaxValueBytes 0x100000
#define kNtHkeyClassesRoot 0x80000000l
#define kNtHkeyCurrentUser 0x80000001l
#define kNtHkeyLocalMachine 0x80000002l
#define kNtHkeyUsers 0x80000003l
#define kNtHkeyPerformanceData 0x80000004l
#define kNtHkeyPerformanceText 0x80000050l
#define kNtHkeyPerformanceNlstext 0x80000060l
#define kNtHkeyCurrentConfig 0x80000005l
#define kNtHkeyDynData 0x80000006l
#define kNtHkeyCurrentUserLocalSettings 0x80000007l
COSMOPOLITAN_C_START_
int RegOpenKey(int64_t hKey, const char16_t *opt_lpSubKey,
int64_t *out_phkResult) paramsnonnull((3));
int RegOpenKeyEx(int64_t hKey, const char16_t *opt_lpSubKey,
uint32_t opt_ulOptions, int samDesired, int64_t *out_phkResult)
paramsnonnull((5));
int RegCloseKey(int64_t hKey);
int RegGetValue(int64_t hkey, const char16_t *opt_lpSubKey,
const char16_t *opt_lpValue, unsigned dwFlags, int *opt_pdwType,
void *opt_out_pvData, uint32_t *opt_inout_pcbDataBytes);
int RegSetValue(int64_t hKey, const char16_t *lpSubKey, int dwType,
const char16_t *lpData, uint32_t cbData);
int RegSetValueEx(int64_t hKey, const char16_t *lpValueName, uint32_t Reserved,
int dwType, const unsigned char *lpData, uint32_t cbData);
int RegQueryInfoKey(int64_t hKey, char16_t *opt_out_lpClass,
uint32_t *opt_inout_lpClassLen, uint32_t *lpReserved,
uint32_t *opt_out_lpcSubKeys,
uint32_t *opt_out_lpcbMaxSubKeyBytes,
uint32_t *opt_out_lpcbMaxClassBytes,
uint32_t *opt_out_lpcValues,
uint32_t *opt_out_lpcbMaxValueNameBytes,
uint32_t *opt_out_lpcbMaxValueBytes,
uint32_t *opt_out_lpcbSecurityDescriptorBytes,
struct NtFileTime *opt_out_lpftLastWriteTime);
int RegEnumKey(int64_t hKey, uint32_t dwIndex, char16_t *opt_lpName,
uint32_t NameLen);
int RegEnumKeyEx(int64_t hKey, uint32_t dwIndex, char16_t *out_lpName,
uint32_t *inout_lpcchName, uint32_t *lpReserved,
char16_t *opt_out_lpClass, uint32_t *opt_inout_lpcchClassLen,
struct NtFileTime *opt_out_lpftLastWriteTime);
int RegEnumValue(int64_t hKey, uint32_t dwIndex, char16_t *lpValueName,
uint32_t *lpValueNameLen, uint32_t *lpReserved,
int *opt_out_lpType, unsigned char *opt_out_lpData,
uint32_t *opt_inout_lpcbDataBytes);
int RegQueryValue(int64_t hKey, const char16_t *opt_lpSubKey,
char16_t *opt_out_lpData, int32_t *opt_inout_lpcbDataBytes);
int RegQueryValueEx(int64_t hKey, const char16_t *opt_lpValueName,
uint32_t *lpReserved, int *opt_out_lpType,
unsigned char *opt_out_lpData,
uint32_t *opt_inout_lpcbDataBytes);
int RegOverridePredefKey(int64_t hKey, int64_t hNewHKey);
int RegOpenUserClassesRoot(void *hToken, uint32_t dwOptions, int samDesired,
int64_t *phkResult);
int RegOpenCurrentUser(int samDesired, int64_t *phkResult);
int RegDisablePredefinedCache();
int RegConnectRegistry(const char16_t *lpMachineName, int64_t hKey,
int64_t *phkResult);
int RegConnectRegistryEx(const char16_t *lpMachineName, int64_t hKey,
uint32_t Flags, int64_t *phkResult);
int RegCreateKey(int64_t hKey, const char16_t *lpSubKey, int64_t *phkResult);
int RegCreateKeyEx(int64_t hKey, const char16_t *lpSubKey, uint32_t Reserved,
int16_t *lpClass, uint32_t dwOptions, int samDesired,
const struct NtSecurityAttributes *lpSecurityAttributes,
int64_t *phkResult, uint32_t *lpdwDisposition);
int RegDeleteKey(int64_t hKey, const char16_t *lpSubKey);
int RegDeleteKeyEx(int64_t hKey, const char16_t *lpSubKey, int samDesired,
uint32_t Reserved);
int RegDeleteTree(int64_t hKey, const char16_t *opt_lpSubKey);
int RegDisableReflectionKey(int64_t hBase);
int RegEnableReflectionKey(int64_t hBase);
int RegQueryReflectionKey(int64_t hBase, bool32 *bIsReflectionDisabled);
int RegDeleteValue(int64_t hKey, const char16_t *lpValueName);
int RegFlushKey(int64_t hKey);
int RegGetKeySecurity(int64_t hKey, uint32_t SecurityInformation,
void *pSecurityDescriptor,
uint32_t *lpcbSecurityDescriptorBytes);
int RegLoadKey(int64_t hKey, const char16_t *lpSubKey, const char16_t *lpFile);
int RegNotifyChangeKeyValue(int64_t hKey, bool32 bWatchSubtree,
uint32_t dwNotifyFilter, void *hEvent,
int fAsynchronous);
int RegQueryMultipleValues(int64_t hKey, struct NtValent *inout_val_list,
uint32_t num_vals, int16_t *out_lpValueBuf,
uint32_t *inout_ldwTotsize) paramsnonnull();
int RegReplaceKey(int64_t hKey, const char16_t *lpSubKey,
const char16_t *lpNewFile, const char16_t *lpOldFile);
int RegRestoreKey(int64_t hKey, const char16_t *lpFile, uint32_t dwFlags);
int RegSaveKey(int64_t hKey, const char16_t *lpFile,
const struct NtSecurityAttributes *lpSecurityAttributes);
int RegSetKeySecurity(int64_t hKey, uint32_t SecurityInformation,
void *pSecurityDescriptor);
int RegUnLoadKey(int64_t hKey, const char16_t *lpSubKey);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/runtime.h */
#define COSMOPOLITAN_LIBC_NT_RUNTIME_H_
/**
* @fileoverview NT Obligatory Runtime Functions.
*
* These functions are placed in their own file because they're (a)
* abstracted by the Cosmopolitan runtime; and (b) it helps GCC avoid
* bloating binaries with debug information the user doesn't need.
*/
#define kNtCpUtf8 65001
#define kNtInvalidHandleValue -1L
#define kNtStdInputHandle -10u
#define kNtStdOutputHandle -11u
#define kNtStdErrorHandle -12u
#define GetCurrentProcess() -1
COSMOPOLITAN_C_START_
char16_t *GetCommandLine(void) nosideeffect;
char16_t *GetEnvironmentStrings(void) __wur;
bool32 FreeEnvironmentStrings(char16_t *) paramsnonnull();
bool32 ReadFile(int64_t hFile, void *lpBuffer, uint32_t nNumberOfBytesToRead,
uint32_t *lpNumberOfBytesRead,
struct NtOverlapped *opt_lpOverlapped);
bool32 WriteFile(int64_t hFile, const void *lpBuffer,
uint32_t nNumberOfBytesToWrite,
uint32_t *lpNumberOfBytesWritten,
struct NtOverlapped *opt_lpOverlapped);
bool32 TerminateProcess(int64_t hProcess, uint32_t uExitCode);
void TerminateThisProcess(uint32_t dwWaitStatus) wontreturn;
void ExitProcess(uint32_t uExitCode) wontreturn;
uint32_t GetLastError(void) nosideeffect;
bool32 CloseHandle(int64_t hObject) dontthrow dontcallback;
intptr_t GetStdHandle(uint32_t nStdHandle) nosideeffect;
bool32 SetStdHandle(uint32_t nStdHandle, int64_t hHandle);
bool32 SetDefaultDllDirectories(unsigned dirflags);
bool32 ProcessPrng(void *RandomBuffer, uint32_t RandomBufferLength);
uint32_t GetModuleFileName(int64_t hModule, char16_t *lpFilename,
uint32_t nSize);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/runtime.inc */
#define FreeEnvironmentStrings(...) __imp_FreeEnvironmentStringsW(__VA_ARGS__)
extern typeof(FreeEnvironmentStrings) *const __imp_FreeEnvironmentStringsW
__msabi;
#define GetCommandLine(...) __imp_GetCommandLineW(__VA_ARGS__)
extern typeof(GetCommandLine) *const __imp_GetCommandLineW __msabi;
#define GetEnvironmentStrings(...) __imp_GetEnvironmentStringsW(__VA_ARGS__)
extern typeof(GetEnvironmentStrings) *const __imp_GetEnvironmentStringsW
__msabi;
#define GetStdHandle(...) __imp_GetStdHandle(__VA_ARGS__)
extern typeof(GetStdHandle) *const __imp_GetStdHandle __msabi;
#define SetStdHandle(...) __imp_SetStdHandle(__VA_ARGS__)
extern typeof(SetStdHandle) *const __imp_SetStdHandle __msabi;
#define ReadFile(...) __imp_ReadFile(__VA_ARGS__)
extern typeof(ReadFile) *const __imp_ReadFile __msabi;
#define WriteFile(...) __imp_WriteFile(__VA_ARGS__)
extern typeof(WriteFile) *const __imp_WriteFile __msabi;
#define SetDefaultDllDirectories(...) \
__imp_SetDefaultDllDirectories(__VA_ARGS__)
extern typeof(SetDefaultDllDirectories) *const __imp_SetDefaultDllDirectories
__msabi;
#define GetModuleFileName(...) __imp_GetModuleFileNameW(__VA_ARGS__)
extern typeof(GetModuleFileName) *const __imp_GetModuleFileNameW __msabi;
extern typeof(GetLastError) *const __imp_GetLastError __msabi;
extern typeof(ExitProcess) *const __imp_ExitProcess __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/signals.h */
#define COSMOPOLITAN_LIBC_NT_EXCEPTIONS_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » signals ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
COSMOPOLITAN_C_START_
typedef int (*NtTopLevelExceptionFilter)(const struct NtExceptionPointers *);
typedef int32_t (*NtVectoredExceptionHandler)(struct NtExceptionPointers *);
int SetErrorMode(int uMode);
int64_t AddVectoredExceptionHandler(uint32_t First,
NtVectoredExceptionHandler pHandler);
int64_t AddVectoredContinueHandler(uint32_t First,
NtVectoredExceptionHandler pHandler);
uint32_t RemoveVectoredExceptionHandler(int64_t hHandle);
uint32_t RemoveVectoredContinueHandler(int64_t hHandle);
NtTopLevelExceptionFilter SetUnhandledExceptionFilter(
NtTopLevelExceptionFilter opt_lpTopLevelExceptionFilter);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/signals.inc */
#define SetErrorMode(...) __imp_SetErrorMode(__VA_ARGS__)
#define AddVectoredExceptionHandler(...) \
__imp_AddVectoredExceptionHandler(__VA_ARGS__)
#define AddVectoredContinueHandler(...) \
__imp_AddVectoredContinueHandler(__VA_ARGS__)
#define RemoveVectoredExceptionHandler(...) \
__imp_RemoveVectoredExceptionHandler(__VA_ARGS__)
#define RemoveVectoredContinueHandler(...) \
__imp_RemoveVectoredContinueHandler(__VA_ARGS__)
#define SetUnhandledExceptionFilter(...) \
__imp_SetUnhandledExceptionFilter(__VA_ARGS__)
extern typeof(SetErrorMode) *const __imp_SetErrorMode __msabi;
extern typeof(AddVectoredExceptionHandler) *const
__imp_AddVectoredExceptionHandler __msabi;
extern typeof(AddVectoredContinueHandler) *const
__imp_AddVectoredContinueHandler __msabi;
extern typeof(RemoveVectoredExceptionHandler) *const
__imp_RemoveVectoredExceptionHandler __msabi;
extern typeof(RemoveVectoredContinueHandler) *const
__imp_RemoveVectoredContinueHandler __msabi;
extern typeof(SetUnhandledExceptionFilter) *const
__imp_SetUnhandledExceptionFilter __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/synchronization.h */
#define COSMOPOLITAN_LIBC_NT_SYNCHRONIZATION_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » synchronization ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
static inline int32_t InterlockedAdd(int32_t volatile *p, int32_t x) {
return atomic_fetch_add((_Atomic(int32_t) *)p, x) + x;
}
static inline int32_t InterlockedExchange(int32_t volatile *p, int32_t x) {
return atomic_exchange((_Atomic(int32_t) *)p, x);
}
typedef void (*NtTimerapcroutine)(void *lpArgToCompletionRoutine,
uint32_t dwTimerLowValue,
uint32_t dwTimerHighValue);
typedef void (*NtWaitOrTimerCallback)(void *lpParameter,
bool32 TimerOrWaitFired);
void WakeByAddressAll(void *Address);
void WakeByAddressSingle(void *Address);
bool32 WaitOnAddress(const volatile void *Address, void *CompareAddress,
size_t AddressSize, uint32_t opt_dwMilliseconds);
void Sleep(uint32_t dwMilliseconds);
uint32_t SleepEx(uint32_t dwMilliseconds, bool32 bAlertable);
void GetSystemTime(struct NtSystemTime *lpSystemTime);
bool32 SystemTimeToFileTime(const struct NtSystemTime *lpSystemTime,
struct NtFileTime *lpFileTime);
void GetSystemTimeAsFileTime(struct NtFileTime *);
void GetSystemTimePreciseAsFileTime(struct NtFileTime *); /* win8+ */
uint32_t WaitForSingleObject(int64_t hHandle, uint32_t dwMilliseconds);
uint32_t WaitForMultipleObjects(uint32_t nCount, const int64_t *lpHandles,
bool32 bWaitAll, uint32_t dwMilliseconds);
uint32_t WaitForSingleObjectEx(int64_t hHandle, uint32_t dwMilliseconds,
bool32 bAlertable);
uint32_t WaitForMultipleObjectsEx(unsigned int nCount, const int64_t *lpHandles,
bool32 bWaitAll, uint32_t dwMilliseconds,
bool32 bAlertable);
bool32 RegisterWaitForSingleObject(int64_t *phNewWaitObject, int64_t hObject,
NtWaitOrTimerCallback Callback,
void *Context, uint32_t dwMilliseconds,
uint32_t dwFlags);
int64_t CreateWaitableTimer(
const struct NtSecurityAttributes *lpTimerAttributes, bool32 bManualReset,
const char16_t *lpTimerName);
bool32 SetWaitableTimer(int64_t hTimer, const int64_t *lpDueTimeAsFtOrNegRela,
int32_t opt_lPeriodMs, NtTimerapcroutine opt_callback,
void *lpArgToCallback, bool32 fUnsleepSystem);
int64_t CreateSemaphore(
const struct NtSecurityAttributes *opt_lpSemaphoreAttributes,
uint32_t lInitialCount, uint32_t lMaximumCount, const char16_t *opt_lpName);
int32_t ReleaseMutex(int64_t hMutex);
int32_t ReleaseSemaphore(int64_t hSemaphore, int32_t lReleaseCount,
int *lpPreviousCount);
void InitializeCriticalSection(struct NtCriticalSection *lpCriticalSection);
void EnterCriticalSection(struct NtCriticalSection *lpCriticalSection);
void LeaveCriticalSection(struct NtCriticalSection *lpCriticalSection);
int32_t TryEnterCriticalSection(struct NtCriticalSection *lpCriticalSection);
void DeleteCriticalSection(struct NtCriticalSection *lpCriticalSection);
int32_t InitializeCriticalSectionAndSpinCount(
struct NtCriticalSection *lpCriticalSection, uint32_t dwSpinCount);
uint32_t SetCriticalSectionSpinCount(
struct NtCriticalSection *lpCriticalSection, uint32_t dwSpinCount);
void InitializeSRWLock(intptr_t *);
void AcquireSRWLockExclusive(intptr_t *);
void AcquireSRWLockShared(intptr_t *);
void ReleaseSRWLockExclusive(intptr_t *);
void ReleaseSRWLockShared(intptr_t *);
void TryAcquireSRWLockExclusive(intptr_t *);
void TryAcquireSRWLockShared(intptr_t *);
uint64_t GetTickCount64(void);
bool32 QueryPerformanceFrequency(uint64_t *lpFrequency);
bool32 QueryPerformanceCounter(uint64_t *lpPerformanceCount);
bool32 GetSystemTimeAdjustment(uint32_t *lpTimeAdjustment,
uint32_t *lpTimeIncrement,
bool32 *lpTimeAdjustmentDisabled);
void GetCurrentProcessorNumberEx(struct NtProcessorNumber *out_ProcNumber);
bool32 GetNumaProcessorNodeEx(const struct NtProcessorNumber *Processor,
unsigned short *out_NodeNumber);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/synchronization.inc */
extern typeof(SleepEx) *const __imp_SleepEx __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/system.h */
#define COSMOPOLITAN_LIBC_NT_SYSTEM_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » system control ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
COSMOPOLITAN_C_START_
bool32 SetSuspendState(bool32 bHibernate, bool32 bForce,
bool32 bWakeupEventsDisabled);
uint32_t InitiateShutdown(const char16_t *lpMachineName,
const char16_t *lpMessage, uint32_t dwGracePeriod,
uint32_t dwShutdownFlags, uint32_t dwReason);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/systeminfo.h */
#define COSMOPOLITAN_LIBC_NT_INFO_H_
COSMOPOLITAN_C_START_
void GetSystemInfo(struct NtSystemInfo *lpSystemInfo);
uint32_t GetSystemDirectory(char16_t *lpBuffer, uint32_t uSize);
uint32_t GetSystemDirectoryA(char *lpBuffer, uint32_t uSize);
uint32_t GetWindowsDirectory(char16_t *lpBuffer, uint32_t uSize);
uint32_t GetTempPath(uint32_t uSize, char16_t *lpBuffer);
bool32 GetComputerNameEx(/* enum/computernameformat.h */ int NameType,
char16_t *opt_lpBuffer, uint32_t *nSize);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/systeminfo.inc */
#define GetSystemInfo(...) __imp_GetSystemInfo(__VA_ARGS__)
#define GetTempPath(...) __imp_GetTempPathW(__VA_ARGS__)
extern typeof(GetSystemInfo) *const __imp_GetSystemInfo __msabi;
extern typeof(GetTempPath) *const __imp_GetTempPathW __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/thread.h */
#define COSMOPOLITAN_LIBC_NT_THREADS_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » threads ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
int64_t CreateThread(const struct NtSecurityAttributes *lpThreadAttributes,
size_t dwStackSize, void *lpStartAddress,
void *lpParameter, uint32_t dwCreationFlags,
uint32_t *opt_lpThreadId) paramsnonnull((3));
void ExitThread(uint32_t dwExitCode) wontreturn;
int64_t GetCurrentThread(void);
uint32_t GetCurrentThreadId(void);
uint64_t SetThreadAffinityMask(int64_t hThread, uintptr_t dwThreadAffinityMask);
int64_t OpenThread(uint32_t dwDesiredAccess, bool32 bInheritHandle,
uint32_t dwThreadId);
bool32 TerminateThread(int64_t hThread, uint32_t dwExitCode);
bool32 GetExitCodeThread(int64_t hThread, uint32_t *lpExitCode);
/* e.g. kNtThreadPriorityAboveNormal, -1u on error */
uint32_t GetThreadPriority(int64_t hThread);
bool32 SetThreadPriority(int64_t hThread, int32_t nPriority);
bool32 SetThreadPriorityBoost(int64_t hThread, bool32 bDisablePriorityBoost);
bool32 GetThreadPriorityBoost(int64_t hThread, bool32 *pDisablePriorityBoost);
bool32 GetThreadIOPendingFlag(int64_t hThread, bool32 *lpIOIsPending);
bool32 CancelSynchronousIo(int64_t hThread);
bool32 CancelIo(int64_t hFile);
bool32 CancelIoEx(int64_t hFile, struct NtOverlapped *opt_lpOverlapped);
uint32_t TlsAlloc(void);
bool32 TlsFree(uint32_t);
bool32 TlsSetValue(uint32_t, void *);
void *TlsGetValue(uint32_t);
uint32_t SuspendThread(int64_t hThread);
uint32_t ResumeThread(int64_t hThread);
bool32 GetThreadContext(int64_t hThread, struct NtContext *in_out_lpContext);
bool32 SetThreadContext(int64_t hThread, const struct NtContext *lpContext);
void *SetThreadDescription(int64_t hThread,
const char16_t *lpThreadDescription);
void *GetThreadDescription(int64_t hThread,
char16_t *out_ppszThreadDescription);
#if ShouldUseMsabiAttribute()
/*!BEGIN libc/nt/thunk/thread.inc */
#define GetCurrentThread(...) __imp_GetCurrentThread(__VA_ARGS__)
#define GetThreadPriority(...) __imp_GetThreadPriority(__VA_ARGS__)
#define SetThreadPriority(...) __imp_SetThreadPriority(__VA_ARGS__)
extern typeof(GetCurrentThread) *const __imp_GetCurrentThread __msabi;
extern typeof(GetThreadPriority) *const __imp_GetThreadPriority __msabi;
extern typeof(SetThreadPriority) *const __imp_SetThreadPriority __msabi;
#endif /* ShouldUseMsabiAttribute() */
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/time.h */
#define COSMOPOLITAN_LIBC_NT_TIME_H_
COSMOPOLITAN_C_START_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » time ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
uint32_t GetTimeZoneInformation(
struct NtTimeZoneInformation *out_lpTimeZoneInformation);
uint32_t GetDynamicTimeZoneInformation(
struct NtDynamicTimeZoneInformation *out_lpTimeZoneInformation);
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/version.h */
#define COSMOPOLITAN_LIBC_NT_VERSION_H_
COSMOPOLITAN_C_START_
bool32 IsAtLeastWindows10(void) pureconst;
bool32 GetVersionEx(struct NtOsVersionInfo *lpVersionInformation);
#if defined(__GNUC__) && !defined(__STRICT_ANSI__) && defined(__x86_64__)
#define IsAtLeastWindows10() (GetNtMajorVersion() >= 10)
#define GetNtMajorVersion() \
__extension__({ \
uintptr_t __x; \
__asm__("mov\t%%gs:96,%q0\r\n" \
"mov\t280(%q0),%b0" \
: "=q"(__x)); \
(unsigned char)__x; \
})
#endif
COSMOPOLITAN_C_END_
/*!BEGIN libc/nt/windows.h */
#define COSMOPOLITAN_LIBC_NT_WINDOWS_H_
/* ░░░░
▒▒▒░░░▒▒▒▒▒▒▒▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▓▓▓▓▓▓░
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓░
▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▒ ▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒▒▒░░░░▒▒▒▒▒▒▓▓▓▓▓▓ █▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓░ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
▒▒▒▒░░░▒▒▒▒▒▒▒▓▓▓▓▓▓ ▒▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▒
▒▒▒▒▓▓ ▓▒▒▓▓▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▓ ▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓
░░░░░░░░░░░▒▒▒▒ ▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓█
▒▒░░░░░░░░░░▒▒▒▒▒▓▓▓ ▓▓▓▓▓▒▒▒▒▒▒▒▒▒▒▓▓▓
░▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓░ ░▓███▓
▒▒░░░░░░░░░░▒▒▒▒▒▓▓░ ▒▓▓▓▒▒▒ ░▒▒▒▓ ████████████
▒▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▒▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒░ ░███
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ███
▒▒░░░░░░░░░░▒▒▒▒▒▒▓▓ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ▓██
▒░░░░░░░░░░░▒▒▒▒▒▓▓ ▓▓▓▓▒▒▒▒▒▒▒▒░░░▒▒▒▒▒▓ ▓██
▒▒░░░▒▒▒░░░▒▒░▒▒▒▓▓▒ ▒▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▒ ███
░▒▓ ░▓▓▓▓▒▒▒▒▒▒▒▒░░░░▒▒▒▒▓ ▓██
╔────────────────────────────────────────────────────────────────▀▀▀─────────│─╗
│ cosmopolitan § new technology » windows ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
COSMOPOLITAN_C_START_
int64_t CreateWindowEx(uint32_t dwExStyle, const char16_t *lpClassName,
const char16_t *lpWindowName, uint32_t dwStyle, int X,
int Y, int nWidth, int nHeight, int64_t hWndParent,
int64_t hMenu, int64_t hInstance, int64_t lpParam);
uint16_t RegisterClass(const struct NtWndClass *lpWndClass);
int64_t DefWindowProc(int64_t hWnd, uint32_t Msg, uint64_t wParam,
int64_t lParam);
int32_t CloseWindow(int64_t hWnd);
int32_t DestroyWindow(int64_t hWnd);
int32_t ShowWindow(int64_t hWnd, int sw);
int32_t ShowCaret(bool32 bShow);
int32_t AnimateWindow(int64_t hWnd, uint32_t dwTime, uint32_t dwFlags);
int64_t LoadIcon(int64_t hInstance, const char16_t *lpIconName);
int32_t MoveWindow(int64_t hWnd, int X, int Y, int nWidth, int nHeight,
bool32 bRepaint);
int32_t BringWindowToTop(int64_t hWnd);
int32_t IsWindowVisible(int64_t hWnd);
int32_t SetWindowText(int64_t hWnd, const char16_t *lpString);
int32_t GetWindowText(int64_t hWnd, char16_t *lpString, int nMaxCount);
int32_t SetWindowPos(int64_t hWnd, int64_t hWndInsertAfter, int X, int Y,
int cx, int cy, uint32_t uFlags);
bool32 GetWindowPlacement(int64_t hWnd, struct NtWindowPlacement *lpwndpl);
bool32 SetWindowPlacement(int64_t hWnd,
const struct NtWindowPlacement *lpwndpl);
int64_t GetCursor(void);
int64_t SetCursor(int64_t hCursor);
int32_t ShowCursor(bool32 bShow);
int64_t LoadCursor(int64_t opt_hInstance, const char16_t *lpCursorNameOrIdc);
bool32 IsWindow(int64_t hWnd);
bool32 IsMenu(int64_t hMenu);
bool32 IsChild(int64_t hWndParent, int64_t hWnd);
bool32 IsZoomed(int64_t hWnd);
bool32 IsIconic(int64_t hWnd);
uintptr_t SetTimer(int64_t opt_hWnd, uintptr_t nIDEvent, uint32_t uElapseMs,
NtTimerProc lpTimerFunc);
int32_t KillTimer(int64_t hWnd, uintptr_t uIDEvent);
int64_t SetCapture(int64_t hWnd);
bool32 ReleaseCapture(void);
int16_t GetKeyState(int32_t nVirtKey);
int64_t CreateMenu(void);
int64_t CreatePopupMenu(void);
int64_t GetMenu(int64_t hWnd);
bool32 DestroyMenu(int64_t hMenu);
int64_t GetSystemMenu(int64_t hWnd, bool32 bRevert);
bool32 AppendMenu(int64_t hMenu, uint32_t mfFlags, uintptr_t uIDNewItem,
const char16_t *lpNewItem);
bool32 InsertMenu(int64_t hMenu, uint32_t uPosition, uint32_t uFlags,
uintptr_t uIDNewItem, const char16_t *lpNewItem);
bool32 TrackPopupMenu(int64_t hMenu, uint32_t uFlags, int32_t x, int32_t y,
int32_t nReserved, int64_t hWnd,
const struct NtRect *prcRect);
int WideCharToMultiByte(unsigned int CodePage, uint32_t dwFlags,
uint16_t *lpWideCharStr, int cchWideChar,
char *lpMultiByteStr, int cbMultiByte,
uint16_t *lpDefaultChar, int *lpUsedDefaultChar);
COSMOPOLITAN_C_END_
/*!BEGIN libc/runtime/clktck.h */
#define COSMOPOLITAN_LIBC_RUNTIME_CLKTCK_H_
COSMOPOLITAN_C_START_
#define CLK_TCK (__clk_tck())
int __clk_tck(void) pureconst;
COSMOPOLITAN_C_END_
/*!BEGIN libc/runtime/fenv.h */
#define COSMOPOLITAN_LIBC_RUNTIME_FENV_H_
#ifdef __x86_64__
#define FE_INVALID 1
#define __FE_DENORM 2
#define FE_DIVBYZERO 4
#define FE_OVERFLOW 8
#define FE_UNDERFLOW 16
#define FE_INEXACT 32
#define FE_ALL_EXCEPT 63
#define FE_TONEAREST 0x0000
#define FE_DOWNWARD 0x0400
#define FE_UPWARD 0x0800
#define FE_TOWARDZERO 0x0c00
#define FE_DFL_ENV ((const fenv_t *)-1)
typedef void *fenv_t;
typedef uint16_t fexcept_t;
#elif defined(__aarch64__)
#define FE_INVALID 1
#define FE_DIVBYZERO 2
#define FE_OVERFLOW 4
#define FE_UNDERFLOW 8
#define FE_INEXACT 16
#define FE_ALL_EXCEPT 31
#define FE_TONEAREST 0
#define FE_DOWNWARD 0x800000
#define FE_UPWARD 0x400000
#define FE_TOWARDZERO 0xc00000
#define FE_DFL_ENV ((const fenv_t *)-1)
typedef void *fenv_t;
typedef uint32_t fexcept_t;
#elif defined(__powerpc64__)
#define FE_TONEAREST 0
#define FE_TOWARDZERO 1
#define FE_UPWARD 2
#define FE_DOWNWARD 3
#define FE_INEXACT 0x02000000
#define FE_DIVBYZERO 0x04000000
#define FE_UNDERFLOW 0x08000000
#define FE_OVERFLOW 0x10000000
#define FE_INVALID 0x20000000
#define FE_ALL_EXCEPT 0x3e000000
#define FE_INVALID_SNAN 0x01000000
#define FE_INVALID_ISI 0x00800000
#define FE_INVALID_IDI 0x00400000
#define FE_INVALID_ZDZ 0x00200000
#define FE_INVALID_IMZ 0x00100000
#define FE_INVALID_COMPARE 0x00080000
#define FE_INVALID_SOFTWARE 0x00000400
#define FE_INVALID_SQRT 0x00000200
#define FE_INVALID_INTEGER_CONVERSION 0x00000100
#define FE_ALL_INVALID 0x01f80700
#define FE_DFL_ENV ((const fenv_t *)-1)
typedef unsigned fexcept_t;
typedef double fenv_t;
#endif /* __x86_64__ */
#ifdef __STDC_WANT_IEC_60559_TYPES_EXT__
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD_TS_18661_3__
#elif defined(__FLT_EVAL_METHOD__)
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
#else
#define FLT_EVAL_METHOD 0
#endif
COSMOPOLITAN_C_START_
#define FLT_ROUNDS (__flt_rounds())
int feclearexcept(int);
int fegetenv(fenv_t *);
int fegetexceptflag(fexcept_t *, int);
int fegetround(void);
int feholdexcept(fenv_t *);
int feraiseexcept(int);
int fesetenv(const fenv_t *);
int fesetexceptflag(const fexcept_t *, int);
int fesetround(int);
int fetestexcept(int);
int feenableexcept(int);
int fedisableexcept(int);
int feupdateenv(const fenv_t *);
int __flt_rounds(void);
int __fesetround(int);
COSMOPOLITAN_C_END_
/*!BEGIN libc/runtime/pathconf.h */
#define COSMOPOLITAN_LIBC_RUNTIME_PATHCONF_H_
#define _PC_LINK_MAX 0
#define _PC_MAX_CANON 1
#define _PC_MAX_INPUT 2
#define _PC_NAME_MAX 3
#define _PC_PATH_MAX 4
#define _PC_PIPE_BUF 5
#define _PC_CHOWN_RESTRICTED 6
#define _PC_NO_TRUNC 7
#define _PC_VDISABLE 8
#define _PC_SYNC_IO 9
#define _PC_ASYNC_IO 10
#define _PC_PRIO_IO 11
#define _PC_SOCK_MAXBUF 12
#define _PC_FILESIZEBITS 13
#define _PC_REC_INCR_XFER_SIZE 14
#define _PC_REC_MAX_XFER_SIZE 15
#define _PC_REC_MIN_XFER_SIZE 16
#define _PC_REC_XFER_ALIGN 17
#define _PC_ALLOC_SIZE_MIN 18
#define _PC_SYMLINK_MAX 19
#define _PC_2_SYMLINKS 20
COSMOPOLITAN_C_START_
long fpathconf(int, int);
long pathconf(const char *, int);
COSMOPOLITAN_C_END_
/*!BEGIN libc/runtime/runtime.h */
#define COSMOPOLITAN_LIBC_RUNTIME_RUNTIME_H_
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § runtime ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
#ifdef __x86_64__
typedef long jmp_buf[8];
typedef long sigjmp_buf[11];
#elif defined(__aarch64__)
typedef long jmp_buf[22];
typedef long sigjmp_buf[25];
#elif defined(__powerpc64__)
typedef unsigned __int128 jmp_buf[32];
#elif defined(__s390x__)
typedef unsigned long jmp_buf[18];
#elif defined(__riscv)
typedef unsigned long jmp_buf[26];
#endif
void mcount(void);
int daemon(int, int);
unsigned long getauxval(unsigned long);
int setjmp(jmp_buf)
libcesque returnstwice paramsnonnull();
void longjmp(jmp_buf, int) libcesque wontreturn paramsnonnull();
int _setjmp(jmp_buf)
libcesque returnstwice paramsnonnull();
int sigsetjmp(sigjmp_buf, int) libcesque returnstwice paramsnonnull();
void siglongjmp(sigjmp_buf, int) libcesque wontreturn paramsnonnull();
void _longjmp(jmp_buf, int) libcesque wontreturn paramsnonnull();
void exit(int) wontreturn;
void _exit(int) libcesque wontreturn;
void _Exit(int) libcesque wontreturn;
void quick_exit(int) wontreturn;
void abort(void) wontreturn;
int atexit(void (*)(void)) paramsnonnull() libcesque;
char *getenv(const char *) paramsnonnull() __wur nosideeffect libcesque;
int putenv(char *);
int setenv(const char *, const char *, int);
int unsetenv(const char *);
int clearenv(void);
void fpreset(void);
void *mmap(void *, uint64_t, int32_t, int32_t, int32_t, int64_t);
int munmap(void *, uint64_t);
int mprotect(void *, uint64_t, int);
int msync(void *, size_t, int);
int mlock(const void *, size_t);
int munlock(const void *, size_t);
long gethostid(void);
int sethostid(long);
char *getlogin(void);
int getlogin_r(char *, size_t);
int login_tty(int);
int getpagesize(void);
int syncfs(int) dontthrow;
int vhangup(void);
int getdtablesize(void);
int sethostname(const char *, size_t);
int acct(const char *);
#if defined(_GNU_SOURCE) || defined(_COSMO_SOURCE)
extern char **environ;
char *secure_getenv(const char *) paramsnonnull() __wur nosideeffect libcesque;
#endif
#ifdef _COSMO_SOURCE
extern int __argc;
extern char **__argv;
extern char **__envp;
extern unsigned long *__auxv;
extern intptr_t __oldstack;
extern char *__program_executable_name;
extern uint64_t __nosync;
extern int __strace;
extern int __ftrace;
extern uint64_t __syscount;
extern uint64_t kStartTsc;
extern const char kNtSystemDirectory[];
extern const char kNtWindowsDirectory[];
extern size_t __virtualmax;
extern size_t __stackmax;
extern bool32 __isworker;
/* utilities */
void _intsort(int *, size_t);
void _longsort(long *, size_t);
/* diagnostics */
void ShowCrashReports(void);
int ftrace_install(void);
int ftrace_enabled(int);
int strace_enabled(int);
void __print_maps(void);
void __printargs(const char *);
/* builtin sh-like system/popen dsl */
int _cocmd(int, char **, char **);
/* executable program */
char *GetProgramExecutableName(void);
char *GetInterpreterExecutableName(char *, size_t);
int __open_executable(void);
/* execution control */
int verynice(void);
void __warn_if_powersave(void);
void _Exit1(int) libcesque wontreturn;
void __paginate(int, const char *);
void __paginate_file(int, const char *);
/* memory management */
void _weakfree(void *);
void *_mapanon(size_t) attributeallocsize((1)) mallocesque;
void *_mapshared(size_t) attributeallocsize((1)) mallocesque;
void CheckForMemoryLeaks(void);
void CheckForFileLeaks(void);
bool32 _isheap(const void *);
void __enable_threads(void);
void __oom_hook(size_t);
/* code morphing */
void __morph_begin(void);
void __morph_end(void);
void __jit_begin(void);
void __jit_end(void);
void __clear_cache(void *, void *);
/* portability */
int NtGetVersion(void) pureconst;
bool32 IsGenuineBlink(void);
bool32 IsCygwin(void);
const char *GetCpuidOs(void);
const char *GetCpuidEmulator(void);
void GetCpuidBrand(char[13], uint32_t);
long __get_rlimit(int);
const char *__describe_os(void);
long __get_sysctl(int, int);
int __get_arg_max(void) pureconst;
int __get_cpu_count(void) pureconst;
long __get_avphys_pages(void) pureconst;
long __get_phys_pages(void) pureconst;
long __get_minsigstksz(void) pureconst;
void __get_main_stack(void **, size_t *, int *);
long __get_safe_size(long, long);
char *__get_tmpdir(void);
forceinline int __trace_disabled(int x) {
return 0;
}
#ifndef FTRACE
#define ftrace_enabled(...) __trace_disabled(__VA_ARGS__)
#endif
#ifndef SYSDEBUG
#define strace_enabled(...) __trace_disabled(__VA_ARGS__)
#endif
#endif /* _COSMO_SOURCE */
COSMOPOLITAN_C_END_
/*!BEGIN libc/runtime/stack.h */
#ifndef COSMOPOLITAN_LIBC_RUNTIME_STACK_H_
#define COSMOPOLITAN_LIBC_RUNTIME_STACK_H_
/**
* Returns preferred size and alignment of thread stack.
*/
#define GetStackSize() 262144
/**
* Returns preferred stack guard size.
*
* This is the max cpu page size of supported architectures.
*/
#define GetGuardSize() 16384
/**
* Align APE main thread stack at startup.
*
* You need this in your main program module:
*
* STATIC_STACK_ALIGN(GetStackSize());
*
* If you want to use GetStackAddr() and HaveStackMemory() safely on
* your main thread in your process. It causes crt.S to waste a tiny
* amount of memory to ensure those macros go extremely fast.
*/
#define STATIC_STACK_ALIGN(BYTES) \
_STACK_SYMBOL("ape_stack_align", _STACK_STRINGIFY(BYTES) _STACK_EXTRA)
/**
* Makes program stack executable if declared, e.g.
*
* STATIC_EXEC_STACK();
* int main() {
* char code[16] = {
* 0x55, // push %rbp
* 0xb8, 0007, 0x00, 0x00, 0x00, // mov $7,%eax
* 0x5d, // push %rbp
* 0xc3, // ret
* };
* int (*func)(void) = (void *)code;
* printf("result %d should be 7\n", func());
* }
*/
#define STATIC_EXEC_STACK() _STACK_SYMBOL("ape_stack_pf", "7")
#define _STACK_STRINGIFY(ADDR) #ADDR
#define _STACK_SYMBOL(NAME, VALUE) \
__asm__(".equ\t" NAME "," VALUE "\n\t" \
".globl\t" NAME)
#ifdef __SANITIZE_ADDRESS__
#define _STACK_EXTRA "*2"
#else
#define _STACK_EXTRA ""
#endif
#if defined(__GNUC__) && defined(__ELF__)
COSMOPOLITAN_C_START_
extern char ape_stack_prot[] __attribute__((__weak__));
extern char ape_stack_memsz[] __attribute__((__weak__));
extern char ape_stack_align[] __attribute__((__weak__));
/**
* Returns address of bottom of current stack.
*
* This always works on threads. If you want it to work on the main
* process too, then you'll need STATIC_STACK_ALIGN(GetStackSize())
* which will burn O(256kb) of memory to ensure thread invariants.
*/
#define GetStackAddr() ((GetStackPointer() - 1) & -GetStackSize())
#define GetStaticStackSize() ((uintptr_t)ape_stack_memsz)
/**
* Returns true if at least `n` bytes of stack are available.
*
* This always works on threads. If you want it to work on the main
* process too, then you'll need STATIC_STACK_ALIGN(GetStackSize())
* which will burn O(256kb) of memory to ensure thread invariants,
* which make this check exceedingly fast.
*/
#define HaveStackMemory(n) \
(GetStackPointer() >= GetStackAddr() + GetGuardSize() + (n))
/**
* Extends stack memory by poking large allocations.
*
* This can be particularly useful depending on how your system
* implements guard pages. For example, Windows can make stacks
* that aren't fully committed, in which case there's only 4096
* bytes of grows-down guard pages made by portable executable.
* If you alloca() more memory than that, you should call this,
* since it'll not only ensure stack overflows are detected, it
* will also trigger the stack to grow down safely.
*/
forceinline void CheckLargeStackAllocation(void *p, ssize_t n) {
for (; n > 0; n -= 4096) {
((char *)p)[n - 1] = 0;
}
}
void *NewCosmoStack(void) vallocesque;
int FreeCosmoStack(void *) libcesque;
/**
* Tunes stack size of main thread on Windows.
*
* On UNIX systems use `RLIMIT_STACK` to tune the main thread size.
*/
#define STATIC_STACK_SIZE(BYTES) \
_STACK_SYMBOL("ape_stack_memsz", _STACK_STRINGIFY(BYTES) _STACK_EXTRA)
/**
* Tunes main thread stack address on Windows.
*/
#define STATIC_STACK_ADDR(ADDR) \
_STACK_SYMBOL("ape_stack_vaddr", _STACK_STRINGIFY(ADDR))
#ifdef __x86_64__
/**
* Returns preferred bottom address of main thread stack.
*
* On UNIX systems we favor the system provided stack, so this only
* really applies to Windows. It's configurable at link time. It is
* needed because polyfilling fork requires that we know, precicely
* where the stack memory begins and ends.
*/
#define GetStaticStackAddr(ADDEND) \
({ \
intptr_t vAddr; \
__asm__(".weak\tape_stack_vaddr\n\t" \
"movabs\t%1+ape_stack_vaddr,%0" \
: "=r"(vAddr) \
: "i"(ADDEND)); \
vAddr; \
})
#else
#define GetStaticStackAddr(ADDEND) (GetStackAddr() + ADDEND)
#endif
#define GetStackPointer() \
({ \
uintptr_t __sp; \
__asm__(__mov_sp : "=r"(__sp)); \
__sp; \
})
#ifdef __x86_64__
#define __mov_sp "mov\t%%rsp,%0"
#elif defined(__aarch64__)
#define __mov_sp "mov\t%0,sp"
#endif
COSMOPOLITAN_C_END_
#endif /* GNU ELF */
#endif /* COSMOPOLITAN_LIBC_RUNTIME_STACK_H_ */
/*!BEGIN libc/runtime/sysconf.h */
#define COSMOPOLITAN_LIBC_RUNTIME_SYSCONF_H_
#define _SC_ARG_MAX 0
#define _SC_CHILD_MAX 1
#define _SC_CLK_TCK 2
#define _SC_NGROUPS_MAX 3
#define _SC_OPEN_MAX 4
#define _SC_STREAM_MAX 5
#define _SC_TZNAME_MAX 6
#define _SC_JOB_CONTROL 7
#define _SC_SAVED_IDS 8
#define _SC_REALTIME_SIGNALS 9
#define _SC_PRIORITY_SCHEDULING 10
#define _SC_TIMERS 11
#define _SC_ASYNCHRONOUS_IO 12
#define _SC_PRIORITIZED_IO 13
#define _SC_SYNCHRONIZED_IO 14
#define _SC_FSYNC 15
#define _SC_MAPPED_FILES 16
#define _SC_MEMLOCK 17
#define _SC_MEMLOCK_RANGE 18
#define _SC_MEMORY_PROTECTION 19
#define _SC_MESSAGE_PASSING 20
#define _SC_SEMAPHORES 21
#define _SC_SHARED_MEMORY_OBJECTS 22
#define _SC_AIO_LISTIO_MAX 23
#define _SC_AIO_MAX 24
#define _SC_AIO_PRIO_DELTA_MAX 25
#define _SC_DELAYTIMER_MAX 26
#define _SC_MQ_OPEN_MAX 27
#define _SC_MQ_PRIO_MAX 28
#define _SC_VERSION 29
#define _SC_PAGE_SIZE 30
#define _SC_PAGESIZE 30 /* !! */
#define _SC_RTSIG_MAX 31
#define _SC_SEM_NSEMS_MAX 32
#define _SC_SEM_VALUE_MAX 33
#define _SC_SIGQUEUE_MAX 34
#define _SC_TIMER_MAX 35
#define _SC_BC_BASE_MAX 36
#define _SC_BC_DIM_MAX 37
#define _SC_BC_SCALE_MAX 38
#define _SC_BC_STRING_MAX 39
#define _SC_COLL_WEIGHTS_MAX 40
#define _SC_EXPR_NEST_MAX 42
#define _SC_LINE_MAX 43
#define _SC_RE_DUP_MAX 44
#define _SC_2_VERSION 46
#define _SC_2_C_BIND 47
#define _SC_2_C_DEV 48
#define _SC_2_FORT_DEV 49
#define _SC_2_FORT_RUN 50
#define _SC_2_SW_DEV 51
#define _SC_2_LOCALEDEF 52
#define _SC_UIO_MAXIOV 60 /* !! */
#define _SC_IOV_MAX 60
#define _SC_THREADS 67
#define _SC_THREAD_SAFE_FUNCTIONS 68
#define _SC_GETGR_R_SIZE_MAX 69
#define _SC_GETPW_R_SIZE_MAX 70
#define _SC_LOGIN_NAME_MAX 71
#define _SC_TTY_NAME_MAX 72
#define _SC_THREAD_DESTRUCTOR_ITERATIONS 73
#define _SC_THREAD_KEYS_MAX 74
#define _SC_THREAD_STACK_MIN 75
#define _SC_THREAD_THREADS_MAX 76
#define _SC_THREAD_ATTR_STACKADDR 77
#define _SC_THREAD_ATTR_STACKSIZE 78
#define _SC_THREAD_PRIORITY_SCHEDULING 79
#define _SC_THREAD_PRIO_INHERIT 80
#define _SC_THREAD_PRIO_PROTECT 81
#define _SC_THREAD_PROCESS_SHARED 82
#define _SC_NPROCESSORS_CONF 83
#define _SC_NPROCESSORS_ONLN 84
#define _SC_PHYS_PAGES 85
#define _SC_AVPHYS_PAGES 86
#define _SC_ATEXIT_MAX 87
#define _SC_PASS_MAX 88
#define _SC_XOPEN_VERSION 89
#define _SC_XOPEN_XCU_VERSION 90
#define _SC_XOPEN_UNIX 91
#define _SC_XOPEN_CRYPT 92
#define _SC_XOPEN_ENH_I18N 93
#define _SC_XOPEN_SHM 94
#define _SC_2_CHAR_TERM 95
#define _SC_2_UPE 97
#define _SC_XOPEN_XPG2 98
#define _SC_XOPEN_XPG3 99
#define _SC_XOPEN_XPG4 100
#define _SC_NZERO 109
#define _SC_XBS5_ILP32_OFF32 125
#define _SC_XBS5_ILP32_OFFBIG 126
#define _SC_XBS5_LP64_OFF64 127
#define _SC_XBS5_LPBIG_OFFBIG 128
#define _SC_XOPEN_LEGACY 129
#define _SC_XOPEN_REALTIME 130
#define _SC_XOPEN_REALTIME_THREADS 131
#define _SC_ADVISORY_INFO 132
#define _SC_BARRIERS 133
#define _SC_CLOCK_SELECTION 137
#define _SC_CPUTIME 138
#define _SC_THREAD_CPUTIME 139
#define _SC_MONOTONIC_CLOCK 149
#define _SC_READER_WRITER_LOCKS 153
#define _SC_SPIN_LOCKS 154
#define _SC_REGEXP 155
#define _SC_SHELL 157
#define _SC_SPAWN 159
#define _SC_SPORADIC_SERVER 160
#define _SC_THREAD_SPORADIC_SERVER 161
#define _SC_TIMEOUTS 164
#define _SC_TYPED_MEMORY_OBJECTS 165
#define _SC_2_PBS 168
#define _SC_2_PBS_ACCOUNTING 169
#define _SC_2_PBS_LOCATE 170
#define _SC_2_PBS_MESSAGE 171
#define _SC_2_PBS_TRACK 172
#define _SC_SYMLOOP_MAX 173
#define _SC_STREAMS 174
#define _SC_2_PBS_CHECKPOINT 175
#define _SC_V6_ILP32_OFF32 176
#define _SC_V6_ILP32_OFFBIG 177
#define _SC_V6_LP64_OFF64 178
#define _SC_V6_LPBIG_OFFBIG 179
#define _SC_HOST_NAME_MAX 180
#define _SC_TRACE 181
#define _SC_TRACE_EVENT_FILTER 182
#define _SC_TRACE_INHERIT 183
#define _SC_TRACE_LOG 184
#define _SC_IPV6 235
#define _SC_RAW_SOCKETS 236
#define _SC_V7_ILP32_OFF32 237
#define _SC_V7_ILP32_OFFBIG 238
#define _SC_V7_LP64_OFF64 239
#define _SC_V7_LPBIG_OFFBIG 240
#define _SC_SS_REPL_MAX 241
#define _SC_TRACE_EVENT_NAME_MAX 242
#define _SC_TRACE_NAME_MAX 243
#define _SC_TRACE_SYS_MAX 244
#define _SC_TRACE_USER_EVENT_MAX 245
#define _SC_XOPEN_STREAMS 246
#define _SC_THREAD_ROBUST_PRIO_INHERIT 247
#define _SC_THREAD_ROBUST_PRIO_PROTECT 248
#define _SC_SIGSTKSZ 249
#define _SC_MINSIGSTKSZ 250
COSMOPOLITAN_C_START_
long sysconf(int);
COSMOPOLITAN_C_END_
/*!BEGIN libc/runtime/utmp.h */
#define COSMOPOLITAN_LIBC_RUNTIME_UTMP_H_
/*!BEGIN libc/runtime/utmpx.h */
#define COSMOPOLITAN_LIBC_RUNTIME_UTMPX_H_
COSMOPOLITAN_C_START_
struct utmpx {
short ut_type;
pid_t ut_pid;
char ut_line[32];
char ut_id[4];
char ut_user[32];
char ut_host[256];
struct {
short __e_termination;
short __e_exit;
} ut_exit;
long ut_session;
struct timeval ut_tv;
unsigned ut_addr_v6[4];
char __unused[20];
};
void endutxent(void);
struct utmpx *getutxent(void);
struct utmpx *getutxid(const struct utmpx *);
struct utmpx *getutxline(const struct utmpx *);
struct utmpx *pututxline(const struct utmpx *);
void setutxent(void);
#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
#define e_exit __e_exit
#define e_termination __e_termination
void updwtmpx(const char *, const struct utmpx *);
int utmpxname(const char *);
#endif
#define EMPTY 0
#define RUN_LVL 1
#define BOOT_TIME 2
#define NEW_TIME 3
#define OLD_TIME 4
#define INIT_PROCESS 5
#define LOGIN_PROCESS 6
#define USER_PROCESS 7
#define DEAD_PROCESS 8
COSMOPOLITAN_C_END_
#define ACCOUNTING 9
#define UT_NAMESIZE 32
#define UT_HOSTSIZE 256
#define UT_LINESIZE 32
COSMOPOLITAN_C_START_
struct lastlog {
time_t ll_time;
char ll_line[UT_LINESIZE];
char ll_host[UT_HOSTSIZE];
};
#define ut_time ut_tv.tv_sec
#define ut_name ut_user
#define ut_addr ut_addr_v6[0]
#define utmp utmpx
#define e_exit __e_exit
#define e_termination __e_termination
int login_tty(int);
int utmpname(const char *);
struct utmp *getutent(void);
struct utmp *getutid(const struct utmp *);
struct utmp *getutline(const struct utmp *);
struct utmp *pututline(const struct utmp *);
void endutent(void);
void setutent(void);
void updwtmp(const char *, const struct utmp *);
#define _PATH_UTMP "/dev/null/utmp"
#define _PATH_WTMP "/dev/null/wtmp"
#define UTMP_FILE _PATH_UTMP
#define WTMP_FILE _PATH_WTMP
#define UTMP_FILENAME _PATH_UTMP
#define WTMP_FILENAME _PATH_WTMP
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/alg.h */
#define COSMOPOLITAN_LIBC_SOCK_ALG_H_
COSMOPOLITAN_C_START_
struct sockaddr_alg {
uint16_t salg_family;
uint8_t salg_type[14];
uint32_t salg_feat;
uint32_t salg_mask;
uint8_t salg_name[64];
};
struct sockaddr_alg_new {
uint16_t salg_family;
uint8_t salg_type[14];
uint32_t salg_feat;
uint32_t salg_mask;
uint8_t salg_name[]; /* Linux v4.12+ */
};
struct af_alg_iv {
uint32_t ivlen;
uint8_t iv[0];
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/epoll.h */
#define COSMOPOLITAN_LIBC_SOCK_WEPOLL_H_
COSMOPOLITAN_C_START_
typedef union epoll_data {
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} epoll_data_t;
struct thatispacked epoll_event {
uint32_t events;
epoll_data_t data;
};
int epoll_create(int) libcesque;
int epoll_create1(int) libcesque;
int epoll_ctl(int, int, int, struct epoll_event *) libcesque;
int epoll_wait(int, struct epoll_event *, int, int) libcesque;
int epoll_pwait(int, struct epoll_event *, int, int, const sigset_t *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/ifaddrs.h */
#define COSMOPOLITAN_LIBC_SOCK_IFADDRS_H_
COSMOPOLITAN_C_START_
struct ifaddrs {
struct ifaddrs *ifa_next;
char *ifa_name;
unsigned ifa_flags;
struct sockaddr *ifa_addr;
struct sockaddr *ifa_netmask;
union {
struct sockaddr *ifa_broadaddr;
struct sockaddr *ifa_dstaddr;
};
void *ifa_data;
};
void freeifaddrs(struct ifaddrs *) libcesque;
int getifaddrs(struct ifaddrs **) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/in.h */
#define COSMOPOLITAN_LIBC_SOCK_IN_H_
#define IN_CLASSA(a) ((((in_addr_t)(a)) & 0x80000000) == 0)
#define IN_CLASSA_NET 0xff000000
#define IN_CLASSA_NSHIFT 24
#define IN_CLASSA_HOST (0xffffffff & ~IN_CLASSA_NET)
#define IN_CLASSA_MAX 128
#define IN_CLASSB(a) ((((in_addr_t)(a)) & 0xc0000000) == 0x80000000)
#define IN_CLASSB_NET 0xffff0000
#define IN_CLASSB_NSHIFT 16
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
#define IN_CLASSB_MAX 65536
#define IN_CLASSC(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xc0000000)
#define IN_CLASSC_NET 0xffffff00
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
#define IN_CLASSD(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xe0000000)
#define IN_MULTICAST(a) IN_CLASSD(a)
#define IN_EXPERIMENTAL(a) ((((in_addr_t)(a)) & 0xe0000000) == 0xe0000000)
#define IN_BADCLASS(a) ((((in_addr_t)(a)) & 0xf0000000) == 0xf0000000)
#define IN6_IS_ADDR_UNSPECIFIED(a) \
(((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \
((uint32_t *)(a))[2] == 0 && ((uint32_t *)(a))[3] == 0)
#define IN6_IS_ADDR_LOOPBACK(a) \
(((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \
((uint32_t *)(a))[2] == 0 && ((uint8_t *)(a))[12] == 0 && \
((uint8_t *)(a))[13] == 0 && ((uint8_t *)(a))[14] == 0 && \
((uint8_t *)(a))[15] == 1)
#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *)(a))[0] == 0xff)
#define IN6_IS_ADDR_LINKLOCAL(a) \
((((uint8_t *)(a))[0]) == 0xfe && (((uint8_t *)(a))[1] & 0xc0) == 0x80)
#define IN6_IS_ADDR_SITELOCAL(a) \
((((uint8_t *)(a))[0]) == 0xfe && (((uint8_t *)(a))[1] & 0xc0) == 0xc0)
#define IN6_IS_ADDR_V4MAPPED(a) \
(((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \
((uint8_t *)(a))[8] == 0 && ((uint8_t *)(a))[9] == 0 && \
((uint8_t *)(a))[10] == 0xff && ((uint8_t *)(a))[11] == 0xff)
#define IN6_IS_ADDR_V4COMPAT(a) \
(((uint32_t *)(a))[0] == 0 && ((uint32_t *)(a))[1] == 0 && \
((uint32_t *)(a))[2] == 0 && ((uint8_t *)(a))[15] > 1)
#define IN6_IS_ADDR_MC_NODELOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *)(a))[1] & 0xf) == 0x1))
#define IN6_IS_ADDR_MC_LINKLOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *)(a))[1] & 0xf) == 0x2))
#define IN6_IS_ADDR_MC_SITELOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *)(a))[1] & 0xf) == 0x5))
#define IN6_IS_ADDR_MC_ORGLOCAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *)(a))[1] & 0xf) == 0x8))
#define IN6_IS_ADDR_MC_GLOBAL(a) \
(IN6_IS_ADDR_MULTICAST(a) && ((((uint8_t *)(a))[1] & 0xf) == 0xe))
#define __ARE_4_EQUAL(a, b) \
(!((0 [a] - 0 [b]) | (1 [a] - 1 [b]) | (2 [a] - 2 [b]) | (3 [a] - 3 [b])))
#define IN6_ARE_ADDR_EQUAL(a, b) \
__ARE_4_EQUAL((const uint32_t *)(a), (const uint32_t *)(b))
/*!BEGIN libc/sock/select.h */
#define COSMOPOLITAN_LIBC_SOCK_SELECT_H_
#define FD_SETSIZE 1024 /* it's 64 on windows */
COSMOPOLITAN_C_START_
typedef struct fd_set {
unsigned long fds_bits[FD_SETSIZE / (sizeof(long) * 8)];
} fd_set;
#define FD_ISSET(FD, SET) (((SET)->fds_bits[(FD) >> 6] >> ((FD)&63)) & 1)
#define FD_SET(FD, SET) ((SET)->fds_bits[(FD) >> 6] |= 1ull << ((FD)&63))
#define FD_CLR(FD, SET) ((SET)->fds_bits[(FD) >> 6] &= ~(1ull << ((FD)&63)))
#define FD_ZERO(SET) bzero((SET)->fds_bits, sizeof((SET)->fds_bits))
#define FD_SIZE(bits) (((bits) + (sizeof(long) * 8) - 1) / sizeof(long))
int select(int, fd_set *, fd_set *, fd_set *, struct timeval *) libcesque;
int pselect(int, fd_set *, fd_set *, fd_set *, const struct timespec *,
const sigset_t *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/syslog.h */
#define COSMOPOLITAN_LIBC_SOCK_SYSLOG_H_
COSMOPOLITAN_C_START_
int setlogmask(int) libcesque;
void openlog(const char *, int, int) libcesque;
void syslog(int, const char *, ...) libcesque;
void closelog(void) libcesque;
void vsyslog(int, const char *, va_list) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/arphdr.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_ARPHDR_H_
COSMOPOLITAN_C_START_
struct arphdr {
uint16_t ar_hrd;
uint16_t ar_pro;
uint8_t ar_hln;
uint8_t ar_pln;
uint16_t ar_op;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/arpreq.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_ARPREQ_H_
COSMOPOLITAN_C_START_
struct arpreq {
struct sockaddr arp_pa;
struct sockaddr arp_ha;
int arp_flags;
struct sockaddr arp_netmask;
char arp_dev[16];
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/cmsghdr.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_CMSGHDR_H_
COSMOPOLITAN_C_START_
#define CMSG_DATA(cmsg) ((unsigned char *)(((struct cmsghdr *)(cmsg)) + 1))
#define CMSG_FIRSTHDR(mhdr) \
((size_t)(mhdr)->msg_controllen >= sizeof(struct cmsghdr) \
? (struct cmsghdr *)(mhdr)->msg_control \
: (struct cmsghdr *)0)
#define CMSG_NXTHDR(mhdr, cmsg) \
((cmsg)->cmsg_len < sizeof(struct cmsghdr) || \
__CMSG_LEN(cmsg) + sizeof(struct cmsghdr) >= \
__MHDR_END(mhdr) - (unsigned char *)(cmsg) \
? 0 \
: (struct cmsghdr *)__CMSG_NEXT(cmsg))
#define CMSG_ALIGN(len) \
(((len) + sizeof(size_t) - 1) & (size_t) ~(sizeof(size_t) - 1))
#define CMSG_SPACE(len) (CMSG_ALIGN(len) + CMSG_ALIGN(sizeof(struct cmsghdr)))
#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len))
#define __CMSG_LEN(cmsg) \
(((cmsg)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
#define __CMSG_NEXT(cmsg) ((unsigned char *)(cmsg) + __CMSG_LEN(cmsg))
#define __MHDR_END(mhdr) \
((unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen)
struct cmsghdr { /* linux abi */
uint32_t cmsg_len;
uint32_t __pad1;
int32_t cmsg_level;
int32_t cmsg_type;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/ether_header.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_ETHER_HEADER_H_
#define ETH_ALEN 6
COSMOPOLITAN_C_START_
struct ether_addr {
uint8_t ether_addr_octet[ETH_ALEN];
};
struct ether_header {
uint8_t ether_dhost[ETH_ALEN];
uint8_t ether_shost[ETH_ALEN];
uint16_t ether_type;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/ifconf.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IFCONF_H_
/*!BEGIN libc/sock/struct/ifreq.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IFREQ_H_
COSMOPOLITAN_C_START_
#define IF_NAMESIZE 16
#define IFNAMSIZ IF_NAMESIZE
struct ifreq {
union {
char ifrn_name[IFNAMSIZ]; /* Interface name, e.g. "en0". */
} ifr_ifrn;
union {
struct sockaddr ifru_addr; /* SIOCGIFADDR */
struct sockaddr ifru_dstaddr; /* SIOCGIFDSTADDR */
struct sockaddr ifru_netmask; /* SIOCGIFNETMASK */
struct sockaddr ifru_broadaddr; /* SIOCGIFBRDADDR */
short ifru_flags; /* SIOCGIFFLAGS */
int ifru_ivalue; /* todo(jart) */
char ifru_pad[24]; /* ifru_map is the largest, just pad */
} ifr_ifru;
};
#define ifr_name ifr_ifrn.ifrn_name /* interface name */
#define ifr_addr ifr_ifru.ifru_addr /* address */
#define ifr_netmask ifr_ifru.ifru_netmask /* netmask */
#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* destination address */
#define ifr_flags ifr_ifru.ifru_flags /* flags */
#define ifr_ifindex ifr_ifru.ifru_ivalue
COSMOPOLITAN_C_END_
COSMOPOLITAN_C_START_
/*
* Structure used in SIOCGIFCONF request.
* Used to retrieve interface configuration
* for machine (useful for programs which
* must know all networks accessible).
*/
struct ifconf {
int32_t ifc_len; /* size of buffer */
int32_t padding;
union {
char *ifcu_buf;
struct ifreq *ifcu_req;
} ifc_ifcu;
};
/* Shortcuts to the ifconf buffer or ifreq array */
#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
#define ifc_req ifc_ifcu.ifcu_req /* array of structures */
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/in6_pktinfo.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IN6_PKTINFO_H_
/*!BEGIN libc/sock/struct/sockaddr6.h */
#define COSMOPOLITAN_LIBC_CALLS_STRUCT_SOCKADDR6_H_
struct in6_addr {
union {
uint8_t s6_addr[16];
uint16_t s6_addr16[8];
uint32_t s6_addr32[4];
};
};
struct sockaddr_in6 { /* Linux+NT ABI */
uint16_t sin6_family;
uint16_t sin6_port;
uint32_t sin6_flowinfo;
struct in6_addr sin6_addr;
uint32_t sin6_scope_id; /* rfc2553 */
};
extern const struct in6_addr in6addr_any;
extern const struct in6_addr in6addr_loopback;
COSMOPOLITAN_C_START_
struct in6_pktinfo {
struct in6_addr ipi6_addr;
unsigned ipi6_ifindex;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/in_pktinfo.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IN_PKTINFO_H_
COSMOPOLITAN_C_START_
struct in_pktinfo {
int ipi_ifindex;
struct in_addr ipi_spec_dst;
struct in_addr ipi_addr;
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/ip_mreq.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IP_MREQ_H_
COSMOPOLITAN_C_START_
struct ip_mreq {
struct in_addr imr_multiaddr; /* IP multicast address of group */
struct in_addr imr_interface; /* local IP address of interface */
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/ipv6_mreq.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_IPV6_MREQ_H_
COSMOPOLITAN_C_START_
struct ipv6_mreq {
struct in6_addr ipv6mr_multiaddr; /* IPv6 multicast address of group */
unsigned ipv6mr_interface; /* local interface */
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/linger.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_LINGER_H_
COSMOPOLITAN_C_START_
struct linger { /* Linux+XNU+BSD ABI */
int32_t l_onoff; /* on/off */
int32_t l_linger; /* seconds */
};
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/msghdr.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_MSGHDR_H_
COSMOPOLITAN_C_START_
struct msghdr { /* Linux+NT ABI */
void *msg_name; /* optional address */
uint32_t msg_namelen; /* size of msg_name */
struct iovec *msg_iov; /* scatter/gather array */
uint64_t msg_iovlen; /* # elements in msg_iov */
void *msg_control; /* ancillary data c. cmsghdr */
uint64_t msg_controllen; /* ancillary data buffer len */
uint32_t msg_flags; /* MSG_XXX */
};
ssize_t recvmsg(int, struct msghdr *, int);
ssize_t sendmsg(int, const struct msghdr *, int);
COSMOPOLITAN_C_END_
/*!BEGIN libc/sock/struct/pollfd.h */
#define COSMOPOLITAN_LIBC_SOCK_STRUCT_POLLFD_H_
COSMOPOLITAN_C_START_
struct pollfd {
int32_t fd;
int16_t events;
int16_t revents;
};
int poll(struct pollfd *, uint64_t, int32_t);
int ppoll(struct pollfd *, uint64_t, const struct timespec *, const sigset_t *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/stdio/append.h */
#ifndef COSMOPOLITAN_LIBC_STDIO_APPEND_H_
#define COSMOPOLITAN_LIBC_STDIO_APPEND_H_
#define APPEND_COOKIE 21578
#define appendz __appendz
#define appendr __appendr
#define appendd __appendd
#define appendw __appendw
#define appends __appends
#define appendf __appendf
#define vappendf __vappendf
#define kappendf __kappendf
#define kvappendf __kvappendf
COSMOPOLITAN_C_START_
struct appendz {
size_t i;
size_t n;
};
struct appendz appendz(char *) libcesque;
ssize_t appendr(char **, size_t) libcesque;
ssize_t appendd(char **, const void *, size_t) libcesque;
ssize_t appendw(char **, uint64_t) libcesque;
ssize_t appends(char **, const char *) libcesque;
ssize_t appendf(char **, const char *, ...) libcesque;
ssize_t vappendf(char **, const char *, va_list) libcesque;
ssize_t kappendf(char **, const char *, ...) libcesque;
ssize_t kvappendf(char **, const char *, va_list) libcesque;
COSMOPOLITAN_C_END_
#endif /* COSMOPOLITAN_LIBC_STDIO_APPEND_H_ */
/*!BEGIN libc/stdio/dprintf.h */
#define COSMOPOLITAN_LIBC_CALLS_DPRINTF_H_
COSMOPOLITAN_C_START_
libcesque int dprintf(int, const char *, ...) paramsnonnull((2));
libcesque int vdprintf(int, const char *, va_list) paramsnonnull();
COSMOPOLITAN_C_END_
/*!BEGIN libc/stdio/ftw.h */
#define COSMOPOLITAN_THIRD_PARTY_MUSL_FTW_H_
COSMOPOLITAN_C_START_
/**
* Type for file.
*/
#define FTW_F 1
/**
* Type for directory.
*/
#define FTW_D 2
/**
* Type for directory that cannot be read.
*/
#define FTW_DNR 3
/**
* Type for stat() failed and not a symbolic link.
*/
#define FTW_NS 4
/**
* Type for symbolic link when `FTW_PHYS` is in flags.
*/
#define FTW_SL 5
/**
* Directory and `FTW_DEPTH` in flags.
*/
#define FTW_DP 6
/**
* Type for broken symbolic link when `FTW_PHYS` is not in flags.
*/
#define FTW_SLN 7
/**
* Flag to prevent following symbolic links (recommended).
* @see nftw() flags
*/
#define FTW_PHYS 1
/**
* Flag to prevent crossing mount points.
* @see nftw() flags
*/
#define FTW_MOUNT 2
/**
* Unsupported.
* @see nftw() flags
*/
#define FTW_CHDIR 4
/**
* Flag for post-order traversal.
*
* 1. Will use `FTW_DP` instead of `FTW_D` as type.
* 2. Directory callback happens *after* rather than before.
*
* @see nftw() flags
*/
#define FTW_DEPTH 8
struct FTW {
/**
* Byte offset of basename component in `fpath` passed to callback.
*/
int base;
/**
* Depth relative to `dirpath` whose level is zero.
*/
int level;
};
int ftw(const char *, int (*)(const char *, const struct stat *, int),
int) dontthrow;
int nftw(const char *,
int (*)(const char *, const struct stat *, int, struct FTW *), int,
int) dontthrow;
COSMOPOLITAN_C_END_
/*!BEGIN libc/stdio/iconv.h */
#define COSMOPOLITAN_LIBC_STDIO_ICONV_H_
COSMOPOLITAN_C_START_
typedef void *iconv_t;
iconv_t iconv_open(const char *, const char *);
size_t iconv(iconv_t, char **, size_t *, char **, size_t *);
int iconv_close(iconv_t);
COSMOPOLITAN_C_END_
/*!BEGIN libc/stdio/rand.h */
#define COSMOPOLITAN_LIBC_RAND_RAND_H_
#define RAND_MAX __INT_MAX__
COSMOPOLITAN_C_START_
/*───────────────────────────────────────────────────────────────────────────│─╗
│ cosmopolitan § random ─╬─│┼
╚────────────────────────────────────────────────────────────────────────────│*/
int rand(void) libcesque;
void srand(unsigned) libcesque;
char *strfry(char *) libcesque;
int getentropy(void *, size_t) libcesque;
ssize_t getrandom(void *, size_t, unsigned) libcesque;
char *initstate(unsigned, char *, size_t) libcesque;
char *setstate(char *) libcesque;
long random(void) libcesque;
void srandom(unsigned) libcesque;
#ifdef _COSMO_SOURCE
#define vigna __vigna
#define vigna_r __vigna_r
#define rngset __rngset
#define rdrand __rdrand
#define rdseed __rdseed
double poz(double) libcesque;
double pochisq(double, int) libcesque;
uint64_t lemur64(void) libcesque;
uint64_t _rand64(void) libcesque;
uint64_t vigna(void) libcesque;
uint64_t vigna_r(uint64_t[hasatleast 1]) libcesque;
void svigna(uint64_t) libcesque;
uint64_t rdrand(void) libcesque;
uint64_t rdseed(void) libcesque;
void _smt19937(uint64_t) libcesque;
void _Smt19937(uint64_t[], size_t) libcesque;
uint64_t _mt19937(void) libcesque;
double _real1(uint64_t) libcesque;
double _real2(uint64_t) libcesque;
double _real3(uint64_t) libcesque;
double MeasureEntropy(const char *, size_t) libcesque;
void *rngset(void *, size_t, uint64_t (*)(void), size_t) libcesque;
void rt_init(int) libcesque;
void rt_add(void *, int) libcesque;
void rt_end(double *, double *, double *, double *, double *) libcesque;
#endif /* _COSMO_SOURCE */
COSMOPOLITAN_C_END_
/*!BEGIN libc/stdio/readpassphrase.h */
#define COSMOPOLITAN_LIBC_STDIO_READPASSPHRASE_H_
#define RPP_ECHO_OFF 0x00
#define RPP_ECHO_ON 0x01
#define RPP_REQUIRE_TTY 0x02
#define RPP_FORCELOWER 0x04
#define RPP_FORCEUPPER 0x08
#define RPP_SEVENBIT 0x10
#define RPP_STDIN 0x20
COSMOPOLITAN_C_START_
char *readpassphrase(const char *, char *, size_t, int) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/stdio/stdio_ext.h */
#define COSMOPOLITAN_LIBC_STDIO_STDIO_EXT_H_
#define FSETLOCKING_QUERY 0
#define FSETLOCKING_INTERNAL 1
#define FSETLOCKING_BYCALLER 2
COSMOPOLITAN_C_START_
size_t __fbufsize(FILE *) libcesque;
size_t __fpending(FILE *) libcesque;
int __flbf(FILE *) libcesque;
int __freadable(FILE *) libcesque;
int __fwritable(FILE *) libcesque;
int __freading(FILE *) libcesque;
int __fwriting(FILE *) libcesque;
int __fsetlocking(FILE *, int) libcesque;
void _flushlbf(void) libcesque;
void __fpurge(FILE *) libcesque;
void __fseterr(FILE *) libcesque;
const char *__freadptr(FILE *, size_t *) libcesque;
size_t __freadahead(FILE *) libcesque;
void __freadptrinc(FILE *, size_t) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/stdio/syscall.h */
#define COSMOPOLITAN_LIBC_STDIO_SYSCALL_H_
COSMOPOLITAN_C_START_
#define SYS_gettid 1
#define SYS_getrandom 2
#define SYS_getcpu 3
long syscall(long, ...) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN libc/stdio/sysparam.h */
#define COSMOPOLITAN_LIBC_SYSPARAM_H_
#define MAXSYMLINKS 20
#define MAXHOSTNAMELEN 64
#define MAXNAMLEN 255
#define MAXPATHLEN PATH_MAX
#define NBBY 8
#define NGROUPS 32
#define CANBSIZ 255
#define NOFILE 256
#define NCARGS 131072
#define DEV_BSIZE 512
#define NOGROUP (-1)
COSMOPOLITAN_C_START_
#define __bitop(x, i, o) ((x)[(i) / 8] o(1 << (i) % 8))
#define setbit(x, i) __bitop(x, i, |=)
#define clrbit(x, i) __bitop(x, i, &= ~)
#define isset(x, i) __bitop(x, i, &)
#define isclr(x, i) !isset(x, i)
#undef roundup
#define roundup(n, d) (howmany(n, d) * (d))
#define powerof2(n) !(((n)-1) & (n))
#define howmany(n, d) (((n) + ((d)-1)) / (d))
#ifdef MIN
#undef MIN
#endif
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#ifdef MAX
#undef MAX
#endif
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
COSMOPOLITAN_C_END_
/*!BEGIN libc/proc/ntspawn.h */
#define COSMOPOLITAN_NTSPAWN_H_
COSMOPOLITAN_C_START_
struct NtSpawnArgs {
int64_t dirhand;
const char *prog;
char *const *argv;
char *const *envp;
char *const *extravars;
uint32_t dwCreationFlags;
const char16_t *opt_lpCurrentDirectory;
int64_t opt_hParentProcess;
int64_t *opt_lpExplicitHandleList;
uint32_t dwExplicitHandleCount;
const struct NtStartupInfo *lpStartupInfo;
struct NtProcessInformation *opt_out_lpProcessInformation;
};
int mkntenvblock(char16_t[32767], char *const[], char *const[], char[32767]);
int ntspawn(struct NtSpawnArgs *);
size_t mkntcmdline(char16_t *, char *const[], size_t);
void mungentpath(char *);
COSMOPOLITAN_C_END_
/*!BEGIN libc/proc/posix_spawn.h */
#define COSMOPOLITAN_LIBC_STDIO_SPAWN_H_
#define POSIX_SPAWN_USEVFORK 0
#define POSIX_SPAWN_RESETIDS 1
#define POSIX_SPAWN_SETPGROUP 2
#define POSIX_SPAWN_SETSIGDEF 4
#define POSIX_SPAWN_SETSIGMASK 8
#define POSIX_SPAWN_SETSCHEDPARAM 16
#define POSIX_SPAWN_SETSCHEDULER 32
#define POSIX_SPAWN_SETSID 128
#define POSIX_SPAWN_SETRLIMIT 256
COSMOPOLITAN_C_START_
typedef struct _posix_spawna *posix_spawnattr_t;
typedef struct _posix_faction *posix_spawn_file_actions_t;
int posix_spawn(int *, const char *, const posix_spawn_file_actions_t *,
const posix_spawnattr_t *, char *const[], char *const[]);
int posix_spawnp(int *, const char *, const posix_spawn_file_actions_t *,
const posix_spawnattr_t *, char *const[], char *const[]);
int posix_spawn_file_actions_init(posix_spawn_file_actions_t *) libcesque;
int posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *) libcesque;
int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *,
int) libcesque;
int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int,
int) libcesque;
int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *, int,
const char *, int, unsigned) libcesque;
int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *,
const char *) libcesque;
int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *,
int) libcesque;
int posix_spawnattr_init(posix_spawnattr_t *) libcesque;
int posix_spawnattr_destroy(posix_spawnattr_t *) libcesque;
int posix_spawnattr_getflags(const posix_spawnattr_t *, short *) libcesque;
int posix_spawnattr_setflags(posix_spawnattr_t *, short) libcesque;
int posix_spawnattr_getpgroup(const posix_spawnattr_t *, int *) libcesque;
int posix_spawnattr_setpgroup(posix_spawnattr_t *, int) libcesque;
int posix_spawnattr_getschedpolicy(const posix_spawnattr_t *, int *) libcesque;
int posix_spawnattr_setschedpolicy(posix_spawnattr_t *, int) libcesque;
int posix_spawnattr_getschedparam(const posix_spawnattr_t *,
struct sched_param *) libcesque;
int posix_spawnattr_setschedparam(posix_spawnattr_t *,
const struct sched_param *) libcesque;
int posix_spawnattr_getsigmask(const posix_spawnattr_t *, sigset_t *) libcesque;
int posix_spawnattr_setsigmask(posix_spawnattr_t *, const sigset_t *) libcesque;
int posix_spawnattr_getsigdefault(const posix_spawnattr_t *,
sigset_t *) libcesque;
int posix_spawnattr_setsigdefault(posix_spawnattr_t *,
const sigset_t *) libcesque;
int posix_spawnattr_getrlimit(const posix_spawnattr_t *, int,
struct rlimit *) libcesque;
int posix_spawnattr_setrlimit(posix_spawnattr_t *, int,
const struct rlimit *) libcesque;
COSMOPOLITAN_C_END_
/*!BEGIN third_party/nsync/atomic.h */
#define NSYNC_ATOMIC_H_
COSMOPOLITAN_C_START_
#define nsync_atomic_uint32_ atomic_uint
#define NSYNC_ATOMIC_UINT32_INIT_ 0
#define NSYNC_ATOMIC_UINT32_LOAD_(p) (*(p))
#define NSYNC_ATOMIC_UINT32_STORE_(p, v) (*(p) = (v))
#define NSYNC_ATOMIC_UINT32_PTR_(p) (p)
COSMOPOLITAN_C_END_
/*!BEGIN third_party/nsync/counter.h */
#define NSYNC_COUNTER_H_
/*!BEGIN third_party/nsync/time.h */
#define NSYNC_TIME_H_
COSMOPOLITAN_C_START_
#define NSYNC_TIME_SEC(t) ((t).tv_sec)
#define NSYNC_TIME_NSEC(t) ((t).tv_nsec)
#define NSYNC_TIME_STATIC_INIT(t, ns) \
{ (t), (ns) }
/* The type nsync_time represents the interval elapsed between two
moments in time. Often the first such moment is an address-space-wide
epoch, such as the Unix epoch, but clients should not rely on the
epoch in one address space being the same as that in another.
Intervals relative to the epoch are known as absolute times. */
typedef struct timespec nsync_time;
/* A deadline infinitely far in the future. */
#define nsync_time_no_deadline timespec_max
/* The zero delay, or an expired deadline. */
#define nsync_time_zero timespec_zero
/* Return the current time since the epoch. */
#define nsync_time_now() timespec_real()
/* Sleep for the specified delay. Returns the unslept time which may be
non-zero if the call was interrupted. */
#define nsync_time_sleep(a) timespec_sleep(a)
/* Sleep until the specified time. Returns 0 on success, and EINTR
if the call was interrupted. */
#define nsync_time_sleep_until(a) timespec_sleep_until(a)
/* Return a+b */
#define nsync_time_add(a, b) timespec_add(a, b)
/* Return a-b */
#define nsync_time_sub(a, b) timespec_sub(a, b)
/* Return +ve, 0, or -ve according to whether a>b, a==b, or a 0) after a
waiter has waited. */
uint32_t nsync_counter_add(nsync_counter c, int32_t delta);
/* Return the current value of c. */
uint32_t nsync_counter_value(nsync_counter c);
/* Wait until c has value 0, or until abs_deadline, then return
the value of c. It is a checkable runtime error to increment c after
a waiter may have been woken due to the counter reaching zero.
If abs_deadline==nsync_time_no_deadline, the deadline
is far in the future. */
uint32_t nsync_counter_wait(nsync_counter c, nsync_time abs_deadline);
COSMOPOLITAN_C_END_
/*!BEGIN third_party/nsync/cv.h */
#define NSYNC_CV_H_
/*!BEGIN third_party/nsync/mu.h */
#define NSYNC_MU_H_
COSMOPOLITAN_C_START_
/* An nsync_mu is a lock. If initialized to zero, it's valid and unlocked.
An nsync_mu can be "free", held by a single thread (aka fiber,
goroutine) in "write" (exclusive) mode, or by many threads in "read"
(shared) mode. A thread that acquires it should eventually release
it. It is illegal to acquire an nsync_mu in one thread and release it
in another. It is illegal for a thread to reacquire an nsync_mu while
holding it (even a second share of a "read" lock).
Example usage:
static struct foo {
nsync_mu mu; // protects invariant a+b==0 on fields below.
int a;
int b;
} p = { NSYNC_MU_INIT, 0, 0 };
// ....
nsync_mu_lock (&p.mu);
// The current thread now has exclusive access to p.a and p.b;
// invariant assumed true.
p.a++;
p.b--; // restore invariant p.a+p.b==0 before releasing p.mu
nsync_mu_unlock (&p.mu)
Mutexes can be used with condition variables; see nsync_cv.h.
nsync_mu_wait() and nsync_mu_wait_with_deadline() can be used instead
of condition variables. See nsync_mu_wait.h for more details. Example
use of nsync_mu_wait() to wait for p.a==0, using definition above:
int a_is_zero (const void *condition_arg) {
return (((const struct foo *)condition_arg)->a == 0);
}
...
nsync_mu_lock (&p.mu);
nsync_mu_wait (&p.mu, &a_is_zero, &p, NULL);
// The current thread now has exclusive access to
// p.a and p.b, and p.a==0.
...
nsync_mu_unlock (&p.mu);
*/
typedef struct nsync_mu_s_ {
nsync_atomic_uint32_ word; /* internal use only */
int _zero; /* c pthread_mutex_t */
struct Dll *waiters; /* internal use only */
} nsync_mu;
/* An nsync_mu should be zeroed to initialize, which can be accomplished
by initializing with static initializer NSYNC_MU_INIT, or by setting
the entire structure to all zeroes, or using nsync_mu_init(). */
#define NSYNC_MU_INIT \
{ NSYNC_ATOMIC_UINT32_INIT_, 0 }
void nsync_mu_init(nsync_mu *mu);
/* Block until *mu is free and then acquire it in writer mode. Requires
that the calling thread not already hold *mu in any mode. */
void nsync_mu_lock(nsync_mu *mu);
/* Unlock *mu, which must have been acquired in write mode by the
calling thread, and wake waiters, if appropriate. */
void nsync_mu_unlock(nsync_mu *mu);
/* Attempt to acquire *mu in writer mode without blocking, and return
non-zero iff successful. Return non-zero with high probability if *mu
was free on entry. */
int nsync_mu_trylock(nsync_mu *mu);
/* Block until *mu can be acquired in reader mode and then acquire it.
Requires that the calling thread not already hold *mu in any mode. */
void nsync_mu_rlock(nsync_mu *mu);
/* Unlock *mu, which must have been acquired in read mode by the calling
thread, and wake waiters, if appropriate. */
void nsync_mu_runlock(nsync_mu *mu);
/* Attempt to acquire *mu in reader mode without blocking, and return
non-zero iff successful. Return non-zero with high probability if *mu
was free on entry. Perhaps fail to acquire if a writer is waiting, to
avoid starvation. */
int nsync_mu_rtrylock(nsync_mu *mu);
/* May abort if *mu is not held in write mode by the calling thread. */
void nsync_mu_assert_held(const nsync_mu *mu);
/* May abort if *mu is not held in read or write mode
by the calling thread. */
void nsync_mu_rassert_held(const nsync_mu *mu);
/* Return whether *mu is held in read mode.
Requires that the calling thread holds *mu in some mode. */
int nsync_mu_is_reader(const nsync_mu *mu);
COSMOPOLITAN_C_END_
COSMOPOLITAN_C_START_
#define NSYNC_CV_INIT \
{ NSYNC_ATOMIC_UINT32_INIT_, 0 }
struct nsync_note_s_;
/* An nsync_cv is a condition variable in the style of Mesa, Java,
POSIX, and Go's sync.Cond. It allows a thread to wait for a condition
on state protected by a mutex, and to proceed with the mutex held and
the condition true.
See also nsync_mu_wait() and nsync_mu_wait_with_deadline(), which
implement conditional critical sections. In many cases, they are
easier to use than condition variables.
Usage
After making the desired predicate true, call:
nsync_cv_signal (&cv); // If at most one thread can make use
// of the predicate becoming true.
or
nsync_cv_broadcast (&cv); // If multiple threads can make use
// of the predicate becoming true.
To wait for a predicate with no deadline (assuming
nsync_cv_broadcast() or nsync_cv_signal() is called whenever the
predicate becomes true):
nsync_mu_lock (μ)
while (!some_predicate_protected_by_mu) { // while-loop required
nsync_cv_wait (&cv, &mu);
}
// predicate is now true
nsync_mu_unlock (&mu);
To wait for a predicate with a deadline (assuming nsync_cv_broadcast() or
nsync_cv_signal() is called whenever the predicate becomes true):
nsync_mu_lock (&mu);
while (!some_predicate_protected_by_mu &&
nsync_cv_wait_with_deadline (&cv, &mu, abs_deadline,
cancel_note) == 0) {
}
if (some_predicate_protected_by_mu) { // predicate is true
} else {
// predicate is false, and deadline expired, or
// cancel_note was notified.
}
nsync_mu_unlock (&mu);
or, if the predicate is complex and you wish to write it just once
and inline, you could use the following instead of the for-loop
above:
nsync_mu_lock (&mu);
int pred_is_true = 0;
int outcome = 0;
while (!(pred_is_true = some_predicate_protected_by_mu) &&
outcome == 0) {
outcome = nsync_cv_wait_with_deadline (&cv, &mu, abs_deadline,
cancel_note);
}
if (pred_is_true) { // predicate is true
} else {
// predicate is false, and deadline expired, or
// cancel_note was notified.
}
nsync_mu_unlock (&mu);
As the examples show, Mesa-style condition variables require that
waits use a loop that tests the predicate anew after each wait. It
may be surprising that these are preferred over the precise wakeups
offered by the condition variables in Hoare monitors. Imprecise
wakeups make more efficient use of the critical section, because
threads can enter it while a woken thread is still emerging from the
scheduler, which may take thousands of cycles. Further, they make the
programme easier to read and debug by making the predicate explicit
locally at the wait, where the predicate is about to be assumed; the
reader does not have to infer the predicate by examining all the
places where wakeups may occur. */
typedef struct nsync_cv_s_ {
/* see bits below */
nsync_atomic_uint32_ word;
/* points to tail of list of waiters; under mu. */
struct Dll *waiters;
} nsync_cv;
/* An nsync_cv should be zeroed to initialize, which can be accomplished
by initializing with static initializer NSYNC_CV_INIT, or by setting
the entire struct to 0, or using nsync_cv_init(). */
void nsync_cv_init(nsync_cv *cv);
/* Wake at least one thread if any are currently blocked on *cv. If the
chosen thread is a reader on an nsync_mu, wake all readers and, if
possible, a writer. */
void nsync_cv_signal(nsync_cv *cv);
/* Wake all threads currently blocked on *cv. */
void nsync_cv_broadcast(nsync_cv *cv);
/* Atomically release "mu" (which must be held on entry) and block the
caller on *cv. Wait until awakened by a call to nsync_cv_signal() or
nsync_cv_broadcast(), or a spurious wakeup; then reacquire "mu", and
return. Equivalent to a call to nsync_mu_wait_with_deadline() with
abs_deadline==nsync_time_no_deadline, and cancel_note==NULL. Callers
should use nsync_cv_wait() in a loop, as with all standard Mesa-style
condition variables. See examples above. Returns 0 normally, otherwise
ECANCELED may be returned if calling POSIX thread is cancelled only when
the PTHREAD_CANCEL_MASKED mode is in play. */
int nsync_cv_w