Collection of DPF-based plugins for packaging
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
3.4KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_short_sleep.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_SHORT_SLEEP
  8. #
  9. # DESCRIPTION
  10. #
  11. # This macro searches for a "sleep" function that has 1/1000 of a second
  12. # accuracy. On some systems, this is known as nap() and on others usleep()
  13. # / 1000. There are probably other functions like this defined in other
  14. # system libraries, but we don't know how to search for them yet.
  15. # Contributions joyously accepted. :)
  16. #
  17. # LICENSE
  18. #
  19. # Copyright (c) 2008 Warren Young <warren@etr-usa.com>
  20. #
  21. # Copying and distribution of this file, with or without modification, are
  22. # permitted in any medium without royalty provided the copyright notice
  23. # and this notice are preserved. This file is offered as-is, without any
  24. # warranty.
  25. #serial 7
  26. AU_ALIAS([ETR_SHORT_SLEEP], [AX_SHORT_SLEEP])
  27. AC_DEFUN([AX_SHORT_SLEEP],
  28. [
  29. AC_MSG_CHECKING([for nap() in libc])
  30. AC_TRY_LINK([ extern "C" long nap(long ms); ], [ nap(42); ],
  31. [
  32. ax_ss_found=yes
  33. ax_ss_factor=1
  34. AC_DEFINE(HAVE_NAP,1,
  35. [Define to use the nap() system call for short sleeps])
  36. AC_MSG_RESULT(yes)
  37. ],
  38. [
  39. AC_MSG_RESULT(no)
  40. ax_ss_found=no
  41. ])
  42. if test x"$ax_ss_found" = "xno"
  43. then
  44. AC_MSG_CHECKING([for usleep()])
  45. AC_TRY_LINK([ #include <unistd.h> ], [ usleep(42); ],
  46. [
  47. ax_ss_found=yes
  48. ax_ss_factor=1000
  49. AC_DEFINE(HAVE_USLEEP,1,
  50. [Define to use the usleep() system call for short sleeps])
  51. AC_MSG_RESULT(yes)
  52. ],
  53. [
  54. AC_MSG_RESULT(no)
  55. ax_ss_found=no
  56. ])
  57. fi
  58. if test x"$ax_ss_found" = "xno"
  59. then
  60. save_LIBS=$LIBS
  61. LIBS="$LIBS -lx"
  62. AC_MSG_CHECKING([for nap() in libx])
  63. AC_TRY_LINK([ extern "C" long nap(long ms); ], [ nap(42); ],
  64. [
  65. ax_ss_found=yes
  66. ax_ss_factor=1
  67. AC_DEFINE(HAVE_NAP,1,
  68. [Define to use the nap() system call for short sleeps])
  69. AC_MSG_RESULT(yes)
  70. ],
  71. [
  72. AC_MSG_RESULT(no)
  73. ax_ss_found=no
  74. ])
  75. LIBS=$save_LIBS
  76. AX_SS_LIB=-lx
  77. AC_SUBST(AX_SS_LIB)
  78. fi
  79. if test x"$ax_ss_found" = "xyes"
  80. then
  81. AC_DEFINE_UNQUOTED(SHORT_SLEEP_FACTOR, $ax_ss_factor,
  82. [Multiply milliseconds by this to get the argument for the short sleep system call])
  83. else
  84. AC_MSG_ERROR([Could not find a "short sleep" system call.])
  85. fi
  86. ])dnl AX_SHORT_SLEEP