ffi_util.cpp: include sys/sysmacros.h only under GNU Libc and uclibc #3843
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.
This patch will avoid including sys/sysmacros.h if neither uclibc nor
GNU glibc is available
Rationale
If it may help to inform this or any alternate approach, there's some
commentary available about the macros defined in sys/sysmacros.h in a
discussion thread under the libc-alpha mailing list (2015)
Quoting the original message in the thread:
In the original ffi_util.cpp, the macros
major
andminor
willalready have been defined when not previously defined.
If there may be any other use of sys/sysmacros.h e.g on Linux
platforms, this patch should serve to ensure that the file is still
included under a build on such platform, while not included under a
FreeBSD platform such that may not provide a sys/sysmacros.h
Known Limitations
This is an approximate test. Perhaps it could be addressed
alternately, with an autoconf-like test during configure?
This patch may not serve to include sys/sysmacros.h under musl libc
builds on Linux, thus when building on Alpine Linux. However, the
'major' and 'minor' macros would still have been defined on this
platform, later in ffi_util.cpp
Short of a feature test during configure, this could possibly be
addressed alternately if testing for the
__linux__
feature macroIt's a short patch towards building rbx on FreeBSD, where sys/sysmacros.h is
generally not available.
The patch has been tested with a build of Rubinius v5.0 with clang 9.0
and clang 11 on FreeBSD 11.1
Previous to the patch, when compiling Rubinius v5.0 with clang 9.0 on FreeBSD 11.1: