this post was submitted on 10 Aug 2025
150 points (95.7% liked)

Linux

9631 readers
124 users here now

A community for everything relating to the GNU/Linux operating system (except the memes!)

Also, check out:

Original icon base courtesy of lewing@isc.tamu.edu and The GIMP

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] JamonBear@sh.itjust.works 13 points 1 month ago (1 children)

Cmon, this is not about naming, this is about non-generic code in generic header.

IMO hiding such a little operation behind a macro/function just hurt readability. Furthermore, considering that this function is only used once in the provided patch and that word ordering on RISC-V is not about to change anytime soon, it is perfectly fine to inline the code.

[–] FizzyOrange@programming.dev 0 points 1 month ago (1 children)

this is about non-generic code in generic header.

(a << 16) | b is about the most generic code you can get. How is that remotely RISC-V specific?

[–] zygo_histo_morpheus@programming.dev 11 points 1 month ago* (last edited 1 month ago) (1 children)

Making a u32 ~~pointer~~ from two u16's isn't a generic operation because it has to make assumptions about ~~how the pointers work~~ endianess

Edit: Actually, I'm wrong, didn't think this through properly. See the replies

[–] FizzyOrange@programming.dev 2 points 1 month ago (1 children)

What makes you think it's making a pointer? Nobody said anything about that.

[–] zygo_histo_morpheus@programming.dev 2 points 1 month ago (1 children)

Oh my bad I don't know where I got that from lol

[–] FizzyOrange@programming.dev 3 points 1 month ago

Nw. You're also wrong about endianness. This function would be written exactly the same irrespective of endianness:

uint32_t u16_high_low_to_u32(uint16_t high, uint16_t low) {
  return (high << 16) | low;
}

That is endian agnostic.