bytes.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (C) 2005-2008 Team XBMC
  3. * http://www.xbmc.org
  4. * Copyright (C) 2008-2009 Andrej Stepanchuk
  5. * Copyright (C) 2009-2010 Howard Chu
  6. *
  7. * This file is part of librtmp.
  8. *
  9. * librtmp is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as
  11. * published by the Free Software Foundation; either version 2.1,
  12. * or (at your option) any later version.
  13. *
  14. * librtmp is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with librtmp see the file COPYING. If not, write to
  21. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  22. * Boston, MA 02110-1301, USA.
  23. * http://www.gnu.org/copyleft/lgpl.html
  24. */
  25. #ifndef __BYTES_H__
  26. #define __BYTES_H__
  27. #ifdef _WIN32
  28. /* Windows is little endian only */
  29. #define __LITTLE_ENDIAN 1234
  30. #define __BIG_ENDIAN 4321
  31. #define __BYTE_ORDER __LITTLE_ENDIAN
  32. #define __FLOAT_WORD_ORDER __BYTE_ORDER
  33. typedef unsigned char uint8_t;
  34. #else /* !_WIN32 */
  35. #include <sys/param.h>
  36. #if defined(BYTE_ORDER) && !defined(__BYTE_ORDER)
  37. #define __BYTE_ORDER BYTE_ORDER
  38. #endif
  39. #if defined(BIG_ENDIAN) && !defined(__BIG_ENDIAN)
  40. #define __BIG_ENDIAN BIG_ENDIAN
  41. #endif
  42. #if defined(LITTLE_ENDIAN) && !defined(__LITTLE_ENDIAN)
  43. #define __LITTLE_ENDIAN LITTLE_ENDIAN
  44. #endif
  45. #endif /* !_WIN32 */
  46. /* define default endianness */
  47. #ifndef __LITTLE_ENDIAN
  48. #define __LITTLE_ENDIAN 1234
  49. #endif
  50. #ifndef __BIG_ENDIAN
  51. #define __BIG_ENDIAN 4321
  52. #endif
  53. #ifndef __BYTE_ORDER
  54. #warning "Byte order not defined on your system, assuming little endian!"
  55. #define __BYTE_ORDER __LITTLE_ENDIAN
  56. #endif
  57. /* ok, we assume to have the same float word order and byte order if float word order is not defined */
  58. #ifndef __FLOAT_WORD_ORDER
  59. /* #warning "Float word order not defined, assuming the same as byte order!" */
  60. #define __FLOAT_WORD_ORDER __BYTE_ORDER
  61. #endif
  62. #if !defined(__BYTE_ORDER) || !defined(__FLOAT_WORD_ORDER)
  63. #error "Undefined byte or float word order!"
  64. #endif
  65. #if __FLOAT_WORD_ORDER != __BIG_ENDIAN && __FLOAT_WORD_ORDER != __LITTLE_ENDIAN
  66. #error "Unknown/unsupported float word order!"
  67. #endif
  68. #if __BYTE_ORDER != __BIG_ENDIAN && __BYTE_ORDER != __LITTLE_ENDIAN
  69. #error "Unknown/unsupported byte order!"
  70. #endif
  71. #endif