Which *nix ? BSD : System V

Arthur David Olson ado at elsie.UUCP
Tue Feb 26 06:07:41 AEST 1985


daveb at 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 at 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 at seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks



More information about the Comp.unix mailing list