162306a36Sopenharmony_ci/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Standard definitions and types for NOLIBC
462306a36Sopenharmony_ci * Copyright (C) 2023 Vincent Dagonneau <v@vda.io>
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#ifndef _NOLIBC_STDINT_H
862306a36Sopenharmony_ci#define _NOLIBC_STDINT_H
962306a36Sopenharmony_ci
1062306a36Sopenharmony_citypedef unsigned char       uint8_t;
1162306a36Sopenharmony_citypedef   signed char        int8_t;
1262306a36Sopenharmony_citypedef unsigned short     uint16_t;
1362306a36Sopenharmony_citypedef   signed short      int16_t;
1462306a36Sopenharmony_citypedef unsigned int       uint32_t;
1562306a36Sopenharmony_citypedef   signed int        int32_t;
1662306a36Sopenharmony_citypedef unsigned long long uint64_t;
1762306a36Sopenharmony_citypedef   signed long long  int64_t;
1862306a36Sopenharmony_citypedef __SIZE_TYPE__        size_t;
1962306a36Sopenharmony_citypedef   signed long       ssize_t;
2062306a36Sopenharmony_citypedef unsigned long     uintptr_t;
2162306a36Sopenharmony_citypedef   signed long      intptr_t;
2262306a36Sopenharmony_citypedef   signed long     ptrdiff_t;
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_citypedef   int8_t       int_least8_t;
2562306a36Sopenharmony_citypedef  uint8_t      uint_least8_t;
2662306a36Sopenharmony_citypedef  int16_t      int_least16_t;
2762306a36Sopenharmony_citypedef uint16_t     uint_least16_t;
2862306a36Sopenharmony_citypedef  int32_t      int_least32_t;
2962306a36Sopenharmony_citypedef uint32_t     uint_least32_t;
3062306a36Sopenharmony_citypedef  int64_t      int_least64_t;
3162306a36Sopenharmony_citypedef uint64_t     uint_least64_t;
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_citypedef   int8_t        int_fast8_t;
3462306a36Sopenharmony_citypedef  uint8_t       uint_fast8_t;
3562306a36Sopenharmony_citypedef  ssize_t       int_fast16_t;
3662306a36Sopenharmony_citypedef   size_t      uint_fast16_t;
3762306a36Sopenharmony_citypedef  ssize_t       int_fast32_t;
3862306a36Sopenharmony_citypedef   size_t      uint_fast32_t;
3962306a36Sopenharmony_citypedef  int64_t       int_fast64_t;
4062306a36Sopenharmony_citypedef uint64_t      uint_fast64_t;
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_citypedef  int64_t           intmax_t;
4362306a36Sopenharmony_citypedef uint64_t          uintmax_t;
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/* limits of integral types */
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci#define        INT8_MIN  (-128)
4862306a36Sopenharmony_ci#define       INT16_MIN  (-32767-1)
4962306a36Sopenharmony_ci#define       INT32_MIN  (-2147483647-1)
5062306a36Sopenharmony_ci#define       INT64_MIN  (-9223372036854775807LL-1)
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define        INT8_MAX  (127)
5362306a36Sopenharmony_ci#define       INT16_MAX  (32767)
5462306a36Sopenharmony_ci#define       INT32_MAX  (2147483647)
5562306a36Sopenharmony_ci#define       INT64_MAX  (9223372036854775807LL)
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci#define       UINT8_MAX  (255)
5862306a36Sopenharmony_ci#define      UINT16_MAX  (65535)
5962306a36Sopenharmony_ci#define      UINT32_MAX  (4294967295U)
6062306a36Sopenharmony_ci#define      UINT64_MAX  (18446744073709551615ULL)
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_ci#define  INT_LEAST8_MIN  INT8_MIN
6362306a36Sopenharmony_ci#define INT_LEAST16_MIN  INT16_MIN
6462306a36Sopenharmony_ci#define INT_LEAST32_MIN  INT32_MIN
6562306a36Sopenharmony_ci#define INT_LEAST64_MIN  INT64_MIN
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ci#define  INT_LEAST8_MAX  INT8_MAX
6862306a36Sopenharmony_ci#define INT_LEAST16_MAX  INT16_MAX
6962306a36Sopenharmony_ci#define INT_LEAST32_MAX  INT32_MAX
7062306a36Sopenharmony_ci#define INT_LEAST64_MAX  INT64_MAX
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ci#define  UINT_LEAST8_MAX UINT8_MAX
7362306a36Sopenharmony_ci#define UINT_LEAST16_MAX UINT16_MAX
7462306a36Sopenharmony_ci#define UINT_LEAST32_MAX UINT32_MAX
7562306a36Sopenharmony_ci#define UINT_LEAST64_MAX UINT64_MAX
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci#define SIZE_MAX         ((size_t)(__LONG_MAX__) * 2 + 1)
7862306a36Sopenharmony_ci#define INTPTR_MIN       (-__LONG_MAX__ - 1)
7962306a36Sopenharmony_ci#define INTPTR_MAX       __LONG_MAX__
8062306a36Sopenharmony_ci#define PTRDIFF_MIN      INTPTR_MIN
8162306a36Sopenharmony_ci#define PTRDIFF_MAX      INTPTR_MAX
8262306a36Sopenharmony_ci#define UINTPTR_MAX      SIZE_MAX
8362306a36Sopenharmony_ci
8462306a36Sopenharmony_ci#define  INT_FAST8_MIN   INT8_MIN
8562306a36Sopenharmony_ci#define INT_FAST16_MIN   INTPTR_MIN
8662306a36Sopenharmony_ci#define INT_FAST32_MIN   INTPTR_MIN
8762306a36Sopenharmony_ci#define INT_FAST64_MIN   INT64_MIN
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci#define  INT_FAST8_MAX   INT8_MAX
9062306a36Sopenharmony_ci#define INT_FAST16_MAX   INTPTR_MAX
9162306a36Sopenharmony_ci#define INT_FAST32_MAX   INTPTR_MAX
9262306a36Sopenharmony_ci#define INT_FAST64_MAX   INT64_MAX
9362306a36Sopenharmony_ci
9462306a36Sopenharmony_ci#define  UINT_FAST8_MAX  UINT8_MAX
9562306a36Sopenharmony_ci#define UINT_FAST16_MAX  SIZE_MAX
9662306a36Sopenharmony_ci#define UINT_FAST32_MAX  SIZE_MAX
9762306a36Sopenharmony_ci#define UINT_FAST64_MAX  UINT64_MAX
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#ifndef INT_MIN
10062306a36Sopenharmony_ci#define INT_MIN          (-__INT_MAX__ - 1)
10162306a36Sopenharmony_ci#endif
10262306a36Sopenharmony_ci#ifndef INT_MAX
10362306a36Sopenharmony_ci#define INT_MAX          __INT_MAX__
10462306a36Sopenharmony_ci#endif
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci#ifndef LONG_MIN
10762306a36Sopenharmony_ci#define LONG_MIN         (-__LONG_MAX__ - 1)
10862306a36Sopenharmony_ci#endif
10962306a36Sopenharmony_ci#ifndef LONG_MAX
11062306a36Sopenharmony_ci#define LONG_MAX         __LONG_MAX__
11162306a36Sopenharmony_ci#endif
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci#endif /* _NOLIBC_STDINT_H */
114