pbsds3 has quit [Quit: Ping timeout (120 seconds)]
pbsds3 has joined #rust-embedded
m5zs7k has quit [Quit: m5zs7k]
m5zs7k has joined #rust-embedded
pbsds3 has quit [Ping timeout: 245 seconds]
pbsds35 has joined #rust-embedded
<dinkelhacker>
Hey, just noticed that ptr::write_bytes has a null check. On my platform 0x0 is a valid address. What would be a memset equivalent in rust that doesn't do any checks?
M9names[m] has joined #rust-embedded
<M9names[m]>
probably safest to write that in asm yourself i think? how often do you expect to have to write to 0x0?
whitequark[cis] has joined #rust-embedded
<whitequark[cis]>
i would probably just permanently allocate a byte or word at 0x0 so that you never have to think about it again
<dinkelhacker>
Only once.. I'm relocating the vector table to there. Just wondered why there is no drop in replacement for memset that just writes wherever.
<thejpster[m]>
Because it’s UB to write to the null pointer. You have to do it in assembly.
<thejpster[m]>
We had a similar argument about a structure that lived at the top 16 bytes of address space.
<thejpster[m]>
Ralf Jung had some strident opinions.
ruabmbua[m] has joined #rust-embedded
<ruabmbua[m]>
If you already have memory to memory dma in your project / platform, use that instead of writing inline assembly for all CPU architectures you want to support ;-)
dirbaio[m] has joined #rust-embedded
<dirbaio[m]>
DMA varies more across chips than arch :P
korken89[m] has quit [Quit: Idle timeout reached: 172800s]
<ruabmbua[m]>
<dirbaio[m]> "DMA varies more across chips..." <- Probably true 😂
<ruabmbua[m]>
Worked out for my project, but not necessarily in most others 😬
<dinkelhacker>
I just ended up using a good old for loop and ptr.offset to relocate the vector table. Probably not the fastest option but I don't care about that currently. At least it doesn't complain about UB. Allthough, it's probably still UB, right thejpster[m] ?
<thejpster[m]>
Does it work in debug profile builds where the pointer validity assets are enabled?
<dngrs[m]>
<thejpster[m]> "Because it’s UB to write to..." <- Does rust assume null == 0x0? C doesn't
vollbrecht[m] has joined #rust-embedded
<vollbrecht[m]>
a 0 can be a null pointer but a null pointer is not automatically 0x00. E.g a Null pointer is not comparable to any other null pointer
<vollbrecht[m]>
so talking equality and general null pointers is nothing you can say in a general case
<vollbrecht[m]>
* so talking equality and the concept of a general null pointers is nothing mush together
<vollbrecht[m]>
* so talking equality to a specific value and the concept of a general null pointers is nothing mush together
<vollbrecht[m]>
* so talking equality to a specific value and the concept of a general null pointers is nothing one can mush together
<dngrs[m]>
(to classify, I was using == as a shorthand for "is at", not so much talking about actual equally ops)
lulf[m] has joined #rust-embedded
<lulf[m]>
<realroot[m]1> "lulf how is going watchful..." <- You can try watchful using the builtin pinetime bootloader now. Only in trial mode, so once it resets, it will revert to infinitime again.