* sysdeps/unix/clock_nanosleep.c (clock_nanosleep): Diagnose EINVAL

for CLOCK_THREAD_CPUTIME_ID, not ENOTSUP.
	Use SYSDEP_NANOSLEEP handler before validating CLOCK_ID value.

	* rt/tst-timer4.c (TEST_CLOCK, TEST_CLOCK_NANOSLEEP): New macros.
	Use them throughout in place of CLOCK_REALTIME and nanosleep.
	(do_test) [TEST_CLOCK_MISSING]: Call this macro and if it returns
	non-null, punt the test with a message using the string returned.
	* rt/tst-timer5.c: New file.
	* rt/Makefile (tests): Add it.
This commit is contained in:
Roland McGrath 2004-12-06 22:29:01 +00:00
parent bc5cb1e6aa
commit 60fce589e8
2 changed files with 21 additions and 5 deletions

View File

@ -1,3 +1,16 @@
2004-12-06 Roland McGrath <roland@redhat.com>
* sysdeps/unix/clock_nanosleep.c (clock_nanosleep): Diagnose EINVAL
for CLOCK_THREAD_CPUTIME_ID, not ENOTSUP.
Use SYSDEP_NANOSLEEP handler before validating CLOCK_ID value.
* rt/tst-timer4.c (TEST_CLOCK, TEST_CLOCK_NANOSLEEP): New macros.
Use them throughout in place of CLOCK_REALTIME and nanosleep.
(do_test) [TEST_CLOCK_MISSING]: Call this macro and if it returns
non-null, punt the test with a message using the string returned.
* rt/tst-timer5.c: New file.
* rt/Makefile (tests): Add it.
2004-12-01 Paolo Bonzini <bonzini@gnu.org> 2004-12-01 Paolo Bonzini <bonzini@gnu.org>
* posix/regcomp.c (free_dfa_content, init_dfa): Remove * posix/regcomp.c (free_dfa_content, init_dfa): Remove

View File

@ -1,5 +1,5 @@
/* High-resolution sleep with the specified clock. /* High-resolution sleep with the specified clock.
Copyright (C) 2000, 2001, 2003 Free Software Foundation, Inc. Copyright (C) 2000, 2001, 2003, 2004 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -49,16 +49,19 @@ clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *req,
|| __builtin_expect (req->tv_nsec, 0) >= 1000000000) || __builtin_expect (req->tv_nsec, 0) >= 1000000000)
return EINVAL; return EINVAL;
if (clock_id == CLOCK_THREAD_CPUTIME_ID)
return EINVAL; /* POSIX specifies EINVAL for this case. */
#ifdef SYSDEP_NANOSLEEP
SYSDEP_NANOSLEEP;
#endif
if (CPUCLOCK_P (clock_id)) if (CPUCLOCK_P (clock_id))
return ENOTSUP; return ENOTSUP;
if (INVALID_CLOCK_P (clock_id)) if (INVALID_CLOCK_P (clock_id))
return EINVAL; return EINVAL;
#ifdef SYSDEP_NANOSLEEP
SYSDEP_NANOSLEEP;
#endif
/* If we got an absolute time, remap it. */ /* If we got an absolute time, remap it. */
if (flags == TIMER_ABSTIME) if (flags == TIMER_ABSTIME)
{ {