xref: /netbsd-src/external/gpl3/gdb/dist/libctf/ctf-endian.h (revision 889f3bb010ad20d396fb291b89f202288dac2c87)
18dffb485Schristos /* Interface to endianness-neutrality functions.
2*889f3bb0Schristos    Copyright (C) 2019-2024 Free Software Foundation, Inc.
38dffb485Schristos 
48dffb485Schristos    This file is part of libctf.
58dffb485Schristos 
68dffb485Schristos    libctf is free software; you can redistribute it and/or modify it under
78dffb485Schristos    the terms of the GNU General Public License as published by the Free
88dffb485Schristos    Software Foundation; either version 3, or (at your option) any later
98dffb485Schristos    version.
108dffb485Schristos 
118dffb485Schristos    This program is distributed in the hope that it will be useful, but
128dffb485Schristos    WITHOUT ANY WARRANTY; without even the implied warranty of
138dffb485Schristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
148dffb485Schristos    See the GNU General Public License for more details.
158dffb485Schristos 
168dffb485Schristos    You should have received a copy of the GNU General Public License
178dffb485Schristos    along with this program; see the file COPYING.  If not see
188dffb485Schristos    <http://www.gnu.org/licenses/>.  */
198dffb485Schristos 
208dffb485Schristos #ifndef _CTF_ENDIAN_H
218dffb485Schristos #define _CTF_ENDIAN_H
228dffb485Schristos 
238dffb485Schristos #include "config.h"
248dffb485Schristos #include <stdint.h>
258dffb485Schristos #include "swap.h"
268dffb485Schristos 
27fbd0cba2Schristos #if !defined (HAVE_ENDIAN_H)
288dffb485Schristos # ifndef WORDS_BIGENDIAN
29fbd0cba2Schristos #  ifndef htole64
308dffb485Schristos #   define htole64(x) (x)
31fbd0cba2Schristos #  endif
32fbd0cba2Schristos #  ifndef le64toh
338dffb485Schristos #   define le64toh(x) (x)
34fbd0cba2Schristos #  endif
358dffb485Schristos # else
36fbd0cba2Schristos #  ifndef htole64
378dffb485Schristos #   define htole64(x) bswap_64 ((x))
38fbd0cba2Schristos #  endif
39fbd0cba2Schristos #  ifndef le64toh
408dffb485Schristos #   define le64toh(x) bswap_64 ((x))
41fbd0cba2Schristos #  endif
428dffb485Schristos # endif /* WORDS_BIGENDIAN */
438dffb485Schristos #endif /* !defined(HAVE_ENDIAN_H) */
448dffb485Schristos 
458dffb485Schristos #endif /* !defined(_CTF_ENDIAN_H) */
46