[net.unix] Which *nix ? BSD : System V

ado@elsie.UUCP (Arthur David Olson) (02/25/85)

daveb@rtech.ARPA (Dave Brower)--
> . . .If you need to know at compile time whether you're on a Berklix or 
> a System V system, this might help. . .
> 	# include	<fcntl.h>
> 	# ifdef		FNDELAY
> 	# define	BSD
> 	# else
> 	# define	SYS5
> 	# endif
> . . .Can anyone think of a case where this is not true, or
> suggest a more convenient/valid alternative? . . .

guy@rlgvax.UUCP (Guy Harris)--
> . . .Yes - 4.1BSD.  It would produce an error complaining that <fcntl.h>
> couldn't be found. . .

An alternative might be to include "sys/ioctl.h", which is present on 4.1bsd,
4.2bsd, and System III.  If it's also present on System V (and the Berkeley
FIONREAD ioctl call hasn't been picked up AT&T) you're in good shape.
The code might then look like:
	
 	# include	<sys/ioctl.h>
 	# ifdef		FIONREAD
 	# define	BSD
 	# else
 	# define	ATT
 	# endif

A more portable alternative might be:

	/*
	** Skip the following if BSD or ATT is already defined,
	** or if unix isn't defined.
	*/
	#ifndef		BSD
	#ifndef		ATT
	#ifdef		unix
	/*
	** We may be on a 1970's vintage system lacking "sys/ioctl.h".
	** To find out, include "stdio.h" and see if fileno is defined.
	** Only try to include "sys/ioctl.h" if it is defined.
	*/
	#include	"stdio.h"
	#ifdef		fileno
	#include	"sys/ioctl.h"
	#ifdef 		FIONREAD
	#define		BSD
	#endif		/* FIONREAD */
	#ifndef		FIONREAD
	#define		ATT
	#endif		/* !FIONREAD */
	#endif		/* fileno */
	#endif		/* !ATT */
	#endif		/* !BSD */
--
UNIX is an AT&T Bell Laboratories trademark.
--
	UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado@seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks

john@genrad.UUCP (John Nelson) (02/26/85)

In article <5068@elsie.UUCP> ado@elsie.UUCP (Arthur David Olson) writes:
>An alternative might be to include "sys/ioctl.h", which is present on 4.1bsd,
>4.2bsd, and System III.  If it's also present on System V (and the Berkeley
>FIONREAD ioctl call hasn't been picked up AT&T) you're in good shape.

NO!  Unisoft ports of System III and System V have implemented the FIONREAD
ioctl call (good thing, too - really helps porting some programs!).

guy@rlgvax.UUCP (Guy Harris) (02/26/85)

> An alternative might be to include "sys/ioctl.h", which is present on 4.1bsd,
> 4.2bsd, and System III.  If it's also present on System V (and the Berkeley
> FIONREAD ioctl call hasn't been picked up AT&T)

It is, and it hasn't.  (In fact, the S5 "sys/ioctl.h" is an empty file;
it was a silly idea in the first place - you really want "termio.h" for
terminals, "mtio.h" for mag tapes, etc.)

	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

john@genrad.UUCP (John Nelson) (03/03/85)

As an alternative to including <sys/ioctl.h>, here is something that works
MUCH BETTER.

Include <signal.h>.  V7 systems do not have any signal which indicates a
child process has terminated.  Both SIII and SV call that signal SIGCLD.
All berkeley systems have an equivalent signal, but call it SIGCHLD.

<signal.h> has other goodies for system differention.  I always use SIGSTOP
to check for job control, and SIGVTALRM for 4.2 BSD exclusivity.

rpw3@redwood.UUCP (Rob Warnock) (03/07/85)

+---------------
| As an alternative to including <sys/ioctl.h>, here is something that works
| MUCH BETTER.  | | Include <signal.h>...
| <signal.h> has other goodies for system differention.  I always use SIGSTOP
| to check for job control, and SIGVTALRM for 4.2 BSD exclusivity.
+---------------

Much better, and this approach brings us closer to the "real"
issue, which is NOT "what system is this?" but "how do I do XYZ?";
NOT "am I on 4.2", but "do I assume 4.2-style signals?" (Example:
the 68000 system I use has a "v7" kernel, a "4.1" tty driver, but
no "job control". Is it "v.7" or "4.1"?)

With the varieties of UNIX ports around, each of which has chosen
different combinations of features from different sources, it is
better (where possible) to make our "feature tests" be just that,
tests of "features" rather than "versions". Unless we set up a
central registry which hands out unique labels for versions of
UNIX (like Xerox's Ethernet "types"), we will continue to have
portability glitches.


Rob Warnock
Systems Architecture Consultant

UUCP:	{ihnp4,ucbvax!dual}!fortune!redwood!rpw3
DDD:	(415)572-2607
USPS:	510 Trinidad Lane, Foster City, CA  94404

rick@cadtec.UUCP (Rick Auricchio) (03/08/85)

==
Opinions expressed above are my own; nobody else is foolish enough.
Rick Auricchio     Cadtec Corp.  2355 Old Oakland Rd, San Jose CA 95131
{decwrl!nsc,csi,onyx,teklds}!cadtec!rick	N1150G	 (408) 942-1535
	"This space available"