←back to thread

The C23 edition of Modern C

(gustedt.wordpress.com)
515 points bwidlar | 3 comments | | HN request time: 0.913s | source
Show context
eqvinox ◴[] No.41858531[source]
> The storage order, the endianness, as given for my machine, is called little-endian. A system that has high-order representation digits first is called big-endian. Both orders are commonly used by modern processor types. Some processors are even able to switch between the two orders on the fly.

Calling big endian "commonly used by modern processor types" when s390x is really the only one left is a bit of a stretch ;D

(Comments about everyone's favorite niche/dead BE architecture in 3… 2… 1…)

replies(7): >>41858643 #>>41858658 #>>41858663 #>>41859666 #>>41860712 #>>41860854 #>>41866505 #
1. unilynx ◴[] No.41859666[source]
well in a way all processors commonly use them... as big-endian is also the network byte order
replies(1): >>41860856 #
2. flohofwoe ◴[] No.41860856[source]
...x86 CPUs actually have special mov instructions now to load big endian data. Not sure since when though (on godbolt it needs `-march=native`:

https://www.godbolt.org/z/bWfhGx7xh

...without -march=native it's a mov and bswap (so not too bad either).

replies(1): >>41861030 #
3. cmovq ◴[] No.41861030[source]
Looks like it was introduced with Haswell (2013). So it’s safe to use if you’re also compiling with AVX2.