From xemacs-m  Sun Jun 15 13:43:13 1997
Received: from birdland.rhein-neckar.de (root@birdland.rhein-neckar.de [193.197.88.3])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id NAA15713
	for <xemacs-beta@xemacs.org>; Sun, 15 Jun 1997 13:43:11 -0500 (CDT)
Received: from cthulhu.rhein-neckar.de (uucp@localhost) by birdland.rhein-neckar.de (8.8.5/8.8.3) with bsmtp id UAA02876 for xemacs.org!xemacs-beta; Sun, 15 Jun 1997 20:40:28 +0200 (MET DST)
Received: from arthur.rhein-neckar.de by cthulhu.rhein-neckar.de
	via rsmtp with bsmtp
	id <m0wdIqN-0002tFC@cthulhu.rhein-neckar.de>
	for <xemacs-beta@xemacs.org>; Sun, 15 Jun 1997 19:11:59 +0200 (MET DST)
	(Smail-3.2 1996-Jul-4 #30 built 1997-Jun-4)
Received: by arthur.rhein-neckar.de
	via sendmail with stdio
	id <m0wdIm8-0001mNC@arthur.rhein-neckar.de>
	for xemacs-beta@xemacs.org; Sun, 15 Jun 1997 19:07:36 +0200 (CEST)
	(Smail-3.2.0.95 1997-May-7 #5 built 1997-May-28)
Message-Id: <m0wdIm8-0001mNC@arthur.rhein-neckar.de>
Date: Sun, 15 Jun 1997 19:07:36 +0200 (CEST)
From: Andreas Jaeger <aj@arthur.rhein-neckar.de>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: xemacs-beta@xemacs.org
Subject: XEmacs 20.3b6+: Defining _BSD_SOURCE is not ok
X-Mailer: VM 6.31 under 20.2 XEmacs Lucid


Hi,

I've tried for the first time to compile a beta of XEmacs 20.3 (beta
7) and noticed a problem with the Linux defines (change introduced in beta 
6).
The file src/s/linux.h says:
#define _BSD_SOURCE 1
But such defines have to come before the inclusion of any header (and
we include add least <stdio.h> before). The definition of _BSD_SOURCE
is only useful if the define comes before the inclusion of any header
files - otherwise (and this is the case) it's useless.

As far as I remember the argument for defining _BSD_SOURCE was that X11 
was also compiled with -D_BSD_SOURCE. But with XFree 3.3 we've got the 
following compile flags (see linux.cf in X11R6/lib/X11/config/):
#if LinuxCLibMajorVersion >= 6
#define SourceDefines		-D_POSIX_C_SOURCE=199309L \
				-D_POSIX_SOURCE \
				-D_BSD_SOURCE -D_SVID_SOURCE
#else
#define SourceDefines		-D_POSIX_SOURCE \
				-D_BSD_SOURCE -D_SVID_SOURCE
#endif
This is totally different to just defining _BSD_SOURCE. If we only
define _BSD_SOURCE, we favor (with glibc) BSD over POSIX - but with
both _POSIX_SOURCE and _BSD_SOURCE we don't favor BSD.

My two points are:
1. If we define _BSD_SOURCE we should also define _POSIX_SOURCE (and
   maybe more, see above)
2. If we define _BSD_SOURCE we should define it before any header file 
   is included, otherwise the definition is useless.

You might ask, where it makes a difference for me (since nobody else
has complained before)?
linux.h says:
/* glibc fuckage */
#if defined __GLIBC__ && ((__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || __GLIBC__ > 2)
# define GETPGRP_NEEDS_ARG
#endif
since getpgrp needs one argument if and only if (!) we favor BSD over
POSIX. Since the definition of _BSD_SOURCE has no effect, getpgrp does 
not need any arguments.

My system: Linux 2.0.31-pre2, glibc 2.1 snapshot, gcc 2.7.2.2, XFree
3.3.

Andreas
-- 
 Andreas Jaeger   aj@arthur.rhein-neckar.de    jaeger@informatik.uni-kl.de
  for pgp-key finger ajaeger@alma.student.uni-kl.de
    http://www.student.uni-kl.de/~ajaeger/

