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
Index: configure.in
===================================================================
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)
 
        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="$CPPFLAGS -D_XOPEN_SOURCE=500"
+                               CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
+                               CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE_EXTENDED=1"
+                               LIBS="$LIBS -lxnet"
+                               AC_MSG_RESULT(yes)
+                       else
+                               AC_MSG_RESULT(no)
+                       fi
+
+                       if test "$GCC" = "yes"; then
+                               CFLAGS="$CFLAGS -Wno-char-subscripts"
+                       fi
+               ;;
+       esac
+
+       dnl *****************************
        dnl *** Checks for libpthread ***
        dnl *****************************
        AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
Index: mono/arch/sparc/tramp.c
===================================================================
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);
         }
 
-       return NULL;
+       return 0xdeadbeef;
 }
 
 MonoMethod*
Index: mono/io-layer/atomic.h
===================================================================
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 @@
        
        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" \
+                             : "=&r" (tmp) \
+                             : "r" (&lock) \
+                             : "memory"); 
+
+#define END_SPIN(lock) \
+__asm__ __volatile__("stb      %%g0, [%0]"  \
+                      : /* no outputs */ \
+                      : "r" (&lock)\
+                      : "memory");
+
+
+static inline gint32 InterlockedCompareExchange(volatile gint32 *dest, gint32 exch, 
+gint32 comp)
+{
+       static unsigned char lock;
+       int tmp;
+       gint32 old;
+
+       BEGIN_SPIN(tmp,lock)
+
+       old = *dest;
+       if (old==comp) {
+               *dest=exch;
+       }
+
+       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 = *dest;
+        if (old==comp) {
+                *dest=exch;
+        }
+
+        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 = *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 = *dest;
+
+        END_SPIN(lock)
+
+        return(ret);
+}
+
+static inline gint32 InterlockedExchange(volatile gint32 *dest, gint32 exch)
+{
+        static unsigned char lock;
+        int tmp;
+        gint32 ret;
+
+        BEGIN_SPIN(tmp,lock)
+
+        ret = *dest;
+        *dest = 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 = *dest;
+        *dest = 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 = *dest;
+        *dest += add;
+
+        END_SPIN(lock)
+
+        return(ret);
+}
+
 #else
+
 extern gint32 InterlockedCompareExchange(volatile gint32 *dest, gint32 exch, gint32 
comp);
 extern gpointer InterlockedCompareExchangePointer(volatile gpointer *dest, gpointer 
exch, gpointer comp);
 extern gint32 InterlockedIncrement(volatile gint32 *dest);
Index: mono/io-layer/daemon.c
===================================================================
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 @@
 
 #undef DEBUG
 
+/* 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=0;
 /* Array to keep track of handles that have been referenced by the
Index: mono/io-layer/handles-private.h
===================================================================
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 @@
 
 #undef DEBUG
 
+/* 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;
 
Index: mono/io-layer/handles.c
===================================================================
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 @@
 
 #undef DEBUG
 
+/* 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
===================================================================
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>
 
+/* 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
===================================================================
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 = handle >> 2;
+
+#ifdef HAVE_BOHEM_GC
        if ((handle & 0x3) > 1)
                GC_unregister_disappearing_link (&(gc_handles [idx]));
+#else
+       g_error ("No GCHandle support");
+#endif
 
        gc_handles [idx] = (gpointer)-1;
 }
Index: mono/metadata/socket-io.c
===================================================================
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
+
 
 #undef DEBUG
 

Attachment: msg03029/pgp00000.pgp
Description: PGP signature

Reply via email to