Repository navigation
hal: print 64-bit values and pointers without long long casts - #4617
Conversation
Use PRId64/PRIu64 for hal_sint/hal_uint values (halsh, halmeter, sampler_usr) and PRIxPTR for the rtapi_intptr_t function pointers in halcmd show funct. The macros pick the right specifier on LP64 and ILP32, so format and argument agree everywhere with no cast. Also fix signedness of the hm2_eth debug time prints (%lld, not %llu).
|
Using PRId64/PRIu64 and friends is just as or even uglier. We need to drop 32-but compat. |
|
Dropping 32-bit compat is a packaging decision, not a code style one, and we have not made it: Until that decision is made, PRI macros are not compat cruft, they are the only correct C99 spelling for printing |
The fact that we do not test in CI should say it all IMO. If we tested strictly, then it would fail to build. So why exactly are we distributing something we do not test in CI? |
|
That's a great question, which I don't know the answer to :-) |
|
At the meeting it was decided to keep support for 32bit cause of beaglebone, probably keeping support till 2030 as armhf is going to be supported by debian and kernel till then, since we are close to a release this should go in, different reservations can be discussed next meeting, or here. |
hal: drop the remaining long long print casts
Requested by @BsAtHome in #4614: "move it all to libfmt and lets be done with it (in a separate PR)". This is that PR, for the sites #4614 did not cover.
hal64 made
hal_sint/hal_uintvalues int64_t and the query function pointersrtapi_intptr_t, but the print sites force-match them with(long long)casts and%lld/%llx. The casts are correct but ugly, and they hide what the actual types are.Replace with the inttypes.h macros that match the real types:
PRId64/PRIu64for sint/uint (halsh, halmeter, sampler_usr),PRIxPTRfor the function pointers (halcmd show funct). Format and argument then agree on both LP64 and ILP32 with no cast. Where fmt fits it is already used (#4614 covers the halcmd thread print); these sites are C files or pointer prints, where the PRI macros are the idiomatic spelling.Also fixes a real signedness bug in passing: the hm2_eth debug time prints used
%llufor signedlong longvalues.Left alone on purpose:
halmodule.cc, wherePyErr_Formatis Python's own printf and needs its%lldcast, andrtapi_get_time()callers, whose values genuinely arelong longso%lldis the correct specifier. Making those fixed-width too is an rtapi API change, separate discussion.Verified: full build on i386 (Debian trixie container) shows no errors from these files, and on LP64 the macros expand to the same specifier+type combination the casts produced, so output is unchanged.