-#define S_ISUID 0004000 /* set user id on execution */
-#define S_ISGID 0002000 /* set group id on execution */
-#ifndef _POSIX_SOURCE
-#define S_ISTXT 0001000 /* sticky bit */
-#endif
-
-#define S_IRWXU 0000700 /* RWX mask for owner */
-#define S_IRUSR 0000400 /* R for owner */
-#define S_IWUSR 0000200 /* W for owner */
-#define S_IXUSR 0000100 /* X for owner */
-
-#ifndef _POSIX_SOURCE
-#define S_IREAD S_IRUSR
-#define S_IWRITE S_IWUSR
-#define S_IEXEC S_IXUSR
-#endif
-
-#define S_IRWXG 0000070 /* RWX mask for group */
-#define S_IRGRP 0000040 /* R for group */
-#define S_IWGRP 0000020 /* W for group */
-#define S_IXGRP 0000010 /* X for group */
-
-#define S_IRWXO 0000007 /* RWX mask for other */
-#define S_IROTH 0000004 /* R for other */
-#define S_IWOTH 0000002 /* W for other */
-#define S_IXOTH 0000001 /* X for other */
-
-#ifndef _POSIX_SOURCE
-#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_IFSOCK 0140000 /* socket */
-#define S_IFWHT 0160000 /* whiteout */
-#define S_ISVTX 0001000 /* save swapped text even after use */
-#endif
-
-#define S_ISDIR(m) ((m & 0170000) == 0040000) /* directory */
-#define S_ISCHR(m) ((m & 0170000) == 0020000) /* char special */
-#define S_ISBLK(m) ((m & 0170000) == 0060000) /* block special */
-#define S_ISREG(m) ((m & 0170000) == 0100000) /* regular file */
-#define S_ISFIFO(m) ((m & 0170000) == 0010000 || \
- (m & 0170000) == 0140000) /* fifo or socket */
-#ifndef _POSIX_SOURCE
-#define S_ISLNK(m) ((m & 0170000) == 0120000) /* symbolic link */
-#define S_ISSOCK(m) ((m & 0170000) == 0010000 || \
- (m & 0170000) == 0140000) /* fifo or socket */
-#define S_ISWHT(m) ((m & 0170000) == 0160000) /* whiteout */
-#endif
-
-#ifndef _POSIX_SOURCE
+/*
+ * [XSI] The following are symbolic names for the values of type mode_t. They
+ * are bitmap values.
+ */
+#ifndef S_IFMT
+/* File type */
+#define S_IFMT 0170000 /* [XSI] type of file mask */
+#define S_IFIFO 0010000 /* [XSI] named pipe (fifo) */
+#define S_IFCHR 0020000 /* [XSI] character special */
+#define S_IFDIR 0040000 /* [XSI] directory */
+#define S_IFBLK 0060000 /* [XSI] block special */
+#define S_IFREG 0100000 /* [XSI] regular */
+#define S_IFLNK 0120000 /* [XSI] symbolic link */
+#define S_IFSOCK 0140000 /* [XSI] socket */
+#ifndef _POSIX_C_SOURCE
+#define S_IFWHT 0160000 /* whiteout */
+#define S_IFXATTR 0200000 /* extended attribute */
+#endif
+
+/* File mode */
+/* Read, write, execute/search by owner */
+#define S_IRWXU 0000700 /* [XSI] RWX mask for owner */
+#define S_IRUSR 0000400 /* [XSI] R for owner */
+#define S_IWUSR 0000200 /* [XSI] W for owner */
+#define S_IXUSR 0000100 /* [XSI] X for owner */
+/* Read, write, execute/search by group */
+#define S_IRWXG 0000070 /* [XSI] RWX mask for group */
+#define S_IRGRP 0000040 /* [XSI] R for group */
+#define S_IWGRP 0000020 /* [XSI] W for group */
+#define S_IXGRP 0000010 /* [XSI] X for group */
+/* Read, write, execute/search by others */
+#define S_IRWXO 0000007 /* [XSI] RWX mask for other */
+#define S_IROTH 0000004 /* [XSI] R for other */
+#define S_IWOTH 0000002 /* [XSI] W for other */
+#define S_IXOTH 0000001 /* [XSI] X for other */
+
+#define S_ISUID 0004000 /* [XSI] set user id on execution */
+#define S_ISGID 0002000 /* [XSI] set group id on execution */
+#define S_ISVTX 0001000 /* [XSI] directory restrcted delete */
+
+#ifndef _POSIX_C_SOURCE
+#define S_ISTXT S_ISVTX /* sticky bit: not supported */
+#define S_IREAD S_IRUSR /* backward compatability */
+#define S_IWRITE S_IWUSR /* backward compatability */
+#define S_IEXEC S_IXUSR /* backward compatability */
+#endif
+#endif /* !S_IFMT */
+
+/*
+ * [XSI] The following macros shall be provided to test whether a file is
+ * of the specified type. The value m supplied to the macros is the value
+ * of st_mode from a stat structure. The macro shall evaluate to a non-zero
+ * value if the test is true; 0 if the test is false.
+ */
+#define S_ISBLK(m) (((m) & 0170000) == 0060000) /* block special */
+#define S_ISCHR(m) (((m) & 0170000) == 0020000) /* char special */
+#define S_ISDIR(m) (((m) & 0170000) == 0040000) /* directory */
+#define S_ISFIFO(m) (((m) & 0170000) == 0010000) /* fifo or socket */
+#define S_ISREG(m) (((m) & 0170000) == 0100000) /* regular file */
+#define S_ISLNK(m) (((m) & 0170000) == 0120000) /* symbolic link */
+#define S_ISSOCK(m) (((m) & 0170000) == 0140000) /* socket */
+#ifndef _POSIX_C_SOURCE
+#define S_ISWHT(m) (((m) & 0170000) == 0160000) /* whiteout */
+#define S_ISXATTR(m) (((m) & 0200000) == 0200000) /* extended attribute */
+#endif
+
+/*
+ * [XSI] The implementation may implement message queues, semaphores, or
+ * shared memory objects as distinct file types. The following macros
+ * shall be provided to test whether a file is of the specified type.
+ * The value of the buf argument supplied to the macros is a pointer to
+ * a stat structure. The macro shall evaluate to a non-zero value if
+ * the specified object is implemented as a distinct file type and the
+ * specified file type is contained in the stat structure referenced by
+ * buf. Otherwise, the macro shall evaluate to zero.
+ *
+ * NOTE: The current implementation does not do this, although
+ * this may change in future revisions, and co currently only
+ * provides these macros to ensure source compatability with
+ * implementations which do.
+ */
+#define S_TYPEISMQ(buf) (0) /* Test for a message queue */
+#define S_TYPEISSEM(buf) (0) /* Test for a semaphore */
+#define S_TYPEISSHM(buf) (0) /* Test for a shared memory object */
+
+/*
+ * [TYM] The implementation may implement typed memory objects as distinct
+ * file types, and the following macro shall test whether a file is of the
+ * specified type. The value of the buf argument supplied to the macros is
+ * a pointer to a stat structure. The macro shall evaluate to a non-zero
+ * value if the specified object is implemented as a distinct file type and
+ * the specified file type is contained in the stat structure referenced by
+ * buf. Otherwise, the macro shall evaluate to zero.
+ *
+ * NOTE: The current implementation does not do this, although
+ * this may change in future revisions, and co currently only
+ * provides this macro to ensure source compatability with
+ * implementations which do.
+ */
+#define S_TYPEISTMO(buf) (0) /* Test for a typed memory object */
+
+
+#ifndef _POSIX_C_SOURCE