diff --git a/ChangeLog b/ChangeLog
index e14afe9db4c..46ed65e9406 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -810,6 +810,7 @@
typical embeddd system.
* sched/: Added gettimeofday(). This implementation is simply a thin
wrapper around clock_gettimer().
+ * lib/: Add gmtime() and localtime()
diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html
index 908c927c831..e91143d811c 100644
--- a/Documentation/NuttX.html
+++ b/Documentation/NuttX.html
@@ -1483,6 +1483,7 @@ nuttx-0.4.10 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
typical embeddd system.
* sched/: Added gettimeofday(). This implementation is simply a thin
wrapper around clock_gettimer().
+ * lib/: Add gmtime() and localtime()
nuttx-0.4.10 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
diff --git a/Documentation/NuttxUserGuide.html b/Documentation/NuttxUserGuide.html
index 7c6bb0f0a34..dbd88cba22f 100644
--- a/Documentation/NuttxUserGuide.html
+++ b/Documentation/NuttxUserGuide.html
@@ -2462,14 +2462,16 @@ VxWorks provides the following comparable interface:
2.7.2 clock_gettime
2.7.3 clock_getres
2.7.4 mktime
- 2.7.5 gmtime_r
- 2.7.6 localtime_r
- 2.7.7 timer_create
- 2.7.8 timer_delete
- 2.7.9 timer_settime
- 2.7.10 timer_gettime
- 2.7.11 timer_getoverrun
- 2.7.12 gettimeofday
+ 2.7.5 gmtime
+ 2.7.6 localtime
+ 2.7.7 gmtime_r
+ 2.7.8 localtime_r
+ 2.7.9 timer_create
+ 2.7.10 timer_delete
+ 2.7.11 timer_settime
+ 2.7.12 timer_gettime
+ 2.7.13 timer_getoverrun
+ 2.7.14 gettimeofday
@@ -2584,7 +2586,46 @@ VxWorks provides the following comparable interface:
To be provided.
-
+
+
+ Function Prototype:
+
+
+ #include <time.h>
+ struct tm *gmtime(const time_t *clock);
+
+
+ Description:
+
+
+ Input Parameters:
+
+
+ clock.
+ Represents calendar time.
+ This is an absolute time value representing the number of seconds elapsed since 00:00:00
+ on January 1, 1970, Coordinated Universal Time (UTC).
+
+
+
+ Returned Values:
+
+
+ If successful, the gmtime() function will return the pointer to a statically
+ defined instance of struct tim.
+ Otherwise, a NULL will be returned to indicate the error:
+
+
+
+
+
+ #include <time.h>
+ #define localtime(c) gmtime(c)
+
+
+
Function Prototype:
@@ -2599,26 +2640,32 @@ VxWorks provides the following comparable interface:
Input Parameters:
- parm.
+ clock.
+ Represents calendar time.
+ This is an absolute time value representing the number of seconds elapsed since 00:00:00
+ on January 1, 1970, Coordinated Universal Time (UTC).
+ result.
+ A user-provided buffer to receive the converted time structure.
Returned Values:
- If successful, the gmtime_r() function will return zero (OK).
- Otherwise, an non-zero error number will be returned to indicate the error:
+ If successful, the gmtime_r() function will return the pointer, result,
+ provided by the caller.
+ Otherwise, a NULL will be returned to indicate the error:
-
+
#include <time.h>
#define localtime_r(c,r) gmtime_r(c,r)
-
+
Function Prototype:
@@ -2688,7 +2735,7 @@ VxWorks provides the following comparable interface:
Only CLOCK_REALTIME is supported for the clockid argument.
-
+
Function Prototype:
@@ -2727,7 +2774,7 @@ VxWorks provides the following comparable interface:
Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -2810,7 +2857,7 @@ VxWorks provides the following comparable interface:
The ovalue argument is ignored.
-
+
Function Prototype:
@@ -2857,7 +2904,7 @@ VxWorks provides the following comparable interface:
Comparable to the POSIX interface of the same name.
-
+
Function Prototype:
@@ -2918,7 +2965,7 @@ VxWorks provides the following comparable interface:
interface of the same name.
-
+
Function Prototype:
@@ -7553,6 +7600,7 @@ notify a task when a message is available on a queue.
getpid
gets
getsockopt
+ gmtime
gmtime_r
Introduction
ioctl
diff --git a/include/fcntl.h b/include/fcntl.h
index 5218e247306..66a66e0f5d7 100644
--- a/include/fcntl.h
+++ b/include/fcntl.h
@@ -57,8 +57,9 @@
#define O_APPEND 0x10 /* Keep contents, append to end */
#define O_TRUNC 0x20 /* Delete contents */
#define O_NONBLOCK 0x40 /* Don't wait for data */
+#define O_NDELAY O_NONBLOCK
#define O_SYNC 0x80 /* Synchronize output on write */
-#define O_DSYNC OSYNC
+#define O_DSYNC O_SYNC
#define O_RSYNC 0x00 /* Sychronize input on read */
#define O_ACCMODE 0x00 /* Required by POSIX */
diff --git a/include/time.h b/include/time.h
index a7e2e6bb5e0..ce18c135018 100644
--- a/include/time.h
+++ b/include/time.h
@@ -143,7 +143,10 @@ EXTERN int clock_gettime(clockid_t clockid, struct timespec *tp);
EXTERN int clock_getres(clockid_t clockid, struct timespec *res);
EXTERN time_t mktime(struct tm *tp);
+EXTERN struct tm *gmtime(const time_t *clock);
EXTERN struct tm *gmtime_r(const time_t *clock, struct tm *result);
+
+#define localtime(c) gmtime(c)
#define localtime_r(c,r) gmtime_r(c,r)
EXTERN int timer_create(clockid_t clockid, FAR struct sigevent *evp, FAR timer_t *timerid);
diff --git a/lib/Makefile b/lib/Makefile
index b2792cdf38c..63264bc36f0 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -83,7 +83,7 @@ UNISTD_SRCS += lib_chdir.c lib_getcwd.c
endif
endif
-TIME_SRCS = lib_mktime.c lib_gmtimer.c lib_timeutils.c
+TIME_SRCS = lib_mktime.c lib_gmtime.c lib_gmtimer.c lib_timeutils.c
NET_SRCS = lib_htons.c lib_htonl.c lib_inetntoa.c lib_etherntoa.c
diff --git a/lib/lib_gmtime.c b/lib/lib_gmtime.c
new file mode 100644
index 00000000000..14076b0eec9
--- /dev/null
+++ b/lib/lib_gmtime.c
@@ -0,0 +1,94 @@
+/****************************************************************************
+ * lib/lib_gmtime.c
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt
+ *
+ * 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
+#include
+
+#include
+#include
+#include
+
+#include
+
+/****************************************************************************
+ * Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Type Declarations
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/**************************************************************************
+ * Public Constant Data
+ **************************************************************************/
+
+/****************************************************************************
+ * Public Variables
+ ****************************************************************************/
+
+/**************************************************************************
+ * Private Variables
+ **************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Function: gmtime
+ *
+ * Description:
+ * Similar to gmtime_r, but not thread-safe
+ *
+ ****************************************************************************/
+
+struct tm *gmtime(const time_t *clock)
+{
+ static struct tm tm;
+ return gmtime_r(clock, &tm);
+}
+
diff --git a/netutils/thttpd/mime_types.h b/netutils/thttpd/mime_types.h
index ef2106af990..531605b66e6 100644
--- a/netutils/thttpd/mime_types.h
+++ b/netutils/thttpd/mime_types.h
@@ -62,6 +62,7 @@ struct mime_entry
/* A list of file extensions followed by the corresponding MIME encoding.
* Extensions not found in the table proceed to the mime_types table.
+ * Must be ordered by extension so to support binary searches.
*/
static struct mime_entry enc_tab[] =
@@ -74,6 +75,7 @@ static const int n_enc_tab = sizeof(enc_tab) / sizeof(*enc_tab);
/* A list of file extensions followed by the corresponding MIME type.
* Extensions not found in the table are returned as text/plain.
+ * Must be ordered by extension so to support binary searches.
*/
static struct mime_entry typ_tab[] =
diff --git a/sched/clock_ticks2time.c b/sched/clock_ticks2time.c
index f0218df4759..154756a6f98 100644
--- a/sched/clock_ticks2time.c
+++ b/sched/clock_ticks2time.c
@@ -1,7 +1,7 @@
/********************************************************************************
* clock_ticks2time.c
*
- * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt
*
* Redistribution and use in source and binary forms, with or without