mozilla-ppc64le-libffi.patch
author Wolfgang Rosenauer <wr@rosenauer.org>
Thu, 12 Jun 2014 00:02:30 +0200
branchesr24
changeset 743 d43937f702f4
parent 713 3c7719dfcafa
permissions -rw-r--r--
24.6.0 release
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
713
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     1
# HG changeset patch
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     2
# Parent 8dc4f9193d19bb9ab3f476cbf44366fdf5304ae4
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     3
# User Ulrich Weigand <uweigand@de.ibm.com>
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     4
Bug 976648 - powerpc64le-linux support - libffi backport
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     5
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     6
diff --git a/js/src/ctypes/libffi/aclocal.m4 b/js/src/ctypes/libffi/aclocal.m4
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     7
--- a/js/src/ctypes/libffi/aclocal.m4
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     8
+++ b/js/src/ctypes/libffi/aclocal.m4
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
     9
@@ -1277,31 +1277,34 @@ ia64-*-hpux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    10
 	  LD="${LD-ld} -64"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    11
 	  ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    12
       esac
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    13
     fi
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    14
   fi
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    15
   rm -rf conftest*
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    16
   ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    17
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    18
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    19
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    20
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    21
   # Find out which ABI we are using.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    22
   echo 'int i;' > conftest.$ac_ext
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    23
   if AC_TRY_EVAL(ac_compile); then
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    24
     case `/usr/bin/file conftest.o` in
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    25
       *32-bit*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    26
 	case $host in
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    27
 	  x86_64-*kfreebsd*-gnu)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    28
 	    LD="${LD-ld} -m elf_i386_fbsd"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    29
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    30
 	  x86_64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    31
 	    LD="${LD-ld} -m elf_i386"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    32
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    33
-	  ppc64-*linux*|powerpc64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    34
+	  powerpc64le-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    35
+	    LD="${LD-ld} -m elf32lppclinux"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    36
+	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    37
+	  powerpc64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    38
 	    LD="${LD-ld} -m elf32ppclinux"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    39
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    40
 	  s390x-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    41
 	    LD="${LD-ld} -m elf_s390"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    42
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    43
 	  sparc64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    44
 	    LD="${LD-ld} -m elf32_sparc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    45
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    46
@@ -1310,17 +1313,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    47
       *64-bit*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    48
 	case $host in
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    49
 	  x86_64-*kfreebsd*-gnu)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    50
 	    LD="${LD-ld} -m elf_x86_64_fbsd"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    51
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    52
 	  x86_64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    53
 	    LD="${LD-ld} -m elf_x86_64"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    54
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    55
-	  ppc*-*linux*|powerpc*-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    56
+	  powerpcle-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    57
+	    LD="${LD-ld} -m elf64lppc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    58
+	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    59
+	  powerpc-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    60
 	    LD="${LD-ld} -m elf64ppc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    61
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    62
 	  s390*-*linux*|s390*-*tpf*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    63
 	    LD="${LD-ld} -m elf64_s390"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    64
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    65
 	  sparc*-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    66
 	    LD="${LD-ld} -m elf64_sparc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    67
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    68
diff --git a/js/src/ctypes/libffi/configure b/js/src/ctypes/libffi/configure
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    69
--- a/js/src/ctypes/libffi/configure
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    70
+++ b/js/src/ctypes/libffi/configure
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    71
@@ -6293,17 +6293,17 @@ ia64-*-hpux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    72
 	  LD="${LD-ld} -64"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    73
 	  ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    74
       esac
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    75
     fi
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    76
   fi
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    77
   rm -rf conftest*
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    78
   ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    79
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    80
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    81
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    82
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    83
   # Find out which ABI we are using.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    84
   echo 'int i;' > conftest.$ac_ext
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    85
   if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    86
   (eval $ac_compile) 2>&5
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    87
   ac_status=$?
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    88
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    89
   test $ac_status = 0; }; then
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    90
@@ -6311,17 +6311,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    91
       *32-bit*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    92
 	case $host in
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    93
 	  x86_64-*kfreebsd*-gnu)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    94
 	    LD="${LD-ld} -m elf_i386_fbsd"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    95
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    96
 	  x86_64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    97
 	    LD="${LD-ld} -m elf_i386"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    98
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
    99
-	  ppc64-*linux*|powerpc64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   100
+	  powerpc64le-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   101
+	    LD="${LD-ld} -m elf32lppclinux"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   102
+	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   103
+	  powerpc64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   104
 	    LD="${LD-ld} -m elf32ppclinux"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   105
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   106
 	  s390x-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   107
 	    LD="${LD-ld} -m elf_s390"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   108
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   109
 	  sparc64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   110
 	    LD="${LD-ld} -m elf32_sparc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   111
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   112
@@ -6330,17 +6333,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   113
       *64-bit*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   114
 	case $host in
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   115
 	  x86_64-*kfreebsd*-gnu)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   116
 	    LD="${LD-ld} -m elf_x86_64_fbsd"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   117
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   118
 	  x86_64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   119
 	    LD="${LD-ld} -m elf_x86_64"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   120
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   121
-	  ppc*-*linux*|powerpc*-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   122
+	  powerpcle-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   123
+	    LD="${LD-ld} -m elf64lppc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   124
+	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   125
+	  powerpc-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   126
 	    LD="${LD-ld} -m elf64ppc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   127
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   128
 	  s390*-*linux*|s390*-*tpf*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   129
 	    LD="${LD-ld} -m elf64_s390"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   130
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   131
 	  sparc*-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   132
 	    LD="${LD-ld} -m elf64_sparc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   133
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   134
diff --git a/js/src/ctypes/libffi/m4/libtool.m4 b/js/src/ctypes/libffi/m4/libtool.m4
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   135
--- a/js/src/ctypes/libffi/m4/libtool.m4
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   136
+++ b/js/src/ctypes/libffi/m4/libtool.m4
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   137
@@ -1262,31 +1262,34 @@ ia64-*-hpux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   138
 	  LD="${LD-ld} -64"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   139
 	  ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   140
       esac
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   141
     fi
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   142
   fi
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   143
   rm -rf conftest*
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   144
   ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   145
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   146
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   147
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   148
 s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   149
   # Find out which ABI we are using.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   150
   echo 'int i;' > conftest.$ac_ext
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   151
   if AC_TRY_EVAL(ac_compile); then
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   152
     case `/usr/bin/file conftest.o` in
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   153
       *32-bit*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   154
 	case $host in
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   155
 	  x86_64-*kfreebsd*-gnu)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   156
 	    LD="${LD-ld} -m elf_i386_fbsd"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   157
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   158
 	  x86_64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   159
 	    LD="${LD-ld} -m elf_i386"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   160
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   161
-	  ppc64-*linux*|powerpc64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   162
+	  powerpc64le-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   163
+	    LD="${LD-ld} -m elf32lppclinux"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   164
+	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   165
+	  powerpc64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   166
 	    LD="${LD-ld} -m elf32ppclinux"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   167
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   168
 	  s390x-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   169
 	    LD="${LD-ld} -m elf_s390"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   170
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   171
 	  sparc64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   172
 	    LD="${LD-ld} -m elf32_sparc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   173
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   174
@@ -1295,17 +1298,20 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   175
       *64-bit*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   176
 	case $host in
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   177
 	  x86_64-*kfreebsd*-gnu)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   178
 	    LD="${LD-ld} -m elf_x86_64_fbsd"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   179
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   180
 	  x86_64-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   181
 	    LD="${LD-ld} -m elf_x86_64"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   182
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   183
-	  ppc*-*linux*|powerpc*-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   184
+	  powerpcle-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   185
+	    LD="${LD-ld} -m elf64lppc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   186
+	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   187
+	  powerpc-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   188
 	    LD="${LD-ld} -m elf64ppc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   189
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   190
 	  s390*-*linux*|s390*-*tpf*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   191
 	    LD="${LD-ld} -m elf64_s390"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   192
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   193
 	  sparc*-*linux*)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   194
 	    LD="${LD-ld} -m elf64_sparc"
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   195
 	    ;;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   196
diff --git a/js/src/ctypes/libffi/src/powerpc/ffi.c b/js/src/ctypes/libffi/src/powerpc/ffi.c
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   197
--- a/js/src/ctypes/libffi/src/powerpc/ffi.c
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   198
+++ b/js/src/ctypes/libffi/src/powerpc/ffi.c
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   199
@@ -1,12 +1,14 @@
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   200
 /* -----------------------------------------------------------------------
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   201
-   ffi.c - Copyright (c) 1998 Geoffrey Keating
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   202
-   Copyright (C) 2007, 2008 Free Software Foundation, Inc
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   203
-   Copyright (C) 2008 Red Hat, Inc
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   204
+   ffi.c - Copyright (C) 2011 Anthony Green
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   205
+           Copyright (C) 2011 Kyle Moffett
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   206
+           Copyright (C) 2008 Red Hat, Inc
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   207
+           Copyright (C) 2007, 2008 Free Software Foundation, Inc
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   208
+	   Copyright (c) 1998 Geoffrey Keating
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   209
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   210
    PowerPC Foreign Function Interface
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   211
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   212
    Permission is hereby granted, free of charge, to any person obtaining
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   213
    a copy of this software and associated documentation files (the
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   214
    ``Software''), to deal in the Software without restriction, including
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   215
    without limitation the rights to use, copy, modify, merge, publish,
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   216
    distribute, sublicense, and/or sell copies of the Software, and to
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   217
@@ -34,42 +36,39 @@
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   218
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   219
 extern void ffi_closure_SYSV (void);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   220
 extern void FFI_HIDDEN ffi_closure_LINUX64 (void);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   221
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   222
 enum {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   223
   /* The assembly depends on these exact flags.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   224
   FLAG_RETURNS_SMST	= 1 << (31-31), /* Used for FFI_SYSV small structs.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   225
   FLAG_RETURNS_NOTHING  = 1 << (31-30), /* These go in cr7 */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   226
+#ifndef __NO_FPRS__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   227
   FLAG_RETURNS_FP       = 1 << (31-29),
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   228
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   229
   FLAG_RETURNS_64BITS   = 1 << (31-28),
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   230
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   231
   FLAG_RETURNS_128BITS  = 1 << (31-27), /* cr6  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   232
-  FLAG_SYSV_SMST_R4     = 1 << (31-26), /* use r4 for FFI_SYSV 8 byte
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   233
-					   structs.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   234
-  FLAG_SYSV_SMST_R3     = 1 << (31-25), /* use r3 for FFI_SYSV 4 byte
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   235
-					   structs.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   236
-  /* Bits (31-24) through (31-19) store shift value for SMST */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   237
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   238
   FLAG_ARG_NEEDS_COPY   = 1 << (31- 7),
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   239
+  FLAG_ARG_NEEDS_PSAVE  = FLAG_ARG_NEEDS_COPY, /* Used by ELFv2 */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   240
+#ifndef __NO_FPRS__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   241
   FLAG_FP_ARGUMENTS     = 1 << (31- 6), /* cr1.eq; specified by ABI */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   242
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   243
   FLAG_4_GPR_ARGUMENTS  = 1 << (31- 5),
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   244
   FLAG_RETVAL_REFERENCE = 1 << (31- 4)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   245
 };
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   246
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   247
 /* About the SYSV ABI.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   248
-unsigned int NUM_GPR_ARG_REGISTERS = 8;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   249
+#define ASM_NEEDS_REGISTERS 4
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   250
+#define NUM_GPR_ARG_REGISTERS 8
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   251
 #ifndef __NO_FPRS__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   252
-unsigned int NUM_FPR_ARG_REGISTERS = 8;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   253
-#else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   254
-unsigned int NUM_FPR_ARG_REGISTERS = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   255
+# define NUM_FPR_ARG_REGISTERS 8
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   256
 #endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   257
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   258
-enum { ASM_NEEDS_REGISTERS = 4 };
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   259
-
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   260
 /* ffi_prep_args_SYSV is called by the assembly routine once stack space
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   261
    has been allocated for the function's arguments.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   262
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   263
    The stack layout we want looks like this:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   264
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   265
    |   Return address from ffi_call_SYSV 4bytes	|	higher addresses
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   266
    |--------------------------------------------|
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   267
    |   Previous backchain pointer	4	|       stack pointer here
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   268
@@ -108,100 +107,119 @@ ffi_prep_args_SYSV (extended_cif *ecif, 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   269
   /* 'stacktop' points at the previous backchain pointer.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   270
   valp stacktop;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   271
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   272
   /* 'gpr_base' points at the space for gpr3, and grows upwards as
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   273
      we use GPR registers.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   274
   valp gpr_base;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   275
   int intarg_count;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   276
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   277
+#ifndef __NO_FPRS__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   278
   /* 'fpr_base' points at the space for fpr1, and grows upwards as
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   279
      we use FPR registers.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   280
   valp fpr_base;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   281
   int fparg_count;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   282
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   283
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   284
   /* 'copy_space' grows down as we put structures in it.  It should
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   285
      stay 16-byte aligned.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   286
   valp copy_space;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   287
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   288
   /* 'next_arg' grows up as we put parameters in it.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   289
   valp next_arg;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   290
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   291
-  int i, ii MAYBE_UNUSED;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   292
+  int i;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   293
   ffi_type **ptr;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   294
+#ifndef __NO_FPRS__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   295
   double double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   296
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   297
   union {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   298
     void **v;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   299
     char **c;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   300
     signed char **sc;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   301
     unsigned char **uc;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   302
     signed short **ss;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   303
     unsigned short **us;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   304
     unsigned int **ui;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   305
     long long **ll;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   306
     float **f;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   307
     double **d;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   308
   } p_argv;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   309
   size_t struct_copy_size;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   310
   unsigned gprvalue;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   311
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   312
-  if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   313
-    NUM_FPR_ARG_REGISTERS = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   314
-
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   315
   stacktop.c = (char *) stack + bytes;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   316
   gpr_base.u = stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   317
   intarg_count = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   318
+#ifndef __NO_FPRS__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   319
   fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   320
   fparg_count = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   321
   copy_space.c = ((flags & FLAG_FP_ARGUMENTS) ? fpr_base.c : gpr_base.c);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   322
+#else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   323
+  copy_space.c = gpr_base.c;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   324
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   325
   next_arg.u = stack + 2;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   326
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   327
   /* Check that everything starts aligned properly.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   328
-  FFI_ASSERT (((unsigned) (char *) stack & 0xF) == 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   329
-  FFI_ASSERT (((unsigned) copy_space.c & 0xF) == 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   330
-  FFI_ASSERT (((unsigned) stacktop.c & 0xF) == 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   331
+  FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   332
+  FFI_ASSERT (((unsigned long) copy_space.c & 0xF) == 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   333
+  FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   334
   FFI_ASSERT ((bytes & 0xF) == 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   335
   FFI_ASSERT (copy_space.c >= next_arg.c);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   336
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   337
   /* Deal with return values that are actually pass-by-reference.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   338
   if (flags & FLAG_RETVAL_REFERENCE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   339
     {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   340
       *gpr_base.u++ = (unsigned long) (char *) ecif->rvalue;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   341
       intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   342
     }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   343
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   344
   /* Now for the arguments.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   345
   p_argv.v = ecif->avalue;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   346
   for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   347
        i > 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   348
        i--, ptr++, p_argv.v++)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   349
     {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   350
-      switch ((*ptr)->type)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   351
-	{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   352
+      unsigned short typenum = (*ptr)->type;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   353
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   354
+      /* We may need to handle some values depending on ABI */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   355
+      if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT) {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   356
+		if (typenum == FFI_TYPE_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   357
+			typenum = FFI_TYPE_UINT32;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   358
+		if (typenum == FFI_TYPE_DOUBLE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   359
+			typenum = FFI_TYPE_UINT64;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   360
+		if (typenum == FFI_TYPE_LONGDOUBLE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   361
+			typenum = FFI_TYPE_UINT128;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   362
+      } else if (ecif->cif->abi != FFI_LINUX) {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   363
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   364
+		if (typenum == FFI_TYPE_LONGDOUBLE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   365
+			typenum = FFI_TYPE_STRUCT;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   366
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   367
+      }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   368
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   369
+      /* Now test the translated value */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   370
+      switch (typenum) {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   371
+#ifndef __NO_FPRS__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   372
 	case FFI_TYPE_FLOAT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   373
 	  /* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   374
-	  if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   375
-	    goto soft_float_prep;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   376
 	  double_tmp = **p_argv.f;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   377
 	  if (fparg_count >= NUM_FPR_ARG_REGISTERS)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   378
 	    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   379
 	      *next_arg.f = (float) double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   380
 	      next_arg.u += 1;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   381
 	      intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   382
 	    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   383
 	  else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   384
 	    *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   385
 	  fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   386
 	  FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   387
 	  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   388
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   389
 	case FFI_TYPE_DOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   390
 	  /* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   391
-	  if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   392
-	    goto soft_double_prep;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   393
 	  double_tmp = **p_argv.d;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   394
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   395
 	  if (fparg_count >= NUM_FPR_ARG_REGISTERS)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   396
 	    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   397
 	      if (intarg_count >= NUM_GPR_ARG_REGISTERS
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   398
 		  && intarg_count % 2 != 0)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   399
 		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   400
 		  intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   401
@@ -213,53 +231,16 @@ ffi_prep_args_SYSV (extended_cif *ecif, 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   402
 	  else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   403
 	    *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   404
 	  fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   405
 	  FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   406
 	  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   407
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   408
 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   409
 	case FFI_TYPE_LONGDOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   410
-	  if ((ecif->cif->abi != FFI_LINUX)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   411
-		&& (ecif->cif->abi != FFI_LINUX_SOFT_FLOAT))
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   412
-	    goto do_struct;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   413
-	  /* The soft float ABI for long doubles works like this,
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   414
-	     a long double is passed in four consecutive gprs if available.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   415
-	     A maximum of 2 long doubles can be passed in gprs.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   416
-	     If we do not have 4 gprs left, the long double is passed on the
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   417
-	     stack, 4-byte aligned.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   418
-	  if (ecif->cif->abi == FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   419
-	    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   420
-	      unsigned int int_tmp = (*p_argv.ui)[0];
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   421
-	      if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   422
-		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   423
-		  if (intarg_count < NUM_GPR_ARG_REGISTERS)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   424
-		    intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   425
-		  *next_arg.u = int_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   426
-		  next_arg.u++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   427
-		  for (ii = 1; ii < 4; ii++)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   428
-		    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   429
-		      int_tmp = (*p_argv.ui)[ii];
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   430
-		      *next_arg.u = int_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   431
-		      next_arg.u++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   432
-		    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   433
-		}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   434
-	      else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   435
-		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   436
-		  *gpr_base.u++ = int_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   437
-		  for (ii = 1; ii < 4; ii++)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   438
-		    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   439
-		      int_tmp = (*p_argv.ui)[ii];
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   440
-		      *gpr_base.u++ = int_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   441
-		    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   442
-		}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   443
-	      intarg_count +=4;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   444
-	    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   445
-	  else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   446
-	    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   447
 	      double_tmp = (*p_argv.d)[0];
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   448
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   449
 	      if (fparg_count >= NUM_FPR_ARG_REGISTERS - 1)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   450
 		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   451
 		  if (intarg_count >= NUM_GPR_ARG_REGISTERS
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   452
 		      && intarg_count % 2 != 0)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   453
 		    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   454
 		      intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   455
@@ -275,23 +256,50 @@ ffi_prep_args_SYSV (extended_cif *ecif, 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   456
 		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   457
 		  *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   458
 		  double_tmp = (*p_argv.d)[1];
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   459
 		  *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   460
 		}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   461
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   462
 	      fparg_count += 2;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   463
 	      FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   464
-	    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   465
 	  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   466
 #endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   467
+#endif /* have FPRs */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   468
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   469
+	/*
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   470
+	 * The soft float ABI for long doubles works like this, a long double
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   471
+	 * is passed in four consecutive GPRs if available.  A maximum of 2
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   472
+	 * long doubles can be passed in gprs.  If we do not have 4 GPRs
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   473
+	 * left, the long double is passed on the stack, 4-byte aligned.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   474
+	 */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   475
+	case FFI_TYPE_UINT128: {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   476
+		unsigned int int_tmp = (*p_argv.ui)[0];
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   477
+		unsigned int ii;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   478
+		if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3) {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   479
+			if (intarg_count < NUM_GPR_ARG_REGISTERS)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   480
+				intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   481
+			*(next_arg.u++) = int_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   482
+			for (ii = 1; ii < 4; ii++) {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   483
+				int_tmp = (*p_argv.ui)[ii];
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   484
+				*(next_arg.u++) = int_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   485
+			}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   486
+		} else {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   487
+			*(gpr_base.u++) = int_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   488
+			for (ii = 1; ii < 4; ii++) {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   489
+				int_tmp = (*p_argv.ui)[ii];
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   490
+				*(gpr_base.u++) = int_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   491
+			}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   492
+		}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   493
+		intarg_count += 4;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   494
+		break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   495
+	}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   496
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   497
 	case FFI_TYPE_UINT64:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   498
 	case FFI_TYPE_SINT64:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   499
-	soft_double_prep:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   500
 	  if (intarg_count == NUM_GPR_ARG_REGISTERS-1)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   501
 	    intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   502
 	  if (intarg_count >= NUM_GPR_ARG_REGISTERS)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   503
 	    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   504
 	      if (intarg_count % 2 != 0)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   505
 		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   506
 		  intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   507
 		  next_arg.u++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   508
@@ -314,19 +322,16 @@ ffi_prep_args_SYSV (extended_cif *ecif, 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   509
 		  gpr_base.u++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   510
 		}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   511
 	      *gpr_base.ll++ = **p_argv.ll;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   512
 	    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   513
 	  intarg_count += 2;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   514
 	  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   515
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   516
 	case FFI_TYPE_STRUCT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   517
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   518
-	do_struct:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   519
-#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   520
 	  struct_copy_size = ((*ptr)->size + 15) & ~0xF;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   521
 	  copy_space.c -= struct_copy_size;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   522
 	  memcpy (copy_space.c, *p_argv.c, (*ptr)->size);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   523
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   524
 	  gprvalue = (unsigned long) copy_space.c;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   525
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   526
 	  FFI_ASSERT (copy_space.c > next_arg.c);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   527
 	  FFI_ASSERT (flags & FLAG_ARG_NEEDS_COPY);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   528
@@ -344,45 +349,91 @@ ffi_prep_args_SYSV (extended_cif *ecif, 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   529
 	case FFI_TYPE_SINT16:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   530
 	  gprvalue = **p_argv.ss;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   531
 	  goto putgpr;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   532
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   533
 	case FFI_TYPE_INT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   534
 	case FFI_TYPE_UINT32:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   535
 	case FFI_TYPE_SINT32:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   536
 	case FFI_TYPE_POINTER:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   537
-	soft_float_prep:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   538
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   539
 	  gprvalue = **p_argv.ui;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   540
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   541
 	putgpr:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   542
 	  if (intarg_count >= NUM_GPR_ARG_REGISTERS)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   543
 	    *next_arg.u++ = gprvalue;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   544
 	  else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   545
 	    *gpr_base.u++ = gprvalue;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   546
 	  intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   547
 	  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   548
 	}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   549
     }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   550
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   551
   /* Check that we didn't overrun the stack...  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   552
   FFI_ASSERT (copy_space.c >= next_arg.c);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   553
   FFI_ASSERT (gpr_base.u <= stacktop.u - ASM_NEEDS_REGISTERS);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   554
+  /* The assert below is testing that the number of integer arguments agrees
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   555
+     with the number found in ffi_prep_cif_machdep().  However, intarg_count
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   556
+     is incremented whenever we place an FP arg on the stack, so account for
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   557
+     that before our assert test.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   558
+#ifndef __NO_FPRS__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   559
+  if (fparg_count > NUM_FPR_ARG_REGISTERS)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   560
+    intarg_count -= fparg_count - NUM_FPR_ARG_REGISTERS;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   561
   FFI_ASSERT (fpr_base.u
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   562
 	      <= stacktop.u - ASM_NEEDS_REGISTERS - NUM_GPR_ARG_REGISTERS);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   563
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   564
   FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS || intarg_count <= 4);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   565
 }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   566
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   567
 /* About the LINUX64 ABI.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   568
 enum {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   569
   NUM_GPR_ARG_REGISTERS64 = 8,
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   570
   NUM_FPR_ARG_REGISTERS64 = 13
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   571
 };
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   572
 enum { ASM_NEEDS_REGISTERS64 = 4 };
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   573
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   574
+#if _CALL_ELF == 2
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   575
+static unsigned int
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   576
+discover_homogeneous_aggregate (const ffi_type *t, unsigned int *elnum)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   577
+{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   578
+  switch (t->type)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   579
+    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   580
+    case FFI_TYPE_FLOAT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   581
+    case FFI_TYPE_DOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   582
+      *elnum = 1;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   583
+      return (int) t->type;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   584
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   585
+    case FFI_TYPE_STRUCT:;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   586
+      {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   587
+	unsigned int base_elt = 0, total_elnum = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   588
+	ffi_type **el = t->elements;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   589
+	while (*el)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   590
+	  {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   591
+	    unsigned int el_elt, el_elnum = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   592
+	    el_elt = discover_homogeneous_aggregate (*el, &el_elnum);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   593
+	    if (el_elt == 0
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   594
+		|| (base_elt && base_elt != el_elt))
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   595
+	      return 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   596
+	    base_elt = el_elt;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   597
+	    total_elnum += el_elnum;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   598
+	    if (total_elnum > 8)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   599
+	      return 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   600
+	    el++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   601
+	  }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   602
+	*elnum = total_elnum;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   603
+	return base_elt;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   604
+      }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   605
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   606
+    default:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   607
+      return 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   608
+    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   609
+}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   610
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   611
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   612
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   613
 /* ffi_prep_args64 is called by the assembly routine once stack space
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   614
    has been allocated for the function's arguments.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   615
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   616
    The stack layout we want looks like this:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   617
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   618
    |   Ret addr from ffi_call_LINUX64	8bytes	|	higher addresses
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   619
    |--------------------------------------------|
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   620
    |   CR save area			8bytes	|
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   621
@@ -418,141 +469,216 @@ ffi_prep_args64 (extended_cif *ecif, uns
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   622
   const unsigned long bytes = ecif->cif->bytes;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   623
   const unsigned long flags = ecif->cif->flags;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   624
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   625
   typedef union {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   626
     char *c;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   627
     unsigned long *ul;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   628
     float *f;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   629
     double *d;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   630
+    size_t p;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   631
   } valp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   632
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   633
   /* 'stacktop' points at the previous backchain pointer.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   634
   valp stacktop;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   635
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   636
   /* 'next_arg' points at the space for gpr3, and grows upwards as
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   637
      we use GPR registers, then continues at rest.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   638
   valp gpr_base;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   639
   valp gpr_end;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   640
   valp rest;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   641
   valp next_arg;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   642
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   643
   /* 'fpr_base' points at the space for fpr3, and grows upwards as
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   644
      we use FPR registers.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   645
   valp fpr_base;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   646
-  int fparg_count;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   647
+  unsigned int fparg_count;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   648
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   649
-  int i, words;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   650
+  unsigned int i, words, nargs, nfixedargs;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   651
   ffi_type **ptr;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   652
   double double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   653
   union {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   654
     void **v;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   655
     char **c;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   656
     signed char **sc;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   657
     unsigned char **uc;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   658
     signed short **ss;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   659
     unsigned short **us;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   660
     signed int **si;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   661
     unsigned int **ui;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   662
     unsigned long **ul;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   663
     float **f;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   664
     double **d;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   665
   } p_argv;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   666
   unsigned long gprvalue;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   667
+#ifdef __STRUCT_PARM_ALIGN__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   668
+  unsigned long align;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   669
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   670
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   671
   stacktop.c = (char *) stack + bytes;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   672
   gpr_base.ul = stacktop.ul - ASM_NEEDS_REGISTERS64 - NUM_GPR_ARG_REGISTERS64;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   673
   gpr_end.ul = gpr_base.ul + NUM_GPR_ARG_REGISTERS64;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   674
+#if _CALL_ELF == 2
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   675
+  rest.ul = stack + 4 + NUM_GPR_ARG_REGISTERS64;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   676
+#else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   677
   rest.ul = stack + 6 + NUM_GPR_ARG_REGISTERS64;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   678
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   679
   fpr_base.d = gpr_base.d - NUM_FPR_ARG_REGISTERS64;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   680
   fparg_count = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   681
   next_arg.ul = gpr_base.ul;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   682
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   683
   /* Check that everything starts aligned properly.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   684
   FFI_ASSERT (((unsigned long) (char *) stack & 0xF) == 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   685
   FFI_ASSERT (((unsigned long) stacktop.c & 0xF) == 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   686
   FFI_ASSERT ((bytes & 0xF) == 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   687
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   688
   /* Deal with return values that are actually pass-by-reference.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   689
   if (flags & FLAG_RETVAL_REFERENCE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   690
     *next_arg.ul++ = (unsigned long) (char *) ecif->rvalue;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   691
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   692
   /* Now for the arguments.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   693
   p_argv.v = ecif->avalue;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   694
-  for (ptr = ecif->cif->arg_types, i = ecif->cif->nargs;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   695
-       i > 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   696
-       i--, ptr++, p_argv.v++)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   697
+  nargs = ecif->cif->nargs;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   698
+  nfixedargs = ecif->cif->nfixedargs;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   699
+  for (ptr = ecif->cif->arg_types, i = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   700
+       i < nargs;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   701
+       i++, ptr++, p_argv.v++)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   702
     {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   703
+      unsigned int elt, elnum;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   704
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   705
       switch ((*ptr)->type)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   706
 	{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   707
 	case FFI_TYPE_FLOAT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   708
 	  double_tmp = **p_argv.f;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   709
-	  *next_arg.f = (float) double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   710
+	  if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   711
+	    *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   712
+	  else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   713
+	    *next_arg.f = (float) double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   714
 	  if (++next_arg.ul == gpr_end.ul)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   715
 	    next_arg.ul = rest.ul;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   716
-	  if (fparg_count < NUM_FPR_ARG_REGISTERS64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   717
-	    *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   718
 	  fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   719
 	  FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   720
 	  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   721
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   722
 	case FFI_TYPE_DOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   723
 	  double_tmp = **p_argv.d;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   724
-	  *next_arg.d = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   725
+	  if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   726
+	    *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   727
+	  else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   728
+	    *next_arg.d = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   729
 	  if (++next_arg.ul == gpr_end.ul)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   730
 	    next_arg.ul = rest.ul;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   731
-	  if (fparg_count < NUM_FPR_ARG_REGISTERS64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   732
-	    *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   733
 	  fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   734
 	  FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   735
 	  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   736
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   737
 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   738
 	case FFI_TYPE_LONGDOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   739
 	  double_tmp = (*p_argv.d)[0];
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   740
-	  *next_arg.d = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   741
+	  if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   742
+	    *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   743
+	  else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   744
+	    *next_arg.d = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   745
 	  if (++next_arg.ul == gpr_end.ul)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   746
 	    next_arg.ul = rest.ul;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   747
-	  if (fparg_count < NUM_FPR_ARG_REGISTERS64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   748
-	    *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   749
 	  fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   750
 	  double_tmp = (*p_argv.d)[1];
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   751
-	  *next_arg.d = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   752
+	  if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   753
+	    *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   754
+	  else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   755
+	    *next_arg.d = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   756
 	  if (++next_arg.ul == gpr_end.ul)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   757
 	    next_arg.ul = rest.ul;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   758
-	  if (fparg_count < NUM_FPR_ARG_REGISTERS64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   759
-	    *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   760
 	  fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   761
 	  FFI_ASSERT (__LDBL_MANT_DIG__ == 106);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   762
 	  FFI_ASSERT (flags & FLAG_FP_ARGUMENTS);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   763
 	  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   764
 #endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   765
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   766
 	case FFI_TYPE_STRUCT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   767
-	  words = ((*ptr)->size + 7) / 8;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   768
-	  if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   769
+#ifdef __STRUCT_PARM_ALIGN__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   770
+	  align = (*ptr)->alignment;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   771
+	  if (align > __STRUCT_PARM_ALIGN__)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   772
+	    align = __STRUCT_PARM_ALIGN__;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   773
+	  if (align > 1)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   774
+	    next_arg.p = ALIGN (next_arg.p, align);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   775
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   776
+	  elt = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   777
+#if _CALL_ELF == 2
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   778
+	  elt = discover_homogeneous_aggregate (*ptr, &elnum);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   779
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   780
+	  if (elt)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   781
 	    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   782
-	      size_t first = gpr_end.c - next_arg.c;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   783
-	      memcpy (next_arg.c, *p_argv.c, first);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   784
-	      memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   785
-	      next_arg.c = rest.c + words * 8 - first;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   786
+	      union {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   787
+		void *v;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   788
+		float *f;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   789
+		double *d;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   790
+	      } arg;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   791
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   792
+	      arg.v = *p_argv.v;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   793
+	      if (elt == FFI_TYPE_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   794
+		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   795
+		  do
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   796
+		    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   797
+		      double_tmp = *arg.f++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   798
+		      if (fparg_count < NUM_FPR_ARG_REGISTERS64
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   799
+			  && i < nfixedargs)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   800
+			*fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   801
+		      else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   802
+			*next_arg.f = (float) double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   803
+		      if (++next_arg.f == gpr_end.f)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   804
+			next_arg.f = rest.f;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   805
+		      fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   806
+		    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   807
+		  while (--elnum != 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   808
+		  if ((next_arg.p & 3) != 0)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   809
+		    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   810
+		      if (++next_arg.f == gpr_end.f)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   811
+			next_arg.f = rest.f;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   812
+		    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   813
+		}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   814
+	      else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   815
+		do
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   816
+		  {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   817
+		    double_tmp = *arg.d++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   818
+		    if (fparg_count < NUM_FPR_ARG_REGISTERS64 && i < nfixedargs)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   819
+		      *fpr_base.d++ = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   820
+		    else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   821
+		      *next_arg.d = double_tmp;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   822
+		    if (++next_arg.d == gpr_end.d)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   823
+		      next_arg.d = rest.d;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   824
+		    fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   825
+		  }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   826
+		while (--elnum != 0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   827
 	    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   828
 	  else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   829
 	    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   830
-	      char *where = next_arg.c;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   831
+	      words = ((*ptr)->size + 7) / 8;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   832
+	      if (next_arg.ul >= gpr_base.ul && next_arg.ul + words > gpr_end.ul)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   833
+		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   834
+		  size_t first = gpr_end.c - next_arg.c;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   835
+		  memcpy (next_arg.c, *p_argv.c, first);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   836
+		  memcpy (rest.c, *p_argv.c + first, (*ptr)->size - first);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   837
+		  next_arg.c = rest.c + words * 8 - first;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   838
+		}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   839
+	      else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   840
+		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   841
+		  char *where = next_arg.c;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   842
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   843
-	      /* Structures with size less than eight bytes are passed
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   844
-		 left-padded.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   845
-	      if ((*ptr)->size < 8)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   846
-		where += 8 - (*ptr)->size;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   847
-
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   848
-	      memcpy (where, *p_argv.c, (*ptr)->size);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   849
-	      next_arg.ul += words;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   850
-	      if (next_arg.ul == gpr_end.ul)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   851
-		next_arg.ul = rest.ul;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   852
+#ifndef __LITTLE_ENDIAN__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   853
+		  /* Structures with size less than eight bytes are passed
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   854
+		     left-padded.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   855
+		  if ((*ptr)->size < 8)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   856
+		    where += 8 - (*ptr)->size;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   857
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   858
+		  memcpy (where, *p_argv.c, (*ptr)->size);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   859
+		  next_arg.ul += words;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   860
+		  if (next_arg.ul == gpr_end.ul)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   861
+		    next_arg.ul = rest.ul;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   862
+		}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   863
 	    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   864
 	  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   865
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   866
 	case FFI_TYPE_UINT8:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   867
 	  gprvalue = **p_argv.uc;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   868
 	  goto putgpr;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   869
 	case FFI_TYPE_SINT8:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   870
 	  gprvalue = **p_argv.sc;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   871
@@ -586,53 +712,55 @@ ffi_prep_args64 (extended_cif *ecif, uns
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   872
   FFI_ASSERT (flags & FLAG_4_GPR_ARGUMENTS
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   873
 	      || (next_arg.ul >= gpr_base.ul
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   874
 		  && next_arg.ul <= gpr_base.ul + 4));
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   875
 }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   876
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   877
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   878
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   879
 /* Perform machine dependent cif processing */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   880
-ffi_status
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   881
-ffi_prep_cif_machdep (ffi_cif *cif)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   882
+static ffi_status
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   883
+ffi_prep_cif_machdep_core (ffi_cif *cif)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   884
 {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   885
   /* All this is for the SYSV and LINUX64 ABI.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   886
-  int i;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   887
   ffi_type **ptr;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   888
   unsigned bytes;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   889
-  int fparg_count = 0, intarg_count = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   890
-  unsigned flags = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   891
+  unsigned i, fparg_count = 0, intarg_count = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   892
+  unsigned flags = cif->flags;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   893
   unsigned struct_copy_size = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   894
   unsigned type = cif->rtype->type;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   895
   unsigned size = cif->rtype->size;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   896
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   897
-  if (cif->abi == FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   898
-    NUM_FPR_ARG_REGISTERS = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   899
-
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   900
+  /* The machine-independent calculation of cif->bytes doesn't work
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   901
+     for us.  Redo the calculation.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   902
   if (cif->abi != FFI_LINUX64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   903
     {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   904
-      /* All the machine-independent calculation of cif->bytes will be wrong.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   905
-	 Redo the calculation for SYSV.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   906
-
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   907
       /* Space for the frame pointer, callee's LR, and the asm's temp regs.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   908
       bytes = (2 + ASM_NEEDS_REGISTERS) * sizeof (int);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   909
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   910
       /* Space for the GPR registers.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   911
       bytes += NUM_GPR_ARG_REGISTERS * sizeof (int);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   912
     }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   913
   else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   914
     {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   915
       /* 64-bit ABI.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   916
+#if _CALL_ELF == 2
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   917
+      /* Space for backchain, CR, LR, TOC and the asm's temp regs.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   918
+      bytes = (4 + ASM_NEEDS_REGISTERS64) * sizeof (long);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   919
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   920
+      /* Space for the general registers.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   921
+      bytes += NUM_GPR_ARG_REGISTERS64 * sizeof (long);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   922
+#else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   923
       /* Space for backchain, CR, LR, cc/ld doubleword, TOC and the asm's temp
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   924
 	 regs.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   925
       bytes = (6 + ASM_NEEDS_REGISTERS64) * sizeof (long);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   926
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   927
       /* Space for the mandatory parm save area and general registers.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   928
       bytes += 2 * NUM_GPR_ARG_REGISTERS64 * sizeof (long);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   929
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   930
     }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   931
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   932
   /* Return value handling.  The rules for SYSV are as follows:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   933
      - 32-bit (or less) integer values are returned in gpr3;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   934
      - Structures of size <= 4 bytes also returned in gpr3;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   935
      - 64-bit integer values and structures between 5 and 8 bytes are returned
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   936
      in gpr3 and gpr4;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   937
      - Single/double FP values are returned in fpr1;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   938
@@ -641,71 +769,93 @@ ffi_prep_cif_machdep (ffi_cif *cif)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   939
      - long doubles (if not equivalent to double) are returned in
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   940
      fpr1,fpr2 for Linux and as for large structs for SysV.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   941
      For LINUX64:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   942
      - integer values in gpr3;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   943
      - Structures/Unions by reference;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   944
      - Single/double FP values in fpr1, long double in fpr1,fpr2.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   945
      - soft-float float/doubles are treated as UINT32/UINT64 respectivley.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   946
      - soft-float long doubles are returned in gpr3-gpr6.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   947
+  /* First translate for softfloat/nonlinux */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   948
+  if (cif->abi == FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   949
+    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   950
+      if (type == FFI_TYPE_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   951
+	type = FFI_TYPE_UINT32;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   952
+      if (type == FFI_TYPE_DOUBLE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   953
+	type = FFI_TYPE_UINT64;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   954
+      if (type == FFI_TYPE_LONGDOUBLE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   955
+	type = FFI_TYPE_UINT128;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   956
+    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   957
+  else if (cif->abi != FFI_LINUX
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   958
+	   && cif->abi != FFI_LINUX64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   959
+    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   960
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   961
+      if (type == FFI_TYPE_LONGDOUBLE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   962
+	type = FFI_TYPE_STRUCT;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   963
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   964
+    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   965
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   966
   switch (type)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   967
     {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   968
+#ifndef __NO_FPRS__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   969
 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   970
     case FFI_TYPE_LONGDOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   971
-      if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   972
-	&& cif->abi != FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   973
-	goto byref;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   974
       flags |= FLAG_RETURNS_128BITS;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   975
       /* Fall through.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   976
 #endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   977
     case FFI_TYPE_DOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   978
       flags |= FLAG_RETURNS_64BITS;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   979
       /* Fall through.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   980
     case FFI_TYPE_FLOAT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   981
-      /* With FFI_LINUX_SOFT_FLOAT no fp registers are used.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   982
-      if (cif->abi != FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   983
-	flags |= FLAG_RETURNS_FP;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   984
+      flags |= FLAG_RETURNS_FP;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   985
       break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   986
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   987
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   988
+    case FFI_TYPE_UINT128:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   989
+      flags |= FLAG_RETURNS_128BITS;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   990
+      /* Fall through.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   991
     case FFI_TYPE_UINT64:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   992
     case FFI_TYPE_SINT64:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   993
       flags |= FLAG_RETURNS_64BITS;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   994
       break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   995
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   996
     case FFI_TYPE_STRUCT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   997
-      if (cif->abi == FFI_SYSV)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   998
+      /*
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
   999
+       * The final SYSV ABI says that structures smaller or equal 8 bytes
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1000
+       * are returned in r3/r4.  The FFI_GCC_SYSV ABI instead returns them
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1001
+       * in memory.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1002
+       *
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1003
+       * NOTE: The assembly code can safely assume that it just needs to
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1004
+       *       store both r3 and r4 into a 8-byte word-aligned buffer, as
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1005
+       *       we allocate a temporary buffer in ffi_call() if this flag is
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1006
+       *       set.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1007
+       */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1008
+      if (cif->abi == FFI_SYSV && size <= 8)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1009
 	{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1010
-	  /* The final SYSV ABI says that structures smaller or equal 8 bytes
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1011
-	     are returned in r3/r4. The FFI_GCC_SYSV ABI instead returns them
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1012
-	     in memory.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1013
-
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1014
-	  /* Treat structs with size <= 8 bytes.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1015
-	  if (size <= 8)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1016
+	  flags |= FLAG_RETURNS_SMST;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1017
+	  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1018
+	}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1019
+#if _CALL_ELF == 2
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1020
+      if (cif->abi == FFI_LINUX64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1021
+	{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1022
+	  unsigned int elt, elnum;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1023
+	  elt = discover_homogeneous_aggregate (cif->rtype, &elnum);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1024
+	  if (elt)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1025
+	    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1026
+	      if (elt == FFI_TYPE_DOUBLE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1027
+		flags |= FLAG_RETURNS_64BITS;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1028
+	      flags |= FLAG_RETURNS_FP | FLAG_RETURNS_SMST;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1029
+	      break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1030
+	    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1031
+	  if (size <= 16)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1032
 	    {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1033
 	      flags |= FLAG_RETURNS_SMST;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1034
-	      /* These structs are returned in r3. We pack the type and the
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1035
-		 precalculated shift value (needed in the sysv.S) into flags.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1036
-		 The same applies for the structs returned in r3/r4.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1037
-	      if (size <= 4)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1038
-		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1039
-		  flags |= FLAG_SYSV_SMST_R3;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1040
-		  flags |= 8 * (4 - size) << 8;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1041
-		  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1042
-		}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1043
-	      /* These structs are returned in r3 and r4. See above.   */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1044
-	      if  (size <= 8)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1045
-		{
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1046
-		  flags |= FLAG_SYSV_SMST_R3 | FLAG_SYSV_SMST_R4;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1047
-		  flags |= 8 * (8 - size) << 8;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1048
-		  break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1049
-		}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1050
+	      break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1051
 	    }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1052
 	}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1053
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1054
-    byref:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1055
 #endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1056
       intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1057
       flags |= FLAG_RETVAL_REFERENCE;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1058
       /* Fall through.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1059
     case FFI_TYPE_VOID:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1060
       flags |= FLAG_RETURNS_NOTHING;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1061
       break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1062
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1063
@@ -717,218 +867,334 @@ ffi_prep_cif_machdep (ffi_cif *cif)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1064
   if (cif->abi != FFI_LINUX64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1065
     /* The first NUM_GPR_ARG_REGISTERS words of integer arguments, and the
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1066
        first NUM_FPR_ARG_REGISTERS fp arguments, go in registers; the rest
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1067
        goes on the stack.  Structures and long doubles (if not equivalent
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1068
        to double) are passed as a pointer to a copy of the structure.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1069
        Stuff on the stack needs to keep proper alignment.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1070
     for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1071
       {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1072
-	switch ((*ptr)->type)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1073
-	  {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1074
+	unsigned short typenum = (*ptr)->type;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1075
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1076
+	/* We may need to handle some values depending on ABI */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1077
+	if (cif->abi == FFI_LINUX_SOFT_FLOAT) {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1078
+		if (typenum == FFI_TYPE_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1079
+			typenum = FFI_TYPE_UINT32;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1080
+		if (typenum == FFI_TYPE_DOUBLE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1081
+			typenum = FFI_TYPE_UINT64;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1082
+		if (typenum == FFI_TYPE_LONGDOUBLE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1083
+			typenum = FFI_TYPE_UINT128;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1084
+	} else if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX64) {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1085
+#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1086
+		if (typenum == FFI_TYPE_LONGDOUBLE)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1087
+			typenum = FFI_TYPE_STRUCT;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1088
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1089
+	}
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1090
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1091
+	switch (typenum) {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1092
+#ifndef __NO_FPRS__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1093
 	  case FFI_TYPE_FLOAT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1094
-	    /* With FFI_LINUX_SOFT_FLOAT floats are handled like UINT32.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1095
-	    if (cif->abi == FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1096
-	      goto soft_float_cif;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1097
 	    fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1098
 	    /* floating singles are not 8-aligned on stack */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1099
 	    break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1100
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1101
 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1102
 	  case FFI_TYPE_LONGDOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1103
-	    if (cif->abi != FFI_LINUX && cif->abi != FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1104
-	      goto do_struct;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1105
-	    if (cif->abi == FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1106
-	      {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1107
-		if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1108
-		  || intarg_count < NUM_GPR_ARG_REGISTERS)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1109
-		  /* A long double in FFI_LINUX_SOFT_FLOAT can use only
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1110
-		     a set of four consecutive gprs. If we have not enough,
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1111
-		     we have to adjust the intarg_count value.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1112
-		  intarg_count += NUM_GPR_ARG_REGISTERS - intarg_count;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1113
-		intarg_count += 4;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1114
-		break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1115
-	      }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1116
-	    else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1117
-	      fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1118
+	    fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1119
 	    /* Fall thru */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1120
 #endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1121
 	  case FFI_TYPE_DOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1122
-	    /* With FFI_LINUX_SOFT_FLOAT doubles are handled like UINT64.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1123
-	    if (cif->abi == FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1124
-	      goto soft_double_cif;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1125
 	    fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1126
 	    /* If this FP arg is going on the stack, it must be
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1127
 	       8-byte-aligned.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1128
 	    if (fparg_count > NUM_FPR_ARG_REGISTERS
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1129
 		&& intarg_count >= NUM_GPR_ARG_REGISTERS
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1130
 		&& intarg_count % 2 != 0)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1131
 	      intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1132
 	    break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1133
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1134
+	  case FFI_TYPE_UINT128:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1135
+		/*
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1136
+		 * A long double in FFI_LINUX_SOFT_FLOAT can use only a set
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1137
+		 * of four consecutive gprs. If we do not have enough, we
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1138
+		 * have to adjust the intarg_count value.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1139
+		 */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1140
+		if (intarg_count >= NUM_GPR_ARG_REGISTERS - 3
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1141
+				&& intarg_count < NUM_GPR_ARG_REGISTERS)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1142
+			intarg_count = NUM_GPR_ARG_REGISTERS;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1143
+		intarg_count += 4;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1144
+		break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1145
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1146
 	  case FFI_TYPE_UINT64:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1147
 	  case FFI_TYPE_SINT64:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1148
-	  soft_double_cif:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1149
 	    /* 'long long' arguments are passed as two words, but
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1150
 	       either both words must fit in registers or both go
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1151
 	       on the stack.  If they go on the stack, they must
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1152
 	       be 8-byte-aligned.
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1153
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1154
 	       Also, only certain register pairs can be used for
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1155
 	       passing long long int -- specifically (r3,r4), (r5,r6),
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1156
 	       (r7,r8), (r9,r10).
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1157
 	    */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1158
 	    if (intarg_count == NUM_GPR_ARG_REGISTERS-1
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1159
 		|| intarg_count % 2 != 0)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1160
 	      intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1161
 	    intarg_count += 2;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1162
 	    break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1163
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1164
 	  case FFI_TYPE_STRUCT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1165
-#if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1166
-	  do_struct:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1167
-#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1168
 	    /* We must allocate space for a copy of these to enforce
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1169
 	       pass-by-value.  Pad the space up to a multiple of 16
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1170
 	       bytes (the maximum alignment required for anything under
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1171
 	       the SYSV ABI).  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1172
 	    struct_copy_size += ((*ptr)->size + 15) & ~0xF;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1173
 	    /* Fall through (allocate space for the pointer).  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1174
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1175
-	  default:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1176
-	  soft_float_cif:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1177
+	  case FFI_TYPE_POINTER:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1178
+	  case FFI_TYPE_INT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1179
+	  case FFI_TYPE_UINT32:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1180
+	  case FFI_TYPE_SINT32:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1181
+	  case FFI_TYPE_UINT16:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1182
+	  case FFI_TYPE_SINT16:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1183
+	  case FFI_TYPE_UINT8:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1184
+	  case FFI_TYPE_SINT8:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1185
 	    /* Everything else is passed as a 4-byte word in a GPR, either
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1186
 	       the object itself or a pointer to it.  */
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1187
 	    intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1188
 	    break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1189
+	  default:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1190
+		FFI_ASSERT (0);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1191
 	  }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1192
       }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1193
   else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1194
     for (ptr = cif->arg_types, i = cif->nargs; i > 0; i--, ptr++)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1195
       {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1196
+	unsigned int elt, elnum;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1197
+#ifdef __STRUCT_PARM_ALIGN__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1198
+	unsigned int align;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1199
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1200
+
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1201
 	switch ((*ptr)->type)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1202
 	  {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1203
 #if FFI_TYPE_LONGDOUBLE != FFI_TYPE_DOUBLE
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1204
 	  case FFI_TYPE_LONGDOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1205
-	    if (cif->abi == FFI_LINUX_SOFT_FLOAT)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1206
-	      intarg_count += 4;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1207
-	    else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1208
-	      {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1209
-		fparg_count += 2;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1210
-		intarg_count += 2;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1211
-	      }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1212
+	    fparg_count += 2;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1213
+	    intarg_count += 2;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1214
+	    if (fparg_count > NUM_FPR_ARG_REGISTERS64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1215
+	      flags |= FLAG_ARG_NEEDS_PSAVE;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1216
 	    break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1217
 #endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1218
 	  case FFI_TYPE_FLOAT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1219
 	  case FFI_TYPE_DOUBLE:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1220
 	    fparg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1221
 	    intarg_count++;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1222
+	    if (fparg_count > NUM_FPR_ARG_REGISTERS64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1223
+	      flags |= FLAG_ARG_NEEDS_PSAVE;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1224
 	    break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1225
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1226
 	  case FFI_TYPE_STRUCT:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1227
+#ifdef __STRUCT_PARM_ALIGN__
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1228
+	    align = (*ptr)->alignment;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1229
+	    if (align > __STRUCT_PARM_ALIGN__)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1230
+	      align = __STRUCT_PARM_ALIGN__;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1231
+	    align = align / 8;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1232
+	    if (align > 1)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1233
+	      intarg_count = ALIGN (intarg_count, align);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1234
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1235
 	    intarg_count += ((*ptr)->size + 7) / 8;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1236
+	    elt = 0;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1237
+#if _CALL_ELF == 2
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1238
+	    elt = discover_homogeneous_aggregate (*ptr, &elnum);
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1239
+#endif
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1240
+	    if (elt)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1241
+	      {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1242
+		fparg_count += elnum;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1243
+		if (fparg_count > NUM_FPR_ARG_REGISTERS64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1244
+		  flags |= FLAG_ARG_NEEDS_PSAVE;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1245
+	      }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1246
+	    else
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1247
+	      {
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1248
+		if (intarg_count > NUM_GPR_ARG_REGISTERS64)
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1249
+		  flags |= FLAG_ARG_NEEDS_PSAVE;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1250
+	      }
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1251
 	    break;
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1252
 
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1253
-	  default:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1254
+	  case FFI_TYPE_POINTER:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1255
+	  case FFI_TYPE_UINT64:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1256
+	  case FFI_TYPE_SINT64:
3c7719dfcafa update to 24.4.0esr
Wolfgang Rosenauer <wr@rosenauer.org>
parents:
diff changeset
  1257
+	  case FFI_TYPE_INT:
3c7719dfcafa update to 24.4.0esr