gettimeofday() and settimeofday(): Move gittimeofdady() from sched/clock to libc/time. All remove gettimeofday() from NuttX system calls. It is only a wrapper around clock_settime() and does not need a trap. gettimeofday() is no longer tried as a core OS interface.
gettimeofday has been decremented in POSIX 2008. settimeofday() was never part of POSIX, but I decided to add it to libc as well just for symmetry.
This commit is contained in:
parent
5e8cdece21
commit
147042218b
@ -130,7 +130,8 @@ extern volatile bool g_rtc_enabled;
|
|||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#define EXTERN extern "C"
|
#define EXTERN extern "C"
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#else
|
#else
|
||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
@ -150,7 +151,7 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
EXTERN int up_rtcinitialize(void);
|
int up_rtcinitialize(void);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: up_rtc_time
|
* Name: up_rtc_time
|
||||||
@ -159,7 +160,7 @@ EXTERN int up_rtcinitialize(void);
|
|||||||
* Get the current time in seconds. This is similar to the standard time()
|
* Get the current time in seconds. This is similar to the standard time()
|
||||||
* function. This interface is only required if the low-resolution RTC/counter
|
* function. This interface is only required if the low-resolution RTC/counter
|
||||||
* hardware implementation selected. It is only used by the RTOS during
|
* hardware implementation selected. It is only used by the RTOS during
|
||||||
* initializeation to set up the system time when CONFIG_RTC is set but neither
|
* initialization to set up the system time when CONFIG_RTC is set but neither
|
||||||
* CONFIG_RTC_HIRES nor CONFIG_RTC_DATETIME are set.
|
* CONFIG_RTC_HIRES nor CONFIG_RTC_DATETIME are set.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
@ -171,7 +172,7 @@ EXTERN int up_rtcinitialize(void);
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifndef CONFIG_RTC_HIRES
|
#ifndef CONFIG_RTC_HIRES
|
||||||
EXTERN time_t up_rtc_time(void);
|
time_t up_rtc_time(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
@ -191,7 +192,7 @@ EXTERN time_t up_rtc_time(void);
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_HIRES
|
#ifdef CONFIG_RTC_HIRES
|
||||||
EXTERN int up_rtc_gettime(FAR struct timespec *tp);
|
int up_rtc_gettime(FAR struct timespec *tp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
@ -201,7 +202,7 @@ EXTERN int up_rtc_gettime(FAR struct timespec *tp);
|
|||||||
* Get the current date and time from the date/time RTC. This interface
|
* Get the current date and time from the date/time RTC. This interface
|
||||||
* is only supported by the date/time RTC hardware implementation.
|
* is only supported by the date/time RTC hardware implementation.
|
||||||
* It is used to replace the system timer. It is only used by the RTOS during
|
* It is used to replace the system timer. It is only used by the RTOS during
|
||||||
* initializeation to set up the system time when CONFIG_RTC and CONFIG_RTC_DATETIME
|
* initialization to set up the system time when CONFIG_RTC and CONFIG_RTC_DATETIME
|
||||||
* are selected (and CONFIG_RTC_HIRES is not).
|
* are selected (and CONFIG_RTC_HIRES is not).
|
||||||
*
|
*
|
||||||
* NOTE: Some date/time RTC hardware is capability of sub-second accuracy. That
|
* NOTE: Some date/time RTC hardware is capability of sub-second accuracy. That
|
||||||
@ -218,7 +219,7 @@ EXTERN int up_rtc_gettime(FAR struct timespec *tp);
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_DATETIME
|
#ifdef CONFIG_RTC_DATETIME
|
||||||
EXTERN int up_rtc_getdatetime(FAR struct tm *tp);
|
int up_rtc_getdatetime(FAR struct tm *tp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
@ -236,7 +237,7 @@ EXTERN int up_rtc_getdatetime(FAR struct tm *tp);
|
|||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
EXTERN int up_rtc_settime(FAR const struct timespec *tp);
|
int up_rtc_settime(FAR const struct timespec *tp);
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Name: up_rtc_setalarm
|
* Name: up_rtc_setalarm
|
||||||
@ -254,7 +255,7 @@ EXTERN int up_rtc_settime(FAR const struct timespec *tp);
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
EXTERN int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback);
|
int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
@ -272,7 +273,7 @@ EXTERN int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback);
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_ALARM
|
#ifdef CONFIG_RTC_ALARM
|
||||||
EXTERN int up_rtc_cancelalarm(void);
|
int up_rtc_cancelalarm(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
@ -202,8 +202,7 @@
|
|||||||
#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)
|
||||||
#define SYS_gettimeofday (__SYS_clock+4)
|
#define __SYS_timers (__SYS_clock+4)
|
||||||
#define __SYS_timers (__SYS_clock+5)
|
|
||||||
|
|
||||||
/* The following are defined only if POSIX timers are supported */
|
/* The following are defined only if POSIX timers are supported */
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* include/sys/time.h
|
* include/sys/time.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009, 2015 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
|
||||||
@ -51,6 +51,17 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Type Definitions
|
* Public Type Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
/* struct timeval is defined in time.h */
|
||||||
|
|
||||||
|
/* The use of the struct timezone is obsolete; the tz argument should
|
||||||
|
* normally be specified as NULL (and is ignored in any event).
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct timezone
|
||||||
|
{
|
||||||
|
int tz_minuteswest; /* Minutes west of Greenwich */
|
||||||
|
int tz_dsttime; /* Type of DST correction */
|
||||||
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
@ -59,12 +70,58 @@
|
|||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
#define EXTERN extern "C"
|
#define EXTERN extern "C"
|
||||||
extern "C" {
|
extern "C"
|
||||||
|
{
|
||||||
#else
|
#else
|
||||||
#define EXTERN extern
|
#define EXTERN extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
EXTERN int gettimeofday(struct timeval *tp, FAR void *tzp);
|
/****************************************************************************
|
||||||
|
* Name: gettimeofday
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Get the current time
|
||||||
|
*
|
||||||
|
* Conforming to SVr4, 4.3BSD. POSIX.1-2001 describes gettimeofday().
|
||||||
|
* POSIX.1-2008 marks gettimeofday() as obsolete, recommending the use of
|
||||||
|
* clock_gettime(2) instead.
|
||||||
|
*
|
||||||
|
* NuttX implements gettimeofday() as a thin layer around clock_gettime();
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* tv - The location to return the current time
|
||||||
|
* tz - Ignored
|
||||||
|
*
|
||||||
|
* Returned value:
|
||||||
|
* Zero (OK) on success; -1 is returned on failure with the errno variable
|
||||||
|
* set appropriately.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int gettimeofday(FAR struct timeval *tv, FAR struct timezone *tz);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: settimeofday
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the current time
|
||||||
|
*
|
||||||
|
* Conforming to SVr4, 4.3BSD. POSIX.1-2001 describes gettimeofday() but
|
||||||
|
* not settimeofday().
|
||||||
|
*
|
||||||
|
* NuttX implements settimeofday() as a thin layer around clock_settime();
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* tv - The net to time to be set
|
||||||
|
* tz - Ignored
|
||||||
|
*
|
||||||
|
* Returned value:
|
||||||
|
* Zero (OK) on success; -1 is returned on failure with the errno variable
|
||||||
|
* set appropriately.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int settimeofday(FAR const struct timeval *tv, FAR struct timezone *tz);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
# Add the time C files to the build
|
# Add the time C files to the build
|
||||||
|
|
||||||
CSRCS += lib_strftime.c lib_calendar2utc.c lib_daysbeforemonth.c
|
CSRCS += lib_strftime.c lib_calendar2utc.c lib_daysbeforemonth.c
|
||||||
CSRCS += lib_isleapyear.c lib_time.c
|
CSRCS += lib_gettimeofday.c lib_isleapyear.c lib_settimeofday.c lib_time.c
|
||||||
|
|
||||||
ifdef CONFIG_LIBC_LOCALTIME
|
ifdef CONFIG_LIBC_LOCALTIME
|
||||||
CSRCS += lib_localtime.c
|
CSRCS += lib_localtime.c
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* sched/clock/clock_gettimeofday.c
|
* libc/time/lib_gettimeofday.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2009, 2015 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
|
||||||
@ -40,38 +40,10 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include "clock/clock.h"
|
#include <nuttx/clock.h>
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Type Declarations
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Function Prototypes
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* Public Constant Data
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Variables
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/**************************************************************************
|
|
||||||
* Private Variables
|
|
||||||
**************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
@ -81,17 +53,31 @@
|
|||||||
* Name: gettimeofday
|
* Name: gettimeofday
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Get the current time
|
* Get the current time
|
||||||
|
*
|
||||||
|
* Conforming to SVr4, 4.3BSD. POSIX.1-2001 describes gettimeofday().
|
||||||
|
* POSIX.1-2008 marks gettimeofday() as obsolete, recommending the use of
|
||||||
|
* clock_gettime(2) instead.
|
||||||
|
*
|
||||||
|
* NuttX implements gettimeofday() as a thin layer around clock_gettime();
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* tv - The location to return the current time
|
||||||
|
* tz - Ignored
|
||||||
|
*
|
||||||
|
* Returned value:
|
||||||
|
* Zero (OK) on success; -1 is returned on failure with the errno variable
|
||||||
|
* set appropriately.
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int gettimeofday(struct timeval *tp, void *tzp)
|
int gettimeofday(FAR struct timeval *tv, FAR struct timezone *tz)
|
||||||
{
|
{
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
if (!tp)
|
if (!tv)
|
||||||
{
|
{
|
||||||
set_errno(EINVAL);
|
set_errno(EINVAL);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
@ -105,8 +91,8 @@ int gettimeofday(struct timeval *tp, void *tzp)
|
|||||||
{
|
{
|
||||||
/* Convert the struct timespec to a struct timeval */
|
/* Convert the struct timespec to a struct timeval */
|
||||||
|
|
||||||
tp->tv_sec = ts.tv_sec;
|
tv->tv_sec = ts.tv_sec;
|
||||||
tp->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
|
tv->tv_usec = ts.tv_nsec / NSEC_PER_USEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
92
libc/time/lib_settimeofday.c
Normal file
92
libc/time/lib_settimeofday.c
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* libc/time/lib_settimeofday.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 <sys/time.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include <nuttx/clock.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: settimeofday
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Set the current time
|
||||||
|
*
|
||||||
|
* Conforming to SVr4, 4.3BSD. POSIX.1-2001 describes gettimeofday() but
|
||||||
|
* not settimeofday().
|
||||||
|
*
|
||||||
|
* NuttX implements settimeofday() as a thin layer around clock_settime();
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* tv - The net to time to be set
|
||||||
|
* tz - Ignored
|
||||||
|
*
|
||||||
|
* Returned value:
|
||||||
|
* Zero (OK) on success; -1 is returned on failure with the errno variable
|
||||||
|
* set appropriately.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int settimeofday(FAR const struct timeval *tv, FAR struct timezone *tz)
|
||||||
|
{
|
||||||
|
struct timespec ts;
|
||||||
|
|
||||||
|
#ifdef CONFIG_DEBUG
|
||||||
|
if (!tv || tv->tv_usec >= USEC_PER_SEC)
|
||||||
|
{
|
||||||
|
set_errno(EINVAL);
|
||||||
|
return ERROR;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/* Convert the timeval to a timespec */
|
||||||
|
|
||||||
|
ts.tv_sec = tv->tv_sec;
|
||||||
|
ts.tv_nsec = tv->tv_usec * NSEC_PER_USEC;
|
||||||
|
|
||||||
|
/* Let clock_settime do the work */
|
||||||
|
|
||||||
|
return clock_settime(CLOCK_REALTIME, &ts);
|
||||||
|
}
|
@ -42,18 +42,6 @@
|
|||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Function: time
|
* Function: time
|
||||||
*
|
*
|
||||||
@ -62,13 +50,13 @@
|
|||||||
* this value, and if the argument is not a null pointer, the value is also
|
* this value, and if the argument is not a null pointer, the value is also
|
||||||
* set to the object pointed by tloc.
|
* set to the object pointed by tloc.
|
||||||
*
|
*
|
||||||
* Note that this function is just a thin wrapper around gettimeofday()
|
* Note that this function is just a thin wrapper around clock_gettime()
|
||||||
* and is provided for compatibility. gettimeofday() is the preffered way
|
* and is provided for compatibility. clock_gettime() is the preferred way
|
||||||
* to obtain system time.
|
* to obtain system time.
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* Pointer to an object of type time_t, where the time value is stored.
|
* Pointer to an object of type time_t, where the time value is stored.
|
||||||
* Alternativelly, this parameter can be a null pointer, in which case the
|
* Alternatively, this parameter can be a null pointer, in which case the
|
||||||
* parameter is not used, but a time_t object is still returned by the
|
* parameter is not used, but a time_t object is still returned by the
|
||||||
* function.
|
* function.
|
||||||
*
|
*
|
||||||
@ -84,22 +72,22 @@
|
|||||||
|
|
||||||
time_t time(time_t *tloc)
|
time_t time(time_t *tloc)
|
||||||
{
|
{
|
||||||
struct timeval tp;
|
struct timespec ts;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Get the current time from the system */
|
/* Get the current time from the system */
|
||||||
|
|
||||||
ret = gettimeofday(&tp, NULL);
|
ret = clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
if (ret == OK)
|
if (ret == OK)
|
||||||
{
|
{
|
||||||
/* Return the seconds since the epoch */
|
/* Return the seconds since the epoch */
|
||||||
|
|
||||||
if (tloc)
|
if (tloc)
|
||||||
{
|
{
|
||||||
*tloc = tp.tv_sec;
|
*tloc = ts.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tp.tv_sec;
|
return ts.tv_sec;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (time_t)ERROR;
|
return (time_t)ERROR;
|
||||||
|
@ -35,7 +35,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_gettimeofday.c clock_systimer.c clock_systimespec.c
|
CSRCS += clock_systimer.c clock_systimespec.c
|
||||||
|
|
||||||
# Include clock build support
|
# Include clock build support
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
"getenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char*","FAR const char*"
|
"getenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","FAR char*","FAR const char*"
|
||||||
"getpid","unistd.h","","pid_t"
|
"getpid","unistd.h","","pid_t"
|
||||||
"getsockopt","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int","int","FAR void*","FAR socklen_t*"
|
"getsockopt","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int","int","FAR void*","FAR socklen_t*"
|
||||||
"gettimeofday","sys/time.h","","int","struct timeval*","FAR void*"
|
|
||||||
"ioctl","sys/ioctl.h","!defined(CONFIG_LIBC_IOCTL_VARIADIC) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","int","int","unsigned long"
|
"ioctl","sys/ioctl.h","!defined(CONFIG_LIBC_IOCTL_VARIADIC) && (CONFIG_NSOCKET_DESCRIPTORS > 0 || CONFIG_NFILE_DESCRIPTORS > 0)","int","int","int","unsigned long"
|
||||||
"kill","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","pid_t","int"
|
"kill","signal.h","!defined(CONFIG_DISABLE_SIGNALS)","int","pid_t","int"
|
||||||
"listen","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int"
|
"listen","sys/socket.h","CONFIG_NSOCKET_DESCRIPTORS > 0 && defined(CONFIG_NET)","int","int","int"
|
||||||
|
Can't render this file because it has a wrong number of fields in line 2.
|
@ -142,7 +142,6 @@ SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert)
|
|||||||
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)
|
||||||
SYSCALL_LOOKUP(gettimeofday, 2, STUB_gettimeofday)
|
|
||||||
|
|
||||||
/* The following are defined only if POSIX timers are supported */
|
/* The following are defined only if POSIX timers are supported */
|
||||||
|
|
||||||
|
@ -144,7 +144,6 @@ uintptr_t STUB_clock_systimer(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);
|
||||||
uintptr_t STUB_gettimeofday(int nbr, uintptr_t parm1, uintptr_t parm2);
|
|
||||||
|
|
||||||
/* The following are defined only if POSIX timers are supported */
|
/* The following are defined only if POSIX timers are supported */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user