Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions system/lib/libc/musl/arch/emscripten/bits/alltypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,58 +147,62 @@ typedef _Int64 suseconds_t;
#endif


// XXX EMSCRIPTEN: This file has been modified from the upstream musl version
// to make use of clang pre-defined macros whereever possible, eliminating
// possible inconsistencies.

#if defined(__NEED_int8_t) && !defined(__DEFINED_int8_t)
typedef signed char int8_t;
typedef __INT8_TYPE__ int8_t;
#define __DEFINED_int8_t
#endif

#if defined(__NEED_int16_t) && !defined(__DEFINED_int16_t)
typedef signed short int16_t;
typedef __INT16_TYPE__ int16_t;
#define __DEFINED_int16_t
#endif

#if defined(__NEED_int32_t) && !defined(__DEFINED_int32_t)
typedef signed int int32_t;
typedef __INT32_TYPE__ int32_t;
#define __DEFINED_int32_t
#endif

#if defined(__NEED_int64_t) && !defined(__DEFINED_int64_t)
typedef signed _Int64 int64_t;
typedef __INT64_TYPE__ int64_t;
#define __DEFINED_int64_t
#endif

#if defined(__NEED_intmax_t) && !defined(__DEFINED_intmax_t)
typedef signed _Int64 intmax_t;
typedef __INTMAX_TYPE__ intmax_t;
#define __DEFINED_intmax_t
#endif

#if defined(__NEED_uint8_t) && !defined(__DEFINED_uint8_t)
typedef unsigned char uint8_t;
typedef __UINT8_TYPE__ uint8_t;
#define __DEFINED_uint8_t
#endif

#if defined(__NEED_uint16_t) && !defined(__DEFINED_uint16_t)
typedef unsigned short uint16_t;
typedef __UINT16_TYPE__ uint16_t;
#define __DEFINED_uint16_t
#endif

#if defined(__NEED_uint32_t) && !defined(__DEFINED_uint32_t)
typedef unsigned int uint32_t;
typedef __UINT32_TYPE__ uint32_t;
#define __DEFINED_uint32_t
#endif

#if defined(__NEED_uint64_t) && !defined(__DEFINED_uint64_t)
typedef unsigned _Int64 uint64_t;
typedef __UINT64_TYPE__ uint64_t;
#define __DEFINED_uint64_t
#endif

#if defined(__NEED_u_int64_t) && !defined(__DEFINED_u_int64_t)
typedef unsigned _Int64 u_int64_t;
typedef __UINT64_TYPE__ u_int64_t;
#define __DEFINED_u_int64_t
#endif

#if defined(__NEED_uintmax_t) && !defined(__DEFINED_uintmax_t)
typedef unsigned _Int64 uintmax_t;
typedef __UINTMAX_TYPE__ uintmax_t;
#define __DEFINED_uintmax_t
#endif

Expand Down
20 changes: 0 additions & 20 deletions system/lib/libc/musl/arch/emscripten/bits/stdint.h

This file was deleted.

26 changes: 15 additions & 11 deletions system/lib/libc/musl/include/alltypes.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ TYPEDEF _Reg register_t;
TYPEDEF _Int64 time_t;
TYPEDEF _Int64 suseconds_t;

TYPEDEF signed char int8_t;
TYPEDEF signed short int16_t;
TYPEDEF signed int int32_t;
TYPEDEF signed _Int64 int64_t;
TYPEDEF signed _Int64 intmax_t;
TYPEDEF unsigned char uint8_t;
TYPEDEF unsigned short uint16_t;
TYPEDEF unsigned int uint32_t;
TYPEDEF unsigned _Int64 uint64_t;
TYPEDEF unsigned _Int64 u_int64_t;
TYPEDEF unsigned _Int64 uintmax_t;
// XXX EMSCRIPTEN: This file has been modified from the upstream musl version
// to make use of clang pre-defined macros whereever possible, eliminating
// possible inconsistencies.

TYPEDEF __INT8_TYPE__ int8_t;
TYPEDEF __INT16_TYPE__ int16_t;
TYPEDEF __INT32_TYPE__ int32_t;
TYPEDEF __INT64_TYPE__ int64_t;
TYPEDEF __INTMAX_TYPE__ intmax_t;
TYPEDEF __UINT8_TYPE__ uint8_t;
TYPEDEF __UINT16_TYPE__ uint16_t;
TYPEDEF __UINT32_TYPE__ uint32_t;
TYPEDEF __UINT64_TYPE__ uint64_t;
TYPEDEF __UINT64_TYPE__ u_int64_t;
TYPEDEF __UINTMAX_TYPE__ uintmax_t;

TYPEDEF unsigned mode_t;
TYPEDEF unsigned _Reg nlink_t;
Expand Down
172 changes: 77 additions & 95 deletions system/lib/libc/musl/include/stdint.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,30 @@

#include <bits/alltypes.h>

typedef int8_t int_fast8_t;
typedef int64_t int_fast64_t;
// XXX EMSCRIPTEN: This file has been modified from the upstream musl version
// to make use of clang pre-defined macros whereever possible, eliminating
// possible inconsistencies.

typedef __INT_FAST8_TYPE__ int_fast8_t;
typedef __INT_FAST16_TYPE__ int_fast16_t;
typedef __INT_FAST32_TYPE__ int_fast32_t;
typedef __INT_FAST64_TYPE__ int_fast64_t;

typedef __INT_LEAST8_TYPE__ int_least8_t;
typedef __INT_LEAST16_TYPE__ int_least16_t;
typedef __INT_LEAST32_TYPE__ int_least32_t;
typedef __INT_LEAST64_TYPE__ int_least64_t;

typedef __UINT_FAST8_TYPE__ uint_fast8_t;
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
typedef __UINT_FAST64_TYPE__ uint_fast64_t;

typedef __UINT_LEAST8_TYPE__ uint_least8_t;
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
typedef __UINT_LEAST64_TYPE__ uint_least64_t;

typedef int8_t int_least8_t;
typedef int16_t int_least16_t;
typedef int32_t int_least32_t;
typedef int64_t int_least64_t;

typedef uint8_t uint_fast8_t;
typedef uint64_t uint_fast64_t;

typedef uint8_t uint_least8_t;
typedef uint16_t uint_least16_t;
typedef uint32_t uint_least32_t;
typedef uint64_t uint_least64_t;

#ifdef __EMSCRIPTEN__
#define INT8_MIN (-1-__INT8_MAX__)
#define INT16_MIN (-1-__INT16_MAX__)
#define INT32_MIN (-1-__INT32_MAX__)
Expand All @@ -50,91 +57,66 @@ typedef uint64_t uint_least64_t;
#define UINT16_MAX __UINT16_MAX__
#define UINT32_MAX __UINT32_MAX__
#define UINT64_MAX __UINT64_MAX__
#else
#define INT8_MIN (-1-0x7f)
#define INT16_MIN (-1-0x7fff)
#define INT32_MIN (-1-0x7fffffff)
#define INT64_MIN (-1-0x7fffffffffffffff)

#define INT8_MAX (0x7f)
#define INT16_MAX (0x7fff)
#define INT32_MAX (0x7fffffff)
#define INT64_MAX (0x7fffffffffffffff)

#define UINT8_MAX (0xff)
#define UINT16_MAX (0xffff)
#define UINT32_MAX (0xffffffffu)
#define UINT64_MAX (0xffffffffffffffffu)
#endif

#define INT_FAST8_MIN INT8_MIN
#define INT_FAST64_MIN INT64_MIN

#define INT_LEAST8_MIN INT8_MIN
#define INT_LEAST16_MIN INT16_MIN
#define INT_LEAST32_MIN INT32_MIN
#define INT_LEAST64_MIN INT64_MIN

#define INT_FAST8_MAX INT8_MAX
#define INT_FAST64_MAX INT64_MAX

#define INT_LEAST8_MAX INT8_MAX
#define INT_LEAST16_MAX INT16_MAX
#define INT_LEAST32_MAX INT32_MAX
#define INT_LEAST64_MAX INT64_MAX

#define UINT_FAST8_MAX UINT8_MAX
#define UINT_FAST64_MAX UINT64_MAX

#define UINT_LEAST8_MAX UINT8_MAX
#define UINT_LEAST16_MAX UINT16_MAX
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX

#define INTMAX_MIN INT64_MIN
#define INTMAX_MAX INT64_MAX
#define UINTMAX_MAX UINT64_MAX

#define WINT_MIN 0U
#define WINT_MAX UINT32_MAX

#if L'\0'-1 > 0
#define WCHAR_MAX (0xffffffffu+L'\0')
#define WCHAR_MIN (0+L'\0')
#else
#define WCHAR_MAX (0x7fffffff+L'\0')
#define WCHAR_MIN (-1-0x7fffffff+L'\0')
#endif
#define INT_FAST8_MIN (-1-__INT_FAST8_MAX__)
Comment thread
sbc100 marked this conversation as resolved.
#define INT_FAST16_MIN (-1-__INT_FAST16_MAX__)
#define INT_FAST32_MIN (-1-__INT_FAST32_MAX__)
#define INT_FAST64_MIN (-1-__INT_FAST64_MAX__)

#define INT_LEAST8_MIN (-1-__INT_LEAST8_MAX__)
#define INT_LEAST16_MIN (-1-__INT_LEAST16_MAX__)
#define INT_LEAST32_MIN (-1-__INT_LEAST32_MAX__)
#define INT_LEAST64_MIN (-1-__INT_LEAST64_MAX__)

#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 INTMAX_MIN (-1-__INTMAX_MAX__)
#define INTMAX_MAX __INTMAX_MAX__
#define UINTMAX_MAX __UINTMAX_MAX__

#define WCHAR_MAX __WCHAR_MAX__
#define WINT_MAX __WINT_MAX__
#define INTPTR_MAX __INTPTR_MAX__
#define UINTPTR_MAX __UINTPTR_MAX__
#define PTRDIFF_MAX __PTRDIFF_MAX__
#define SIZE_MAX __SIZE_MAX__

#define WINT_MIN (-1-__WINT_MAX__)
#define WCHAR_MIN (-1-__WCHAR_MAX__)
#define INTPTR_MIN (-1-__INTPTR_MAX__)
#define PTRDIFF_MIN (-1-__PTRDIFF_MAX__)

#define SIG_ATOMIC_MIN INT32_MIN
#define SIG_ATOMIC_MAX INT32_MAX

#include <bits/stdint.h>

#define INT8_C(c) c
#define INT16_C(c) c
#define INT32_C(c) c

#define UINT8_C(c) c
#define UINT16_C(c) c
#define UINT32_C(c) c ## U

// XXX EMSCRIPTEN: Use the clang-builtin macros here when available.
#ifdef __UINT64_C
#define INT64_C __INT64_C
#define UINT64_C __UINT64_C
#define INT8_C __INT8_C
#define INT16_C __INT16_C
#define INT32_C __INT32_C
#define INT64_C __INT64_C
#define INTMAX_C __INTMAX_C

#define UINT8_C __UINT8_C
#define UINT16_C __UINT16_C
#define UINT32_C __UINT32_C
#define UINT64_C __UINT64_C
#define UINTMAX_C __UINTMAX_C
#elif UINTPTR_MAX == UINT64_MAX
#define INT64_C(c) c ## L
#define UINT64_C(c) c ## UL
#define INTMAX_C(c) c ## L
#define UINTMAX_C(c) c ## UL
#else
#define INT64_C(c) c ## LL
#define UINT64_C(c) c ## ULL
#define INTMAX_C(c) c ## LL
#define UINTMAX_C(c) c ## ULL
#endif

#endif
26 changes: 25 additions & 1 deletion test/other/test_stdint_limits.64.out
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ INTPTR_MAX: 9223372036854775807
WCHAR_MIN: -2147483648
WCHAR_MAX: 2147483647
WINT_MIN: 0
WINT_MAX: 4294967295
WINT_MAX: -1
UINTPTR_MAX: 18446744073709551615
SIZE_MAX: 18446744073709551615
SSIZE_MAX: 9223372036854775807
Expand All @@ -25,10 +25,34 @@ INT32_MIN: -2147483648
INT32_MAX: 2147483647
INT64_MIN: -9223372036854775808
INT64_MAX: 9223372036854775807
INT_LEAST8_MIN: -128
INT_LEAST8_MAX: 127
INT_LEAST16_MIN: -32768
INT_LEAST16_MAX: 32767
INT_LEAST32_MIN: -2147483648
INT_LEAST32_MAX: 2147483647
INT_LEAST64_MIN: -9223372036854775808
INT_LEAST64_MAX: 9223372036854775807
INT_FAST8_MIN: -128
INT_FAST8_MAX: 127
INT_FAST16_MIN: -2147483648
INT_FAST16_MAX: 2147483647
INT_FAST32_MIN: -2147483648
INT_FAST32_MAX: 2147483647
INT_FAST64_MIN: -9223372036854775808
INT_FAST64_MAX: 9223372036854775807
UINT8_MAX: 255
UINT16_MAX: 65535
UINT32_MAX: 4294967295
UINT64_MAX: 18446744073709551615
UINT_LEAST8_MAX: 255
UINT_LEAST16_MAX: 65535
UINT_LEAST32_MAX: 4294967295
UINT_LEAST64_MAX: 18446744073709551615
UINT_FAST8_MAX: 255
UINT_FAST16_MAX: 4294967295
UINT_FAST32_MAX: 4294967295
UINT_FAST64_MAX: 18446744073709551615
INT8_C: (d) 42
INT16_C: (d) 42
INT32_C: (d) 42
Expand Down
Loading
Loading