Fix epoll_pwait2 feature detection#184
Merged
Merged
Conversation
b208330 to
df460d5
Compare
The Termux Android build can expose an epoll_pwait2 symbol while omitting the corresponding declaration from <sys/epoll.h>. The previous mkmf probe only checked whether the symbol could be linked, so extconf.rb generated HAVE_EPOLL_PWAIT2 even though epoll.c could not compile a real call to the function under C99 implicit-declaration rules. Probe epoll_pwait2 using the same header and a concrete call expression instead. This keeps HAVE_EPOLL_PWAIT2 enabled on platforms where the header declares the API, while allowing Android/Termux to fall back to the existing epoll_wait path. Closes #155
df460d5 to
734c25d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TL;DR
Fix
epoll_pwait2feature detection so Android/Termux can fall back toepoll_waitwhen the header does not declareepoll_pwait2.Context
Closes #155
The reported Termux build has a linkable
epoll_pwait2symbol, so mkmf's barehave_func("epoll_pwait2")probe can defineHAVE_EPOLL_PWAIT2. However, Android's<sys/epoll.h>in that environment does not declareepoll_pwait2, so compilingepoll.cfails with an implicit function declaration error under C99.Changes
The probe now checks an
epoll_pwait2(0, 0, 0, 0, 0)call expression through<sys/epoll.h>. This keeps the generated macro asHAVE_EPOLL_PWAIT2while requiring the declaration to be visible to the compiler.Platforms whose headers expose the API still use
epoll_pwait2; Android/Termux configurations that only expose the symbol leave the macro undefined and continue using the existingepoll_waitfallback.Tophatting
bundle exec rubocop -Aruby ext/extconf.rbThe local extconf run reports
checking for epoll_pwait2(0, 0, 0, 0, 0) in sys/epoll.h... noon this machine, which matches the intended header-aware fallback behavior when the declaration is unavailable.