Fix compilation errors on systems where int32_t is long#1934
Fix compilation errors on systems where int32_t is long#1934ccawley2011 wants to merge 1 commit intozlib-ng:developfrom
Conversation
WalkthroughThe update modifies the function signatures in the Changes
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (2)📓 Common learningszlib-ng.h.in (9)⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (10)
🔇 Additional comments (7)
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #1934 +/- ##
============================================
+ Coverage 39.39% 81.67% +42.28%
============================================
Files 74 150 +76
Lines 7885 13618 +5733
Branches 1303 3052 +1749
============================================
+ Hits 3106 11123 +8017
+ Misses 4536 1547 -2989
- Partials 243 948 +705 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
So both int and long are 32-bit, is that right? I don't see the connection between your description and the changes you propose, so please elaborate. Also, a feature of zlib-ng is that it uses stdint datatypes so that they are always the same size on any platform, unlike int and long that can vary. |
|
We currently do not support Newlib, so it is pointless to try fixing any issues with it... We however already do use preprocessor magic to hide differences between declarations of some types in toolchains, but proper support needs configure time checks. There is already different types for compat and non-compat builds and that is intended to avoid overflows on 64-bit platforms. |
|
I think this is not just for Newlib support. |
|
I think that the functions themselves should instead be changed to use int32_t, as that would be in line with what we are trying to do in zlib-ng and would not change the the zlib-ng native api. We might need to use a custom type though, because we still need the functions to use I still don't know whether that would fix the problems with Newlib though, since the problem description is unclear on the specifics. |
The main issue with using custom type is that standard C doesn't allow overloading function parameters, so using custom type would break zlib compatibility. GNU extension for C does however allow overloading function parameters only when the types are different size. We could use preprocessor magic using |
Are you saying this would not work? Changing the functions themselves to use If that does not work, it should still be possible by using That does not address any problems in the functions with platforms where int is not actually 32-bit of course. IMO the long-term solution is to make a compat-shim, in effect a compat library that loads the native library and just has shim functions for the entire zlib library, and only has the required checks and data-type translation that we do not need in native. |
I'm saying the fix has to go to the *.c files, not the header files as changing header files would change the ABI (and cause CI to fail). This is obviously because the compiler doesn't load header files separately, but instead included from the source files. For proper fix we would need to have Newlib on our CI workflows. There was already several issues in stock zlib if Using shim functions works in release builds as long as there is no indirect jumps. When using shim functions, it doesn't matter if |
I agree, but in most cases using |
|
I just encountered this issue while trying to compile for 32-bit armv7, and |
This PR needs complete rewrite as in current form it is unacceptable... As per contributing guidelines of zlib-ng, original author must either abandon the PR before someone else can rewrite it, or rewrite it oneself. |
|
when looking into some warnings from zlib I saw it was using int32_t for its structures/functions. |
This is by convention... Using explicit integer widths allows optimising for minimal structure padding. Biggest issue with original zlib was to assume width of What comes to function parameters, passing pointers of different size is not allowed, so using explicit integer width avoids compiler errors while being compatible with both original zlib API and zlib-ng's API. When we started, types like |
…stead of int * Based on PR zlib-ng#1934
@Dead2, for shared libraries that would mean two dynamic loaded library files, correct? I wonder if that would be acceptable. |
…stead of int * Based on PR zlib-ng#1934
…stead of int * Based on PR zlib-ng#1934
…stead of int * Based on PR zlib-ng#1934
…stead of int * Based on PR zlib-ng#1934
…stead of int * Based on PR zlib-ng#1934
Just the different SONAME is enough to require two shared libraries. Then need to make sure all symbol names are unique, as linker can bypass the compat shim if it wants due to strict symbol lookup order. Compat shim has to come before other shared libraries and no static library can use same symbol names. |
…stead of int * Based on PR zlib-ng#1934
…stead of int * Based on PR zlib-ng#1934
…stead of int * Based on PR #1934
|
Closing this in favor of #1980 |
This occurs on some 32-bit platforms using Newlib -
intandlongare the same size but considered distinct types, which means that functions and prototypes need to use the same types.Summary by CodeRabbit