Re: byteswap.h not found on 12 and 13

From: Warner Losh <imp_at_bsdimp.com>
Date: Fri, 24 Mar 2023 09:34:57 UTC
On Fri, Mar 24, 2023 at 3:13 AM Juraj Lutter <otis@freebsd.org> wrote:

>
>
> > On 24 Mar 2023, at 10:09, Warner Losh <imp@bsdimp.com> wrote:
> >
> > one last reply, if this is for a port, then byteswap.h can usually be
> implemented as
>

#include <sys/param.h>
#if __FreeBSD_version < 1301500


> > #include <sys/endian.h>
> > #define __bswap_16(x) __bswap16(x)
> > #define __bswap_32(x) __bswap32(x)
> > #define __bswap_64(x) __bswap64(x)
> >
> > #define bswap_16(x) __bswap16(x)
> > #define bswap_32(x) __bswap32(x)
> > #define bswap_64(x) __bswap64(x)

#else
#include_next <byteswap.h>
#endif

might make it a complete file.


> >
> > in older versions of FreeBSD, but some tricky software will hate the
> bswap16 (no underscore) etc defines. You could likely put that into the
> port.
>
> In releng/13 there is also infiniband/byteswap.h that does:
>
> #include <sys/types.h>
> #include <sys/endian.h>
>
> #define bswap_16        bswap16
> #define bswap_32        bswap32
> #define bswap_64        bswap64
>

That works too. The reason I suggested what I did is that it also lets you
do #undef bswap16, etc if your software needs it.

Warner