PageRenderTime 26ms CodeModel.GetById 15ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/js/src/ctypes/patches-libffi/00-base.patch

http://github.com/zpao/v8monkey
Patch | 1328 lines | 1211 code | 117 blank | 0 comment | 0 complexity | d94e468c742d7b63f81f8f1deff00489 MD5 | raw file
   1Patch libffi to fix bug 550602, bug 538216, bug545634, bug 594611, bug 605421
   2and bug 631928.
   3
   4diff --git a/js/src/ctypes/libffi/Makefile.in b/js/src/ctypes/libffi/Makefile.in
   5--- a/js/src/ctypes/libffi/Makefile.in
   6+++ b/js/src/ctypes/libffi/Makefile.in
   7@@ -199,17 +199,17 @@ LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
   8 CCLD = $(CC)
   9 LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
  10 	--mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
  11 	$(LDFLAGS) -o $@
  12 SOURCES = $(libffi_la_SOURCES) $(nodist_libffi_la_SOURCES) \
  13 	$(libffi_convenience_la_SOURCES) \
  14 	$(nodist_libffi_convenience_la_SOURCES)
  15 DIST_SOURCES = $(libffi_la_SOURCES) $(libffi_convenience_la_SOURCES)
  16-INFO_DEPS = $(srcdir)/doc/libffi.info
  17+INFO_DEPS =
  18 am__TEXINFO_TEX_DIR = $(srcdir)
  19 DVIS = doc/libffi.dvi
  20 PDFS = doc/libffi.pdf
  21 PSS = doc/libffi.ps
  22 HTMLS = doc/libffi.html
  23 TEXINFOS = doc/libffi.texi
  24 TEXI2DVI = texi2dvi
  25 TEXI2PDF = $(TEXI2DVI) --pdf --batch
  26@@ -986,57 +986,57 @@ distclean-compile:
  27 @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/ffi.Plo@am__quote@
  28 @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/ffi64.Plo@am__quote@
  29 @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/freebsd.Plo@am__quote@
  30 @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/sysv.Plo@am__quote@
  31 @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/unix64.Plo@am__quote@
  32 @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/win32.Plo@am__quote@
  33 @AMDEP_TRUE@@am__include@ @am__quote@src/x86/$(DEPDIR)/win64.Plo@am__quote@
  34 
  35-.S.o:
  36+%.o: %.S
  37 @am__fastdepCCAS_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
  38 @am__fastdepCCAS_TRUE@	$(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
  39 @am__fastdepCCAS_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
  40 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
  41 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  42 @am__fastdepCCAS_FALSE@	$(CPPASCOMPILE) -c -o $@ $<
  43 
  44-.S.obj:
  45+%.obj: %.S
  46 @am__fastdepCCAS_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
  47 @am__fastdepCCAS_TRUE@	$(CPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
  48 @am__fastdepCCAS_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
  49 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
  50 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  51 @am__fastdepCCAS_FALSE@	$(CPPASCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
  52 
  53-.S.lo:
  54+%.lo: %.S
  55 @am__fastdepCCAS_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
  56 @am__fastdepCCAS_TRUE@	$(LTCPPASCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
  57 @am__fastdepCCAS_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
  58 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
  59 @AMDEP_TRUE@@am__fastdepCCAS_FALSE@	DEPDIR=$(DEPDIR) $(CCASDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  60 @am__fastdepCCAS_FALSE@	$(LTCPPASCOMPILE) -c -o $@ $<
  61 
  62-.c.o:
  63+%.o: %.c
  64 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
  65 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
  66 @am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
  67 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
  68 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  69 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ $<
  70 
  71-.c.obj:
  72+%.obj: %.c
  73 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
  74 @am__fastdepCC_TRUE@	$(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
  75 @am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Po
  76 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
  77 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  78 @am__fastdepCC_FALSE@	$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
  79 
  80-.c.lo:
  81+%.lo: %.c
  82 @am__fastdepCC_TRUE@	depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
  83 @am__fastdepCC_TRUE@	$(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
  84 @am__fastdepCC_TRUE@	$(am__mv) $$depbase.Tpo $$depbase.Plo
  85 @AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
  86 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
  87 @am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
  88 
  89 mostlyclean-libtool:
  90@@ -1129,17 +1129,17 @@ $(srcdir)/doc/stamp-vti: doc/libffi.texi $(top_srcdir)/configure
  91 	-@rm -f vti.tmp
  92 	@cp $(srcdir)/doc/version.texi $@
  93 
  94 mostlyclean-vti:
  95 	-rm -f vti.tmp
  96 
  97 maintainer-clean-vti:
  98 @MAINTAINER_MODE_TRUE@	-rm -f $(srcdir)/doc/stamp-vti $(srcdir)/doc/version.texi
  99-.dvi.ps:
 100+%.ps: %.dvi
 101 	TEXINPUTS="$(am__TEXINFO_TEX_DIR)$(PATH_SEPARATOR)$$TEXINPUTS" \
 102 	$(DVIPS) -o $@ $<
 103 
 104 uninstall-dvi-am:
 105 	@$(NORMAL_UNINSTALL)
 106 	@list='$(DVIS)'; test -n "$(dvidir)" || list=; \
 107 	for p in $$list; do \
 108 	  $(am__strip_dir) \
 109diff --git a/js/src/ctypes/libffi/configure b/js/src/ctypes/libffi/configure
 110--- a/js/src/ctypes/libffi/configure
 111+++ b/js/src/ctypes/libffi/configure
 112@@ -8903,17 +8903,17 @@ if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
 113       # Tell ltmain to make .dll files, not .so files.
 114       shrext_cmds=".dll"
 115       # FIXME: Setting linknames here is a bad hack.
 116       archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
 117       # The linker will automatically build a .lib file if we build a DLL.
 118       old_archive_from_new_cmds='true'
 119       # FIXME: Should let the user specify the lib program.
 120       old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
 121-      fix_srcfile_path='`cygpath -w "$srcfile"`'
 122+      fix_srcfile_path=''
 123       enable_shared_with_static_runtimes=yes
 124       ;;
 125 
 126     darwin* | rhapsody*)
 127 
 128 
 129   archive_cmds_need_lc=no
 130   hardcode_direct=no
 131@@ -12270,20 +12270,20 @@ fi
 132 
 133 if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
 134     { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler supports pc related relocs" >&5
 135 $as_echo_n "checking assembler supports pc related relocs... " >&6; }
 136 if test "${libffi_cv_as_x86_pcrel+set}" = set; then :
 137   $as_echo_n "(cached) " >&6
 138 else
 139 
 140-	libffi_cv_as_x86_pcrel=yes
 141+	libffi_cv_as_x86_pcrel=no
 142 	echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
 143-	if $CC $CFLAGS -c conftest.s 2>&1 | $EGREP -i 'illegal|warning' > /dev/null; then
 144-	    libffi_cv_as_x86_pcrel=no
 145+	if $CC $CFLAGS -c conftest.s > /dev/null; then
 146+	    libffi_cv_as_x86_pcrel=yes
 147 	fi
 148 
 149 fi
 150 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libffi_cv_as_x86_pcrel" >&5
 151 $as_echo "$libffi_cv_as_x86_pcrel" >&6; }
 152     if test "x$libffi_cv_as_x86_pcrel" = xyes; then
 153 
 154 $as_echo "#define HAVE_AS_X86_PCREL 1" >>confdefs.h
 155diff --git a/js/src/ctypes/libffi/src/x86/ffi64.c b/js/src/ctypes/libffi/src/x86/ffi64.c
 156--- a/js/src/ctypes/libffi/src/x86/ffi64.c
 157+++ b/js/src/ctypes/libffi/src/x86/ffi64.c
 158@@ -373,29 +373,29 @@ ffi_prep_cif_machdep (ffi_cif *cif)
 159 	  || gprcount + ngpr > MAX_GPR_REGS
 160 	  || ssecount + nsse > MAX_SSE_REGS)
 161 	{
 162 	  long align = cif->arg_types[i]->alignment;
 163 
 164 	  if (align < 8)
 165 	    align = 8;
 166 
 167-	  bytes = ALIGN(bytes, align);
 168+	  bytes = ALIGN (bytes, align);
 169 	  bytes += cif->arg_types[i]->size;
 170 	}
 171       else
 172 	{
 173 	  gprcount += ngpr;
 174 	  ssecount += nsse;
 175 	}
 176     }
 177   if (ssecount)
 178     flags |= 1 << 11;
 179   cif->flags = flags;
 180-  cif->bytes = bytes;
 181+  cif->bytes = ALIGN (bytes, 8);
 182 
 183   return FFI_OK;
 184 }
 185 
 186 void
 187 ffi_call (ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 188 {
 189   enum x86_64_reg_class classes[MAX_CLASSES];
 190diff --git a/js/src/ctypes/libffi/src/arm/ffi.c b/js/src/ctypes/libffi/src/arm/ffi.c
 191--- a/js/src/ctypes/libffi/src/arm/ffi.c
 192+++ b/js/src/ctypes/libffi/src/arm/ffi.c
 193@@ -24,22 +24,30 @@
 194    DEALINGS IN THE SOFTWARE.
 195    ----------------------------------------------------------------------- */
 196 
 197 #include <ffi.h>
 198 #include <ffi_common.h>
 199 
 200 #include <stdlib.h>
 201 
 202-/* ffi_prep_args is called by the assembly routine once stack space
 203-   has been allocated for the function's arguments */
 204+/* Forward declares. */
 205+static int vfp_type_p (ffi_type *);
 206+static void layout_vfp_args (ffi_cif *);
 207 
 208-void ffi_prep_args(char *stack, extended_cif *ecif)
 209+/* ffi_prep_args is called by the assembly routine once stack space
 210+   has been allocated for the function's arguments
 211+   
 212+   The vfp_space parameter is the load area for VFP regs, the return
 213+   value is cif->vfp_used (word bitset of VFP regs used for passing
 214+   arguments). These are only used for the VFP hard-float ABI.
 215+*/
 216+int ffi_prep_args(char *stack, extended_cif *ecif, float *vfp_space)
 217 {
 218-  register unsigned int i;
 219+  register unsigned int i, vi = 0;
 220   register void **p_argv;
 221   register char *argp;
 222   register ffi_type **p_arg;
 223 
 224   argp = stack;
 225 
 226   if ( ecif->cif->flags == FFI_TYPE_STRUCT ) {
 227     *(void **) argp = ecif->rvalue;
 228@@ -49,16 +57,31 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
 229   p_argv = ecif->avalue;
 230 
 231   for (i = ecif->cif->nargs, p_arg = ecif->cif->arg_types;
 232        (i != 0);
 233        i--, p_arg++)
 234     {
 235       size_t z;
 236 
 237+      /* Allocated in VFP registers. */
 238+      if (ecif->cif->abi == FFI_VFP
 239+	  && vi < ecif->cif->vfp_nargs && vfp_type_p (*p_arg))
 240+	{
 241+	  float* vfp_slot = vfp_space + ecif->cif->vfp_args[vi++];
 242+	  if ((*p_arg)->type == FFI_TYPE_FLOAT)
 243+	    *((float*)vfp_slot) = *((float*)*p_argv);
 244+	  else if ((*p_arg)->type == FFI_TYPE_DOUBLE)
 245+	    *((double*)vfp_slot) = *((double*)*p_argv);
 246+	  else
 247+	    memcpy(vfp_slot, *p_argv, (*p_arg)->size);
 248+	  p_argv++;
 249+	  continue;
 250+	}
 251+
 252       /* Align if necessary */
 253       if (((*p_arg)->alignment - 1) & (unsigned) argp) {
 254 	argp = (char *) ALIGN(argp, (*p_arg)->alignment);
 255       }
 256 
 257       if ((*p_arg)->type == FFI_TYPE_STRUCT)
 258 	argp = (char *) ALIGN(argp, 4);
 259 
 260@@ -98,23 +121,25 @@ void ffi_prep_args(char *stack, extended_cif *ecif)
 261 	    }
 262 	  else
 263 	    {
 264 	      memcpy(argp, *p_argv, z);
 265 	    }
 266 	  p_argv++;
 267 	  argp += z;
 268     }
 269-  
 270-  return;
 271+
 272+  /* Indicate the VFP registers used. */
 273+  return ecif->cif->vfp_used;
 274 }
 275 
 276 /* Perform machine dependent cif processing */
 277 ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
 278 {
 279+  int type_code;
 280   /* Round the stack up to a multiple of 8 bytes.  This isn't needed 
 281      everywhere, but it is on some platforms, and it doesn't harm anything
 282      when it isn't needed.  */
 283   cif->bytes = (cif->bytes + 7) & ~7;
 284 
 285   /* Set the return type flag */
 286   switch (cif->rtype->type)
 287     {
 288@@ -125,137 +150,176 @@ ffi_status ffi_prep_cif_machdep(ffi_cif *cif)
 289       break;
 290 
 291     case FFI_TYPE_SINT64:
 292     case FFI_TYPE_UINT64:
 293       cif->flags = (unsigned) FFI_TYPE_SINT64;
 294       break;
 295 
 296     case FFI_TYPE_STRUCT:
 297-      if (cif->rtype->size <= 4)
 298+      if (cif->abi == FFI_VFP
 299+	  && (type_code = vfp_type_p (cif->rtype)) != 0)
 300+	{
 301+	  /* A Composite Type passed in VFP registers, either
 302+	     FFI_TYPE_STRUCT_VFP_FLOAT or FFI_TYPE_STRUCT_VFP_DOUBLE. */
 303+	  cif->flags = (unsigned) type_code;
 304+	}
 305+      else if (cif->rtype->size <= 4)
 306 	/* A Composite Type not larger than 4 bytes is returned in r0.  */
 307 	cif->flags = (unsigned)FFI_TYPE_INT;
 308       else
 309 	/* A Composite Type larger than 4 bytes, or whose size cannot
 310 	   be determined statically ... is stored in memory at an
 311 	   address passed [in r0].  */
 312 	cif->flags = (unsigned)FFI_TYPE_STRUCT;
 313       break;
 314 
 315     default:
 316       cif->flags = FFI_TYPE_INT;
 317       break;
 318     }
 319 
 320+  /* Map out the register placements of VFP register args.
 321+     The VFP hard-float calling conventions are slightly more sophisticated than
 322+     the base calling conventions, so we do it here instead of in ffi_prep_args(). */
 323+  if (cif->abi == FFI_VFP)
 324+    layout_vfp_args (cif);
 325+
 326   return FFI_OK;
 327 }
 328 
 329-extern void ffi_call_SYSV(void (*)(char *, extended_cif *), extended_cif *,
 330-			  unsigned, unsigned, unsigned *, void (*fn)(void));
 331+/* Prototypes for assembly functions, in sysv.S */
 332+extern void ffi_call_SYSV (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *);
 333+extern void ffi_call_VFP (void (*fn)(void), extended_cif *, unsigned, unsigned, unsigned *);
 334 
 335 void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 336 {
 337   extended_cif ecif;
 338 
 339   int small_struct = (cif->flags == FFI_TYPE_INT 
 340 		      && cif->rtype->type == FFI_TYPE_STRUCT);
 341+  int vfp_struct = (cif->flags == FFI_TYPE_STRUCT_VFP_FLOAT
 342+		    || cif->flags == FFI_TYPE_STRUCT_VFP_DOUBLE);
 343 
 344   ecif.cif = cif;
 345   ecif.avalue = avalue;
 346 
 347   unsigned int temp;
 348   
 349   /* If the return value is a struct and we don't have a return	*/
 350   /* value address then we need to make one		        */
 351 
 352   if ((rvalue == NULL) && 
 353       (cif->flags == FFI_TYPE_STRUCT))
 354     {
 355       ecif.rvalue = alloca(cif->rtype->size);
 356     }
 357   else if (small_struct)
 358     ecif.rvalue = &temp;
 359+  else if (vfp_struct)
 360+    {
 361+      /* Largest case is double x 4. */
 362+      ecif.rvalue = alloca(32);
 363+    }
 364   else
 365     ecif.rvalue = rvalue;
 366 
 367   switch (cif->abi) 
 368     {
 369     case FFI_SYSV:
 370-      ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, cif->flags, ecif.rvalue,
 371-		    fn);
 372+      ffi_call_SYSV (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
 373+      break;
 374 
 375+    case FFI_VFP:
 376+      ffi_call_VFP (fn, &ecif, cif->bytes, cif->flags, ecif.rvalue);
 377       break;
 378+
 379     default:
 380       FFI_ASSERT(0);
 381       break;
 382     }
 383   if (small_struct)
 384     memcpy (rvalue, &temp, cif->rtype->size);
 385+  else if (vfp_struct)
 386+    memcpy (rvalue, ecif.rvalue, cif->rtype->size);
 387 }
 388 
 389 /** private members **/
 390 
 391 static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
 392-					 void** args, ffi_cif* cif);
 393+					 void** args, ffi_cif* cif, float *vfp_stack);
 394 
 395 void ffi_closure_SYSV (ffi_closure *);
 396 
 397+void ffi_closure_VFP (ffi_closure *);
 398+
 399 /* This function is jumped to by the trampoline */
 400 
 401 unsigned int
 402-ffi_closure_SYSV_inner (closure, respp, args)
 403+ffi_closure_SYSV_inner (closure, respp, args, vfp_args)
 404      ffi_closure *closure;
 405      void **respp;
 406      void *args;
 407+     void *vfp_args;
 408 {
 409   // our various things...
 410   ffi_cif       *cif;
 411   void         **arg_area;
 412 
 413   cif         = closure->cif;
 414   arg_area    = (void**) alloca (cif->nargs * sizeof (void*));  
 415 
 416   /* this call will initialize ARG_AREA, such that each
 417    * element in that array points to the corresponding 
 418    * value on the stack; and if the function returns
 419    * a structure, it will re-set RESP to point to the
 420    * structure return address.  */
 421 
 422-  ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif);
 423+  ffi_prep_incoming_args_SYSV(args, respp, arg_area, cif, vfp_args);
 424 
 425   (closure->fun) (cif, *respp, arg_area, closure->user_data);
 426 
 427   return cif->flags;
 428 }
 429 
 430 /*@-exportheader@*/
 431 static void 
 432 ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
 433-			    void **avalue, ffi_cif *cif)
 434+			    void **avalue, ffi_cif *cif,
 435+			    /* Used only under VFP hard-float ABI. */
 436+			    float *vfp_stack)
 437 /*@=exportheader@*/
 438 {
 439-  register unsigned int i;
 440+  register unsigned int i, vi = 0;
 441   register void **p_argv;
 442   register char *argp;
 443   register ffi_type **p_arg;
 444 
 445   argp = stack;
 446 
 447   if ( cif->flags == FFI_TYPE_STRUCT ) {
 448     *rvalue = *(void **) argp;
 449     argp += 4;
 450   }
 451 
 452   p_argv = avalue;
 453 
 454   for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
 455     {
 456       size_t z;
 457-
 458-      size_t alignment = (*p_arg)->alignment;
 459+      size_t alignment;
 460+  
 461+      if (cif->abi == FFI_VFP
 462+	  && vi < cif->vfp_nargs && vfp_type_p (*p_arg))
 463+	{
 464+	  *p_argv++ = (void*)(vfp_stack + cif->vfp_args[vi++]);
 465+	  continue;
 466+	}
 467+
 468+      alignment = (*p_arg)->alignment;
 469       if (alignment < 4)
 470 	alignment = 4;
 471       /* Align if necessary */
 472       if ((alignment - 1) & (unsigned) argp) {
 473 	argp = (char *) ALIGN(argp, alignment);
 474       }
 475 
 476       z = (*p_arg)->size;
 477@@ -290,20 +354,147 @@ ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
 478 
 479 ffi_status
 480 ffi_prep_closure_loc (ffi_closure* closure,
 481 		      ffi_cif* cif,
 482 		      void (*fun)(ffi_cif*,void*,void**,void*),
 483 		      void *user_data,
 484 		      void *codeloc)
 485 {
 486-  FFI_ASSERT (cif->abi == FFI_SYSV);
 487+  void (*closure_func)(ffi_closure*) = NULL;
 488 
 489+  if (cif->abi == FFI_SYSV)
 490+    closure_func = &ffi_closure_SYSV;
 491+  else if (cif->abi == FFI_VFP)
 492+    closure_func = &ffi_closure_VFP;
 493+  else
 494+    FFI_ASSERT (0);
 495+    
 496   FFI_INIT_TRAMPOLINE (&closure->tramp[0], \
 497-		       &ffi_closure_SYSV,  \
 498+		       closure_func,  \
 499 		       codeloc);
 500     
 501   closure->cif  = cif;
 502   closure->user_data = user_data;
 503   closure->fun  = fun;
 504 
 505   return FFI_OK;
 506 }
 507+
 508+/* Below are routines for VFP hard-float support. */
 509+
 510+static int rec_vfp_type_p (ffi_type *t, int *elt, int *elnum)
 511+{
 512+  switch (t->type)
 513+    {
 514+    case FFI_TYPE_FLOAT:
 515+    case FFI_TYPE_DOUBLE:
 516+      *elt = (int) t->type;
 517+      *elnum = 1;
 518+      return 1;
 519+
 520+    case FFI_TYPE_STRUCT_VFP_FLOAT:
 521+      *elt = FFI_TYPE_FLOAT;
 522+      *elnum = t->size / sizeof (float);
 523+      return 1;
 524+
 525+    case FFI_TYPE_STRUCT_VFP_DOUBLE:
 526+      *elt = FFI_TYPE_DOUBLE;
 527+      *elnum = t->size / sizeof (double);
 528+      return 1;
 529+
 530+    case FFI_TYPE_STRUCT:;
 531+      {
 532+	int base_elt = 0, total_elnum = 0;
 533+	ffi_type **el = t->elements;
 534+	while (*el)
 535+	  {
 536+	    int el_elt = 0, el_elnum = 0;
 537+	    if (! rec_vfp_type_p (*el, &el_elt, &el_elnum)
 538+		|| (base_elt && base_elt != el_elt)
 539+		|| total_elnum + el_elnum > 4)
 540+	      return 0;
 541+	    base_elt = el_elt;
 542+	    total_elnum += el_elnum;
 543+	    el++;
 544+	  }
 545+	*elnum = total_elnum;
 546+	*elt = base_elt;
 547+	return 1;
 548+      }
 549+    default: ;
 550+    }
 551+  return 0;
 552+}
 553+
 554+static int vfp_type_p (ffi_type *t)
 555+{
 556+  int elt, elnum;
 557+  if (rec_vfp_type_p (t, &elt, &elnum))
 558+    {
 559+      if (t->type == FFI_TYPE_STRUCT)
 560+	{
 561+	  if (elnum == 1)
 562+	    t->type = elt;
 563+	  else
 564+	    t->type = (elt == FFI_TYPE_FLOAT
 565+		       ? FFI_TYPE_STRUCT_VFP_FLOAT
 566+		       : FFI_TYPE_STRUCT_VFP_DOUBLE);
 567+	}
 568+      return (int) t->type;
 569+    }
 570+  return 0;
 571+}
 572+
 573+static void place_vfp_arg (ffi_cif *cif, ffi_type *t)
 574+{
 575+  int reg = cif->vfp_reg_free;
 576+  int nregs = t->size / sizeof (float);
 577+  int align = ((t->type == FFI_TYPE_STRUCT_VFP_FLOAT
 578+		|| t->type == FFI_TYPE_FLOAT) ? 1 : 2);
 579+  /* Align register number. */
 580+  if ((reg & 1) && align == 2)
 581+    reg++;
 582+  while (reg + nregs <= 16)
 583+    {
 584+      int s, new_used = 0;
 585+      for (s = reg; s < reg + nregs; s++)
 586+	{
 587+	  new_used |= (1 << s);
 588+	  if (cif->vfp_used & (1 << s))
 589+	    {
 590+	      reg += align;
 591+	      goto next_reg;
 592+	    }
 593+	}
 594+      /* Found regs to allocate. */
 595+      cif->vfp_used |= new_used;
 596+      cif->vfp_args[cif->vfp_nargs++] = reg;
 597+
 598+      /* Update vfp_reg_free. */
 599+      if (cif->vfp_used & (1 << cif->vfp_reg_free))
 600+	{
 601+	  reg += nregs;
 602+	  while (cif->vfp_used & (1 << reg))
 603+	    reg += 1;
 604+	  cif->vfp_reg_free = reg;
 605+	}
 606+      return;
 607+    next_reg: ;
 608+    }
 609+}
 610+
 611+static void layout_vfp_args (ffi_cif *cif)
 612+{
 613+  int i;
 614+  /* Init VFP fields */
 615+  cif->vfp_used = 0;
 616+  cif->vfp_nargs = 0;
 617+  cif->vfp_reg_free = 0;
 618+  memset (cif->vfp_args, -1, 16); /* Init to -1. */
 619+
 620+  for (i = 0; i < cif->nargs; i++)
 621+    {
 622+      ffi_type *t = cif->arg_types[i];
 623+      if (vfp_type_p (t))
 624+	place_vfp_arg (cif, t);
 625+    }
 626+}
 627diff --git a/js/src/ctypes/libffi/src/arm/ffitarget.h b/js/src/ctypes/libffi/src/arm/ffitarget.h
 628--- a/js/src/ctypes/libffi/src/arm/ffitarget.h
 629+++ b/js/src/ctypes/libffi/src/arm/ffitarget.h
 630@@ -29,21 +29,35 @@
 631 
 632 #ifndef LIBFFI_ASM
 633 typedef unsigned long          ffi_arg;
 634 typedef signed long            ffi_sarg;
 635 
 636 typedef enum ffi_abi {
 637   FFI_FIRST_ABI = 0,
 638   FFI_SYSV,
 639+  FFI_VFP,
 640   FFI_LAST_ABI,
 641+#ifdef __ARM_PCS_VFP
 642+  FFI_DEFAULT_ABI = FFI_VFP
 643+#else
 644   FFI_DEFAULT_ABI = FFI_SYSV
 645+#endif
 646 } ffi_abi;
 647 #endif
 648 
 649+#define FFI_EXTRA_CIF_FIELDS			\
 650+  int vfp_used;					\
 651+  short vfp_reg_free, vfp_nargs;		\
 652+  signed char vfp_args[16]			\
 653+
 654+/* Internally used. */
 655+#define FFI_TYPE_STRUCT_VFP_FLOAT  (FFI_TYPE_LAST + 1)
 656+#define FFI_TYPE_STRUCT_VFP_DOUBLE (FFI_TYPE_LAST + 2)
 657+
 658 /* ---- Definitions for closures ----------------------------------------- */
 659 
 660 #define FFI_CLOSURES 1
 661 #define FFI_TRAMPOLINE_SIZE 20
 662 #define FFI_NATIVE_RAW_API 0
 663 
 664 #endif
 665 
 666diff --git a/js/src/ctypes/libffi/src/arm/sysv.S b/js/src/ctypes/libffi/src/arm/sysv.S
 667--- a/js/src/ctypes/libffi/src/arm/sysv.S
 668+++ b/js/src/ctypes/libffi/src/arm/sysv.S
 669@@ -137,54 +137,52 @@ _L__\name:
 670 	ldr\cond	pc, [sp], #4
 671 	.else
 672 	ldm\cond\dirn	sp!, {\regs, pc}
 673 	.endif
 674 #endif
 675 .endm
 676 
 677 
 678-	@ r0:   ffi_prep_args
 679+	@ r0:   fn
 680 	@ r1:   &ecif
 681 	@ r2:   cif->bytes
 682 	@ r3:   fig->flags
 683 	@ sp+0: ecif.rvalue
 684-	@ sp+4: fn
 685 
 686 	@ This assumes we are using gas.
 687 ARM_FUNC_START ffi_call_SYSV
 688 	@ Save registers
 689         stmfd	sp!, {r0-r3, fp, lr}
 690 	UNWIND .save	{r0-r3, fp, lr}
 691 	mov	fp, sp
 692 
 693 	UNWIND .setfp	fp, sp
 694 
 695 	@ Make room for all of the new args.
 696 	sub	sp, fp, r2
 697 
 698 	@ Place all of the ffi_prep_args in position
 699-	mov	ip, r0
 700 	mov	r0, sp
 701 	@     r1 already set
 702 
 703 	@ Call ffi_prep_args(stack, &ecif)
 704-	call_reg(ip)
 705+	bl	ffi_prep_args
 706 
 707 	@ move first 4 parameters in registers
 708 	ldmia	sp, {r0-r3}
 709 
 710 	@ and adjust stack
 711-	ldr	ip, [fp, #8]
 712-        cmp	ip, #16
 713-	movhs	ip, #16
 714-        add	sp, sp, ip
 715+	sub	lr, fp, sp	@ cif->bytes == fp - sp
 716+	ldr	ip, [fp]	@ load fn() in advance
 717+	cmp	lr, #16
 718+	movhs	lr, #16
 719+	add	sp, sp, lr
 720 
 721 	@ call (fn) (...)
 722-	ldr	ip, [fp, #28]
 723 	call_reg(ip)
 724 	
 725 	@ Remove the space we pushed for the args
 726 	mov	sp, fp
 727 
 728 	@ Load r2 with the pointer to storage for the return value
 729 	ldr	r2, [sp, #24]
 730 
 731@@ -225,16 +223,111 @@ ARM_FUNC_START ffi_call_SYSV
 732 
 733 LSYM(Lepilogue):
 734 	RETLDM	"r0-r3,fp"
 735 
 736 .ffi_call_SYSV_end:
 737 	UNWIND .fnend
 738         .size    CNAME(ffi_call_SYSV),.ffi_call_SYSV_end-CNAME(ffi_call_SYSV)
 739 
 740+
 741+	@ r0:   fn
 742+	@ r1:   &ecif
 743+	@ r2:   cif->bytes
 744+	@ r3:   fig->flags
 745+	@ sp+0: ecif.rvalue
 746+
 747+ARM_FUNC_START ffi_call_VFP
 748+	@ Save registers
 749+        stmfd	sp!, {r0-r3, fp, lr}
 750+	UNWIND .save	{r0-r3, fp, lr}
 751+	mov	fp, sp
 752+	UNWIND .setfp	fp, sp
 753+
 754+	@ Make room for all of the new args.
 755+	sub	sp, sp, r2
 756+
 757+	@ Make room for loading VFP args
 758+	sub	sp, sp, #64
 759+
 760+	@ Place all of the ffi_prep_args in position
 761+	mov	r0, sp
 762+	@     r1 already set
 763+	sub	r2, fp, #64   @ VFP scratch space
 764+
 765+	@ Call ffi_prep_args(stack, &ecif, vfp_space)
 766+	bl	ffi_prep_args
 767+
 768+	@ Load VFP register args if needed
 769+	cmp	r0, #0
 770+	beq	LSYM(Lbase_args)
 771+
 772+	@ Load only d0 if possible
 773+	cmp	r0, #3
 774+	sub	ip, fp, #64
 775+	flddle	d0, [ip]
 776+	fldmiadgt	ip, {d0-d7}
 777+
 778+LSYM(Lbase_args):
 779+	@ move first 4 parameters in registers
 780+	ldmia	sp, {r0-r3}
 781+
 782+	@ and adjust stack
 783+	sub	lr, ip, sp	@ cif->bytes == (fp - 64) - sp
 784+	ldr	ip, [fp]	@ load fn() in advance
 785+        cmp	lr, #16
 786+	movhs	lr, #16
 787+        add	sp, sp, lr
 788+
 789+	@ call (fn) (...)
 790+	call_reg(ip)
 791+
 792+	@ Remove the space we pushed for the args
 793+	mov	sp, fp
 794+
 795+	@ Load r2 with the pointer to storage for
 796+	@ the return value
 797+	ldr	r2, [sp, #24]
 798+
 799+	@ Load r3 with the return type code 
 800+	ldr	r3, [sp, #12]
 801+
 802+	@ If the return value pointer is NULL,
 803+	@ assume no return value.
 804+	cmp	r2, #0
 805+	beq	LSYM(Lepilogue_vfp)
 806+	
 807+	cmp	r3, #FFI_TYPE_INT
 808+	streq	r0, [r2]
 809+	beq	LSYM(Lepilogue_vfp)
 810+
 811+	cmp	r3, #FFI_TYPE_SINT64
 812+	stmeqia	r2, {r0, r1}
 813+	beq	LSYM(Lepilogue_vfp)
 814+
 815+	cmp	r3, #FFI_TYPE_FLOAT
 816+	fstseq	s0, [r2]
 817+	beq	LSYM(Lepilogue_vfp)
 818+	
 819+	cmp	r3, #FFI_TYPE_DOUBLE
 820+	fstdeq	d0, [r2]
 821+	beq	LSYM(Lepilogue_vfp)
 822+
 823+	cmp	r3, #FFI_TYPE_STRUCT_VFP_FLOAT
 824+	cmpne	r3, #FFI_TYPE_STRUCT_VFP_DOUBLE
 825+	fstmiadeq	r2, {d0-d3}
 826+
 827+LSYM(Lepilogue_vfp):
 828+	RETLDM	"r0-r3,fp"
 829+
 830+.ffi_call_VFP_end:
 831+	UNWIND .fnend
 832+        .size    CNAME(ffi_call_VFP),.ffi_call_VFP_end-CNAME(ffi_call_VFP)
 833+	
 834+	
 835 /*
 836 	unsigned int FFI_HIDDEN
 837 	ffi_closure_SYSV_inner (closure, respp, args)
 838 	     ffi_closure *closure;
 839 	     void **respp;
 840   	     void *args;
 841 */
 842 
 843@@ -297,11 +390,73 @@ ARM_FUNC_START ffi_closure_SYSV
 844 	ldfd	f0, [sp]
 845 	b	.Lclosure_epilogue
 846 #endif
 847 
 848 .ffi_closure_SYSV_end:
 849 	UNWIND .fnend
 850         .size    CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
 851 
 852+
 853+ARM_FUNC_START ffi_closure_VFP
 854+	fstmfdd	sp!, {d0-d7}
 855+	@ r0-r3, then d0-d7
 856+	UNWIND .pad #80
 857+	add	ip, sp, #80
 858+	stmfd	sp!, {ip, lr}
 859+	UNWIND .save	{r0, lr}
 860+	add	r2, sp, #72
 861+	add	r3, sp, #8
 862+	.pad #72
 863+	sub	sp, sp, #72
 864+	str	sp, [sp, #64]
 865+	add	r1, sp, #64
 866+	bl	ffi_closure_SYSV_inner
 867+
 868+	cmp	r0, #FFI_TYPE_INT
 869+	beq	.Lretint_vfp
 870+
 871+	cmp	r0, #FFI_TYPE_FLOAT
 872+	beq	.Lretfloat_vfp
 873+
 874+	cmp	r0, #FFI_TYPE_DOUBLE
 875+	cmpne	r0, #FFI_TYPE_LONGDOUBLE
 876+	beq	.Lretdouble_vfp
 877+
 878+	cmp	r0, #FFI_TYPE_SINT64
 879+	beq	.Lretlonglong_vfp
 880+
 881+	cmp	r0, #FFI_TYPE_STRUCT_VFP_FLOAT
 882+	beq	.Lretfloat_struct_vfp
 883+
 884+	cmp	r0, #FFI_TYPE_STRUCT_VFP_DOUBLE
 885+	beq	.Lretdouble_struct_vfp
 886+	
 887+.Lclosure_epilogue_vfp:
 888+	add	sp, sp, #72
 889+	ldmfd	sp, {sp, pc}
 890+
 891+.Lretfloat_vfp:
 892+	flds	s0, [sp]
 893+	b	.Lclosure_epilogue_vfp
 894+.Lretdouble_vfp:
 895+	fldd	d0, [sp]
 896+	b	.Lclosure_epilogue_vfp
 897+.Lretint_vfp:
 898+	ldr	r0, [sp]
 899+	b	.Lclosure_epilogue_vfp
 900+.Lretlonglong_vfp:
 901+	ldmia	sp, {r0, r1}
 902+	b	.Lclosure_epilogue_vfp
 903+.Lretfloat_struct_vfp:
 904+	fldmiad	sp, {d0-d1}
 905+	b	.Lclosure_epilogue_vfp
 906+.Lretdouble_struct_vfp:
 907+	fldmiad	sp, {d0-d3}
 908+	b	.Lclosure_epilogue_vfp
 909+
 910+.ffi_closure_VFP_end:
 911+	UNWIND .fnend
 912+        .size    CNAME(ffi_closure_VFP),.ffi_closure_VFP_end-CNAME(ffi_closure_VFP)
 913+
 914 #if defined __ELF__ && defined __linux__
 915 	.section	.note.GNU-stack,"",%progbits
 916 #endif
 917diff --git a/js/src/ctypes/libffi/testsuite/lib/libffi-dg.exp b/js/src/ctypes/libffi/testsuite/lib/libffi-dg.exp
 918--- a/js/src/ctypes/libffi/testsuite/lib/libffi-dg.exp
 919+++ b/js/src/ctypes/libffi/testsuite/lib/libffi-dg.exp
 920@@ -261,16 +261,66 @@ proc dg-xfail-if { args } {
 921     set args [lreplace $args 0 0]
 922     set selector "target [join [lindex $args 1]]"
 923     if { [dg-process-target $selector] == "S" } {
 924 	global compiler_conditional_xfail_data
 925 	set compiler_conditional_xfail_data $args
 926     }
 927 }
 928 
 929+proc check-flags { args } {
 930+
 931+    # The args are within another list; pull them out.
 932+    set args [lindex $args 0]
 933+
 934+    # The next two arguments are optional.  If they were not specified,
 935+    # use the defaults.
 936+    if { [llength $args] == 2 } {
 937+	lappend $args [list "*"]
 938+    }
 939+    if { [llength $args] == 3 } {
 940+	lappend $args [list ""]
 941+    }
 942+
 943+    # If the option strings are the defaults, or the same as the
 944+    # defaults, there is no need to call check_conditional_xfail to
 945+    # compare them to the actual options.
 946+    if { [string compare [lindex $args 2] "*"] == 0
 947+	 && [string compare [lindex $args 3] "" ] == 0 } {
 948+	set result 1    
 949+    } else {
 950+	# The target list might be an effective-target keyword, so replace
 951+	# the original list with "*-*-*", since we already know it matches.
 952+	set result [check_conditional_xfail [lreplace $args 1 1 "*-*-*"]]
 953+    }
 954+
 955+    return $result
 956+}
 957+
 958+proc dg-skip-if { args } {
 959+    # Verify the number of arguments.  The last two are optional.
 960+    set args [lreplace $args 0 0]
 961+    if { [llength $args] < 2 || [llength $args] > 4 } {
 962+        error "dg-skip-if 2: need 2, 3, or 4 arguments"
 963+    }
 964+
 965+    # Don't bother if we're already skipping the test.
 966+    upvar dg-do-what dg-do-what
 967+    if { [lindex ${dg-do-what} 1] == "N" } {
 968+      return
 969+    }
 970+
 971+    set selector [list target [lindex $args 1]]
 972+    if { [dg-process-target $selector] == "S" } {
 973+        if [check-flags $args] {
 974+            upvar dg-do-what dg-do-what
 975+            set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
 976+        }
 977+    }
 978+}
 979 
 980 # We need to make sure that additional_files and additional_sources
 981 # are both cleared out after every test.  It is not enough to clear
 982 # them out *before* the next test run because gcc-target-compile gets
 983 # run directly from some .exp files (outside of any test).  (Those
 984 # uses should eventually be eliminated.)
 985 
 986 # Because the DG framework doesn't provide a hook that is run at the
 987diff --git a/js/src/ctypes/libffi/testsuite/libffi.call/cls_double_va.c b/js/src/ctypes/libffi/testsuite/libffi.call/cls_double_va.c
 988--- a/js/src/ctypes/libffi/testsuite/libffi.call/cls_double_va.c
 989+++ b/js/src/ctypes/libffi/testsuite/libffi.call/cls_double_va.c
 990@@ -1,16 +1,18 @@
 991 /* Area:		ffi_call, closure_call
 992    Purpose:		Test doubles passed in variable argument lists.
 993    Limitations:	none.
 994    PR:			none.
 995    Originator:	Blake Chaffin 6/6/2007	 */
 996 
 997 /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
 998 /* { dg-output "" { xfail avr32*-*-* } } */
 999+/* { dg-skip-if "" arm*-*-* { "-mfloat-abi=hard" } { "" } } */
1000+
1001 #include "ffitest.h"
1002 
1003 static void
1004 cls_double_va_fn(ffi_cif* cif __UNUSED__, void* resp, 
1005 		 void** args, void* userdata __UNUSED__)
1006 {
1007 	char*	format		= *(char**)args[0];
1008 	double	doubleValue	= *(double*)args[1];
1009diff --git a/js/src/ctypes/libffi/testsuite/libffi.call/cls_longdouble_va.c b/js/src/ctypes/libffi/testsuite/libffi.call/cls_longdouble_va.c
1010--- a/js/src/ctypes/libffi/testsuite/libffi.call/cls_longdouble_va.c
1011+++ b/js/src/ctypes/libffi/testsuite/libffi.call/cls_longdouble_va.c
1012@@ -1,16 +1,18 @@
1013 /* Area:		ffi_call, closure_call
1014    Purpose:		Test long doubles passed in variable argument lists.
1015    Limitations:	none.
1016    PR:			none.
1017    Originator:	Blake Chaffin 6/6/2007	 */
1018 
1019 /* { dg-do run { xfail strongarm*-*-* xscale*-*-* } } */
1020 /* { dg-output "" { xfail avr32*-*-* x86_64-*-mingw* } } */
1021+/* { dg-skip-if "" arm*-*-* { "-mfloat-abi=hard" } { "" } } */
1022+
1023 #include "ffitest.h"
1024 
1025 static void
1026 cls_longdouble_va_fn(ffi_cif* cif __UNUSED__, void* resp, 
1027 		     void** args, void* userdata __UNUSED__)
1028 {
1029 	char*		format	= *(char**)args[0];
1030 	long double	ldValue	= *(long double*)args[1];
1031diff --git a/js/src/ctypes/libffi/include/ffi.h.in b/js/src/ctypes/libffi/include/ffi.h.in
1032--- a/js/src/ctypes/libffi/include/ffi.h.in
1033+++ b/js/src/ctypes/libffi/include/ffi.h.in
1034@@ -72,25 +72,37 @@ extern "C" {
1035 #endif
1036 
1037 #include <stddef.h>
1038 #include <limits.h>
1039 
1040 /* LONG_LONG_MAX is not always defined (not if STRICT_ANSI, for example).
1041    But we can find it either under the correct ANSI name, or under GNU
1042    C's internal name.  */
1043+
1044+#define FFI_64_BIT_MAX 9223372036854775807
1045+
1046 #ifdef LONG_LONG_MAX
1047 # define FFI_LONG_LONG_MAX LONG_LONG_MAX
1048 #else
1049 # ifdef LLONG_MAX
1050 #  define FFI_LONG_LONG_MAX LLONG_MAX
1051 # else
1052 #  ifdef __GNUC__
1053 #   define FFI_LONG_LONG_MAX __LONG_LONG_MAX__
1054 #  endif
1055+#  ifdef _AIX
1056+#   ifndef __PPC64__
1057+#    if defined (__IBMC__) || defined (__IBMCPP__)
1058+#     define FFI_LONG_LONG_MAX LONGLONG_MAX
1059+#    endif
1060+#   endif /* __PPC64__ */
1061+#   undef  FFI_64_BIT_MAX
1062+#   define FFI_64_BIT_MAX 9223372036854775807LL
1063+#  endif
1064 # endif
1065 #endif
1066 
1067 /* The closure code assumes that this works on pointers, i.e. a size_t	*/
1068 /* can hold a pointer.							*/
1069 
1070 typedef struct _ffi_type
1071 {
1072@@ -127,27 +139,27 @@ typedef struct _ffi_type
1073 #elif INT_MAX == 9223372036854775807
1074 # define ffi_type_uint         ffi_type_uint64
1075 # define ffi_type_sint         ffi_type_sint64
1076 #else
1077  #error "int size not supported"
1078 #endif
1079 
1080 #if LONG_MAX == 2147483647
1081-# if FFI_LONG_LONG_MAX != 9223372036854775807
1082+# if FFI_LONG_LONG_MAX != FFI_64_BIT_MAX
1083  #error "no 64-bit data type supported"
1084 # endif
1085-#elif LONG_MAX != 9223372036854775807
1086+#elif LONG_MAX != FFI_64_BIT_MAX
1087  #error "long size not supported"
1088 #endif
1089 
1090 #if LONG_MAX == 2147483647
1091 # define ffi_type_ulong        ffi_type_uint32
1092 # define ffi_type_slong        ffi_type_sint32
1093-#elif LONG_MAX == 9223372036854775807
1094+#elif LONG_MAX == FFI_64_BIT_MAX
1095 # define ffi_type_ulong        ffi_type_uint64
1096 # define ffi_type_slong        ffi_type_sint64
1097 #else
1098  #error "long size not supported"
1099 #endif
1100 
1101 /* These are defined in types.c */
1102 extern ffi_type ffi_type_void;
1103@@ -190,17 +202,17 @@ typedef struct {
1104 #endif
1105 } ffi_cif;
1106 
1107 /* ---- Definitions for the raw API -------------------------------------- */
1108 
1109 #ifndef FFI_SIZEOF_ARG
1110 # if LONG_MAX == 2147483647
1111 #  define FFI_SIZEOF_ARG        4
1112-# elif LONG_MAX == 9223372036854775807
1113+# elif LONG_MAX == FFI_64_BIT_MAX
1114 #  define FFI_SIZEOF_ARG        8
1115 # endif
1116 #endif
1117 
1118 #ifndef FFI_SIZEOF_JAVA_RAW
1119 #  define FFI_SIZEOF_JAVA_RAW FFI_SIZEOF_ARG
1120 #endif
1121 
1122diff --git a/js/src/ctypes/libffi/configure.ac b/js/src/ctypes/libffi/configure.ac
1123--- a/js/src/ctypes/libffi/configure.ac
1124+++ b/js/src/ctypes/libffi/configure.ac
1125@@ -272,20 +272,20 @@ if test x$TARGET = xSPARC; then
1126        AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
1127 	       [Define if your assembler supports .register.])
1128     fi
1129 fi
1130 
1131 if test x$TARGET = xX86 || test x$TARGET = xX86_WIN32 || test x$TARGET = xX86_64; then
1132     AC_CACHE_CHECK([assembler supports pc related relocs],
1133 	libffi_cv_as_x86_pcrel, [
1134-	libffi_cv_as_x86_pcrel=yes
1135+	libffi_cv_as_x86_pcrel=no
1136 	echo '.text; foo: nop; .data; .long foo-.; .text' > conftest.s
1137-	if $CC $CFLAGS -c conftest.s 2>&1 | $EGREP -i 'illegal|warning' > /dev/null; then
1138-	    libffi_cv_as_x86_pcrel=no
1139+	if $CC $CFLAGS -c conftest.s > /dev/null; then
1140+	    libffi_cv_as_x86_pcrel=yes
1141 	fi
1142 	])
1143     if test "x$libffi_cv_as_x86_pcrel" = xyes; then
1144 	AC_DEFINE(HAVE_AS_X86_PCREL, 1,
1145 		  [Define if your assembler supports PC relative relocs.])
1146     fi
1147 
1148     AC_CACHE_CHECK([assembler .ascii pseudo-op support],
1149diff --git a/js/src/ctypes/libffi/config.sub b/js/src/ctypes/libffi/config.sub
1150--- a/js/src/ctypes/libffi/config.sub
1151+++ b/js/src/ctypes/libffi/config.sub
1152@@ -1,15 +1,15 @@
1153 #! /bin/sh
1154 # Configuration validation subroutine script.
1155 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
1156 #   2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
1157 #   Free Software Foundation, Inc.
1158 
1159-timestamp='2009-11-07'
1160+timestamp='2011-01-03'
1161 
1162 # This file is (in principle) common to ALL GNU software.
1163 # The presence of a machine in this file suggests that SOME GNU software
1164 # can handle that machine.  It does not imply ALL GNU software can.
1165 #
1166 # This file is free software; you can redistribute it and/or modify
1167 # it under the terms of the GNU General Public License as published by
1168 # the Free Software Foundation; either version 2 of the License, or
1169@@ -121,17 +121,17 @@ esac
1170 
1171 # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
1172 # Here we must recognize all the valid KERNEL-OS combinations.
1173 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
1174 case $maybe_os in
1175   nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
1176   uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
1177   kopensolaris*-gnu* | \
1178-  storm-chaos* | os2-emx* | rtmk-nova*)
1179+  storm-chaos* | os2-emx* | rtmk-nova* | wince-winmo*)
1180     os=-$maybe_os
1181     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
1182     ;;
1183   *)
1184     basic_machine=`echo $1 | sed 's/-[^-]*$//'`
1185     if [ $basic_machine != $1 ]
1186     then os=`echo $1 | sed 's/.*-/-/'`
1187     else os=; fi
1188@@ -282,32 +282,30 @@ case $basic_machine in
1189 	| mt \
1190 	| msp430 \
1191 	| nios | nios2 \
1192 	| ns16k | ns32k \
1193 	| or32 \
1194 	| pdp10 | pdp11 | pj | pjl \
1195 	| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
1196 	| pyramid \
1197-	| rx \
1198 	| score \
1199 	| sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
1200 	| sh64 | sh64le \
1201 	| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
1202 	| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
1203 	| spu | strongarm \
1204 	| tahoe | thumb | tic4x | tic80 | tron \
1205-	| ubicom32 \
1206 	| v850 | v850e \
1207 	| we32k \
1208 	| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
1209 	| z8k | z80)
1210 		basic_machine=$basic_machine-unknown
1211 		;;
1212-	m6811 | m68hc11 | m6812 | m68hc12 | picochip)
1213+	m6811 | m68hc11 | m6812 | m68hc12)
1214 		# Motorola 68HC11/12.
1215 		basic_machine=$basic_machine-unknown
1216 		os=-none
1217 		;;
1218 	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
1219 		;;
1220 	ms1)
1221 		basic_machine=mt-unknown
1222@@ -368,26 +366,25 @@ case $basic_machine in
1223 	| mt-* \
1224 	| msp430-* \
1225 	| nios-* | nios2-* \
1226 	| none-* | np1-* | ns16k-* | ns32k-* \
1227 	| orion-* \
1228 	| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
1229 	| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
1230 	| pyramid-* \
1231-	| romp-* | rs6000-* | rx-* \
1232+	| romp-* | rs6000-* \
1233 	| sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
1234 	| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
1235 	| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
1236 	| sparclite-* \
1237 	| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
1238 	| tahoe-* | thumb-* \
1239 	| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \
1240 	| tron-* \
1241-	| ubicom32-* \
1242 	| v850-* | v850e-* | vax-* \
1243 	| we32k-* \
1244 	| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
1245 	| xstormy16-* | xtensa*-* \
1246 	| ymp-* \
1247 	| z8k-* | z80-*)
1248 		;;
1249 	# Recognize the basic CPU types without company name, with glob match.
1250@@ -1294,17 +1291,17 @@ case $os in
1251 	      | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
1252 	      | -uxpv* | -beos* | -mpeix* | -udk* \
1253 	      | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
1254 	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
1255 	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
1256 	      | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
1257 	      | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
1258 	      | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
1259-	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
1260+	      | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -winmo*)
1261 	# Remember, each alternative MUST END IN *, to match a version number.
1262 		;;
1263 	-qnx*)
1264 		case $basic_machine in
1265 		    x86-* | i*86-*)
1266 			;;
1267 		    *)
1268 			os=-nto$os
1269@@ -1336,16 +1333,19 @@ case $os in
1270 		os=`echo $os | sed -e 's|sunos6|solaris3|'`
1271 		;;
1272 	-opened*)
1273 		os=-openedition
1274 		;;
1275         -os400*)
1276 		os=-os400
1277 		;;
1278+	-wince-winmo*)
1279+		os=-wince-winmo
1280+		;;
1281 	-wince*)
1282 		os=-wince
1283 		;;
1284 	-osfrose*)
1285 		os=-osfrose
1286 		;;
1287 	-osf*)
1288 		os=-osf
1289@@ -1427,16 +1427,19 @@ case $os in
1290 		os=-kaos
1291 		;;
1292 	-zvmoe)
1293 		os=-zvmoe
1294 		;;
1295 	-dicos*)
1296 		os=-dicos
1297 		;;
1298+        -android*)
1299+	        os=-android
1300+                ;;
1301 	-none)
1302 		;;
1303 	*)
1304 		# Get rid of the `-' at the beginning of $os.
1305 		os=`echo $os | sed 's/[^-]*-//'`
1306 		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
1307 		exit 1
1308 		;;
1309@@ -1681,16 +1684,19 @@ case $basic_machine in
1310 				vendor=apple
1311 				;;
1312 			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
1313 				vendor=atari
1314 				;;
1315 			-vos*)
1316 				vendor=stratus
1317 				;;
1318+			*-android*|*-linuxandroid*)
1319+				vendor=linux-
1320+				;;
1321 		esac
1322 		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
1323 		;;
1324 esac
1325 
1326 echo $basic_machine$os
1327 exit
1328