commit 4df0fba8b05fcf175805f7bb41aa7fd6333e2ad9
parent e06af7592242862e95c1a200e711f7bb57802628
Author: Sebastian <sebastian@sebsite.pw>
Date: Wed, 7 Jun 2023 03:07:49 -0400
types::c: add limits
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
4 files changed, 360 insertions(+), 0 deletions(-)
diff --git a/types/c/arch+aarch64.ha b/types/c/arch+aarch64.ha
@@ -1,40 +1,114 @@
+use types;
+
// Integer type compatible with `char`, as specified by ISO/IEC 9899.
export type char = uchar;
+// Minimum value which can be stored in a [[char]] type.
+export def CHAR_MIN: char = UCHAR_MIN;
+
+// Maximum value which can be stored in a [[char]] type.
+export def CHAR_MAX: char = UCHAR_MAX;
+
// Integer type compatible with `signed char`, as specified by ISO/IEC 9899.
export type schar = i8;
+// Minimum value which can be stored in an [[schar]] type.
+export def SCHAR_MIN: schar = types::I8_MIN;
+
+// Maximum value which can be stored in an [[schar]] type.
+export def SCHAR_MAX: schar = types::I8_MAX;
+
// Integer type compatible with `unsigned char`, as specified by ISO/IEC 9899.
export type uchar = u8;
+// Minimum value which can be stored in a [[uchar]] type.
+export def UCHAR_MIN: uchar = types::U8_MIN;
+
+// Maximum value which can be stored in a [[uchar]] type.
+export def UCHAR_MAX: uchar = types::U8_MAX;
+
// Integer type compatible with `signed short`, as specified by ISO/IEC 9899.
export type short = i16;
+// Minimum value which can be stored in a [[short]] type.
+export def SHORT_MIN: short = types::I16_MIN;
+
+// Maximum value which can be stored in a [[short]] type.
+export def SHORT_MAX: short = types::I16_MAX;
+
// Integer type compatible with `unsigned short`, as specified by ISO/IEC 9899.
export type ushort = u16;
+// Minimum value which can be stored in a [[ushort]] type.
+export def USHRT_MIN: ushort = types::U16_MIN;
+
+// Maximum value which can be stored in a [[ushort]] type.
+export def USHRT_MAX: ushort = types::U16_MAX;
+
// Integer type compatible with `signed long`, as specified by ISO/IEC 9899.
export type long = i64;
+// Minimum value which can be stored in a [[long]] type.
+export def LONG_MIN: long = types::I64_MIN;
+
+// Maximum value which can be stored in a [[long]] type.
+export def LONG_MAX: long = types::I64_MAX;
+
// Integer type compatible with `unsigned long`, as specified by ISO/IEC 9899.
export type ulong = u64;
+// Minimum value which can be stored in a [[ulong]] type.
+export def ULONG_MIN: ulong = types::U64_MIN;
+
+// Maximum value which can be stored in a [[ulong]] type.
+export def ULONG_MAX: ulong = types::U64_MAX;
+
// Integer type compatible with `signed long long`, as specified by ISO/IEC
// 9899:1999.
export type longlong = i64;
+// Minimum value which can be stored in a [[longlong]] type.
+export def LLONG_MIN: longlong = types::I64_MIN;
+
+// Maximum value which can be stored in a [[longlong]] type.
+export def LLONG_MAX: longlong = types::I64_MAX;
+
// Integer type compatible with `unsigned long long`, as specified by ISO/IEC
// 9899:1999.
export type ulonglong = u64;
+// Minimum value which can be stored in a [[ulonglong]] type.
+export def ULLONG_MIN: ulonglong = types::U64_MIN;
+
+// Maximum value which can be stored in a [[ulonglong]] type.
+export def ULLONG_MAX: ulonglong = types::U64_MAX;
+
// Integer type compatible with `intptr_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899.
export type intptr = i64;
+// Minimum value which can be stored in an [[intptr]] type.
+export def INTPTR_MIN: intptr = types::I64_MIN;
+
+// Maximum value which can be stored in an [[intptr]] type.
+export def INTPTR_MAX: intptr = types::I64_MAX;
+
// Integer type compatible with `ptrdiff_t`, as defined in <stddef.h> and
// specified by ISO/IEC 9899.
export type ptrdiff = i64;
+// Minimum value which can be stored in a [[ptrdiff]] type.
+export def PTRDIFF_MIN: ptrdiff = types::I64_MIN;
+
+// Maximum value which can be stored in a [[ptrdiff]] type.
+export def PTRDIFF_MAX: ptrdiff = types::I64_MAX;
+
// Integer type compatible with `ssize_t`, as defined in <sys/types.h> and
// specified by POSIX.
export type ssize = i64;
+
+// Minimum value which can be stored in an [[ssize]] type.
+export def SSIZE_MIN: ssize = types::I64_MIN;
+
+// Maximum value which can be stored in an [[ssize]] type.
+export def SSIZE_MAX: ssize = types::I64_MAX;
diff --git a/types/c/arch+riscv64.ha b/types/c/arch+riscv64.ha
@@ -1,40 +1,114 @@
+use types;
+
// Integer type compatible with `char`, as specified by ISO/IEC 9899.
export type char = uchar;
+// Minimum value which can be stored in a [[char]] type.
+export def CHAR_MIN: char = UCHAR_MIN;
+
+// Maximum value which can be stored in a [[char]] type.
+export def CHAR_MAX: char = UCHAR_MAX;
+
// Integer type compatible with `signed char`, as specified by ISO/IEC 9899.
export type schar = i8;
+// Minimum value which can be stored in an [[schar]] type.
+export def SCHAR_MIN: schar = types::I8_MIN;
+
+// Maximum value which can be stored in an [[schar]] type.
+export def SCHAR_MAX: schar = types::I8_MAX;
+
// Integer type compatible with `unsigned char`, as specified by ISO/IEC 9899.
export type uchar = u8;
+// Minimum value which can be stored in a [[uchar]] type.
+export def UCHAR_MIN: uchar = types::U8_MIN;
+
+// Maximum value which can be stored in a [[uchar]] type.
+export def UCHAR_MAX: uchar = types::U8_MAX;
+
// Integer type compatible with `signed short`, as specified by ISO/IEC 9899.
export type short = i16;
+// Minimum value which can be stored in a [[short]] type.
+export def SHORT_MIN: short = types::I16_MIN;
+
+// Maximum value which can be stored in a [[short]] type.
+export def SHORT_MAX: short = types::I16_MAX;
+
// Integer type compatible with `unsigned short`, as specified by ISO/IEC 9899.
export type ushort = u16;
+// Minimum value which can be stored in a [[ushort]] type.
+export def USHRT_MIN: ushort = types::U16_MIN;
+
+// Maximum value which can be stored in a [[ushort]] type.
+export def USHRT_MAX: ushort = types::U16_MAX;
+
// Integer type compatible with `signed long`, as specified by ISO/IEC 9899.
export type long = i64;
+// Minimum value which can be stored in a [[long]] type.
+export def LONG_MIN: long = types::I64_MIN;
+
+// Maximum value which can be stored in a [[long]] type.
+export def LONG_MAX: long = types::I64_MAX;
+
// Integer type compatible with `unsigned long`, as specified by ISO/IEC 9899.
export type ulong = u64;
+// Minimum value which can be stored in a [[ulong]] type.
+export def ULONG_MIN: ulong = types::U64_MIN;
+
+// Maximum value which can be stored in a [[ulong]] type.
+export def ULONG_MAX: ulong = types::U64_MAX;
+
// Integer type compatible with `signed long long`, as specified by ISO/IEC
// 9899:1999.
export type longlong = i64;
+// Minimum value which can be stored in a [[longlong]] type.
+export def LLONG_MIN: longlong = types::I64_MIN;
+
+// Maximum value which can be stored in a [[longlong]] type.
+export def LLONG_MAX: longlong = types::I64_MAX;
+
// Integer type compatible with `unsigned long long`, as specified by ISO/IEC
// 9899:1999.
export type ulonglong = u64;
+// Minimum value which can be stored in a [[ulonglong]] type.
+export def ULLONG_MIN: ulonglong = types::U64_MIN;
+
+// Maximum value which can be stored in a [[ulonglong]] type.
+export def ULLONG_MAX: ulonglong = types::U64_MAX;
+
// Integer type compatible with `intptr_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899.
export type intptr = i64;
+// Minimum value which can be stored in an [[intptr]] type.
+export def INTPTR_MIN: intptr = types::I64_MIN;
+
+// Maximum value which can be stored in an [[intptr]] type.
+export def INTPTR_MAX: intptr = types::I64_MAX;
+
// Integer type compatible with `ptrdiff_t`, as defined in <stddef.h> and
// specified by ISO/IEC 9899.
export type ptrdiff = i64;
+// Minimum value which can be stored in a [[ptrdiff]] type.
+export def PTRDIFF_MIN: ptrdiff = types::I64_MIN;
+
+// Maximum value which can be stored in a [[ptrdiff]] type.
+export def PTRDIFF_MAX: ptrdiff = types::I64_MAX;
+
// Integer type compatible with `ssize_t`, as defined in <sys/types.h> and
// specified by POSIX.
export type ssize = i64;
+
+// Minimum value which can be stored in an [[ssize]] type.
+export def SSIZE_MIN: ssize = types::I64_MIN;
+
+// Maximum value which can be stored in an [[ssize]] type.
+export def SSIZE_MAX: ssize = types::I64_MAX;
diff --git a/types/c/arch+x86_64.ha b/types/c/arch+x86_64.ha
@@ -1,40 +1,114 @@
+use types;
+
// Integer type compatible with `char`, as specified by ISO/IEC 9899.
export type char = schar;
+// Minimum value which can be stored in a [[char]] type.
+export def CHAR_MIN: char = SCHAR_MIN;
+
+// Maximum value which can be stored in a [[char]] type.
+export def CHAR_MAX: char = SCHAR_MAX;
+
// Integer type compatible with `signed char`, as specified by ISO/IEC 9899.
export type schar = i8;
+// Minimum value which can be stored in an [[schar]] type.
+export def SCHAR_MIN: schar = types::I8_MIN;
+
+// Maximum value which can be stored in an [[schar]] type.
+export def SCHAR_MAX: schar = types::I8_MAX;
+
// Integer type compatible with `unsigned char`, as specified by ISO/IEC 9899.
export type uchar = u8;
+// Minimum value which can be stored in a [[uchar]] type.
+export def UCHAR_MIN: uchar = types::U8_MIN;
+
+// Maximum value which can be stored in a [[uchar]] type.
+export def UCHAR_MAX: uchar = types::U8_MAX;
+
// Integer type compatible with `signed short`, as specified by ISO/IEC 9899.
export type short = i16;
+// Minimum value which can be stored in a [[short]] type.
+export def SHORT_MIN: short = types::I16_MIN;
+
+// Maximum value which can be stored in a [[short]] type.
+export def SHORT_MAX: short = types::I16_MAX;
+
// Integer type compatible with `unsigned short`, as specified by ISO/IEC 9899.
export type ushort = u16;
+// Minimum value which can be stored in a [[ushort]] type.
+export def USHRT_MIN: ushort = types::U16_MIN;
+
+// Maximum value which can be stored in a [[ushort]] type.
+export def USHRT_MAX: ushort = types::U16_MAX;
+
// Integer type compatible with `signed long`, as specified by ISO/IEC 9899.
export type long = i64;
+// Minimum value which can be stored in a [[long]] type.
+export def LONG_MIN: long = types::I64_MIN;
+
+// Maximum value which can be stored in a [[long]] type.
+export def LONG_MAX: long = types::I64_MAX;
+
// Integer type compatible with `unsigned long`, as specified by ISO/IEC 9899.
export type ulong = u64;
+// Minimum value which can be stored in a [[ulong]] type.
+export def ULONG_MIN: ulong = types::U64_MIN;
+
+// Maximum value which can be stored in a [[ulong]] type.
+export def ULONG_MAX: ulong = types::U64_MAX;
+
// Integer type compatible with `signed long long`, as specified by ISO/IEC
// 9899:1999.
export type longlong = i64;
+// Minimum value which can be stored in a [[longlong]] type.
+export def LLONG_MIN: longlong = types::I64_MIN;
+
+// Maximum value which can be stored in a [[longlong]] type.
+export def LLONG_MAX: longlong = types::I64_MAX;
+
// Integer type compatible with `unsigned long long`, as specified by ISO/IEC
// 9899:1999.
export type ulonglong = u64;
+// Minimum value which can be stored in a [[ulonglong]] type.
+export def ULLONG_MIN: ulonglong = types::U64_MIN;
+
+// Maximum value which can be stored in a [[ulonglong]] type.
+export def ULLONG_MAX: ulonglong = types::U64_MAX;
+
// Integer type compatible with `intptr_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899.
export type intptr = i64;
+// Minimum value which can be stored in an [[intptr]] type.
+export def INTPTR_MIN: intptr = types::I64_MIN;
+
+// Maximum value which can be stored in an [[intptr]] type.
+export def INTPTR_MAX: intptr = types::I64_MAX;
+
// Integer type compatible with `ptrdiff_t`, as defined in <stddef.h> and
// specified by ISO/IEC 9899.
export type ptrdiff = i64;
+// Minimum value which can be stored in a [[ptrdiff]] type.
+export def PTRDIFF_MIN: ptrdiff = types::I64_MIN;
+
+// Maximum value which can be stored in a [[ptrdiff]] type.
+export def PTRDIFF_MAX: ptrdiff = types::I64_MAX;
+
// Integer type compatible with `ssize_t`, as defined in <sys/types.h> and
// specified by POSIX.
export type ssize = i64;
+
+// Minimum value which can be stored in an [[ssize]] type.
+export def SSIZE_MIN: ssize = types::I64_MIN;
+
+// Maximum value which can be stored in an [[ssize]] type.
+export def SSIZE_MAX: ssize = types::I64_MAX;
diff --git a/types/c/types.ha b/types/c/types.ha
@@ -4,14 +4,32 @@ use types;
// by ISO/IEC 9899:2023.
export type char8 = uchar;
+// Minimum value which can be stored in a [[char8]] type.
+export def CHAR8_MIN: char8 = UCHAR_MIN;
+
+// Maximum value which can be stored in a [[char8]] type.
+export def CHAR8_MAX: char8 = UCHAR_MAX;
+
// Integer type compatible with `char16_t`, as defined in <uchar.h> and
// specified by ISO/IEC 9899:2011.
export type char16 = uint_least16;
+// Minimum value which can be stored in a [[char16]] type.
+export def CHAR16_MIN: char16 = UINT_LEAST16_MIN;
+
+// Maximum value which can be stored in a [[char16]] type.
+export def CHAR16_MAX: char16 = UINT_LEAST16_MAX;
+
// Integer type compatible with `char32_t`, as defined in <uchar.h> and
// specified by ISO/IEC 9899:2011.
export type char32 = uint_least32;
+// Minimum value which can be stored in a [[char32]] type.
+export def CHAR32_MIN: char32 = UINT_LEAST32_MIN;
+
+// Maximum value which can be stored in a [[char32]] type.
+export def CHAR32_MAX: char32 = UINT_LEAST32_MAX;
+
// Integer type compatible with `intmax_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
//
@@ -19,6 +37,12 @@ export type char32 = uint_least32;
// type should only be used when required for C interop.
export type intmax = i64;
+// Minimum value which can be stored in an [[intmax]] type.
+export def INTMAX_MIN: intmax = types::I64_MIN;
+
+// Maximum value which can be stored in an [[intmax]] type.
+export def INTMAX_MAX: intmax = types::I64_MAX;
+
// Integer type compatible with `uintmax_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
//
@@ -26,74 +50,188 @@ export type intmax = i64;
// type should only be used when required for C interop.
export type uintmax = u64;
+// Minimum value which can be stored in a [[uintmax]] type.
+export def UINTMAX_MIN: uintmax = types::U64_MIN;
+
+// Maximum value which can be stored in a [[uintmax]] type.
+export def UINTMAX_MAX: uintmax = types::U64_MAX;
+
// Integer type compatible with `int_least8_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type int_least8 = i8;
+// Minimum value which can be stored in an [[int_least8]] type.
+export def INT_LEAST8_MIN: int_least8 = types::I8_MIN;
+
+// Maximum value which can be stored in an [[int_least8]] type.
+export def INT_LEAST8_MAX: int_least8 = types::I8_MAX;
+
// Integer type compatible with `int_least16_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type int_least16 = i16;
+// Minimum value which can be stored in an [[int_least16]] type.
+export def INT_LEAST16_MIN: int_least16 = types::I16_MIN;
+
+// Maximum value which can be stored in an [[int_least16]] type.
+export def INT_LEAST16_MAX: int_least16 = types::I16_MAX;
+
// Integer type compatible with `int_least32_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type int_least32 = i32;
+// Minimum value which can be stored in an [[int_least32]] type.
+export def INT_LEAST32_MIN: int_least32 = types::I32_MIN;
+
+// Maximum value which can be stored in an [[int_least32]] type.
+export def INT_LEAST32_MAX: int_least32 = types::I32_MAX;
+
// Integer type compatible with `int_least64_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type int_least64 = i64;
+// Minimum value which can be stored in an [[int_least64]] type.
+export def INT_LEAST64_MIN: int_least64 = types::I64_MIN;
+
+// Maximum value which can be stored in an [[int_least64]] type.
+export def INT_LEAST64_MAX: int_least64 = types::I64_MAX;
+
// Integer type compatible with `uint_least8_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type uint_least8 = u8;
+// Minimum value which can be stored in a [[uint_least8]] type.
+export def UINT_LEAST8_MIN: uint_least8 = types::U8_MIN;
+
+// Maximum value which can be stored in a [[uint_least8]] type.
+export def UINT_LEAST8_MAX: uint_least8 = types::U8_MAX;
+
// Integer type compatible with `uint_least16_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type uint_least16 = u16;
+// Minimum value which can be stored in a [[uint_least16]] type.
+export def UINT_LEAST16_MIN: uint_least16 = types::U16_MIN;
+
+// Maximum value which can be stored in a [[uint_least16]] type.
+export def UINT_LEAST16_MAX: uint_least16 = types::U16_MAX;
+
// Integer type compatible with `uint_least32_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type uint_least32 = u32;
+// Minimum value which can be stored in a [[uint_least32]] type.
+export def UINT_LEAST32_MIN: uint_least32 = types::U32_MIN;
+
+// Maximum value which can be stored in a [[uint_least32]] type.
+export def UINT_LEAST32_MAX: uint_least32 = types::U32_MAX;
+
// Integer type compatible with `uint_least64_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type uint_least64 = u64;
+// Minimum value which can be stored in a [[uint_least64]] type.
+export def UINT_LEAST64_MIN: uint_least64 = types::U64_MIN;
+
+// Maximum value which can be stored in a [[uint_least64]] type.
+export def UINT_LEAST64_MAX: uint_least64 = types::U64_MAX;
+
// Integer type compatible with `int_fast8_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type int_fast8 = i8;
+// Minimum value which can be stored in an [[int_fast8]] type.
+export def INT_FAST8_MIN: int_fast8 = types::I8_MIN;
+
+// Maximum value which can be stored in an [[int_fast8]] type.
+export def INT_FAST8_MAX: int_fast8 = types::I8_MAX;
+
// Integer type compatible with `int_fast16_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type int_fast16 = i16;
+// Minimum value which can be stored in an [[int_fast16]] type.
+export def INT_FAST16_MIN: int_fast16 = types::I16_MIN;
+
+// Maximum value which can be stored in an [[int_fast16]] type.
+export def INT_FAST16_MAX: int_fast16 = types::I16_MAX;
+
// Integer type compatible with `int_fast32_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type int_fast32 = i32;
+// Minimum value which can be stored in an [[int_fast32]] type.
+export def INT_FAST32_MIN: int_fast32 = types::I32_MIN;
+
+// Maximum value which can be stored in an [[int_fast32]] type.
+export def INT_FAST32_MAX: int_fast32 = types::I32_MAX;
+
// Integer type compatible with `int_fast64_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type int_fast64 = i64;
+// Minimum value which can be stored in an [[int_fast64]] type.
+export def INT_FAST64_MIN: int_fast64 = types::I64_MIN;
+
+// Maximum value which can be stored in an [[int_fast64]] type.
+export def INT_FAST64_MAX: int_fast64 = types::I64_MAX;
+
// Integer type compatible with `uint_fast8_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type uint_fast8 = u8;
+// Minimum value which can be stored in a [[uint_fast8]] type.
+export def UINT_FAST8_MIN: uint_fast8 = types::U8_MIN;
+
+// Maximum value which can be stored in a [[uint_fast8]] type.
+export def UINT_FAST8_MAX: uint_fast8 = types::U8_MAX;
+
// Integer type compatible with `uint_fast16_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type uint_fast16 = u16;
+// Minimum value which can be stored in a [[uint_fast16]] type.
+export def UINT_FAST16_MIN: uint_fast16 = types::U16_MIN;
+
+// Maximum value which can be stored in a [[uint_fast16]] type.
+export def UINT_FAST16_MAX: uint_fast16 = types::U16_MAX;
+
// Integer type compatible with `uint_fast32_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type uint_fast32 = u32;
+// Minimum value which can be stored in a [[uint_fast32]] type.
+export def UINT_FAST32_MIN: uint_fast32 = types::U32_MIN;
+
+// Maximum value which can be stored in a [[uint_fast32]] type.
+export def UINT_FAST32_MAX: uint_fast32 = types::U32_MAX;
+
// Integer type compatible with `uint_fast64_t`, as defined in <stdint.h> and
// specified by ISO/IEC 9899:1999.
export type uint_fast64 = u64;
+// Minimum value which can be stored in a [[uint_fast64]] type.
+export def UINT_FAST64_MIN: uint_fast64 = types::U64_MIN;
+
+// Maximum value which can be stored in a [[uint_fast64]] type.
+export def UINT_FAST64_MAX: uint_fast64 = types::U64_MAX;
+
// Integer type compatible with `wchar_t`, as defined in <stddef.h> and
// specified by ISO/IEC 9899.
export type wchar = i32;
+// Minimum value which can be stored in a [[wchar]] type.
+export def WCHAR_MIN: wchar = types::I32_MIN;
+
+// Maximum value which can be stored in a [[wchar]] type.
+export def WCHAR_MAX: wchar = types::I32_MAX;
+
// Integer type compatible with `wint_t`, as defined in <stdint.h> and specified
// by ISO/IEC 9899:1994.
export type wint = u32;
+
+// Minimum value which can be stored in a [[wint]] type.
+export def WINT_MIN: wint = types::U32_MIN;
+
+// Maximum value which can be stored in a [[wint]] type.
+export def WINT_MAX: wint = types::U32_MAX;