summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-02-15 13:00:44 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-02-15 13:00:44 -0600
commit093c95eb3997be03752c8428f3ce42aeee00b546 (patch)
tree45d8c9c3af62fb37fd9deed4c074bfa5723fea23
parentedffe515d983f8fa7a3d67c684ef47cbe676d35c (diff)
downloadnuttx-093c95eb3997be03752c8428f3ce42aeee00b546.tar.gz
nuttx-093c95eb3997be03752c8428f3ce42aeee00b546.tar.bz2
nuttx-093c95eb3997be03752c8428f3ce42aeee00b546.zip
Move struct timveval from include/time.h to include/sys/time.h where it belongs.
-rw-r--r--nuttx/include/nuttx/rtc.h22
-rw-r--r--nuttx/include/nuttx/time.h9
-rw-r--r--nuttx/include/sys/time.h8
-rw-r--r--nuttx/include/time.h42
-rw-r--r--nuttx/libc/time/lib_gettimeofday.c1
-rw-r--r--nuttx/libc/time/lib_settimeofday.c1
6 files changed, 49 insertions, 34 deletions
diff --git a/nuttx/include/nuttx/rtc.h b/nuttx/include/nuttx/rtc.h
index 287a067ef..a84eaf7b8 100644
--- a/nuttx/include/nuttx/rtc.h
+++ b/nuttx/include/nuttx/rtc.h
@@ -275,15 +275,17 @@
struct rtc_time
{
- int tm_sec;
- int tm_min;
- int tm_hour;
- int tm_mday;
- int tm_mon;
- int tm_year;
- int tm_wday; /* unused */
- int tm_yday; /* unused */
- int tm_isdst; /* unused */
+ int tm_sec; /* Seconds (0-61, allows for leap seconds) */
+ int tm_min; /* Minutes (0-59) */
+ int tm_hour; /* Hours (0-23) */
+ int tm_mday; /* Day of the month (1-31) */
+ int tm_mon; /* Month (0-11) */
+ int tm_year; /* Years since 1900 */
+#ifdef CONFIG_LIBC_LOCALTIME
+ int tm_wday; /* Day of the week (0-6) (unused) */
+ int tm_yday; /* Day of the year (0-365) (unused) */
+ int tm_isdst; /* Non-0 if daylight savings time is in effect (unused) */
+#endif
};
#ifdef CONFIG_RTC_ALARM
@@ -427,7 +429,7 @@ struct rtc_lowerhalf_s
FAR const struct rtc_ops_s *ops;
- /* Data following this can vary from RTC driver to driver */
+ /* Data following this can vary from RTC driver-to-driver */
};
/****************************************************************************
diff --git a/nuttx/include/nuttx/time.h b/nuttx/include/nuttx/time.h
index cccacdf93..315c4431a 100644
--- a/nuttx/include/nuttx/time.h
+++ b/nuttx/include/nuttx/time.h
@@ -74,7 +74,8 @@
#ifdef __cplusplus
#define EXTERN extern "C"
-extern "C" {
+extern "C"
+{
#else
#define EXTERN extern
#endif
@@ -87,7 +88,7 @@ extern "C" {
*
****************************************************************************/
-EXTERN int clock_isleapyear(int year);
+int clock_isleapyear(int year);
/****************************************************************************
* Function: clock_daysbeforemonth
@@ -97,7 +98,7 @@ EXTERN int clock_isleapyear(int year);
*
****************************************************************************/
-EXTERN int clock_daysbeforemonth(int month, bool leapyear);
+int clock_daysbeforemonth(int month, bool leapyear);
/****************************************************************************
* Function: clock_calendar2utc
@@ -110,7 +111,7 @@ EXTERN int clock_daysbeforemonth(int month, bool leapyear);
*
****************************************************************************/
-EXTERN time_t clock_calendar2utc(int year, int month, int day);
+time_t clock_calendar2utc(int year, int month, int day);
#undef EXTERN
#ifdef __cplusplus
diff --git a/nuttx/include/sys/time.h b/nuttx/include/sys/time.h
index e9bc3d6b3..972cfaca8 100644
--- a/nuttx/include/sys/time.h
+++ b/nuttx/include/sys/time.h
@@ -51,7 +51,13 @@
/****************************************************************************
* Public Type Definitions
****************************************************************************/
-/* struct timeval is defined in time.h */
+/* struct timeval represents time as seconds plus microseconds */
+
+struct timeval
+{
+ time_t tv_sec; /* Seconds */
+ long tv_usec; /* Microseconds */
+};
/* The use of the struct timezone is obsolete; the tz argument should
* normally be specified as NULL (and is ignored in any event).
diff --git a/nuttx/include/time.h b/nuttx/include/time.h
index e19c360c2..832927ea8 100644
--- a/nuttx/include/time.h
+++ b/nuttx/include/time.h
@@ -1,7 +1,7 @@
/********************************************************************************
* include/time.h
*
- * Copyright (C) 2007-2011, 2013-2014 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2011, 2013-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -80,7 +80,6 @@
#define CLOCK_REALTIME 0
-
/* Clock that cannot be set and represents monotonic time since some
* unspecified starting point. It is not affected by changes in the
* system time-of-day clock.
@@ -104,35 +103,43 @@
/********************************************************************************
* Public Types
********************************************************************************/
+/* Scalar types */
typedef uint32_t time_t; /* Holds time in seconds */
typedef uint8_t clockid_t; /* Identifies one time base source */
typedef FAR void *timer_t; /* Represents one POSIX timer */
+/* struct timespec is the standard representation of time as seconds and
+ * nanoseconds.
+ */
+
struct timespec
{
time_t tv_sec; /* Seconds */
long tv_nsec; /* Nanoseconds */
};
-struct timeval
-{
- time_t tv_sec; /* Seconds */
- long tv_usec; /* Microseconds */
-};
+/* struct tm is the standard representation for "broken out" time.
+ *
+ * REVISIT: This structure could be packed better using uint8_t's and
+ * uint16_t's. The standard definition does, however, call out type int for
+ * all of the members. NOTE: Any changes to this structure must be also be
+ * reflected in struct rtc_time defined in include/nuttx/rtc.h; these two
+ * structures must be cast compatible.
+ */
struct tm
{
- int tm_sec; /* second (0-61, allows for leap seconds) */
- int tm_min; /* minute (0-59) */
- int tm_hour; /* hour (0-23) */
- int tm_mday; /* day of the month (1-31) */
- int tm_mon; /* month (0-11) */
- int tm_year; /* years since 1900 */
+ int tm_sec; /* Seconds (0-61, allows for leap seconds) */
+ int tm_min; /* Minutes (0-59) */
+ int tm_hour; /* Hours (0-23) */
+ int tm_mday; /* Day of the month (1-31) */
+ int tm_mon; /* Month (0-11) */
+ int tm_year; /* Years since 1900 */
#ifdef CONFIG_LIBC_LOCALTIME
- int tm_wday; /* day of the week (0-6) */
- int tm_yday; /* day of the year (0-365) */
- int tm_isdst; /* non-0 if daylight savings time is in effect */
+ int tm_wday; /* Day of the week (0-6) */
+ int tm_yday; /* Day of the year (0-365) */
+ int tm_isdst; /* Non-0 if daylight savings time is in effect */
#endif
};
@@ -161,7 +168,8 @@ struct sigevent;
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
-extern "C" {
+extern "C"
+{
#else
#define EXTERN extern
#endif
diff --git a/nuttx/libc/time/lib_gettimeofday.c b/nuttx/libc/time/lib_gettimeofday.c
index e14d0af34..d1315b128 100644
--- a/nuttx/libc/time/lib_gettimeofday.c
+++ b/nuttx/libc/time/lib_gettimeofday.c
@@ -40,7 +40,6 @@
#include <nuttx/config.h>
#include <sys/time.h>
-#include <time.h>
#include <errno.h>
#include <nuttx/clock.h>
diff --git a/nuttx/libc/time/lib_settimeofday.c b/nuttx/libc/time/lib_settimeofday.c
index 4c71c105c..a28b634a7 100644
--- a/nuttx/libc/time/lib_settimeofday.c
+++ b/nuttx/libc/time/lib_settimeofday.c
@@ -40,7 +40,6 @@
#include <nuttx/config.h>
#include <sys/time.h>
-#include <time.h>
#include <errno.h>
#include <nuttx/clock.h>