[Mono-list] Solaris 9 patches

Mark Crichton crichton@gimp.org
Thu, 19 Sep 2002 08:44:43 -0400


--v9Ux+11Zm5mwPlX6
Content-Type: multipart/mixed; boundary="a8Wt8u1KmwUX3Y2C"
Content-Disposition: inline


--a8Wt8u1KmwUX3Y2C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hello,

In an effort to further the SPARC port of mono, I've had to slap around
mono a bit to get it to compile on Solaris.

Attached is a patch.  Note that the biggest problem right now is
_POSIX_THREAD_PROCESS_SHARED.  It is actually defined and implemented
on Solaris, but that code path seems borked (it just hangs, and truss
claims a thread is sleeping...), so I've commented it out for now.

If anyone has a Solaris version OTHER than 9, I'd like to hear about
it.  Also, I've test compiled with gcc 3.2, so if people who have a
commercial Sun compiler also look over the code, I'd appreciate it (or
someone donate me a license/CD for SUNs comercial compiler).

Last thing to do on the io-layer is to fix the linuxisms in the daemon.
Of course, BSD will need the same work as well...

Mark

--a8Wt8u1KmwUX3Y2C
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="sol9.diff"
Content-Transfer-Encoding: quoted-printable

Index: configure.in
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/configure.in,v
retrieving revision 1.101
diff -u -r1.101 configure.in
--- configure.in	9 Sep 2002 15:39:28 -0000	1.101
+++ configure.in	19 Sep 2002 04:27:58 -0000
@@ -311,6 +311,28 @@
 	AC_DEFINE_UNQUOTED(MONO_SIZEOF_SUNPATH, $cv_mono_sizeof_sunpath)
=20
 	dnl *****************************
+	dnl *** Checks for libxnet    ***
+	dnl *****************************
+	case "${host}" in
+		*solaris* )
+			AC_MSG_CHECKING(for Solaris XPG4 support)
+			if test -f /usr/lib/libxnet.so; then
+				CPPFLAGS=3D"$CPPFLAGS -D_XOPEN_SOURCE=3D500"
+	    			CPPFLAGS=3D"$CPPFLAGS -D__EXTENSIONS__"
+				CPPFLAGS=3D"$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=3D1"
+           			LIBS=3D"$LIBS -lxnet"
+  	    			AC_MSG_RESULT(yes)
+			else
+  	    			AC_MSG_RESULT(no)
+			fi
+
+			if test "$GCC" =3D "yes"; then
+		    		CFLAGS=3D"$CFLAGS -Wno-char-subscripts"
+			fi
+    		;;
+	esac
+
+	dnl *****************************
 	dnl *** Checks for libpthread ***
 	dnl *****************************
 	AC_CHECK_LIB(pthread, main, LIBS=3D"$LIBS -lpthread")
Index: mono/arch/sparc/tramp.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/arch/sparc/tramp.c,v
retrieving revision 1.4
diff -u -r1.4 tramp.c
--- mono/arch/sparc/tramp.c	20 Aug 2002 15:03:07 -0000	1.4
+++ mono/arch/sparc/tramp.c	19 Sep 2002 04:27:58 -0000
@@ -510,7 +510,7 @@
 		fflush (stderr);
         }
=20
-	return NULL;
+	return 0xdeadbeef;
 }
=20
 MonoMethod*
Index: mono/io-layer/atomic.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/io-layer/atomic.h,v
retrieving revision 1.6
diff -u -r1.6 atomic.h
--- mono/io-layer/atomic.h	12 Aug 2002 13:46:57 -0000	1.6
+++ mono/io-layer/atomic.h	19 Sep 2002 04:27:58 -0000
@@ -107,7 +107,144 @@
 =09
 	return(ret);
 }
+
+#elif defined(sparc)
+#define WAPI_ATOMIC_ASM
+
+#define BEGIN_SPIN(tmp,lock) \
+__asm__ __volatile__("1:        ldstub [%1],%0\n\t"  \
+                             "          cmp %0, 0\n\t" \
+                             "          bne 1b\n\t" \
+                             "          nop" \
+                             : "=3D&r" (tmp) \
+                             : "r" (&lock) \
+                             : "memory");=20
+
+#define END_SPIN(lock) \
+__asm__ __volatile__("stb	%%g0, [%0]"  \
+                      : /* no outputs */ \
+                      : "r" (&lock)\
+                      : "memory");
+
+
+static inline gint32 InterlockedCompareExchange(volatile gint32 *dest, gin=
t32 exch, gint32 comp)
+{
+	static unsigned char lock;
+	int tmp;
+	gint32 old;
+
+	BEGIN_SPIN(tmp,lock)
+
+	old =3D *dest;
+	if (old=3D=3Dcomp) {
+		*dest=3Dexch;
+	}
+
+	END_SPIN(lock)
+
+	return(old);
+}
+
+static inline gpointer InterlockedCompareExchangePointer(volatile gpointer=
 *dest, gpointer exch, gpointer comp)
+{
+        static unsigned char lock;
+        int tmp;
+        gpointer old;
+
+        BEGIN_SPIN(tmp,lock)
+
+        old =3D *dest;
+        if (old=3D=3Dcomp) {
+                *dest=3Dexch;
+        }
+
+        END_SPIN(lock)
+
+        return(old);
+}
+
+static inline gint32 InterlockedIncrement(volatile gint32 *dest)
+{
+        static unsigned char lock;
+        int tmp;
+        gint32 ret;
+
+        BEGIN_SPIN(tmp,lock)
+
+        *dest++;
+        ret =3D *dest;
+
+        END_SPIN(lock)
+
+        return(ret);
+}
+
+static inline gint32 InterlockedDecrement(volatile gint32 *dest)
+{
+        static unsigned char lock;
+        int tmp;
+        gint32 ret;
+
+        BEGIN_SPIN(tmp,lock)
+
+	*dest--;
+        ret =3D *dest;
+
+        END_SPIN(lock)
+
+        return(ret);
+}
+
+static inline gint32 InterlockedExchange(volatile gint32 *dest, gint32 exc=
h)
+{
+        static unsigned char lock;
+        int tmp;
+        gint32 ret;
+
+        BEGIN_SPIN(tmp,lock)
+
+        ret =3D *dest;
+        *dest =3D exch;
+
+        END_SPIN(lock)
+
+        return(ret);
+}
+
+static inline gpointer InterlockedExchangePointer(volatile gpointer *dest,=
 gpointer exch)
+{
+        static unsigned char lock;
+        int tmp;
+        gpointer ret;
+
+        BEGIN_SPIN(tmp,lock)
+
+        ret =3D *dest;
+        *dest =3D exch;
+
+        END_SPIN(lock)
+
+        return(ret);
+}
+
+static inline gint32 InterlockedExchangeAdd(volatile gint32 *dest, gint32 =
add)
+{
+        static unsigned char lock;
+        int tmp;
+        gint32 ret;
+
+        BEGIN_SPIN(tmp,lock)
+
+        ret =3D *dest;
+        *dest +=3D add;
+
+        END_SPIN(lock)
+
+        return(ret);
+}
+
 #else
+
 extern gint32 InterlockedCompareExchange(volatile gint32 *dest, gint32 exc=
h, gint32 comp);
 extern gpointer InterlockedCompareExchangePointer(volatile gpointer *dest,=
 gpointer exch, gpointer comp);
 extern gint32 InterlockedIncrement(volatile gint32 *dest);
Index: mono/io-layer/daemon.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/io-layer/daemon.c,v
retrieving revision 1.15
diff -u -r1.15 daemon.c
--- mono/io-layer/daemon.c	19 Aug 2002 19:49:38 -0000	1.15
+++ mono/io-layer/daemon.c	19 Sep 2002 04:27:59 -0000
@@ -30,6 +30,9 @@
=20
 #undef DEBUG
=20
+/* The shared thread codepath doesn't seem to work yet... */
+#undef _POSIX_THREAD_PROCESS_SHARED
+
 /* Keep track of the number of clients */
 static int nfds=3D0;
 /* Array to keep track of handles that have been referenced by the
Index: mono/io-layer/handles-private.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/io-layer/handles-private.h,v
retrieving revision 1.7
diff -u -r1.7 handles-private.h
--- mono/io-layer/handles-private.h	25 Jun 2002 12:39:19 -0000	1.7
+++ mono/io-layer/handles-private.h	19 Sep 2002 04:27:59 -0000
@@ -18,6 +18,9 @@
=20
 #undef DEBUG
=20
+/* Shared threads dont seem to work yet */
+#undef _POSIX_THREAD_PROCESS_SHARED
+
 extern struct _WapiHandleShared_list *_wapi_shared_data;
 extern struct _WapiHandlePrivate_list *_wapi_private_data;
=20
Index: mono/io-layer/handles.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/io-layer/handles.c,v
retrieving revision 1.22
diff -u -r1.22 handles.c
--- mono/io-layer/handles.c	1 Sep 2002 20:47:54 -0000	1.22
+++ mono/io-layer/handles.c	19 Sep 2002 04:28:00 -0000
@@ -28,6 +28,9 @@
=20
 #undef DEBUG
=20
+/* Shared threads don't seem to work yet */
+#undef _POSIX_THREAD_PROCESS_SHARED
+
 /*
  * This flag _MUST_ remain set to FALSE in the daemon process.  When
  * we exec()d a standalone daemon, that happened because shared_init()
Index: mono/io-layer/wapi-private.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/io-layer/wapi-private.h,v
retrieving revision 1.16
diff -u -r1.16 wapi-private.h
--- mono/io-layer/wapi-private.h	20 Jul 2002 10:19:39 -0000	1.16
+++ mono/io-layer/wapi-private.h	19 Sep 2002 04:28:00 -0000
@@ -17,6 +17,9 @@
 #include <mono/io-layer/io.h>
 #include <mono/io-layer/daemon-private.h>
=20
+/* Shared threads don't seem to work yet */
+#undef _POSIX_THREAD_PROCESS_SHARED
+
 /* Increment this whenever an incompatible change is made to the
  * shared handle structure.
  *
Index: mono/metadata/gc.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/metadata/gc.c,v
retrieving revision 1.15
diff -u -r1.15 gc.c
--- mono/metadata/gc.c	14 Sep 2002 00:06:40 -0000	1.15
+++ mono/metadata/gc.c	19 Sep 2002 04:28:01 -0000
@@ -304,8 +304,13 @@
 ves_icall_System_GCHandle_FreeHandle (guint32 handle)
 {
 	int idx =3D handle >> 2;
+
+#ifdef HAVE_BOHEM_GC
 	if ((handle & 0x3) > 1)
 		GC_unregister_disappearing_link (&(gc_handles [idx]));
+#else
+	g_error ("No GCHandle support");
+#endif
=20
 	gc_handles [idx] =3D (gpointer)-1;
 }
Index: mono/metadata/socket-io.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvs/public/mono/mono/metadata/socket-io.c,v
retrieving revision 1.18
diff -u -r1.18 socket-io.c
--- mono/metadata/socket-io.c	22 Aug 2002 08:49:27 -0000	1.18
+++ mono/metadata/socket-io.c	19 Sep 2002 04:28:02 -0000
@@ -24,6 +24,13 @@
 #ifdef HAVE_NETDB_H
 #include <netdb.h>
 #endif
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>     /* defines FIONBIO and FIONREAD */
+#endif
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>    /* defines SIOCATMARK */
+#endif
+
=20
 #undef DEBUG
=20

--a8Wt8u1KmwUX3Y2C--

--v9Ux+11Zm5mwPlX6
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (SunOS)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj2JxroACgkQOfj2Ja/u/oATawCfbptYnZBM9qdqTl1KDWuGt/ih
Eu4AoIg/FnEHcu4WVxt0pkS1MqYxzJ6M
=RT4T
-----END PGP SIGNATURE-----

--v9Ux+11Zm5mwPlX6--