]> sourceware.org Git - glibc.git/blame - string/endian.h
Update copyright dates with scripts/update-copyrights
[glibc.git] / string / endian.h
CommitLineData
dff8da6b 1/* Copyright (C) 1992-2024 Free Software Foundation, Inc.
54d79e99
UD
2 This file is part of the GNU C Library.
3
4 The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
54d79e99
UD
8
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12 Lesser General Public License for more details.
54d79e99 13
41bdb6e2 14 You should have received a copy of the GNU Lesser General Public
59ba27a6 15 License along with the GNU C Library; if not, see
5a82c748 16 <https://www.gnu.org/licenses/>. */
28f540f4
RM
17
18#ifndef _ENDIAN_H
19#define _ENDIAN_H 1
5107cf1d 20
28f540f4
RM
21#include <features.h>
22
aa706e13 23/* Get the definitions of __*_ENDIAN, __BYTE_ORDER, and __FLOAT_WORD_ORDER. */
5107cf1d 24#include <bits/endian.h>
28f540f4 25
0095a3e8
AF
26#ifdef __USE_MISC
27# define LITTLE_ENDIAN __LITTLE_ENDIAN
28# define BIG_ENDIAN __BIG_ENDIAN
29# define PDP_ENDIAN __PDP_ENDIAN
30# define BYTE_ORDER __BYTE_ORDER
31#endif
32
33#if defined __USE_MISC && !defined __ASSEMBLER__
2f9a1be8 34/* Conversion interfaces. */
e92799fc 35# include <bits/byteswap.h>
6a1cefac 36# include <bits/uintn-identity.h>
e92799fc
UD
37
38# if __BYTE_ORDER == __LITTLE_ENDIAN
39# define htobe16(x) __bswap_16 (x)
6a1cefac 40# define htole16(x) __uint16_identity (x)
e92799fc 41# define be16toh(x) __bswap_16 (x)
6a1cefac 42# define le16toh(x) __uint16_identity (x)
e92799fc
UD
43
44# define htobe32(x) __bswap_32 (x)
6a1cefac 45# define htole32(x) __uint32_identity (x)
e92799fc 46# define be32toh(x) __bswap_32 (x)
6a1cefac 47# define le32toh(x) __uint32_identity (x)
e92799fc 48
6a57d931 49# define htobe64(x) __bswap_64 (x)
6a1cefac 50# define htole64(x) __uint64_identity (x)
6a57d931 51# define be64toh(x) __bswap_64 (x)
6a1cefac 52# define le64toh(x) __uint64_identity (x)
b1aa60f3 53
e92799fc 54# else
6a1cefac 55# define htobe16(x) __uint16_identity (x)
e92799fc 56# define htole16(x) __bswap_16 (x)
6a1cefac 57# define be16toh(x) __uint16_identity (x)
e92799fc
UD
58# define le16toh(x) __bswap_16 (x)
59
6a1cefac 60# define htobe32(x) __uint32_identity (x)
e92799fc 61# define htole32(x) __bswap_32 (x)
6a1cefac 62# define be32toh(x) __uint32_identity (x)
e92799fc
UD
63# define le32toh(x) __bswap_32 (x)
64
6a1cefac 65# define htobe64(x) __uint64_identity (x)
6a57d931 66# define htole64(x) __bswap_64 (x)
6a1cefac 67# define be64toh(x) __uint64_identity (x)
6a57d931 68# define le64toh(x) __bswap_64 (x)
e92799fc 69# endif
2f9a1be8
UD
70#endif
71
28f540f4 72#endif /* endian.h */
This page took 0.760316 seconds and 5 git commands to generate.