gettimeofday automatically compatible with different glibc versions.

This commit is contained in:
fengbojiang 2023-10-19 17:31:44 +08:00
parent e1deb64acd
commit 88d100facf
3 changed files with 13 additions and 5 deletions

View File

@ -545,13 +545,12 @@ kevent(int kq, const struct kevent *changelist, int nchanges,
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
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 31)
gettimeofday(struct timeval *tv, void *tz)
#else
gettimeofday(struct timeval *tv, struct timezone *tz)
#endif
{
if (unlikely(inited == 0)) {
return SYSCALL(gettimeofday)(tv, tz);

View File

@ -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 (*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);
#endif
int ff_dup(int oldfd);
int ff_dup2(int oldfd, int newfd);

View File

@ -1452,7 +1452,11 @@ ff_kevent(int kq, const struct kevent *changelist, int nchanges,
}
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)
#endif
{
long nsec;
ff_get_current_time(&(tv->tv_sec), &nsec);