Add missing types, update standard namespaces, and use variable types

that don't require <sys/types.h>.
This commit is contained in:
Mike Barcroft 2003-03-14 16:09:48 +00:00
parent 2be1729151
commit 13141dbc38

View File

@ -45,11 +45,48 @@
#include <sys/cdefs.h>
#include <sys/_types.h>
/* XXX missing blkcnt_t, blksize_t, dev_t. */
#ifndef _FFLAGS_T_DECLARED
typedef __fflags_t fflags_t; /* file flags */
typedef __fflags_t fflags_t;
#define _FFLAGS_T_DECLARED
#endif
#ifndef _GID_T_DECLARED
typedef __gid_t gid_t;
#define _GID_T_DECLARED
#endif
#ifndef _INO_T_DECLARED
typedef __ino_t ino_t;
#define _INO_T_DECLARED
#endif
#ifndef _MODE_T_DECLARED
typedef __mode_t mode_t;
#define _MODE_T_DECLARED
#endif
#ifndef _NLINK_T_DECLARED
typedef __nlink_t nlink_t;
#define _NLINK_T_DECLARED
#endif
#ifndef _OFF_T_DECLARED
typedef __off_t off_t;
#define _OFF_T_DECLARED
#endif
#ifndef _TIME_T_DECLARED
typedef __time_t time_t;
#define _TIME_T_DECLARED
#endif
#ifndef _UID_T_DECLARED
typedef __uid_t uid_t;
#define _UID_T_DECLARED
#endif
#if !defined(_KERNEL) && !defined(_POSIX_SOURCE)
/*
* XXX we need this for struct timespec. We get miscellaneous namespace
@ -62,31 +99,31 @@ typedef __fflags_t fflags_t; /* file flags */
#include <sys/_timespec.h>
#endif
#ifdef _KERNEL
#ifdef _KERNEL /* XXX __dev_t should be in <sys/_types.h>. */
#define __dev_t udev_t
#else
#define __dev_t dev_t
#endif
#ifndef _POSIX_SOURCE
#if __BSD_VISIBLE
struct ostat {
u_int16_t st_dev; /* inode's device */
__uint16_t st_dev; /* inode's device */
ino_t st_ino; /* inode's number */
mode_t st_mode; /* inode protection mode */
nlink_t st_nlink; /* number of hard links */
u_int16_t st_uid; /* user ID of the file's owner */
u_int16_t st_gid; /* group ID of the file's group */
u_int16_t st_rdev; /* device type */
int32_t st_size; /* file size, in bytes */
__uint16_t st_uid; /* user ID of the file's owner */
__uint16_t st_gid; /* group ID of the file's group */
__uint16_t st_rdev; /* device type */
__int32_t st_size; /* file size, in bytes */
struct timespec st_atimespec; /* time of last access */
struct timespec st_mtimespec; /* time of last data modification */
struct timespec st_ctimespec; /* time of last file status change */
int32_t st_blksize; /* optimal blocksize for I/O */
int32_t st_blocks; /* blocks allocated for file */
__int32_t st_blksize; /* optimal blocksize for I/O */
__int32_t st_blocks; /* blocks allocated for file */
fflags_t st_flags; /* user defined flags for file */
u_int32_t st_gen; /* file generation number */
__uint32_t st_gen; /* file generation number */
};
#endif /* !_POSIX_SOURCE */
#endif /* __BSD_VISIBLE */
struct stat {
__dev_t st_dev; /* inode's device */
@ -96,7 +133,7 @@ struct stat {
uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */
__dev_t st_rdev; /* device type */
#ifndef _POSIX_SOURCE
#if __BSD_VISIBLE
struct timespec st_atimespec; /* time of last access */
struct timespec st_mtimespec; /* time of last data modification */
struct timespec st_ctimespec; /* time of last file status change */
@ -109,12 +146,12 @@ struct stat {
long st_ctimensec; /* nsec of last file status change */
#endif
off_t st_size; /* file size, in bytes */
int64_t st_blocks; /* blocks allocated for file */
u_int32_t st_blksize; /* optimal blocksize for I/O */
__int64_t st_blocks; /* blocks allocated for file */
__uint32_t st_blksize; /* optimal blocksize for I/O */
fflags_t st_flags; /* user defined flags for file */
u_int32_t st_gen; /* file generation number */
int32_t st_lspare;
#ifndef _POSIX_SOURCE
__uint32_t st_gen; /* file generation number */
__int32_t st_lspare;
#if __BSD_VISIBLE
struct timespec st_birthtimespec; /* time of file creation */
/*
* Explicitly pad st_birthtimespec to 16 bytes so that the size of
@ -124,8 +161,8 @@ struct stat {
* to cover up to 64 bits on 32-bit machines. We assume that
* CHAR_BIT is 8...
*/
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
#else
time_t st_birthtime; /* time of file creation */
long st_birthtimensec; /* nsec of file creation */
@ -134,12 +171,12 @@ struct stat {
#endif
};
#ifndef _POSIX_SOURCE
#if __BSD_VISIBLE
struct nstat {
__dev_t st_dev; /* inode's device */
ino_t st_ino; /* inode's number */
u_int32_t st_mode; /* inode protection mode */
u_int32_t st_nlink; /* number of hard links */
__uint32_t st_mode; /* inode protection mode */
__uint32_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of the file's owner */
gid_t st_gid; /* group ID of the file's group */
__dev_t st_rdev; /* device type */
@ -147,22 +184,22 @@ struct nstat {
struct timespec st_mtimespec; /* time of last data modification */
struct timespec st_ctimespec; /* time of last file status change */
off_t st_size; /* file size, in bytes */
int64_t st_blocks; /* blocks allocated for file */
u_int32_t st_blksize; /* optimal blocksize for I/O */
__int64_t st_blocks; /* blocks allocated for file */
__uint32_t st_blksize; /* optimal blocksize for I/O */
fflags_t st_flags; /* user defined flags for file */
u_int32_t st_gen; /* file generation number */
__uint32_t st_gen; /* file generation number */
struct timespec st_birthtimespec; /* time of file creation */
/*
* See above about the following padding.
*/
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
unsigned int :(8 / 2) * (16 - (int)sizeof(struct timespec));
};
#endif
#undef __dev_t
#ifndef _POSIX_SOURCE
#if __BSD_VISIBLE
#define st_atime st_atimespec.tv_sec
#define st_mtime st_mtimespec.tv_sec
#define st_ctime st_ctimespec.tv_sec
@ -171,7 +208,7 @@ struct nstat {
#define S_ISUID 0004000 /* set user id on execution */
#define S_ISGID 0002000 /* set group id on execution */
#ifndef _POSIX_SOURCE
#if __BSD_VISIBLE
#define S_ISTXT 0001000 /* sticky bit */
#endif
@ -180,7 +217,7 @@ struct nstat {
#define S_IWUSR 0000200 /* W for owner */
#define S_IXUSR 0000100 /* X for owner */
#ifndef _POSIX_SOURCE
#if __BSD_VISIBLE
#define S_IREAD S_IRUSR
#define S_IWRITE S_IWUSR
#define S_IEXEC S_IXUSR
@ -196,7 +233,7 @@ struct nstat {
#define S_IWOTH 0000002 /* W for other */
#define S_IXOTH 0000001 /* X for other */
#ifndef _POSIX_SOURCE
#if __XSI_VISIBLE
#define S_IFMT 0170000 /* type of file mask */
#define S_IFIFO 0010000 /* named pipe (fifo) */
#define S_IFCHR 0020000 /* character special */
@ -205,22 +242,26 @@ struct nstat {
#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
#if __BSD_VISIBLE
#define S_IFWHT 0160000 /* whiteout */
#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) /* fifo or socket */
#ifndef _POSIX_SOURCE
#if __POSIX_VISIBLE >= 200112
#define S_ISLNK(m) (((m) & 0170000) == 0120000) /* symbolic link */
#define S_ISSOCK(m) (((m) & 0170000) == 0140000) /* socket */
#endif
#if __XSI_VISIBLE
#define S_ISWHT(m) (((m) & 0170000) == 0160000) /* whiteout */
#endif
#ifndef _POSIX_SOURCE
#if __BSD_VISIBLE
#define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO) /* 0777 */
/* 7777 */
#define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
@ -260,27 +301,31 @@ struct nstat {
#define NOUNLINK (UF_NOUNLINK | SF_NOUNLINK)
#endif
#endif /* !_POSIX_SOURCE */
#endif /* __BSD_VISIBLE */
#ifndef _KERNEL
__BEGIN_DECLS
#if __BSD_VISIBLE
int chflags(const char *, unsigned long);
#endif
int chmod(const char *, mode_t);
#if __BSD_VISIBLE
int fchflags(int, unsigned long);
int fchmod(int, mode_t);
#endif
int fstat(int, struct stat *);
#if __BSD_VISIBLE
int lchflags(const char *, int);
int lchmod(const char *, mode_t);
#endif
#if __POSIX_VISIBLE >= 200112
int lstat(const char *, struct stat *);
#endif
int mkdir(const char *, mode_t);
int mkfifo(const char *, mode_t);
int stat(const char *, struct stat *);
mode_t umask(mode_t);
#ifndef _POSIX_SOURCE
int chflags(const char *, unsigned long);
int lchflags(const char *, int);
int fchflags(int, unsigned long);
int fchmod(int, mode_t);
int lchmod(const char *, mode_t);
int lstat(const char *, struct stat *);
#endif
__END_DECLS
#endif /* !_KERNEL */
#endif /* !_SYS_STAT_H_ */