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

Bug#773409: updated patch



Hi!
x32 support has been accepted upstream.  I'd be great to have it in Debian
as well -- not having ocaml blocks hundreds of packages, both those written
in ocaml as well as those which depend on ones written in ocaml.

As you probably don't want to go with new upstream versions yet, here's an
updated version of the patch.  It needed fixing -- a directory has been
moved in the meantime, but there are no actual code changes.

Please apply!

-- 
A tit a day keeps the vet away.
--- ocaml-4.02.3.orig/byterun/caml/signals_machdep.h
+++ ocaml-4.02.3/byterun/caml/signals_machdep.h
@@ -25,10 +25,19 @@
 
 #elif defined(__GNUC__) && defined(__x86_64__)
 
+#ifdef __ILP32__
+/* x32 */
+#define Read_and_clear(dst,src) \
+  asm("xorl %0, %0; xchgl %0, %1" \
+      : "=r" (dst), "=m" (src) \
+      : "m" (src))
+#else
+/* amd64 */
 #define Read_and_clear(dst,src) \
   asm("xorq %0, %0; xchgq %0, %1" \
       : "=r" (dst), "=m" (src) \
       : "m" (src))
+#endif
 
 #elif defined(__GNUC__) && defined(__ppc__)
 
--- ocaml-4.02.3.orig/configure
+++ ocaml-4.02.3/configure
@@ -861,6 +861,7 @@ case "$target" in
   arm*-*-linux-gnueabi)         arch=arm; system=linux_eabi;;
   arm*-*-openbsd*)              arch=arm; system=bsd;;
   zaurus*-*-openbsd*)           arch=arm; system=bsd;;
+  x86_64-*-linux-gnux32)        arch=x32; system=linux;;
   x86_64-*-linux*)              arch=amd64; system=linux;;
   x86_64-*-gnu*)                arch=amd64; system=gnu;;
   x86_64-*-freebsd*)            arch=amd64; system=freebsd;;
--- ocaml-4.02.3.orig/otherlibs/num/bng.c
+++ ocaml-4.02.3/otherlibs/num/bng.c
@@ -17,7 +17,7 @@
 #include "caml/config.h"
 
 #if defined(__GNUC__) && BNG_ASM_LEVEL > 0
-#if defined(BNG_ARCH_ia32)
+#if defined(BNG_ARCH_ia32) || defined(BNG_ARCH_x32)
 #include "bng_ia32.c"
 #elif defined(BNG_ARCH_amd64)
 #include "bng_amd64.c"
--- ocaml-4.02.3.orig/otherlibs/num/bng_ia32.c
+++ ocaml-4.02.3/otherlibs/num/bng_ia32.c
@@ -187,7 +187,7 @@ static bngdigit bng_ia32_mult_sub_digit
    This is faster than the plain IA32 code above on the Pentium 4.
    (Arithmetic operations with carry are slow on the Pentium 4). */
 
-#if BNG_ASM_LEVEL >= 2
+#if BNG_ASM_LEVEL >= 2 || defined(__x86_64__)
 
 static bngcarry bng_ia32sse2_add
        (bng a/*[alen]*/, bngsize alen,
@@ -393,6 +393,13 @@ static int bng_ia32_sse2_supported(void)
 
 static void bng_ia32_setup_ops(void)
 {
+#ifdef __x86_64__
+  /* x32 -- SSE2 always supported */
+  bng_ops.add = bng_ia32sse2_add;
+  bng_ops.sub = bng_ia32sse2_sub;
+  bng_ops.mult_add_digit = bng_ia32sse2_mult_add_digit;
+  bng_ops.mult_sub_digit = bng_ia32sse2_mult_sub_digit;
+#else
 #if BNG_ASM_LEVEL >= 2
   if (bng_ia32_sse2_supported()) {
     bng_ops.add = bng_ia32sse2_add;
@@ -406,6 +413,7 @@ static void bng_ia32_setup_ops(void)
   bng_ops.sub = bng_ia32_sub;
   bng_ops.mult_add_digit = bng_ia32_mult_add_digit;
   bng_ops.mult_sub_digit = bng_ia32_mult_sub_digit;
+#endif
 }
 
 #define BNG_SETUP_OPS bng_ia32_setup_ops()
--- ocaml-4.02.3.orig/testsuite/makefiles/Makefile.common
+++ ocaml-4.02.3/testsuite/makefiles/Makefile.common
@@ -68,7 +68,7 @@ OCAMLMKLIB=$(OCAMLRUN) $(OTOPDIR)/tools/
 OCAMLYACC=$(TOPDIR)/yacc/ocamlyacc$(EXE)
 OCAMLBUILD=$(TOPDIR)/_build/ocamlbuild/ocamlbuild.native
 DUMPOBJ=$(OCAMLRUN) $(OTOPDIR)/tool/dumpobj
-BYTECODE_ONLY=[ "$(ARCH)" = "none" -o "$(ASM)" = "none" ]
+BYTECODE_ONLY=[ "$(ARCH)" = "none" -o "$(ARCH)" = "x32" -o "$(ASM)" = "none" ]
 
 #FORTRAN_COMPILER=
 #FORTRAN_LIBRARY=

Reply to: