endianness.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2008 iptelorg GmbH
  5. *
  6. * Permission to use, copy, modify, and distribute this software for any
  7. * purpose with or without fee is hereby granted, provided that the above
  8. * copyright notice and this permission notice appear in all copies.
  9. *
  10. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  11. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  12. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  13. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  14. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  15. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  16. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. */
  18. /*
  19. * endianness compile and runtime tests
  20. *
  21. * History:
  22. * --------
  23. * 2008-06-13 created by andrei
  24. */
  25. /*!
  26. * \file
  27. * \brief SIP-router core ::
  28. * \ingroup core
  29. * Module: \ref core
  30. */
  31. #include "endianness.h"
  32. int _endian_test_int=1 /* used for the runtime endian tests */;
  33. /* return 0 on success, -1 on error (compile time detected endianness is
  34. * different from run time)
  35. */
  36. int endianness_sanity_check()
  37. {
  38. #ifdef __IS_LITTLE_ENDIAN
  39. return is_little_endian()-1;
  40. #elif defined __IS_BIG_ENDIAN
  41. return is_big_endian()-1;
  42. #else
  43. #warning BUG: endianness macro are not defined
  44. return -1;
  45. #endif
  46. }