1/* bits/types.h -- definitions of __*_t types underlying *_t types.
2 Copyright (C) 2002-2020 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <https://www.gnu.org/licenses/>. */
18
19/*
20 * Never include this file directly; use <sys/types.h> instead.
21 */
22
23#ifndef _BITS_TYPES_H
24#define _BITS_TYPES_H 1
25
26#include <features.h>
27#include <bits/wordsize.h>
28#include <bits/timesize.h>
29
30/* Convenience types. */
31typedef unsigned char __u_char;
32typedef unsigned short int __u_short;
33typedef unsigned int __u_int;
34typedef unsigned long int __u_long;
35
36/* Fixed-size types, underlying types depend on word size and compiler. */
37typedef signed char __int8_t;
38typedef unsigned char __uint8_t;
39typedef signed short int __int16_t;
40typedef unsigned short int __uint16_t;
41typedef signed int __int32_t;
42typedef unsigned int __uint32_t;
43#if __WORDSIZE == 64
44typedef signed long int __int64_t;
45typedef unsigned long int __uint64_t;
46#else
47__extension__ typedef signed long long int __int64_t;
48__extension__ typedef unsigned long long int __uint64_t;
49#endif
50
51/* Smallest types with at least a given width. */
52typedef __int8_t __int_least8_t;
53typedef __uint8_t __uint_least8_t;
54typedef __int16_t __int_least16_t;
55typedef __uint16_t __uint_least16_t;
56typedef __int32_t __int_least32_t;
57typedef __uint32_t __uint_least32_t;
58typedef __int64_t __int_least64_t;
59typedef __uint64_t __uint_least64_t;
60
61/* quad_t is also 64 bits. */
62#if __WORDSIZE == 64
63typedef long int __quad_t;
64typedef unsigned long int __u_quad_t;
65#else
66__extension__ typedef long long int __quad_t;
67__extension__ typedef unsigned long long int __u_quad_t;
68#endif
69
70/* Largest integral types. */
71#if __WORDSIZE == 64
72typedef long int __intmax_t;
73typedef unsigned long int __uintmax_t;
74#else
75__extension__ typedef long long int __intmax_t;
76__extension__ typedef unsigned long long int __uintmax_t;
77#endif
78
79
80/* The machine-dependent file <bits/typesizes.h> defines __*_T_TYPE
81 macros for each of the OS types we define below. The definitions
82 of those macros must use the following macros for underlying types.
83 We define __S<SIZE>_TYPE and __U<SIZE>_TYPE for the signed and unsigned
84 variants of each of the following integer types on this machine.
85
86 16 -- "natural" 16-bit type (always short)
87 32 -- "natural" 32-bit type (always int)
88 64 -- "natural" 64-bit type (long or long long)
89 LONG32 -- 32-bit type, traditionally long
90 QUAD -- 64-bit type, traditionally long long
91 WORD -- natural type of __WORDSIZE bits (int or long)
92 LONGWORD -- type of __WORDSIZE bits, traditionally long
93
94 We distinguish WORD/LONGWORD, 32/LONG32, and 64/QUAD so that the
95 conventional uses of `long' or `long long' type modifiers match the
96 types we define, even when a less-adorned type would be the same size.
97 This matters for (somewhat) portably writing printf/scanf formats for
98 these types, where using the appropriate l or ll format modifiers can
99 make the typedefs and the formats match up across all GNU platforms. If
100 we used `long' when it's 64 bits where `long long' is expected, then the
101 compiler would warn about the formats not matching the argument types,
102 and the programmer changing them to shut up the compiler would break the
103 program's portability.
104
105 Here we assume what is presently the case in all the GCC configurations
106 we support: long long is always 64 bits, long is always word/address size,
107 and int is always 32 bits. */
108
109#define __S16_TYPE short int
110#define __U16_TYPE unsigned short int
111#define __S32_TYPE int
112#define __U32_TYPE unsigned int
113#define __SLONGWORD_TYPE long int
114#define __ULONGWORD_TYPE unsigned long int
115#if __WORDSIZE == 32
116# define __SQUAD_TYPE __int64_t
117# define __UQUAD_TYPE __uint64_t
118# define __SWORD_TYPE int
119# define __UWORD_TYPE unsigned int
120# define __SLONG32_TYPE long int
121# define __ULONG32_TYPE unsigned long int
122# define __S64_TYPE __int64_t
123# define __U64_TYPE __uint64_t
124/* We want __extension__ before typedef's that use nonstandard base types
125 such as `long long' in C89 mode. */
126# define __STD_TYPE __extension__ typedef
127#elif __WORDSIZE == 64
128# define __SQUAD_TYPE long int
129# define __UQUAD_TYPE unsigned long int
130# define __SWORD_TYPE long int
131# define __UWORD_TYPE unsigned long int
132# define __SLONG32_TYPE int
133# define __ULONG32_TYPE unsigned int
134# define __S64_TYPE long int
135# define __U64_TYPE unsigned long int
136/* No need to mark the typedef with __extension__. */
137# define __STD_TYPE typedef
138#else
139# error
140#endif
141#include <bits/typesizes.h> /* Defines __*_T_TYPE macros. */
142#include <bits/time64.h> /* Defines __TIME*_T_TYPE macros. */
143
144
145__STD_TYPE __DEV_T_TYPE __dev_t; /* Type of device numbers. */
146__STD_TYPE __UID_T_TYPE __uid_t; /* Type of user identifications. */
147__STD_TYPE __GID_T_TYPE __gid_t; /* Type of group identifications. */
148__STD_TYPE __INO_T_TYPE __ino_t; /* Type of file serial numbers. */
149__STD_TYPE __INO64_T_TYPE __ino64_t; /* Type of file serial numbers (LFS).*/
150__STD_TYPE __MODE_T_TYPE __mode_t; /* Type of file attribute bitmasks. */
151__STD_TYPE __NLINK_T_TYPE __nlink_t; /* Type of file link counts. */
152__STD_TYPE __OFF_T_TYPE __off_t; /* Type of file sizes and offsets. */
153__STD_TYPE __OFF64_T_TYPE __off64_t; /* Type of file sizes and offsets (LFS). */
154__STD_TYPE __PID_T_TYPE __pid_t; /* Type of process identifications. */
155__STD_TYPE __FSID_T_TYPE __fsid_t; /* Type of file system IDs. */
156__STD_TYPE __CLOCK_T_TYPE __clock_t; /* Type of CPU usage counts. */
157__STD_TYPE __RLIM_T_TYPE __rlim_t; /* Type for resource measurement. */
158__STD_TYPE __RLIM64_T_TYPE __rlim64_t; /* Type for resource measurement (LFS). */
159__STD_TYPE __ID_T_TYPE __id_t; /* General type for IDs. */
160__STD_TYPE __TIME_T_TYPE __time_t; /* Seconds since the Epoch. */
161__STD_TYPE __USECONDS_T_TYPE __useconds_t; /* Count of microseconds. */
162__STD_TYPE __SUSECONDS_T_TYPE __suseconds_t; /* Signed count of microseconds. */
163
164__STD_TYPE __DADDR_T_TYPE __daddr_t; /* The type of a disk address. */
165__STD_TYPE __KEY_T_TYPE __key_t; /* Type of an IPC key. */
166
167/* Clock ID used in clock and timer functions. */
168__STD_TYPE __CLOCKID_T_TYPE __clockid_t;
169
170/* Timer ID returned by `timer_create'. */
171__STD_TYPE __TIMER_T_TYPE __timer_t;
172
173/* Type to represent block size. */
174__STD_TYPE __BLKSIZE_T_TYPE __blksize_t;
175
176/* Types from the Large File Support interface. */
177
178/* Type to count number of disk blocks. */
179__STD_TYPE __BLKCNT_T_TYPE __blkcnt_t;
180__STD_TYPE __BLKCNT64_T_TYPE __blkcnt64_t;
181
182/* Type to count file system blocks. */
183__STD_TYPE __FSBLKCNT_T_TYPE __fsblkcnt_t;
184__STD_TYPE __FSBLKCNT64_T_TYPE __fsblkcnt64_t;
185
186/* Type to count file system nodes. */
187__STD_TYPE __FSFILCNT_T_TYPE __fsfilcnt_t;
188__STD_TYPE __FSFILCNT64_T_TYPE __fsfilcnt64_t;
189
190/* Type of miscellaneous file system fields. */
191__STD_TYPE __FSWORD_T_TYPE __fsword_t;
192
193__STD_TYPE __SSIZE_T_TYPE __ssize_t; /* Type of a byte count, or error. */
194
195/* Signed long type used in system calls. */
196__STD_TYPE __SYSCALL_SLONG_TYPE __syscall_slong_t;
197/* Unsigned long type used in system calls. */
198__STD_TYPE __SYSCALL_ULONG_TYPE __syscall_ulong_t;
199
200/* These few don't really vary by system, they always correspond
201 to one of the other defined types. */
202typedef __off64_t __loff_t; /* Type of file sizes and offsets (LFS). */
203typedef char *__caddr_t;
204
205/* Duplicates info from stdint.h but this is used in unistd.h. */
206__STD_TYPE __SWORD_TYPE __intptr_t;
207
208/* Duplicate info from sys/socket.h. */
209__STD_TYPE __U32_TYPE __socklen_t;
210
211/* C99: An integer type that can be accessed as an atomic entity,
212 even in the presence of asynchronous interrupts.
213 It is not currently necessary for this to be machine-specific. */
214typedef int __sig_atomic_t;
215
216/* Seconds since the Epoch, visible to user code when time_t is too
217 narrow only for consistency with the old way of widening too-narrow
218 types. User code should never use __time64_t. */
219#if __TIMESIZE == 64 && defined __LIBC
220# define __time64_t __time_t
221#elif __TIMESIZE != 64
222__STD_TYPE __TIME64_T_TYPE __time64_t;
223#endif
224
225#undef __STD_TYPE
226
227#endif /* bits/types.h */
228