[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lost] [Patch] Stubs für die wichtigsten Zeitfunktionen



Hier ein paar Stubs für die Zeitfunktionen, die von gcc benutzt werden.
Index: src/modules/include/time.h
===================================================================
--- src/modules/include/time.h	(Revision 692)
+++ src/modules/include/time.h	(Arbeitskopie)
@@ -36,6 +36,7 @@
 #ifndef _TIME_H_
 #define _TIME_H_
 #include <sys/types.h>
+#include <config.h>
 
 struct tm {
     int tm_sec;     /// Sekunden 0-60
@@ -52,11 +53,18 @@
 
 time_t time();
 
+#ifndef CONFIG_LIBC_NO_STUBS
 /// Datum und Uhrzeit in einen String umwandeln
-char *ctime(const time_t *time_ptr);
+char* ctime(const time_t* time_ptr);
 
+/// Zeit und Datum als String
+char* asctime(const struct tm* time_ptr);
+
 /// Timestamp in tm-Struct einfuellen
 struct tm* gmtime(const time_t* time_ptr);
 
+struct tm* localtime(const time_t* time_ptr);
 #endif
 
+#endif
+
Index: src/modules/lib/stdlibc/localtime.c
===================================================================
--- src/modules/lib/stdlibc/localtime.c	(Revision 0)
+++ src/modules/lib/stdlibc/localtime.c	(Revision 0)
@@ -0,0 +1,54 @@
+/*  
+ * Copyright (c) 2007 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Antoine Kaufmann.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project 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 HOLDERS 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.
+ */
+
+#include <sys/types.h>
+#include <time.h>
+#include <errno.h>
+#include <config.h>
+
+
+#ifndef CONFIG_LIBC_NO_STUBS
+struct tm tm;
+
+/**
+ * TODO
+ **/
+struct tm* localtime(const time_t* time)
+{
+    // TODO
+    return &tm;
+}
+#endif
+
Index: src/modules/lib/stdlibc/asctime.c
===================================================================
--- src/modules/lib/stdlibc/asctime.c	(Revision 0)
+++ src/modules/lib/stdlibc/asctime.c	(Revision 0)
@@ -0,0 +1,53 @@
+/*  
+ * Copyright (c) 2007 The LOST Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the LOST Project
+ * by Antoine Kaufmann.
+ *
+ * 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. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the LOST Project
+ *     and its contributors.
+ * 4. Neither the name of the LOST Project 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 HOLDERS 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.
+ */
+
+#include <sys/types.h>
+#include <time.h>
+#include <errno.h>
+#include <config.h>
+
+#ifndef CONFIG_LIBC_NO_STUBS
+char* asctime_buf = "Wed Jun 30 21:49:08 1993\n";
+
+/**
+ * TODO
+ **/
+char* asctime(const struct tm* time)
+{
+    // TODO
+    return asctime_buf;
+}
+#endif
+
Index: src/modules/lib/stdlibc/gmtime.c
===================================================================
--- src/modules/lib/stdlibc/gmtime.c	(Revision 692)
+++ src/modules/lib/stdlibc/gmtime.c	(Arbeitskopie)
@@ -36,7 +36,9 @@
 #include <sys/types.h>
 #include <time.h>
 #include <string.h>
+#include <config.h>
 
+#ifndef CONFIG_LIBC_NO_STUBS
 struct tm tm;
 
 /**
@@ -53,3 +55,5 @@
     memset(&tm, 0, sizeof(struct tm));
     return &tm;
 }
+#endif
+
Index: src/modules/lib/stdlibc/ctime.c
===================================================================
--- src/modules/lib/stdlibc/ctime.c	(Revision 692)
+++ src/modules/lib/stdlibc/ctime.c	(Arbeitskopie)
@@ -35,7 +35,10 @@
 
 #include <sys/types.h>
 #include <time.h>
+#include <config.h>
 
+#ifndef CONFIG_LIBC_NO_STUBS
+
 char* ctime_string = "Wed Jun 42 13:37:42 1337\n";
 
 /**
@@ -46,7 +49,9 @@
  * @return Pointer auf den Buffer mit dem String. Statisch alloziert, kann von
  *          weiteren aufrufen ueberschrieben werden.
  */
-char *ctime(const time_t *time_ptr)
+char* ctime(const time_t* time_ptr)
 {
     return ctime_string;
 }
+#endif
+