1 .\" Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 .Nm bswap16 , bswap32 , bswap64 ,
32 .Nm be16toh , be32toh , be64toh , htobe16 , htobe32 , htobe64 ,
33 .Nm htole16 , htole32 , htole64 , le16toh , le32toh , le64toh ,
34 .Nm be16enc , be16dec , be32enc , be32dec , be64enc , be64dec ,
35 .Nm le16enc , le16dec , le32enc , le32dec , le64enc , le64dec
36 .Nd byte order operations
40 .Fn bswap16 "uint16_t int16"
42 .Fn bswap32 "uint32_t int32"
44 .Fn bswap64 "uint64_t int64"
46 .Fn be16toh "uint16_t big16"
48 .Fn be32toh "uint32_t big32"
50 .Fn be64toh "uint64_t big64"
52 .Fn htobe16 "uint16_t host16"
54 .Fn htobe32 "uint32_t host32"
56 .Fn htobe64 "uint64_t host64"
58 .Fn htole16 "uint16_t host16"
60 .Fn htole32 "uint32_t host32"
62 .Fn htole64 "uint64_t host64"
64 .Fn le16toh "uint16_t little16"
66 .Fn le32toh "uint32_t little32"
68 .Fn le64toh "uint64_t little64"
70 .Fn be16dec "const void *"
72 .Fn be32dec "const void *"
74 .Fn be64dec "const void *"
76 .Fn le16dec "const void *"
78 .Fn le32dec "const void *"
80 .Fn le64dec "const void *"
82 .Fn be16enc "void *" uint16_t
84 .Fn be32enc "void *" uint32_t
86 .Fn be64enc "void *" uint64_t
88 .Fn le16enc "void *" uint16_t
90 .Fn le32enc "void *" uint32_t
92 .Fn le64enc "void *" uint64_t
99 functions return a byte order swapped integer.
100 On big endian systems, the number is converted to little endian byte order.
101 On little endian systems, the number is converted to big endian byte order.
108 functions return a big endian byte ordered integer
109 converted to the system's native byte order.
110 The return value will be the same as the argument on big endian systems.
117 functions return a little endian byte ordered integer
118 converted to the system's native byte order.
119 The return value will be the same as the argument on little endian systems.
126 functions return a integer in the system's native
127 byte order converted to big endian byte order.
128 The return value will be the same as the argument on big endian systems.
135 functions return a integer in the system's native
136 byte order converted to little endian byte order.
137 The return value will be the same as the argument on little endian systems.
153 functions encode and decode integers to/from byte strings on any alignment
154 in big/little endian format.
162 functions first appeared in
164 and were originally developed by the
168 The encode/decode functions first appeared in