mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
libreplace: add clock_gettime replacement function for systems that don't have it
This commit is contained in:
parent
9f87bc4588
commit
3df1037a74
@ -33,6 +33,7 @@ opendir
|
|||||||
readdir
|
readdir
|
||||||
telldir
|
telldir
|
||||||
seekdir
|
seekdir
|
||||||
|
clock_gettime
|
||||||
closedir
|
closedir
|
||||||
dlopen
|
dlopen
|
||||||
dlclose
|
dlclose
|
||||||
|
@ -760,3 +760,24 @@ int rep_strerror_r(int errnum, char *buf, size_t buflen)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
||||||
|
@ -517,6 +517,10 @@ char *rep_get_current_dir_name(void);
|
|||||||
int rep_strerror_r(int errnum, char *buf, size_t buflen);
|
int rep_strerror_r(int errnum, char *buf, size_t buflen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(HAVE_CLOCK_GETTIME)
|
||||||
|
#define clock_gettime rep_clock_gettime
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LIMITS_H
|
#ifdef HAVE_LIMITS_H
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -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]);
|
int rep_utimes(const char *filename, const struct timeval tv[2]);
|
||||||
#endif
|
#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
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user