endian.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Copyright (C) 1992, 1996, 1997, 2000 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #ifndef _ENDIAN_H
  16. #define _ENDIAN_H 1
  17. #include <features.h>
  18. /* Definitions for byte order, according to significance of bytes,
  19. from low addresses to high addresses. The value is what you get by
  20. putting '4' in the most significant byte, '3' in the second most
  21. significant byte, '2' in the second least significant byte, and '1'
  22. in the least significant byte, and then writing down one digit for
  23. each byte, starting with the byte at the lowest address at the left,
  24. and proceeding to the byte with the highest address at the right. */
  25. #define __LITTLE_ENDIAN 1234
  26. #define __BIG_ENDIAN 4321
  27. #define __PDP_ENDIAN 3412
  28. /* This file defines `__BYTE_ORDER' for the particular machine. */
  29. #include <bits/endian.h>
  30. /* Some machines may need to use a different endianness for floating point
  31. values. */
  32. #ifndef __FLOAT_WORD_ORDER
  33. # define __FLOAT_WORD_ORDER __BYTE_ORDER
  34. #endif
  35. #ifdef __USE_BSD
  36. # define LITTLE_ENDIAN __LITTLE_ENDIAN
  37. # define BIG_ENDIAN __BIG_ENDIAN
  38. # define PDP_ENDIAN __PDP_ENDIAN
  39. # define BYTE_ORDER __BYTE_ORDER
  40. #endif
  41. #if __BYTE_ORDER == __LITTLE_ENDIAN
  42. # define __LONG_LONG_PAIR(HI, LO) LO, HI
  43. #elif __BYTE_ORDER == __BIG_ENDIAN
  44. # define __LONG_LONG_PAIR(HI, LO) HI, LO
  45. #endif
  46. #endif /* endian.h */