master
  1/* Copyright (C) 1997-2025 Free Software Foundation, Inc.
  2   This file is part of the GNU C Library.
  3
  4   The GNU C Library is free software; you can redistribute it and/or
  5   modify it under the terms of the GNU Lesser General Public
  6   License as published by the Free Software Foundation; either
  7   version 2.1 of the License, or (at your option) any later version.
  8
  9   The GNU C Library is distributed in the hope that it will be useful,
 10   but WITHOUT ANY WARRANTY; without even the implied warranty of
 11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12   Lesser General Public License for more details.
 13
 14   You should have received a copy of the GNU Lesser General Public
 15   License along with the GNU C Library; if not, see
 16   <https://www.gnu.org/licenses/>.  */
 17
 18/*
 19 *	ISO C99: 7.18 Integer types <stdint.h>
 20 */
 21
 22#ifndef _STDINT_H
 23#define _STDINT_H	1
 24
 25#define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
 26#include <bits/libc-header-start.h>
 27#include <bits/types.h>
 28#include <bits/wchar.h>
 29#include <bits/wordsize.h>
 30
 31/* Exact integral types.  */
 32
 33/* Signed.  */
 34#include <bits/stdint-intn.h>
 35
 36/* Unsigned.  */
 37#include <bits/stdint-uintn.h>
 38
 39
 40/* Small types.  */
 41#include <bits/stdint-least.h>
 42
 43
 44/* Fast types.  */
 45
 46/* Signed.  */
 47typedef signed char		int_fast8_t;
 48#if __WORDSIZE == 64
 49typedef long int		int_fast16_t;
 50typedef long int		int_fast32_t;
 51typedef long int		int_fast64_t;
 52#else
 53typedef int			int_fast16_t;
 54typedef int			int_fast32_t;
 55__extension__
 56typedef long long int		int_fast64_t;
 57#endif
 58
 59/* Unsigned.  */
 60typedef unsigned char		uint_fast8_t;
 61#if __WORDSIZE == 64
 62typedef unsigned long int	uint_fast16_t;
 63typedef unsigned long int	uint_fast32_t;
 64typedef unsigned long int	uint_fast64_t;
 65#else
 66typedef unsigned int		uint_fast16_t;
 67typedef unsigned int		uint_fast32_t;
 68__extension__
 69typedef unsigned long long int	uint_fast64_t;
 70#endif
 71
 72
 73/* Types for `void *' pointers.  */
 74#if __WORDSIZE == 64
 75# ifndef __intptr_t_defined
 76typedef long int		intptr_t;
 77#  define __intptr_t_defined
 78# endif
 79typedef unsigned long int	uintptr_t;
 80#else
 81# ifndef __intptr_t_defined
 82typedef int			intptr_t;
 83#  define __intptr_t_defined
 84# endif
 85typedef unsigned int		uintptr_t;
 86#endif
 87
 88
 89/* Largest integral types.  */
 90typedef __intmax_t		intmax_t;
 91typedef __uintmax_t		uintmax_t;
 92
 93
 94# if __WORDSIZE == 64
 95#  define __INT64_C(c)	c ## L
 96#  define __UINT64_C(c)	c ## UL
 97# else
 98#  define __INT64_C(c)	c ## LL
 99#  define __UINT64_C(c)	c ## ULL
100# endif
101
102/* Limits of integral types.  */
103
104/* Minimum of signed integral types.  */
105# define INT8_MIN		(-128)
106# define INT16_MIN		(-32767-1)
107# define INT32_MIN		(-2147483647-1)
108# define INT64_MIN		(-__INT64_C(9223372036854775807)-1)
109/* Maximum of signed integral types.  */
110# define INT8_MAX		(127)
111# define INT16_MAX		(32767)
112# define INT32_MAX		(2147483647)
113# define INT64_MAX		(__INT64_C(9223372036854775807))
114
115/* Maximum of unsigned integral types.  */
116# define UINT8_MAX		(255)
117# define UINT16_MAX		(65535)
118# define UINT32_MAX		(4294967295U)
119# define UINT64_MAX		(__UINT64_C(18446744073709551615))
120
121
122/* Minimum of signed integral types having a minimum size.  */
123# define INT_LEAST8_MIN		(-128)
124# define INT_LEAST16_MIN	(-32767-1)
125# define INT_LEAST32_MIN	(-2147483647-1)
126# define INT_LEAST64_MIN	(-__INT64_C(9223372036854775807)-1)
127/* Maximum of signed integral types having a minimum size.  */
128# define INT_LEAST8_MAX		(127)
129# define INT_LEAST16_MAX	(32767)
130# define INT_LEAST32_MAX	(2147483647)
131# define INT_LEAST64_MAX	(__INT64_C(9223372036854775807))
132
133/* Maximum of unsigned integral types having a minimum size.  */
134# define UINT_LEAST8_MAX	(255)
135# define UINT_LEAST16_MAX	(65535)
136# define UINT_LEAST32_MAX	(4294967295U)
137# define UINT_LEAST64_MAX	(__UINT64_C(18446744073709551615))
138
139
140/* Minimum of fast signed integral types having a minimum size.  */
141# define INT_FAST8_MIN		(-128)
142# if __WORDSIZE == 64
143#  define INT_FAST16_MIN	(-9223372036854775807L-1)
144#  define INT_FAST32_MIN	(-9223372036854775807L-1)
145# else
146#  define INT_FAST16_MIN	(-2147483647-1)
147#  define INT_FAST32_MIN	(-2147483647-1)
148# endif
149# define INT_FAST64_MIN		(-__INT64_C(9223372036854775807)-1)
150/* Maximum of fast signed integral types having a minimum size.  */
151# define INT_FAST8_MAX		(127)
152# if __WORDSIZE == 64
153#  define INT_FAST16_MAX	(9223372036854775807L)
154#  define INT_FAST32_MAX	(9223372036854775807L)
155# else
156#  define INT_FAST16_MAX	(2147483647)
157#  define INT_FAST32_MAX	(2147483647)
158# endif
159# define INT_FAST64_MAX		(__INT64_C(9223372036854775807))
160
161/* Maximum of fast unsigned integral types having a minimum size.  */
162# define UINT_FAST8_MAX		(255)
163# if __WORDSIZE == 64
164#  define UINT_FAST16_MAX	(18446744073709551615UL)
165#  define UINT_FAST32_MAX	(18446744073709551615UL)
166# else
167#  define UINT_FAST16_MAX	(4294967295U)
168#  define UINT_FAST32_MAX	(4294967295U)
169# endif
170# define UINT_FAST64_MAX	(__UINT64_C(18446744073709551615))
171
172
173/* Values to test for integral types holding `void *' pointer.  */
174# if __WORDSIZE == 64
175#  define INTPTR_MIN		(-9223372036854775807L-1)
176#  define INTPTR_MAX		(9223372036854775807L)
177#  define UINTPTR_MAX		(18446744073709551615UL)
178# else
179#  define INTPTR_MIN		(-2147483647-1)
180#  define INTPTR_MAX		(2147483647)
181#  define UINTPTR_MAX		(4294967295U)
182# endif
183
184
185/* Minimum for largest signed integral type.  */
186# define INTMAX_MIN		(-__INT64_C(9223372036854775807)-1)
187/* Maximum for largest signed integral type.  */
188# define INTMAX_MAX		(__INT64_C(9223372036854775807))
189
190/* Maximum for largest unsigned integral type.  */
191# define UINTMAX_MAX		(__UINT64_C(18446744073709551615))
192
193
194/* Limits of other integer types.  */
195
196/* Limits of `ptrdiff_t' type.  */
197# if __WORDSIZE == 64
198#  define PTRDIFF_MIN		(-9223372036854775807L-1)
199#  define PTRDIFF_MAX		(9223372036854775807L)
200# else
201#  if __WORDSIZE32_PTRDIFF_LONG
202#   define PTRDIFF_MIN		(-2147483647L-1)
203#   define PTRDIFF_MAX		(2147483647L)
204#  else
205#   define PTRDIFF_MIN		(-2147483647-1)
206#   define PTRDIFF_MAX		(2147483647)
207#  endif
208# endif
209
210/* Limits of `sig_atomic_t'.  */
211# define SIG_ATOMIC_MIN		(-2147483647-1)
212# define SIG_ATOMIC_MAX		(2147483647)
213
214/* Limit of `size_t' type.  */
215# if __WORDSIZE == 64
216#  define SIZE_MAX		(18446744073709551615UL)
217# else
218#  if __WORDSIZE32_SIZE_ULONG
219#   define SIZE_MAX		(4294967295UL)
220#  else
221#   define SIZE_MAX		(4294967295U)
222#  endif
223# endif
224
225/* Limits of `wchar_t'.  */
226# ifndef WCHAR_MIN
227/* These constants might also be defined in <wchar.h>.  */
228#  define WCHAR_MIN		__WCHAR_MIN
229#  define WCHAR_MAX		__WCHAR_MAX
230# endif
231
232/* Limits of `wint_t'.  */
233# define WINT_MIN		(0u)
234# define WINT_MAX		(4294967295u)
235
236/* Signed.  */
237# define INT8_C(c)	c
238# define INT16_C(c)	c
239# define INT32_C(c)	c
240# if __WORDSIZE == 64
241#  define INT64_C(c)	c ## L
242# else
243#  define INT64_C(c)	c ## LL
244# endif
245
246/* Unsigned.  */
247# define UINT8_C(c)	c
248# define UINT16_C(c)	c
249# define UINT32_C(c)	c ## U
250# if __WORDSIZE == 64
251#  define UINT64_C(c)	c ## UL
252# else
253#  define UINT64_C(c)	c ## ULL
254# endif
255
256/* Maximal type.  */
257# if __WORDSIZE == 64
258#  define INTMAX_C(c)	c ## L
259#  define UINTMAX_C(c)	c ## UL
260# else
261#  define INTMAX_C(c)	c ## LL
262#  define UINTMAX_C(c)	c ## ULL
263# endif
264
265#if __GLIBC_USE (IEC_60559_BFP_EXT_C23)
266
267# define INT8_WIDTH 8
268# define UINT8_WIDTH 8
269# define INT16_WIDTH 16
270# define UINT16_WIDTH 16
271# define INT32_WIDTH 32
272# define UINT32_WIDTH 32
273# define INT64_WIDTH 64
274# define UINT64_WIDTH 64
275
276# define INT_LEAST8_WIDTH 8
277# define UINT_LEAST8_WIDTH 8
278# define INT_LEAST16_WIDTH 16
279# define UINT_LEAST16_WIDTH 16
280# define INT_LEAST32_WIDTH 32
281# define UINT_LEAST32_WIDTH 32
282# define INT_LEAST64_WIDTH 64
283# define UINT_LEAST64_WIDTH 64
284
285# define INT_FAST8_WIDTH 8
286# define UINT_FAST8_WIDTH 8
287# define INT_FAST16_WIDTH __WORDSIZE
288# define UINT_FAST16_WIDTH __WORDSIZE
289# define INT_FAST32_WIDTH __WORDSIZE
290# define UINT_FAST32_WIDTH __WORDSIZE
291# define INT_FAST64_WIDTH 64
292# define UINT_FAST64_WIDTH 64
293
294# define INTPTR_WIDTH __WORDSIZE
295# define UINTPTR_WIDTH __WORDSIZE
296
297# define INTMAX_WIDTH 64
298# define UINTMAX_WIDTH 64
299
300# define PTRDIFF_WIDTH __WORDSIZE
301# define SIG_ATOMIC_WIDTH 32
302# define SIZE_WIDTH __WORDSIZE
303# define WCHAR_WIDTH 32
304# define WINT_WIDTH 32
305
306#endif
307
308#endif /* stdint.h */