File: acx_nanosleep.m4

package info (click to toggle)
google-perftools 2.7-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 7,284 kB
  • sloc: cpp: 27,869; ansic: 9,534; sh: 4,799; perl: 4,116; makefile: 1,101; asm: 128
file content (35 lines) | stat: -rw-r--r-- 1,151 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# 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_TRY_LINK([#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_TRY_LINK([#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
])