History log of /freebsd-current/lib/libc/string/swab.c
Revision Date Author Comments
# bac2eea1 22-Apr-2024 rilysh <nightquick@proton.me>

swab.c(libc): use a simplified version of byte swapping

This version of swab function simplifies the logic of swapping adjacent
bytes. Previous version of swab() used an arbitrary unrolling, which was
relevant back in the day but unnecessary for modern compilers, as if the
input size is known at compile time, they can do it automatically.

This version of swab() is inspired by musl.
A similar version can be found at: https://github.com/openbsd/src/blob/master/lib/libc/string/swab.c

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1086


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

lib: 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


# 559a218c 01-Nov-2023 Warner Losh <imp@FreeBSD.org>

libc: Purge unneeded cdefs.h

These sys/cdefs.h are not needed. Purge them. They are mostly left-over
from the $FreeBSD$ removal. A few in libc are still required for macros
that cdefs.h defines. Keep those.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D42385


# 1d386b48 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 70164d95 23-Jul-2021 Alfonso <gfunni234@gmail.com>

Fix truncation when ssize_t is larger than MAX_INT

Casting to int truncates size on some platforms, resulting swab not
copying all the data. Cast len to size_t to avoid right shifting a
signed value: we know here it's > 0, so we can safely cast it w/o losing
precision.

In addition, be more careful with signedness of char pointers and
temporaries. Downgrade tmp from unsigned long to unsigned char since
we're only reading and writing characters.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/516


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

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


# 3fb3b97c 28-May-2013 Ed Maste <emaste@FreeBSD.org>

Renumber clauses to reduce diffs to other versions

NetBSD, OpenBSD, and Android's Bionic number the clauses 1 through 3,
so follow suit to make comparison easier.


# 0a0c8e01 04-Mar-2012 Eitan Adler <eadler@FreeBSD.org>

POSIX mandates that swab do nothing when len < 0

PR: kern/140690
Submitted by: Jeremy Huddleston <jeremyhu@apple.com>
Approved by: cperciva
MFC after: 2 weeks


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


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


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

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


# c879ae35 08-Jan-2007 Warner Losh <imp@FreeBSD.org>

Per Regents of the University of Calfornia letter, remove advertising
clause.

# If I've done so improperly on a file, please let me know.


# 2f5cde3c 10-Dec-2004 Tom Rhodes <trhodes@FreeBSD.org>

According to the information on:
http://www.opengroup.org/onlinepubs/009695399/functions/swab.html
the prototype for swab() should be in <unistd.h> and not in <string.h>.
Move it, and update to match SUS. Leave the prototype in string.h for
now, for backwards compat.

PR: 74751
Submitted by: Craig Rodrigues <rodrigc@crodrigues.org>
Discussed with: das


# c9ab23ee 30-Aug-2002 Robert Drehmel <robert@FreeBSD.org>

- Convert the function definition to declare its arguments
in the ANSI-C format.
- Change the code a bit to hopefully save some cycles.
I.e. (simplified) change

a = b + 1;
while (--b & 0x7)
/* ... */
to
a = b;
for (; b & 0x7; b--)
/* ... */
and
while (--a >= 0)
/* ... */
to
for (; a > 0; a--)
/* ... */
- Equip two function arguments of swab() with the 'restrict'
type qualifier in form of the '__restrict' macro. This is
specified by POSIX.1-2001.


# 8fb3f3f6 21-Mar-2002 David E. O'Brien <obrien@FreeBSD.org>

Remove 'register' keyword.


# de5fe5d5 07-Nov-2001 David E. O'Brien <obrien@FreeBSD.org>

rcsid[]->__FBSDID


# 5864b79c 24-May-2001 David E. O'Brien <obrien@FreeBSD.org>

Make the rcsid and FreeBSD IDs more sane in the wcs* and wmem* files.
Do the same for the non-wcs*/wmem* files while I'm here.


# 58f0484f 26-May-1994 Rodney W. Grimes <rgrimes@FreeBSD.org>

BSD 4.4 Lite Lib Sources