History log of /freebsd-current/sys/sys/types.h
Revision Date Author Comments
# cf5d9c41 20-Apr-2024 Gordon Bergling <gbe@FreeBSD.org>

sys: Remove two double words in source code comments

- s/of of/of/

MFC after: 5 days


# 29363fb4 23-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove ancient SCCS tags.

Remove ancient SCCS tags from the tree, automated scripting, with two
minor fixup to keep things compiling. All the common forms in the tree
were removed with a perl script.

Sponsored by: Netflix


# 2ff63af9 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

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

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


# cebb8646 12-Mar-2023 Mateusz Guzik <mjg@FreeBSD.org>

Support byte-sized enums

To that end add __enum_uint8_decl and __enum_uint8.

By default enums take 4 bytes, but vast majority of them have values
which would fit in a byte.

One can try to workaround the problem by using bitfields, like so:
enum some_small_enum foo:8;

but that's ugly and runs into trouble when using atomic_load (you can't
take an address of a bitfield, even if it is sized to a multiply of a
byte).

Both gcc 13 and clang support specifying the size, and for older
variants one can fallback to the "packed" attribute.

Names are mangled in order to avoid mix use with plain enum.

Reviewed by:
Differential Revision: https://reviews.freebsd.org/D39031


# 3029b0b0 25-Apr-2023 Dimitry Andric <dim@FreeBSD.org>

boolean_t: change to unsigned int to avoid signed bitfield warnings

This is the final part, which actually makes boolean_t unsigned. Note
that we do not change its size, nor do we try to change it directly to
bool, since that results in a lot of regressions.

Converting the remaining instances of boolean_t to plain C99 bool can
now be done in a piecemeal fashion, after which boolean_t may hopefully
be retired.

MFC after: 1 week
Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D39753


# 92fc50b4 17-Aug-2022 Jessica Clarke <jrtc27@FreeBSD.org>

sys: Extract __bitcount* from sys/types.h to new sys/bitcount.h

This will allow the code to be reused by the cross-build sys/types.h
wrapper in order to provide the APIs for greater compatibility. This
also provides a path towards eventually removing the definitions from
sys/types.h altogether if so desired by gradually migrating users to
including sys/bitcount.h explicitly, but that is not the primary goal
here.

Note that the copyright header is a direct copu of sys/types.h's given
that's where this code comes from. This could be replaced in future with
a more specific one restricted to just the code in question, depending
on what the copyright for that code is.

Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D36132


# b1ad6a90 28-Mar-2022 Brooks Davis <brooks@FreeBSD.org>

syscallarg_t: Add a type for system call arguments

This more clearly differentiates system call arguments from integer
registers and return values. On current architectures it has no effect,
but on architectures where pointers are not integers (CHERI) and may
not even share registers (CHERI-MIPS) it is necessiary to differentiate
between system call arguments (syscallarg_t) and integer register values
(register_t).

Obtained from: CheriBSD

Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D33780


# 0910a41e 12-Jan-2022 Brooks Davis <brooks@FreeBSD.org>

Revert "syscallarg_t: Add a type for system call arguments"

Missed issues in truss on at least armv7 and powerpcspe need to be
resolved before recommit.

This reverts commit 3889fb8af0b611e3126dc250ebffb01805152104.
This reverts commit 1544e0f5d1f1e3b8c10a64cb899a936976ca7ea4.


# 1544e0f5 12-Jan-2022 Brooks Davis <brooks@FreeBSD.org>

syscallarg_t: Add a type for system call arguments

This more clearly differentiates system call arguments from integer
registers and return values. On current architectures it has no effect,
but on architectures where pointers are not integers (CHERI) and may
not even share registers (CHERI-MIPS) it is necessiary to differentiate
between system call arguments (syscallarg_t) and integer register values
(register_t).

Obtained from: CheriBSD

Reviewed by: imp, kib
Differential Revision: https://reviews.freebsd.org/D33780


# 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


# dfff3776 12-Apr-2021 Mark Johnston <markj@FreeBSD.org>

Rename struct device to struct _device

types.h defines device_t as a typedef of struct device *. struct device
is defined in subr_bus.c and almost all of the kernel uses device_t.
The LinuxKPI also defines a struct device, so type confusion can occur.

This causes bugs and ambiguity for debugging tools. Rename the FreeBSD
struct device to struct _device.

Reviewed by: gbe (man pages)
Reviewed by: rpokala, imp, jhb
MFC after: 1 week
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D29676


# 60b426f4 24-Oct-2020 Warner Losh <imp@FreeBSD.org>

Remove obsolete check for GCC < 3 and support for Intel Compiler

We no longer support old versions of GCC. Remove this check by
assuming it's false. That will make the entire expression false. Also
remove support for Intel compiler, it's badly bitrotted. Technically,
this removes support for C89 and K&R from compilers that don't define
_Bool in those compilation environments as well. I'm unaware of any
working compiler today for which that would be relevant (pcc has it
and tcc sadly isn't working for other reasons), though if one
pops up in ports, I'll work to resolve the issue.


# 45472826 14-Sep-2020 Warner Losh <imp@FreeBSD.org>

Tweak what's visible in the standalone environment. We define offsetof
in stand.h typically, but when this is included we can define it
multiple times. However, we don't define bool in stand.h at the
moment, so allow it to be defined inside types.h when we're building
for the standalone environment.

MFC After: 3 days


# ca6129af 14-Apr-2020 Kyle Evans <kevans@FreeBSD.org>

sys/types.h: adjust #endif comment to match reality

Submitted by: sigsys gmail com


# 38cf2a43 06-Feb-2020 Leandro Lupori <luporl@FreeBSD.org>

Implement kvm_kerndisp

This change adds a new libkvm function, kvm_kerndisp(), that can be used to
retrieve the kernel displacement, that is the difference between the kernel's
base virtual address at run time and the kernel base virtual address specified
in the kernel image file.

This will be used by kgdb, to properly relocate kernel symbols, when needed.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D23285


# 9dc7ed62 08-Nov-2019 Ed Maste <emaste@FreeBSD.org>

kvm: fix types for cross-debugging

As with other libkvm interfaces use maximum-sized types to support
cross-debugging (e.g. a 64-bit vmcore on a 32-bit host). See
https://lists.freebsd.org/pipermail/svn-src-all/2019-February/176051.html
for further discussion.

This is an API-breaking change, but there are few consumers of this
interface today.

Reviewed by: will
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D21945


# 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


# 10d9120c 02-Dec-2018 Konstantin Belousov <kib@FreeBSD.org>

Change the vm_ooffset_t type to unsigned.

The type represents byte offset in the vm_object_t data space, which
does not span negative offsets in FreeBSD VM. The change matches byte
offset signess with the unsignedness of the vm_pindex_t which
represents the type of the page indexes in the objects.

This allows to remove the UOFF_TO_IDX() macro which was used when we
have to forcibly interpret the type as unsigned anyway. Also it fixes
a lot of implicit bugs in the device drivers d_mmap methods.

Reviewed by: alc, markj (previous version)
Tested by: pho
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation


# 09f4e462 02-Nov-2018 Ed Maste <emaste@FreeBSD.org>

sys/types.h: avoid using terse macro _M

Although _M is reserved for use by the implemenation it is rather non-
descriptive and conflicted with a libc++ test. Just rename to _Major
and _Minor to avoid conflicts.

Reviewed by: dim
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D16734


# f38b68ae 05-Jul-2018 Brooks Davis <brooks@FreeBSD.org>

Make struct xinpcb and friends word-size independent.

Replace size_t members with ksize_t (uint64_t) and pointer members
(never used as pointers in userspace, but instead as unique
idenitifiers) with kvaddr_t (uint64_t). This makes the structs
identical between 32-bit and 64-bit ABIs.

On 64-bit bit systems, the ABI is maintained. On 32-bit systems,
this is an ABI breaking change. The ABI of most of these structs
was previously broken in r315662. This also imposes a small API
change on userspace consumers who must handle kernel pointers
becoming virtual addresses.

PR: 228301 (exp-run by antoine)
Reviewed by: jtl, kib, rwatson (various versions)
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D15386


# ab35e1c7 12-Jun-2018 Bruce Evans <bde@FreeBSD.org>

Fix the encoding of major and minor numbers in 64-bit dev_t by restoring
the old encodings for the lower 16 and 32 bits and only using the
higher 32 bits for unusually large major and minor numbers. This
change breaks compatibility with the previous encoding (which was only
used in -current).

Fix truncation to (essentially) 16-bit dev_t in newnfs v3.

Any encoding of device numbers gives an ABI, so it can't be changed
without translations for compatibility. Extra bits give the much
larger complication that the translations need to compress into fewer
bits. Fortunately, more than 32 bits are rarely needed, so
compression is rarely needed except for 16-bit linux dev_t where it
was always needed but never done.

The previous encoding moved the major number into the top 32 bits.
Almost no translation code handled this, so the major number was blindly
truncated away in most 32-bit encodings. E.g., for ffs, mknod(8) with
major = 1 and minor = 2 gave dev_t = 0x10000002; ffs cannot represent
this and blindly truncated it to 2. But if this mknod was run on any
released version of FreeBSD, it gives dev_t = 0x102. ffs can represent
this, but in the previous encoding it was not decoded, giving major = 0,
minor = 0x102.

The presence of bugs was most obvious for exporting dev_t's from an
old system to -current, since bugs in newnfs augment them. I fixed
oldnfs to support 32-bit dev_t in 1996 (r16634), but this regressed
to 16-bit dev_t in newnfs, first to the old 16-bit encoding and then
further in -current. E.g., old ad0 with major = 234, minor = 0x10002
had the correct (major, minor) number on the wire, but newnfs truncated
this to (234, 2) and then the previous encoding shifted the major
number into oblivion as seen by ffs or old applications.

I first tried to fix this by translating on every ABI/API boundary, but
there are too many boundaries and too many sloppy translations by blind
truncation. So use the old encoding for the low 32 bits so that sloppy
translations work no worse than before provided the high 32 bits are
not set. Add some error checking for when bits are lost. Keep not
doing any error checking for translations for almost everything in
compat/linux.

compat/freebsd32/freebsd32_misc.c:
Optionally check for losing bits after possibly-truncating assignments as
before.

compat/linux/linux_stats.c:
Depend on the representation being compatible with Linux's (or just with
itself for local use) and spell some of the translations as assignments in
a macro that hides the details.

fs/nfsclient/nfs_clcomsubs.c:
Essentially the same fix as in 1996, except there is now no possible
truncation in makedev() itself. Also fix nearby style bugs.

kern/vfs_syscalls.c:
As for freebsd32. Also update the sysctl description to include file
numbers, and change it to describe device ids as device numbers.

sys/types.h:
Use inline functions (wrapped by macros) since the expressions are now
a bit too complicated for plain macros. Describe the encoding and
some of the reasons for it. 16-bit compatibility didn't leave many
reasonable choices for the 32-bit encoding, and 32-bit compatibility
doesn't leave many reasonable choices for the 64-bit encoding. My
choice is to put the 8 new minor bits in the low 8 bits of the top 32
bits. This minimizes discontiguities.

Reviewed by: kib (except for rewrite of the comment in linux_stats.c)


# 51369649 20-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

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.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.


# 0b9b3897 05-Aug-2017 Konstantin Belousov <kib@FreeBSD.org>

Remove trivial comments. Remove and-ing with UINT_MAX for minor(),
cast to int already does the required truncation of significant bits.

Requested and reviewed by: bde
Sponsored by: The FreeBSD Foundation


# dfcc612c 02-Aug-2017 Konstantin Belousov <kib@FreeBSD.org>

For makedev(), cast the minor argument to unsigned type explicitely,
avoiding possible sign propagation.

Submitted by: hselasky


# 5dd37194 02-Aug-2017 Konstantin Belousov <kib@FreeBSD.org>

Change major()/minor() to work with 64bit dev_t.

Since traditional types for the macros values are int, remove the
cookie trick and just split the dev_t at the word boundary.

Reported by: Victor Stinner <victor.stinner@gmail.com>
PR: 221048
Sponsored by: The FreeBSD Foundation


# fbbd9655 28-Feb-2017 Warner Losh <imp@FreeBSD.org>

Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96


# 9fb10d63 03-Feb-2017 Konstantin Belousov <kib@FreeBSD.org>

Define the vm_ooffset_t and vm_pindex_t types as machine-independend.

The types are for the byte offset and page index in vm object. They
are similar to off_t, which is defined as 64bit MI integer. Using MI
definitions will allow to provide consistent MD values of vm
object-related maximum sizes.

Reviewed by: alc
Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# 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


# 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


# 873a0bd6 26-Sep-2015 Konstantin Belousov <kib@FreeBSD.org>

Make the __bitcount*() functions unconditionally available, by moving
them out of the #if _BSD_VISIBLE block. Other headers may depend on
__bitcount(). The dependencies can be a header not specified by
POSIX, and then namespace restrictions by _XOPEN_SOURCE are not
applicable, as it was reported. Or, we might grow an implementation
of some POSIX facility using __bitcount(), which also should work.

Reported by: Jason Schulz <schulz.j@gmail.com>
Discussed with: jhb
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks


# 589b2c1c 20-Mar-2015 John Baldwin <jhb@FreeBSD.org>

Expand the bitcount* API to support 64-bit integers, plain ints and longs
and create a "hidden" API that can be used in other system headers without
adding namespace pollution.
- If the POPCNT instruction is enabled at compile time, use
__builtin_popcount*() to implement __bitcount*(), otherwise fall back
to software implementations.
- Use the existing bitcount16() and bitcount32() from <sys/systm.h> to
implement the non-POPCNT __bitcount16() and __bitcount32() in
<sys/types.h>.
- For the non-POPCNT __bitcount64(), use a similar SWAR method on 64-bit
systems. For 32-bit systems, use two __bitcount32() operations on the
two halves.
- Use __bitcount32() to provide a __bitcount() that operates on plain ints.
- Use either __bitcount32() or __bitcount64() to provide a
__bitcountl() that operates on longs.
- Add public bitcount*() wrappers for __bitcount*() for use in the kernel
in <sys/libkern.h>.
- Use __builtinl() instead of __builtin_popcountl() in BIT_COUNT().

Discussed with: bde


# d2925ccc 16-Mar-2015 Robert Watson <rwatson@FreeBSD.org>

Introduce a cap_ioctl_t used for the 'cmds' arguments to cap_ioctls_limit()
and cap_ioctls_get(). On FreeBSD, these are 'unsigned long', but on Linux,
ioctl(2) takes an 'int', making mild abstraction desirable.

MFC after: 3 days
Sponsored by: Google, Inc.


# 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


# aa97685d 28-Feb-2013 Davide Italiano <davide@FreeBSD.org>

Move the definition of sbintime_t type from <sys/time.h> to <sys/types.h>.
With this change we prevent gross namespace pollution.

Reported by: bde
Suggested by: attilio


# e2d55f48 15-Nov-2012 Konstantin Belousov <kib@FreeBSD.org>

Move the definition of the idtype_t from sys/types.h to sys/wait.h.
Fix the bug, use #if __BSD_VISIBLE instead of #if defined(__BSD_VISIBLE),
since __BSD_VISIBLE is always defined.
Reformat the comments from the Solaris style to KNF.

Reported and reviewed by: bde
MFC after: 28 days


# f13b5a0f 12-Nov-2012 Konstantin Belousov <kib@FreeBSD.org>

Add the wait6(2) system call. It takes POSIX waitid()-like process
designator to select a process which is waited for. The system call
optionally returns siginfo_t which would be otherwise provided to
SIGCHLD handler, as well as extended structure accounting for child
and cumulative grandchild resource usage.

Allow to get the current rusage information for non-exited processes
as well, similar to Solaris.

The explicit WEXITED flag is required to wait for exited processes,
allowing for more fine-grained control of the events the waiter is
interested in.

Fix the handling of siginfo for WNOWAIT option for all wait*(2)
family, by not removing the queued signal state.

PR: standards/170346
Submitted by: "Jukka A. Ukkonen" <jau@iki.fi>
MFC after: 1 month


# 86872b65 31-Jan-2012 Sergey Kandaurov <pluknet@FreeBSD.org>

Isolate v_caddr_t in the ie driver.

Submitted by: Bruce Evans on net@


# f6ab8089 13-Dec-2011 Ed Schouten <ed@FreeBSD.org>

Replace __const by const in all non-contributed source code.

As C1X is close to being released, there is no need to wrap around a
feature that is already part of C90. Most of these files already use
`const' in different placed as well.


# 108cd494 12-Dec-2011 Matthew D Fleming <mdf@FreeBSD.org>

- Define true and false in sys/types.h for _KERNEL consumers, and
typedef bool. Due to macro expansion it seemed better to use a
typedef for kernel consumers (specifically ofed won't compile
without more changes if a define is used).
- <stdbool.h> should also not re-define bool/true/false if they are
defined by <sys/types.h>. It would probably be a programming error
to define _KERNEL for user-space code, but downstream consumers
like Isilon have already been including <stdbool.h> in kernel
sources, and this protects that usage.
- sizeof(_Bool) is not necessarily the same as sizeof(int), so kernel
modules should be rebuild with this change. Bump __FreeBSD_version.

MFC after: 2 weeks
Sponsored by: Isilon Systems, LLC


# 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)


# b928a692 05-May-2011 David E. O'Brien <obrien@FreeBSD.org>

Don't duplicate define the stdint types.


# 71a19bdc 05-May-2011 Attilio Rao <attilio@FreeBSD.org>

Commit the support for removing cpumask_t and replacing it directly with
cpuset_t objects.
That is going to offer the underlying support for a simple bump of
MAXCPU and then support for number of cpus > 32 (as it is today).

Right now, cpumask_t is an int, 32 bits on all our supported architecture.
cpumask_t on the other side is implemented as an array of longs, and
easilly extendible by definition.

The architectures touched by this commit are the following:
- amd64
- i386
- pc98
- arm
- ia64
- XEN

while the others are still missing.
Userland is believed to be fully converted with the changes contained
here.

Some technical notes:
- This commit may be considered an ABI nop for all the architectures
different from amd64 and ia64 (and sparc64 in the future)
- per-cpu members, which are now converted to cpuset_t, needs to be
accessed avoiding migration, because the size of cpuset_t should be
considered unknown
- size of cpuset_t objects is different from kernel and userland (this is
primirally done in order to leave some more space in userland to cope
with KBI extensions). If you need to access kernel cpuset_t from the
userland please refer to example in this patch on how to do that
correctly (kgdb may be a good source, for example).
- Support for other architectures is going to be added soon
- Only MAXCPU for amd64 is bumped now

The patch has been tested by sbruno and Nicholas Esborn on opteron
4 x 12 pack CPUs. More testing on big SMP is expected to came soon.
pluknet tested the patch with his 8-ways on both amd64 and i386.

Tested by: pluknet, sbruno, gianni, Nicholas Esborn
Reviewed by: jeff, jhb, sbruno


# 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.


# 175389cf 21-Jul-2010 Edward Tomasz Napierala <trasz@FreeBSD.org>

Remove spurious '/*-' marks and fix some other style problems.

Submitted by: bde@


# 1a996ed1 18-Jul-2010 Edward Tomasz Napierala <trasz@FreeBSD.org>

Revert r210225 - turns out I was wrong; the "/*-" is not license-only
thing; it's also used to indicate that the comment should not be automatically
rewrapped.

Explained by: cperciva@


# 805cc58a 18-Jul-2010 Edward Tomasz Napierala <trasz@FreeBSD.org>

The "/*-" comment marker is supposed to denote copyrights. Remove non-copyright
occurences from sys/sys/ and sys/kern/.


# a6fb7268 29-Oct-2009 John Baldwin <jhb@FreeBSD.org>

MFC 196615:
Extend the device pager to support different memory attributes on different
pages in an object.
- Add a new variant of d_mmap() currently called d_mmap2() which accepts
an additional in/out parameter that is the memory attribute to use for
the requested page.
- A driver either uses d_mmap() or d_mmap2() for all requests but not both.
The current implementation uses a flag in the cdevsw (D_MMAP2) to indicate
that the driver provides a d_mmap2() handler instead of d_mmap(). This
is done to make the change ABI compatible with existing drivers and
MFC'able to 7 and 8.


# 2fa8c8d2 28-Aug-2009 John Baldwin <jhb@FreeBSD.org>

Extend the device pager to support different memory attributes on different
pages in an object.
- Add a new variant of d_mmap() currently called d_mmap2() which accepts
an additional in/out parameter that is the memory attribute to use for
the requested page.
- A driver either uses d_mmap() or d_mmap2() for all requests but not both.
The current implementation uses a flag in the cdevsw (D_MMAP2) to indicate
that the driver provides a d_mmap2() handler instead of d_mmap(). This
is done to make the change ABI compatible with existing drivers and
MFC'able to 7 and 8.

Submitted by: alc
MFC after: 1 month


# a4611ab6 28-Jan-2009 Ed Schouten <ed@FreeBSD.org>

Last step of splitting up minor and unit numbers: remove minor().

Inside the kernel, the minor() function was responsible for obtaining
the device minor number of a character device. Because we made device
numbers dynamically allocated and independent of the unit number passed
to make_dev() a long time ago, it was actually a misnomer. If you really
want to obtain the device number, you should use dev2udev().

We already converted all the drivers to use dev2unit() to obtain the
device unit number, which is still used by a lot of drivers. I've
noticed not a single driver passes NULL to dev2unit(). Even if they
would, its behaviour would make little sense. This is why I've removed
the NULL check.

Ths commit removes minor(), minor2unit() and unit2minor() from the
kernel. Because there was a naming collision with uminor(), we can
rename umajor() and uminor() back to major() and minor(). This means
that the makedev(3) manual page also applies to kernel space code now.

I suspect umajor() and uminor() isn't used that often in external code,
but to make it easier for other parties to port their code, I've
increased __FreeBSD_version to 800062.


# 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.


# c6ec8c53 27-Sep-2008 Ed Schouten <ed@FreeBSD.org>

Move uminor() and umajor() to the same place as userspace minor() and major().

The uminor() and umajor() functions have the same use in kernel space as
the minor() and major() functions in userspace. If we ever get rid of
the minor() function in kernel space, we could decide to just expose
minor() and major() to kernel space, making uminor() and umajor()
redundant.

There are two reasons why we want to have uminor() and umajor() in
<sys/types.h>:

- Having them close together prevents them from diverting. Even though
it's unlikely the definitions will change, it's a good habit to have
them at the same place.

- They don't really belong in kern_conf.c. kern_conf.c has been
liberated from dealing with device major and minor number handling.

The device_ids(9) manpage now lists the wrong #include's, because it
should only list <sys/types.h> now. I'm leaving it as it is now, because
I wonder if we should document them anyway. We're probably better off
documenting minor(3) and major(3).


# 70d12a18 19-Aug-2008 John Baldwin <jhb@FreeBSD.org>

Export 'struct pcpu' to userland w/o requiring _KERNEL. A few ports
already define _KERNEL to get to this and I'm about to add hooks to
libkvm to access per-CPU data.

MFC after: 1 week


# 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


# e3709a56 28-Nov-2007 John Birrell <jb@FreeBSD.org>

Remove _SOLARIS_C_SOURCE compatibility definitions. Unfortunately the
ZFS porting style didn't extend this, instead using a heap of additional
header files that don't get installed.

My intention had been to allow OpenSolaris external code to build on
FreeBSD out of the box (i.e. without a src tree).


# 1d70d6cb 04-Aug-2006 John Birrell <jb@FreeBSD.org>

Add some compatibility definitions for OpenSolaris source.

These are only defined if _SOLARIS_C_SOURCE is defined, so they don't
polute the FreeBSD compile environment.

They are used all over the OpenSolaris source, so defining them here
removes the need to continually resolve differences in FreeBSD system
haeder files from Solaris header files.


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

Bring in experimental kernel support for POSIX message queue.


# 3d8d9f8f 26-Sep-2005 Nate Lawson <njl@FreeBSD.org>

Fix order and style(9) to match surrounding defs.


# a7789231 24-Sep-2005 Poul-Henning Kamp <phk@FreeBSD.org>

Add two convenience functions for device drivers: bus_alloc_resources()
and bus_free_resources(). These functions take a list of resources
and handle them all in one go. A flag makes it possible to mark
a resource as optional.

A typical device driver can save 10-30 lines of code by using these.

Usage examples will follow RSN.

MFC: A good idea, eventually.


# 4d62f529 31-May-2005 Craig Rodrigues <rodrigc@FreeBSD.org>

According to:
http://www.opengroup.org/onlinepubs/009695399/basedefs/sys/types.h.html

#include <sys/types.h>
should include the definitions of pthread types.

PR: standards/78907
Reported by: Brooks Davis
Approved by: das (mentor)


# 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.


# 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.


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

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


# 5bdc6a41 19-Apr-2004 David E. O'Brien <obrien@FreeBSD.org>

Prevent SysV spellings in int's in the kernel.

Submitted by: bde


# 82c6e879 06-Apr-2004 Warner Losh <imp@FreeBSD.org>

Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core


# a36bdc06 20-Mar-2004 Marcel Moolenaar <marcel@FreeBSD.org>

Introduce the cpumask_t type. The purpose of the type is to create a
level of abstraction for any and all CPU mask and CPU bitmap variables
so that platforms have the ability to break free from the hard limit
of 32 CPUs, simply because we don't have more bits in an u_int. Note
that the type is not supposed to solve massive parallelism, where
the number of CPUs can be larger than the width of the widest integral
type. As such, cpumask_t is not supposed to be a compound type. If
such would be necessary in the future, we can deal with the issues
then and there. For now, it can be assumed that the type is integral
and unsigned.

With this commit, all MD definitions start off as u_int. This allows
us to phase-in cpumask_t at our leasure without breaking anything.
Once cpumask_t is used consistently, platforms can switch to wider
(or smaller) types if such would be beneficial (or not; whatever :-)

Compile-tested on: i386


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

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


# 227f9a1c 24-Mar-2003 Jake Burkholder <jake@FreeBSD.org>

- Add vm_paddr_t, a physical address type. This is required for systems
where physical addresses larger than virtual addresses, such as i386s
with PAE.
- Use this to represent physical addresses in the MI vm system and in the
i386 pmap code. This also changes the paddr parameter to d_mmap_t.
- Fix printf formats to handle physical addresses >4G in the i386 memory
detection code, and due to kvtop returning vm_paddr_t instead of u_long.

Note that this is a name change only; vm_paddr_t is still the same as
vm_offset_t on all currently supported platforms.

Sponsored by: DARPA, Network Associates Laboratories
Discussed with: re, phk (cdevsw change)


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

Share ino_t and nlink_t.


# 56ec17ab 29-Jan-2003 Mike Barcroft <mike@FreeBSD.org>

Style: keep most typedefs in the same place.


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

Add suseconds_t and useconds_t for storing microseconds.


# 2d7b9daf 22-Oct-2002 Tim J. Robbins <tjr@FreeBSD.org>

Add back the typedefs for in_addr_t and in_port_t; some broken autoconf
scripts expect <sys/types.h> to define them.


# 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>.


# b7214516 03-Oct-2002 Peter Wemm <peter@FreeBSD.org>

Move swblk_t from sys/types.h to sys/dmap.h, the only include that uses
it. It's also only used in vm/vm_swap.c, but that is also the only source
file that #include's <sys/dmap.h>. sys/dmap.h could probably be embedded
entirely in vm_swap.c since that is the only consumer of it.


# 160d26d3 01-Oct-2002 Mike Barcroft <mike@FreeBSD.org>

o Update a visibility conditional.
o Adjust some comments in keeping with the header's local style.
o Change some typedefs to use types that don't require namespace
pollution or deprecated types.
o Move some macros to the "does not belong in this header" section.


# ca916247 27-Sep-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Rename struct specinfo to the more appropriate struct cdev.

Agreed on: jake, rwatson, jhb


# 606e9685 26-Sep-2002 Mike Barcroft <mike@FreeBSD.org>

Remove NBBY and howmany() macros.


# 56144d5a 23-Sep-2002 Mike Barcroft <mike@FreeBSD.org>

o Move select() helper macros from <sys/types.h> to <sys/select.h>.
o Include <sys/select.h> from <sys/types.h> in the __BSD_VISIBLE case,
so applications and base software can be slowly updated.
o Prototype select() in <sys/select.h>. It was previously only
prototyped in <unistd.h>.
o Add some XXX's to <sys/types.h>.

Reviewed by: -standards


# f0771a98 16-Sep-2002 Mike Barcroft <mike@FreeBSD.org>

pid_t will be shared with at least <fcntl.h>.


# 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


# 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


# 1c85e6a3 21-Jun-2002 Kirk McKusick <mckusick@FreeBSD.org>

This commit adds basic support for the UFS2 filesystem. The UFS2
filesystem expands the inode to 256 bytes to make space for 64-bit
block pointers. It also adds a file-creation time field, an ability
to use jumbo blocks per inode to allow extent like pointer density,
and space for extended attributes (up to twice the filesystem block
size worth of attributes, e.g., on a 16K filesystem, there is space
for 32K of attributes). UFS2 fully supports and runs existing UFS1
filesystems. New filesystems built using newfs can be built in either
UFS1 or UFS2 format using the -O option. In this commit UFS1 is
the default format, so if you want to build UFS2 format filesystems,
you must specify -O 2. This default will be changed to UFS2 when
UFS2 proves itself to be stable. In this commit the boot code for
reading UFS2 filesystems is not compiled (see /sys/boot/common/ufsread.c)
as there is insufficient space in the boot block. Once the size of the
boot block is increased, this code can be defined.

Things to note: the definition of SBSIZE has changed to SBLOCKSIZE.
The header file <ufs/ufs/dinode.h> must be included before
<ufs/ffs/fs.h> so as to get the definitions of ufs2_daddr_t and
ufs_lbn_t.

Still TODO:
Verify that the first level bootstraps work for all the architectures.
Convert the utility ffsinfo to understand UFS2 and test growfs.
Add support for the extended attribute storage. Update soft updates
to ensure integrity of extended attribute storage. Switch the
current extended attribute interfaces to use the extended attribute
storage. Add the extent like functionality (framework is there,
but is currently never used).

Sponsored by: DARPA & NAI Labs.
Reviewed by: Poul-Henning Kamp <phk@freebsd.org>


# 0a3d1610 15-Jun-2002 Garrett Wollman <wollman@FreeBSD.org>

Fix visibility macros. Declare fsblkcnt_t and fsfilcnt_t (for statvfs())
per POSIX.


# 4ecbca5e 18-May-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Try again: Make daddr_t 64 bits.

Sponsored by: DARPA & NAI Labs.


# f07d4b25 18-May-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Move the hideously misnamed type "u_daddr_t" to <sys/blist.h> where it
belongs.

Sponsored by: DARPA & NAI Labs.


# 4aafadc8 15-May-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Revert daddr_t to 32 bits while we research the reported problems.


# 98b0c789 14-May-2002 Poul-Henning Kamp <phk@FreeBSD.org>

Make daddr_t and u_daddr_t 64bits wide.
Retire daddr64_t and use daddr_t instead.

Sponsored by: DARPA & NAI Labs.


# 49285705 10-Apr-2002 Mike Barcroft <mike@FreeBSD.org>

Remove the hack for segsz_t from <sys/types.h>; use the normal
_BSD_FOO_T_ method for defining segsz_t.


# da071285 06-Apr-2002 Jake Burkholder <jake@FreeBSD.org>

segsz_t needs to be 64bit for sparc64.


# 5c8137de 01-Apr-2002 Mike Barcroft <mike@FreeBSD.org>

Fix some whitespace style bugs.


# 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


# 789f12fe 19-Mar-2002 Alfred Perlstein <alfred@FreeBSD.org>

Remove __P


# 0d2af521 15-Mar-2002 Kirk McKusick <mckusick@FreeBSD.org>

Introduce the new 64-bit size disk block, daddr64_t. Change
the bio and buffer structures to have daddr64_t bio_pblkno,
b_blkno, and b_lblkno fields which allows access to disks
larger than a Terabyte in size. This change also requires
that the VOP_BMAP vnode operation accept and return daddr64_t
blocks. This delta should not affect system operation in
any way. It merely sets up the necessary interfaces to allow
the development of disk drivers that work with these larger
disk block addresses. It also allows for the development of
UFS2 which will use 64-bit block addresses.


# 834dcade 26-Feb-2002 Mike Barcroft <mike@FreeBSD.org>

Rather than include namespace pollution in <grp.h> in order to declare
`gid_t', use the canonical protection scheme to define a type in two or
more headers. This brings <grp.h> closer to POSIX.1-2001 conformance.


# fd8e4ebc 18-Feb-2002 Mike Barcroft <mike@FreeBSD.org>

o Move NTOHL() and associated macros into <sys/param.h>. These are
deprecated in favor of the POSIX-defined lowercase variants.
o Change all occurrences of NTOHL() and associated marcros in the
source tree to use the lowercase function variants.
o Add missing license bits to sparc64's <machine/endian.h>.
Approved by: jake
o Clean up <machine/endian.h> files.
o Remove unused __uint16_swap_uint32() from i386's <machine/endian.h>.
o Remove prototypes for non-existent bswapXX() functions.
o Include <machine/endian.h> in <arpa/inet.h> to define the
POSIX-required ntohl() family of functions.
o Do similar things to expose the ntohl() family in libstand, <netinet/in.h>,
and <sys/param.h>.
o Prepend underscores to the ntohl() family to help deal with
complexities associated with having MD (asm and inline) versions, and
having to prevent exposure of these functions in other headers that
happen to make use of endian-specific defines.
o Create weak aliases to the canonical function name to help deal with
third-party software forgetting to include an appropriate header.
o Remove some now unneeded pollution from <sys/types.h>.
o Add missing <arpa/inet.h> includes in userland.

Tested on: alpha, i386
Reviewed by: bde, jake, tmm


# 3b7a4c4b 15-Feb-2002 Garrett Wollman <wollman@FreeBSD.org>

Resurrect one of the easiest changes from my big include files roll-up
patch from a year ago: give file flags their own type. This does not
(yet) change the type used by system calls or library functions.
The underlying type was chosen to match what is returned by stat().


# 385fedb6 04-Feb-2002 Mark Murray <markm@FreeBSD.org>

Back out the "upgrading" of NBBY to unsigned, as it exposes
bugs elsewhere, and also is well understood as a signed quantity.


# dc20def4 03-Feb-2002 Mark Murray <markm@FreeBSD.org>

Zero functional difference; make some integer constants unsigned, as
they are used in unsigned context. This shuts lint(1) up in a few
significant ways with "signed/unsigned" arithmetic warnings.


# de2656d0 30-Nov-2001 Mike Barcroft <mike@FreeBSD.org>

o Stop abusing MD headers with non-MD types.
o Hide nonstandard functions and types in <netinet/in.h> when
_POSIX_SOURCE is defined.
o Add some missing types (required by POSIX.1-200x) to <netinet/in.h>.
o Restore vendor ID from Rev 1.1 in <netinet/in.h> and make use of new
__FBSDID() macro.
o Fix some miscellaneous issues in <arpa/inet.h>.
o Correct final argument for the inet_ntop() function (POSIX.1-200x).
o Get rid of the namespace pollution from <sys/types.h> in
<arpa/inet.h>.

Reviewed by: fenner
Partially submitted by: bde


# 0ac2d551 02-Nov-2001 Mike Barcroft <mike@FreeBSD.org>

o Add new header <sys/stdint.h>.
o Make <stdint.h> a symbolic link to <sys/stdint.h>.
o Move most of <sys/inttypes.h> into <sys/stdint.h>, as per C99.
o Remove <sys/inttypes.h>.
o Adjust includes in sys/types.h and boot/efi/include/ia64/efibind.h
to reflect new location of integer types in <sys/stdint.h>.
o Remove previously symbolicly linked <inttypes.h>, instead create a
new file.
o Add MD headers <machine/_inttypes.h> from NetBSD.
o Include <sys/stdint.h> in <inttypes.h>, as required by C99; and
include <machine/_inttypes.h> in <inttypes.h>, to fill in the
remaining requirements for <inttypes.h>.
o Add additional integer types in <machine/ansi.h> and
<machine/limits.h> which are included via <sys/stdint.h>.

Partially obtain from: NetBSD
Tested on: alpha, i386
Discussed on: freebsd-standards@bostonradio.org
Reviewed by: bde, fenner, obrien, wollman


# 3e481b46 01-Sep-2001 Matthew Dillon <dillon@FreeBSD.org>

Undo last commit. The problem's been fixed for a long time.


# 7e39632b 31-Aug-2001 Matthew Dillon <dillon@FreeBSD.org>

Add FD_SETSIZE warning to types.h


# 03516cfe 29-Aug-2001 Mike Barcroft <mike@FreeBSD.org>

o Remove some GCCisms in src/powerpc/include/endian.h.
o Unify <machine/endian.h>'s across all architectures.
o Make bswapXX() functions use a different spelling of u_int16_t and
friends to reduce namespace pollution. The bswapXX() functions
don't actually exist, but we'll probably import these at some
point. Atleast one driver (if_de) depends on bswapXX() for big
endian cases.
o Deprecate byteorder(3) prototypes from <sys/types.h>, these are
now prototyped indirectly in <arpa/inet.h>.
o Deprecate in_addr_t and in_port_t typedefs in <sys/types.h>, these
are now typedef'd in <arpa/inet.h>.
o Change byteorder(3) prototypes to use standards compliant uint32_t
(spelled __uint32_t to reduce namespace pollution).
o Document new preferred headers and standards compliance.

Discussed with: bde
PR: 29946
Reviewed by: bmilekic


# 815d14dd 15-Jul-2001 Peter Wemm <peter@FreeBSD.org>

Use a fixed type for times in on-disk structures for ufs rather than
something that could potentially change like time_t.


# 8b625cb7 24-Mar-2001 Hajimu UMEMOTO <ume@FreeBSD.org>

Unbreak build on alpha.
- Move in_port_t to sys/types.h.
- Nuke in_addr_t from each endian.h.

Reported by: jhb


# 2da24fa6 23-Mar-2001 Hajimu UMEMOTO <ume@FreeBSD.org>

IPv4 address is not unsigned int. This change introduces in_addr_t.

PR: 9982
Adviced by: des
Reviewed by: -alpha and -net (no objection)
Obtained from: OpenBSD


# 46aa3347 27-Oct-2000 Poul-Henning Kamp <phk@FreeBSD.org>

Convert all users of fldoff() to offsetof(). fldoff() is bad
because it only takes a struct tag which makes it impossible to
use unions, typedefs etc.

Define __offsetof() in <machine/ansi.h>

Define offsetof() in terms of __offsetof() in <stddef.h> and <sys/types.h>

Remove myriad of local offsetof() definitions.

Remove includes of <stddef.h> in kernel code.

NB: Kernelcode should *never* include from /usr/include !

Make <sys/queue.h> include <machine/ansi.h> to avoid polluting the API.

Deprecate <struct.h> with a warning. The warning turns into an error on
01-12-2000 and the file gets removed entirely on 01-01-2001.

Paritials reviews by: various.
Significant brucifications by: bde


# 6ecfb1da 20-Feb-2000 Peter Wemm <peter@FreeBSD.org>

Followup to previous commit; change fd_mask from signed to unsigned as
it should have been to start with. The implications of that are not
pleasant when combined with >> as it breaks on multiples of NFDBITS.
Right shifting of a signed value fills with a copy of the sign bit,
not a zero.

Reported by: bde


# f082218c 20-Feb-2000 Peter Wemm <peter@FreeBSD.org>

Fix select(2) for the Alpha. (!!) It was never returning true for
fd's in the range of 32-63, 96-127 etc. The first problem was the
FD_*() macros were shifting a 32 bit integer "1" left by more than
32 bits. The same problem happened in selscan(). ffs() also takes
an int argument and causes failure. For cases where int == long
(ie: the usual case for x86, but not always as gcc can have long
being a 64 bit quantity) ffs() could be used.

Reported by: Marian Stagarescu <marian@bile.skycache.com>
Reviewed by: dfr, gallatin (sys/types.h only)
Approved by: jkh


# 664a31e4 28-Dec-1999 Peter Wemm <peter@FreeBSD.org>

Change #ifdef KERNEL to #ifdef _KERNEL in the public headers. "KERNEL"
is an application space macro and the applications are supposed to be free
to use it as they please (but cannot). This is consistant with the other
BSD's who made this change quite some time ago. More commits to come.


# d71408a5 03-Oct-1999 Marcel Moolenaar <marcel@FreeBSD.org>

Don't use const and volatile directly. Use the macros. This fixes
the breakage for K&R sources.


# c3aac50f 27-Aug-1999 Peter Wemm <peter@FreeBSD.org>

$Id$ -> $FreeBSD$


# 698bfad7 20-Jul-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Now a dev_t is a pointer to struct specinfo which is shared by all specdev
vnodes referencing this device.

Details:
cdevsw->d_parms has been removed, the specinfo is available
now (== dev_t) and the driver should modify it directly
when applicable, and the only driver doing so, does so:
vn.c. I am not sure the logic in checking for "<" was right
before, and it looks even less so now.

An intial pool of 50 struct specinfo are depleted during
early boot, after that malloc had better work. It is
likely that fewer than 50 would do.

Hashing is done from udev_t to dev_t with a prime number
remainder hash, experiments show no better hash available
for decent cost (MD5 is only marginally better) The prime
number used should not be close to a power of two, we use
83 for now.

Add new checkalias2() to get around the loss of info from
dev2udev() in bdevvp();

The aliased vnodes are hung on a list straight of the dev_t,
and speclisth[SPECSZ] is unused. The sharing of struct
specinfo means that the v_specnext moves into the vnode
which grows by 4 bytes.

Don't use a VBLK dev_t which doesn't make sense in MFS, now
we hang a dummy cdevsw on B/Cmaj 253 so that things look sane.

Storage overhead from all of this is O(50k).

Bump __FreeBSD_version to 400009

The next step will add the stuff needed so device-drivers can start to
hang things from struct specinfo


# 3083856d 17-Jul-1999 John Polstra <jdp@FreeBSD.org>

Remove a duplicate comment.


# adfea48f 12-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Produce compiler warning if dev_t and udev_t is confused.


# 7238b096 12-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

#define udev_t dev_t in userland, so that programs which peek at
vnodes and stuff compile. They may still not work however.


# bfbb9ce6 11-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Divorce "dev_t" from the "major|minor" bitmap, which is now called
udev_t in the kernel but still called dev_t in userland.

Provide functions to manipulate both types:
major() umajor()
minor() uminor()
makedev() umakedev()
dev2udev() udev2dev()

For now they're functions, they will become in-line functions
after one of the next two steps in this process.

Return major/minor/makedev to macro-hood for userland.

Register a name in cdevsw[] for the "filedescriptor" driver.

In the kernel the udev_t appears in places where we have the
major/minor number combination, (ie: a potential device: we
may not have the driver nor the device), like in inodes, vattr,
cdevsw registration and so on, whereas the dev_t appears where
we carry around a reference to a actual device.

In the future the cdevsw and the aliased-from vnode will be hung
directly from the dev_t, along with up to two softc pointers for
the device driver and a few houskeeping bits. This will essentially
replace the current "alias" check code (same buck, bigger bang).

A little stunt has been provided to try to catch places where the
wrong type is being used (dev_t vs udev_t), if you see something
not working, #undef DEVT_FASCIST in kern/kern_conf.c and see if
it makes a difference. If it does, please try to track it down
(many hands make light work) or at least try to reproduce it
as simply as possible, and describe how to do that.

Without DEVT_FASCIST I belive this patch is a no-op.

Stylistic/posixoid comments about the userland view of the <sys/*.h>
files welcome now, from userland they now contain the end result.

Next planned step: make all dev_t's refer to the same devsw[] which
means convert BLK's to CHR's at the perimeter of the vnodes and
other places where they enter the game (bootdev, mknod, sysctl).


# 14910508 09-May-1999 Poul-Henning Kamp <phk@FreeBSD.org>

Make minor, major and makedev inline functions so we gain type checking
and prevent compile time creation of dev_t's from happening again.


# 8aef1712 27-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Fix warnings in preparation for adding -Wall -Wcast-qual to the
kernel compile


# b28536d5 27-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

Added c_caddr_t: const char * version of the char * caddr_t, for
use in -Wall / -Wcast-qual fixes.


# 1c7c3c6a 21-Jan-1999 Matthew Dillon <dillon@FreeBSD.org>

This is a rather large commit that encompasses the new swapper,
changes to the VM system to support the new swapper, VM bug
fixes, several VM optimizations, and some additional revamping of the
VM code. The specific bug fixes will be documented with additional
forced commits. This commit is somewhat rough in regards to code
cleanup issues.

Reviewed by: "John S. Dyson" <root@dyson.iquest.net>, "David Greenman" <dg@root.com>


# 8252a465 18-Dec-1998 Dmitrij Tejblum <dt@FreeBSD.org>

Little reorganization:
- created internal names for fixed-size integral types, like __int32_t. They
will be used to make several headers self-sufficient.
- <stdlib.h> don't include <machine/types.h> anymore.
- created <sys/inttypes.h>, which can be used as <inttypes.h>.
- declaration of uoff_t and ufs_daddr_t moved to <sys/types.h>.

Reviewed by: bde


# ecbb00a2 07-Jun-1998 Doug Rabson <dfr@FreeBSD.org>

This commit fixes various 64bit portability problems required for
FreeBSD/alpha. The most significant item is to change the command
argument to ioctl functions from int to u_long. This change brings us
inline with various other BSD versions. Driver writers may like to
use (__FreeBSD_version == 300003) to detect this change.

The prototype FreeBSD/alpha machdep will follow in a couple of days
time.


# 7be755be 23-Feb-1998 Bruce Evans <bde@FreeBSD.org>

MF22: removed duplicate #include of <sys.cdefs.h> and fixed comments about
the main #include of it.

Fixed disordering of _BSD_CLOCKID_T.

Removed forward declarations of "common" structs. The declarations are
now made closer to where they are used.


# eb794faa 07-Jan-1998 Alexander Langer <alex@FreeBSD.org>

Define integer types added by POSIX.1g. We already had int8_t, int16_t,
and int32_t -- this adds their unsigned counterparts uint8_t, uint16_t,
and uint32_t. Bruce has noted that C9x also defines these types (in a
different file), so this may have to be revisited with some ifdefs at a
later date.

Reviewed by: bde


# 7167d5b0 30-Dec-1997 Alexander Langer <alex@FreeBSD.org>

Convert caddr_t --> void * for sys/mman.h functions.

mlock, mmap, mprotect, msync, munlock, and munmap are defined by
POSIX as taking void *. The const modifier has been added to
mlock, munlock, and mprotect as the standard dictates.

minherit comes from OpenBSD and has been updated to conform with
their recent change to void *.

madvise and mincore are not defined by POSIX, but their arguments
have been modified to be consistent with the POSIX-defined functions.
mincore takes a const pointer, but madvise does not due to the
MADV_FREE case.

Discussed with: bde


# ee68b83f 08-May-1997 Peter Wemm <peter@FreeBSD.org>

Add posix-style clock and timer types (clockid_t and timer_t)


# fc632680 13-Apr-1997 Bruce Evans <bde@FreeBSD.org>

#ifdef'ed the declaration of lseek() so that -Wredundant-decls doesn't
cause noise.

Duplicated the lseek() redeclaration hack for all functions involving
off_t's (ftruncate(), mmap() and truncate()) to help broken programs
work.


# 61d85639 13-Apr-1997 Bruce Evans <bde@FreeBSD.org>

Moved #include of <sys/cdefs.h> earlier so that __signed in
<machine/types.h> gets redefined in the non-GNU and non-ANSI cases.
Since this hasn't caused problems, there must be no one actually
benefitting from the obfuscations supported by <sys/cdefs.h>.
`make CC="cc -traditional"' in /usr/src/bin shows the same. Almost
everything is broken in essentially the same way - `const' is used
in strings before <sys/cdefs.h> is included, so `const' is not
#defined away until after it is used.

Fixed some style bugs.


# 6875d254 22-Feb-1997 Peter Wemm <peter@FreeBSD.org>

Back out part 1 of the MCFH that changed $Id$ to $FreeBSD$. We are not
ready for it yet.


# faad6f1e 21-Feb-1997 Andrey A. Chernov <ache@FreeBSD.org>

Increase FD_SETSIZE back to 1024, select code fixed now


# a859cfce 15-Feb-1997 Andrey A. Chernov <ache@FreeBSD.org>

Back ut FD_SETSIZE increasing until related kernel issues will be resolved


# acc24279 15-Feb-1997 Andrey A. Chernov <ache@FreeBSD.org>

Bump default FD_SETSIZE from 256 to 1024 as many modern
systems do nowdays (like SunOs 5.5.1 f.e.)
256 is too small under real network load


# ec0c5f69 30-Jan-1997 Satoshi Asami <asami@FreeBSD.org>

Change space to tab.

Pointed out by: bde (this is only one of the four, though)


# 1130b656 14-Jan-1997 Jordan K. Hubbard <jkh@FreeBSD.org>

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 7431589c 05-Jan-1997 David Nugent <davidn@FreeBSD.org>

Move typedef for rlim_t into sys/types.h (as per NetBSD).


# 05ab86ce 30-Apr-1996 Bruce Evans <bde@FreeBSD.org>

Removed gratuitous differences from Lite2.

Cleaned up vm typedefs.


# 1d252fa4 29-Apr-1996 Poul-Henning Kamp <phk@FreeBSD.org>

Don't include <machine/ansi.h> twice.

Reviewed by: phk
Submitted by: "Philippe Charnier" <charnier@lirmm.fr>


# 02e2c406 11-Mar-1996 Peter Wemm <peter@FreeBSD.org>

Import 4.4BSD-Lite2 onto the vendor branch, note that in the kernel, all
files are off the vendor branch, so this should not change anything.

A "U" marker generally means that the file was not changed in between
the 4.4Lite and Lite-2 releases, and does not need a merge. "C" generally
means that there was a change.
[new sys/syscallargs.h file, to be "cvs rm"ed]


# 01af853d 10-Mar-1996 Jeffrey Hsu <hsu@FreeBSD.org>

Merge in Lite2: use fixed-width types.
Did not accept changes to types of off_t and pid_t. See
<machine/ansi.h> for explanation.
Did not accept changes to major and minor macros upon bde's review.
These changes are unnecessary.
Did not accept type change to fd_mask upon bde's review.
This change is unnecessary as long as sizeof(fd_mask) divides FD_SETSIZE.
Reviewed by: davidg & bde


# 21503ddf 14-Dec-1995 Peter Wemm <peter@FreeBSD.org>

move typedef for key_t from sys/ipc.h to sys/types.h, as suggested in the
comment in ipc.h. This is so that prototypes for the sysv ipc functions
can be processed without having to #include <sys/ipc.h> in everything..


# 5ad9d5a7 09-Dec-1995 Bruce Evans <bde@FreeBSD.org>

Moved the declaration of boolean_t from <vm/vm_param.h> to
<sys/types.h> (if KERNEL is defined). This allows removing bogus
dependencies on vm stuff in several places (e.g., ddb) and stops
<vm_param.h> from depending on <vm_param.h>

Added declaration of boolean_t to <vm/vm.h> (if KERNEL is not
defined). It never belonged in <vm/vm_param.h>. Unfortunately,
it is required for some vm headers that are included by applications.

Deleted declarations of TRUE and FALSE from <vm/vm_param.h>. They
are defined in <sys/param.h> if KERNEL is defined and we'll soon
find out if any applications depend on them being defined in a vm
header.


# 0ff89d5b 05-Dec-1995 Bruce Evans <bde@FreeBSD.org>

Moved the declaration of vm_object_t from <vm/vm.h> to <sys/types.h>
(if KERNEL is defined). This allows removing the #includes of vm
stuff in vnode_if.h, which will speed up the compilation of LINT by
about 5%.


# 200db834 27-Jun-1995 Bruce Evans <bde@FreeBSD.org>

Use the new machine-dependent definitions of _BSD_OFF_T_ and
_BSD_PID_T_ to declare off_t and pid_t.


# 13594380 25-Sep-1994 David Greenman <dg@FreeBSD.org>

Extended minor number to include bits 16-31. It was done this way rather
than making it 16bit and extending the major to 16bit because doing that
would have caused problems with existing filesystems /dev entries. This
change should have no apparant side effects.
This change is needed for the DOS partition re-work and other things.

Submitted by: Bruce Evans


# 5e2f9610 16-Sep-1994 Paul Richards <paul@FreeBSD.org>

Moved include of cdefs.h outside of ifndef KERNEL so it always
gets included.


# 3c4dd356 02-Aug-1994 David Greenman <dg@FreeBSD.org>

Added $Id$


# df8bae1d 24-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Kernel Sources