Skip to content

Commit 19b67af

Browse files
committed
gettimeofday automatically compatible with different glibc versions.
1 parent 993b574 commit 19b67af

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

app/nginx-1.25.2/src/event/modules/ngx_ff_module.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,13 +545,12 @@ kevent(int kq, const struct kevent *changelist, int nchanges,
545545
return ff_kevent(kq, changelist, nchanges, eventlist, nevents, timeout);
546546
}
547547

548-
/*
549-
* It is need to modify the definition, such as Ubuntu 22.04 or later.
550-
*
551-
* int(struct timeval * restrict, void * restrict)
552-
*/
553548
int
549+
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 31)
550+
gettimeofday(struct timeval *tv, void *tz)
551+
#else
554552
gettimeofday(struct timeval *tv, struct timezone *tz)
553+
#endif
555554
{
556555
if (unlikely(inited == 0)) {
557556
return SYSCALL(gettimeofday)(tv, tz);

lib/ff_api.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,11 @@ int ff_kevent_do_each(int kq, const struct kevent *changelist, int nchanges,
136136
void *eventlist, int nevents, const struct timespec *timeout,
137137
void (*do_each)(void **, struct kevent *));
138138

139+
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 31)
140+
int ff_gettimeofday(struct timeval *tv, void *tz);
141+
#else
139142
int ff_gettimeofday(struct timeval *tv, struct timezone *tz);
143+
#endif
140144

141145
int ff_dup(int oldfd);
142146
int ff_dup2(int oldfd, int newfd);

lib/ff_syscall_wrapper.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,11 @@ ff_kevent(int kq, const struct kevent *changelist, int nchanges,
14571457
}
14581458

14591459
int
1460+
#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 31)
1461+
ff_gettimeofday(struct timeval *tv, void *tz)
1462+
#else
14601463
ff_gettimeofday(struct timeval *tv, struct timezone *tz)
1464+
#endif
14611465
{
14621466
long nsec;
14631467
ff_get_current_time(&(tv->tv_sec), &nsec);

0 commit comments

Comments
 (0)