summaryrefslogtreecommitdiff
path: root/nuttx/lib
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-16 15:43:39 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-04-16 15:43:39 +0000
commit105a59fa90e7dd9f7cd2bea774d99e60c3562fa8 (patch)
tree3130fee552185c1366e662b4506a3f5ffb3d870f /nuttx/lib
parentcbb245c0b6816c10be52a03a3ea8c66db8e0a7ae (diff)
downloadpx4-nuttx-105a59fa90e7dd9f7cd2bea774d99e60c3562fa8.tar.gz
px4-nuttx-105a59fa90e7dd9f7cd2bea774d99e60c3562fa8.tar.bz2
px4-nuttx-105a59fa90e7dd9f7cd2bea774d99e60c3562fa8.zip
THTTPD works on LPCXpresso
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3514 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/lib')
-rw-r--r--nuttx/lib/time/lib_time.c49
1 files changed, 34 insertions, 15 deletions
diff --git a/nuttx/lib/time/lib_time.c b/nuttx/lib/time/lib_time.c
index 95352f133..6900791a7 100644
--- a/nuttx/lib/time/lib_time.c
+++ b/nuttx/lib/time/lib_time.c
@@ -39,11 +39,10 @@
#include <nuttx/config.h>
+#include <sys/time.h>
#include <time.h>
-#include <nuttx/clock.h>
-
-#if !defined(CONFIG_DISABLE_CLOCK) && defined(CONFIG_UPTIME)
+#ifndef CONFIG_DISABLE_CLOCK
/****************************************************************************
* Pre-processor Definitions
@@ -61,30 +60,50 @@
* Function: time
*
* Description:
- * Return the current system up-time.
+ * Get the current calendar time as a time_t object. The function returns
+ * this value, and if the argument is not a null pointer, the value is also
+ * set to the object pointed by tloc.
+ *
+ * Note that this function is just a thin wrapper around gettimeofday()
+ * and is provided for compatibility. gettimeofday() is the preffered way
+ * to obtain system time.
*
* Parameters:
- * The tloc argument points to an area where the return value is
- * also stored. If tloc is a null pointer, no 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
+ * parameter is not used, but a time_t object is still returned by the
+ * function.
*
* Return Value:
- * The current system up time
+ * The current calendar time as a time_t object. If the argument is not
+ * a null pointer, the return value is the same as the one stored in the
+ * location pointed by the argument.
+ *
+ * If the function could not retrieve the calendar time, it returns a -1
+ * value.
*
****************************************************************************/
time_t time(time_t *tloc)
{
- /* Get the current uptime from the system */
+ struct timeval tp;
+ int ret;
- time_t uptime = clock_uptime();
-
- /* Return the uptime */
+ /* Get the current uptime from the system */
- if (tloc)
+ ret = gettimeofday(&tp, NULL);
+ if (ret == OK)
{
- *tloc = uptime;
+ /* Return the seconds since the epoch */
+
+ if (tloc)
+ {
+ *tloc = tp.tv_sec;
+ }
+ return tp.tv_sec;
}
- return uptime;
+
+ return (time_t)ERROR;
}
-#endif /* !CONFIG_DISABLE_CLOCK && CONFIG_UPTIME */
+#endif /* !CONFIG_DISABLE_CLOCK */