summaryrefslogtreecommitdiff
path: root/tools/include/nolibc/stdint.h
blob: cd79ddd6170e05b19945e66151bcbcf840028d32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* SPDX-License-Identifier: LGPL-2.1 OR MIT */
/*
 * Standard definitions and types for NOLIBC
 * Copyright (C) 2023 Vincent Dagonneau <v@vda.io>
 */

#ifndef _NOLIBC_STDINT_H
#define _NOLIBC_STDINT_H

typedef unsigned char       uint8_t;
typedef   signed char        int8_t;
typedef unsigned short     uint16_t;
typedef   signed short      int16_t;
typedef unsigned int       uint32_t;
typedef   signed int        int32_t;
typedef unsigned long long uint64_t;
typedef   signed long long  int64_t;
typedef __SIZE_TYPE__        size_t;
typedef   signed long       ssize_t;
typedef unsigned long     uintptr_t;
typedef   signed long      intptr_t;
typedef   signed long     ptrdiff_t;

typedef   int8_t       int_least8_t;
typedef  uint8_t      uint_least8_t;
typedef  int16_t      int_least16_t;
typedef uint16_t     uint_least16_t;
typedef  int32_t      int_least32_t;
typedef uint32_t     uint_least32_t;
typedef  int64_t      int_least64_t;
typedef uint64_t     uint_least64_t;

typedef   int8_t        int_fast8_t;
typedef  uint8_t       uint_fast8_t;
typedef  ssize_t       int_fast16_t;
typedef   size_t      uint_fast16_t;
typedef  ssize_t       int_fast32_t;
typedef   size_t      uint_fast32_t;
typedef  int64_t       int_fast64_t;
typedef uint64_t      uint_fast64_t;

typedef  int64_t           intmax_t;
typedef uint64_t          uintmax_t;

/* limits of integral types */

#define        INT8_MIN  (-128)
#define       INT16_MIN  (-32767-1)
#define       INT32_MIN  (-2147483647-1)
#define       INT64_MIN  (-9223372036854775807LL-1)

#define        INT8_MAX  (127)
#define       INT16_MAX  (32767)
#define       INT32_MAX  (2147483647)
#define       INT64_MAX  (9223372036854775807LL)

#define       UINT8_MAX  (255)
#define      UINT16_MAX  (65535)
#define      UINT32_MAX  (4294967295U)
#define      UINT64_MAX  (18446744073709551615ULL)

#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_LEAST8_MAX  INT8_MAX
#define INT_LEAST16_MAX  INT16_MAX
#define INT_LEAST32_MAX  INT32_MAX
#define INT_LEAST64_MAX  INT64_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 SIZE_MAX         ((size_t)(__LONG_MAX__) * 2 + 1)
#define INTPTR_MIN       (-__LONG_MAX__ - 1)
#define INTPTR_MAX       __LONG_MAX__
#define PTRDIFF_MIN      INTPTR_MIN
#define PTRDIFF_MAX      INTPTR_MAX
#define UINTPTR_MAX      SIZE_MAX

#define  INT_FAST8_MIN   INT8_MIN
#define INT_FAST16_MIN   INTPTR_MIN
#define INT_FAST32_MIN   INTPTR_MIN
#define INT_FAST64_MIN   INT64_MIN

#define  INT_FAST8_MAX   INT8_MAX
#define INT_FAST16_MAX   INTPTR_MAX
#define INT_FAST32_MAX   INTPTR_MAX
#define INT_FAST64_MAX   INT64_MAX

#define  UINT_FAST8_MAX  UINT8_MAX
#define UINT_FAST16_MAX  SIZE_MAX
#define UINT_FAST32_MAX  SIZE_MAX
#define UINT_FAST64_MAX  UINT64_MAX

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

#ifndef INT_MIN
#define INT_MIN          (-__INT_MAX__ - 1)
#endif
#ifndef INT_MAX
#define INT_MAX          __INT_MAX__
#endif

#ifndef LONG_MIN
#define LONG_MIN         (-__LONG_MAX__ - 1)
#endif
#ifndef LONG_MAX
#define LONG_MAX         __LONG_MAX__
#endif

#ifndef ULONG_MAX
#define ULONG_MAX         ((unsigned long)(__LONG_MAX__) * 2 + 1)
#endif

#ifndef LLONG_MIN
#define LLONG_MIN         (-__LONG_LONG_MAX__ - 1)
#endif
#ifndef LLONG_MAX
#define LLONG_MAX         __LONG_LONG_MAX__
#endif

#ifndef ULLONG_MAX
#define ULLONG_MAX         ((unsigned long long)(__LONG_LONG_MAX__) * 2 + 1)
#endif

#endif /* _NOLIBC_STDINT_H */