s48_determine_bits_per_byte.m4 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. ### s48_determine_bits_per_byte.m4 --- S48_DETERMINE_BITS_PER_BYTE macro -*- Autoconf -*-
  2. # serial 1
  3. dnl
  4. dnl
  5. dnl Determines the number of bits per byte
  6. AC_DEFUN([S48_DETERMINE_BITS_PER_BYTE], [dnl
  7. AC_MSG_CHECKING(bits per byte)
  8. AC_CACHE_VAL(ac_cv_bits_per_byte,
  9. [AC_TRY_RUN([#include <stdio.h>
  10. #include <stdlib.h>
  11. main()
  12. {
  13. unsigned char c = 1;
  14. int i = 0;
  15. FILE *f=fopen("conftestval", "w");
  16. if (!f) exit(1);
  17. while (c != 0) {
  18. i++;
  19. c = c << 1;
  20. }
  21. fprintf(f, "%d\n", i);
  22. exit(0);
  23. }],
  24. ac_cv_bits_per_byte=`cat conftestval`,
  25. ac_cv_bits_per_byte=0,
  26. AC_MSG_ERROR(failed to compile test program))])
  27. if test "$ac_cv_bits_per_byte" = "0" -o "$ac_cv_bits_per_byte" = ""; then
  28. AC_MSG_ERROR([Unable to determine bits per byte, see config.log for details.]);
  29. fi
  30. AC_MSG_RESULT($ac_cv_bits_per_byte)
  31. AC_DEFINE_UNQUOTED(BITS_PER_BYTE, [$ac_cv_bits_per_byte], [Check for the number of bits per byte])
  32. ])
  33. ### s48_determine_bits_per_byte.m4 ends here