-
Notifications
You must be signed in to change notification settings - Fork 270
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need better platform code separation #3
Comments
Thank you very much for this feedback, I very much appreciate it. How about cpuinfo_{arch}_{OS}.c? Any suggestion? |
I'd personally do separate directory approach. |
I vote on the suggestion from gchatelet. |
Using separate directories would allow for each OS to share code using additional files, still isolated from the rest. |
@Androbin 's rationale makes sense. I'll play a bit with the layout and come back with a proposal. |
# This is the 1st commit message: Update macros to detect mips64 and differentiate between x86 32/64. # This is the commit message #2: Fix Mips32 and add an alias for Mips32/64. # This is the commit message #3: Allow specifying cmake generator. # This is the commit message #4: Remove unavailable MSVC version and test Ninja on travis # This is the commit message #5: Add ninja build. # This is the commit message #6: Use Ninja by default # This is the commit message #7: Show tests output # This is the commit message #8: Defaulting env to Ninja in the build matrix # This is the commit message #9: Defaulting env to Ninja in the build matrix # This is the commit message #10: Do not use ninja on OSX # This is the commit message #11: Fix test output. # This is the commit message #12: Fix running tests # This is the commit message #13: Fix running tests
This commit helps with platform code separation (fixes #3). It should also help with the build as we can simply include all `impl_*.c` files regardless of OS / arch. Note: this patch contains breaking changes in `include/cpu_features_macros.h` - `CPU_FEATURES_OS_LINUX_OR_ANDROID` does not exist anymore - `CPU_FEATURES_OS_FREEBSD`, `CPU_FEATURES_OS_ANDROID` and `CPU_FEATURES_OS_LINUX` are now mutually exclusive (i.e. `CPU_FEATURES_OS_ANDROID` does not imply `CPU_FEATURES_OS_LINUX`) - `CPU_FEATURES_OS_DARWIN` has been renamed into `CPU_FEATURES_OS_MACOS` to be able to target non-Mac Apple products (IOS, TV, WATCH). They are now targetable with `CPU_FEATURES_OS_IPHONE`. This matches Apple naming convention described in [this stackoverflow](https://stackoverflow.com/a/49560690).
It turns out, MACOS is a perfectly fine OS to support aarch64 (through its name arm64.) The only thing missing was the appropriate check in impl_aarch64, plus renaming the file to match that it's really for any OS that has the CPU. jwatte@Jons-MBP build % make test Running tests... Test project /Users/jwatte/cpu_features/build Start 1: bit_utils_test 1/4 Test google#1: bit_utils_test ................... Passed 0.06 sec Start 2: string_view_test 2/4 Test google#2: string_view_test ................. Passed 0.04 sec Start 3: stack_line_reader_test 3/4 Test google#3: stack_line_reader_test ........... Passed 0.04 sec Start 4: cpuinfo_aarch64_test 4/4 Test google#4: cpuinfo_aarch64_test ............. Passed 0.12 sec
I was interested in adding iOS, macOS and Windows support, but the layout of the code is not conducive to this. src/cpuinfo_aarch64.c is highly Linux-specific. For an ARM64 Windows implementation, where would the code go? (In Windows, the ARM64 implementation would be based around IsProcessorFeaturePresent.)
The text was updated successfully, but these errors were encountered: