1swab(3)                    Library Functions Manual                    swab(3)
2
3
4

NAME

6       swab - swap adjacent bytes
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #define _XOPEN_SOURCE       /* See feature_test_macros(7) */
13       #include <unistd.h>
14
15       void swab(const void from[restrict .n], void to[restrict .n],
16                 ssize_t n);
17

DESCRIPTION

19       The swab() function copies n bytes from the array pointed to by from to
20       the array pointed to by to, exchanging adjacent  even  and  odd  bytes.
21       This  function is used to exchange data between machines that have dif‐
22       ferent low/high byte ordering.
23
24       This function does nothing when n is negative.  When n is positive  and
25       odd, it handles n-1 bytes as above, and does something unspecified with
26       the last byte.  (In other words, n should be even.)
27

RETURN VALUE

29       The swab() function returns no value.
30

ATTRIBUTES

32       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
33       tributes(7).
34
35       ┌────────────────────────────────────────────┬───────────────┬─────────┐
36Interface                                   Attribute     Value   
37       ├────────────────────────────────────────────┼───────────────┼─────────┤
38swab()                                      │ Thread safety │ MT-Safe │
39       └────────────────────────────────────────────┴───────────────┴─────────┘
40

STANDARDS

42       POSIX.1-2008.
43

HISTORY

45       POSIX.1-2001, SVr4, 4.3BSD.
46

SEE ALSO

48       bstring(3)
49
50
51
52Linux man-pages 6.05              2023-07-20                           swab(3)
Impressum