gperftools/m4/acx_nanosleep.m4
Aliaksey Kandratsenka c37f6c4c7c fix deprecated autoconf bits
As part of that we also upgrade required autoconf version to 2.69
which is what I see in rhel/centos 7 and ubuntu 14.04. Both are old
enough. And, of course, .tar.gz releases still ship "packaged" configure,
so will work on older distros.

This fixes issue #1335.
2023-07-02 21:28:30 -04:00

32 lines
1.1 KiB
Plaintext

# Check for support for nanosleep. It's defined in <time.h>, but on
# some systems, such as solaris, you need to link in a library to use it.
# We set acx_nanosleep_ok if nanosleep is supported; in that case,
# NANOSLEEP_LIBS is set to whatever libraries are needed to support
# nanosleep.
AC_DEFUN([ACX_NANOSLEEP],
[AC_MSG_CHECKING(if nanosleep requires any libraries)
AC_LANG_SAVE
AC_LANG([C])
acx_nanosleep_ok="no"
NANOSLEEP_LIBS=
# For most folks, this should just work
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[static struct timespec ts; nanosleep(&ts, NULL);]])],[acx_nanosleep_ok=yes],[])
# For solaris, we may need -lrt
if test "x$acx_nanosleep_ok" != "xyes"; then
OLD_LIBS="$LIBS"
LIBS="-lrt $LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <time.h>]], [[static struct timespec ts; nanosleep(&ts, NULL);]])],[acx_nanosleep_ok=yes],[])
if test "x$acx_nanosleep_ok" = "xyes"; then
NANOSLEEP_LIBS="-lrt"
fi
LIBS="$OLD_LIBS"
fi
if test "x$acx_nanosleep_ok" != "xyes"; then
AC_MSG_ERROR([cannot find the nanosleep function])
else
AC_MSG_RESULT(${NANOSLEEP_LIBS:-no})
fi
AC_LANG_RESTORE
])