[Mono-list] FreeBSD port patches

Sandro Tolaini sandro@focuseek.com
18 Apr 2002 15:27:22 +0300


--=-+ItXjNG5aWCr0wxXRYhF
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

On Thu, 2002-04-18 at 09:29, Miguel de Icaza wrote:

> Very nice!  You might want to look into compiling and running the
> compiler test suite and the mono engine test suite (mcs/tests and
> mono/mono/tests). 

I'll do that ASAP...

> Yeah, we expected something like that would be needed.  Could you post
> the diff, so we can discuss how to best split the code?

Patches attached. I've also attached the configure line I had to use
(looks like pthread support in autoconf has to be reworked, sorry I'm
not an autoconf guru).

> Sounds like a problem in the port.  That can mean all sorts of things,
> it is just the behavior when something is going badly on the binding to
> the OS. 

Maybe that the test suite can pinpoint us to the bug location.

Cheers,
  Sandro Tolaini.

--=-+ItXjNG5aWCr0wxXRYhF
Content-Disposition: attachment; filename=mono-freebsd.configure
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=ISO-8859-1

env CPPFLAGS=3D"-pthread -I/usr/local/include" LDFLAGS=3D"-pthread -L/usr/l=
ocal/lib" ./configure

--=-+ItXjNG5aWCr0wxXRYhF
Content-Disposition: attachment; filename=mono-freebsd.diff
Content-Transfer-Encoding: quoted-printable
Content-Type: text/x-patch; charset=ISO-8859-1

diff -r --unified mono-0.10.orig/mono/io-layer/io.c mono-0.10/mono/io-layer=
/io.c
--- mono-0.10.orig/mono/io-layer/io.c	Wed Mar 27 06:05:39 2002
+++ mono-0.10/mono/io-layer/io.c	Sat Apr 13 10:42:10 2002
@@ -1635,9 +1635,11 @@
 		g_free (handle);
=20
 		switch (result) {
+#ifdef GLOB_NOMATCH
 		case GLOB_NOMATCH:
 			SetLastError (ERROR_NO_MORE_FILES);
 			break;
+#endif
=20
 		default:
 #ifdef DEBUG
diff -r --unified mono-0.10.orig/mono/io-layer/sockets.c mono-0.10/mono/io-=
layer/sockets.c
--- mono-0.10.orig/mono/io-layer/sockets.c	Tue Mar 19 20:08:12 2002
+++ mono-0.10/mono/io-layer/sockets.c	Sat Apr 13 10:42:23 2002
@@ -233,7 +233,9 @@
 		case EINVAL:
 			WSASetLastError(WSAEINVAL);
 			break;
+#ifdef ENOSR
 		case ENOSR:
+#endif
 		case ECONNABORTED:
 		case ESOCKTNOSUPPORT:
 		case EPROTONOSUPPORT:
diff -r --unified mono-0.10.orig/mono/io-layer/unicode.c mono-0.10/mono/io-=
layer/unicode.c
--- mono-0.10.orig/mono/io-layer/unicode.c	Wed Mar 27 06:05:39 2002
+++ mono-0.10/mono/io-layer/unicode.c	Sat Apr 13 10:42:45 2002
@@ -1,7 +1,7 @@
 #include <config.h>
 #include <glib.h>
 #include <pthread.h>
-#include <iconv.h>
+#include <giconv.h>
 #include <errno.h>
=20
 #include "mono/io-layer/wapi.h"
diff -r --unified mono-0.10.orig/mono/jit/exception.c mono-0.10/mono/jit/ex=
ception.c
--- mono-0.10.orig/mono/jit/exception.c	Thu Mar 21 23:02:16 2002
+++ mono-0.10/mono/jit/exception.c	Sat Apr 13 10:49:11 2002
@@ -40,19 +40,19 @@
 	x86_mov_reg_membase (code, X86_EAX, X86_ESP, 4, 4);
=20
 	/* get return address, stored in EDX */
-	x86_mov_reg_membase (code, X86_EDX, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, eip), 4);
+	x86_mov_reg_membase (code, X86_EDX, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, sc_eip), 4);
 	/* restore EBX */
-	x86_mov_reg_membase (code, X86_EBX, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, ebx), 4);
+	x86_mov_reg_membase (code, X86_EBX, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, sc_ebx), 4);
 	/* restore EDI */
-	x86_mov_reg_membase (code, X86_EDI, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, edi), 4);
+	x86_mov_reg_membase (code, X86_EDI, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, sc_edi), 4);
 	/* restore ESI */
-	x86_mov_reg_membase (code, X86_ESI, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, esi), 4);
+	x86_mov_reg_membase (code, X86_ESI, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, sc_esi), 4);
 	/* restore ESP */
-	x86_mov_reg_membase (code, X86_ESP, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, esp), 4);
+	x86_mov_reg_membase (code, X86_ESP, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, sc_esp), 4);
 	/* restore EBP */
-	x86_mov_reg_membase (code, X86_EBP, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, ebp), 4);
+	x86_mov_reg_membase (code, X86_EBP, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, sc_ebp), 4);
 	/* restore ECX. the exception object is passed here to the catch handler =
*/
-	x86_mov_reg_membase (code, X86_ECX, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, ecx), 4);
+	x86_mov_reg_membase (code, X86_ECX, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, sc_ecx), 4);
=20
 	/* jump to the saved IP */
 	x86_jump_reg (code, X86_EDX);
@@ -92,7 +92,7 @@
 	/* save EBP */
 	x86_push_reg (code, X86_EBP);
 	/* set new EBP */
-	x86_mov_reg_membase (code, X86_EBP, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, ebp), 4);
+	x86_mov_reg_membase (code, X86_EBP, X86_EAX,  G_STRUCT_OFFSET (struct sig=
context, sc_ebp), 4);
 	/* call the handler */
 	x86_call_reg (code, X86_ECX);
 	/* restore EBP */
@@ -119,7 +119,7 @@
 {
 	MonoDomain *domain =3D mono_domain_get ();
 	MonoJitInfo *ji;
-	gpointer ip =3D (gpointer)ctx->eip;
+	gpointer ip =3D (gpointer)ctx->sc_eip;
 	static void (*restore_context) (struct sigcontext *);
 	static void (*call_finally) (struct sigcontext *, unsigned long);
 	void (*cleanup) (MonoObject *exc);
@@ -155,8 +155,8 @@
 					if (ei->flags =3D=3D 0 && mono_object_isinst (obj,=20
 					        mono_class_get (m->klass->image, ei->token_or_filter))) {
 				=09
-						ctx->eip =3D (unsigned long)ei->handler_start;
-						ctx->ecx =3D (unsigned long)obj;
+						ctx->sc_eip =3D (unsigned long)ei->handler_start;
+						ctx->sc_ecx =3D (unsigned long)obj;
 						restore_context (ctx);
 						g_assert_not_reached ();
 					}
@@ -196,22 +196,22 @@
=20
 		/* restore caller saved registers */
 		if (ji->used_regs & X86_ESI_MASK) {
-			ctx->esi =3D *((int *)ctx->ebp + offset);
+			ctx->sc_esi =3D *((int *)ctx->sc_ebp + offset);
 			offset++;
 		}
 		if (ji->used_regs & X86_EDI_MASK) {
-			ctx->edi =3D *((int *)ctx->ebp + offset);
+			ctx->sc_edi =3D *((int *)ctx->sc_ebp + offset);
 			offset++;
 		}
 		if (ji->used_regs & X86_EBX_MASK) {
-			ctx->ebx =3D *((int *)ctx->ebp + offset);
+			ctx->sc_ebx =3D *((int *)ctx->sc_ebp + offset);
 		}
=20
-		ctx->esp =3D ctx->ebp;
-		ctx->eip =3D *((int *)ctx->ebp + 1);
-		ctx->ebp =3D *((int *)ctx->ebp);
+		ctx->sc_esp =3D ctx->sc_ebp;
+		ctx->sc_eip =3D *((int *)ctx->sc_ebp + 1);
+		ctx->sc_ebp =3D *((int *)ctx->sc_ebp);
 	=09
-		if (ctx->ebp < (unsigned)mono_end_of_stack)
+		if (ctx->sc_ebp < (unsigned)mono_end_of_stack)
 			arch_handle_exception (ctx, obj);
 		else
 			cleanup (obj);
@@ -231,12 +231,12 @@
=20
 		*lmf_addr =3D lmf->previous_lmf;
=20
-		ctx->esi =3D lmf->esi;
-		ctx->edi =3D lmf->edi;
-		ctx->ebx =3D lmf->ebx;
-		ctx->ebp =3D lmf->ebp;
-		ctx->eip =3D lmf->eip;
-		ctx->esp =3D (unsigned long)&lmf->eip;
+		ctx->sc_esi =3D lmf->esi;
+		ctx->sc_edi =3D lmf->edi;
+		ctx->sc_ebx =3D lmf->ebx;
+		ctx->sc_ebp =3D lmf->ebp;
+		ctx->sc_eip =3D lmf->eip;
+		ctx->sc_esp =3D (unsigned long)&lmf->eip;
=20
 		if (mono_object_isinst (obj, mono_defaults.exception_class)) {
 			char  *strace =3D mono_string_to_utf8 (((MonoException*)obj)->stack_tra=
ce);
@@ -254,7 +254,7 @@
 			g_free (tmp);
 		}
=20
-		if (ctx->eip < (unsigned)mono_end_of_stack)
+		if (ctx->sc_eip < (unsigned)mono_end_of_stack)
 			arch_handle_exception (ctx, obj);
 		else=20
 			cleanup (obj);
@@ -270,15 +270,15 @@
 {
 	struct sigcontext ctx;
=20
-	ctx.esp =3D esp;
-	ctx.eip =3D eip;
-	ctx.ebp =3D ebp;
-	ctx.edi =3D edi;
-	ctx.esi =3D esi;
-	ctx.ebx =3D ebx;
-	ctx.edx =3D edx;
-	ctx.ecx =3D ecx;
-	ctx.eax =3D eax;
+	ctx.sc_esp =3D esp;
+	ctx.sc_eip =3D eip;
+	ctx.sc_ebp =3D ebp;
+	ctx.sc_edi =3D edi;
+	ctx.sc_esi =3D esi;
+	ctx.sc_ebx =3D ebx;
+	ctx.sc_edx =3D edx;
+	ctx.sc_ecx =3D ecx;
+	ctx.sc_eax =3D eax;
 =09
 	arch_handle_exception (&ctx, exc);
=20
diff -r --unified mono-0.10.orig/mono/metadata/debug-symfile.c mono-0.10/mo=
no/metadata/debug-symfile.c
--- mono-0.10.orig/mono/metadata/debug-symfile.c	Wed Mar 27 00:10:11 2002
+++ mono-0.10/mono/metadata/debug-symfile.c	Sat Apr 13 10:44:13 2002
@@ -128,6 +128,9 @@
 get_sections (MonoDebugSymbolFile *symfile, gboolean emit_warnings)
 {
 #ifdef HAVE_ELF_H
+#ifdef __FreeBSD__
+	static const char ELFMAG[] =3D { ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3, 0 };
+#endif
 	if (!strncmp (symfile->raw_contents, ELFMAG, strlen (ELFMAG)))
 		return get_sections_elf32 (symfile, emit_warnings);
 #endif
diff -r --unified mono-0.10.orig/mono/metadata/icall.c mono-0.10/mono/metad=
ata/icall.c
--- mono-0.10.orig/mono/metadata/icall.c	Wed Mar 27 06:05:39 2002
+++ mono-0.10/mono/metadata/icall.c	Sat Apr 13 10:43:27 2002
@@ -36,6 +36,9 @@
 #include <mono/io-layer/io-layer.h>
 #include "decimal.h"
=20
+#ifdef __FreeBSD__
+extern char **environ;
+#endif
=20
 static MonoObject *
 ves_icall_System_Array_GetValueImpl (MonoObject *this, guint32 pos)
diff -r --unified mono-0.10.orig/mono/metadata/unicode.c mono-0.10/mono/met=
adata/unicode.c
--- mono-0.10.orig/mono/metadata/unicode.c	Sun Mar 24 22:11:31 2002
+++ mono-0.10/mono/metadata/unicode.c	Sat Apr 13 10:43:42 2002
@@ -14,7 +14,7 @@
 #include <mono/metadata/object.h>
 #include <mono/metadata/unicode.h>
=20
-#include <iconv.h>
+#include <giconv.h>
=20
 static MonoUnicodeCategory catmap[] =3D {
 	/* G_UNICODE_CONTROL =3D */              Control,

--=-+ItXjNG5aWCr0wxXRYhF--