summaryrefslogtreecommitdiff
path: root/lib/replace
diff options
context:
space:
mode:
Diffstat (limited to 'lib/replace')
-rw-r--r--lib/replace/README1
-rw-r--r--lib/replace/replace.c21
-rw-r--r--lib/replace/replace.h4
-rw-r--r--lib/replace/system/time.h6
4 files changed, 32 insertions, 0 deletions
diff --git a/lib/replace/README b/lib/replace/README
index b2d2e4fea5..bf4e67ff0c 100644
--- a/lib/replace/README
+++ b/lib/replace/README
@@ -33,6 +33,7 @@ opendir
readdir
telldir
seekdir
+clock_gettime
closedir
dlopen
dlclose
diff --git a/lib/replace/replace.c b/lib/replace/replace.c
index 12716ea6d3..f3459dd9c2 100644
--- a/lib/replace/replace.c
+++ b/lib/replace/replace.c
@@ -760,3 +760,24 @@ int rep_strerror_r(int errnum, char *buf, size_t buflen)
return 0;
}
#endif
+
+#ifndef HAVE_CLOCK_GETTIME
+int rep_clock_gettime(clockid_t clk_id, struct timespec *tp)
+{
+ struct timeval tval;
+ switch (clk_id) {
+ case 0: /* CLOCK_REALTIME :*/
+#ifdef HAVE_GETTIMEOFDAY_TZ
+ gettimeofday(&tval,NULL);
+#else
+ gettimeofday(&tval);
+#endif
+ tp->tv_sec = tval.tv_sec;
+ tp->tv_nsec = tval.tv_usec * 1000;
+ break;
+ default:
+ return EINVAL;
+ }
+ return 0;
+}
+#endif
diff --git a/lib/replace/replace.h b/lib/replace/replace.h
index 4efcb4c6ee..055dd7172f 100644
--- a/lib/replace/replace.h
+++ b/lib/replace/replace.h
@@ -517,6 +517,10 @@ char *rep_get_current_dir_name(void);
int rep_strerror_r(int errnum, char *buf, size_t buflen);
#endif
+#if !defined(HAVE_CLOCK_GETTIME)
+#define clock_gettime rep_clock_gettime
+#endif
+
#ifdef HAVE_LIMITS_H
#include <limits.h>
#endif
diff --git a/lib/replace/system/time.h b/lib/replace/system/time.h
index 4abf295d1a..ff26531e45 100644
--- a/lib/replace/system/time.h
+++ b/lib/replace/system/time.h
@@ -66,4 +66,10 @@ int rep_utime(const char *filename, const struct utimbuf *buf);
int rep_utimes(const char *filename, const struct timeval tv[2]);
#endif
+#ifndef HAVE_CLOCK_GETTIME
+#define CLOCK_REALTIME 0
+typedef int clockid_t;
+int rep_clock_gettime(clockid_t clk_id, struct timespec *tp);
+#endif
+
#endif