diff options
author | Niklas Therning <niklas@therning.org> | 2017-01-31 13:03:15 +0300 |
---|---|---|
committer | Niklas Therning <niklas@therning.org> | 2017-02-01 11:19:35 +0300 |
commit | a55ddfca06c299ee350e65987a99dc37c20fb64c (patch) | |
tree | cceb448e5c82a3cabcef42f549d06de61bc28a57 /support | |
parent | e3a6168dc24f425bace4d80a6b89e0cf0759c25c (diff) |
Fixes the Mono.Posix API breakage introduced in #3985
Also reverts the changes done to support/map.c. This is a generated file which
shouldn't be changed directly. An alternate fix for the problem in map.c on
Windows was to make sure L_SET et al are defined in mph.h which was already
done for Solaris.
Diffstat (limited to 'support')
-rw-r--r-- | support/fcntl.c | 7 | ||||
-rw-r--r-- | support/map.c | 40 | ||||
-rw-r--r-- | support/mph.h | 8 | ||||
-rw-r--r-- | support/stdio.c | 8 | ||||
-rw-r--r-- | support/sys-stat.c | 12 |
5 files changed, 56 insertions, 19 deletions
diff --git a/support/fcntl.c b/support/fcntl.c index 85605d1bc21..900a58f8104 100644 --- a/support/fcntl.c +++ b/support/fcntl.c @@ -13,15 +13,21 @@ #include <sys/types.h> #include <sys/stat.h> +#ifdef HAVE_UNISTD_H #include <unistd.h> +#endif #include <fcntl.h> #include <errno.h> +#ifdef HOST_WIN32 +#include <corecrt_io.h> +#endif #include "map.h" #include "mph.h" G_BEGIN_DECLS +#ifndef HOST_WIN32 gint32 Mono_Posix_Syscall_fcntl (gint32 fd, gint32 cmd) { @@ -95,6 +101,7 @@ Mono_Posix_Syscall_fcntl_lock (gint32 fd, gint32 cmd, struct Mono_Posix_Flock *l return r; } +#endif gint32 Mono_Posix_Syscall_open (const char *pathname, gint32 flags) diff --git a/support/map.c b/support/map.c index 615584889df..92fca755371 100644 --- a/support/map.c +++ b/support/map.c @@ -4716,36 +4716,52 @@ int Mono_Posix_ToPosixMadviseAdvice (int x, int *r) int Mono_Posix_FromSeekFlags (short x, short *r) { *r = 0; -#ifdef L_INCR if (x == Mono_Posix_SeekFlags_L_INCR) +#ifdef L_INCR {*r = L_INCR; return 0;} -#endif /* def L_INCR */ -#ifdef L_SET +#else /* def L_INCR */ + {errno = EINVAL; return -1;} +#endif /* ndef L_INCR */ if (x == Mono_Posix_SeekFlags_L_SET) +#ifdef L_SET {*r = L_SET; return 0;} -#endif /* def L_SET */ -#ifdef L_XTND +#else /* def L_SET */ + {errno = EINVAL; return -1;} +#endif /* ndef L_SET */ if (x == Mono_Posix_SeekFlags_L_XTND) +#ifdef L_XTND {*r = L_XTND; return 0;} -#endif /* def L_XTND */ -#ifdef SEEK_CUR +#else /* def L_XTND */ + {errno = EINVAL; return -1;} +#endif /* ndef L_XTND */ if (x == Mono_Posix_SeekFlags_SEEK_CUR) +#ifdef SEEK_CUR {*r = SEEK_CUR; return 0;} -#endif /* def SEEK_CUR */ -#ifdef SEEK_END +#else /* def SEEK_CUR */ + {errno = EINVAL; return -1;} +#endif /* ndef SEEK_CUR */ if (x == Mono_Posix_SeekFlags_SEEK_END) +#ifdef SEEK_END {*r = SEEK_END; return 0;} -#endif /* def SEEK_END */ -#ifdef SEEK_SET +#else /* def SEEK_END */ + {errno = EINVAL; return -1;} +#endif /* ndef SEEK_END */ if (x == Mono_Posix_SeekFlags_SEEK_SET) +#ifdef SEEK_SET {*r = SEEK_SET; return 0;} -#endif /* def SEEK_SET */ +#else /* def SEEK_SET */ + {errno = EINVAL; return -1;} +#endif /* ndef SEEK_SET */ + if (x == 0) + return 0; errno = EINVAL; return -1; } int Mono_Posix_ToSeekFlags (short x, short *r) { *r = 0; + if (x == 0) + return 0; #ifdef L_INCR if (x == L_INCR) {*r = Mono_Posix_SeekFlags_L_INCR; return 0;} diff --git a/support/mph.h b/support/mph.h index cb5d94131da..141b675c010 100644 --- a/support/mph.h +++ b/support/mph.h @@ -54,11 +54,9 @@ # endif #endif /* !defined(EOVERFLOW) */ -#if !defined (HOST_WIN32) - /* - * Solaris doesn't define these BSD values, and if they're not present then - * map.c:Mono_Posix_FromSeekFlags() breaks badly; see: + * Solaris/Windows don't define these BSD values, and if they're not present + * then map.c:Mono_Posix_FromSeekFlags() breaks badly; see: * http://bugzilla.gnome.org/show_bug.cgi?id=370081 */ @@ -74,6 +72,8 @@ #define L_XTND SEEK_END #endif /* ndef L_XTND */ +#if !defined (HOST_WIN32) + /* * OS X doesn't define MAP_ANONYMOUS, but it does define MAP_ANON. * Alias them to fix: https://bugzilla.xamarin.com/show_bug.cgi?id=3419 diff --git a/support/stdio.c b/support/stdio.c index b7cc689deb5..590ff8cf821 100644 --- a/support/stdio.c +++ b/support/stdio.c @@ -16,23 +16,25 @@ G_BEGIN_DECLS -#ifndef HOST_WIN32 gint32 Mono_Posix_Syscall_L_ctermid (void) { +#ifndef HOST_WIN32 return L_ctermid; +#else + return -1; +#endif } gint32 Mono_Posix_Syscall_L_cuserid (void) { -#if defined(__APPLE__) || defined (__OpenBSD__) +#if defined(__APPLE__) || defined (__OpenBSD__) || defined (HOST_WIN32) return -1; #else return L_cuserid; #endif } -#endif /* ndef HOST_WIN32 */ mph_size_t Mono_Posix_Stdlib_fread (unsigned char *ptr, mph_size_t size, mph_size_t nmemb, void *stream) diff --git a/support/sys-stat.c b/support/sys-stat.c index d71d555b4d1..075563b0cf4 100644 --- a/support/sys-stat.c +++ b/support/sys-stat.c @@ -13,7 +13,9 @@ #include <sys/types.h> #include <sys/stat.h> +#ifdef HAVE_UNISTD_H #include <unistd.h> +#endif #include <fcntl.h> #include <errno.h> @@ -42,8 +44,10 @@ Mono_Posix_FromStat (struct Mono_Posix_Stat *from, void *_to) to->st_gid = from->st_gid; to->st_rdev = from->st_rdev; to->st_size = from->st_size; +#ifndef HOST_WIN32 to->st_blksize = from->st_blksize; to->st_blocks = from->st_blocks; +#endif to->st_atime = from->st_atime_; to->st_mtime = from->st_mtime_; to->st_ctime = from->st_ctime_; @@ -76,8 +80,10 @@ Mono_Posix_ToStat (void *_from, struct Mono_Posix_Stat *to) to->st_gid = from->st_gid; to->st_rdev = from->st_rdev; to->st_size = from->st_size; +#ifndef HOST_WIN32 to->st_blksize = from->st_blksize; to->st_blocks = from->st_blocks; +#endif to->st_atime_ = from->st_atime; to->st_mtime_ = from->st_mtime; to->st_ctime_ = from->st_ctime; @@ -126,6 +132,7 @@ Mono_Posix_Syscall_fstat (int filedes, struct Mono_Posix_Stat *buf) return r; } +#ifndef HOST_WIN32 gint32 Mono_Posix_Syscall_lstat (const char *file_name, struct Mono_Posix_Stat *buf) { @@ -141,6 +148,7 @@ Mono_Posix_Syscall_lstat (const char *file_name, struct Mono_Posix_Stat *buf) r = -1; return r; } +#endif #ifdef HAVE_FSTATAT gint32 @@ -163,6 +171,7 @@ Mono_Posix_Syscall_fstatat (gint32 dirfd, const char *file_name, struct Mono_Pos } #endif +#ifndef HOST_WIN32 gint32 Mono_Posix_Syscall_mknod (const char *pathname, guint32 mode, mph_dev_t dev) { @@ -170,6 +179,7 @@ Mono_Posix_Syscall_mknod (const char *pathname, guint32 mode, mph_dev_t dev) return -1; return mknod (pathname, mode, dev); } +#endif #ifdef HAVE_MKNODAT gint32 @@ -203,6 +213,7 @@ Mono_Posix_Syscall_get_utime_omit () #endif } +#if defined(HAVE_FUTIMENS) || defined(HAVE_UTIMENSAT) static inline struct timespec* copy_utimens (struct timespec* to, struct Mono_Posix_Timespec *from) { @@ -216,6 +227,7 @@ copy_utimens (struct timespec* to, struct Mono_Posix_Timespec *from) return NULL; } +#endif #ifdef HAVE_FUTIMENS gint32 |