From 7881095dcc9ce16c67163cc3d9b8fb7c2adf4c66 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 12 Feb 2015 11:10:46 -0600 Subject: 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. --- nuttx/include/nuttx/rtc.h | 21 ++++++++------- nuttx/include/sys/syscall.h | 3 +-- nuttx/include/sys/time.h | 63 ++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 72 insertions(+), 15 deletions(-) (limited to 'nuttx/include') diff --git a/nuttx/include/nuttx/rtc.h b/nuttx/include/nuttx/rtc.h index 1b5658f16..b7801fd36 100644 --- a/nuttx/include/nuttx/rtc.h +++ b/nuttx/include/nuttx/rtc.h @@ -130,7 +130,8 @@ extern volatile bool g_rtc_enabled; #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" -extern "C" { +extern "C" +{ #else #define EXTERN extern #endif @@ -150,7 +151,7 @@ extern "C" { * ************************************************************************************/ -EXTERN int up_rtcinitialize(void); +int up_rtcinitialize(void); /************************************************************************************ * 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() * function. This interface is only required if the low-resolution RTC/counter * 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. * * Input Parameters: @@ -171,7 +172,7 @@ EXTERN int up_rtcinitialize(void); ************************************************************************************/ #ifndef CONFIG_RTC_HIRES -EXTERN time_t up_rtc_time(void); +time_t up_rtc_time(void); #endif /************************************************************************************ @@ -191,7 +192,7 @@ EXTERN time_t up_rtc_time(void); ************************************************************************************/ #ifdef CONFIG_RTC_HIRES -EXTERN int up_rtc_gettime(FAR struct timespec *tp); +int up_rtc_gettime(FAR struct timespec *tp); #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 * 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 - * 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). * * 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 -EXTERN int up_rtc_getdatetime(FAR struct tm *tp); +int up_rtc_getdatetime(FAR struct tm *tp); #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 @@ -254,7 +255,7 @@ EXTERN int up_rtc_settime(FAR const struct timespec *tp); ************************************************************************************/ #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 /************************************************************************************ @@ -272,7 +273,7 @@ EXTERN int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback); ************************************************************************************/ #ifdef CONFIG_RTC_ALARM -EXTERN int up_rtc_cancelalarm(void); +int up_rtc_cancelalarm(void); #endif #undef EXTERN diff --git a/nuttx/include/sys/syscall.h b/nuttx/include/sys/syscall.h index c0d163452..79c8433b3 100644 --- a/nuttx/include/sys/syscall.h +++ b/nuttx/include/sys/syscall.h @@ -202,8 +202,7 @@ #define SYS_clock_getres (__SYS_clock+1) #define SYS_clock_gettime (__SYS_clock+2) #define SYS_clock_settime (__SYS_clock+3) -#define SYS_gettimeofday (__SYS_clock+4) -#define __SYS_timers (__SYS_clock+5) +#define __SYS_timers (__SYS_clock+4) /* The following are defined only if POSIX timers are supported */ diff --git a/nuttx/include/sys/time.h b/nuttx/include/sys/time.h index 75dfd7280..e9bc3d6b3 100644 --- a/nuttx/include/sys/time.h +++ b/nuttx/include/sys/time.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/sys/time.h * - * Copyright (C) 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -51,6 +51,17 @@ /**************************************************************************** * 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 @@ -59,12 +70,58 @@ #undef EXTERN #if defined(__cplusplus) #define EXTERN extern "C" -extern "C" { +extern "C" +{ #else #define EXTERN extern #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 #if defined(__cplusplus) -- cgit v1.2.3