xref: /freebsd/share/man/man9/byteorder.9 (revision 8a1791edf44f041928e97c0b64c839a3b87e9068)
18a1791edSMike Barcroft.\" Copyright (c) 2002 Mike Barcroft <mike@FreeBSD.org>
28a1791edSMike Barcroft.\" All rights reserved.
38a1791edSMike Barcroft.\"
48a1791edSMike Barcroft.\" Redistribution and use in source and binary forms, with or without
58a1791edSMike Barcroft.\" modification, are permitted provided that the following conditions
68a1791edSMike Barcroft.\" are met:
78a1791edSMike Barcroft.\" 1. Redistributions of source code must retain the above copyright
88a1791edSMike Barcroft.\"    notice, this list of conditions and the following disclaimer.
98a1791edSMike Barcroft.\" 2. Redistributions in binary form must reproduce the above copyright
108a1791edSMike Barcroft.\"    notice, this list of conditions and the following disclaimer in the
118a1791edSMike Barcroft.\"    documentation and/or other materials provided with the distribution.
128a1791edSMike Barcroft.\"
138a1791edSMike Barcroft.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
148a1791edSMike Barcroft.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
158a1791edSMike Barcroft.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
168a1791edSMike Barcroft.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
178a1791edSMike Barcroft.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
188a1791edSMike Barcroft.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
198a1791edSMike Barcroft.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
208a1791edSMike Barcroft.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
218a1791edSMike Barcroft.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
228a1791edSMike Barcroft.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
238a1791edSMike Barcroft.\" SUCH DAMAGE.
248a1791edSMike Barcroft.\"
258a1791edSMike Barcroft.\" $FreeBSD$
268a1791edSMike Barcroft.\"
278a1791edSMike Barcroft.Dd March 5, 2002
288a1791edSMike Barcroft.Dt BYTEORDER 9
298a1791edSMike Barcroft.Os
308a1791edSMike Barcroft.Sh NAME
318a1791edSMike Barcroft.Nm be16toh ,
328a1791edSMike Barcroft.Nm be32toh ,
338a1791edSMike Barcroft.Nm be64toh ,
348a1791edSMike Barcroft.Nm htobe16 ,
358a1791edSMike Barcroft.Nm htobe32 ,
368a1791edSMike Barcroft.Nm htobe64 ,
378a1791edSMike Barcroft.Nm htole16 ,
388a1791edSMike Barcroft.Nm htole32 ,
398a1791edSMike Barcroft.Nm htole64 ,
408a1791edSMike Barcroft.Nm le16toh ,
418a1791edSMike Barcroft.Nm le32toh ,
428a1791edSMike Barcroft.Nm le64toh
438a1791edSMike Barcroft.Nd convert values between big endian, little endian, and host byte order
448a1791edSMike Barcroft.Sh SYNOPSIS
458a1791edSMike Barcroft.In sys/param.h
468a1791edSMike Barcroft.Ft uint16_t
478a1791edSMike Barcroft.Fn be16toh "uint16_t big16"
488a1791edSMike Barcroft.Ft uint32_t
498a1791edSMike Barcroft.Fn be32toh "uint32_t big32"
508a1791edSMike Barcroft.Ft uint64_t
518a1791edSMike Barcroft.Fn be64toh "uint64_t big64"
528a1791edSMike Barcroft.Ft uint16_t
538a1791edSMike Barcroft.Fn htobe16 "uint16_t host16"
548a1791edSMike Barcroft.Ft uint32_t
558a1791edSMike Barcroft.Fn htobe32 "uint32_t host32"
568a1791edSMike Barcroft.Ft uint64_t
578a1791edSMike Barcroft.Fn htobe64 "uint64_t host64"
588a1791edSMike Barcroft.Ft uint16_t
598a1791edSMike Barcroft.Fn htole16 "uint16_t host16"
608a1791edSMike Barcroft.Ft uint32_t
618a1791edSMike Barcroft.Fn htole32 "uint32_t host32"
628a1791edSMike Barcroft.Ft uint64_t
638a1791edSMike Barcroft.Fn htole64 "uint64_t host64"
648a1791edSMike Barcroft.Ft uint16_t
658a1791edSMike Barcroft.Fn le16toh "uint16_t little16"
668a1791edSMike Barcroft.Ft uint32_t
678a1791edSMike Barcroft.Fn le32toh "uint32_t little32"
688a1791edSMike Barcroft.Ft uint64_t
698a1791edSMike Barcroft.Fn le64toh "uint64_t little64"
708a1791edSMike Barcroft.Sh DESCRIPTION
718a1791edSMike BarcroftThe
728a1791edSMike Barcroft.Fn be16toh ,
738a1791edSMike Barcroft.Fn be32toh ,
748a1791edSMike Barcroftand
758a1791edSMike Barcroft.Fn be64toh
768a1791edSMike Barcroftfunctions return a big endian byte ordered integer
778a1791edSMike Barcroftconverted to the system's native byte order.
788a1791edSMike BarcroftThe return value will be the same as the argument on big endian systems.
798a1791edSMike Barcroft.Pp
808a1791edSMike BarcroftThe
818a1791edSMike Barcroft.Fn le16toh ,
828a1791edSMike Barcroft.Fn le32toh ,
838a1791edSMike Barcroftand
848a1791edSMike Barcroft.Fn le64toh
858a1791edSMike Barcroftfunctions return a little endian byte ordered integer
868a1791edSMike Barcroftconverted to the system's native byte order.
878a1791edSMike BarcroftThe return value will be the same as the argument on little endian systems.
888a1791edSMike Barcroft.Pp
898a1791edSMike BarcroftThe
908a1791edSMike Barcroft.Fn htobe16 ,
918a1791edSMike Barcroft.Fn htobe32 ,
928a1791edSMike Barcroftand
938a1791edSMike Barcroft.Fn htobe64
948a1791edSMike Barcroftfunctions return a integer in the system's native
958a1791edSMike Barcroftbyte order converted to big endian byte order.
968a1791edSMike BarcroftThe return value will be the same as the argument on big endian systems.
978a1791edSMike Barcroft.Pp
988a1791edSMike BarcroftThe
998a1791edSMike Barcroft.Fn htole16 ,
1008a1791edSMike Barcroft.Fn htole32 ,
1018a1791edSMike Barcroftand
1028a1791edSMike Barcroft.Fn htole64
1038a1791edSMike Barcroftfunctions return a integer in the system's native
1048a1791edSMike Barcroftbyte order converted to little endian byte order.
1058a1791edSMike BarcroftThe return value will be the same as the argument on little endian systems.
1068a1791edSMike Barcroft.Sh SEE ALSO
1078a1791edSMike Barcroft.Xr byteorder 3
1088a1791edSMike Barcroft.Sh HISTORY
1098a1791edSMike BarcroftThese functions first appeared in
1108a1791edSMike Barcroft.Fx 5.0 ,
1118a1791edSMike Barcroftand were originally developed by the
1128a1791edSMike Barcroft.Nx
1138a1791edSMike Barcroftproject.
114