History log of /freebsd-current/sys/sys/_types.h
Revision Date Author Comments
# 55513a1b 18-Mar-2024 Brooks Davis <brooks@FreeBSD.org>

sys/acl.h: move main typedefs to sys/_types.h

Make __ prefixed versions available without the pollution of sys/acl.h
(and by extension sys/param.h).

Reviewed by: kib
Differential Revision: https://reviews.freebsd.org/D44382


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# b8717a87 12-Apr-2022 John Baldwin <jhb@FreeBSD.org>

Remove checks for __GNUCLIKE macros for varargs.

All supported compilers (modern versions of GCC and clang) support
these.

PR: 263102 (exp-run)
Reviewed by: brooks, imp
Differential Revision: https://reviews.freebsd.org/D34800


# 959af5a8 15-Dec-2021 Kristof Provost <kp@FreeBSD.org>

sys: make callout.h self-contained

Avoid including sys/types.h from sys/_callout.h (as we try to avoid having
headers starting with underscores depending on non-underscore headers)
by introducing __sbintime_t in sys/_types.h and including that header
instead.

Reviewed by: imp
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D33500


# 9bb8a409 14-Jun-2021 Alex Richardson <arichardson@FreeBSD.org>

Reduce code duplication in machine/_types.h

Many of these typedefs are the same across all architectures or can
be set based on an architecture-independent compiler-provided macro
(e.g. __SIZEOF_SIZE_T__). These macros have been available since GCC 4.6
and Clang sometime before 3.0 (godbolt.org does not have any older clang
versions installed).

I originally considered using the compiler-provided `__FOO_TYPE__` directly.
However, in order to do so we have to check that those match the previous
typedef exactly (not just that they have the same size) since any change
would be an ABI break. For example, changing `long` to `long long` results
in different C++ name mangling. Additionally, Clang and GCC disagree on
the underlying type for some of (u)int*_fast_t types, so this change
only moves the definitions that are identical across all architectures
and does not touch those types.

This de-deduplication will allow us to have a smaller diff downstream in
CheriBSD: we only have to only change the (u)intptr_t definition in
sys/_types.h in CheriBSD instead of having to change machine/_types.h for
all CHERI-enabled architectures (currently RISC-V, AArch64 and MIPS).

Reviewed By: imp, kib
Differential Revision: https://reviews.freebsd.org/D29895


# 1bb95729 21-Jun-2019 Alan Somers <asomers@FreeBSD.org>

Reduce namespace pollution from r349233

Define __daddr_t in _types.h and use it in filio.h

Reported by: ian, bde
Reviewed by: ian, imp, cem
MFC after: 2 weeks
MFC-With: 349233
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D20715


# ef1fcaf0 22-Feb-2018 Warner Losh <imp@FreeBSD.org>

Do not include float interfaces when using libsa.

We don't support float in the boot loaders, so don't include
interfaces for float or double in systems headers. In addition, take
the unusual step of spiking double and float to prevent any more
accidental seepage.


# 62bca778 12-Feb-2018 Warner Losh <imp@FreeBSD.org>

Move __va_list and related defines to sys/sys/_types.h

__va_list and related defines are identical in all the
ARCH/include/_types.h files. Move them to sys/sys/_types.h

Sponsored by: Netflix


# c4e20cad 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/sys: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# b47efe07 26-May-2017 Dimitry Andric <dim@FreeBSD.org>

Define a new __INO64 macro in <sys/_types.h>, to indicate the system
uses 64-bit inode numbers. Programs can use this to avoid including
<sys/param.h>, with its associated namespace pollution.

Reviewed by: kib


# 69921123 23-May-2017 Konstantin Belousov <kib@FreeBSD.org>

Commit the 64-bit inode project.

Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify
struct dirent layout to add d_off, increase the size of d_fileno
to 64-bits, increase the size of d_namlen to 16-bits, and change
the required alignment. Increase struct statfs f_mntfromname[] and
f_mntonname[] array length MNAMELEN to 1024.

ABI breakage is mitigated by providing compatibility using versioned
symbols, ingenious use of the existing padding in structures, and
by employing other tricks. Unfortunately, not everything can be
fixed, especially outside the base system. For instance, third-party
APIs which pass struct stat around are broken in backward and
forward incompatible ways.

Kinfo sysctl MIBs ABI is changed in backward-compatible way, but
there is no general mechanism to handle other sysctl MIBS which
return structures where the layout has changed. It was considered
that the breakage is either in the management interfaces, where we
usually allow ABI slip, or is not important.

Struct xvnode changed layout, no compat shims are provided.

For struct xtty, dev_t tty device member was reduced to uint32_t.
It was decided that keeping ABI compat in this case is more useful
than reporting 64-bit dev_t, for the sake of pstat.

Update note: strictly follow the instructions in UPDATING. Build
and install the new kernel with COMPAT_FREEBSD11 option enabled,
then reboot, and only then install new world.

Credits: The 64-bit inode project, also known as ino64, started life
many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick
(mckusick) then picked up and updated the patch, and acted as a
flag-waver. Feedback, suggestions, and discussions were carried
by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles),
and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial
ports investigation followed by an exp-run by Antoine Brodin (antoine).
Essential and all-embracing testing was done by Peter Holm (pho).
The heavy lifting of coordinating all these efforts and bringing the
project to completion were done by Konstantin Belousov (kib).

Sponsored by: The FreeBSD Foundation (emaste, kib)
Differential revision: https://reviews.freebsd.org/D10439


# 5dd72342 21-Oct-2016 John Baldwin <jhb@FreeBSD.org>

Define max_align_t for C11.

libc++'s stddef.h includes an existing definition of max_align_t for
C++11, but it is only defined for C++, not for C. In addition, GCC and
clang both define an alternate version of max_align_t that uses a
union of multiple types rather than a plain long double as in libc++.
This adds a __max_align_t to <sys/_types.h> that matches the GCC and
clang definition that is mapped to max_align_t in <stddef.h>.

PR: 210890
Reviewed by: dim
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D8194


# 6710d21d 12-May-2016 Conrad Meyer <cem@FreeBSD.org>

Pollute more places with off64_t and add __off64_t

Despite the private namespace, several broken ports depend on the __off64_t
name for the type. Export it exactly the same way off_t and __off_t are
exported.

A follow-up to r299456.

Suggested by: php56
Sponsored by: EMC / Isilon Storage Division


# da1b038a 17-Mar-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Use uintmax_t (typedef'd to rman_res_t type) for rman ranges.

On some architectures, u_long isn't large enough for resource definitions.
Particularly, powerpc and arm allow 36-bit (or larger) physical addresses, but
type `long' is only 32-bit. This extends rman's resources to uintmax_t. With
this change, any resource can feasibly be placed anywhere in physical memory
(within the constraints of the driver).

Why uintmax_t and not something machine dependent, or uint64_t? Though it's
possible for uintmax_t to grow, it's highly unlikely it will become 128-bit on
32-bit architectures. 64-bit architectures should have plenty of RAM to absorb
the increase on resource sizes if and when this occurs, and the number of
resources on memory-constrained systems should be sufficiently small as to not
pose a drastic overhead. That being said, uintmax_t was chosen for source
clarity. If it's specified as uint64_t, all printf()-like calls would either
need casts to uintmax_t, or be littered with PRI*64 macros. Casts to uintmax_t
aren't horrible, but it would also bake into the API for
resource_list_print_type() either a hidden assumption that entries get cast to
uintmax_t for printing, or these calls would need the PRI*64 macros. Since
source code is meant to be read more often than written, I chose the clearest
path of simply using uintmax_t.

Tested on a PowerPC p5020-based board, which places all device resources in
0xfxxxxxxxx, and has 8GB RAM.
Regression tested on qemu-system-i386
Regression tested on qemu-system-mips (malta profile)

Tested PAE and devinfo on virtualbox (live CD)

Special thanks to bz for his testing on ARM.

Reviewed By: bz, jhb (previous)
Relnotes: Yes
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D4544


# 2dd1bdf1 26-Jan-2016 Justin Hibbits <jhibbits@FreeBSD.org>

Convert rman to use rman_res_t instead of u_long

Summary:
Migrate to using the semi-opaque type rman_res_t to specify rman resources. For
now, this is still compatible with u_long.

This is step one in migrating rman to use uintmax_t for resources instead of
u_long.

Going forward, this could feasibly be used to specify architecture-specific
definitions of resource ranges, rather than baking a specific integer type into
the API.

This change has been broken out to facilitate MFC'ing drivers back to 10 without
breaking ABI.

Reviewed By: jhb
Sponsored by: Alex Perez/Inertial Computing
Differential Revision: https://reviews.freebsd.org/D5075


# aad37c81 04-Jan-2015 Kevin Lo <kevlo@FreeBSD.org>

Change the type of blksize_t from uint32_t to a POSIX compliant int32_t
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_types.h.html


# 7008be5b 04-Sep-2013 Pawel Jakub Dawidek <pjd@FreeBSD.org>

Change the cap_rights_t type from uint64_t to a structure that we can extend
in the future in a backward compatible (API and ABI) way.

The cap_rights_t represents capability rights. We used to use one bit to
represent one right, but we are running out of spare bits. Currently the new
structure provides place for 114 rights (so 50 more than the previous
cap_rights_t), but it is possible to grow the structure to hold at least 285
rights, although we can make it even larger if 285 rights won't be enough.

The structure definition looks like this:

struct cap_rights {
uint64_t cr_rights[CAP_RIGHTS_VERSION + 2];
};

The initial CAP_RIGHTS_VERSION is 0.

The top two bits in the first element of the cr_rights[] array contain total
number of elements in the array - 2. This means if those two bits are equal to
0, we have 2 array elements.

The top two bits in all remaining array elements should be 0.
The next five bits in all array elements contain array index. Only one bit is
used and bit position in this five-bits range defines array index. This means
there can be at most five array elements in the future.

To define new right the CAPRIGHT() macro must be used. The macro takes two
arguments - an array index and a bit to set, eg.

#define CAP_PDKILL CAPRIGHT(1, 0x0000000000000800ULL)

We still support aliases that combine few rights, but the rights have to belong
to the same array element, eg:

#define CAP_LOOKUP CAPRIGHT(0, 0x0000000000000400ULL)
#define CAP_FCHMOD CAPRIGHT(0, 0x0000000000002000ULL)

#define CAP_FCHMODAT (CAP_FCHMOD | CAP_LOOKUP)

There is new API to manage the new cap_rights_t structure:

cap_rights_t *cap_rights_init(cap_rights_t *rights, ...);
void cap_rights_set(cap_rights_t *rights, ...);
void cap_rights_clear(cap_rights_t *rights, ...);
bool cap_rights_is_set(const cap_rights_t *rights, ...);

bool cap_rights_is_valid(const cap_rights_t *rights);
void cap_rights_merge(cap_rights_t *dst, const cap_rights_t *src);
void cap_rights_remove(cap_rights_t *dst, const cap_rights_t *src);
bool cap_rights_contains(const cap_rights_t *big, const cap_rights_t *little);

Capability rights to the cap_rights_init(), cap_rights_set(),
cap_rights_clear() and cap_rights_is_set() functions are provided by
separating them with commas, eg:

cap_rights_t rights;

cap_rights_init(&rights, CAP_READ, CAP_WRITE, CAP_FSTAT);

There is no need to terminate the list of rights, as those functions are
actually macros that take care of the termination, eg:

#define cap_rights_set(rights, ...) \
__cap_rights_set((rights), __VA_ARGS__, 0ULL)
void __cap_rights_set(cap_rights_t *rights, ...);

Thanks to using one bit as an array index we can assert in those functions that
there are no two rights belonging to different array elements provided
together. For example this is illegal and will be detected, because CAP_LOOKUP
belongs to element 0 and CAP_PDKILL to element 1:

cap_rights_init(&rights, CAP_LOOKUP | CAP_PDKILL);

Providing several rights that belongs to the same array's element this way is
correct, but is not advised. It should only be used for aliases definition.

This commit also breaks compatibility with some existing Capsicum system calls,
but I see no other way to do that. This should be fine as Capsicum is still
experimental and this change is not going to 9.x.

Sponsored by: The FreeBSD Foundation


# 74b6b2bb 25-May-2013 Ed Schouten <ed@FreeBSD.org>

Fix <uchar.h> in for C++11.

It turns out that in C++11, char16_t and char32_t are built-in types;
language keywords. Just fix this by putting traditional _*_T_DECLARED
blocks around the definitions. We'll just predefine these in
<sys/_types.h>.

This also opens up the possibility to define char16_t in other header
files, if ever needed (e.g. if we would gain a <ctype.h> for
char16_t/char32_t).


# 50c77c6e 21-May-2013 Ed Schouten <ed@FreeBSD.org>

Add <uchar.h>.

The <uchar.h> header, part of C11, adds a small number of utility
functions for 16/32-bit "universal" characters, which may or may not be
UTF-16/32. As our wchar_t is already ISO 10646, simply add light-weight
wrappers around wcrtomb() and mbrtowc().

While there, also add (non-yet-standard) _l functions, similar to the
ones we already have for the other locale-dependent functions.

Reviewed by: theraven


# 74dc547e 23-Jun-2012 Andrew Turner <andrew@FreeBSD.org>

Make the wchar_t type machine dependent.

This is required for ARM EABI. Section 7.1.1 of the Procedure Call for the
ARM Architecture (AAPCS) defines wchar_t as either an unsigned int or an
unsigned short with the former preferred.

Because of this requirement we need to move the definition of __wchar_t to
a machine dependent header. It also cleans up the macros defining the limits
of wchar_t by defining __WCHAR_MIN and __WCHAR_MAX in the same machine
dependent header then using them to define WCHAR_MIN and WCHAR_MAX
respectively.

Discussed with: bde


# 07b1b594 30-Jun-2011 Jonathan Anderson <jonathan@FreeBSD.org>

Define cap_rights_t and DTYPE_CAPABILITY, which are required to
implement Capsicum capabilities.

Approved by: mentor (rwatson), re (bz)


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 15bc6b2b 28-Oct-2008 Edward Tomasz Napierala <trasz@FreeBSD.org>

Introduce accmode_t. This is required for NFSv4 ACLs - it will be neccessary
to add more V* constants, and the variables changed by this patch were often
being assigned to mode_t variables, which is 16 bit.

Approved by: rwatson (mentor)


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# d7f687fc 02-Mar-2008 Jeff Roberson <jeff@FreeBSD.org>

Add cpuset, an api for thread to cpu binding and cpu resource grouping
and assignment.
- Add a reference to a struct cpuset in each thread that is inherited from
the thread that created it.
- Release the reference when the thread is destroyed.
- Add prototypes for syscalls and macros for manipulating cpusets in
sys/cpuset.h
- Add syscalls to create, get, and set new numbered cpusets:
cpuset(), cpuset_{get,set}id()
- Add syscalls for getting and setting affinity masks for cpusets or
individual threads: cpuid_{get,set}affinity()
- Add types for the 'level' and 'which' parameters for the cpuset. This
will permit expansion of the api to cover cpu masks for other objects
identifiable with an id_t integer. For example, IRQs and Jails may be
coming soon.
- The root set 0 contains all valid cpus. All thread initially belong to
cpuset 1. This permits migrating all threads off of certain cpus to
reserve them for special applications.

Sponsored by: Nokia
Discussed with: arch, rwatson, brooks, davidxu, deischen
Reviewed by: antoine


# 61d3a4ef 28-Feb-2006 David Xu <davidxu@FreeBSD.org>

Let kernel POSIX timer code and mqueue code to use integer as a resource
handle, the timer_t and mqd_t types will be a pointer which userland
will define it.


# 655291f2 25-Nov-2005 David Xu <davidxu@FreeBSD.org>

Bring in experimental kernel support for POSIX message queue.


# 3eea6658 21-Mar-2005 David Schultz <das@FreeBSD.org>

- Declare mknod in stat.h (in addition to unistd.h), as per XSI.
- Use blksize_t and blkcnt_t in struct stat.
- Hide non-standard fields in stat.h when !__BSD_VISIBLE.
- Add restrict qualifiers in stat.h.


# de84c3d1 08-Nov-2004 Dag-Erling Smørgrav <des@FreeBSD.org>

Document why rlim_t needs to be a signed type.
Define RLIM_INFINITY as INT64_MAX instead of hand-rolling it.

MFC after: 1 week


# 0068114d 19-Jun-2004 Marcel Moolenaar <marcel@FreeBSD.org>

Define __lwpid_t as an int32_t in <sys/_types.h> and define lwpid_t
as an __lwpid_t in <sys/types.h>. Retype td_tid from an int to a
lwpid_t and change related definitions accordingly.


# f3732fd1 17-Jun-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Second half of the dev_t cleanup.

The big lines are:
NODEV -> NULL
NOUDEV -> NODEV
udev_t -> dev_t
udev2dev() -> findcdev()

Various minor adjustments including handling of userland access to kernel
space struct cdev etc.


# 89c9c53d 16-Jun-2004 Poul-Henning Kamp <phk@FreeBSD.org>

Do the dreaded s/dev_t/struct cdev */
Bump __FreeBSD_version accordingly.


# 22e9911e 14-Jun-2004 Bruce Evans <bde@FreeBSD.org>

Fixed some style bugs:
- the comments on the rune/wide char types were lost
- struct cdev was bogusly forward declared
- some comments were excessively indented.


# 1db12dbd 13-Jun-2004 David Schultz <das@FreeBSD.org>

Add __fixpt_t to _types.h, and typedef __fixpt_t fixpt_t in types.h.


# a54ec1d2 28-Mar-2003 Mike Barcroft <mike@FreeBSD.org>

Move details of dev_t (and udev_t) to <sys/_types.h>.


# 2019acb6 01-Mar-2003 Mike Barcroft <mike@FreeBSD.org>

Share ino_t and nlink_t.


# 089a3f75 22-Dec-2002 Mike Barcroft <mike@FreeBSD.org>

Add suseconds_t and useconds_t for storing microseconds.


# 7a43ac45 22-Oct-2002 Mike Barcroft <mike@FreeBSD.org>

Note that id_t can also hold a gid_t. Realign comments.


# 06f0dd00 21-Oct-2002 Mike Barcroft <mike@FreeBSD.org>

Add id_t, a new type capable of representing a pid_t or a uid_t. Move
the definition of rlim_t to <sys/_types.h> so that it can be shared.


# 89b6abc3 14-Oct-2002 Mike Barcroft <mike@FreeBSD.org>

Move details of key_t to <sys/_types.h>, so that it can be typedef'd
in more than just <sys/types.h>.


# f4a1f909 17-Sep-2002 Mike Barcroft <mike@FreeBSD.org>

Move definition of nl_item type to <sys/_types.h>, so that it can be
shared.


# dd777001 25-Aug-2002 Mike Barcroft <mike@FreeBSD.org>

Move intrmask_t to the kernel-only section of <sys/types.h>. Add some
comments submitted by bde.


# b7df4506 23-Aug-2002 Mike Barcroft <mike@FreeBSD.org>

o Fix namespace issues in <sys/mman.h>.
o Move mode_t details from <sys/types.h> into <sys/_types.h>.
o Add primitives for sharing the mode_t and off_t typedefs.
o Add typedefs mode_t, off_t, and size_t to <sys/mman.h>.

PR: 21644


# bd8e0716 23-Aug-2002 Mike Barcroft <mike@FreeBSD.org>

Move several MI types from <machine/_types.h> to <sys/_types.h>.
These types are unlikely to ever become very MD. They include:
clockid_t, ct_rune_t, fflags_t, intrmask_t, mbstate_t, off_t, pid_t,
rune_t, socklen_t, timer_t, wchar_t, and wint_t.

While moving them, make a few adjustments (submitted by bde):
o __ct_rune_t needs to be precisely `int', not necessarily __int32_t,
since the arg type of the ctype functions is int.
o __rune_t, __wchar_t and __wint_t inherit this via a typedef of
__ct_rune_t.
o Some minor wording changes in the comment blocks for ct_rune_t and
mbstate_t.

Submitted by: bde (partially)


# abbd8902 21-Aug-2002 Mike Barcroft <mike@FreeBSD.org>

o Merge <machine/ansi.h> and <machine/types.h> into a new header
called <machine/_types.h>.
o <machine/ansi.h> will continue to live so it can define MD clock
macros, which are only MD because of gratuitous differences between
architectures.
o Change all headers to make use of this. This mainly involves
changing:
#ifdef _BSD_FOO_T_
typedef _BSD_FOO_T_ foo_t;
#undef _BSD_FOO_T_
#endif
to:
#ifndef _FOO_T_DECLARED
typedef __foo_t foo_t;
#define _FOO_T_DECLARED
#endif

Concept by: bde
Reviewed by: jake, obrien


# 25091754 14-Jun-2002 Garrett Wollman <wollman@FreeBSD.org>

Implement the <sys/statvfs.h> header. Related changes to <sys/types.h>
are still awaiting a worldstone. Functions and their declarations to
come later.


# c6e43821 19-Apr-2002 Mike Barcroft <mike@FreeBSD.org>

Add sa_family_t type to <sys/_types.h> and typedefs to <netinet/in.h>
and <sys/socket.h>. Previously, sa_family_t was only typedef'd in
<sys/socket.h>.


# 8822d3fb 01-Apr-2002 Mike Barcroft <mike@FreeBSD.org>

o Implement <sys/_types.h>, a new header for storing types that are
MI, not required to be a fixed size, and used in multiple headers.
This will grow in time, as more things move here from <sys/types.h>
and <machine/ansi.h>.
o Add missing type definitions (uint16_t and uint32_t) to
<arpa/inet.h> and <netinet/in.h>.
o Reduce pollution in <sys/types.h> by using `#if _FOO_T_DECLARED'
widgets to avoid including <sys/stdint.h>.
o Add some missing type definitions to <unistd.h> and note the ones
that still need to be added.
o Make use of <sys/_types.h> primitives in <grp.h> and <sys/types.h>.

Reviewed by: bde