Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84; site elsie.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!bellcore!decvax!wanginst!ucadmus!harvard!seismo!umcp-cs!cvl!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: net.unix Subject: Re: Which *nix ? BSD : System V Message-ID: <5068@elsie.UUCP> Date: Mon, 25-Feb-85 15:07:41 EST Article-I.D.: elsie.5068 Posted: Mon Feb 25 15:07:41 1985 Date-Received: Fri, 1-Mar-85 06:32:30 EST References: <147@rtech.ARPA> <492@rlgvax.UUCP> Distribution: net Organization: NIH-LEC, Bethesda, MD Lines: 59 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 > # 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 > 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 # 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