1c34da317SVincent Dagonneau /* SPDX-License-Identifier: LGPL-2.1 OR MIT */ 2c34da317SVincent Dagonneau /* 3c34da317SVincent Dagonneau * Standard definitions and types for NOLIBC 4c34da317SVincent Dagonneau * Copyright (C) 2023 Vincent Dagonneau <v@vda.io> 5c34da317SVincent Dagonneau */ 6c34da317SVincent Dagonneau 7c34da317SVincent Dagonneau #ifndef _NOLIBC_STDINT_H 8c34da317SVincent Dagonneau #define _NOLIBC_STDINT_H 9c34da317SVincent Dagonneau 10c34da317SVincent Dagonneau typedef unsigned char uint8_t; 11c34da317SVincent Dagonneau typedef signed char int8_t; 12c34da317SVincent Dagonneau typedef unsigned short uint16_t; 13c34da317SVincent Dagonneau typedef signed short int16_t; 14c34da317SVincent Dagonneau typedef unsigned int uint32_t; 15c34da317SVincent Dagonneau typedef signed int int32_t; 16c34da317SVincent Dagonneau typedef unsigned long long uint64_t; 17c34da317SVincent Dagonneau typedef signed long long int64_t; 18*202a0bd1SThomas Weißschuh typedef __SIZE_TYPE__ size_t; 19c34da317SVincent Dagonneau typedef signed long ssize_t; 20c34da317SVincent Dagonneau typedef unsigned long uintptr_t; 21c34da317SVincent Dagonneau typedef signed long intptr_t; 22c34da317SVincent Dagonneau typedef signed long ptrdiff_t; 23c34da317SVincent Dagonneau 243e9fd4e9SVincent Dagonneau typedef int8_t int_least8_t; 253e9fd4e9SVincent Dagonneau typedef uint8_t uint_least8_t; 263e9fd4e9SVincent Dagonneau typedef int16_t int_least16_t; 273e9fd4e9SVincent Dagonneau typedef uint16_t uint_least16_t; 283e9fd4e9SVincent Dagonneau typedef int32_t int_least32_t; 293e9fd4e9SVincent Dagonneau typedef uint32_t uint_least32_t; 303e9fd4e9SVincent Dagonneau typedef int64_t int_least64_t; 313e9fd4e9SVincent Dagonneau typedef uint64_t uint_least64_t; 323e9fd4e9SVincent Dagonneau 333e9fd4e9SVincent Dagonneau typedef int8_t int_fast8_t; 343e9fd4e9SVincent Dagonneau typedef uint8_t uint_fast8_t; 353e9fd4e9SVincent Dagonneau typedef ssize_t int_fast16_t; 363e9fd4e9SVincent Dagonneau typedef size_t uint_fast16_t; 373e9fd4e9SVincent Dagonneau typedef ssize_t int_fast32_t; 383e9fd4e9SVincent Dagonneau typedef size_t uint_fast32_t; 39f9bf5944SThomas Weißschuh typedef int64_t int_fast64_t; 40f9bf5944SThomas Weißschuh typedef uint64_t uint_fast64_t; 413e9fd4e9SVincent Dagonneau 423e9fd4e9SVincent Dagonneau typedef int64_t intmax_t; 433e9fd4e9SVincent Dagonneau typedef uint64_t uintmax_t; 443e9fd4e9SVincent Dagonneau 453e9fd4e9SVincent Dagonneau /* limits of integral types */ 463e9fd4e9SVincent Dagonneau 473e9fd4e9SVincent Dagonneau #define INT8_MIN (-128) 483e9fd4e9SVincent Dagonneau #define INT16_MIN (-32767-1) 493e9fd4e9SVincent Dagonneau #define INT32_MIN (-2147483647-1) 503e9fd4e9SVincent Dagonneau #define INT64_MIN (-9223372036854775807LL-1) 513e9fd4e9SVincent Dagonneau 523e9fd4e9SVincent Dagonneau #define INT8_MAX (127) 533e9fd4e9SVincent Dagonneau #define INT16_MAX (32767) 543e9fd4e9SVincent Dagonneau #define INT32_MAX (2147483647) 553e9fd4e9SVincent Dagonneau #define INT64_MAX (9223372036854775807LL) 563e9fd4e9SVincent Dagonneau 573e9fd4e9SVincent Dagonneau #define UINT8_MAX (255) 583e9fd4e9SVincent Dagonneau #define UINT16_MAX (65535) 593e9fd4e9SVincent Dagonneau #define UINT32_MAX (4294967295U) 603e9fd4e9SVincent Dagonneau #define UINT64_MAX (18446744073709551615ULL) 613e9fd4e9SVincent Dagonneau 623e9fd4e9SVincent Dagonneau #define INT_LEAST8_MIN INT8_MIN 633e9fd4e9SVincent Dagonneau #define INT_LEAST16_MIN INT16_MIN 643e9fd4e9SVincent Dagonneau #define INT_LEAST32_MIN INT32_MIN 653e9fd4e9SVincent Dagonneau #define INT_LEAST64_MIN INT64_MIN 663e9fd4e9SVincent Dagonneau 673e9fd4e9SVincent Dagonneau #define INT_LEAST8_MAX INT8_MAX 683e9fd4e9SVincent Dagonneau #define INT_LEAST16_MAX INT16_MAX 693e9fd4e9SVincent Dagonneau #define INT_LEAST32_MAX INT32_MAX 703e9fd4e9SVincent Dagonneau #define INT_LEAST64_MAX INT64_MAX 713e9fd4e9SVincent Dagonneau 723e9fd4e9SVincent Dagonneau #define UINT_LEAST8_MAX UINT8_MAX 733e9fd4e9SVincent Dagonneau #define UINT_LEAST16_MAX UINT16_MAX 743e9fd4e9SVincent Dagonneau #define UINT_LEAST32_MAX UINT32_MAX 753e9fd4e9SVincent Dagonneau #define UINT_LEAST64_MAX UINT64_MAX 763e9fd4e9SVincent Dagonneau 773e9fd4e9SVincent Dagonneau #define SIZE_MAX ((size_t)(__LONG_MAX__) * 2 + 1) 783e9fd4e9SVincent Dagonneau #define INTPTR_MIN (-__LONG_MAX__ - 1) 793e9fd4e9SVincent Dagonneau #define INTPTR_MAX __LONG_MAX__ 803e9fd4e9SVincent Dagonneau #define PTRDIFF_MIN INTPTR_MIN 813e9fd4e9SVincent Dagonneau #define PTRDIFF_MAX INTPTR_MAX 823e9fd4e9SVincent Dagonneau #define UINTPTR_MAX SIZE_MAX 833e9fd4e9SVincent Dagonneau 843e9fd4e9SVincent Dagonneau #define INT_FAST8_MIN INT8_MIN 853e9fd4e9SVincent Dagonneau #define INT_FAST16_MIN INTPTR_MIN 863e9fd4e9SVincent Dagonneau #define INT_FAST32_MIN INTPTR_MIN 87f9bf5944SThomas Weißschuh #define INT_FAST64_MIN INT64_MIN 883e9fd4e9SVincent Dagonneau 893e9fd4e9SVincent Dagonneau #define INT_FAST8_MAX INT8_MAX 903e9fd4e9SVincent Dagonneau #define INT_FAST16_MAX INTPTR_MAX 913e9fd4e9SVincent Dagonneau #define INT_FAST32_MAX INTPTR_MAX 92f9bf5944SThomas Weißschuh #define INT_FAST64_MAX INT64_MAX 933e9fd4e9SVincent Dagonneau 943e9fd4e9SVincent Dagonneau #define UINT_FAST8_MAX UINT8_MAX 953e9fd4e9SVincent Dagonneau #define UINT_FAST16_MAX SIZE_MAX 963e9fd4e9SVincent Dagonneau #define UINT_FAST32_MAX SIZE_MAX 97f9bf5944SThomas Weißschuh #define UINT_FAST64_MAX UINT64_MAX 983e9fd4e9SVincent Dagonneau 99bd27fef3SZhangjin Wu #ifndef INT_MIN 100bd27fef3SZhangjin Wu #define INT_MIN (-__INT_MAX__ - 1) 101bd27fef3SZhangjin Wu #endif 102bd27fef3SZhangjin Wu #ifndef INT_MAX 103bd27fef3SZhangjin Wu #define INT_MAX __INT_MAX__ 104bd27fef3SZhangjin Wu #endif 105bd27fef3SZhangjin Wu 106bd27fef3SZhangjin Wu #ifndef LONG_MIN 107bd27fef3SZhangjin Wu #define LONG_MIN (-__LONG_MAX__ - 1) 108bd27fef3SZhangjin Wu #endif 109bd27fef3SZhangjin Wu #ifndef LONG_MAX 110bd27fef3SZhangjin Wu #define LONG_MAX __LONG_MAX__ 111bd27fef3SZhangjin Wu #endif 112bd27fef3SZhangjin Wu 113c34da317SVincent Dagonneau #endif /* _NOLIBC_STDINT_H */ 114