Use inline functions instead of macros to avoid problems in C++.

Inline functions respect scope, whereas macros don't.
Define umask in sys/stat.h, and mode_t in sys/types.h.
This commit is contained in:
Dimitrie O. Paun 2003-01-11 22:49:54 +00:00 committed by Alexandre Julliard
parent 6843fee633
commit df9537eaef
6 changed files with 45 additions and 26 deletions

View File

@ -156,27 +156,33 @@ int _wunlink(const MSVCRT(wchar_t)*);
#ifndef USE_MSVCRT_PREFIX
#define access _access
#define chmod _chmod
#define chsize _chsize
#define close _close
#define creat _creat
#define dup _dup
#define dup2 _dup2
#define eof _eof
#define filelength _filelength
#define isatty _isatty
#define locking _locking
#define lseek _lseek
#define mktemp _mktemp
static inline int access(const char* path, int mode) { return _access(path, mode); }
static inline int chmod(const char* path, int mode) { return _chmod(path, mode); }
static inline int chsize(int fd, long size) { return _chsize(fd, size); }
static inline int close(int fd) { return _close(fd); }
static inline int creat(const char* path, int mode) { return _creat(path, mode); }
static inline int dup(int od) { return _dup(od); }
static inline int dup2(int od, int nd) { return _dup2(od, nd); }
static inline int eof(int fd) { return _eof(fd); }
static inline long filelength(int fd) { return _filelength(fd); }
static inline int isatty(int fd) { return _isatty(fd); }
static inline int locking(int fd, int mode, long size) { return _locking(fd, mode, size); }
static inline long lseek(int fd, long off, int where) { return _lseek(fd, off, where); }
static inline char* mktemp(char* pat) { return _mktemp(pat); }
#define open _open
#define read _read
#define setmode _setmode
static inline int read(int fd, void* buf, unsigned int size) { return _read(fd, buf, size); }
static inline int setmode(int fd, int mode) { return _setmode(fd, mode); }
#define sopen _sopen
#define tell _tell
#define umask _umask
#define unlink _unlink
#define write _write
#endif /* USE_MSVCRT_PREFIX */
static inline long tell(int fd) { return _tell(fd); }
#ifndef MSVCRT_UMASK_DEFINED
static inline int umask(int fd) { return _umask(fd); }
#define MSVCRT_UMASK_DEFINED
#endif
#ifndef MSVCRT_UNLINK_DEFINED
static inline int unlink(const char* path) { return _unlink(path); }
#define MSVCRT_UNLINK_DEFINED
#endif
static inline int write(int fd, const void* buf, unsigned int size) { return _write(fd, buf, size); }
#endif /* USE _MSVCRT_PREFIX */
#endif /* __WINE_IO_H */

View File

@ -263,7 +263,10 @@ int MSVCRT(wscanf)(const MSVCRT(wchar_t)*,...);
#define pclose _pclose
#define popen _popen
#define tempnam _tempnam
#define unlink _unlink
#ifndef MSVCRT_UNLINK_DEFINED
static inline int unlink(const char* path) { return _unlink(path); }
#define MSVCRT_UNLINK_DEFINED
#endif
#define fgetwchar _fgetwchar
#define fputwchar _fputwchar

View File

@ -106,6 +106,7 @@ int MSVCRT(_fstat)(int,struct _stat*);
int MSVCRT(_stat)(const char*,struct _stat*);
int _fstati64(int,struct _stati64*);
int _stati64(const char*,struct _stati64*);
int _umask(int);
#ifndef MSVCRT_WSTAT_DEFINED
#define MSVCRT_WSTAT_DEFINED
@ -127,8 +128,12 @@ int _wstati64(const MSVCRT(wchar_t)*,struct _stati64*);
#define S_IWRITE _S_IWRITE
#define S_IEXEC _S_IEXEC
#define fstat _fstat
#define stat _stat
static inline int fstat(int fd, struct _stat* ptr) { return _fstat(fd, ptr); }
static inline int stat(const char* path, struct _stat* ptr) { return _stat(path, ptr); }
#ifndef MSVCRT_UMASK_DEFINED
static inline int umask(int fd) { return _umask(fd); }
#define MSVCRT_UMASK_DEFINED
#endif
#endif /* USE_MSVCRT_PREFIX */
#endif /* __WINE_SYS_STAT_H */

View File

@ -60,7 +60,7 @@ void _ftime(struct _timeb*);
#ifndef USE_MSVCRT_PREFIX
#define timeb _timeb
#define ftime _ftime
static inline void ftime(struct _timeb* ptr) { return _ftime(ptr); }
#endif /* USE_MSVCRT_PREFIX */
#endif /* __WINE_SYS_TIMEB_H */

View File

@ -39,6 +39,11 @@ typedef unsigned short _ino_t;
#define MSVCRT_INO_T_DEFINED
#endif
#ifndef MSVCRT_MODE_T_DEFINED
typedef unsigned short _mode_t;
#define MSVCRT_MODE_T_DEFINED
#endif
#ifndef MSVCRT_OFF_T_DEFINED
typedef int MSVCRT(_off_t);
#define MSVCRT_OFF_T_DEFINED
@ -49,10 +54,10 @@ typedef long MSVCRT(time_t);
#define MSVCRT_TIME_T_DEFINED
#endif
#ifndef USE_MSVCRT_PREFIX
#define dev_t _dev_t
#define ino_t _ino_t
#define mode_t _mode_t
#define off_t _off_t
#endif /* USE_MSVCRT_PREFIX */

View File

@ -67,7 +67,7 @@ int _wutime(const MSVCRT(wchar_t)*,struct _utimbuf*);
#ifndef USE_MSVCRT_PREFIX
#define utimbuf _utimbuf
#define utime _utime
static inline int utime(const char* path, struct _utimbuf* buf) { return _utime(path, buf); }
#endif /* USE_MSVCRT_PREFIX */
#endif /* __WINE_SYS_UTIME_H */