/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

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