- NetBSD Manual Pages
SWAB(3) NetBSD Library Functions Manual SWAB(3)
Powered by man-cgi (2021-06-01).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.
swab -- swap adjacent bytes
Standard C Library (libc, -lc)
swab(const void * restrict src, void * restrict dst, ssize_t len);
The function swab() copies len bytes from the location referenced by src
to the location referenced by dst, swapping adjacent bytes.
If len is negative or zero, swab() does nothing. If len is odd, swab()
copies len - 1 bytes and the disposition of the last byte is unspecified.
The swab() function conforms to IEEE Std 1003.1-2001 (``POSIX.1'').
A swab() function appeared in Version 7 AT&T UNIX. It was originally
documented to be ``useful for carrying binary data between PDP11's and
In NetBSD 6.0 the type of len was changed from size_t to ssize_t for
NetBSD 7.0 April 30, 2010 NetBSD 7.0