> On Aug 13, 2019, at 09:22, Alan Somers <asom...@freebsd.org> wrote: > > Author: asomers > Date: Tue Aug 13 16:22:43 2019 > New Revision: 350993 > URL: https://svnweb.freebsd.org/changeset/base/350993 > > Log: > Consistently use the byteorder functions in the correct direction > > Though ntohs and htons are functionally identical, they have different > meanings.Using the correct one helps to document the code.
This statement is only true for BE platforms. For LE platforms like i386/x64, ntohs and htons actually does a endianness conversion: sys/powerpc/include/endian.h:#define __ntohs(x) (__bswap16((__uint16_t)(x))) sys/powerpc/include/endian.h:#define __ntohs(x) ((__uint16_t)(x)) sys/sparc64/include/endian.h:#define __ntohs(x) ((__uint16_t)(x)) sys/x86/include/endian.h:#define __ntohs(x) __bswap16(x) sys/mips/include/endian.h:#define __ntohs(x) ((__uint16_t)(x)) sys/mips/include/endian.h:#define __ntohs(x) (__bswap16((x))) sys/arm/include/endian.h:#define __ntohs(x) ((__uint16_t)(x)) sys/arm/include/endian.h:#define __ntohs(x) (__bswap16(x)) sys/arm64/include/endian.h:#define __ntohs(x) (__bswap16(x)) sys/riscv/include/endian.h:#define __ntohs(x) (__bswap16(x)) sys/sys/param.h:#define ntohs(x) __ntohs(x) sys/netinet/in.h:#define ntohs(x) __ntohs(x) Thanks, -Enji _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"