History log of /freebsd-current/sys/i386/include/endian.h
Revision Date Author Comments
# 71625ec9 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c comment pattern

Remove /^/[*/]\s*\$FreeBSD\$.*\n/


# 95b1d16d 28-Feb-2012 Tijl Coosemans <tijl@FreeBSD.org>

Copy amd64 endian.h to x86 and merge with i386 endian.h. Replace
amd64/i386/pc98 endian.h with stubs.

In __bswap64_const(x) the conflict between 0xffUL and 0xffULL has been
resolved by reimplementing the macro in terms of __bswap32(x). As a side
effect __bswap64_var(x) is now implemented using two bswap instructions on
i386 and should be much faster. __bswap32_const(x) has been reimplemented
in terms of __bswap16(x) for consistency.


# e4cd31dd 21-Mar-2011 Jeff Roberson <jeff@FreeBSD.org>

- Merge changes to the base system to support OFED. These include
a wider arg2 for sysctl, updates to vlan code, IFT_INFINIBAND,
and other miscellaneous small features.


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


# 2c97d32a 08-Apr-2009 Ed Schouten <ed@FreeBSD.org>

Also remove the unused __word_swap_int*() macros.

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>


# 17cfde3d 08-Apr-2009 Ed Schouten <ed@FreeBSD.org>

Implement __bswap16() without using inline assembly.

Most compilers nowadays (including GCC) are smart enough to know what's
going on and generate more efficient code anyway.

Submitted by: Christoph Mallon <christoph.mallon@gmx.de>


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

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


# a5f50ef9 02-Mar-2005 Joerg Wunsch <joerg@FreeBSD.org>

netchild's mega-patch to isolate compiler dependencies into a central
place.

This moves the dependency on GCC's and other compiler's features into
the central sys/cdefs.h file, while the individual source files can
then refer to #ifdef __COMPILER_FEATURE_FOO where they by now used to
refer to #if __GNUC__ > 3.1415 && __BARC__ <= 42.

By now, GCC and ICC (the Intel compiler) have been actively tested on
IA32 platforms by netchild. Extension to other compilers is supposed
to be possible, of course.

Submitted by: netchild
Reviewed by: various developers on arch@, some time ago


# 2d68e3fb 16-Nov-2004 John Baldwin <jhb@FreeBSD.org>

Initiate deorbit burn sequence for 80386 support in FreeBSD: Remove
80386 (I386_CPU) support from the kernel.


# f36cfd49 07-Apr-2004 Warner Losh <imp@FreeBSD.org>

Remove advertising clause from University of California Regent's
license, per letter dated July 22, 1999 and email from Peter Wemm,
Alan Cox and Robert Watson.

Approved by: core, peter, alc, rwatson


# a122cca9 12-Mar-2004 Tom Rhodes <trhodes@FreeBSD.org>

These are changes to allow to use the Intel C/C++ compiler (lang/icc)
to build the kernel. It doesn't affect the operation if gcc.

Most of the changes are just adding __INTEL_COMPILER to #ifdef's, as
icc v8 may define __GNUC__ some parts may look strange but are
necessary.

Additional changes:
- in_cksum.[ch]:
* use a generic C version instead of the assembly version in the !gcc
case (ASM code breaks with the optimizations icc does)
-> no bad checksums with an icc compiled kernel
Help from: andre, grehan, das
Stolen from: alpha version via ppc version
The entire checksum code should IMHO be replaced with the DragonFly
version (because it isn't guaranteed future revisions of gcc will
include similar optimizations) as in:
---snip---
Revision Changes Path
1.12 +1 -0 src/sys/conf/files.i386
1.4 +142 -558 src/sys/i386/i386/in_cksum.c
1.5 +33 -69 src/sys/i386/include/in_cksum.h
1.5 +2 -0 src/sys/netinet/igmp.c
1.6 +0 -1 src/sys/netinet/in.h
1.6 +2 -0 src/sys/netinet/ip_icmp.c

1.4 +3 -4 src/contrib/ipfilter/ip_compat.h
1.3 +1 -2 src/sbin/natd/icmp.c
1.4 +0 -1 src/sbin/natd/natd.c
1.48 +1 -0 src/sys/conf/files
1.2 +0 -1 src/sys/conf/files.amd64
1.13 +0 -1 src/sys/conf/files.i386
1.5 +0 -1 src/sys/conf/files.pc98
1.7 +1 -1 src/sys/contrib/ipfilter/netinet/fil.c
1.10 +2 -3 src/sys/contrib/ipfilter/netinet/ip_compat.h
1.10 +1 -1 src/sys/contrib/ipfilter/netinet/ip_fil.c
1.7 +1 -1 src/sys/dev/netif/txp/if_txp.c
1.7 +1 -1 src/sys/net/ip_mroute/ip_mroute.c
1.7 +1 -2 src/sys/net/ipfw/ip_fw2.c
1.6 +1 -2 src/sys/netinet/igmp.c
1.4 +158 -116 src/sys/netinet/in_cksum.c
1.6 +1 -1 src/sys/netinet/ip_gre.c
1.7 +1 -2 src/sys/netinet/ip_icmp.c
1.10 +1 -1 src/sys/netinet/ip_input.c
1.10 +1 -2 src/sys/netinet/ip_output.c
1.13 +1 -2 src/sys/netinet/tcp_input.c
1.9 +1 -2 src/sys/netinet/tcp_output.c
1.10 +1 -1 src/sys/netinet/tcp_subr.c
1.10 +1 -1 src/sys/netinet/tcp_syncache.c
1.9 +1 -2 src/sys/netinet/udp_usrreq.c

1.5 +1 -2 src/sys/netinet6/ipsec.c
1.5 +1 -2 src/sys/netproto/ipsec/ipsec.c
1.5 +1 -1 src/sys/netproto/ipsec/ipsec_input.c
1.4 +1 -2 src/sys/netproto/ipsec/ipsec_output.c

and finally remove
sys/i386/i386 in_cksum.c
sys/i386/include in_cksum.h
---snip---
- endian.h:
* DTRT in C++ mode
- quad.h:
* we don't use gcc v1 anymore, remove support for it
Suggested by: bde (long ago)
- assym.h:
* avoid zero-length arrays (remove dependency on a gcc specific
feature)
This change changes the contents of the object file, but as it's
only used to generate some values for a header, and the generator
knows how to handle this, there's no impact in the gcc case.
Explained by: bde
Submitted by: Marius Strobl <marius@alchemy.franken.de>
- aicasm.c:
* minor change to teach it about the way icc spells "-nostdinc"
Not approved by: gibbs (no reply to my mail)
- bump __FreeBSD_version (lang/icc needs to know about the changes)

Incarnations of this patch survive gcc compiles since a loooong time,
I use it on my desktop. An icc compiled kernel works since Nov. 2003
(exceptions: snd_* if used as modules), it survives a build of the
entire ports collection with icc.

Parts of this commit contains suggestions or submissions from
Marius Strobl <marius@alchemy.franken.de>.

Reviewed by: -arch
Submitted by: netchild


# 795a3f52 22-Sep-2003 Peter Wemm <peter@FreeBSD.org>

Microoptimization to allow the compiler to evaluate ntohl() etc on
known constants at compile time rather than at run time. We have a number
of nasty hacks around the place to cache ntohl() of constants (eg: nfs).
This change allows the compiler to compile-time evaluate ntohl(1) as
0x01000000 rather than having to emit assembler code to do it. This
has other smaller flow-on effects because the compiler can see that
ntohl(constant) itself has a constant value now and can propagate the
compile time evaluation.

Obtained from: Ideas from NetBSD and Linux, and some code from NetBSD


# a98a5f06 03-Aug-2003 David E. O'Brien <obrien@FreeBSD.org>

Style sync.


# c0d4804d 22-Sep-2002 Mike Barcroft <mike@FreeBSD.org>

Be careful not to define GCC-specific optimizations in the non-GCC
case.


# 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


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

Add manifest constants: _LITTLE_ENDIAN, _BIG_ENDIAN, _PDP_ENDIAN, and
_BYTE_ORDER. These are far more useful than their non-underscored
equivalents as these can be used in restricted namespace environments.
Mark the non-underscored variants as deprecated.


# d846855d 09-Mar-2002 Mike Barcroft <mike@FreeBSD.org>

o Don't require long long support in bswap64() functions.
o In i386's <machine/endian.h>, macros have some advantages over
inlines, so change some inlines to macros.
o In i386's <machine/endian.h>, ungarbage collect word_swap_int()
(previously __uint16_swap_uint32), it has some uses on i386's with
PDP endianness.

Submitted by: bde

o Move a comment up in <machine/endian.h> that was accidentially moved
down a few revisions ago.
o Reenable userland's use of optimized inline-asm versions of
byteorder(3) functions.
o Fix ordering of prototypes vs. redefinition of byteorder(3)
functions, so that the non-GCC (libc asm) case has proper
prototypes.
o Add proper prototypes for byteorder(3) functions in <sys/param.h>.
o Prevent redundant duplicate prototypes by making use of the
_BYTEORDER_PROTOTYPED define.
o Move the bswap16(), bswap32(), bswap64() C functions into MD space
for platforms in which asm versions don't exist. This significantly
reduces the complexity of some things at the cost of duplicate code.

Reviewed by: bde


# 90ce56c2 27-Feb-2002 Thomas Moestl <tmm@FreeBSD.org>

Add the following functions/macros to support byte order conversions and
device drivers for bus system with other endinesses than the CPU (using
interfaces compatible to NetBSD):

- bwap16() and bswap32(). These have optimized implementations on some
architectures; for those that don't, there exist generic implementations.
- macros to convert from a certain byte order to host byte order and vice
versa, using a naming scheme like le16toh(), htole16().
These are implemented using the bswap functions.
- stream bus space access functions, which do not perform a byte order
conversion (while the normal access functions would if the bus endianess
differs from the CPU endianess).

htons(), htonl(), ntohs() and ntohl() are implemented using the new
functions above for kernel usage. None of the above interfaces is currently
exported to user land.

Make use of the new functions in a few places where local implementations
of the same functionality existed.

Reviewed by: mike, bde
Tested on alpha by: mike


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

Add C++ support.


# 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


# 3f9a462f 18-Dec-2001 John Baldwin <jhb@FreeBSD.org>

Various assembly fixes mostly in the form of using the "+" modifier for
output operands to mark them as both input and output rather than listing
operands twice.

Reviewed by: bde


# c6010b66 28-Nov-2001 John Baldwin <jhb@FreeBSD.org>

Whitespace fixes so thre 386 versoion of __uint8_swap_uint32 is easier to
read.


# 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


# b4edbce0 14-Apr-2001 Mark Murray <markm@FreeBSD.org>

Back out wrapping the asm ... ; bits in #ifndef lint macros. There
are some good reasons for not doing this, even if the linting of
the code breaks.

1) If lint were ever to understand the stuff inside the macros,
that would break the checks.

2) There are ways to use __GNUC__ to exclude overly specific
code.

3) (Not yet practical) Lint(1) needs to properlyu understand
all of te code we actually run.

Complained about by: bde
Education by: jake, jhb, eivind


# c13d191d 13-Apr-2001 Mark Murray <markm@FreeBSD.org>

Make this more lint-friendly. This file seems to be invoked in just
about any .c file that includes a .h, and lint produces copious
whining because of the asm ...; stuff.


# f88eb011 06-Mar-2001 David Malone <dwmalone@FreeBSD.org>

Spell what was originally "unsigned long" as "unsigned long" again,
to cut down on some compiler warnings caused by lexically mismatched
types.

Reviewed by: bde


# 27c63589 28-Oct-2000 Bruce Evans <bde@FreeBSD.org>

Quick fix for namespace problems which broke many ports. Spell
uint16_t as "unsigned short" like it used to be and uint32_t as
"unsigned int" not like it used to be (was: "unsigned long").


# 0910581f 16-Oct-2000 Brian Somers <brian@FreeBSD.org>

Move __uint16_swap_uint32, __uint8_swap_uint32 and
__uint8_swap_uint16 inside __GNUC__.

Reviewed by: bde


# abf94dbd 15-Oct-2000 Brian Somers <brian@FreeBSD.org>

Remove namespace polution (x -> __x) introduced in the last
revision.

Pointed out by: bde


# d6c1f639 14-Oct-2000 Brian Somers <brian@FreeBSD.org>

Redefine __word_swap_long, __byte_swap_long and __byte_swap_word
as inline functions, renaming them to __uint16_swap_uint32,
__uint8_swap_uint32 and __uint8_swap_uint16.

Doing it properly suggested by: msmith
Reviewed by: msmith


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


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

$Id$ -> $FreeBSD$


# f3086365 31-Aug-1997 Bruce Evans <bde@FreeBSD.org>

Put I*86_CPU options in opt_global.h and don't #include "opt_cpu.h"
centrally.


# 8bd28861 20-Apr-1997 Bruce Evans <bde@FreeBSD.org>

Fixed linting of and compilation of the gcc byte-swapping macros
properly. Simply don't use the gcc macros if we're not gcc, and
declare prototypes for the byte-swapping functions in case the
macro versions are not used. The previous fix was wrong and broke
libpcap, which abuses -Dlint.

Don't pollute the namespace if _POSIX_SOURCE is defined. This is
broken - it makes almost everything in <machine/endian.h> inaccessible
if _POSIX_SOURCE is defined, yet <machine/endian.h> is not a POSIX
header. Other systems don't do it any better.

Removed always-false `BYTE_ORDER == BIG_ENDIAN' ifdef.
Obtained from: partly from Lite(2?) and NetBSD


# 55e1a055 16-Mar-1997 Nate Williams <nate@FreeBSD.org>

Don't try to lint the gcc extension byte-swapping macros.

Submitted by: Eivind Eklund <eivind@dimaga.com>


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


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


# 807cf400 06-Dec-1996 John Dyson <dyson@FreeBSD.org>

Make LKM's build again. I have added the allegedly broken
ACTUALLY_LKM_NOT_KERNEL until the real fix comes through. Whatever
flag that is used to indicate building LKMs will have be be substituted
in the future. This allows proper selection of the usage of the
efficient, single instruction in the kernel, but alas, doesn't allow
for use in userland or LKMs :-(. Them's the breaks!!!


# 66f61b82 06-Dec-1996 John Dyson <dyson@FreeBSD.org>

Change endian.h so that when a kernel is compiled without I386_CPU, and
with one of the following (I486_CPU,I586_CPU,I686_CPU) so it can take
advantage of the very quick bswap insn. This keeps LKMs from being
built to take advantage of the insn, but also makes sure that the LKMs
can be run on all CPUs. (The LKMs don't pick up the CPU options :-( ).


# 6f235fb2 29-Nov-1996 John Dyson <dyson@FreeBSD.org>

Relax the constraints on the bswap opcode (it works on non-byte
registers.) Also clean up some namespace pollution, and remove
gcc-1 support (nothing really works with it anymore anyway.)
Submitted by: Bruce Evans <bde@freebsd.org> and me.


# f8b40814 29-Nov-1996 John Dyson <dyson@FreeBSD.org>

Support the appropriate use of bswap instruction on non-I386 builds.
Per Wayne Scott of Intel, the old sequence took 20cycles!!! on a P6.
Another nice side-benefit is that the kernel is about 3K smaller!!!
Submitted by: Wayne Scott <wscott@ichips.intel.com>


# bbabe47b 21-Oct-1996 Nate Williams <nate@FreeBSD.org>

When compiling with '-Wall -pedantic', the byte swapping macros gave the
following warning:
warning: ANSI C forbids braced-groups within expressions

Adding __extension__ before the statement-expression seems to work right.

Submitted by: bde (a *long* time ago)


# bcbd3805 12-Feb-1995 Jordan K. Hubbard <jkh@FreeBSD.org>

Rename the local variable used by various macros outside the user's
namespace.
Reported-By: "Philippe Charnier" <charnier@lirmm.fr>


# 20dcc37d 10-Sep-1994 Geoff Rehmet <csgr@FreeBSD.org>

Change "asm" to "__asm" - makes it possible to compile code with
"-ansi" compiler switch set.


# 90d795a1 18-Dec-1993 Andrew Moore <alm@FreeBSD.org>

adding libc/quad:
added _QUAD_HIGH/LOW
added (U_)QUAD_MAX/MIN
(from NetBSD)


# 6e393973 07-Nov-1993 Garrett Wollman <wollman@FreeBSD.org>

Made all header files idempotent and moved incorrect common data from
headers into a related source file. Added cons.h as first step towards
moving i386/i386/cons.h to machine/cons.h where it belongs.


# 34a8ed1b 16-Oct-1993 Rodney W. Grimes <rgrimes@FreeBSD.org>

Removed all patch kit headers, sccsid and rcsid strings, put $Id$ in, some
minor cleanup. Added $Id$ to files that did not have any version info, etc


# 5b81b6b3 12-Jun-1993 Rodney W. Grimes <rgrimes@FreeBSD.org>

Initial import, 0.1 + pk 0.2.4-B1