diff options
Diffstat (limited to 'include/ruby/win32.h')
| -rw-r--r-- | include/ruby/win32.h | 160 |
1 files changed, 76 insertions, 84 deletions
diff --git a/include/ruby/win32.h b/include/ruby/win32.h index 27a3467606..fe1978fdde 100644 --- a/include/ruby/win32.h +++ b/include/ruby/win32.h @@ -19,6 +19,11 @@ RUBY_SYMBOL_EXPORT_BEGIN */ /* + * Definitions for NT port of Perl + */ + + +/* * Ok now we can include the normal include files. */ @@ -35,7 +40,6 @@ extern "C++" { /* template without extern "C++" */ #endif #include <winsock2.h> #include <ws2tcpip.h> -#include <mswsock.h> #if !defined(_MSC_VER) || _MSC_VER >= 1400 #include <iphlpapi.h> #endif @@ -134,44 +138,38 @@ typedef int clockid_t; #undef stat #undef fstat #ifdef RUBY_EXPORT -#define utime(_p, _t) rb_w32_uutime(_p, _t) +#define utime(_p, _t) rb_w32_utime(_p, _t) #undef HAVE_UTIMES #define HAVE_UTIMES 1 -#define utimes(_p, _t) rb_w32_uutimes(_p, _t) +#define utimes(_p, _t) rb_w32_utimes(_p, _t) #undef HAVE_UTIMENSAT #define HAVE_UTIMENSAT 1 #define AT_FDCWD -100 -#define utimensat(_d, _p, _t, _f) rb_w32_uutimensat(_d, _p, _t, _f) -#define lseek(_f, _o, _w) rb_w32_lseek(_f, _o, _w) +#define utimensat(_d, _p, _t, _f) rb_w32_utimensat(_d, _p, _t, _f) +#define lseek(_f, _o, _w) _lseeki64(_f, _o, _w) #define pipe(p) rb_w32_pipe(p) -#define open rb_w32_uopen +#define open rb_w32_open #define close(h) rb_w32_close(h) #define fclose(f) rb_w32_fclose(f) -#define read(f, b, s) rb_w32_read(f, b, s) -#define write(f, b, s) rb_w32_write(f, b, s) -#define pread(f, b, s, o) rb_w32_pread(f, b, s, o) -#define pwrite(f, b, s, o) rb_w32_pwrite(f, b, s, o) +#define read(f, b, s) rb_w32_read(f, b, s) +#define write(f, b, s) rb_w32_write(f, b, s) #define getpid() rb_w32_getpid() -#undef HAVE_GETPPID -#define HAVE_GETPPID 1 #define getppid() rb_w32_getppid() #define sleep(x) rb_w32_Sleep((x)*1000) #define Sleep(msec) (void)rb_w32_Sleep(msec) -#undef HAVE_EXECV -#define HAVE_EXECV 1 #undef execv -#define execv(path,argv) rb_w32_uaspawn(P_OVERLAY,path,argv) +#define execv(path,argv) rb_w32_aspawn(P_OVERLAY,path,argv) #undef isatty #define isatty(h) rb_w32_isatty(h) #undef mkdir -#define mkdir(p, m) rb_w32_umkdir(p, m) +#define mkdir(p, m) rb_w32_mkdir(p, m) #undef rmdir -#define rmdir(p) rb_w32_urmdir(p) +#define rmdir(p) rb_w32_rmdir(p) #undef unlink -#define unlink(p) rb_w32_uunlink(p) +#define unlink(p) rb_w32_unlink(p) #endif /* RUBY_EXPORT */ /* same with stati64 except the size of st_ino and nanosecond timestamps */ @@ -193,6 +191,8 @@ struct stati128 { long st_ctimensec; }; +#if SIZEOF_OFF_T == 8 +#define off_t __int64 #define stat stati128 #undef SIZEOF_STRUCT_STAT_ST_INO #define SIZEOF_STRUCT_STAT_ST_INO sizeof(unsigned __int64) @@ -201,9 +201,15 @@ struct stati128 { #define HAVE_STRUCT_STAT_ST_MTIMENSEC #define HAVE_STRUCT_STAT_ST_CTIMENSEC #define fstat(fd,st) rb_w32_fstati128(fd,st) -#define stati128(path, st) rb_w32_ustati128(path,st) -#define lstat(path,st) rb_w32_ulstati128(path,st) -#define access(path,mode) rb_w32_uaccess(path,mode) +#define stati128(path, st) rb_w32_stati128(path,st) +#else +#define stat(path,st) rb_w32_stat(path,st) +#define fstat(fd,st) rb_w32_fstat(fd,st) +extern int rb_w32_stat(const char *, struct stat *); +extern int rb_w32_fstat(int, struct stat *); +#endif +#define lstat(path,st) rb_w32_lstati128(path,st) +#define access(path,mode) rb_w32_access(path,mode) #define strcasecmp _stricmp #define strncasecmp _strnicmp @@ -252,6 +258,7 @@ struct ifaddrs { extern void rb_w32_sysinit(int *, char ***); extern DWORD rb_w32_osid(void); +extern rb_pid_t rb_w32_pipe_exec(const char *, const char *, int, int *, int *); extern int flock(int fd, int oper); extern int rb_w32_io_cancelable_p(int); extern int rb_w32_is_socket(int); @@ -287,8 +294,10 @@ extern struct servent *WSAAPI rb_w32_getservbyport(int, const char *); extern int socketpair(int, int, int, int *); extern int getifaddrs(struct ifaddrs **); extern void freeifaddrs(struct ifaddrs *); -extern char * rb_w32_ugetcwd(char *, int); +extern char * rb_w32_getcwd(char *, int); extern char * rb_w32_ugetenv(const char *); +extern char * rb_w32_getenv(const char *); +extern int rb_w32_rename(const char *, const char *); extern int rb_w32_urename(const char *, const char *); extern char **rb_w32_get_environ(void); extern void rb_w32_free_environ(char **); @@ -297,33 +306,44 @@ extern const char *WSAAPI rb_w32_inet_ntop(int,const void *,char *,size_t); extern int WSAAPI rb_w32_inet_pton(int,const char *,void *); extern DWORD rb_w32_osver(void); +extern int chown(const char *, int, int); extern int rb_w32_uchown(const char *, int, int); +extern int link(const char *, const char *); extern int rb_w32_ulink(const char *, const char *); +extern ssize_t readlink(const char *, char *, size_t); extern ssize_t rb_w32_ureadlink(const char *, char *, size_t); +extern ssize_t rb_w32_wreadlink(const WCHAR *, WCHAR *, size_t); +extern int symlink(const char *src, const char *link); extern int rb_w32_usymlink(const char *src, const char *link); extern int gettimeofday(struct timeval *, struct timezone *); extern int clock_gettime(clockid_t, struct timespec *); extern int clock_getres(clockid_t, struct timespec *); -extern rb_pid_t waitpid(rb_pid_t, int *, int); -extern rb_pid_t wait(int *); +extern rb_pid_t waitpid (rb_pid_t, int *, int); +extern rb_pid_t rb_w32_spawn(int, const char *, const char*); +extern rb_pid_t rb_w32_aspawn(int, const char *, char *const *); +extern rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD); extern rb_pid_t rb_w32_uspawn(int, const char *, const char*); extern rb_pid_t rb_w32_uaspawn(int, const char *, char *const *); extern rb_pid_t rb_w32_uaspawn_flags(int, const char *, char *const *, DWORD); -#undef HAVE_KILL -#define HAVE_KILL 1 -extern int kill(rb_pid_t, int); +extern int kill(int, int); extern int fcntl(int, int, ...); extern int rb_w32_set_nonblock(int); extern rb_pid_t rb_w32_getpid(void); extern rb_pid_t rb_w32_getppid(void); extern int rb_w32_isatty(int); extern int rb_w32_uchdir(const char *); +extern int rb_w32_mkdir(const char *, int); extern int rb_w32_umkdir(const char *, int); +extern int rb_w32_rmdir(const char *); extern int rb_w32_urmdir(const char *); +extern int rb_w32_unlink(const char *); extern int rb_w32_uunlink(const char *); extern int rb_w32_uchmod(const char *, int); +extern int rb_w32_stati128(const char *, struct stati128 *); extern int rb_w32_ustati128(const char *, struct stati128 *); +extern int rb_w32_lstati128(const char *, struct stati128 *); extern int rb_w32_ulstati128(const char *, struct stati128 *); +extern int rb_w32_access(const char *, int); extern int rb_w32_uaccess(const char *, int); extern char rb_w32_fd_is_text(int); extern int rb_w32_fstati128(int, struct stati128 *); @@ -345,6 +365,14 @@ rb_infinity_float(void) #endif #if !defined __MINGW32__ || defined __NO_ISOCEXT +#ifndef isnan +#define isnan(x) _isnan(x) +#endif +static inline int +finite(double x) +{ + return _finite(x); +} #ifndef copysign #define copysign(a, b) _copysign(a, b) #endif @@ -353,6 +381,8 @@ scalb(double a, long b) { return _scalb(a, b); } +#else +__declspec(dllimport) extern int finite(double); #endif #if !defined S_IFIFO && defined _S_IFIFO @@ -390,7 +420,6 @@ scalb(double a, long b) #endif #define S_IFLNK 0xa000 -#define S_IFSOCK 0xc000 /* * define this so we can do inplace editing @@ -398,9 +427,9 @@ scalb(double a, long b) #define SUFFIX -extern int rb_w32_ftruncate(int fd, rb_off_t length); -extern int rb_w32_truncate(const char *path, rb_off_t length); -extern int rb_w32_utruncate(const char *path, rb_off_t length); +extern int rb_w32_ftruncate(int fd, off_t length); +extern int rb_w32_truncate(const char *path, off_t length); +extern int rb_w32_utruncate(const char *path, off_t length); #undef HAVE_FTRUNCATE #define HAVE_FTRUNCATE 1 @@ -412,7 +441,11 @@ extern int rb_w32_utruncate(const char *path, rb_off_t length); #undef HAVE_TRUNCATE #define HAVE_TRUNCATE 1 -#define truncate rb_w32_utruncate +#if defined HAVE_TRUNCATE64 +#define truncate truncate64 +#else +#define truncate rb_w32_truncate +#endif #if defined(_MSC_VER) && _MSC_VER >= 1400 && _MSC_VER < 1800 #define strtoll _strtoi64 @@ -650,8 +683,6 @@ extern char *rb_w32_strerror(int); #undef setsockopt #define setsockopt(s, v, n, o, l) rb_w32_setsockopt(s, v, n, o, l) -#undef HAVE_SHUTDOWN -#define HAVE_SHUTDOWN 1 #undef shutdown #define shutdown(s, h) rb_w32_shutdown(s, h) @@ -683,13 +714,13 @@ extern char *rb_w32_strerror(int); #define get_osfhandle(h) rb_w32_get_osfhandle(h) #undef getcwd -#define getcwd(b, s) rb_w32_ugetcwd(b, s) +#define getcwd(b, s) rb_w32_getcwd(b, s) #undef getenv -#define getenv(n) rb_w32_ugetenv(n) +#define getenv(n) rb_w32_getenv(n) #undef rename -#define rename(o, n) rb_w32_urename(o, n) +#define rename(o, n) rb_w32_rename(o, n) #undef times #define times(t) rb_w32_times(t) @@ -699,10 +730,10 @@ extern char *rb_w32_strerror(int); #endif struct tms { - long tms_utime; - long tms_stime; - long tms_cutime; - long tms_cstime; + long tms_utime; + long tms_stime; + long tms_cutime; + long tms_cstime; }; int rb_w32_times(struct tms *); @@ -712,6 +743,7 @@ struct tm *localtime_r(const time_t *, struct tm *); /* thread stuff */ int rb_w32_sleep(unsigned long msec); +int rb_w32_open(const char *, int, ...); int rb_w32_uopen(const char *, int, ...); int rb_w32_wopen(const WCHAR *, int, ...); int rb_w32_close(int); @@ -719,11 +751,11 @@ int rb_w32_fclose(FILE*); int rb_w32_pipe(int[2]); ssize_t rb_w32_read(int, void *, size_t); ssize_t rb_w32_write(int, const void *, size_t); -ssize_t rb_w32_pread(int, void *, size_t, rb_off_t offset); -ssize_t rb_w32_pwrite(int, const void *, size_t, rb_off_t offset); -rb_off_t rb_w32_lseek(int, rb_off_t, int); +int rb_w32_utime(const char *, const struct utimbuf *); int rb_w32_uutime(const char *, const struct utimbuf *); +int rb_w32_utimes(const char *, const struct timeval *); int rb_w32_uutimes(const char *, const struct timeval *); +int rb_w32_utimensat(int /* must be AT_FDCWD */, const char *, const struct timespec *, int /* must be 0 */); int rb_w32_uutimensat(int /* must be AT_FDCWD */, const char *, const struct timespec *, int /* must be 0 */); long rb_w32_write_console(uintptr_t, int); /* use uintptr_t instead of VALUE because it's not defined yet here */ int WINAPI rb_w32_Sleep(unsigned long msec); @@ -734,27 +766,6 @@ int rb_w32_unwrap_io_handle(int); WCHAR *rb_w32_mbstr_to_wstr(UINT, const char *, int, long *); char *rb_w32_wstr_to_mbstr(UINT, const WCHAR *, int, long *); -DEPRECATED_BY(rb_w32_ugetcwd, char *rb_w32_getcwd(char *, int)); -DEPRECATED_BY(rb_w32_ugetenv, char *rb_w32_getenv(const char *)); -DEPRECATED_BY(rb_w32_urename, int rb_w32_rename(const char *, const char *)); -DEPRECATED_BY(rb_w32_uopen, int rb_w32_open(const char *, int, ...)); -DEPRECATED_BY(rb_w32_uchown, int chown(const char *, int, int)); -DEPRECATED_BY(rb_w32_ulink, int link(const char *, const char *)); -DEPRECATED_BY(rb_w32_ureadlink, ssize_t readlink(const char *, char *, size_t)); -DEPRECATED_BY(rb_w32_usymlink, int symlink(const char *src, const char *link)); -DEPRECATED_BY(rb_w32_umkdir, int rb_w32_mkdir(const char *, int)); -DEPRECATED_BY(rb_w32_urmdir, int rb_w32_rmdir(const char *)); -DEPRECATED_BY(rb_w32_uunlink, int rb_w32_unlink(const char *)); -DEPRECATED_BY(rb_w32_uutime, int rb_w32_utime(const char *, const struct utimbuf *)); -DEPRECATED_BY(rb_w32_uutimes, int rb_w32_utimes(const char *, const struct timeval *)); -DEPRECATED_BY(rb_w32_uutimensat, int rb_w32_utimensat(int, const char *, const struct timespec *, int)); -DEPRECATED_BY(rb_w32_ustati128, int rb_w32_stati128(const char *, struct stati128 *)); -DEPRECATED_BY(rb_w32_ulstati128, int rb_w32_lstati128(const char *, struct stati128 *)); -DEPRECATED_BY(rb_w32_uaccess, int rb_w32_access(const char *, int)); -DEPRECATED_BY(rb_w32_uspawn, rb_pid_t rb_w32_spawn(int, const char *, const char*)); -DEPRECATED_BY(rb_w32_uaspawn, rb_pid_t rb_w32_aspawn(int, const char *, char *const *)); -DEPRECATED_BY(rb_w32_uaspawn_flags, rb_pid_t rb_w32_aspawn_flags(int, const char *, char *const *, DWORD)); - /* == ***CAUTION*** Since this function is very dangerous, ((*NEVER*)) @@ -803,25 +814,6 @@ double rb_w32_pow(double x, double y); #define pow rb_w32_pow #endif -// mmap tiny emulation -#define MAP_FAILED ((void *)-1) - -#define PROT_READ 0x01 -#define PROT_WRITE 0x02 -#define PROT_EXEC 0x04 - -#define MAP_PRIVATE 0x0002 -#define MAP_ANON 0x1000 -#define MAP_ANONYMOUS MAP_ANON - -extern void *rb_w32_mmap(void *, size_t, int, int, int, rb_off_t); -extern int rb_w32_munmap(void *, size_t); -extern int rb_w32_mprotect(void *, size_t, int); - -#define mmap(a, l, p, f, d, o) rb_w32_mmap(a, l, p, f, d, o) -#define munmap(a, l) rb_w32_munmap(a, l) -#define mprotect(a, l, prot) rb_w32_mprotect(a, l, prot) - #if defined(__cplusplus) #if 0 { /* satisfy cc-mode */ |
