htole64(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

   #include <endian.h>

   uint16_t htobe16(uint16_t host_16bits);
   uint16_t htole16(uint16_t host_16bits);
   uint16_t be16toh(uint16_t big_endian_16bits);
   uint16_t le16toh(uint16_t little_endian_16bits);

   uint32_t htobe32(uint32_t host_32bits);
   uint32_t htole32(uint32_t host_32bits);
   uint32_t be32toh(uint32_t big_endian_32bits);
   uint32_t le32toh(uint32_t little_endian_32bits);

   uint64_t htobe64(uint64_t host_64bits);
   uint64_t htole64(uint64_t host_64bits);
   uint64_t be64toh(uint64_t big_endian_64bits);
   uint64_t le64toh(uint64_t little_endian_64bits);

   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

   htobe16(),   htole16(),  be16toh(),  le16toh(),  htobe32(),  htole32(),
   be32toh(), le32toh(), htobe64(), htole64(), be64toh(), le64toh():
       Since glibc 2.19:
           _DEFAULT_SOURCE
       In glibc up to and including 2.19:
           _BSD_SOURCE

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  <sys/endian.h>  instead  of
   <endian.h>.  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
   functions.  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 <endian.h>
   #include <stdint.h>
   #include <stdio.h>
   #include <stdlib.h>

   int
   main(int argc, char *argv[])
   {
       union {
           uint32_t u32;
           uint8_t 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(EXIT_SUCCESS);
   }

SEE ALSO

   bswap(3), byteorder(3)

COLOPHON

   This  page  is  part of release 4.09 of the Linux man-pages project.  A
   description of the project, information about reporting bugs,  and  the
   latest     version     of     this    page,    can    be    found    at
   https://www.kernel.org/doc/man-pages/.


More Linux Commands

manpages/tcl_wordBreakBefore.n.html
tcl_wordBreakBefore(n) - standard library of Tcl procedures
Tcl includes a library of Tcl procedures for commonly-needed functions. The procedures defined in the Tcl library are generic ones suitable for use by many diff

manpages/glIndexi.3gl.html
glIndexi(3gl) - set the current color index - Linux man page
glIndex updates the current (single-valued) color index. It takes one argument, the new value for the current color index. The current index is stored as a floa

manpages/SQL::Statement::Roadmap.3pm.html
SQL::Statement::Roadmap(3pm) - Planned Enhancements for SQL:
This part should test if the API to DBI drivers work (maybe an empty test driver will be needed for that). Functionality This part should test the functionality

manpages/blogd.8.html
blogd(8) - boot logging on /dev/console - Linux manual page
Without argument blogd determines the real underlying character device of /dev/console. blogd spawns a pty/tty pair to reconnect the current /dev/console with t

manpages/XrmValue.3.html
XrmValue(3) - initialize the Resource Manager, Resource Mana
The XrmInitialize function initialize the resource manager. It must be called before any other Xrm functions are used. The XrmParseCommand function parses an (a

manpages/User::pwent.3pm.html
User::pwent(3pm) - by-name interface to Perl's built-in getp
This modules default exports override the core getpwent(), getpwuid(), and getpwnam() functions, replacing them with versions that return User::pwent objects. T

manpages/field_opts_off.3form.html
field_opts_off(3form) - set and get field options (ManPage)
The function set_field_opts sets all the given fields option bits (field option bits may be logically-ORed together). The function field_opts_on turns on the gi

manpages/gnutls_certificate_get_peers.3.html
gnutls_certificate_get_peers(3) - API function (Man Page)...
Get the peers raw certificate (chain) as sent by the peer. These certificates are in raw format (DER encoded for X.509). In case of a X.509 then a certificate l

manpages/idmap_tdb2.8.html
idmap_tdb2(8) - Samba's idmap_tdb2 Backend for Winbind......
The idmap_tdb2 plugin is a substitute for the default idmap_tdb backend used by winbindd for storing SID/uid/gid mapping tables in clustered environments with S

manpages/glRasterPos.3gl.html
glRasterPos(3gl) - specify the raster position for pixel ope
The GL maintains a 3D position in window coordinates. This position, called the raster position, is used to position pixel and bitmap write operations. It is ma

manpages/pthread_setname_np.3.html
pthread_setname_np(3) set get the name of a thread..........
By default, all the threads created using pthread_create() inherit the program name. The pthread_setname_np() function can be used to set a unique name for a th

manpages/CPAN::Distroprefs.3pm.html
CPAN::Distroprefs(3pm) - read and match distroprefs.........
This module encapsulates reading Distroprefs and matching them against CPAN distributions. INTERFACE my $finder = CPAN::Distroprefs-&gt;find($dir, \%ext_map); whil





We can't live, work or learn in freedom unless the software we use is free.