Subject: Re: building -current on FreeBSD fails
To: Luke Mewburn <lukem@netbsd.org>
From: Mark Valentine <mark@valentine.me.uk>
List: current-users
Date: 06/06/2003 15:41:07
> From: Luke Mewburn <lukem@netbsd.org>
> Date: Fri 6 Jun, 2003
> Subject: Re: building -current on FreeBSD fails

> The inclusion of "compat.h" before <sys/param.h> (et al) should mean
> that your patches are unnecessary for the build of tools/installboot,
> as compat.h should be providing the endian macros.

configure determines that I have <sys/endian.h> - assume for a moment that
this is correct behaviour (at least none of the build tools appear to use
htobe64()/be64toh(), and those do exist in FreeBSD 5.0, so it would be
correct there).

In this case installboot should be using the host's <sys/endian.h> somehow,
but it's simply not being included ("configure says we have <sys/endian.h>,
so assume we get its contents by way of <sys/param.h> including
<machine/endian.h>..." - oops).

And even with finer grained detection by configure, if it detected that the
host had, say, be16toh() in <sys/endian.h>, then code which uses be16toh()
should _somehow_ be including the host's <sys/endian.h> to get it.

> That said, we should be fixing this in compat.h and not in the
> installboot sources.

In that case should compat_defs.h contain:

  #if HAVE_SYS_ENDIAN_H
  #include <sys/endian.h>
  #endif

That seems to be the way to restore the assumption that the endian macros
are available "automagically".

I see now that my patch is insufficient as it ignores HAVE_SYS_ENDIAN_H in
config.h (and that's not defined until after the later #include of
"installboot.h", unless I'm missing something).

On the other hand, if we just want to use NetBSD's endian macros anyway, all
the HAVE_SYS_ENDIAN logic should just go away.

Incidentally, where's the right place to document the <sys/endian.h> macros?

Presumably not lib/libc/net/byteorder.3...

		Cheers,

		Mark.

-- 
"Tigers will do ANYTHING for a tuna fish sandwich."
"We're kind of stupid that way."   *munch* *munch*
  -- <http://www.calvinandhobbes.com>