Originally posted by microcode
View Post
But specially if you are operating in a heterogeneous environment, you have no escape.
its not cheap because there are tons of swap operations, conditions and such in the code, for one packet is ok, but when you are processing 100Gbps is not ok, for 400Gbps worst, to just swap 8 bytes or 64 bits you do:
Code:
/usr/include/x86_64-linux-gnu/bits/byteswap.h /* Swap bytes in 64-bit value. */ ((((x) & 0xff00000000000000ull) >> 56) \ | (((x) & 0x00ff000000000000ull) >> 40) \ | (((x) & 0x0000ff0000000000ull) >> 24) \ | (((x) & 0x000000ff00000000ull) >> 8) \ | (((x) & 0x00000000ff000000ull) << 8) \ | (((x) & 0x0000000000ff0000ull) << 24) \ | (((x) & 0x000000000000ff00ull) << 40) \ | (((x) & 0x00000000000000ffull) << 56))
you usually don't call this functions directly, you call then indirectly, trough other macros..
Imagine the amount of operation you will have running loops of this things..
for a single time, or even for 1 packet or a dozen, no problem..

Comment