Please check the GNU Autoconf Macro Archive for Updates
AC-Archive
Autoconf Macro Archive

ac-archive.sf.net: - Project CVS - Download
Macro Index
- AM Support
- C++ Support
- C Support
- Fortran Support
- Java Support
- Cross Compilation
- Installed Packages
- Miscellaneous
- LaTeX Support
- Uncategorized
- archive macros
- adl's macros
- bkorb's macros
- guidod's macros
- latex's macros
- other's macros
- rleigh's macros
- obsoleted macros
- released macros
- search index

Documentation
- Contribute!
- History
- acincludedir m4
- acinclude (tool)
- macro howto
- ax tricks
- maintainers
- License
- Topics

generated...
2007-08-05

(C) 2007 guidod
Download the M4 Source.

etr_short_sleep

Back to the Main Page.

Synopsis
ETR_SHORT_SLEEP
, 
Version

2001-06-07

Author

Warren Young <warren@etr-usa.com>

License

AllPermissive
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. Users of this software should generally follow the principles of the MIT License includings its disclaimer.

Category

cryp.to ac-archive's Miscellaneous (released)

Documentation

This macro searches for a "sleep" function that has 1/1000 of a second accuracy. On some systems, this is known as nap() and on others usleep() / 1000. There are probably other functions like this defined in other system libraries, but we don't know how to search for them yet. Contributions joyously accepted. :)

M4 Source Code
AC_DEFUN([ETR_SHORT_SLEEP],
[
        AC_MSG_CHECKING([for nap() in libc])
        AC_TRY_LINK([ extern "C" long nap(long ms); ], [ nap(42); ],
                [
                        etr_ss_found=yes
                        etr_ss_factor=1
                        AC_DEFINE(HAVE_NAP,1,
                                [Define to use the nap() system call for short sleeps])
                        AC_MSG_RESULT(yes)
                ],
                [
                        AC_MSG_RESULT(no)
                        etr_ss_found=no
                ])

        if test x"$etr_ss_found" = "xno"
        then
                AC_MSG_CHECKING([for usleep()])
                AC_TRY_LINK([ #include &lt;unistd.h&gt; ], [ usleep(42); ],
                        [
                                etr_ss_found=yes
                                etr_ss_factor=1000
                                AC_DEFINE(HAVE_USLEEP,1,
                                        [Define to use the usleep() system call for short sleeps])
                                AC_MSG_RESULT(yes)
                        ],
                        [
                                AC_MSG_RESULT(no)
                                etr_ss_found=no
                        ])
        fi

        if test x"$etr_ss_found" = "xno"
        then
                save_LIBS=$LIBS
                LIBS="$LIBS -lx"
                AC_MSG_CHECKING([for nap() in libx])
                AC_TRY_LINK([ extern "C" long nap(long ms); ], [ nap(42); ],
                        [
                                etr_ss_found=yes
                                etr_ss_factor=1
                                AC_DEFINE(HAVE_NAP,1,
                                        [Define to use the nap() system call for short sleeps])
                                AC_MSG_RESULT(yes)
                        ],
                        [
                                AC_MSG_RESULT(no)
                                etr_ss_found=no
                        ])

                LIBS=$save_LIBS
                ETR_SS_LIB=-lx
                AC_SUBST(ETR_SS_LIB)
        fi

        if test x"$etr_ss_found" = "xyes"
        then
                AC_DEFINE_UNQUOTED(SHORT_SLEEP_FACTOR, $etr_ss_factor,
                        [Multiply milliseconds by this to get the argument for the short sleep system call])
        else
                AC_MSG_ERROR([Could not find a "short sleep" system call.])
        fi
])dnl ETR_SHORT_SLEEP