[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: someone could port libgc



1)    Please find attached a file to patch libgc.

Requirements:

Minimum Hurd development system
patch
Source:
libgc4_4.12-4.13alpha1-2.dsc
libgc4_4.12-4.13alpha1.orig.tar.gz
libgc4_4.12-4.13alpha1-2.diff.gz

This will generate a directory called libgc4-4.12-4.13alpha1;  within this do patch
<libgc.patch.

dpkg-buildpackage will now make (under Hurd or Linux) the packages:
libgc4_4.12-4.13alpha1-2_hurd-i386.deb
libgc4_4.12-4.13alpha1-2_i386.deb

You may type 'make test' to see some output.

2)    My main worry about this package is that you need to set DATASTART, DATAEND and
STACKBOTTOM, (cold end of stack).  For the first time I looked at Hurd source and put:

#       define STACKBOTTOM ((ptr_t)0xc0000000)
#       define ALIGNMENT  4
        extern int  __datastart;
#       define DATASTART ((ptr_t) (&__datastart))
        extern int  _end;
#       define DATAEND   ((ptr_t) (&_end))

I thought 0xc0000000, or 0xc0000000 - 16 * 1024 * 1024 would be right as it corresponds
with defines in the Hurd, and looked similar to Linux.  The built library generated bus
errors.  By now I had enough code in to run the test program;  this recomended the
following settings:

#       define STACKBOTTOM ((ptr_t)0x101a000)
#       define ALIGNMENT  4
        extern int  _etext;
#       define DATASTART ((ptr_t) (&_etext))
        extern int  _end;
#       define DATAEND   ((ptr_t) (&_end))

This works; but I do not understand that 0x101a000 setting.

3) Comments

There is no configure script and no need for auto* jobs.  The build runs directly from the
Makefile.  You may want to change the CFLAGS in the Makefile, (this is well documented
within the Makefile.)  You can remove the -DSILENT flag to give verbose output; or you may
want to add -DFIND_LEAK.  Please note that the test program does not work with FIND_LEAK
set.  The test program within the build (cpp_test) has been modified not to run when
TEST_LEAK is set;  this allows the build to finish.

The Debian rules do not recognise the Hurd, so it does a native build.

4)    Testing

I do not know anything about this library so testing is minimal.  I have a memory tester
program,  I have compiled this, after installing deb package.  It produces the same results
under the Hurd or Linux.

5)    Upstream source

I wrote to the package maintainer offering the patch, but have received no reply.

Chris

diff -Naur libgc4-4.12-4.13alpha1/Makefile libgc4-4.12-4.13alpha1.hurd/Makefile
--- libgc4-4.12-4.13alpha1/Makefile	Fri Jan 21 17:04:57 2000
+++ libgc4-4.12-4.13alpha1.hurd/Makefile	Fri Jan 21 15:14:08 2000
@@ -16,7 +16,8 @@
 #  Under Irix 6, you will have to specify the ABI for as if you specify
 #  it for the C compiler.
 
-CFLAGS := ${DEBIAN_CFLAGS} -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION -DSILENT
+CFLAGS := ${DEBIAN_CFLAGS} -DNO_SIGNALS -DALL_INTERIOR_POINTERS -DNO_EXECUTE_PERMISSION  -DOPERATOR_NEW_ARRAY \
+-DSILENT
 
 # Setjmp_test may yield overly optimistic results when compiled
 # without optimization.
diff -Naur libgc4-4.12-4.13alpha1/config.h libgc4-4.12-4.13alpha1.hurd/config.h
--- libgc4-4.12-4.13alpha1/config.h	Tue Feb 17 06:14:18 1998
+++ libgc4-4.12-4.13alpha1.hurd/config.h	Fri Jan 21 14:58:42 2000
@@ -230,6 +230,12 @@
 #   define mach_type_known
 # endif
 
+#if  defined(__GNU__)
+#    define  HURD
+#    define  I386
+#    define  mach_type_known
+#endif
+
 /* Feel free to add more clauses here */
 
 /* Or manually define the machine type here.  A machine type is 	*/
@@ -570,6 +576,16 @@
 				 +((word)&etext & 0xfff))
 #	define STACKBOTTOM ((ptr_t) 0x7ffffffc)
 #   endif
+#   ifdef HURD
+#       define OS_TYPE "HURD"
+#       define STACKBOTTOM ((ptr_t)0x101a000)
+#       define ALIGNMENT  4
+        extern int  _etext;
+#       define DATASTART ((ptr_t) (&_etext))
+        extern int  _end;
+#       define DATAEND   ((ptr_t) (&_end))
+#   endif
+ 
 #   ifdef LINUX
 #	define OS_TYPE "LINUX"
 #	define STACKBOTTOM ((ptr_t)0xc0000000)
diff -Naur libgc4-4.12-4.13alpha1/mach_dep.c libgc4-4.12-4.13alpha1.hurd/mach_dep.c
--- libgc4-4.12-4.13alpha1/mach_dep.c	Thu Aug 21 00:11:03 1997
+++ libgc4-4.12-4.13alpha1.hurd/mach_dep.c	Mon Jan 17 20:52:44 2000
@@ -170,7 +170,7 @@
 
 #       if defined(I386) &&!defined(OS2) &&!defined(SVR4) &&!defined(MSWIN32) \
 	&& !defined(SCO) && !(defined(LINUX) && defined(__ELF__)) \
-	&& !defined(DOS4GW)
+	&& !defined(DOS4GW) && !defined(HURD)
 	/* I386 code, generic code does not appear to work */
 	/* It does appear to work under OS2, and asms dont */
 	/* This is used for some 38g UNIX variants and for CYGWIN32 */
@@ -194,6 +194,19 @@
 	  asm("pushl %ebx");  asm("call GC_push_one"); asm("addl $4,%esp");
 #	endif
 
+#	if defined(HURD)
+          /* This is modified for Linux with ELF (Note: _ELF_ only) */
+	  /* Copied for Hurd,  many thanks  */
+	  asm("pushl %eax");  asm("call GC_push_one"); asm("addl $4,%esp");
+	  asm("pushl %ecx");  asm("call GC_push_one"); asm("addl $4,%esp");
+	  asm("pushl %edx");  asm("call GC_push_one"); asm("addl $4,%esp");
+	  asm("pushl %ebp");  asm("call GC_push_one"); asm("addl $4,%esp");
+	  asm("pushl %esi");  asm("call GC_push_one"); asm("addl $4,%esp");
+	  asm("pushl %edi");  asm("call GC_push_one"); asm("addl $4,%esp");
+	  asm("pushl %ebx");  asm("call GC_push_one"); asm("addl $4,%esp");
+#	endif
+
+
 #       if defined(I386) && defined(MSWIN32) && !defined(USE_GENERIC)
 	/* I386 code, Microsoft variant		*/
 	  __asm  push eax
@@ -332,7 +345,7 @@
 #       if !(defined M68K) && !(defined VAX) && !(defined RT) 
 #	if !(defined SPARC) && !(defined I386) && !(defined NS32K)
 #	if !defined(HP_PA) && !defined(M88K) && !defined(POWERPC)
-#	if !defined(UTS4)
+#	if !defined(UTS4)  &&  !defined(HURD)
 	    --> bad news <--
 # 	endif
 #       endif
diff -Naur libgc4-4.12-4.13alpha1/os_dep.c libgc4-4.12-4.13alpha1.hurd/os_dep.c
--- libgc4-4.12-4.13alpha1/os_dep.c	Tue Feb 17 06:01:21 1998
+++ libgc4-4.12-4.13alpha1.hurd/os_dep.c	Fri Jan 21 17:03:08 2000
@@ -72,6 +72,10 @@
 #   define NEED_FIND_LIMIT
 # endif
 
+# if defined(HURD)
+#   define NEED_FIND_LIMIT
+# endif
+
 #ifdef NEED_FIND_LIMIT
 #   include <setjmp.h>
 #endif
@@ -1374,7 +1378,7 @@
 #if defined(SUNOS4) || defined(FREEBSD)
     typedef void (* SIG_PF)();
 #endif
-#if defined(SUNOS5SIGS) || defined(OSF1) || defined(LINUX)
+#if defined(SUNOS5SIGS) || defined(OSF1) || defined(LINUX) || defined(HURD)
     typedef void (* SIG_PF)(int);
 #endif
 #if defined(MSWIN32)
@@ -1398,6 +1402,9 @@
 #   endif
 # endif
 
+#if defined(HURD)
+    typedef void (* REAL_SIG_PF)(int, struct sigcontext);
+#endif
 SIG_PF GC_old_bus_handler;
 SIG_PF GC_old_segv_handler;	/* Also old MSWIN32 ACCESS_VIOLATION filter */
 
@@ -1429,6 +1436,9 @@
 #     define CODE_OK (code == EACCES)
 #   endif
 # endif
+# if defined(HURD)
+      void GC_write_fault_handler(int sig, struct sigcontext sc)
+# endif
 # if defined(LINUX)
 #   if (LINUX_VERSION_CODE >= 0x20100)
       void GC_write_fault_handler(int sig, struct sigcontext sc)
@@ -1464,6 +1474,12 @@
 #   ifdef SUNOS5SIGS
 	char * addr = (char *) (scp -> si_addr);
 #   endif
+#   ifdef  HURD
+#     ifdef I386
+char * addr; /*  Set to what? */
+#     endif
+#   endif
+
 #   ifdef LINUX
 #     ifdef I386
 	char * addr = (char *) (sc.cr2);
@@ -1517,7 +1533,7 @@
 		    (*(REAL_SIG_PF)old_handler) (sig, scp, context);
 		    return;
 #		endif
-#		if defined (LINUX)
+#		if defined (LINUX)  || defined(HURD)
 		    (*(REAL_SIG_PF)old_handler) (sig, sc);
 		    return;
 #		endif
@@ -1536,7 +1552,7 @@
             set_pht_entry_from_index(GC_dirty_pages, index);
         }
         UNPROTECT(h, GC_page_size);
-#	if defined(OSF1) || defined(LINUX)
+#	if defined(OSF1) || defined(LINUX)  || defined(HURD)
 	    /* These reset the signal handler each time by default. */
 	    signal(SIGSEGV, (SIG_PF) GC_write_fault_handler);
 #	endif
@@ -1615,7 +1631,7 @@
 #	endif
       }
 #   endif
-#   if defined(OSF1) || defined(SUNOS4) || defined(LINUX)
+#   if defined(OSF1) || defined(SUNOS4) || defined(LINUX)  || defined(HURD)
       GC_old_segv_handler = signal(SIGSEGV, (SIG_PF)GC_write_fault_handler);
       if (GC_old_segv_handler == SIG_IGN) {
         GC_err_printf0("Previously ignored segmentation violation!?");
diff -Naur libgc4-4.12-4.13alpha1/test_cpp.cc libgc4-4.12-4.13alpha1.hurd/test_cpp.cc
--- libgc4-4.12-4.13alpha1/test_cpp.cc	Fri Oct 31 20:13:50 1997
+++ libgc4-4.12-4.13alpha1.hurd/test_cpp.cc	Thu Jan 20 13:45:41 2000
@@ -184,6 +184,20 @@
       *x = 29;
       x -= 3;
 #   endif
+
+#  ifdef FIND_LEAK
+#    ifdef __GNU__
+printf("You have set the flag FIND_LEAK\n");
+printf("This test loops horribly under the Hurd. So will not try it\n\n");
+return ( 0 ); 
+#      endif
+#    ifdef __linux__
+printf("You have set the flag FIND_LEAK\n");
+printf("This test loops horribly under Linux. So will not try it\n\n");
+return ( 0 ); 
+#     endif
+#  endif
+
     if (argc != 2 || (0 >= (n = atoi( argv[ 1 ] )))) {
         GC_printf0( "usage: test_cpp number-of-iterations\n" );
         exit( 1 );}

Reply to: