A production issue has led our team to the following questions:
- Under RHEL6 using GCC 4.4.6, how are
ntohs
andntohl
implemented? - Are the implementations known to be fast or slow?
- How can I actually see the generated assembly code for the functions?
I know the implications behind questions may seem far-fetched and ridiculous, but I have been asked to investigate.
The hardware in question is an Intel box, little endian, 64-bit processor and compiled in 64 bit.
/usr/include/bits/byteswap.h
for the__bswap_16
and__bswap_32
functions, which are used when optimization is enabled (see<netinet/in.h>
for details of how.)-save-temps
option to keep the intermediate.s
files, or use-S
to stop after compilation and before assembling the code, or use http://gcc.godbolt.org/