Mac OS X and BSD portability fixes. MonoPosixHelper should now cleanly
authorJonathan Pryor <jpryor@novell.com>
Fri, 5 Nov 2004 19:16:52 +0000 (19:16 -0000)
committerJonathan Pryor <jpryor@novell.com>
Fri, 5 Nov 2004 19:16:52 +0000 (19:16 -0000)
compile on Darwin.

svn path=/trunk/mono/; revision=35725

ChangeLog
support/dirent.c
support/fcntl.c
support/grp.c
support/mph.h
support/old-map.c
support/pwd.c
support/sys-mount.c
support/sys-sendfile.c
support/time.c
support/unistd.c

index f55692554c6f2e8658c517e0d82507f52f68807b..751005bc574a368bc40e5a00dc2dc7e6614a5aeb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
        * support/Makefile.am: Add new INCLUDE directives (for glib headers),
          source; bump library version (so we don't clobber previous versions of
          libMonoPosixHelper.so).
-       * support/dirent.c: New file; <dirent.h> wrapper functions
+       * support/dirent.c: New file; <dirent.h> wrapper functions; 
+         BSD portability fixes.
        * support/errno.c: New file; <errno.h> wrapper functions
-       * support/fcntl.c: New file; <fcntl.h> wrapper functions
-       * support/grp.c: New file; <grp.h> wrapper functions
+       * support/fcntl.c: New file; <fcntl.h> wrapper functions;
+         BSD portability fixes.
+       * support/grp.c: New file; <grp.h> wrapper functions;
+         BSD portability fixes.
        * support/map.c: Updated macro mapping functions (more enums mapped, more
          error checking, etc.).
        * support/map.h: Updated macro mapping functions
        * support/old-map.c: Previous map.c implementation, for backward compatibility
+         Remove spurious warning about redefining _GNU_SOURCE.
        * support/old-map.h: Previous map.h implementation, for backward compatibility
-       * support/mph.h: New file; Utility types, macros
-       * support/pwd.c: New file; <pwd.h> wrapper functions
+       * support/mph.h: New file; Utility types, macros;
+         BSD portability fixes.
+       * support/pwd.c: New file; <pwd.h> wrapper functions;
+         BSD portability fixes.
        * support/stdio.c: New file; <stdio.h> wrapper functions
        * support/stdlib.c: New file; <stdlib.h> wrapper functions
        * support/sys-mman.c: New file; <sys/mman.h> wrapper functions
-       * support/sys-mount.c: New file; <sys/mount.h> wrapper functions
-       * support/sys-sendfile.c: New file; <sys/sendfile.h> wrapper functions
+       * support/sys-mount.c: New file; <sys/mount.h> wrapper functions;
+         BSD portability fixes.
+       * support/sys-sendfile.c: New file; <sys/sendfile.h> wrapper functions;
+         BSD portability fixes.
        * support/sys-stat.c: New file; <sys/stat.h> wrapper functions
        * support/sys-wait.c: New file; <sys/wait.h> wrapper functions
-       * support/time.c: New file; <time.h> wrapper functions
-       * support/unistd.c: New file; <unistd.h> wrapper functions
+       * support/time.c: New file; <time.h> wrapper functions;
+         BSD portability fixes.
+       * support/unistd.c: New file; <unistd.h> wrapper functions;
+         BSD portability fixes.
 
 2004-10-31  Zoltan Varga  <vargaz@freemail.hu>
 
index 999a34126a60dcbef63eafe4925507607797b3ee..48c0b0f0e00ed3ad637702eff3452a70146b96b9 100644 (file)
@@ -53,7 +53,11 @@ copy_dirent (
        )
 {
        to->d_ino    = from->d_ino;
+#ifdef MPH_ON_BSD
+       to->d_off    = 0;
+#else
        to->d_off    = from->d_off;
+#endif
        to->d_reclen = from->d_reclen;
        to->d_type   = from->d_type;
        to->d_name   = strdup (from->d_name);
index 4fd8f19f4ecd4cbba4b9efa260ddb73635117523..1631b0ad809704ab48821128831a639252f7ebe9 100644 (file)
@@ -42,13 +42,13 @@ gint32
 Mono_Posix_Syscall_fcntl_arg (gint32 fd, gint32 cmd, gint64 arg)
 {
        long _arg;
-       int _argi;
        gint32 _cmd;
 
        mph_return_if_long_overflow (arg);
 
 #ifdef F_NOTIFY
        if (cmd == F_NOTIFY) {
+               int _argi;
                if (Mono_Posix_FromDirectoryNotifyFlags (arg, &_argi) == -1) {
                        return -1;
                }
@@ -140,6 +140,7 @@ Mono_Posix_Syscall_creat (const char *pathname, guint32 mode)
 #endif
 }
 
+#ifdef HAVE_POSIX_FADVISE
 gint32
 Mono_Posix_Syscall_posix_fadvise (gint32 fd, mph_off_t offset, mph_off_t len, 
        gint32 advice)
@@ -156,7 +157,9 @@ Mono_Posix_Syscall_posix_fadvise (gint32 fd, mph_off_t offset, mph_off_t len,
        return posix_fadvise (fd, (off_t) offset, (off_t) len, advice);
 #endif
 }
+#endif /* ndef HAVE_POSIX_FADVISE */
 
+#ifdef HAVE_POSIX_FALLOCATE
 gint32
 Mono_Posix_Syscall_posix_fallocate (gint32 fd, mph_off_t offset, mph_size_t len)
 {
@@ -169,6 +172,7 @@ Mono_Posix_Syscall_posix_fallocate (gint32 fd, mph_off_t offset, mph_size_t len)
        return posix_fadvise (fd, (off_t) offset, (size_t) len);
 #endif
 }
+#endif /* ndef HAVE_POSIX_FALLOCATE */
 
 G_END_DECLS
 
index ff49aa1bd2a8ccd7fb9c5a9132a7657e7b35a51a..b2051c9019f9707621b670fa6cb24de52484e361 100644 (file)
@@ -7,10 +7,14 @@
  * Copyright (C) 2004 Jonathan Pryor
  */
 
+#include <sys/types.h>
+#include <sys/param.h>
 #include <grp.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
+#include <unistd.h>    /* for setgroups on Mac OS X */
 
 #include "mph.h"
 
@@ -233,6 +237,7 @@ Mono_Posix_Syscall_getgrent (struct Mono_Posix_Syscall__Group *grbuf)
        return 0;
 }
 
+#ifdef HAVE_FGETGRENT
 gint32
 Mono_Posix_Syscall_fgetgrent (FILE *stream, struct Mono_Posix_Syscall__Group *grbuf)
 {
@@ -253,6 +258,7 @@ Mono_Posix_Syscall_fgetgrent (FILE *stream, struct Mono_Posix_Syscall__Group *gr
        }
        return 0;
 }
+#endif /* ndef HAVE_FGETGRENT */
 
 gint32
 Mono_Posix_Syscall_setgroups (mph_size_t size, mph_gid_t *list)
index b7a9b4cfc9a3bd960d166eb7c35031371498d22c..f0c09fbd1c296af49fc11dd3625e3acd3b5b8c95 100644 (file)
 #define MPH_USE_64_API
 #endif
 
+#if __APPLE__ || __BSD__
+#define MPH_ON_BSD
+#endif
+
 typedef    gint64 mph_blkcnt_t;
 typedef    gint64 mph_blksize_t;
 typedef   guint64 mph_dev_t;
index e31392145b15313f1bf0cbd697b49da22cde9585..dee52b7d6b66f25a517511e99a5524fff9c72d87 100644 (file)
@@ -1,6 +1,9 @@
 /* This file was automatically generated by make-map from Mono.Posix.dll */
 
+#ifndef _GNU_SOURCE
 #define _GNU_SOURCE
+#endif
+
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <sys/wait.h>
index 99aabcbabbf0b12109495c13ced65a2d7ff1e080..fc908958905a58c32882676fa636dbd31f5f808c 100644 (file)
@@ -228,6 +228,7 @@ Mono_Posix_Syscall_getpwent (struct Mono_Posix_Syscall__Passwd *pwbuf)
        return 0;
 }
 
+#ifdef HAVE_FGETPWENT
 gint32
 Mono_Posix_Syscall_fgetpwent (FILE *stream, struct Mono_Posix_Syscall__Passwd *pwbuf)
 {
@@ -248,6 +249,7 @@ Mono_Posix_Syscall_fgetpwent (FILE *stream, struct Mono_Posix_Syscall__Passwd *p
        }
        return 0;
 }
+#endif /* ndef FGETPWENT */
 
 G_END_DECLS
 
index 9e5cd2765a47b5e201ee364c79949defb968e1aa..b13933c7f71382d230c307595d6a22774d287a2e 100644 (file)
 #include <sys/mount.h>
 #include <glib/gtypes.h>
 
+#include "mph.h"
 #include "map.h"
 
 G_BEGIN_DECLS
 
 gint32
 Mono_Posix_Syscall_mount (const char *source, const char *target, 
-               const char *filesystemtype, guint64 mountflags, const void *data)
+               const char *filesystemtype, guint64 mountflags, void *data)
 {
        if (Mono_Posix_FromMountFlags (mountflags, &mountflags) == -1)
                return -1;
 
+#ifdef MPH_ON_BSD
+       return mount (filesystemtype, target, mountflags, data);
+#else
        return mount (source, target, filesystemtype, (unsigned long) mountflags, data);
+#endif
+}
+
+gint32
+Mono_Posix_Syscall_umount (const char *source)
+{
+#ifdef MPH_ON_BSD
+       return unmount (source, MNT_FORCE);
+#else
+       return umount (source);
+#endif
+}
+
+gint32
+Mono_Posix_Syscall_umount2 (const char *source, gint32 flags)
+{
+#ifdef MPH_ON_BSD
+       return unmount (source, flags);
+#else
+       return umount2 (source, flags);
+#endif
 }
 
 G_END_DECLS
index 1e8092de82c4886adce8218a5232fc51d918843a..0a6c7f6d59fb9c2b02580adec0fbcc257e05e89d 100644 (file)
@@ -7,13 +7,18 @@
  * Copyright (C) 2004 Jonathan Pryor
  */
 
-#include <sys/sendfile.h>
+#include <sys/types.h>
 #include <errno.h>
 
+#ifdef HAVE_SYS_SENDFILE_H
+#include <sys/sendfile.h>
+#endif /* ndef HAVE_SYS_SENDFILE_H */
+
 #include "mph.h"
 
 G_BEGIN_DECLS
 
+#ifdef HAVE_SENDFILE
 mph_ssize_t
 Mono_Posix_Syscall_sendfile (int out_fd, int in_fd, mph_off_t *offset, mph_size_t count)
 {
@@ -29,6 +34,7 @@ Mono_Posix_Syscall_sendfile (int out_fd, int in_fd, mph_off_t *offset, mph_size_
 
        return r;
 }
+#endif /* ndef HAVE_SENDFILE */
 
 G_END_DECLS
 
index 591933907936f76a18150351a4872811837669c8..71bbae9d0375a4d1e6d1f83640560d4209c56bbb 100644 (file)
@@ -16,6 +16,7 @@
 
 G_BEGIN_DECLS
 
+#ifdef HAVE_STIME
 gint32
 Mono_Posix_Syscall_stime (mph_time_t *t)
 {
@@ -28,6 +29,7 @@ Mono_Posix_Syscall_stime (mph_time_t *t)
        _t = (time_t) *t;
        return stime (&_t);
 }
+#endif /* ndef HAVE_STIME */
 
 mph_time_t
 Mono_Posix_Syscall_time (mph_time_t *t)
index 51bc7608f09704dfe53a624b937031f417575179..42e02ecc5cc3ddae8296170146e1cae8d8237459 100644 (file)
@@ -17,6 +17,7 @@
 #include <fcntl.h>
 #include <errno.h>
 #include <limits.h>
+#include <string.h>     /* for swab(3) on Mac OS X */
 
 #include <glib/gtypes.h>
 
@@ -136,12 +137,14 @@ Mono_Posix_Syscall_confstr (int name, char *buf, mph_size_t len)
        return confstr (name, buf, (size_t) len);
 }
 
+#ifdef HAVE_TTYNAME_R
 gint32
 Mono_Posix_Syscall_ttyname_r (int fd, char *buf, mph_size_t len)
 {
        mph_return_if_size_t_overflow (len);
        return ttyname_r (fd, buf, (size_t) len);
 }
+#endif /* ndef HAVE_TTYNAME_R */
 
 gint32
 Mono_Posix_Syscall_readlink (const char *path, char *buf, mph_size_t len)
@@ -181,7 +184,12 @@ gint32
 Mono_Posix_Syscall_sethostid (gint64 hostid)
 {
        mph_return_if_long_overflow (hostid);
+#ifdef MPH_ON_BSD
+       sethostid ((long) hostid);
+       return 0;
+#else
        return sethostid ((long) hostid);
+#endif
 }
 
 gint32