!BHcierreUuwCMxVqOf:matrix.org

Rust Embedded

373 Members
Welcome to the Rust Embedded chat room! | Bridged to Freenode IRC: #rust-embedded | Public logs: https://freenode.logbot.info/rust-embedded/ | Discuss, coordinate, help: https://github.com/rust-embedded/wg | Code of conduct: https://www.rust-lang.org/conduct.html39 Servers

Load older messages


SenderMessageTime
27 Feb 2021
@freenode_agg:matrix.orgagg I guess if you're looking at the elf of the same executable it's fine :p 13:13:54
@korken89:matrix.orgkorken89Defined layout yes, just dumping memory no ;)13:14:02
@korken89:matrix.orgkorken89Hehe indeed13:14:05
@freenode_gsalazar:matrix.orggsalazarso maybe I can elaborate a bit on the question: I am converting something from C and replicated a structure (which has attribute packed on the C code) to fill the different data that then I need to send via USB to the host13:15:40
@freenode_gsalazar:matrix.orggsalazarthe host needs to receive the structure with the same information in the same order to interpret it correctly13:16:13
@freenode_gsalazar:matrix.orggsalazarand I was wondering on the best way to do so13:17:21
@freenode_agg:matrix.orgagg I've used eg slice::from_raw_parts as a slightly less dangerous transmute 13:18:57
@freenode_agg:matrix.orgaggBe sure to put repr(c) and repr(packed) on the struct13:19:10
@freenode_agg:matrix.orgagg Then slice::from_raw_parts(&s as *const _, mem::size_of::<T>()) or something like that 13:20:05
@freenode_agg:matrix.orgagghttps://github.com/adamgreig/ffp/blob/master/firmware/src/hal/usb/packets.rs#L28713:21:22
@korken89:matrix.orgkorken89I found it quite interesting that even reading padding bytes in unpacked structures was well defined, even though they are considered uninitialised13:26:31
@korken89:matrix.orgkorken89Interesting special case of uninitialised memory13:26:55
@freenode_agg:matrix.orgaggYea, I was a bit surprised by that13:30:43
@freenode_agg:matrix.orgaggNot sure I knew about it when I wrote the comment in that file13:30:52
@korken89:matrix.orgkorken89I find it weird and cool13:32:20
@korken89:matrix.orgkorken89But makes sense, else memcpy would be UB 13:32:39
@freenode_gsalazar:matrix.orggsalazaragg korken89: thanks15:18:56
@bradleyharden:matrix.orgbradleyharden Is there any way to do pointer arithmetic in the declaration of a const? I want to declare a constant that is a pointer to a field of a PAC RegisterBlock. I can call the PAC struct's ::ptr() method to get a pointer to the block, but I can't dereference the pointer in a const expression. I can't cast the pointer to uszie, because that's unsatable. And I can't use .offset(), .add() and the like, because they aren't constant functions. 15:22:49
@bradleyharden:matrix.orgbradleyharden * Is there any way to do pointer arithmetic in the declaration of a const? I want to declare a constant that is a pointer to a field of a PAC RegisterBlock. I can call the PAC struct's ::ptr() method to get a pointer to the block, but I can't dereference the pointer in a const expression. I can't cast the pointer to uszie, because that's unsatable. And I can't use .offset(), .add() and the like, because they aren't constant functions. 15:25:19
@bradleyharden:matrix.orgbradleyhardenI guess I can use the literal address and then cast to a pointer. But that's brittle.15:26:47
@jannic:matrix.org@jannic:matrix.org left the room.16:00:17
@pythondude:matrix.org@pythondude:matrix.org left the room.16:00:18
@joeschneider-d5:matrix.orgJoe Schneider joined the room.16:01:46
@freenode_englosh:matrix.org@freenode_englosh:matrix.org joined the room.16:24:10
@yatekii:matrix.orgyatekiiDoes anyone know if there is a way to detect the macOS version from within cargo/rustc? ^^16:58:28
@yatekii:matrix.orgyatekii(have a dependency depend on it)16:58:36
@freenode_englosh:matrix.org@freenode_englosh:matrix.org left the room.17:02:07
@freenode_tokomak:matrix.org@freenode_tokomak:matrix.org left the room.17:13:14
@freenode_epony:matrix.orgepony joined the room.17:49:34
@freenode_ni:matrix.org@freenode_ni:matrix.org left the room.18:56:56

There are no newer messages yet.


Back to Room List