Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 02 Feb 1996 07:39:37 -0700
From:      Warner Losh <imp@village.org>
To:        Andreas Klemm <andreas@knobel.gun.de>
Cc:        hackers@FreeBSD.org, ports@FreeBSD.org
Subject:   Re: Another Pentium gcc patch, -D__FreeBSD__=2 -Dbsd4_4 
Message-ID:  <199602021439.HAA24937@rover.village.org>
In-Reply-To: Your message of Thu, 01 Feb 1996 19:41:39 %2B0100

next in thread | raw e-mail | index | archive | help
: When I did the gcc port, cc failed to compile some sources, because
: the correct typedef for us (FreeBSD) was only included, when bsd4_4
: would have beed defined. So I had to patch the sources, to add
: 
: #if defined(bsd4_4) && defined(__FreeBSD__)
: 		    ^^^^^^^^^^^^^^^^^^^^^^^
: 
: I think the bsd4_4 definition should be included to make it easier
: to compile stuff for 4.4 BSD. It seems to me, that it's for some
: people common to test for bsd4_4. It would make it easier to
: compile those sources and would decrease the amount of modifications/
: patches. 

The latest gcc don't have this problem.  In fact, xm-freebsd.h defines
HAVE_STRERROR so that bsd4_4 doesn't even get tested for builds for
FreeBSD systems.  bsd4_4 is defined by gcc *ONLY* on mips-dec-bsd, as
far as I can tell.  That's the only place in the entire gcc 2.7.2
sources where -Dbsd4_4 or #define bsd4_4 happens in the source.  As it
turns out, cpp is compiled on this one architecture to have bsd4_4
defined.  NetBSD doesn't, FreeBSD doesn't, BSDi doesn't.  Etc.  gcc
itself only uses bsd4_4 when HAVE_STRERROR isn't defined and it is
building its own strerror.  gcc didn't used to be like this, but it is
as of the latest release.

In fact, most versions of gcc that were wrong were easily fixed by
adding #define HAVE_STRERROR to tm-freebsd.h and rebuilding.  I recall
once adding #define bsd4_4 to that file a long time ago before the
HAVE_STRERROR code was in place.  Since that was just once place to
fix, rather than 6 or so in the sources.  That's part of porting, I
guess :-).

If you want bsd4_4, then you can just as easily include:

#ifdef HAVE_SYS_PARAMS
#include <sys/params.h>
#endif
#ifdef BSD4_4
#define bsd4_4
#endif

since params.h is the *STANDARD* bsd way of figuring out if you are
running on a BSD system.

To date, I have never needed __FreeBSD__ as a define.  The BSD
year/month version number has always proven to be suffcient for my
needs.  This includes porting kerberos, gcc and some other stuff that
had old, icky defines before.  I've ported about 500,000 lines of code
to FreeBSD between work projects and software from the net, so this
isn't a trivial amount of code.  I'm not saying that __FreeBSD__
shouldn't be defined, but its use should be very rare...

Ideally, however, you'd not need to ask the question "Am I running BSD
4.4"  Instead, something like autoconfig should ask much smaller
questions and then tell you what it found by defining HAVE_STRERROR,
HAVE_BROKEN_SELECT, HAVE_PARALLEL_PRINTER_PORT_DONGLE, etc.

Warner





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