endianness 889 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # Copyright (C) Igor Sysoev
  2. # Copyright (C) Nginx, Inc.
  3. echo $ngx_n "checking for system byte ordering ...$ngx_c"
  4. cat << END >> $NGX_AUTOCONF_ERR
  5. ----------------------------------------
  6. checking for system byte ordering
  7. END
  8. cat << END > $NGX_AUTOTEST.c
  9. int main(void) {
  10. int i = 0x11223344;
  11. char *p;
  12. p = (char *) &i;
  13. if (*p == 0x44) return 0;
  14. return 1;
  15. }
  16. END
  17. ngx_test="$CC $CC_TEST_FLAGS $CC_AUX_FLAGS \
  18. -o $NGX_AUTOTEST $NGX_AUTOTEST.c $NGX_LD_OPT $ngx_feature_libs"
  19. eval "$ngx_test >> $NGX_AUTOCONF_ERR 2>&1"
  20. if [ -x $NGX_AUTOTEST ]; then
  21. if $NGX_AUTOTEST >/dev/null 2>&1; then
  22. echo " little endian"
  23. have=NGX_HAVE_LITTLE_ENDIAN . auto/have
  24. else
  25. echo " big endian"
  26. fi
  27. rm -rf $NGX_AUTOTEST*
  28. else
  29. rm -rf $NGX_AUTOTEST*
  30. echo
  31. echo "$0: error: cannot detect system byte ordering"
  32. exit 1
  33. fi