From b0378096d37f4e5d124a4ee7b9e9365d2f85ee83 Mon Sep 17 00:00:00 2001 From: teamol Date: Thu, 29 Apr 2021 15:42:15 +0800 Subject: [PATCH 1/2] fix time mould by ChinaSoft Team Change-Id: I8224c82a2fb34b0ab6e5b9b100f7de860f95cafe --- kernel/include/time.h | 3 +++ src/thread/pthread_getcpuclockid.c | 2 -- src/time/clock_getcpuclockid.c | 2 -- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/include/time.h b/kernel/include/time.h index 7c7b34776..7092c3fe4 100644 --- a/kernel/include/time.h +++ b/kernel/include/time.h @@ -109,6 +109,9 @@ struct itimerspec64 { #define MAX_CLOCKS 16 +#define CPUCLOCK_PERTHREAD_MASK 4 +#define CPUCLOCK_ID_OFFSET 3 + #define TIMER_ABSTIME 1 int nanosleep (const struct timespec *, struct timespec *); diff --git a/src/thread/pthread_getcpuclockid.c b/src/thread/pthread_getcpuclockid.c index 41c6b7d98..9df14fb68 100755 --- a/src/thread/pthread_getcpuclockid.c +++ b/src/thread/pthread_getcpuclockid.c @@ -1,9 +1,7 @@ -#include #include "pthread_impl.h" int pthread_getcpuclockid(pthread_t t, clockid_t *clockid) { - unsupported_api(__FUNCTION__); *clockid = (-t->tid-1)*8U + 6; return 0; } diff --git a/src/time/clock_getcpuclockid.c b/src/time/clock_getcpuclockid.c index aa916f3d3..1c1b14947 100755 --- a/src/time/clock_getcpuclockid.c +++ b/src/time/clock_getcpuclockid.c @@ -1,13 +1,11 @@ #include #include #include -#include #include "syscall.h" int clock_getcpuclockid(pid_t pid, clockid_t *clk) { struct timespec ts; - unsupported_api(__FUNCTION__); clockid_t id = (-pid-1)*8U + 2; int ret = __syscall(SYS_clock_getres, id, &ts); -- Gitee From d72436c4a4abfbad457796b75b581e276ae4c7e5 Mon Sep 17 00:00:00 2001 From: teamol Date: Thu, 29 Apr 2021 15:42:15 +0800 Subject: [PATCH 2/2] fix time mould by ChinaSoft Team Change-Id: I8224c82a2fb34b0ab6e5b9b100f7de860f95cafe --- kernel/include/time.h | 3 +++ src/thread/pthread_getcpuclockid.c | 32 ++++++++++++++++++++++++++++-- src/time/clock_getcpuclockid.c | 2 -- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/kernel/include/time.h b/kernel/include/time.h index 7c7b34776..7092c3fe4 100644 --- a/kernel/include/time.h +++ b/kernel/include/time.h @@ -109,6 +109,9 @@ struct itimerspec64 { #define MAX_CLOCKS 16 +#define CPUCLOCK_PERTHREAD_MASK 4 +#define CPUCLOCK_ID_OFFSET 3 + #define TIMER_ABSTIME 1 int nanosleep (const struct timespec *, struct timespec *); diff --git a/src/thread/pthread_getcpuclockid.c b/src/thread/pthread_getcpuclockid.c index 41c6b7d98..6a43ed32c 100755 --- a/src/thread/pthread_getcpuclockid.c +++ b/src/thread/pthread_getcpuclockid.c @@ -1,9 +1,37 @@ -#include +/* +* Copyright (c) 2019-2021, Huawei Technologies Co., Ltd. All rights reserved. +* Copyright (c) 2019-2021, Huawei Device Co., Ltd. All rights reserved. +* +* Redistribution and use in source and binary forms, with or without modification, +* are permitted provided that the following conditions are met: +* +* 1. Redistributions of source code must retain the above copyright notice, this list of +* conditions and the following disclaimer. +* +* 2. Redistributions in binary form must reproduce the above copyright notice, this list +* of conditions and the following disclaimer in the documentation and/or other materials +* provided with the distribution. +* +* 3. Neither the name of the copyright holder nor the names of its contributors may be used +* to endorse or promote products derived from this software without specific prior written +* permission. +* +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR +* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; +* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF +* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ #include "pthread_impl.h" int pthread_getcpuclockid(pthread_t t, clockid_t *clockid) { - unsupported_api(__FUNCTION__); *clockid = (-t->tid-1)*8U + 6; return 0; } diff --git a/src/time/clock_getcpuclockid.c b/src/time/clock_getcpuclockid.c index aa916f3d3..1c1b14947 100755 --- a/src/time/clock_getcpuclockid.c +++ b/src/time/clock_getcpuclockid.c @@ -1,13 +1,11 @@ #include #include #include -#include #include "syscall.h" int clock_getcpuclockid(pid_t pid, clockid_t *clk) { struct timespec ts; - unsupported_api(__FUNCTION__); clockid_t id = (-pid-1)*8U + 2; int ret = __syscall(SYS_clock_getres, id, &ts); -- Gitee