From 66b004fc78a4f1bc6cebcf42d02dddcae355edc2 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Mon, 27 Jul 2026 13:45:03 +0000 Subject: [PATCH 3/3] fix struct itimerspec redefinition in epoll-shim's own build timerfd.c both force-includes src/compat_itimerspec.h (via the compat_enable_itimerspec target linked into epoll-shim itself) and explicitly includes the public include/sys/timerfd.h, which now also defines struct itimerspec under the same COMPAT_ENABLE_ITIMERSPEC condition since the previous commit -- causing a redefinition error. Share a guard macro between the two copies of the definition so whichever is seen first in a translation unit wins. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01U6fuL1PtRJHhr97gAGyS1h --- include/sys/timerfd.h | 9 +++++++++ src/compat_itimerspec.h | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/sys/timerfd.h b/include/sys/timerfd.h index f5b6d42..da7a747 100644 --- a/include/sys/timerfd.h +++ b/include/sys/timerfd.h @@ -21,11 +21,20 @@ extern "C" { * it here. Only defined when the build has actually detected the * struct is missing (see CMakeLists.txt's HAVE_TIMERFD/APPLE check), * to avoid ever conflicting with a real system definition. + * + * Guarded separately from src/compat_itimerspec.h's copy of the same + * definition (which epoll-shim's own build force-includes into every + * translation unit compiled for the library, this header included), + * so whichever of the two is seen first in a given file wins and the + * second is a no-op instead of a redefinition error. */ +#ifndef EPOLL_SHIM_ITIMERSPEC_DEFINED_ +#define EPOLL_SHIM_ITIMERSPEC_DEFINED_ struct itimerspec { struct timespec it_interval; struct timespec it_value; }; +#endif #else struct itimerspec; #endif diff --git a/src/compat_itimerspec.h b/src/compat_itimerspec.h index 67662bd..7be2398 100644 --- a/src/compat_itimerspec.h +++ b/src/compat_itimerspec.h @@ -5,10 +5,21 @@ #include +/* + * Guarded separately from the copy of this definition in + * include/sys/timerfd.h (which is what external consumers of + * epoll-shim see, and which epoll-shim's own timerfd.c also includes + * directly), so whichever of the two headers is seen first in a + * given translation unit wins and the second is a no-op instead of a + * redefinition error. + */ +#ifndef EPOLL_SHIM_ITIMERSPEC_DEFINED_ +#define EPOLL_SHIM_ITIMERSPEC_DEFINED_ struct itimerspec { struct timespec it_interval; struct timespec it_value; }; #endif +#endif #endif -- 2.43.0