1 .\" $NetBSD: byteorder.9,v 1.3 2009/04/10 23:30:57 tsutsui Exp $
3 .\" Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" $FreeBSD: src/share/man/man9/byteorder.9,v 1.6 2003/05/21 17:32:55 ru Exp $
60 .Nd byte order operations
64 .Fn bswap16 "uint16_t int16"
66 .Fn bswap32 "uint32_t int32"
68 .Fn bswap64 "uint64_t int64"
70 .Fn be16toh "uint16_t big16"
72 .Fn be32toh "uint32_t big32"
74 .Fn be64toh "uint64_t big64"
76 .Fn htobe16 "uint16_t host16"
78 .Fn htobe32 "uint32_t host32"
80 .Fn htobe64 "uint64_t host64"
82 .Fn htole16 "uint16_t host16"
84 .Fn htole32 "uint32_t host32"
86 .Fn htole64 "uint64_t host64"
88 .Fn le16toh "uint16_t little16"
90 .Fn le32toh "uint32_t little32"
92 .Fn le64toh "uint64_t little64"
94 .Fn be16dec "const void *stream"
96 .Fn be32dec "const void *stream"
98 .Fn be64dec "const void *stream"
100 .Fn le16dec "const void *stream"
102 .Fn le32dec "const void *stream"
104 .Fn le64dec "const void *stream"
106 .Fn be16enc "void *stream" "uint16_t host16"
108 .Fn be32enc "void *stream" "uint32_t host32"
110 .Fn be64enc "void *stream" "uint64_t host64"
112 .Fn le16enc "void *stream" "uint16_t host16"
114 .Fn le32enc "void *stream" "uint32_t host32"
116 .Fn le64enc "void *stream" "uint64_t host64"
123 functions return a byte order swapped integer.
124 On big endian systems, the number is converted to little endian byte order.
125 On little endian systems, the number is converted to big endian byte order.
132 functions return a big endian byte ordered integer
133 converted to the system's native byte order.
134 The return value will be the same as the argument on big endian systems.
141 functions return a little endian byte ordered integer
142 converted to the system's native byte order.
143 The return value will be the same as the argument on little endian systems.
150 functions return an integer in the system's native
151 byte order converted to big endian byte order.
152 The return value will be the same as the argument on big endian systems.
159 functions return an integer in the system's native
160 byte order converted to little endian byte order.
161 The return value will be the same as the argument on little endian systems.
177 functions encode and decode integers to/from octet stream
178 on any alignment in big/little endian format.
186 functions first appeared in
188 These functions were introduced to handle PCI bus master devices which assumed
189 host's memory used to pass integer parameters via DMA transfer was
190 always little endian even on big endian systems.
192 The encode/decode functions first appeared in
200 This manual page was written by
201 .An Mike Barcroft Aq mike@FreeBSD.org .