1 .\" Copyright (c) 2020 by Alejandro Colomar <colomar.6.4.3@gmail.com>
2 .\" and Copyright (c) 2020 by Michael Kerrisk <mtk.manpages@gmail.com>
4 .\" %%%LICENSE_START(VERBATIM)
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
27 .TH SYSTEM_DATA_TYPES 7 2021-03-22 "Linux" "Linux Programmer's Manual"
29 system_data_types \- overview of system data types
32 .\" A list of type names (the struct/union keyword will be omitted).
33 .\" Each entry will have the following parts:
34 .\" * Include (see NOTES)
36 .\" * Definition (no "Definition" header)
37 .\" Only struct/union types will have definition;
38 .\" typedefs will remain opaque.
40 .\" * Description (no "Description" header)
41 .\" A few lines describing the type.
43 .\" * Versions (optional)
45 .\" * Conforming to (see NOTES)
46 .\" Format: CXY and later; POSIX.1-XXXX and later.
48 .\" * Notes (optional)
53 .\"------------------------------------- aiocb ------------------------/
62 int aio_fildes; /* File descriptor */
63 off_t aio_offset; /* File offset */
64 volatile void *aio_buf; /* Location of buffer */
65 size_t aio_nbytes; /* Length of transfer */
66 int aio_reqprio; /* Request priority offset */
67 struct sigevent aio_sigevent; /* Signal number and value */
68 int aio_lio_opcode;/* Operation to be performed */
72 For further information about this structure, see
76 POSIX.1-2001 and later.
88 .\"------------------------------------- blkcnt_t ---------------------/
97 Used for file block counts.
99 it shall be a signed integer type.
101 .IR "Conforming to" :
102 POSIX.1-2001 and later.
107 .\"------------------------------------- blksize_t --------------------/
116 Used for file block sizes.
118 it shall be a signed integer type.
120 .IR "Conforming to" :
121 POSIX.1-2001 and later.
126 .\"------------------------------------- cc_t -------------------------/
133 Used for terminal special characters.
135 it shall be an unsigned integer type.
137 .IR "Conforming to" :
138 POSIX.1-2001 and later.
143 .\"------------------------------------- clock_t ----------------------/
154 Used for system time in clock ticks or
159 it shall be an integer type or a real-floating type.
161 .IR "Conforming to" :
162 C99 and later; POSIX.1-2001 and later.
168 .\"------------------------------------- clockid_t --------------------/
177 Used for clock ID type in the clock and timer functions.
179 it shall be defined as an arithmetic type.
181 .IR "Conforming to" :
182 POSIX.1-2001 and later.
185 .BR clock_adjtime (2),
186 .BR clock_getres (2),
187 .BR clock_nanosleep (2),
188 .BR timer_create (2),
189 .BR clock_getcpuclockid (3)
191 .\"------------------------------------- dev_t ------------------------/
202 it shall be an integer type.
203 For further details of this type, see
206 .IR "Conforming to" :
207 POSIX.1-2001 and later.
213 .\"------------------------------------- div_t ------------------------/
222 int quot; /* Quotient */
223 int rem; /* Remainder */
227 It is the type of the value returned by the
231 .IR "Conforming to" :
232 C99 and later; POSIX.1-2001 and later.
237 .\"------------------------------------- double_t ---------------------/
244 The implementation's most efficient floating type at least as wide as
246 Its type depends on the value of the macro
267 .BR FLT_EVAL_METHOD ,
270 is implementation-defined.
272 .IR "Conforming to" :
273 C99 and later; POSIX.1-2001 and later.
280 .\"------------------------------------- fd_set -----------------------/
289 A structure type that can represent a set of file descriptors.
291 the maximum number of file descriptors in an
293 structure is the value of the macro
296 .IR "Conforming to" :
297 POSIX.1-2001 and later.
302 .\"------------------------------------- fenv_t -----------------------/
309 This type represents the entire floating-point environment,
310 including control modes and status flags; for further details, see
313 .IR "Conforming to" :
314 C99 and later; POSIX.1-2001 and later.
319 .\"------------------------------------- fexcept_t --------------------/
326 This type represents the floating-point status flags collectively;
327 for further details see
330 .IR "Conforming to" :
331 C99 and later; POSIX.1-2001 and later.
336 .\"------------------------------------- FILE -------------------------/
345 An object type used for streams.
347 .IR "Conforming to" :
348 C99 and later; POSIX.1-2001 and later.
360 .\"------------------------------------- float_t ----------------------/
367 The implementation's most efficient floating type at least as wide as
369 Its type depends on the value of the macro
390 .BR FLT_EVAL_METHOD ,
393 is implementation-defined.
395 .IR "Conforming to" :
396 C99 and later; POSIX.1-2001 and later.
403 .\"------------------------------------- gid_t ------------------------/
419 A type used to hold group IDs.
421 this shall be an integer type.
423 .IR "Conforming to" :
424 POSIX.1-2001 and later.
435 .\"------------------------------------- id_t -------------------------/
442 .IR <sys/resource.h> .
444 A type used to hold a general identifier.
446 this shall be an integer type that can be used to contain a
452 .IR "Conforming to" :
453 POSIX.1-2001 and later.
459 .\"------------------------------------- imaxdiv_t --------------------/
468 intmax_t quot; /* Quotient */
469 intmax_t rem; /* Remainder */
473 It is the type of the value returned by the
477 .IR "Conforming to" :
478 C99 and later; POSIX.1-2001 and later.
483 .\"------------------------------------- intmax_t ---------------------/
492 A signed integer type
493 capable of representing any value of any signed integer type
494 supported by the implementation.
495 According to the C language standard, it shall be
496 capable of storing values in the range
502 .\" TODO: Document INT*_C(3)
503 expands its argument to an integer constant of type
506 The length modifier for
512 families of functions is
514 resulting commonly in
522 .IR "Conforming to" :
523 C99 and later; POSIX.1-2001 and later.
527 is not large enough to represent values of type
529 in implementations where
533 is less than 128 bits wide.
540 .\"------------------------------------- intN_t -----------------------/
554 A signed integer type
555 of a fixed width of exactly N bits,
556 N being the value specified in its type name.
557 According to the C language standard, they shall be
558 capable of storing values in the range
561 substituting N by the appropriate number.
570 is only required in implementations that provide integer types
572 and all other types of this form are optional.
574 The length modifiers for the
579 are expanded by macros of the forms
585 resulting for example in
592 The length modifiers for the
597 are expanded by macros of the forms
603 resulting for example in
611 .IR "Conforming to" :
612 C99 and later; POSIX.1-2001 and later.
622 .\"------------------------------------- intptr_t ---------------------/
631 A signed integer type
634 value can be converted to this type and back.
635 According to the C language standard, it shall be
636 capable of storing values in the range
640 The length modifier for
645 is expanded by the macros
651 resulting commonly in
658 The length modifier for
663 is expanded by the macros
669 resulting commonly in
677 .IR "Conforming to" :
678 C99 and later; POSIX.1-2001 and later.
687 .\"------------------------------------- lconv ------------------------/
695 struct lconv { /* Values in the "C" locale: */
696 char *decimal_point; /* "." */
697 char *thousands_sep; /* "" */
698 char *grouping; /* "" */
699 char *mon_decimal_point; /* "" */
700 char *mon_thousands_sep; /* "" */
701 char *mon_grouping; /* "" */
702 char *positive_sign; /* "" */
703 char *negative_sign; /* "" */
704 char *currency_symbol; /* "" */
705 char frac_digits; /* CHAR_MAX */
706 char p_cs_precedes; /* CHAR_MAX */
707 char n_cs_precedes; /* CHAR_MAX */
708 char p_sep_by_space; /* CHAR_MAX */
709 char n_sep_by_space; /* CHAR_MAX */
710 char p_sign_posn; /* CHAR_MAX */
711 char n_sign_posn; /* CHAR_MAX */
712 char *int_curr_symbol; /* "" */
713 char int_frac_digits; /* CHAR_MAX */
714 char int_p_cs_precedes; /* CHAR_MAX */
715 char int_n_cs_precedes; /* CHAR_MAX */
716 char int_p_sep_by_space; /* CHAR_MAX */
717 char int_n_sep_by_space; /* CHAR_MAX */
718 char int_p_sign_posn; /* CHAR_MAX */
719 char int_n_sign_posn; /* CHAR_MAX */
723 Contains members related to the formatting of numeric values.
724 In the "C" locale, its members have the values
725 shown in the comments above.
727 .IR "Conforming to" :
728 C11 and later; POSIX.1-2001 and later.
736 .\"------------------------------------- ldiv_t -----------------------/
745 long quot; /* Quotient */
746 long rem; /* Remainder */
750 It is the type of the value returned by the
754 .IR "Conforming to" :
755 C99 and later; POSIX.1-2001 and later.
760 .\"------------------------------------- lldiv_t ----------------------/
769 long long quot; /* Quotient */
770 long long rem; /* Remainder */
774 It is the type of the value returned by the
778 .IR "Conforming to" :
779 C99 and later; POSIX.1-2001 and later.
784 .\"------------------------------------- mode_t -----------------------/
799 Used for some file attributes (e.g., file mode).
801 it shall be an integer type.
803 .IR "Conforming to" :
804 POSIX.1-2001 and later.
813 .\"------------------------------------- off64_t ----------------------/
821 It is a 64-bit signed integer type.
823 .IR "Conforming to" :
825 It is not standardized by the C language standard nor POSIX.
828 The feature test macro
829 .B _LARGEFILE64_SOURCE
830 has to be defined for this type to be available.
833 .BR copy_file_range (2),
835 .BR sync_file_range (2),
837 .BR feature_test_macros (7)
845 .\"------------------------------------- off_t ------------------------/
862 this shall be a signed integer type.
872 .IR "Conforming to" :
873 POSIX.1-2001 and later.
876 On some architectures,
877 the width of this type can be controlled with the feature test macro
878 .BR _FILE_OFFSET_BITS .
881 .\" .BR fallocate (2),
885 .BR posix_fadvise (2),
890 .\" .BR getdirentries (3),
892 .BR posix_fallocate (3),
893 .BR feature_test_macros (7)
901 .\"------------------------------------- pid_t ------------------------/
922 This type is used for storing process IDs, process group IDs, and session IDs.
923 According to POSIX, it shall be a signed integer type,
924 and the implementation shall support one or more programming environments
927 is no greater than the width of the type
930 .IR "Conforming to" :
931 POSIX.1-2001 and later.
942 .BR sched_setscheduler (2),
947 .\"------------------------------------- ptrdiff_t --------------------/
954 Used for a count of elements, and array indices.
955 It is the result of subtracting two pointers.
956 According to the C language standard, it shall be a signed integer type
957 capable of storing values in the range
961 The length modifier for
967 families of functions is
969 resulting commonly in
977 .IR "Conforming to" :
978 C99 and later; POSIX.1-2001 and later.
987 .\"------------------------------------- regex_t ----------------------/
996 size_t re_nsub; /* Number of parenthesized subexpressions */
1000 This is a structure type used in regular expression matching.
1001 It holds a compiled regular expression, compiled with
1004 .IR "Conforming to" :
1005 POSIX.1-2001 and later.
1010 .\"------------------------------------- regmatch_t -------------------/
1019 regoff_t rm_so; /* Byte offset from start of string
1020 to start of substring */
1021 regoff_t rm_eo; /* Byte offset from start of string of
1022 the first character after the end of
1027 This is a structure type used in regular expression matching.
1029 .IR "Conforming to" :
1030 POSIX.1-2001 and later.
1035 .\"------------------------------------- regoff_t ---------------------/
1042 According to POSIX, it shall be a signed integer type
1043 capable of storing the largest value that can be stored in either a
1050 Prior to POSIX.1-2008, the type was capable of storing
1051 the largest value that can be stored in either an
1057 .IR "Conforming to" :
1058 POSIX.1-2001 and later.
1069 .\"------------------------------------- sigevent ---------------------/
1083 int sigev_notify; /* Notification type */
1084 int sigev_signo; /* Signal number */
1085 union sigval sigev_value; /* Signal value */
1086 void (*sigev_notify_function)(union sigval);
1087 /* Notification function */
1088 pthread_attr_t *sigev_notify_attributes;
1089 /* Notification attributes */
1093 For further details about this type, see
1104 .IR "Conforming to" :
1105 POSIX.1-2001 and later.
1108 .BR timer_create (2),
1109 .BR getaddrinfo_a (3),
1115 structure in this page.
1117 .\"------------------------------------- siginfo_t --------------------/
1128 int si_signo; /* Signal number */
1129 int si_code; /* Signal code */
1130 pid_t si_pid; /* Sending process ID */
1131 uid_t si_uid; /* Real user ID of sending process */
1132 void *si_addr; /* Address of faulting instruction */
1133 int si_status; /* Exit value or signal */
1134 union sigval si_value; /* Signal value */
1138 Information associated with a signal.
1139 For further details on this structure
1140 (including additional, Linux-specific fields), see
1143 .IR "Conforming to" :
1144 POSIX.1-2001 and later.
1147 .BR pidfd_send_signal (2),
1148 .BR rt_sigqueueinfo (2),
1150 .BR sigwaitinfo (2),
1153 .\"------------------------------------- sigset_t ---------------------/
1162 .IR <sys/select.h> .
1164 This is a type that represents a set of signals.
1165 According to POSIX, this shall be an integer or structure type.
1167 .IR "Conforming to" :
1168 POSIX.1-2001 and later.
1171 .BR epoll_pwait (2),
1177 .BR sigprocmask (2),
1179 .BR sigwaitinfo (2),
1182 .\"------------------------------------- sigval -----------------------/
1191 int sigval_int; /* Integer value */
1192 void *sigval_ptr; /* Pointer value */
1196 Data passed with a signal.
1198 .IR "Conforming to" :
1199 POSIX.1-2001 and later.
1202 .BR pthread_sigqueue (3),
1214 .\"------------------------------------- size_t -----------------------/
1242 .IR <sys/socket.h> ,
1250 Used for a count of bytes. It is the result of the
1253 According to the C language standard,
1254 it shall be an unsigned integer type
1255 capable of storing values in the range [0,
1258 the implementation shall support one or more programming environments
1261 is no greater than the width of the type
1264 The length modifier for
1270 families of functions is
1272 resulting commonly in
1294 .IR "Conforming to" :
1295 C99 and later; POSIX.1-2001 and later.
1313 .\"------------------------------------- sockaddr ---------------------/
1318 .IR <sys/socket.h> .
1322 sa_family_t sa_family; /* Address family */
1323 char sa_data[]; /* Socket address */
1327 Describes a socket address.
1329 .IR "Conforming to" :
1330 POSIX.1-2001 and later.
1334 .BR getpeername (2),
1335 .BR getsockname (2),
1338 .\"------------------------------------- socklen_t --------------------/
1343 .IR <sys/socket.h> .
1347 Describes the length of a socket address.
1349 this shall be an integer type of at least 32 bits.
1351 .IR "Conforming to" :
1352 POSIX.1-2001 and later.
1358 .BR gethostbyaddr (2),
1359 .BR getnameinfo (2),
1364 structure in this page.
1366 .\"------------------------------------- ssize_t ----------------------/
1378 .IR <sys/socket.h> ,
1383 Used for a count of bytes or an error indication.
1384 According to POSIX, it shall be a signed integer type
1385 capable of storing values at least in the range [-1,
1387 and the implementation shall support one or more programming environments
1390 is no greater than the width of the type
1393 Glibc and most other implementations provide a length modifier for
1399 families of functions, which is
1401 resulting commonly in
1412 on most implementations,
1413 portable POSIX programs should avoid using it\(emfor example,
1414 by converting the value to
1416 and using its length modifier
1419 .IR "Conforming to" :
1420 POSIX.1-2001 and later.
1436 .\"------------------------------------- suseconds_t ------------------/
1443 .IR <sys/select.h> ,
1447 Used for time in microseconds.
1448 According to POSIX, it shall be a signed integer type
1449 capable of storing values at least in the range [-1, 1000000],
1450 and the implementation shall support one or more programming environments
1453 is no greater than the width of the type
1456 .IR "Conforming to" :
1457 POSIX.1-2001 and later.
1462 structure in this page.
1464 .\"------------------------------------- time_t -----------------------/
1475 .IR <sys/select.h> ,
1483 Used for time in seconds.
1484 According to POSIX, it shall be an integer type.
1485 .\" In POSIX.1-2001, the type was specified as being either an integer
1486 .\" type or a real-floating type. However, existing implementations
1487 .\" used an integer type, and POSIX.1-2008 tightened the specification
1488 .\" to reflect this.
1496 .IR "Conforming to" :
1497 C99 and later; POSIX.1-2001 and later.
1505 .\"------------------------------------- timer_t ----------------------/
1514 Used for timer ID returned by
1515 .BR timer_create (2).
1517 there are no defined comparison or assignment operators for this type.
1519 .IR "Conforming to" :
1520 POSIX.1-2001 and later.
1523 .BR timer_create (2),
1524 .BR timer_delete (2),
1525 .BR timer_getoverrun (2),
1526 .BR timer_settime (2)
1528 .\"------------------------------------- timespec ---------------------/
1539 .IR <sys/select.h> ,
1545 time_t tv_sec; /* Seconds */
1546 long tv_nsec; /* Nanoseconds */
1550 Describes times in seconds and nanoseconds.
1552 .IR "Conforming to" :
1553 C11 and later; POSIX.1-2001 and later.
1556 .BR clock_gettime (2),
1557 .BR clock_nanosleep (2),
1559 .BR timerfd_gettime (2),
1560 .BR timer_gettime (2)
1562 .\"------------------------------------- timeval ----------------------/
1569 .IR <sys/resource.h> ,
1570 .IR <sys/select.h> ,
1576 time_t tv_sec; /* Seconds */
1577 suseconds_t tv_usec; /* Microseconds */
1581 Describes times in seconds and microseconds.
1583 .IR "Conforming to" :
1584 POSIX.1-2001 and later.
1587 .BR gettimeofday (2),
1594 .\"------------------------------------- uid_t ----------------------/
1609 A type used to hold user IDs.
1611 this shall be an integer type.
1613 .IR "Conforming to" :
1614 POSIX.1-2001 and later.
1624 .\"------------------------------------- uintmax_t --------------------/
1633 An unsigned integer type
1634 capable of representing any value of any unsigned integer type
1635 supported by the implementation.
1636 According to the C language standard, it shall be
1637 capable of storing values in the range [0,
1642 .\" TODO: Document UINT*_C(3)
1643 expands its argument to an integer constant of type
1646 The length modifier for
1652 families of functions is
1654 resulting commonly in
1662 .IR "Conforming to" :
1663 C99 and later; POSIX.1-2001 and later.
1667 is not large enough to represent values of type
1668 .I unsigned __int128
1669 in implementations where
1670 .I unsigned __int128
1672 .I unsigned long long
1673 is less than 128 bits wide.
1680 .\"------------------------------------- uintN_t ----------------------/
1694 An unsigned integer type
1695 of a fixed width of exactly N bits,
1696 N being the value specified in its type name.
1697 According to the C language standard, they shall be
1698 capable of storing values in the range [0,
1700 substituting N by the appropriate number.
1709 is only required in implementations that provide integer types
1711 and all other types of this form are optional.
1713 The length modifiers for the
1718 are expanded by macros of the forms
1726 resulting for example in
1733 The length modifiers for the
1738 are expanded by macros of the forms
1746 resulting for example in
1754 .IR "Conforming to" :
1755 C99 and later; POSIX.1-2001 and later.
1765 .\"------------------------------------- uintptr_t --------------------/
1774 An unsigned integer type
1777 value can be converted to this type and back.
1778 According to the C language standard, it shall be
1779 capable of storing values in the range [0,
1782 The length modifier for
1787 is expanded by the macros
1795 resulting commonly in
1802 The length modifier for
1807 is expanded by the macros
1815 resulting commonly in
1823 .IR "Conforming to" :
1824 C99 and later; POSIX.1-2001 and later.
1833 .\"------------------------------------- va_list ----------------------/
1844 Used by functions with a varying number of arguments of varying types.
1845 The function must declare an object of type
1847 which is used by the macros
1853 to traverse the list of arguments.
1855 .IR "Conforming to" :
1856 C99 and later; POSIX.1-2001 and later.
1864 .\"------------------------------------- void * -----------------------/
1868 According to the C language standard,
1869 a pointer to any object type may be converted to a pointer to
1872 POSIX further requires that any pointer,
1873 including pointers to functions,
1874 may be converted to a pointer to
1878 Conversions from and to any other pointer type are done implicitly,
1879 not requiring casts at all.
1880 Note that this feature prevents any kind of type checking:
1881 the programmer should be careful not to convert a
1883 value to a type incompatible to that of the underlying data,
1884 because that would result in undefined behavior.
1886 This type is useful in function parameters and return value
1887 to allow passing values of any type.
1888 The function will typically use some mechanism to know
1889 the real type of the data being passed via a pointer to
1892 A value of this type can't be dereferenced,
1893 as it would give a value of type
1895 which is not possible.
1896 Likewise, pointer arithmetic is not possible with this type.
1897 However, in GNU C, pointer arithmetic is allowed
1898 as an extension to the standard;
1899 this is done by treating the size of a
1901 or of a function as 1.
1902 A consequence of this is that
1906 and on function types, and returns 1.
1908 The conversion specifier for
1914 families of functions is
1918 The POSIX requirement about compatibility between
1920 and function pointers was added in
1921 POSIX.1-2008 Technical Corrigendum 1 (2013).
1923 .IR "Conforming to" :
1924 C99 and later; POSIX.1-2001 and later.
1938 .\"--------------------------------------------------------------------/
1940 The structures described in this manual page shall contain,
1941 at least, the members shown in their definition, in no particular order.
1943 Most of the integer types described in this page don't have
1944 a corresponding length modifier for the
1948 families of functions.
1949 To print a value of an integer type that doesn't have a length modifier,
1950 it should be converted to
1954 by an explicit cast.
1955 To scan into a variable of an integer type
1956 that doesn't have a length modifier,
1957 an intermediate temporary variable of type
1962 When copying from the temporary variable to the destination variable,
1963 the value could overflow.
1964 If the type has upper and lower limits,
1965 the user should check that the value is within those limits,
1966 before actually copying the value.
1967 The example below shows how these conversions should be done.
1968 .SS Conventions used in this page
1969 In "Conforming to" we only concern ourselves with
1970 C99 and later and POSIX.1-2001 and later.
1971 Some types may be specified in earlier versions of one of these standards,
1972 but in the interests of simplicity we omit details from earlier standards.
1974 In "Include", we first note the "primary" header(s) that
1975 define the type according to either the C or POSIX.1 standards.
1976 Under "Alternatively", we note additional headers that
1977 the standards specify shall define the type.
1979 The program shown below scans from a string and prints a value stored in
1980 a variable of an integer type that doesn't have a length modifier.
1981 The appropriate conversions from and to
1983 and the appropriate range checks,
1984 are used as explained in the notes section above.
1990 #include <sys/types.h>
1995 static const char *const str = "500000 us in half a second";
1999 /* Scan the number from the string into the temporary variable. */
2001 sscanf(str, "%jd", &tmp);
2003 /* Check that the value is within the valid range of suseconds_t. */
2005 if (tmp < \-1 || tmp > 1000000) {
2006 fprintf(stderr, "Scanned value outside valid range!\en");
2010 /* Copy the value to the suseconds_t variable \(aqus\(aq. */
2014 /* Even though suseconds_t can hold the value \-1, this isn\(aqt
2015 a sensible number of microseconds. */
2018 fprintf(stderr, "Scanned value shouldn\(aqt be negative!\en");
2022 /* Print the value. */
2024 printf("There are %jd microseconds in half a second.\en",
2031 .BR feature_test_macros (7),