diff options
| author | njoly <njoly@NetBSD.org> | 2017-03-04 11:16:33 +0000 |
|---|---|---|
| committer | njoly <njoly@NetBSD.org> | 2017-03-04 11:16:33 +0000 |
| commit | d76eff8f852598e49fc562c5168995dfef88f389 (patch) | |
| tree | 2cd91e707ba74b8bf4422b99a398727308a6513f /lib/libpthread | |
| parent | 5f894c4b28a21db45604539ea5dd44d8185e20ce (diff) | |
Fix {clock,pthread}_getcpuclockid to return an error number on
failure, to match OpenGroup specifications.
Diffstat (limited to 'lib/libpthread')
| -rw-r--r-- | lib/libpthread/pthread_getcpuclockid.3 | 9 | ||||
| -rw-r--r-- | lib/libpthread/pthread_getcpuclockid.c | 14 |
2 files changed, 14 insertions, 9 deletions
diff --git a/lib/libpthread/pthread_getcpuclockid.3 b/lib/libpthread/pthread_getcpuclockid.3 index 73dce9ba2c9..950ca945562 100644 --- a/lib/libpthread/pthread_getcpuclockid.3 +++ b/lib/libpthread/pthread_getcpuclockid.3 @@ -1,4 +1,4 @@ -.\" $NetBSD: pthread_getcpuclockid.3,v 1.3 2016/04/24 09:01:45 wiz Exp $ +.\" $NetBSD: pthread_getcpuclockid.3,v 1.4 2017/03/04 11:16:33 njoly Exp $ .\" .\" Copyright (c) 2016 The NetBSD Foundation, Inc. .\" All rights reserved. @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd April 23, 2016 +.Dd March 3, 2017 .Dt PTHREAD_GETCPUCLOCKID 3 .Os .Sh NAME @@ -58,10 +58,7 @@ On success the function returns 0, placing the requested .Fa clock_id in the argument. -On error, the value \-1 is returned -and the value of -.Va errno -is set to reflect what went wrong. +Otherwise an error number will be returned. .Sh ERRORS These functions fail if: .Bl -tag -width Er diff --git a/lib/libpthread/pthread_getcpuclockid.c b/lib/libpthread/pthread_getcpuclockid.c index 38d37222139..79c868f1b45 100644 --- a/lib/libpthread/pthread_getcpuclockid.c +++ b/lib/libpthread/pthread_getcpuclockid.c @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_getcpuclockid.c,v 1.1 2016/04/23 23:12:19 christos Exp $ */ +/* $NetBSD: pthread_getcpuclockid.c,v 1.2 2017/03/04 11:16:33 njoly Exp $ */ /*- * Copyright (c) 2016 The NetBSD Foundation, Inc. @@ -30,10 +30,11 @@ */ #include <sys/cdefs.h> #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: pthread_getcpuclockid.c,v 1.1 2016/04/23 23:12:19 christos Exp $"); +__RCSID("$NetBSD: pthread_getcpuclockid.c,v 1.2 2017/03/04 11:16:33 njoly Exp $"); #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> +#include <errno.h> #include <pthread.h> #include <time.h> @@ -42,5 +43,12 @@ __RCSID("$NetBSD: pthread_getcpuclockid.c,v 1.1 2016/04/23 23:12:19 christos Exp int pthread_getcpuclockid(pthread_t thread, clockid_t *clock_id) { - return clock_getcpuclockid2(P_LWPID, (id_t)thread->pt_lid, clock_id); + int error = 0, saved_errno; + + saved_errno = errno; + if (clock_getcpuclockid2(P_LWPID, (id_t)thread->pt_lid, clock_id) == -1) + error = errno; + errno = saved_errno; + + return error; } |
