1swab(3) Library Functions Manual swab(3)
2
3
4
6 swab - swap adjacent bytes
7
9 Standard C library (libc, -lc)
10
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
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
29 The swab() function returns no value.
30
32 For an explanation of the terms used in this section, see at‐
33 tributes(7).
34
35 ┌────────────────────────────────────────────┬───────────────┬─────────┐
36 │Interface │ Attribute │ Value │
37 ├────────────────────────────────────────────┼───────────────┼─────────┤
38 │swab() │ Thread safety │ MT-Safe │
39 └────────────────────────────────────────────┴───────────────┴─────────┘
40
42 POSIX.1-2008.
43
45 POSIX.1-2001, SVr4, 4.3BSD.
46
48 bstring(3)
49
50
51
52Linux man-pages 6.04 2023-03-30 swab(3)