By accident I noticed that the configure script for one of the gentoo
packages (I think maybe it was coreutils but I can't remember) gives
different results on ~x86 and ~amd64.
The script uses a "test for working nanosleep" that I've included below.

Could someone else compile the test and confirm that it returns 119 on
~amd64 instead of 0?

Here are the steps if you don't already know them:
1. Copy and paste the c code below into a new file named conftest.c
2. # gcc conftest.c
3. # ./a.out  (don't forget that leading dot)
4. # echo $? (this should print either 0 or 119)

I get 119 on ~amd64, which implies the test for nanosleep fails.

Thanks!


Here are the contents of conftest.c:

        #include <errno.h>
        #include <limits.h>
        #include <signal.h>
        #include <sys/time.h>
        #include <time.h>
        #include <unistd.h>
        #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
        #define TYPE_MAXIMUM(t) ((t) (! TYPE_SIGNED (t) ? (t) -1 : ~ (~ (t) 0 
<< (sizeof (t) * CHAR_BIT - 1))))

        static void
        check_for_SIGALRM (int sig)
        {
          if (sig != SIGALRM)
            _exit (1);
        }

        int
        main ()
        {
          static struct timespec ts_sleep;
          static struct timespec ts_remaining;
          static struct sigaction act;
          if (! nanosleep)
            return 1;
          act.sa_handler = check_for_SIGALRM;
          sigemptyset (&act.sa_mask);
          sigaction (SIGALRM, &act, NULL);
          ts_sleep.tv_sec = 0;
          ts_sleep.tv_nsec = 1;
          alarm (1);
          if (nanosleep (&ts_sleep, NULL) != 0)
            return 1;
          ts_sleep.tv_sec = TYPE_MAXIMUM (time_t);
          ts_sleep.tv_nsec = 999999999;
          alarm (1);
          if (nanosleep (&ts_sleep, &ts_remaining) == -1 && errno == EINTR
              && TYPE_MAXIMUM (time_t) - 10 < ts_remaining.tv_sec)
            return 0;
          return 119;
        }


Reply via email to