Subject: Re: CVS commit: src
To: Simon Burge <simonb@telstra.com.au>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: tech-kern
Date: 09/20/1998 07:28:33
On Sun, 20 Sep 1998 17:58:00 +1000
Simon Burge <simonb@telstra.com.au> wrote:
> Dang, just because things recompile under NetBSD doesn't mean it's
> right :(
>
> Is something like the following acceptable? Do any of the _S_IF* need
> protecting? I guess my first foray into standards didn't go too well,
> and I didn't even know it!
This looks ok, sure. The _S_IF* don't need protecting because they're not
in the user's namespace (they're protected w/ the prepended _ :-)
> #define _S_IFMT 0170000 /* type of file mask */
> #define _S_IFIFO 0010000 /* named pipe (fifo) */
> #define _S_IFCHR 0020000 /* character special */
> #define _S_IFDIR 0040000 /* directory */
> #define _S_IFBLK 0060000 /* block special */
> #define _S_IFREG 0100000 /* regular */
> #define _S_IFLNK 0120000 /* symbolic link */
> #define _S_ISVTX 0001000 /* save swapped text even after use */
> #define _S_IFSOCK 0140000 /* socket */
> #define _S_IFWHT 0160000 /* whiteout */
>
> #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
> #define S_IFMT _S_IFMT
> #define S_IFIFO _S_IFIFO
> #define S_IFCHR _S_IFCHR
> #define S_IFDIR _S_IFDIR
> #define S_IFBLK _S_IFBLK
> #define S_IFREG _S_IFREG
> #define S_IFLNK _S_IFLNK
> #define S_ISVTX _S_ISVTX
> #endif
> #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
> #define S_IFSOCK _S_IFSOCK
> #define S_IFWHT _S_IFWHT
> #endif
>
> #define S_ISDIR(m) ((m & _S_IFMT) == _S_IFDIR) /* directory */
> #define S_ISCHR(m) ((m & _S_IFMT) == _S_IFCHR) /* char special */
> #define S_ISBLK(m) ((m & _S_IFMT) == _S_IFBLK) /* block special */
> #define S_ISREG(m) ((m & _S_IFMT) == _S_IFREG) /* regular file */
> #define S_ISFIFO(m) ((m & _S_IFMT) == _S_IFIFO) /* fifo */
> #if !defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE)
> #define S_ISLNK(m) ((m & _S_IFMT) == _S_IFLNK) /* symbolic link */
> #endif
> #if !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)
> #define S_ISSOCK(m) ((m & _S_IFMT) == _S_IFSOCK) /* socket */
> #define S_ISWHT(m) ((m & _S_IFMT) == _S_IFWHT) /* whiteout */
> #endif
>
Jason R. Thorpe thorpej@nas.nasa.gov
NASA Ames Research Center Home: +1 408 866 1912
NAS: M/S 258-5 Work: +1 650 604 0935
Moffett Field, CA 94035 Pager: +1 650 940 5942