summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--package/deps.mak1
-rw-r--r--src/include/skalibs/djbtime.h3
-rw-r--r--src/include/skalibs/stat.h31
-rw-r--r--src/libstddjb/timespec_cmp.c13
-rw-r--r--src/sysdeps/trystatim.c9
-rw-r--r--src/sysdeps/trystatimespec.c9
6 files changed, 66 insertions, 0 deletions
diff --git a/package/deps.mak b/package/deps.mak
index fc8ee82..c213301 100644
--- a/package/deps.mak
+++ b/package/deps.mak
@@ -639,6 +639,7 @@ src/libstddjb/tain_zero.o src/libstddjb/tain_zero.lo: src/libstddjb/tain_zero.c
src/libstddjb/time_from_tai.o src/libstddjb/time_from_tai.lo: src/libstddjb/time_from_tai.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/include/skalibs/uint64.h
src/libstddjb/time_from_tai_relative.o src/libstddjb/time_from_tai_relative.lo: src/libstddjb/time_from_tai_relative.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h
src/libstddjb/time_sysclock_from_tai.o src/libstddjb/time_sysclock_from_tai.lo: src/libstddjb/time_sysclock_from_tai.c src/include/skalibs/bsdsnowflake.h src/include/skalibs/sysdeps.h src/include/skalibs/tai.h src/include/skalibs/uint64.h
+src/libstddjb/timespec_cmp.o src/libstddjb/timespec_cmp.lo: src/libstddjb/timespec_cmp.c src/include/skalibs/djbtime.h
src/libstddjb/timespec_from_tain.o src/libstddjb/timespec_from_tain.lo: src/libstddjb/timespec_from_tain.c src/include/skalibs/tai.h
src/libstddjb/timespec_from_tain_relative.o src/libstddjb/timespec_from_tain_relative.lo: src/libstddjb/timespec_from_tain_relative.c src/include/skalibs/tai.h
src/libstddjb/timespec_sysclock_from_tain.o src/libstddjb/timespec_sysclock_from_tain.lo: src/libstddjb/timespec_sysclock_from_tain.c src/include/skalibs/tai.h
diff --git a/src/include/skalibs/djbtime.h b/src/include/skalibs/djbtime.h
index 980f3b2..386d435 100644
--- a/src/include/skalibs/djbtime.h
+++ b/src/include/skalibs/djbtime.h
@@ -10,6 +10,9 @@
#include <skalibs/tai.h>
+extern int timespec_cmp (struct timespec const *, struct timespec const *) ;
+
+
/* UTC <--> TAI conversions */
/* sysclock can be either TAI-10 or UTC */
diff --git a/src/include/skalibs/stat.h b/src/include/skalibs/stat.h
new file mode 100644
index 0000000..de85cce
--- /dev/null
+++ b/src/include/skalibs/stat.h
@@ -0,0 +1,31 @@
+/* ISC license. */
+
+#ifndef SKALIBS_STAT_H
+#define SKALIBS_STAT_H
+
+#include <skalibs/sysdeps.h>
+
+#ifdef SKALIBS_HASSTATIM
+
+#define ST_ATIM st_atim
+#define ST_MTIM st_mtim
+#define ST_CTIM st_ctim
+
+#else
+
+#ifdef SKALIBS_HASSTATIMESPEC
+
+#define ST_ATIM st_atimespec
+#define ST_MTIM st_mtimespec
+#define ST_CTIM st_ctimespec
+
+#else
+
+#define ST_ATIM st_how_the_fuck_do_you_even_get_atime_on_this_OS
+#define ST_MTIM st_how_the_fuck_do_you_even_get_mtime_on_this_OS
+#define ST_CTIM st_how_the_fuck_do_you_even_get_ctime_on_this_OS
+
+#endif
+#endif
+
+#endif
diff --git a/src/libstddjb/timespec_cmp.c b/src/libstddjb/timespec_cmp.c
new file mode 100644
index 0000000..85d23c2
--- /dev/null
+++ b/src/libstddjb/timespec_cmp.c
@@ -0,0 +1,13 @@
+/* ISC license. */
+
+#include <time.h>
+
+#include <skalibs/djbtime.h>
+
+int timespec_cmp (struct timespec const *a, struct timespec const *b)
+{
+ if (a->tv_sec < b->tv_sec) return -1 ;
+ if (a->tv_sec > b->tv_sec) return 1 ;
+ if (a->tv_nsec < b->tv_nsec) return -1 ;
+ return a->tv_nsec > b->tv_nsec ;
+}
diff --git a/src/sysdeps/trystatim.c b/src/sysdeps/trystatim.c
new file mode 100644
index 0000000..94834cc
--- /dev/null
+++ b/src/sysdeps/trystatim.c
@@ -0,0 +1,9 @@
+/* ISC license. */
+
+#include <sys/stat.h>
+#include <time.h>
+
+struct stat st ;
+struct timespec *tsa = &st.st_atim ;
+struct timespec *tsm = &st.st_mtim ;
+struct timespec *tsc = &st.st_ctim ;
diff --git a/src/sysdeps/trystatimespec.c b/src/sysdeps/trystatimespec.c
new file mode 100644
index 0000000..2690d57
--- /dev/null
+++ b/src/sysdeps/trystatimespec.c
@@ -0,0 +1,9 @@
+/* ISC license. */
+
+#include <sys/stat.h>
+#include <time.h>
+
+struct stat st ;
+struct timespec *tsa = &st.st_atimespec ;
+struct timespec *tsm = &st.st_mtimespec ;
+struct timespec *tsc = &st.st_ctimespec ;