This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/3886] New: clock_nanosleep() does not return an error when its first argument is out of range


According to the clock_nanosleep manpage, clock_nanosleep() should return -1 and
set errno to ENOTSUP for clocks that are not supported. When specifying
CLOCK_MONOTONIC_HR as the first argument to clock_nanosleep(), it returns 0
instead of -1.

System details:
$ uname -a
Linux sabekorlnx05 2.6.18.2-34-default #1 SMP Mon Nov 27 11:46:27 UTC 2006
x86_64 x86_64 x86_64 GNU/Linux
$ rpm -q glibc
glibc-2.5-25

Test program:

$ cat clock_gettime.cpp

#include <iostream>
#include <iomanip>

#define CLOCK_MONOTONIC_HR 5 // see also <linux/time.h>

int main(int /*argc*/, char** /*argv*/)
{
  timespec now;
  if (clock_gettime(CLOCK_MONOTONIC_HR, &now) >= 0)
  {
    std::cout << now.tv_sec << '.'
              << std::setw(9) << std::setfill('0') << now.tv_nsec << std::endl;
  }
  else
  {
    perror("clock_gettime");
  }
  {
    timespec delay;
    delay.tv_sec = 1;
    delay.tv_nsec = 0;
    if (clock_nanosleep(CLOCK_MONOTONIC_HR, 0, &delay, 0) < 0)
      perror("clock_nanosleep");
  }
  return 0;
}

// Local variables:
// compile-command: "for c in g++ ppc_440-g++; do $c -g -pg -Wall -Wextra
-Werror clock_gettime.cpp -o ${c%g++}clock_gettime -lrt; done"
// End:

-- 
           Summary: clock_nanosleep() does not return an error when its
                    first argument is out of range
           Product: glibc
           Version: 2.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: bart dot vanassche at gmail dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: x86_64-suse-linux-gnu
  GCC host triplet: x86_64-suse-linux-gnu
GCC target triplet: x86_64-suse-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=3886

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]