newlib-cygwin/newlib/libc/include/sys/stat.h

194 lines
6.0 KiB
C
Raw Normal View History

2000-02-18 03:39:52 +08:00
#ifndef _SYS_STAT_H
#define _SYS_STAT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <_ansi.h>
#include <time.h>
#include <sys/cdefs.h>
2000-02-18 03:39:52 +08:00
#include <sys/types.h>
#include <sys/_timespec.h>
2000-02-18 03:39:52 +08:00
/* dj's stat defines _STAT_H_ */
#ifndef _STAT_H_
/* It is intended that the layout of this structure not change when the
sizes of any of the basic types change (short, int, long) [via a compile
time option]. */
#ifdef __CYGWIN__
#include <cygwin/stat.h>
#ifdef _COMPILING_NEWLIB
#define stat64 stat
#endif
#else
2000-02-18 03:39:52 +08:00
struct stat
{
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
#if defined(__rtems__)
struct timespec st_atim;
struct timespec st_mtim;
struct timespec st_ctim;
blksize_t st_blksize;
blkcnt_t st_blocks;
#else
2000-02-18 03:39:52 +08:00
/* SysV/sco doesn't have the rest... But Solaris, eabi does. */
#if defined(__svr4__) && !defined(__PPC__) && !defined(__sun__)
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
#else
time_t st_atime;
long st_spare1;
time_t st_mtime;
long st_spare2;
time_t st_ctime;
long st_spare3;
long st_blksize;
long st_blocks;
long st_spare4[2];
#endif
#endif
2000-02-18 03:39:52 +08:00
};
#if defined(__rtems__)
#define st_atime st_atim.tv_sec
#define st_ctime st_ctim.tv_sec
#define st_mtime st_mtim.tv_sec
#endif
#endif
2000-02-18 03:39:52 +08:00
#define _IFMT 0170000 /* type of file */
#define _IFDIR 0040000 /* directory */
#define _IFCHR 0020000 /* character special */
#define _IFBLK 0060000 /* block special */
#define _IFREG 0100000 /* regular */
#define _IFLNK 0120000 /* symbolic link */
#define _IFSOCK 0140000 /* socket */
#define _IFIFO 0010000 /* fifo */
#define S_BLKSIZE 1024 /* size of a block */
#define S_ISUID 0004000 /* set user id on execution */
#define S_ISGID 0002000 /* set group id on execution */
#define S_ISVTX 0001000 /* save swapped text even after use */
#ifndef _POSIX_SOURCE
2000-02-18 03:39:52 +08:00
#define S_IREAD 0000400 /* read permission, owner */
#define S_IWRITE 0000200 /* write permission, owner */
#define S_IEXEC 0000100 /* execute/search permission, owner */
#define S_ENFMT 0002000 /* enforcement-mode locking */
#endif /* !_POSIX_SOURCE */
2000-02-18 03:39:52 +08:00
#define S_IFMT _IFMT
#define S_IFDIR _IFDIR
#define S_IFCHR _IFCHR
#define S_IFBLK _IFBLK
#define S_IFREG _IFREG
#define S_IFLNK _IFLNK
#define S_IFSOCK _IFSOCK
#define S_IFIFO _IFIFO
#ifdef _WIN32
/* The Windows header files define _S_ forms of these, so we do too
for easier portability. */
#define _S_IFMT _IFMT
#define _S_IFDIR _IFDIR
#define _S_IFCHR _IFCHR
#define _S_IFIFO _IFIFO
#define _S_IFREG _IFREG
#define _S_IREAD 0000400
#define _S_IWRITE 0000200
#define _S_IEXEC 0000100
#endif
#define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
2000-02-18 03:39:52 +08:00
#define S_IRUSR 0000400 /* read permission, owner */
#define S_IWUSR 0000200 /* write permission, owner */
#define S_IXUSR 0000100/* execute/search permission, owner */
#define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
2000-02-18 03:39:52 +08:00
#define S_IRGRP 0000040 /* read permission, group */
#define S_IWGRP 0000020 /* write permission, grougroup */
#define S_IXGRP 0000010/* execute/search permission, group */
#define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
2000-02-18 03:39:52 +08:00
#define S_IROTH 0000004 /* read permission, other */
#define S_IWOTH 0000002 /* write permission, other */
#define S_IXOTH 0000001/* execute/search permission, other */
#ifndef _POSIX_SOURCE
#define ACCESSPERMS (S_IRWXU | S_IRWXG | S_IRWXO) /* 0777 */
#define ALLPERMS (S_ISUID | S_ISGID | S_ISVTX | S_IRWXU | S_IRWXG | S_IRWXO) /* 07777 */
#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) /* 0666 */
#endif
2000-02-18 03:39:52 +08:00
#define S_ISBLK(m) (((m)&_IFMT) == _IFBLK)
#define S_ISCHR(m) (((m)&_IFMT) == _IFCHR)
#define S_ISDIR(m) (((m)&_IFMT) == _IFDIR)
#define S_ISFIFO(m) (((m)&_IFMT) == _IFIFO)
#define S_ISREG(m) (((m)&_IFMT) == _IFREG)
#define S_ISLNK(m) (((m)&_IFMT) == _IFLNK)
#define S_ISSOCK(m) (((m)&_IFMT) == _IFSOCK)
#if defined(__CYGWIN__)
/* Special tv_nsec values for futimens(2) and utimensat(2). */
#define UTIME_NOW -2L
#define UTIME_OMIT -1L
#endif
2000-02-18 03:39:52 +08:00
int _EXFUN(chmod,( const char *__path, mode_t __mode ));
int _EXFUN(fchmod,(int __fd, mode_t __mode));
int _EXFUN(fstat,( int __fd, struct stat *__sbuf ));
int _EXFUN(mkdir,( const char *_path, mode_t __mode ));
int _EXFUN(mkfifo,( const char *__path, mode_t __mode ));
int _EXFUN(stat,( const char *__restrict __path, struct stat *__restrict __sbuf ));
2000-02-18 03:39:52 +08:00
mode_t _EXFUN(umask,( mode_t __mask ));
#if defined (__SPU__) || defined(__rtems__) || defined(__CYGWIN__) && !defined(__INSIDE_CYGWIN__)
int _EXFUN(lstat,( const char *__restrict __path, struct stat *__restrict __buf ));
int _EXFUN(mknod,( const char *__path, mode_t __mode, dev_t __dev ));
#endif
#if (__POSIX_VISIBLE >= 200809 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
int _EXFUN(fchmodat, (int, const char *, mode_t, int));
#endif
#if (__BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
int _EXFUN(fstatat, (int, const char *__restrict , struct stat *__restrict, int));
int _EXFUN(mkdirat, (int, const char *, mode_t));
int _EXFUN(mkfifoat, (int, const char *, mode_t));
#endif
#if (__BSD_VISIBLE || __XSI_VISIBLE >= 700 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
int _EXFUN(mknodat, (int, const char *, mode_t, dev_t));
#endif
#if (__BSD_VISIBLE || __POSIX_VISIBLE >= 200809 || defined (__CYGWIN__)) && !defined(__INSIDE_CYGWIN__)
int _EXFUN(utimensat, (int, const char *, const struct timespec *, int));
int _EXFUN(futimens, (int, const struct timespec *));
#endif
2000-02-18 03:39:52 +08:00
/* Provide prototypes for most of the _<systemcall> names that are
provided in newlib for some compilers. */
#ifdef _COMPILING_NEWLIB
2000-02-18 03:39:52 +08:00
int _EXFUN(_fstat,( int __fd, struct stat *__sbuf ));
int _EXFUN(_stat,( const char *__restrict __path, struct stat *__restrict __sbuf ));
Throughout, run newlib with -Wall -Werror option and fix bugs and compiler warnings found this way. * libc/stdio/freopen.c (_freopen_r): Fix bug setting _flags. * libc/include/stdio.h (_rename): Define when building newlib. * libc/include/sys/signal.h (_kill): Ditto. * libc/include/sys/stat.h (_mkdir): Ditto. * libc/include/sys/time.h (_gettimeofday): Ditto. * libc/include/sys/times.h (_times): Ditto. * libc/include/sys/wait.h (_wait): Ditto. * libc/locale/lmessages.c (empty): Don't define for Cygwin. * libc/locale/lmonetary.c (cnv): Ditto. * libc/locale/nl_langinfo.c (nl_langinfo): Ditto for variable s. * libc/posix/collate.c: Throughout cast to avoid compiler warning. * libc/posix/engine.c (matcher): Initialize dp to avoid compiler warning. * libc/posix/glob.c: Disable on Cygwin. Explain why. * libc/posix/regcomp.c: Fix "uninitialized" compiler warnings. (dissect): Deliberately silence gcc compiler warning. Add comment to explain why. * libc/posix/wordexp.c (wordexp): Remove num_bytes variable since result is never used. * libc/posix/popen.c (popen): Ditto for variable last. * libc/reent/mkdirr.c: Include sys/stat.h. * libc/reent/renamer.c: Include stdio.h. * libc/search/hash.c: Throughout use underscored variants of the stat function family. (init_hash): Add missing definition for the __USE_INTERNAL_STAT64 case. * libc/search/hash_bigkey.c (__big_insert): Add parenthesis to avoid compiler warning. * libc/search/hash_page.c (overflow_page): Initalize freep to NULL to avoid compiler warning. * libc/stdio/asiprintf.c (_asiprintf_r): Cast unsigned char * to char * to avoid compiler warning. (asiprintf): Ditto. * libc/stdio/asprintf.c (_asprintf_r): Ditto. (asprintf): Ditto. * libc/stdio/vasiprintf.c (_vasiprintf_r): Ditto. * libc/stdio/vasprintf.c (_vasprintf_r): Ditto. * libc/stdio/mktemp.c (_gettemp): Cast to unsigned char in call to isdigit to avoid compiler warning. * libc/stdio/vfprintf.c (_VFPRINTF_R): Initialize variables used for grouping to avoid compiler warning. Only define and set nseps and nrepeats if they are really used. * libc/stdio/vfwprintf.c (_VFWPRINTF_R): Ditto. Only define state if it is really used. * libc/stdio/vfscanf.c (u_char): Revert to be defined as unsigned char. (__SVFSCANF_R): Cast fmt in call to __mbtowc. * libc/stdlib/mbtowc_r.c (JIS_state_table): Disable when building Cygwin. (JIS_action_table): Ditto. * libc/stdlib/wctomb_r.c (__utf8_wctomb): Add parenthesis to avoid compiler warning. * libc/string/strcasestr.c: Deliberately silence gcc compiler warning. Add comment to explain why. * libc/time/strptime.c (strptime): Cast to unsigned char in calls to isspace to avoid compiler warning. * libm/math/e_atan2.c (__ieee754_atan2): Add parenthesis to avoid compiler warning. * libm/math/e_exp.c (__ieee754_exp): Initialize k to 0 to avoid compiler warning. Drop setting it to 0 later. * libm/math/ef_exp.c (__ieee754_expf): Ditto. * libm/math/e_pow.c (__ieee754_pow): Add braces to avoid compiler warning. * libm/math/ef_pow.c (__ieee754_powf): Ditto. * libm/math/er_lgamma.c (__ieee754_lgamma_r): Initialize nadj to 0 to avoid compiler warning. * libm/math/erf_lgamma.c (__ieee754_lgammaf_r): Ditto. * libm/math/e_rem_pio2.c (__ieee754_rem_pio2): Ditto for variable z. * libm/common/sf_round.c (roundf): Remove signbit variable since result is never used.
2012-08-08 19:04:18 +08:00
int _EXFUN(_mkdir,( const char *_path, mode_t __mode ));
#ifdef __LARGE64_FILES
struct stat64;
int _EXFUN(_stat64,( const char *__restrict __path, struct stat64 *__restrict __sbuf ));
int _EXFUN(_fstat64,( int __fd, struct stat64 *__sbuf ));
#endif
#endif
2000-02-18 03:39:52 +08:00
#endif /* !_STAT_H_ */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_STAT_H */