| 1 |
'\" t |
| 2 |
.\" Copyright 1993, David Metcalfe <[email protected]> |
| 3 |
.\" Copyright, the authors of the Linux man-pages project |
| 4 |
.\" |
| 5 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 6 |
.\" |
| 7 |
.TH swab 3 2026-02-08 "Linux man-pages 6.18" |
| 8 |
.SH NAME |
| 9 |
swab \- swap adjacent bytes |
| 10 |
.SH LIBRARY |
| 11 |
Standard C library |
| 12 |
.RI ( libc ,\~ \-lc ) |
| 13 |
.SH SYNOPSIS |
| 14 |
.nf |
| 15 |
.BR "#define _XOPEN_SOURCE" " /* See feature_test_macros(7) */" |
| 16 |
.B #include <unistd.h> |
| 17 |
.P |
| 18 |
.BR "void swab(" "ssize_t n;" |
| 19 |
.BI " const void " from "[restrict " n "], void " to "[restrict " n ], |
| 20 |
.BI " ssize_t " n ); |
| 21 |
.fi |
| 22 |
.SH DESCRIPTION |
| 23 |
The |
| 24 |
.BR swab () |
| 25 |
function copies |
| 26 |
.I n |
| 27 |
bytes from the array pointed |
| 28 |
to by |
| 29 |
.I from |
| 30 |
to the array pointed to by |
| 31 |
.IR to , |
| 32 |
exchanging |
| 33 |
adjacent even and odd bytes. |
| 34 |
This function is used to exchange data |
| 35 |
between machines that have different low/high byte ordering. |
| 36 |
.P |
| 37 |
This function does nothing when |
| 38 |
.I n |
| 39 |
is negative. |
| 40 |
When |
| 41 |
.I n |
| 42 |
is positive and odd, it handles |
| 43 |
.I n\-1 |
| 44 |
bytes |
| 45 |
as above, and does something unspecified with the last byte. |
| 46 |
(In other words, |
| 47 |
.I n |
| 48 |
should be even.) |
| 49 |
.SH RETURN VALUE |
| 50 |
The |
| 51 |
.BR swab () |
| 52 |
function returns no value. |
| 53 |
.SH ATTRIBUTES |
| 54 |
For an explanation of the terms used in this section, see |
| 55 |
.BR attributes (7). |
| 56 |
.TS |
| 57 |
allbox; |
| 58 |
lbx lb lb |
| 59 |
l l l. |
| 60 |
Interface Attribute Value |
| 61 |
T{ |
| 62 |
.na |
| 63 |
.nh |
| 64 |
.BR swab () |
| 65 |
T} Thread safety MT-Safe |
| 66 |
.TE |
| 67 |
.SH STANDARDS |
| 68 |
POSIX.1-2008. |
| 69 |
.SH HISTORY |
| 70 |
POSIX.1-2001, SVr4, 4.3BSD. |
| 71 |
.SH SEE ALSO |
| 72 |
.BR bstring (3) |