ctf-endian.h revision 1.5 1 /* Interface to endianness-neutrality functions.
2 Copyright (C) 2019-2025 Free Software Foundation, Inc.
3
4 This file is part of libctf.
5
6 libctf is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
9 version.
10
11 This program is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; see the file COPYING. If not see
18 <http://www.gnu.org/licenses/>. */
19
20 #ifndef _CTF_ENDIAN_H
21 #define _CTF_ENDIAN_H
22
23 #include "config.h"
24 #include <stdint.h>
25 #include "swap.h"
26
27 #if !defined (HAVE_ENDIAN_H)
28 # ifndef WORDS_BIGENDIAN
29 # ifndef htole64
30 # define htole64(x) (x)
31 # endif
32 # ifndef le64toh
33 # define le64toh(x) (x)
34 # endif
35 # else
36 # ifndef htole64
37 # define htole64(x) bswap_64 ((x))
38 # endif
39 # ifndef le64toh
40 # define le64toh(x) bswap_64 ((x))
41 # endif
42 # endif /* WORDS_BIGENDIAN */
43 #endif /* !defined(HAVE_ENDIAN_H) */
44
45 #endif /* !defined(_CTF_ENDIAN_H) */
46