2
0

acx_nanosleep.m4 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # Check for support for nanosleep. It's defined in <time.h>, but on
  2. # some systems, such as solaris, you need to link in a library to use it.
  3. # We set acx_nanosleep_ok if nanosleep is supported; in that case,
  4. # NANOSLEEP_LIBS is set to whatever libraries are needed to support
  5. # nanosleep.
  6. AC_DEFUN([ACX_NANOSLEEP],
  7. [AC_MSG_CHECKING(if nanosleep requires any libraries)
  8. AC_LANG_SAVE
  9. AC_LANG_C
  10. acx_nanosleep_ok="no"
  11. NANOSLEEP_LIBS=
  12. # For most folks, this should just work
  13. AC_TRY_LINK([#include <time.h>],
  14. [static struct timespec ts; nanosleep(&ts, NULL);],
  15. [acx_nanosleep_ok=yes])
  16. # For solaris, we may need -lrt
  17. if test "x$acx_nanosleep_ok" != "xyes"; then
  18. OLD_LIBS="$LIBS"
  19. LIBS="-lrt $LIBS"
  20. AC_TRY_LINK([#include <time.h>],
  21. [static struct timespec ts; nanosleep(&ts, NULL);],
  22. [acx_nanosleep_ok=yes])
  23. if test "x$acx_nanosleep_ok" = "xyes"; then
  24. NANOSLEEP_LIBS="-lrt"
  25. fi
  26. LIBS="$OLD_LIBS"
  27. fi
  28. if test "x$acx_nanosleep_ok" != "xyes"; then
  29. AC_MSG_ERROR([cannot find the nanosleep function])
  30. else
  31. AC_MSG_RESULT(${NANOSLEEP_LIBS:-no})
  32. fi
  33. AC_LANG_RESTORE
  34. ])