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>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
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

[-- Attachment #2 --]
<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 24, 2023 at 3:13 AM Juraj Lutter &lt;<a href="mailto:otis@freebsd.org">otis@freebsd.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="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="mailto:imp@bsdimp.com" target="_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> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left: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>#include_next &lt;byteswap.h&gt;</div><div>#endif</div><div><br></div><div>might make it a complete file.</div><div> <br></div><blockquote class="gmail_quote" style="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 bswap16 (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        bswap16<br>
#define bswap_32        bswap32<br>
#define bswap_64        bswap64<br></blockquote><div><br></div><div>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.</div><div><br></div><div>Warner</div></div></div>
help

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