ctf-endian.h 1.2 KB

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