Blame string/endian.h

Packit 6c4009
/* Copyright (C) 1992-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#ifndef	_ENDIAN_H
Packit 6c4009
#define	_ENDIAN_H	1
Packit 6c4009
Packit 6c4009
#include <features.h>
Packit 6c4009
Packit 6c4009
/* Definitions for byte order, according to significance of bytes,
Packit 6c4009
   from low addresses to high addresses.  The value is what you get by
Packit 6c4009
   putting '4' in the most significant byte, '3' in the second most
Packit 6c4009
   significant byte, '2' in the second least significant byte, and '1'
Packit 6c4009
   in the least significant byte, and then writing down one digit for
Packit 6c4009
   each byte, starting with the byte at the lowest address at the left,
Packit 6c4009
   and proceeding to the byte with the highest address at the right.  */
Packit 6c4009
Packit 6c4009
#define	__LITTLE_ENDIAN	1234
Packit 6c4009
#define	__BIG_ENDIAN	4321
Packit 6c4009
#define	__PDP_ENDIAN	3412
Packit 6c4009
Packit 6c4009
/* This file defines `__BYTE_ORDER' for the particular machine.  */
Packit 6c4009
#include <bits/endian.h>
Packit 6c4009
Packit 6c4009
/* Some machines may need to use a different endianness for floating point
Packit 6c4009
   values.  */
Packit 6c4009
#ifndef __FLOAT_WORD_ORDER
Packit 6c4009
# define __FLOAT_WORD_ORDER __BYTE_ORDER
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#ifdef	__USE_MISC
Packit 6c4009
# define LITTLE_ENDIAN	__LITTLE_ENDIAN
Packit 6c4009
# define BIG_ENDIAN	__BIG_ENDIAN
Packit 6c4009
# define PDP_ENDIAN	__PDP_ENDIAN
Packit 6c4009
# define BYTE_ORDER	__BYTE_ORDER
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#if __BYTE_ORDER == __LITTLE_ENDIAN
Packit 6c4009
# define __LONG_LONG_PAIR(HI, LO) LO, HI
Packit 6c4009
#elif __BYTE_ORDER == __BIG_ENDIAN
Packit 6c4009
# define __LONG_LONG_PAIR(HI, LO) HI, LO
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
Packit 6c4009
#if defined __USE_MISC && !defined __ASSEMBLER__
Packit 6c4009
/* Conversion interfaces.  */
Packit 6c4009
# include <bits/byteswap.h>
Packit 6c4009
# include <bits/uintn-identity.h>
Packit 6c4009
Packit 6c4009
# if __BYTE_ORDER == __LITTLE_ENDIAN
Packit 6c4009
#  define htobe16(x) __bswap_16 (x)
Packit 6c4009
#  define htole16(x) __uint16_identity (x)
Packit 6c4009
#  define be16toh(x) __bswap_16 (x)
Packit 6c4009
#  define le16toh(x) __uint16_identity (x)
Packit 6c4009
Packit 6c4009
#  define htobe32(x) __bswap_32 (x)
Packit 6c4009
#  define htole32(x) __uint32_identity (x)
Packit 6c4009
#  define be32toh(x) __bswap_32 (x)
Packit 6c4009
#  define le32toh(x) __uint32_identity (x)
Packit 6c4009
Packit 6c4009
#  define htobe64(x) __bswap_64 (x)
Packit 6c4009
#  define htole64(x) __uint64_identity (x)
Packit 6c4009
#  define be64toh(x) __bswap_64 (x)
Packit 6c4009
#  define le64toh(x) __uint64_identity (x)
Packit 6c4009
Packit 6c4009
# else
Packit 6c4009
#  define htobe16(x) __uint16_identity (x)
Packit 6c4009
#  define htole16(x) __bswap_16 (x)
Packit 6c4009
#  define be16toh(x) __uint16_identity (x)
Packit 6c4009
#  define le16toh(x) __bswap_16 (x)
Packit 6c4009
Packit 6c4009
#  define htobe32(x) __uint32_identity (x)
Packit 6c4009
#  define htole32(x) __bswap_32 (x)
Packit 6c4009
#  define be32toh(x) __uint32_identity (x)
Packit 6c4009
#  define le32toh(x) __bswap_32 (x)
Packit 6c4009
Packit 6c4009
#  define htobe64(x) __uint64_identity (x)
Packit 6c4009
#  define htole64(x) __bswap_64 (x)
Packit 6c4009
#  define be64toh(x) __uint64_identity (x)
Packit 6c4009
#  define le64toh(x) __bswap_64 (x)
Packit 6c4009
# endif
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
#endif	/* endian.h */