Hi,

as discussed in IRC, I was trying to minimal-invasively port
libpostproc (the Debian source package) to x32¹. I could not
test it (for lack of a stand-alone test program) yet, but at
least I got it to build.

As requested, the patch I used is attached. It’s not optimal
as the arch could use the wider registers, but probably good
enough, should it do what it’s supposed to ;-)

bye,
//mirabilos

① https://wiki.debian.org/X32Port
-- 
“ah that reminds me, thanks for the stellar entertainment that you and certain
other people provide on the Debian mailing lists │ sole reason I subscribed to
them (I'm not using Debian anywhere) is the entertainment factor │ Debian does
not strike me as a place for good humour, much less German admin-style humour”
# DP: Port to x32
# DP: There is no GCC documentation about the asm præficēs except
# DP: in http://stackoverflow.com/a/17825185/2171120 – go figure…

--- a/configure
+++ b/configure
@@ -811,6 +811,7 @@ ARCH_LIST='
     sparc
     sparc64
     tomi
+    x32
     x86
     x86_32
     x86_64
@@ -2190,7 +2191,9 @@ case "$arch" in
         check_cc <<EOF && subarch="x86_64"
         int test[(int)sizeof(char*) - 7];
 EOF
-        if test "$subarch" = "x86_64"; then
+        test "$subarch" = "x86_32" && check_cpp_condition sys/types.h \
+            'defined(__x86_64__) && defined(__ILP32__)' && subarch="x32"
+        if test "$subarch" = "x86_64" || test "$subarch" = "x32"; then
             spic=$shared
         fi
     ;;
--- a/libpostproc/postprocess_template.c
+++ b/libpostproc/postprocess_template.c
@@ -29,7 +29,7 @@
 
 #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a)
 
-#if ARCH_X86_64 && defined(PIC)
+#if (ARCH_X32 || ARCH_X86_64) && defined(PIC)
 #    define LOCAL_MANGLE(a) #a "(%%rip)"
 #else
 #    define LOCAL_MANGLE(a) #a
@@ -1142,10 +1142,10 @@ FIND_MIN_MAX((%0, %1, 8))
 #endif
         "movq %%mm6, %%mm0                      \n\t" // max
         "psubb %%mm7, %%mm6                     \n\t" // max - min
-        "push %4                              \n\t"
+        "pushq %q4                              \n\t"
         "movd %%mm6, %k4                        \n\t"
         "cmpb "MANGLE(deringThreshold)", %b4    \n\t"
-        "pop %4                               \n\t"
+        "popq %q4                               \n\t"
         " jb 1f                                 \n\t"
         PAVGB(%%mm0, %%mm7)                           // a=(max + min)/2
         "punpcklbw %%mm7, %%mm7                 \n\t"
--- a/libpostproc/x86/asm.h
+++ b/libpostproc/x86/asm.h
@@ -64,14 +64,34 @@ typedef int32_t x86_reg;
 #    define REGc    ecx
 #    define REGd    edx
 #    define REGSP   esp
+#elif ARCH_X32
+
+#    define OPSIZE "l"
+#    define REG_a "eax"
+#    define REG_b "ebx"
+#    define REG_c "ecx"
+#    define REG_d "edx"
+#    define REG_D "edi"
+#    define REG_S "esi"
+#    define PTR_SIZE "4"
+typedef int32_t x86_reg;
+
+/* do not define REG_SP so code using it fails */
+#    define REG_BP "ebp"
+#    define REGBP   ebp
+#    define REGa    eax
+#    define REGb    ebx
+#    define REGc    ecx
+#    define REGd    edx
+/* do not define REGSP so code using it fails */
 #else
 typedef int x86_reg;
 #endif
 
-#define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE))
-#define HAVE_6REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE))
+#define HAVE_7REGS (ARCH_X32 || ARCH_X86_64 || (HAVE_EBX_AVAILABLE && 
HAVE_EBP_AVAILABLE))
+#define HAVE_6REGS (ARCH_X32 || ARCH_X86_64 || (HAVE_EBX_AVAILABLE || 
HAVE_EBP_AVAILABLE))
 
-#if ARCH_X86_64 && defined(PIC)
+#if (ARCH_X32 || ARCH_X86_64) && defined(PIC)
 #    define BROKEN_RELOCATIONS 1
 #endif
 
@@ -99,7 +119,7 @@ typedef int x86_reg;
 #define LABEL_MANGLE(a) EXTERN_PREFIX #a
 
 // Use rip-relative addressing if compiling PIC code on x86-64.
-#if ARCH_X86_64 && defined(PIC)
+#if (ARCH_X32 || ARCH_X86_64) && defined(PIC)
 #    define LOCAL_MANGLE(a) #a "(%%rip)"
 #else
 #    define LOCAL_MANGLE(a) #a
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to