bridges/source/cpp_uno/gcc3_ios/uno2cpp.cxx |   24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

New commits:
commit ad85bf85c3879c9aa5c98f1d03e3e14aaea7fe2c
Author:     Tor Lillqvist <t...@collabora.com>
AuthorDate: Tue Mar 2 14:30:03 2021 +0200
Commit:     Tor Lillqvist <t...@collabora.com>
CommitDate: Tue Mar 2 15:52:12 2021 +0100

    Handle floating-point return values correctly on iOS
    
    The code did not work at all. The contents of register d0 that we
    tried to access in MapReturn() was not what the called function had
    stored there. Probably the clobber list in the __asm__ statement is
    wrong? Anyway, simpler to fix it by explicitly storing d0, too, into a
    variable after the call, like we do for x0 and x1, and then pass that
    variable, too, to MapReturn().
    
    Fixes https://github.com/CollaboraOnline/online/issues/1519 .
    
    Change-Id: Id05c8c57209eb9ade4d67035830b2dec601bc046
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111826
    Tested-by: Michael Meeks <michael.me...@collabora.com>
    Tested-by: Tor Lillqvist <t...@collabora.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>
    Reviewed-by: Tor Lillqvist <t...@collabora.com>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111835

diff --git a/bridges/source/cpp_uno/gcc3_ios/uno2cpp.cxx 
b/bridges/source/cpp_uno/gcc3_ios/uno2cpp.cxx
index eacd01332900..07ec8501f0df 100644
--- a/bridges/source/cpp_uno/gcc3_ios/uno2cpp.cxx
+++ b/bridges/source/cpp_uno/gcc3_ios/uno2cpp.cxx
@@ -77,7 +77,7 @@ namespace arm
     }
 }
 
-void MapReturn(sal_uInt64 x0, sal_uInt64 x1, typelib_TypeDescriptionReference 
*pReturnType, sal_uInt64 *pRegisterReturn)
+void MapReturn(sal_uInt64 x0, sal_uInt64 x1, double d0, 
typelib_TypeDescriptionReference *pReturnType, sal_uInt64 *pRegisterReturn)
 {
     switch( pReturnType->eTypeClass )
     {
@@ -96,18 +96,10 @@ void MapReturn(sal_uInt64 x0, sal_uInt64 x1, 
typelib_TypeDescriptionReference *p
         pRegisterReturn[0] = x0;
         break;
     case typelib_TypeClass_FLOAT:
-        register float fret asm("s0");
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wuninitialized"
-        *(float*)pRegisterReturn = fret;
-#pragma GCC diagnostic pop
+        *(float*)pRegisterReturn = *(float*)&d0;
         break;
     case typelib_TypeClass_DOUBLE:
-        register double dret asm("d0");
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wuninitialized"
-        *(double*)pRegisterReturn = dret;
-#pragma GCC diagnostic pop
+        *(double*)pRegisterReturn = d0;
         break;
     case typelib_TypeClass_STRUCT:
     case typelib_TypeClass_EXCEPTION:
@@ -153,9 +145,11 @@ void callVirtualMethod(
     // For value returned in registers
     sal_uInt64 x0;
     sal_uInt64 x1;
+    double d0;
 
     __asm__ __volatile__
     (
+     // Assembly string
      "  ldp x0, x1, %[pgpr_0]\n"
      "  ldp x2, x3, %[pgpr_2]\n"
      "  ldp x4, x5, %[pgpr_4]\n"
@@ -168,7 +162,10 @@ void callVirtualMethod(
      "  blr %[pmethod]\n"
      "  str x0, %[x0]\n"
      "  str x1, %[x1]\n"
-     : [x0]"=m" (x0), [x1]"=m" (x1)
+     "  str d0, %[d0]\n"
+     // Output operands
+     : [x0]"=m" (x0), [x1]"=m" (x1), [d0]"=m" (d0)
+     // Input operands
      : [pgpr_0]"m" (pGPR[0]),
        [pgpr_2]"m" (pGPR[2]),
        [pgpr_4]"m" (pGPR[4]),
@@ -179,10 +176,11 @@ void callVirtualMethod(
        [pfpr_4]"m" (pFPR[4]),
        [pfpr_6]"m" (pFPR[6]),
        [pmethod]"r" (pMethod)
+     // Clobbers
      : "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", "x8", "d0", "d1", "d2", 
"d3", "d4", "d5", "d6", "d7"
      );
 
-  MapReturn(x0, x1, pReturnType, (sal_uInt64 *) pRegisterReturn);
+    MapReturn(x0, x1, d0, pReturnType, (sal_uInt64 *) pRegisterReturn);
 }
 }
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to