[Toybox] [PATCH] devmem: Fix 8 byte wide writes

Michael Shavit mshavit at google.com
Fri Oct 6 12:30:26 PDT 2023


On Fri, Oct 6, 2023 at 4:41 AM Rob Landley <rob at landley.net> wrote:
>
> I could adjust _just_ addr to use unsigned long instead of unsigned long long,
> but I don't want two atollu()/atolu() and letting you do a longer address and
> silently truncating it isn't great either. Also, a 32-bit platform can't do an
> atomic 64 bit read/write either (it's gonna do 2 32 bit ones behind the scenes)
> and I kinda don't want to claim it won't? Which means removing the 8 byte option
> when building for 32 bits, which is trivial to do in the code:
>
> +    else if (sizeof(long)==8 && bytes==8) *(unsigned long *)p = data;


We can also emit an error earlier in the function if the WIDTH
parameter is 8 on a 32 bit platform.

IMO disallowing 64bit writes is less risky of headaches than silently
non-atomic behavior.  A clear error message might help alleviate the
documentation issue, but I'll agree it's less than ideal to find out
that something won't work after the fact.


More information about the Toybox mailing list