mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 14:27:37 +08:00
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:
@@ -38,7 +38,7 @@
|
||||
|
||||
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_difftime.c lib_clock.c
|
||||
CSRCS += lib_difftime.c
|
||||
|
||||
ifndef CONFIG_DISABLE_SIGNALS
|
||||
CSRCS += lib_nanosleep.c
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/time/lib_clock.c
|
||||
*
|
||||
* Copyright (C) 2015 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 <time.h>
|
||||
|
||||
#include <nuttx/clock.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: clock
|
||||
*
|
||||
* Description:
|
||||
* The clock() function returns the implementation's best approximation to
|
||||
* the processor time used by the process since the beginning of a
|
||||
* implementation-defined era related only to the process invocation.
|
||||
*
|
||||
* To determine the time in seconds, the value returned by clock() should
|
||||
* be divided by the value of the macro CLOCKS_PER_SEC as defined in <time.h>.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* The system time in units of clock ticks is returend. If the processor
|
||||
* time used is not available or its value cannot be represented, the
|
||||
* function will return the value (clock_t)-1.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
clock_t clock(void)
|
||||
{
|
||||
return (clock_t)clock_systimer();
|
||||
}
|
||||
@@ -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. */
|
||||
|
||||
work->qtime = clock_systimer(); /* Time work queued */
|
||||
work->qtime = clock(); /* Time work queued */
|
||||
|
||||
dq_addlast((FAR dq_entry_t *)work, &wqueue->q);
|
||||
kill(wqueue->pid, SIGWORK); /* Wake up the worker thread */
|
||||
|
||||
@@ -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. */
|
||||
|
||||
stick = clock_systimer();
|
||||
stick = clock();
|
||||
|
||||
/* 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
|
||||
@@ -157,7 +157,7 @@ void work_process(FAR struct usr_wqueue_s *wqueue)
|
||||
* zero. Therefore a delay of zero will always execute immediately.
|
||||
*/
|
||||
|
||||
ctick = clock_systimer();
|
||||
ctick = clock();
|
||||
elapsed = ctick - work->qtime;
|
||||
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 */
|
||||
|
||||
elapsed = clock_systimer() - stick;
|
||||
elapsed = clock() - stick;
|
||||
if (elapsed < wqueue->delay && next > 0)
|
||||
{
|
||||
/* How must time would we need to delay to get to the end of the
|
||||
|
||||
Reference in New Issue
Block a user