From df9537eaefca420fff10ae68b4803c1b0518ce6c Mon Sep 17 00:00:00 2001 From: "Dimitrie O. Paun" Date: Sat, 11 Jan 2003 22:49:54 +0000 Subject: [PATCH] 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. --- include/msvcrt/io.h | 46 +++++++++++++++++++++----------------- include/msvcrt/stdio.h | 5 ++++- include/msvcrt/sys/stat.h | 9 ++++++-- include/msvcrt/sys/timeb.h | 2 +- include/msvcrt/sys/types.h | 7 +++++- include/msvcrt/sys/utime.h | 2 +- 6 files changed, 45 insertions(+), 26 deletions(-) diff --git a/include/msvcrt/io.h b/include/msvcrt/io.h index f76e22b381a..6b4787880b5 100644 --- a/include/msvcrt/io.h +++ b/include/msvcrt/io.h @@ -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 */ diff --git a/include/msvcrt/stdio.h b/include/msvcrt/stdio.h index 91506ff0cfd..dee46c58d88 100644 --- a/include/msvcrt/stdio.h +++ b/include/msvcrt/stdio.h @@ -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 diff --git a/include/msvcrt/sys/stat.h b/include/msvcrt/sys/stat.h index 4af2ade9230..9603b54411a 100644 --- a/include/msvcrt/sys/stat.h +++ b/include/msvcrt/sys/stat.h @@ -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 */ diff --git a/include/msvcrt/sys/timeb.h b/include/msvcrt/sys/timeb.h index 17477fb612d..f2e6a46053c 100644 --- a/include/msvcrt/sys/timeb.h +++ b/include/msvcrt/sys/timeb.h @@ -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 */ diff --git a/include/msvcrt/sys/types.h b/include/msvcrt/sys/types.h index ca98db2bbe5..0b9e0099cf2 100644 --- a/include/msvcrt/sys/types.h +++ b/include/msvcrt/sys/types.h @@ -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 */ diff --git a/include/msvcrt/sys/utime.h b/include/msvcrt/sys/utime.h index 0a0c48c8b4a..29d9d12555c 100644 --- a/include/msvcrt/sys/utime.h +++ b/include/msvcrt/sys/utime.h @@ -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 */