syscall: clock_systimer() is no longer a system call. It has been replaced with the equivalent, standard interface clock() as the system call.

sched/clock:  Move the implementation of clock() from libs/libc/time to sched/clock.  This is necessary because it calls the (now) internal OS function clock_systimer.  clock() is now accessed only via a system call in certain configuratins.
libs/libc/wqueue:  Replace calls to clock_systimer() with calls to the equivalent clock().
This commit is contained in:
Gregory Nutt
2018-06-16 12:50:28 -06:00
parent 8fdbb1e0a4
commit 8fca244f36
12 changed files with 14 additions and 108 deletions
+3 -3
View File
@@ -1,8 +1,8 @@
/**************************************************************************** ystim****************************************************************************
* include/sys/syscall.h * include/sys/syscall.h
* This file contains the system call numbers. * This file contains the system call numbers.
* *
* Copyright (C) 2011-2017 Gregory Nutt. All rights reserved. * Copyright (C) 2011-2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@@ -237,7 +237,7 @@
* NuttX configuration. * NuttX configuration.
*/ */
#define SYS_clock_systimer (__SYS_clock+0) #define SYS_clock (__SYS_clock+0)
#define SYS_clock_getres (__SYS_clock+1) #define SYS_clock_getres (__SYS_clock+1)
#define SYS_clock_gettime (__SYS_clock+2) #define SYS_clock_gettime (__SYS_clock+2)
#define SYS_clock_settime (__SYS_clock+3) #define SYS_clock_settime (__SYS_clock+3)
+1 -1
View File
@@ -38,7 +38,7 @@
CSRCS += lib_strftime.c lib_calendar2utc.c lib_daysbeforemonth.c CSRCS += lib_strftime.c lib_calendar2utc.c lib_daysbeforemonth.c
CSRCS += lib_gettimeofday.c lib_isleapyear.c lib_settimeofday.c lib_time.c CSRCS += lib_gettimeofday.c lib_isleapyear.c lib_settimeofday.c lib_time.c
CSRCS += lib_difftime.c lib_clock.c CSRCS += lib_difftime.c
ifndef CONFIG_DISABLE_SIGNALS ifndef CONFIG_DISABLE_SIGNALS
CSRCS += lib_nanosleep.c CSRCS += lib_nanosleep.c
+1 -1
View File
@@ -114,7 +114,7 @@ static int work_qqueue(FAR struct usr_wqueue_s *wqueue,
/* Now, time-tag that entry and put it in the work queue. */ /* Now, time-tag that entry and put it in the work queue. */
work->qtime = clock_systimer(); /* Time work queued */ work->qtime = clock(); /* Time work queued */
dq_addlast((FAR dq_entry_t *)work, &wqueue->q); dq_addlast((FAR dq_entry_t *)work, &wqueue->q);
kill(wqueue->pid, SIGWORK); /* Wake up the worker thread */ kill(wqueue->pid, SIGWORK); /* Wake up the worker thread */
+3 -3
View File
@@ -141,7 +141,7 @@ void work_process(FAR struct usr_wqueue_s *wqueue)
/* Get the time that we started this polling cycle in clock ticks. */ /* Get the time that we started this polling cycle in clock ticks. */
stick = clock_systimer(); stick = clock();
/* And check each entry in the work queue. Since we have locked the /* And check each entry in the work queue. Since we have locked the
* work queue we know: (1) we will not be suspended unless we do * work queue we know: (1) we will not be suspended unless we do
@@ -157,7 +157,7 @@ void work_process(FAR struct usr_wqueue_s *wqueue)
* zero. Therefore a delay of zero will always execute immediately. * zero. Therefore a delay of zero will always execute immediately.
*/ */
ctick = clock_systimer(); ctick = clock();
elapsed = ctick - work->qtime; elapsed = ctick - work->qtime;
if (elapsed >= work->delay) if (elapsed >= work->delay)
{ {
@@ -251,7 +251,7 @@ void work_process(FAR struct usr_wqueue_s *wqueue)
/* Get the delay (in clock ticks) since we started the sampling */ /* Get the delay (in clock ticks) since we started the sampling */
elapsed = clock_systimer() - stick; elapsed = clock() - stick;
if (elapsed < wqueue->delay && next > 0) if (elapsed < wqueue->delay && next > 0)
{ {
/* How must time would we need to delay to get to the end of the /* How must time would we need to delay to get to the end of the
+1 -1
View File
@@ -36,7 +36,7 @@
CSRCS += clock_initialize.c clock_settime.c clock_gettime.c clock_getres.c CSRCS += clock_initialize.c clock_settime.c clock_gettime.c clock_getres.c
CSRCS += clock_time2ticks.c clock_abstime2ticks.c clock_ticks2time.c CSRCS += clock_time2ticks.c clock_abstime2ticks.c clock_ticks2time.c
CSRCS += clock_systimer.c clock_systimespec.c clock_timespec_add.c CSRCS += clock_systimer.c clock_systimespec.c clock_timespec_add.c
CSRCS += clock_timespec_subtract.c CSRCS += clock_timespec_subtract.c clock.c
ifeq ($(CONFIG_CLOCK_TIMEKEEPING),y) ifeq ($(CONFIG_CLOCK_TIMEKEEPING),y)
CSRCS += clock_timekeeping.c CSRCS += clock_timekeeping.c
@@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* libs/libc/time/lib_clock.c * sched/clock/clock.c
* *
* Copyright (C) 2015 Gregory Nutt. All rights reserved. * Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
-1
View File
@@ -43,7 +43,6 @@ MKSYSCALL = "$(TOPDIR)$(DELIM)tools$(DELIM)mksyscall$(HOSTEXEEXT)"
CSVFILE = "$(TOPDIR)$(DELIM)syscall$(DELIM)syscall.csv" CSVFILE = "$(TOPDIR)$(DELIM)syscall$(DELIM)syscall.csv"
STUB_SRCS += syscall_funclookup.c syscall_stublookup.c syscall_nparms.c STUB_SRCS += syscall_funclookup.c syscall_stublookup.c syscall_nparms.c
STUB_SRCS += syscall_clock_systimer.c
ASRCS = ASRCS =
AOBJS = $(ASRCS:.S=$(OBJEXT)) AOBJS = $(ASRCS:.S=$(OBJEXT))
+1 -1
View File
@@ -9,11 +9,11 @@
"bind","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","FAR const struct sockaddr*","socklen_t" "bind","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","FAR const struct sockaddr*","socklen_t"
"boardctl","sys/boardctl.h","defined(CONFIG_LIB_BOARDCTL)","int","unsigned int","uintptr_t" "boardctl","sys/boardctl.h","defined(CONFIG_LIB_BOARDCTL)","int","unsigned int","uintptr_t"
"clearenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","int" "clearenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","int"
"clock","time.h","","clock_t"
"clock_getres","time.h","","int","clockid_t","struct timespec*" "clock_getres","time.h","","int","clockid_t","struct timespec*"
"clock_gettime","time.h","","int","clockid_t","struct timespec*" "clock_gettime","time.h","","int","clockid_t","struct timespec*"
"clock_nanosleep","time.h","!defined(CONFIG_DISABLE_SIGNALS)","int","clockid_t","int","FAR const struct timespec *", "FAR struct timespec*" "clock_nanosleep","time.h","!defined(CONFIG_DISABLE_SIGNALS)","int","clockid_t","int","FAR const struct timespec *", "FAR struct timespec*"
"clock_settime","time.h","","int","clockid_t","const struct timespec*" "clock_settime","time.h","","int","clockid_t","const struct timespec*"
"clock_systimer","nuttx/clock.h","!defined(__HAVE_KERNEL_GLOBALS)","clock_t"
"close","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","int","int" "close","unistd.h","CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0","int","int"
"closedir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR DIR*" "closedir","dirent.h","CONFIG_NFILE_DESCRIPTORS > 0","int","FAR DIR*"
"connect","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","FAR const struct sockaddr*","socklen_t" "connect","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","FAR const struct sockaddr*","socklen_t"
1 _exit unistd.h void int
9 bind sys/socket.h CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET) int int
10 boardctl sys/boardctl.h defined(CONFIG_LIB_BOARDCTL) int unsigned int
11 clearenv stdlib.h !defined(CONFIG_DISABLE_ENVIRON) int
12 clock time.h clock_t
13 clock_getres time.h int clockid_t
14 clock_gettime time.h int clockid_t
15 clock_nanosleep time.h !defined(CONFIG_DISABLE_SIGNALS) int clockid_t
16 clock_settime time.h int clockid_t
clock_systimer nuttx/clock.h !defined(__HAVE_KERNEL_GLOBALS) clock_t
17 close unistd.h CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0 int int
18 closedir dirent.h CONFIG_NFILE_DESCRIPTORS > 0 int FAR DIR*
19 connect sys/socket.h CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET) int int
-80
View File
@@ -1,80 +0,0 @@
/****************************************************************************
* syscall/syscall_clock_systimer.c
*
* Copyright (C) 2011-2012, 2014, 2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 NuttX 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 OWNER 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <nuttx/clock.h>
/****************************************************************************
* Pre-processor definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: syscall_clock_systimer
*
* Description:
* In the kernel build, proxying for clock_systimer() must be handled
* specially. In the kernel phase of the build, clock_systimer() is
* macro that simply accesses a global variable. In the user phase of
* the kernel build, clock_systimer() is a proxy function.
*
* In order to fill out the table g_funclookup[], this function will stand
* in during the kernel phase of the build so that clock_systemer() will
* have an address that can be included in the g_funclookup[] table.
*
****************************************************************************/
clock_t syscall_clock_systimer(void)
{
return clock_systimer();
}
-13
View File
@@ -89,19 +89,6 @@
#include <nuttx/errno.h> #include <nuttx/errno.h>
#include <nuttx/clock.h> #include <nuttx/clock.h>
/* clock_systimer is a special case: In the kernel build, proxying for
* clock_systimer() must be handled specially. In the kernel phase of
* the build, clock_systimer() is macro that simply accesses a global
* variable. In the user phase of the kernel build, clock_systimer()
* is a proxy function.
*
* In order to fill out the table g_funclookup[], this function will stand
* in during the kernel phase of the build so that clock_systemer() will
* have an address that can be included in the g_funclookup[] table.
*/
clock_t syscall_clock_systimer(void);
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
+1 -1
View File
@@ -164,7 +164,7 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert)
* NuttX configuration. * NuttX configuration.
*/ */
SYSCALL_LOOKUP(syscall_clock_systimer, 0, STUB_clock_systimer) SYSCALL_LOOKUP(syscall_clock, 0, STUB_clock)
SYSCALL_LOOKUP(clock_getres, 2, STUB_clock_getres) SYSCALL_LOOKUP(clock_getres, 2, STUB_clock_getres)
SYSCALL_LOOKUP(clock_gettime, 2, STUB_clock_gettime) SYSCALL_LOOKUP(clock_gettime, 2, STUB_clock_gettime)
SYSCALL_LOOKUP(clock_settime, 2, STUB_clock_settime) SYSCALL_LOOKUP(clock_settime, 2, STUB_clock_settime)
+1 -1
View File
@@ -160,7 +160,7 @@ uintptr_t STUB_clock_nanosleep(int nbr, uintptr_t parm1, uintptr_t parm2,
* NuttX configuration. * NuttX configuration.
*/ */
uintptr_t STUB_clock_systimer(int nbr); uintptr_t STUB_clock(int nbr);
uintptr_t STUB_clock_getres(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_clock_getres(int nbr, uintptr_t parm1, uintptr_t parm2);
uintptr_t STUB_clock_gettime(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_clock_gettime(int nbr, uintptr_t parm1, uintptr_t parm2);
uintptr_t STUB_clock_settime(int nbr, uintptr_t parm1, uintptr_t parm2); uintptr_t STUB_clock_settime(int nbr, uintptr_t parm1, uintptr_t parm2);