have_ulong64.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * have_ulong64 - Determine if we have a 64 bit unsigned long long
  3. *
  4. * usage:
  5. * have_ulong64 > longlong.h
  6. *
  7. * Not all systems have a 'long long type' so this may not compile on
  8. * your system.
  9. *
  10. * This prog outputs the define:
  11. *
  12. * HAVE_64BIT_LONG_LONG
  13. * defined ==> we have a 64 bit unsigned long long
  14. * undefined ==> we must simulate a 64 bit unsigned long long
  15. */
  16. /*
  17. *
  18. * Please do not copyright this code. This code is in the public domain.
  19. *
  20. * LANDON CURT NOLL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  21. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO
  22. * EVENT SHALL LANDON CURT NOLL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  23. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  24. * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  25. * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  26. * PERFORMANCE OF THIS SOFTWARE.
  27. *
  28. * By:
  29. * chongo <Landon Curt Noll> /\oo/\
  30. * http://www.isthe.com/chongo/
  31. *
  32. * Share and Enjoy! :-)
  33. */
  34. /*
  35. * have the compiler try its hand with unsigned and signed long longs
  36. */
  37. #if ! defined(NO64BIT_LONG_LONG)
  38. unsigned long long val = 1099511628211ULL;
  39. #endif /* NO64BIT_LONG_LONG */
  40. int
  41. main(void)
  42. {
  43. /*
  44. * ensure that the length of long long val is what we expect
  45. */
  46. #if defined(NO64BIT_LONG_LONG)
  47. printf("#undef HAVE_64BIT_LONG_LONG\t/* no */\n");
  48. #else /* NO64BIT_LONG_LONG */
  49. if (val == 1099511628211ULL && sizeof(val) == 8) {
  50. printf("#define HAVE_64BIT_LONG_LONG\t/* yes */\n");
  51. }
  52. #endif /* NO64BIT_LONG_LONG */
  53. /* exit(0); */
  54. return 0;
  55. }