mirror of https://github.com/F-Stack/f-stack.git
gettimeofday automatically compatible with different glibc versions.
This commit is contained in:
parent
e1deb64acd
commit
88d100facf
|
@ -545,13 +545,12 @@ kevent(int kq, const struct kevent *changelist, int nchanges,
|
||||||
return ff_kevent(kq, changelist, nchanges, eventlist, nevents, timeout);
|
return ff_kevent(kq, changelist, nchanges, eventlist, nevents, timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* It is need to modify the definition in some OS, such as Ubuntu 22.04 or later.
|
|
||||||
*
|
|
||||||
* int(struct timeval * restrict, void * restrict)
|
|
||||||
*/
|
|
||||||
int
|
int
|
||||||
|
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 31)
|
||||||
|
gettimeofday(struct timeval *tv, void *tz)
|
||||||
|
#else
|
||||||
gettimeofday(struct timeval *tv, struct timezone *tz)
|
gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (unlikely(inited == 0)) {
|
if (unlikely(inited == 0)) {
|
||||||
return SYSCALL(gettimeofday)(tv, tz);
|
return SYSCALL(gettimeofday)(tv, tz);
|
||||||
|
|
|
@ -136,7 +136,12 @@ int ff_kevent_do_each(int kq, const struct kevent *changelist, int nchanges,
|
||||||
void *eventlist, int nevents, const struct timespec *timeout,
|
void *eventlist, int nevents, const struct timespec *timeout,
|
||||||
void (*do_each)(void **, struct kevent *));
|
void (*do_each)(void **, struct kevent *));
|
||||||
|
|
||||||
|
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 31)
|
||||||
|
int ff_gettimeofday(struct timeval *tv, void *tz);
|
||||||
|
#else
|
||||||
int ff_gettimeofday(struct timeval *tv, struct timezone *tz);
|
int ff_gettimeofday(struct timeval *tv, struct timezone *tz);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int ff_dup(int oldfd);
|
int ff_dup(int oldfd);
|
||||||
int ff_dup2(int oldfd, int newfd);
|
int ff_dup2(int oldfd, int newfd);
|
||||||
|
|
|
@ -1452,7 +1452,11 @@ ff_kevent(int kq, const struct kevent *changelist, int nchanges,
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 31)
|
||||||
|
ff_gettimeofday(struct timeval *tv, void *tz)
|
||||||
|
#else
|
||||||
ff_gettimeofday(struct timeval *tv, struct timezone *tz)
|
ff_gettimeofday(struct timeval *tv, struct timezone *tz)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
long nsec;
|
long nsec;
|
||||||
ff_get_current_time(&(tv->tv_sec), &nsec);
|
ff_get_current_time(&(tv->tv_sec), &nsec);
|
||||||
|
|
Loading…
Reference in New Issue