You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2023/07/03 20:11:06 UTC

[nuttx] branch master updated: sched/clock/clock_getres: add two CPUTIME_ID res support

This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 42f8308423 sched/clock/clock_getres: add two CPUTIME_ID res support
42f8308423 is described below

commit 42f830842373d123f9264081a3b9dcef69a179d8
Author: guoshichao <gu...@xiaomi.com>
AuthorDate: Mon Jun 19 22:11:16 2023 +0800

    sched/clock/clock_getres: add two CPUTIME_ID res support
    
    1. make the clock_getres can pass the
    ltp/open_posix_testsuite/clock_getres 7-1, 8-1 two cases
    2. the modification are referred to https://pubs.opengroup.org/onlinepubs/9699919799/functions/clock_getres.html
    
    Signed-off-by: guoshichao <gu...@xiaomi.com>
---
 include/unistd.h               | 2 ++
 libs/libc/unistd/lib_sysconf.c | 4 ++++
 sched/clock/clock_getres.c     | 2 ++
 3 files changed, 8 insertions(+)

diff --git a/include/unistd.h b/include/unistd.h
index 5d7eefcd57..752c4922c2 100644
--- a/include/unistd.h
+++ b/include/unistd.h
@@ -63,6 +63,8 @@
 
 #define _POSIX_VERSION 201712L
 #define _POSIX_PRIORITIZED_IO _POSIX_VERSION
+#define _POSIX_CPUTIME _POSIX_VERSION
+#define _POSIX_THREAD_CPUTIME _POSIX_VERSION
 
 #ifdef CONFIG_FS_AIO
 #  define _POSIX_ASYNCHRONOUS_IO _POSIX_VERSION
diff --git a/libs/libc/unistd/lib_sysconf.c b/libs/libc/unistd/lib_sysconf.c
index 4890a7290b..7a9df35408 100644
--- a/libs/libc/unistd/lib_sysconf.c
+++ b/libs/libc/unistd/lib_sysconf.c
@@ -223,6 +223,10 @@ long sysconf(int name)
         return _POSIX_PRIORITIZED_IO;
       case _SC_AIO_MAX:
         return _POSIX_AIO_MAX;
+      case _SC_CPUTIME:
+        return _POSIX_CPUTIME;
+      case _SC_THREAD_CPUTIME:
+        return _POSIX_THREAD_CPUTIME;
       case _SC_CLK_TCK:
         return CLOCKS_PER_SEC;
 
diff --git a/sched/clock/clock_getres.c b/sched/clock/clock_getres.c
index 4253e2a4aa..c5b27104f7 100644
--- a/sched/clock/clock_getres.c
+++ b/sched/clock/clock_getres.c
@@ -60,6 +60,8 @@ int clock_getres(clockid_t clock_id, struct timespec *res)
       case CLOCK_MONOTONIC:
       case CLOCK_BOOTTIME:
       case CLOCK_REALTIME:
+      case CLOCK_PROCESS_CPUTIME_ID:
+      case CLOCK_THREAD_CPUTIME_ID:
 
         /* Form the timspec using clock resolution in nanoseconds */