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.
1251 It is the result of the
1254 According to the C language standard,
1255 it shall be an unsigned integer type
1256 capable of storing values in the range [0,
1259 the implementation shall support one or more programming environments
1262 is no greater than the width of the type
1265 The length modifier for
1271 families of functions is
1273 resulting commonly in
1295 .IR "Conforming to" :
1296 C99 and later; POSIX.1-2001 and later.
1314 .\"------------------------------------- sockaddr ---------------------/
1319 .IR <sys/socket.h> .
1323 sa_family_t sa_family; /* Address family */
1324 char sa_data[]; /* Socket address */
1328 Describes a socket address.
1330 .IR "Conforming to" :
1331 POSIX.1-2001 and later.
1335 .BR getpeername (2),
1336 .BR getsockname (2),
1339 .\"------------------------------------- socklen_t --------------------/
1344 .IR <sys/socket.h> .
1348 Describes the length of a socket address.
1350 this shall be an integer type of at least 32 bits.
1352 .IR "Conforming to" :
1353 POSIX.1-2001 and later.
1359 .BR gethostbyaddr (2),
1360 .BR getnameinfo (2),
1365 structure in this page.
1367 .\"------------------------------------- ssize_t ----------------------/
1379 .IR <sys/socket.h> ,
1384 Used for a count of bytes or an error indication.
1385 According to POSIX, it shall be a signed integer type
1386 capable of storing values at least in the range [-1,
1388 and the implementation shall support one or more programming environments
1391 is no greater than the width of the type
1394 Glibc and most other implementations provide a length modifier for
1400 families of functions, which is
1402 resulting commonly in
1413 on most implementations,
1414 portable POSIX programs should avoid using it\(emfor example,
1415 by converting the value to
1417 and using its length modifier
1420 .IR "Conforming to" :
1421 POSIX.1-2001 and later.
1437 .\"------------------------------------- suseconds_t ------------------/
1444 .IR <sys/select.h> ,
1448 Used for time in microseconds.
1449 According to POSIX, it shall be a signed integer type
1450 capable of storing values at least in the range [-1, 1000000],
1451 and the implementation shall support one or more programming environments
1454 is no greater than the width of the type
1457 .IR "Conforming to" :
1458 POSIX.1-2001 and later.
1463 structure in this page.
1465 .\"------------------------------------- time_t -----------------------/
1476 .IR <sys/select.h> ,
1484 Used for time in seconds.
1485 According to POSIX, it shall be an integer type.
1486 .\" In POSIX.1-2001, the type was specified as being either an integer
1487 .\" type or a real-floating type. However, existing implementations
1488 .\" used an integer type, and POSIX.1-2008 tightened the specification
1489 .\" to reflect this.
1497 .IR "Conforming to" :
1498 C99 and later; POSIX.1-2001 and later.
1506 .\"------------------------------------- timer_t ----------------------/
1515 Used for timer ID returned by
1516 .BR timer_create (2).
1518 there are no defined comparison or assignment operators for this type.
1520 .IR "Conforming to" :
1521 POSIX.1-2001 and later.
1524 .BR timer_create (2),
1525 .BR timer_delete (2),
1526 .BR timer_getoverrun (2),
1527 .BR timer_settime (2)
1529 .\"------------------------------------- timespec ---------------------/
1540 .IR <sys/select.h> ,
1546 time_t tv_sec; /* Seconds */
1547 long tv_nsec; /* Nanoseconds */
1551 Describes times in seconds and nanoseconds.
1553 .IR "Conforming to" :
1554 C11 and later; POSIX.1-2001 and later.
1557 .BR clock_gettime (2),
1558 .BR clock_nanosleep (2),
1560 .BR timerfd_gettime (2),
1561 .BR timer_gettime (2)
1563 .\"------------------------------------- timeval ----------------------/
1570 .IR <sys/resource.h> ,
1571 .IR <sys/select.h> ,
1577 time_t tv_sec; /* Seconds */
1578 suseconds_t tv_usec; /* Microseconds */
1582 Describes times in seconds and microseconds.
1584 .IR "Conforming to" :
1585 POSIX.1-2001 and later.
1588 .BR gettimeofday (2),
1595 .\"------------------------------------- uid_t ----------------------/
1610 A type used to hold user IDs.
1612 this shall be an integer type.
1614 .IR "Conforming to" :
1615 POSIX.1-2001 and later.
1625 .\"------------------------------------- uintmax_t --------------------/
1634 An unsigned integer type
1635 capable of representing any value of any unsigned integer type
1636 supported by the implementation.
1637 According to the C language standard, it shall be
1638 capable of storing values in the range [0,
1643 .\" TODO: Document UINT*_C(3)
1644 expands its argument to an integer constant of type
1647 The length modifier for
1653 families of functions is
1655 resulting commonly in
1663 .IR "Conforming to" :
1664 C99 and later; POSIX.1-2001 and later.
1668 is not large enough to represent values of type
1669 .I unsigned __int128
1670 in implementations where
1671 .I unsigned __int128
1673 .I unsigned long long
1674 is less than 128 bits wide.
1681 .\"------------------------------------- uintN_t ----------------------/
1695 An unsigned integer type
1696 of a fixed width of exactly N bits,
1697 N being the value specified in its type name.
1698 According to the C language standard, they shall be
1699 capable of storing values in the range [0,
1701 substituting N by the appropriate number.
1710 is only required in implementations that provide integer types
1712 and all other types of this form are optional.
1714 The length modifiers for the
1719 are expanded by macros of the forms
1727 resulting for example in
1734 The length modifiers for the
1739 are expanded by macros of the forms
1747 resulting for example in
1755 .IR "Conforming to" :
1756 C99 and later; POSIX.1-2001 and later.
1766 .\"------------------------------------- uintptr_t --------------------/
1775 An unsigned integer type
1778 value can be converted to this type and back.
1779 According to the C language standard, it shall be
1780 capable of storing values in the range [0,
1783 The length modifier for
1788 is expanded by the macros
1796 resulting commonly in
1803 The length modifier for
1808 is expanded by the macros
1816 resulting commonly in
1824 .IR "Conforming to" :
1825 C99 and later; POSIX.1-2001 and later.
1834 .\"------------------------------------- va_list ----------------------/
1845 Used by functions with a varying number of arguments of varying types.
1846 The function must declare an object of type
1848 which is used by the macros
1854 to traverse the list of arguments.
1856 .IR "Conforming to" :
1857 C99 and later; POSIX.1-2001 and later.
1865 .\"------------------------------------- void * -----------------------/
1869 According to the C language standard,
1870 a pointer to any object type may be converted to a pointer to
1873 POSIX further requires that any pointer,
1874 including pointers to functions,
1875 may be converted to a pointer to
1879 Conversions from and to any other pointer type are done implicitly,
1880 not requiring casts at all.
1881 Note that this feature prevents any kind of type checking:
1882 the programmer should be careful not to convert a
1884 value to a type incompatible to that of the underlying data,
1885 because that would result in undefined behavior.
1887 This type is useful in function parameters and return value
1888 to allow passing values of any type.
1889 The function will typically use some mechanism to know
1890 the real type of the data being passed via a pointer to
1893 A value of this type can't be dereferenced,
1894 as it would give a value of type
1896 which is not possible.
1897 Likewise, pointer arithmetic is not possible with this type.
1898 However, in GNU C, pointer arithmetic is allowed
1899 as an extension to the standard;
1900 this is done by treating the size of a
1902 or of a function as 1.
1903 A consequence of this is that
1907 and on function types, and returns 1.
1909 The conversion specifier for
1915 families of functions is
1919 The POSIX requirement about compatibility between
1921 and function pointers was added in
1922 POSIX.1-2008 Technical Corrigendum 1 (2013).
1924 .IR "Conforming to" :
1925 C99 and later; POSIX.1-2001 and later.
1939 .\"--------------------------------------------------------------------/
1941 The structures described in this manual page shall contain,
1942 at least, the members shown in their definition, in no particular order.
1944 Most of the integer types described in this page don't have
1945 a corresponding length modifier for the
1949 families of functions.
1950 To print a value of an integer type that doesn't have a length modifier,
1951 it should be converted to
1955 by an explicit cast.
1956 To scan into a variable of an integer type
1957 that doesn't have a length modifier,
1958 an intermediate temporary variable of type
1963 When copying from the temporary variable to the destination variable,
1964 the value could overflow.
1965 If the type has upper and lower limits,
1966 the user should check that the value is within those limits,
1967 before actually copying the value.
1968 The example below shows how these conversions should be done.
1969 .SS Conventions used in this page
1970 In "Conforming to" we only concern ourselves with
1971 C99 and later and POSIX.1-2001 and later.
1972 Some types may be specified in earlier versions of one of these standards,
1973 but in the interests of simplicity we omit details from earlier standards.
1975 In "Include", we first note the "primary" header(s) that
1976 define the type according to either the C or POSIX.1 standards.
1977 Under "Alternatively", we note additional headers that
1978 the standards specify shall define the type.
1980 The program shown below scans from a string and prints a value stored in
1981 a variable of an integer type that doesn't have a length modifier.
1982 The appropriate conversions from and to
1984 and the appropriate range checks,
1985 are used as explained in the notes section above.
1991 #include <sys/types.h>
1996 static const char *const str = "500000 us in half a second";
2000 /* Scan the number from the string into the temporary variable. */
2002 sscanf(str, "%jd", &tmp);
2004 /* Check that the value is within the valid range of suseconds_t. */
2006 if (tmp < \-1 || tmp > 1000000) {
2007 fprintf(stderr, "Scanned value outside valid range!\en");
2011 /* Copy the value to the suseconds_t variable \(aqus\(aq. */
2015 /* Even though suseconds_t can hold the value \-1, this isn\(aqt
2016 a sensible number of microseconds. */
2019 fprintf(stderr, "Scanned value shouldn\(aqt be negative!\en");
2023 /* Print the value. */
2025 printf("There are %jd microseconds in half a second.\en",
2032 .BR feature_test_macros (7),