summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/ChangeLog1
-rw-r--r--nuttx/Documentation/NuttX.html1
-rw-r--r--nuttx/Documentation/NuttxUserGuide.html86
-rw-r--r--nuttx/include/fcntl.h3
-rw-r--r--nuttx/include/time.h3
-rw-r--r--nuttx/lib/Makefile2
-rw-r--r--nuttx/lib/lib_gmtime.c94
-rw-r--r--nuttx/netutils/thttpd/mime_types.h2
-rw-r--r--nuttx/sched/clock_ticks2time.c2
9 files changed, 172 insertions, 22 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index e14afe9db..46ed65e94 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/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/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index 908c927c8..e91143d81 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/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/nuttx/Documentation/NuttxUserGuide.html b/nuttx/Documentation/NuttxUserGuide.html
index 7c6bb0f0a..dbd88cba2 100644
--- a/nuttx/Documentation/NuttxUserGuide.html
+++ b/nuttx/Documentation/NuttxUserGuide.html
@@ -2462,14 +2462,16 @@ VxWorks provides the following comparable interface:
<li><a href="#clockgettime">2.7.2 clock_gettime</a></li>
<li><a href="#clockgetres">2.7.3 clock_getres</a></li>
<li><a href="#mktime">2.7.4 mktime</a></li>
- <li><a href="#gmtimer">2.7.5 gmtime_r</a></li>
- <li><a href="#localtimer">2.7.6 localtime_r</a></li>
- <li><a href="#timercreate">2.7.7 timer_create</a></li>
- <li><a href="#timerdelete">2.7.8 timer_delete</a></li>
- <li><a href="#timersettime">2.7.9 timer_settime</a></li>
- <li><a href="#timergettime">2.7.10 timer_gettime</a></li>
- <li><a href="#timergetoverrun">2.7.11 timer_getoverrun</a></li>
- <li><a href="#gettimeofday">2.7.12 gettimeofday</a></li>
+ <li><a href="#gmtime">2.7.5 gmtime</a></li>
+ <li><a href="#localtime">2.7.6 localtime</a></li>
+ <li><a href="#gmtimer">2.7.7 gmtime_r</a></li>
+ <li><a href="#localtimer">2.7.8 localtime_r</a></li>
+ <li><a href="#timercreate">2.7.9 timer_create</a></li>
+ <li><a href="#timerdelete">2.7.10 timer_delete</a></li>
+ <li><a href="#timersettime">2.7.11 timer_settime</a></li>
+ <li><a href="#timergettime">2.7.12 timer_gettime</a></li>
+ <li><a href="#timergetoverrun">2.7.13 timer_getoverrun</a></li>
+ <li><a href="#gettimeofday">2.7.14 gettimeofday</a></li>
</ul>
<H3><a name="clocksettime">2.7.1 clock_settime</a></H3>
@@ -2584,7 +2586,46 @@ VxWorks provides the following comparable interface:
<li><code>To be provided</code>.</li>
</ul>
-<H3><a name="gmtimer">2.7.5 gmtime_r</a></H3>
+<H3><a name="gmtime">2.7.5 gmtime</a></H3>
+<p>
+ <b>Function Prototype:</b>
+</p>
+<pre>
+ #include &lt;time.h&gt;
+ struct tm *gmtime(const time_t *clock);
+</pre>
+<p>
+ <b>Description:</b>
+</p>
+<p>
+ <b>Input Parameters:</b>
+</p>
+<ul>
+ <li><code>clock</code>.
+ 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).
+</li>
+</ul>
+<p>
+ <b>Returned Values:</b>
+</p>
+<p>
+ If successful, the <I>gmtime()</I> function will return the pointer to a statically
+ defined instance of <code>struct tim</code>.
+ Otherwise, a NULL will be returned to indicate the error:
+</p>
+<ul>
+ <li><code>To be provided</code>.</li>
+</ul>
+
+<H3><a name="localtime">2.7.6 localtime</a></H3>
+<pre>
+ #include &lt;time.h&gt;
+ #define localtime(c) gmtime(c)
+</pre>
+
+<H3><a name="gmtimer">2.7.7 gmtime_r</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2599,26 +2640,32 @@ VxWorks provides the following comparable interface:
<b>Input Parameters:</b>
</p>
<ul>
- <li><code>parm</code>. </li>
+ <li><code>clock</code>.
+ 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).
+ <li><code>result</code>.
+ A user-provided buffer to receive the converted time structure.
</ul>
<p>
<b>Returned Values:</b>
</p>
<p>
- If successful, the <I>gmtime_r()</I> function will return zero (<I>OK</I>).
- Otherwise, an non-zero error number will be returned to indicate the error:
+ If successful, the <I>gmtime_r()</I> function will return the pointer, <code>result</code>,
+ provided by the caller.
+ Otherwise, a NULL will be returned to indicate the error:
</p>
<ul>
<li><code>To be provided</code>.</li>
</ul>
-<H3><a name="localtimer">2.7.6 localtime_r</a></H3>
+<H3><a name="localtimer">2.7.8 localtime_r</a></H3>
<pre>
#include &lt;time.h&gt;
#define localtime_r(c,r) gmtime_r(c,r)
</pre>
-<H3><a name="timercreate">2.7.7 timer_create</a></H3>
+<H3><a name="timercreate">2.7.9 timer_create</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2688,7 +2735,7 @@ VxWorks provides the following comparable interface:
<li>Only <code>CLOCK_REALTIME</code> is supported for the <code>clockid</code> argument.</li>
</ul>
-<H3><a name="timerdelete">2.7.8 timer_delete</a></H3>
+<H3><a name="timerdelete">2.7.10 timer_delete</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2727,7 +2774,7 @@ VxWorks provides the following comparable interface:
Comparable to the POSIX interface of the same name.
</p>
-<H3><a name="timersettime">2.7.9 timer_settime</a></H3>
+<H3><a name="timersettime">2.7.11 timer_settime</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2810,7 +2857,7 @@ VxWorks provides the following comparable interface:
<li>The <code>ovalue</code> argument is ignored.</li>
</ul>
-<H3><a name="timergettime">2.7.10 timer_gettime</a></H3>
+<H3><a name="timergettime">2.7.12 timer_gettime</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2857,7 +2904,7 @@ VxWorks provides the following comparable interface:
Comparable to the POSIX interface of the same name.
</p>
-<H3><a name="timergetoverrun">2.7.11 timer_getoverrun</a></H3>
+<H3><a name="timergetoverrun">2.7.13 timer_getoverrun</a></H3>
<p>
<b>Function Prototype:</b>
</p>
@@ -2918,7 +2965,7 @@ VxWorks provides the following comparable interface:
interface of the same name.
</p>
-<h3><a name="gettimeofday">2.7.12 gettimeofday</a></h3>
+<h3><a name="gettimeofday">2.7.14 gettimeofday</a></h3>
<p>
<b>Function Prototype:</b>
</p>
@@ -7553,6 +7600,7 @@ notify a task when a message is available on a queue.
<li><a href="#getpid">getpid</a></li>
<li><a href="#standardio">gets</a></li>
<li><a href="#getsockopt">getsockopt</a></li>
+ <li><a href="#gmtime">gmtime</a></li>
<li><a href="#gmtimer">gmtime_r</a></li>
<li><a href="#Introduction">Introduction</a>
<li><a href="#drvrioctlops">ioctl</a></li>
diff --git a/nuttx/include/fcntl.h b/nuttx/include/fcntl.h
index 5218e2473..66a66e0f5 100644
--- a/nuttx/include/fcntl.h
+++ b/nuttx/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/nuttx/include/time.h b/nuttx/include/time.h
index a7e2e6bb5..ce18c1350 100644
--- a/nuttx/include/time.h
+++ b/nuttx/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/nuttx/lib/Makefile b/nuttx/lib/Makefile
index b2792cdf3..63264bc36 100644
--- a/nuttx/lib/Makefile
+++ b/nuttx/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/nuttx/lib/lib_gmtime.c b/nuttx/lib/lib_gmtime.c
new file mode 100644
index 000000000..14076b0ee
--- /dev/null
+++ b/nuttx/lib/lib_gmtime.c
@@ -0,0 +1,94 @@
+/****************************************************************************
+ * lib/lib_gmtime.c
+ *
+ * Copyright (C) 2009 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * 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/types.h>
+
+#include <time.h>
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/time.h>
+
+/****************************************************************************
+ * 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/nuttx/netutils/thttpd/mime_types.h b/nuttx/netutils/thttpd/mime_types.h
index ef2106af9..531605b66 100644
--- a/nuttx/netutils/thttpd/mime_types.h
+++ b/nuttx/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/nuttx/sched/clock_ticks2time.c b/nuttx/sched/clock_ticks2time.c
index f0218df47..154756a6f 100644
--- a/nuttx/sched/clock_ticks2time.c
+++ b/nuttx/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 <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without