endianness 889 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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