Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Mar 2023 03:34:57 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Juraj Lutter <otis@freebsd.org>
Cc:        Yuri <yuri@aetern.org>, Nuno Teixeira <eduardo@freebsd.org>,  FreeBSD CURRENT <freebsd-current@freebsd.org>,  FreeBSD Mailing List <freebsd-ports@freebsd.org>
Subject:   Re: byteswap.h not found on 12 and 13
Message-ID:  <CANCZdfrprje7Usg1DLN4=XcSjsP2nqSH0nbQtTNn0bTzYJ1x_w@mail.gmail.com>
In-Reply-To: <13BBF767-6CBB-41D5-AD93-6ADD9C417811@FreeBSD.org>
References:  <CAFDf7UKq3bMgd3XA0=U10%2BLhOCY7fZCHds9DdBcrSuNidOityw@mail.gmail.com> <CANCZdfpT3nbZ%2BzHHtdsMDa88JsWr7Frw%2BRPGcy6B=P60DZL2_g@mail.gmail.com> <CAFDf7UL=av0KDAw2O3Fmf=x5wThezBokCQ2KHtW6wOZnn43bxQ@mail.gmail.com> <ef18fee5-358b-3c19-467b-2fd980dff797@aetern.org> <CANCZdfrvHQTZqgGdZjm5Z_fa53g92c_6EHtKZpyRAsKwRsDcLw@mail.gmail.com> <CANCZdfp=zTD5ctpjcQhDBexWP40d=z0GAd09Qa9eFM4yxXq9RQ@mail.gmail.com> <CANCZdfq2nLt1Bq2Jzn=ivvqaOvF9=y8j=ChZzy6TrE5zAzeFiw@mail.gmail.com> <13BBF767-6CBB-41D5-AD93-6ADD9C417811@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000e1ffa305f7a21b2c
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Fri, Mar 24, 2023 at 3:13=E2=80=AFAM Juraj Lutter <otis@freebsd.org> wro=
te:

>
>
> > 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

--000000000000e1ffa305f7a21b2c
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Fri, Mar 24, 2023 at 3:13=E2=80=AF=
AM Juraj Lutter &lt;<a href=3D"mailto:otis@freebsd.org">otis@freebsd.org</a=
>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px=
 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br=
>
<br>
&gt; On 24 Mar 2023, at 10:09, Warner Losh &lt;<a href=3D"mailto:imp@bsdimp=
.com" target=3D"_blank">imp@bsdimp.com</a>&gt; wrote:<br>
&gt; <br>
&gt; one last reply, if this is for a port, then byteswap.h can usually be =
implemented as<br></blockquote><div><br></div><div>#include &lt;sys/param.h=
&gt;</div><div>#if __FreeBSD_version &lt; 1301500</div><div>=C2=A0</div><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef=
t:1px solid rgb(204,204,204);padding-left:1ex">
&gt; #include &lt;sys/endian.h&gt;<br>
&gt; #define __bswap_16(x) __bswap16(x)<br>
&gt; #define __bswap_32(x) __bswap32(x)<br>
&gt; #define __bswap_64(x) __bswap64(x)<br>
&gt; <br>
&gt; #define bswap_16(x) __bswap16(x)<br>
&gt; #define bswap_32(x) __bswap32(x)<br>
&gt; #define bswap_64(x) __bswap64(x)</blockquote><div>#else</div><div>#inc=
lude_next &lt;byteswap.h&gt;</div><div>#endif</div><div><br></div><div>migh=
t make it a complete file.</div><div>=C2=A0<br></div><blockquote class=3D"g=
mail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204=
,204,204);padding-left:1ex">&gt; <br>
&gt; in older versions of FreeBSD, but some tricky software will hate the b=
swap16 (no underscore) etc defines. You could likely put that into the port=
.<br>
<br>
In releng/13 there is also infiniband/byteswap.h that does:<br>
<br>
#include &lt;sys/types.h&gt;<br>
#include &lt;sys/endian.h&gt;<br>
<br>
#define bswap_16=C2=A0 =C2=A0 =C2=A0 =C2=A0 bswap16<br>
#define bswap_32=C2=A0 =C2=A0 =C2=A0 =C2=A0 bswap32<br>
#define bswap_64=C2=A0 =C2=A0 =C2=A0 =C2=A0 bswap64<br></blockquote><div><b=
r></div><div>That works too. The reason I suggested what I did is that it a=
lso lets you do #undef bswap16, etc if your software needs it.</div><div><b=
r></div><div>Warner</div></div></div>

--000000000000e1ffa305f7a21b2c--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfrprje7Usg1DLN4=XcSjsP2nqSH0nbQtTNn0bTzYJ1x_w>