mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-28 07:18:30 +00:00
Initial import
This commit is contained in:
commit
c91b3c5006
14915 changed files with 590219 additions and 0 deletions
1015
libc/integral/c.inc
Normal file
1015
libc/integral/c.inc
Normal file
File diff suppressed because it is too large
Load diff
34
libc/integral/cxx.inc
Normal file
34
libc/integral/cxx.inc
Normal file
|
@ -0,0 +1,34 @@
|
|||
#define COSMOPOLITAN_CPP_START_ namespace cosmo {
|
||||
#define COSMOPOLITAN_CPP_END_ }
|
||||
#define COSMOPOLITAN_CPP_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 */
|
||||
#include "libc/integral/cxxtypescompat.inc"
|
||||
#define __builtin_types_compatible_p(A, B) \
|
||||
(__cxx_types_compatible<A, B>::_value)
|
||||
#else
|
||||
#define __builtin_types_compatible_p(A, B) 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(__builtin_choose_expr) && !__has_builtin(choose_expr)
|
||||
#if 1
|
||||
template <bool _P, typename _T, typename _U>
|
||||
struct __cxx_choose_expr {
|
||||
__cxx_choose_expr(_T _a, _U _b) : _value(_a) {}
|
||||
const _T _value;
|
||||
};
|
||||
template <typename _T, typename _U>
|
||||
struct __cxx_choose_expr<false, _T, _U> {
|
||||
__cxx_choose_expr(_T _a, _U _b) : _value(_b) {}
|
||||
const _U _value;
|
||||
};
|
||||
#define __builtin_choose_expr(X, A, B) \
|
||||
(__cxx_choose_expr<X, typeof(A), typeof(B)>(A, B)._value)
|
||||
#else
|
||||
#define __builtin_choose_expr(X, A, B) ((X) ? (A) : (B))
|
||||
#endif
|
||||
#endif
|
39
libc/integral/cxxtypescompat.inc
Normal file
39
libc/integral/cxxtypescompat.inc
Normal file
|
@ -0,0 +1,39 @@
|
|||
#define NAME __cxx_types_compatible
|
||||
#define QUALIFIED(Q1, Q2) \
|
||||
template <class _T, class _U> \
|
||||
struct NAME<_T Q1, _U Q2> : NAME<_T, _U> {}
|
||||
|
||||
template <class, class>
|
||||
struct NAME {
|
||||
enum { _value = 0 };
|
||||
};
|
||||
|
||||
template <class _T>
|
||||
struct NAME<_T, _T> {
|
||||
enum { _value = 1 };
|
||||
};
|
||||
|
||||
template <class _T, size_t N>
|
||||
struct NAME<_T[], _T[N]> {
|
||||
enum { _value = 1 };
|
||||
};
|
||||
|
||||
template <class _T, size_t N>
|
||||
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
|
67
libc/integral/lp64.inc
Normal file
67
libc/integral/lp64.inc
Normal file
|
@ -0,0 +1,67 @@
|
|||
#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 __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 __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 int
|
||||
#define __UINT64_TYPE__ long unsigned int
|
||||
#define __INTPTR_TYPE__ long int
|
||||
#define __UINTPTR_TYPE__ long unsigned int
|
||||
#define __PTRDIFF_TYPE__ long int
|
||||
#define __SIZE_TYPE__ long 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 /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
99
libc/integral/normalize.inc
Normal file
99
libc/integral/normalize.inc
Normal file
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
* @fileoverview Cosmopolitan Preprocessor / Language Normalization.
|
||||
*
|
||||
* This is our lowest-level header file. You don't need to include it,
|
||||
* since we require that compilers be configured to do so automatically,
|
||||
* and the -include flag is the safest bet. Further note polyfills here
|
||||
* shouldn't be taken as indicators of intent to support.
|
||||
*/
|
||||
|
||||
#define __COSMOPOLITAN__ 1
|
||||
|
||||
#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
|
||||
|
||||
#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
|
||||
|
||||
#ifdef unix
|
||||
#undef unix
|
||||
#endif
|
||||
|
||||
#ifdef linux
|
||||
#undef linux
|
||||
#endif
|
||||
|
||||
#ifndef __BIGGEST_ALIGNMENT__
|
||||
#define __BIGGEST_ALIGNMENT__ 16 /* intrinsics practices need to change */
|
||||
#endif
|
||||
|
||||
#define BIGPAGESIZE 0x200000
|
||||
#define FRAMESIZE 0x10000 /* 8086 */
|
||||
#define STACKSIZE 0x10000 /* goog */
|
||||
#define PAGESIZE 0x1000 /* i386+ */
|
||||
#define BUFSIZ 0x1000 /* best stdio default */
|
||||
#define CACHELINE 0x40 /* nexgen32e */
|
||||
#define CHAR_BIT 8 /* b/c von neumann */
|
||||
#define ENV_MAX 0x7fff /* b/c windows */
|
||||
#define ARG_MAX 0x3fff /* b/c windows */
|
||||
#define CMD_MAX 0x4000 /* b/c windows */
|
||||
#define PATH_MAX 248 /* b/c windows */
|
||||
#define NAME_MAX 63 /* b/c dns */
|
||||
#define CHILD_MAX 25 /* only if malloc isn't linked */
|
||||
#define OPEN_MAX 16 /* only if malloc isn't linked */
|
||||
#define ATEXIT_MAX 32 /* only if malloc isn't linked */
|
||||
#define NSIG 128 /* it's complicated */
|
||||
|
||||
#if defined(__LP64__) && !defined(__INT64_TYPE__)
|
||||
#include "libc/integral/lp64.inc"
|
||||
#endif
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
#ifdef __STDC__
|
||||
#include "libc/integral/c.inc"
|
||||
#else
|
||||
#define const
|
||||
#define volatile
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
#include "libc/integral/cxx.inc"
|
||||
#endif
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue