-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Fix ignored qualifiers #3266
Fix ignored qualifiers #3266
Conversation
Fix ignored volatile qualifier on cast.
I think I achieved that once (but at a lower level of compiler pedantry). I appreciate the effort. |
You have been in there a lot recently. What do you think would be the result of replacing all hal/rtapi_u32/u64 with hal/rtapi_unsigned and the same for signed, where hal_unsigned == u64. |
Well, pedantry is necessary for optimal performance ;-) More seriously, the codebase should compile warning free with |
I can see the argument, but I don't think it is a good idea. There is a reason for distinct types at the low level of interfacing done by parts of the code. This is, after all, real-time code, where speed should be considered. Therefore, it matters what type you use and how it is aligned. The real problem is that a lot of code has been written without proper thought why a specific type is used. That is not only true for 32/64 sizes, but also indiscriminate use of signed/unsigned. Also, because the hal_X_t types are special, it matters how you use them (that goes both for atomicity and volatility). They are not normal variables and the compiler is in large part not allowed to optimize the code when you use them. Just replacing 32 with 64 bit types does not help. You actually need to understand the problem you are trying to solve and pick the right types for the problem at hand.
I think a complete review is in order with a clear strategy how this stuff should be coded. But I think we need to create an issue for hal and RT use and discuss the details there. |
My feeling is that on 64-bit CPUs there is probably no difference in speed between 32-bit and 64-bit operations. The background to this is that initially LinuxCNC used 32-bit floats and 32-bit ints. At some point all the floats were switched to double (and this was before 64-bit CPUs were ubiquitous). Then much later the 64-bit ints were introduced in addition to the 32-bit ones. The 2.9 branch does not have 64-bit HAL pins. |
For further discussion see #3286 |
Running the compile with
-Wignored-qualifiers
results in more warnings that indicate wrong types being used. This PR fixes two cases:Returning const or volatile values is inappropriate, just like casting a value to volatile is inappropriate. The hal_X_t types are replaced with the underlying type and the const on return values is removed.
BTW, yes, I'm trying to eliminate all warnings from the compile.