Manual Pages for Linux CentOS command on man be64toh
MyWebUniversity

Manual Pages for Linux CentOS command on man be64toh

ENDIAN(3) Linux Programmer's Manual ENDIAN(3)

NAME htobe16, htole16, be16toh, le16toh, htobe32, htole32, be32toh, le32toh,

htobe64, htole64, be64toh, le64toh - convert values between host and

big-/little-endian byte order SYNOPSIS

#define BSDSOURCE /* See featuretestmacros(7) */

#include uint16t htobe16(uint16t host16bits); uint16t htole16(uint16t host16bits); uint16t be16toh(uint16t bigendian16bits); uint16t le16toh(uint16t littleendian16bits); uint32t htobe32(uint32t host32bits); uint32t htole32(uint32t host32bits); uint32t be32toh(uint32t bigendian32bits); uint32t le32toh(uint32t littleendian32bits); uint64t htobe64(uint64t host64bits); uint64t htole64(uint64t host64bits); uint64t be64toh(uint64t bigendian64bits); uint64t le64toh(uint64t littleendian64bits); DESCRIPTION These functions convert the byte encoding of integer values from the

byte order that the current CPU (the "host") uses, to and from little-

endian and big-endian byte order. The number, nn, in the name of each function indicates the size of integer handled by the function, either 16, 32, or 64 bits. The functions with names of the form "htobenn" convert from host byte

order to big-endian order. The functions with names of the form "htolenn" convert from host byte

order to little-endian order.

The functions with names of the form "benntoh" convert from big-endian order to host byte order.

The functions with names of the form "lenntoh" convert from little- endian order to host byte order. VERSIONS These functions were added to glibc in version 2.9. CONFORMING TO These functions are nonstandard. Similar functions are present on the BSDs, where the required header file is instead of . Unfortunately, NetBSD, FreeBSD, and glibc haven't followed the original OpenBSD naming convention for these functions, whereby the nn component always appears at the end of the function name (thus, for example, in NetBSD, FreeBSD, and glibc, the equivalent of OpenBSDs "betoh32" is "be32toh"). NOTES These functions are similar to the older byteorder(3) family of func‐ tions. For example, be32toh() is identical to ntohl(). The advantage of the byteorder(3) functions is that they are standard functions available on all UNIX systems. On the other hand, the fact that they were designed for use in the context of TCP/IP means that

they lack the 64-bit and little-endian variants described in this page. EXAMPLE The program below display the results of converting an integer from

host byte order to both little-endian and big-endian byte order. Since

host byte order is either little-endian or big-endian, only one of these conversions will have an effect. When we run this program on a

little-endian system such as x86-32, we see the following:

$ ./a.out x.u32 = 0x44332211 htole32(x.u32) = 0x44332211 htobe32(x.u32) = 0x11223344 Program source

#include

#include

#include

#include int main(int argc, char *argv[]) { union { uint32t u32; uint8t arr[4]; } x;

x.arr[0] = 0x11; /* Lowest-address byte */ x.arr[1] = 0x22; x.arr[2] = 0x33;

x.arr[3] = 0x44; /* Highest-address byte */

printf("x.u32 = 0x%x\n", x.u32);

printf("htole32(x.u32) = 0x%x\n", htole32(x.u32));

printf("htobe32(x.u32) = 0x%x\n", htobe32(x.u32)); exit(EXITSUCCESS); } SEE ALSO byteorder(3) COLOPHON

This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can

be found at http://www.kernel.org/doc/man-pages/.

GNU 2010-09-10 ENDIAN(3)




Contact us      |      About us      |      Term of use      |       Copyright © 2000-2019 MyWebUniversity.com ™