diff --git a/libmaxsi/Makefile b/libmaxsi/Makefile
index f67ebecf..0ab47a58 100644
--- a/libmaxsi/Makefile
+++ b/libmaxsi/Makefile
@@ -37,6 +37,7 @@ bsearch.o \
calloc.o \
clearerr.o \
c++.o \
+ctime.o \
ctype.o \
dir.o \
errno.o \
@@ -72,8 +73,12 @@ fwrite.o \
fwriting.o \
getdelim.o \
getline.o \
+gmtime.o \
+gmtime_r.o \
heap.o \
integer.o \
+localtime.o \
+localtime_r.o \
mbtowc.o \
memchr.o \
memcmp.o \
@@ -117,6 +122,7 @@ HOSTEDOBJS=\
access.o \
chdir.o \
chmod.o \
+clock.o \
close.o \
$(CPUDIR)/fork.o \
$(CPUDIR)/signal.o \
@@ -151,6 +157,7 @@ getpagesize.o \
getpid.o \
getppid.o \
gettermmode.o \
+gettimeofday.o \
init.o \
ioleast.o \
isatty.o \
@@ -184,7 +191,9 @@ time.o \
truncate.o \
umask.o \
unlink.o \
+uptime.o \
usleep.o \
+utime.o \
vexecle.o \
vexecl.o \
vexeclp.o \
diff --git a/libmaxsi/clock.cpp b/libmaxsi/clock.cpp
new file mode 100644
index 00000000..16ae3d3e
--- /dev/null
+++ b/libmaxsi/clock.cpp
@@ -0,0 +1,32 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ clock.cpp
+ Determine processor time.
+
+*******************************************************************************/
+
+#include
+#include
+
+extern "C" clock_t clock(void)
+{
+ errno = ENOTSUP;
+ return -1;
+}
diff --git a/libmaxsi/ctime.cpp b/libmaxsi/ctime.cpp
new file mode 100644
index 00000000..90e9eab0
--- /dev/null
+++ b/libmaxsi/ctime.cpp
@@ -0,0 +1,30 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ ctime.cpp
+ Transform date and time.
+
+*******************************************************************************/
+
+#include
+
+extern "C" char* ctime(const time_t* /*timep*/)
+{
+ return (char*) "ctime(3) is not implemented";
+}
diff --git a/libmaxsi/gettimeofday.cpp b/libmaxsi/gettimeofday.cpp
new file mode 100644
index 00000000..b2497b8b
--- /dev/null
+++ b/libmaxsi/gettimeofday.cpp
@@ -0,0 +1,36 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ gettimeofday.cpp
+ Get date and time.
+
+*******************************************************************************/
+
+#include
+#include
+#include
+
+extern "C" int gettimeofday(struct timeval* tp, void* /*tzp*/)
+{
+ uintmax_t sinceboot;
+ uptime(&sinceboot);
+ tp->tv_sec = sinceboot / 1000000ULL;
+ tp->tv_usec = sinceboot % 1000000ULL;
+ return 0;
+}
diff --git a/libmaxsi/gmtime.cpp b/libmaxsi/gmtime.cpp
new file mode 100644
index 00000000..e72fcef4
--- /dev/null
+++ b/libmaxsi/gmtime.cpp
@@ -0,0 +1,31 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ gmtime.cpp
+ Transform date and time.
+
+*******************************************************************************/
+
+#include
+
+extern "C" struct tm* gmtime(const time_t* timer)
+{
+ static struct tm hack_gmtime_ret;
+ return gmtime_r(timer, &hack_gmtime_ret);
+}
diff --git a/libmaxsi/gmtime_r.cpp b/libmaxsi/gmtime_r.cpp
new file mode 100644
index 00000000..99facaef
--- /dev/null
+++ b/libmaxsi/gmtime_r.cpp
@@ -0,0 +1,30 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ gmtime_r.cpp
+ Transform date and time.
+
+*******************************************************************************/
+
+#include
+
+extern "C" struct tm* gmtime_r(const time_t* timer, struct tm* ret)
+{
+ return localtime_r(timer, ret);
+}
diff --git a/libmaxsi/localtime.cpp b/libmaxsi/localtime.cpp
new file mode 100644
index 00000000..86f42c26
--- /dev/null
+++ b/libmaxsi/localtime.cpp
@@ -0,0 +1,31 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ localtime.cpp
+ Transform date and time.
+
+*******************************************************************************/
+
+#include
+
+extern "C" struct tm* localtime(const time_t* timer)
+{
+ static struct tm hack_localtime_ret;
+ return localtime_r(timer, &hack_localtime_ret);
+}
diff --git a/libmaxsi/localtime_r.cpp b/libmaxsi/localtime_r.cpp
new file mode 100644
index 00000000..e1087d59
--- /dev/null
+++ b/libmaxsi/localtime_r.cpp
@@ -0,0 +1,39 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ localtime_r.cpp
+ Transform date and time.
+
+*******************************************************************************/
+
+#include
+
+extern "C" struct tm* localtime_r(const time_t* timer, struct tm* ret)
+{
+ time_t time = *timer;
+ ret->tm_sec = time % 60; // No leap seconds.
+ ret->tm_min = (time / 60) % 60;
+ ret->tm_hour = (time / 60 / 60) % 24;
+ ret->tm_mday = 0;
+ ret->tm_mon = 0;
+ ret->tm_year = 0;
+ ret->tm_wday = 0;
+ ret->tm_isdst = 0;
+ return ret;
+}
diff --git a/libmaxsi/time.cpp b/libmaxsi/time.cpp
index b253bec9..db7053ad 100644
--- a/libmaxsi/time.cpp
+++ b/libmaxsi/time.cpp
@@ -1,6 +1,6 @@
-/******************************************************************************
+/*******************************************************************************
- COPYRIGHT(C) JONAS 'SORTIE' TERMANSEN 2011, 2012.
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
This file is part of LibMaxsi.
@@ -11,102 +11,25 @@
LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
- more details.
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
You should have received a copy of the GNU Lesser General Public License
along with LibMaxsi. If not, see .
time.cpp
- Useful time functions.
+ Get time in seconds.
*******************************************************************************/
-#include
-#include
#include
-#include
#include
-#include
+#include
-namespace Maxsi
+extern "C" time_t time(time_t* t)
{
- namespace Time
- {
- DEFN_SYSCALL1(int, SysUptime, SYSCALL_UPTIME, uintmax_t*);
-
- extern "C" int uptime(uintmax_t* usecssinceboot)
- {
- return SysUptime(usecssinceboot);
- }
-
- extern "C" clock_t clock(void)
- {
- errno = ENOTSUP;
- return -1;
- }
-
- extern "C" int gettimeofday(struct timeval* tp, void* /*tzp*/)
- {
- uintmax_t sinceboot;
- uptime(&sinceboot);
- tp->tv_sec = sinceboot / 1000000ULL;
- tp->tv_usec = sinceboot % 1000000ULL;
- return 0;
- }
-
- extern "C" time_t time(time_t* t)
- {
- struct timeval tv;
- gettimeofday(&tv, NULL);
- time_t result = tv.tv_sec;
- return t ? *t = result : result;
- }
-
- extern "C" struct tm* localtime_r(const time_t* timer, struct tm* ret)
- {
- time_t time = *timer;
- ret->tm_sec = time % 60; // No leap seconds.
- ret->tm_min = (time / 60) % 60;
- ret->tm_hour = (time / 60 / 60) % 24;
- ret->tm_mday = 0;
- ret->tm_mon = 0;
- ret->tm_year = 0;
- ret->tm_wday = 0;
- ret->tm_isdst = 0;
- return ret;
- }
-
- extern "C" struct tm* gmtime_r(const time_t* timer, struct tm* ret)
- {
- return localtime_r(timer, ret);
- }
-
- // TODO: Who the hell designed the below two functions? I vote that
- // these be removed from Sortix soon - although that'd require fixing
- // a lot of applications..
-
- extern "C" struct tm* localtime(const time_t* timer)
- {
- static struct tm hack_localtime_ret;
- return localtime_r(timer, &hack_localtime_ret);
- }
-
- extern "C" struct tm* gmtime(const time_t* timer)
- {
- static struct tm hack_gmtime_ret;
- return gmtime_r(timer, &hack_gmtime_ret);
- }
-
- extern "C" char* ctime(const time_t* /*timep*/)
- {
- return (char*) "ctime(3) is not implemented";
- }
-
- extern "C" int utime(const char* filepath, const struct utimbuf* times)
- {
- // TODO: Sure, I did that! There is no kernel support for this yet.
- return 0;
- }
- }
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ time_t result = tv.tv_sec;
+ return t ? *t = result : result;
}
diff --git a/libmaxsi/uptime.cpp b/libmaxsi/uptime.cpp
new file mode 100644
index 00000000..26adc999
--- /dev/null
+++ b/libmaxsi/uptime.cpp
@@ -0,0 +1,34 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ uptime.cpp
+ Returns current system uptime.
+
+*******************************************************************************/
+
+#include
+#include
+#include
+
+DEFN_SYSCALL1(int, sys_uptime, SYSCALL_UPTIME, uintmax_t*);
+
+extern "C" int uptime(uintmax_t* usecssinceboot)
+{
+ return sys_uptime(usecssinceboot);
+}
diff --git a/libmaxsi/utime.cpp b/libmaxsi/utime.cpp
new file mode 100644
index 00000000..3e52999e
--- /dev/null
+++ b/libmaxsi/utime.cpp
@@ -0,0 +1,33 @@
+/*******************************************************************************
+
+ Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
+
+ This file is part of LibMaxsi.
+
+ LibMaxsi is free software: you can redistribute it and/or modify it under
+ the terms of the GNU Lesser General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or (at your option)
+ any later version.
+
+ LibMaxsi is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with LibMaxsi. If not, see .
+
+ utime.cpp
+ Change file last access and modification times.
+
+*******************************************************************************/
+
+#include
+//#include
+#include
+
+extern "C" int utime(const char* filepath, const struct utimbuf* times)
+{
+ // TODO: Sure, I did that! There is no kernel support for this yet.
+ return 0;
+}