sys_types.h(7POSIX)

🌸 sys_types.h β€” POSIX Programmer's Manual, sys_types.h(7POSIX) πŸŽ€

okay bestie, buckle up, we're doing header files today and honestly? this one is the blueprint. it's giving "types, types, and more types" and I am obsessed. πŸ’…


✨ PROLOG ✨

real talk first, because this matters: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β€” so like, consult the corresponding Linux manual page for the details on Linux behavior, fr fr. or, worstie scenario, the interface may not be implemented on Linux at all. πŸ’€


πŸ’– NAME πŸ’–

sys/types.h β€” data types. that's it. that's the whole vibe. it's the header that defines your types.


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <sys/types.h>

one line. iconic. no notes. ✨


πŸ‘‘ DESCRIPTION πŸ‘‘

so the <sys/types.h> header shall define at least the following types, and no, we are not skipping any of them, every single one is getting its moment:

  • blkcnt_t β€” used for file block counts.
  • blksize_t β€” used for block sizes.
  • clock_t β€” used for system times in clock ticks or CLOCKS_PER_SEC; peep <time.h> for more.
  • clockid_t β€” used for the clock ID type in the clock and timer functions.
  • dev_t β€” used for device IDs.
  • fsblkcnt_t β€” used for file system block counts.
  • fsfilcnt_t β€” used for file system file counts.
  • gid_t β€” used for group IDs.
  • id_t β€” used as a general identifier; can hold at least a pid_t, uid_t, or gid_t.
  • ino_t β€” used for file serial numbers.
  • key_t β€” used for XSI interprocess communication.
  • mode_t β€” used for some file attributes.
  • nlink_t β€” used for link counts.
  • off_t β€” used for file sizes.
  • pid_t β€” used for process IDs and process group IDs.
  • pthread_attr_t β€” used to identify a thread attribute object.
  • pthread_barrier_t β€” used to identify a barrier.
  • pthread_barrierattr_t β€” used to define a barrier attributes object.
  • pthread_cond_t β€” used for condition variables.
  • pthread_condattr_t β€” used to identify a condition attribute object.
  • pthread_key_t β€” used for thread-specific data keys.
  • pthread_mutex_t β€” used for mutexes.
  • pthread_mutexattr_t β€” used to identify a mutex attribute object.
  • pthread_once_t β€” used for dynamic package initialization.
  • pthread_rwlock_t β€” used for read-write locks.
  • pthread_rwlockattr_t β€” used for read-write lock attributes.
  • pthread_spinlock_t β€” used to identify a spin lock.
  • pthread_t β€” used to identify a thread.
  • size_t β€” used for sizes of objects.
  • ssize_t β€” used for a count of bytes or an error indication.
  • suseconds_t β€” used for time in microseconds.
  • time_t β€” used for time in seconds.
  • timer_t β€” used for the timer ID returned by timer_create().
  • trace_attr_t β€” used to identify a trace stream attributes object
  • trace_event_id_t β€” used to identify a trace event type.
  • trace_event_set_t β€” used to identify a trace event type set.
  • trace_id_t β€” used to identify a trace stream.
  • uid_t β€” used for user IDs.

🧚 the arithmetic-type rule (aka the plot twist)

all of the types shall be defined as arithmetic types of an appropriate length, with the following exceptions, and bestie these exceptions are a whole list:

pthread_attr_t
pthread_barrier_t
pthread_barrierattr_t
pthread_cond_t
pthread_condattr_t
pthread_key_t
pthread_mutex_t
pthread_mutexattr_t
pthread_once_t
pthread_rwlock_t
pthread_rwlockattr_t
pthread_spinlock_t
pthread_t
timer_t
trace_attr_t
trace_event_id_t
trace_event_set_t
trace_id_t

✨ additionally ✨

  • mode_t shall be an integer type.
  • dev_t shall be an integer type.
  • nlink_t, uid_t, gid_t, and id_t shall be integer types.
  • blkcnt_t and off_t shall be signed integer types.
  • fsblkcnt_t, fsfilcnt_t, and ino_t shall be defined as unsigned integer types.
  • size_t shall be an unsigned integer type.
  • blksize_t, pid_t, and ssize_t shall be signed integer types.
  • clock_t shall be an integer or real-floating type. time_t shall be an integer type.

🌈 the range receipts

the type ssize_t shall be capable of storing values at least in the range [-1, {SSIZE_MAX}]. yes, negative one included, because error indications gotta live somewhere. 😌

the type suseconds_t shall be a signed integer type capable of storing values at least in the range [-1, 1000000].

🫢 programming environments

the implementation shall support one or more programming environments in which the widths of blksize_t, pid_t, size_t, ssize_t, and suseconds_t are no greater than the width of type long. wanna know the names of these programming environments? you can get them using the confstr() function or the getconf utility. slay. πŸ’…

πŸ’€ no operators, sorry

there are no defined comparison or assignment operators for the following types. so like, don't try it. seriously:

pthread_attr_t
pthread_barrier_t
pthread_barrierattr_t
pthread_cond_t
pthread_condattr_t
pthread_mutex_t
pthread_mutexattr_t
pthread_rwlock_t
pthread_rwlockattr_t
pthread_spinlock_t
timer_t
trace_attr_t
also, heads up: the following sections are informative. πŸ“’

πŸŽ€ APPLICATION USAGE πŸŽ€

None.

that's right. nothing. empty. the silence is the statement. πŸ™ˆ


🌸 RATIONALE 🌸

None.

again. nothing. iconic behavior honestly. ✨


πŸ¦‹ FUTURE DIRECTIONS πŸ¦‹

None.

three for three. no cap. πŸ’œ


⭐ SEE ALSO ⭐

  • <time.h>
  • The System Interfaces volume of POSIX.1‐2017, confstr()
  • The Shell and Utilities volume of POSIX.1‐2017, getconf

okay legal bestie moment, gotta be precise here:

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .

Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .


and that's the whole page, bestie!! 🫢 this absolute classic was brought to you by IEEE/The Open Group, dated 2017, and it lives at sys_types.h(7POSIX). go forth and typedef responsibly. πŸ’…βœ¨