Date: Tue, 13 Aug 2019 09:50:14 -0700 From: "Enji Cooper (yaneurabeya)" <yaneurabeya@gmail.com> To: Alan Somers <asomers@freebsd.org> Cc: src-committers <src-committers@freebsd.org>, svn-src-all <svn-src-all@freebsd.org>, svn-src-head@freebsd.org Subject: Re: svn commit: r350993 - head/sbin/ping6 Message-ID: <B49D11C2-BD72-4610-ACE1-F212C85BD568@gmail.com> In-Reply-To: <201908131622.x7DGMhUL047226@repo.freebsd.org> References: <201908131622.x7DGMhUL047226@repo.freebsd.org>
index | next in thread | previous in thread | raw e-mail
> On Aug 13, 2019, at 09:22, Alan Somers <asomers@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, -Enjihelp
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?B49D11C2-BD72-4610-ACE1-F212C85BD568>
