xref: /netbsd/lib/libc/gen/bswap.3 (revision bf9ec67e)
1.\" $NetBSD: bswap.3,v 1.6 2002/02/07 07:00:10 ross Exp $
2.\"
3.\" Copyright (c) 1998 Manuel Bouyer.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\"    must display the following acknowledgement:
15.\"	This product includes software developed by the University of
16.\"	California, Berkeley and its contributors.
17.\" 4. Neither the name of the University nor the names of its contributors
18.\"    may be used to endorse or promote products derived from this software
19.\"    without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29.\" INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31.\"
32.Dd March 17, 1998
33.Dt BSWAP 3
34.Os
35.Sh NAME
36.Nm bswap16 ,
37.Nm bswap32 ,
38.Nm bswap64
39.Nd byte-order swapping functions
40.Sh LIBRARY
41.Lb libc
42.Sh SYNOPSIS
43.Fd #include \*[Lt]sys/types.h\*[Gt]
44.Fd #include \*[Lt]machine/bswap.h\*[Gt]
45.Ft u_int16_t
46.Fn bswap16 "u_int16_t"
47.Ft u_int32_t
48.Fn bswap32 "u_int32_t"
49.Ft u_int64_t
50.Fn bswap64 "u_int64_t"
51.Sh DESCRIPTION
52The
53.Fn bswap16 ,
54.Fn bswap32 ,
55and
56.Fn bswap64
57functions return the value of their argument with the bytes inverted.
58They can be used to convert 16, 32 or 64 bits integers from little to big
59endian, or vice-versa.
60.Sh SEE ALSO
61.Xr byteorder 3
62