Skip to content

Commit c4e4c1e

Browse files
committed
uplink: Fix build on macos, struct stat has different member fields
1 parent f07ecbe commit c4e4c1e

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

src/configure.ac

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ AC_CHECK_HEADERS([sys/prctl.h], AC_DEFINE([HAVE_PRCTL_H], [], [Linux process con
6969
AC_SUBST(LIBCAP)
7070
AC_CHECK_LIB(cap,cap_init,[LIBCAP="-lcap"])
7171

72-
dnl Check for
72+
dnl Check for eventfd on Linux
7373
AC_CHECK_HEADERS([sys/eventfd.h], AC_DEFINE([HAVE_EVENTFD_H], [], [Linux event fd support]))
7474

7575
dnl Checks for system headers
@@ -78,6 +78,9 @@ AC_CHECK_HEADERS([poll.h], AC_DEFINE([HAVE_POLL_H]))
7878
dnl AC_CHECK_FUNC(ppoll,,[Probably have ppoll of Linux])
7979
AC_CHECK_HEADERS([sys/epoll.h], AC_DEFINE([HAVE_SYS_EPOLL_H]))
8080

81+
dnl Check for MacOS struct stat
82+
AC_CHECK_MEMBER([struct stat.st_mtimespec], AC_DEFINE([HAVE_STAT_ST_MTIMESPEC], [], [MacOS struct stat.st_mtimespec]))
83+
8184
dnl SCTP checks
8285
AC_CHECK_HEADERS([netinet/sctp.h], AC_DEFINE([HAVE_NETINET_SCTP_H]))
8386

src/uplink.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,18 @@ void consider_res_init(void) {
8080
hlog(LOG_WARNING, "Failed to stat " RESOLV_CONF_PATH ": %s", strerror(errno));
8181
return;
8282
}
83-
if (resolvconf_mtim.tv_sec == resolvconf_stat.st_mtim.tv_sec
84-
&& resolvconf_mtim.tv_nsec == resolvconf_stat.st_mtim.tv_nsec) {
83+
84+
#ifdef HAVE_STAT_ST_MTIMESPEC
85+
#define ST_MTIMESPEC st_mtimespec
86+
#else
87+
#define ST_MTIMESPEC st_mtim
88+
#endif
89+
90+
if (resolvconf_mtim.tv_sec == resolvconf_stat.ST_MTIMESPEC.tv_sec
91+
&& resolvconf_mtim.tv_nsec == resolvconf_stat.ST_MTIMESPEC.tv_nsec) {
8592
return;
8693
}
87-
resolvconf_mtim = resolvconf_stat.st_mtim;
94+
resolvconf_mtim = resolvconf_stat.ST_MTIMESPEC;
8895

8996
// only log on repeated inits; otherwise would be logged on every startup
9097
if (resolvconf_reread)

0 commit comments

Comments
 (0)