2018-03-13 22:07:03 +08:00
|
|
|
/****************************************************************************
|
2018-06-17 02:50:28 +08:00
|
|
|
* sched/clock/clock.c
|
2018-03-13 22:07:03 +08:00
|
|
|
*
|
2024-09-11 19:45:11 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
2021-02-08 23:33:58 +08:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2018-03-13 22:07:03 +08:00
|
|
|
*
|
2021-02-08 23:33:58 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-03-13 22:07:03 +08:00
|
|
|
*
|
2021-02-08 23:33:58 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2018-03-13 22:07:03 +08:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* 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
|
2020-05-05 01:34:04 +08:00
|
|
|
* be divided by the value of the macro CLOCKS_PER_SEC as defined in
|
|
|
|
* <time.h>.
|
2018-03-13 22:07:03 +08:00
|
|
|
*
|
2019-10-18 02:24:19 +08:00
|
|
|
* NOTE: The current implementation does NOT return the processor time
|
|
|
|
* used by the process. NuttX currently does not keep any record of
|
|
|
|
* processing time. Instead the elapsed time since power up is returned.
|
|
|
|
*
|
2018-03-13 22:07:03 +08:00
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Value:
|
2019-10-18 02:24:19 +08:00
|
|
|
* The system time in units of clock ticks is returned. If the processor
|
2018-03-13 22:07:03 +08:00
|
|
|
* time used is not available or its value cannot be represented, the
|
|
|
|
* function will return the value (clock_t)-1.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
clock_t clock(void)
|
|
|
|
{
|
2020-05-04 22:15:10 +08:00
|
|
|
return (clock_t)clock_systime_ticks();
|
2018-03-13 22:07:03 +08:00
|
|
|
}
|