NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/58670: clock_getres function does not recognize CLOCK_THREAD_CPUTIME_ID, leading to an 'Invalid argument' error.



>Number:         58670
>Category:       lib
>Synopsis:       clock_getres function does not recognize CLOCK_THREAD_CPUTIME_ID, leading to an 'Invalid argument' error.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          support
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 10 23:55:00 +0000 2024
>Originator:     Furkan Onder
>Release:        NetBSD 10.0
>Organization:
>Environment:
NetBSD localhost.home 10.0 NetBSD 10.0 (GENERIC) #0: Thu Mar 28 08:33:33 UTC 2024  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
According to the documentation (https://man.netbsd.org/clock_gettime.2), CLOCK_THREAD_CPUTIME_ID is supported by clock_getres. However, when using clock_getres with the CLOCK_THREAD_CPUTIME_ID clock ID, the function returns -1 and sets errno to EINVAL.
>How-To-Repeat:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

int main() {
    struct timespec res;

    if (clock_getres(CLOCK_THREAD_CPUTIME_ID, &res) == -1) {
        perror("clock_getres");
        return EXIT_FAILURE;
    }

    printf("Resolution of CLOCK_THREAD_CPUTIME_ID: %ld.%09ld seconds\n", res.tv_sec, res.tv_nsec);

    return EXIT_SUCCESS;
}

$ gcc -o test_clock test_clock.c
$ ./test_clock
>Fix:



Home | Main Index | Thread Index | Old Index