endianness.c 1.3 KB

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