Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 100 lines (80 sloc) 1.852 kb
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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
AC_DEFUN([CHECK_READLINE], [
    lib="$1"

    old_LIBS=$LIBS

    LIBS="-ltermcap"
    AC_TRY_LINK(,[tgetent();],[
READLINE_DEPLIBS=$LIBS
    ],[
LIBS="-lcurses"
AC_TRY_LINK(,[tgetent();],[
READLINE_DEPLIBS=$LIBS
],[
LIBS="-lncurses"
AC_TRY_LINK(,[tgetent();],[
READLINE_DEPLIBS=$LIBS
],[
AC_MSG_ERROR([Cannot find termcap library])
])
])
    ])

    LIBS=$old_LIBS
    AC_SUBST(READLINE_DEPLIBS)
])


AC_DEFUN([LINUX_NPTL_CHECK], [
   old_LIBS=$LIBS
   LIBS="$LIBS -lpthread"
   AC_MSG_CHECKING(for NPTL support)
   AC_RUN_IFELSE([
#include <stdio.h>
#include <errno.h>
#include <wait.h>
#include <semaphore.h>
#include <pthread.h>
#include <sys/ptrace.h>

static pid_t child_pid;
static sem_t start_sem;
static sem_t finished_sem;
static int ok = 0;

static int
thread_func (void *data)
{
int ret, status;

/* Wait until main thread forked. */
sem_wait (&start_sem);

ret = waitpid (-1, &status, WUNTRACED | __WALL);

if (ret == child_pid) {
fprintf (stderr, "OK\n");
ok = 1;
} else {
fprintf (stderr, "Result: %d - %x - %s\n", ret, status, strerror (errno));
ok = 0;
}

sem_post (&finished_sem);
exit (!ok);
}

int
main (void)
{
pthread_t thread;

sem_init (&start_sem, 1, 0);
sem_init (&finished_sem, 1, 0);

/* First, we create a thread. */
pthread_create (&thread, NULL, thread_func, NULL);

/* Now let's fork a child and trace it. */
child_pid = fork ();
if (!child_pid) {
ptrace (PTRACE_TRACEME, 0, NULL, NULL);
asm ("int $""03");
}

/* Ok, child created. Now let our sibling thread wait for it. */
sem_post (&start_sem);

sem_wait (&finished_sem);
fprintf (stderr, "OK: %d\n", ok);

exit (!ok);
}], nptl=yes, nptl=no)
   AC_MSG_RESULT($nptl)
   LIBS=$old_LIBS

   if test x$nptl != xyes; then
      AC_ERROR([Your kernel/glibc has no NPTL support. Please read README.build])
   fi
])
Something went wrong with that request. Please try again.