xref: /netbsd-src/external/gpl3/gdb.old/dist/libctf/ctf-endian.h (revision 6881a4007f077b54e5f51159c52b9b25f57deb0d)
17d62b00eSchristos /* Interface to endianness-neutrality functions.
2*6881a400Schristos    Copyright (C) 2019-2022 Free Software Foundation, Inc.
37d62b00eSchristos 
47d62b00eSchristos    This file is part of libctf.
57d62b00eSchristos 
67d62b00eSchristos    libctf is free software; you can redistribute it and/or modify it under
77d62b00eSchristos    the terms of the GNU General Public License as published by the Free
87d62b00eSchristos    Software Foundation; either version 3, or (at your option) any later
97d62b00eSchristos    version.
107d62b00eSchristos 
117d62b00eSchristos    This program is distributed in the hope that it will be useful, but
127d62b00eSchristos    WITHOUT ANY WARRANTY; without even the implied warranty of
137d62b00eSchristos    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
147d62b00eSchristos    See the GNU General Public License for more details.
157d62b00eSchristos 
167d62b00eSchristos    You should have received a copy of the GNU General Public License
177d62b00eSchristos    along with this program; see the file COPYING.  If not see
187d62b00eSchristos    <http://www.gnu.org/licenses/>.  */
197d62b00eSchristos 
207d62b00eSchristos #ifndef _CTF_ENDIAN_H
217d62b00eSchristos #define _CTF_ENDIAN_H
227d62b00eSchristos 
237d62b00eSchristos #include "config.h"
247d62b00eSchristos #include <stdint.h>
257d62b00eSchristos #include "swap.h"
267d62b00eSchristos 
277d62b00eSchristos #if !defined (HAVE_ENDIAN_H)
287d62b00eSchristos # ifndef WORDS_BIGENDIAN
297d62b00eSchristos #  ifndef htole64
307d62b00eSchristos #   define htole64(x) (x)
317d62b00eSchristos #  endif
327d62b00eSchristos #  ifndef le64toh
337d62b00eSchristos #   define le64toh(x) (x)
347d62b00eSchristos #  endif
357d62b00eSchristos # else
367d62b00eSchristos #  ifndef htole64
377d62b00eSchristos #   define htole64(x) bswap_64 ((x))
387d62b00eSchristos #  endif
397d62b00eSchristos #  ifndef le64toh
407d62b00eSchristos #   define le64toh(x) bswap_64 ((x))
417d62b00eSchristos #  endif
427d62b00eSchristos # endif /* WORDS_BIGENDIAN */
437d62b00eSchristos #endif /* !defined(HAVE_ENDIAN_H) */
447d62b00eSchristos 
457d62b00eSchristos #endif /* !defined(_CTF_ENDIAN_H) */
46