bdf08742f8eb53e9ce7b40a42c543ed68e6a3577
[platform/upstream/libffi.git] / patches / fix-xfails
1 Index: libffi/ChangeLog
2 ===================================================================
3 --- libffi.orig/ChangeLog
4 +++ libffi/ChangeLog
5 @@ -1,6 +1,11 @@
6  2011-02-09  Anthony Green <green@moxielogic.com>
7  
8 -       * README: Mention ARM iOS.
9 +       * testsuite/libffi.call/err_bad_typedef.c: Remove xfail.
10 +       * testsuite/libffi.call/err_bad_abi.c: Remove xfail.
11 +       * src/x86/ffi64.c (UNLIKELY, LIKELY): Define.
12 +       (ffi_prep_closure_loc): Check for bad ABI.
13 +       * src/prep_cif.c (UNLIKELY, LIKELY): Define.
14 +       (initialize_aggregate): Check for bad types.
15  
16  2011-02-09  Landon Fuller <landonf@macports.org>
17  
18 @@ -20,6 +25,7 @@
19         * src/closures.c: Handle FFI_EXEC_TRAMPOLINE_TABLE case.
20         * build-ios.sh: New file.
21         * fficonfig.h.in, configure, Makefile.in: Rebuilt.
22 +       * README: Mention ARM iOS.
23  
24  2011-02-08  Oren Held  <orenhe@il.ibm.com>
25  
26 Index: libffi/src/prep_cif.c
27 ===================================================================
28 --- libffi.orig/src/prep_cif.c
29 +++ libffi/src/prep_cif.c
30 @@ -1,5 +1,6 @@
31  /* -----------------------------------------------------------------------
32 -   prep_cif.c - Copyright (c) 1996, 1998, 2007  Red Hat, Inc.
33 +   prep_cif.c - Copyright (c) 2011  Anthony Green
34 +                Copyright (c) 1996, 1998, 2007  Red Hat, Inc.
35  
36     Permission is hereby granted, free of charge, to any person obtaining
37     a copy of this software and associated documentation files (the
38 @@ -26,6 +27,12 @@
39  #include <ffi_common.h>
40  #include <stdlib.h>
41  
42 +#ifndef __GNUC__
43 +#define __builtin_expect(x, expected_value) (x)
44 +#endif
45 +#define LIKELY(x)    __builtin_expect((x),1)
46 +#define UNLIKELY(x)  __builtin_expect((x),1)
47 +
48  /* Round up to FFI_SIZEOF_ARG. */
49  
50  #define STACK_ARG_SIZE(x) ALIGN(x, FFI_SIZEOF_ARG)
51 @@ -45,9 +52,13 @@ static ffi_status initialize_aggregate(f
52  
53    ptr = &(arg->elements[0]);
54  
55 +  if (UNLIKELY(ptr == 0))
56 +    return FFI_BAD_TYPEDEF;
57 +
58    while ((*ptr) != NULL)
59      {
60 -      if (((*ptr)->size == 0) && (initialize_aggregate((*ptr)) != FFI_OK))
61 +      if (UNLIKELY(((*ptr)->size == 0)
62 +                   && (initialize_aggregate((*ptr)) != FFI_OK)))
63         return FFI_BAD_TYPEDEF;
64  
65        /* Perform a sanity check on the argument type */
66 @@ -93,7 +104,8 @@ ffi_status ffi_prep_cif(ffi_cif *cif, ff
67    ffi_type **ptr;
68  
69    FFI_ASSERT(cif != NULL);
70 -  FFI_ASSERT(abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI);
71 +  if (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI))
72 +    return FFI_BAD_ABI;
73  
74    cif->abi = abi;
75    cif->arg_types = atypes;
76 Index: libffi/src/x86/ffi64.c
77 ===================================================================
78 --- libffi.orig/src/x86/ffi64.c
79 +++ libffi/src/x86/ffi64.c
80 @@ -28,6 +28,12 @@
81  #include <ffi.h>
82  #include <ffi_common.h>
83  
84 +#ifndef __GNUC__
85 +#define __builtin_expect(x, expected_value) (x)
86 +#endif
87 +#define LIKELY(x)    __builtin_expect((x),1)
88 +#define UNLIKELY(x)  __builtin_expect((x),1)
89 +
90  #include <stdlib.h>
91  #include <stdarg.h>
92  
93 @@ -498,6 +504,13 @@ ffi_prep_closure_loc (ffi_closure* closu
94  {
95    volatile unsigned short *tramp;
96  
97 +  /* Sanity check on the cif ABI.  */
98 +  {
99 +    int abi = cif->abi;
100 +    if (UNLIKELY (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI)))
101 +      return FFI_BAD_ABI;
102 +  }
103 +
104    tramp = (volatile unsigned short *) &closure->tramp[0];
105  
106    tramp[0] = 0xbb49;           /* mov <code>, %r11     */
107 Index: libffi/testsuite/libffi.call/err_bad_abi.c
108 ===================================================================
109 --- libffi.orig/testsuite/libffi.call/err_bad_abi.c
110 +++ libffi/testsuite/libffi.call/err_bad_abi.c
111 @@ -4,7 +4,6 @@
112     PR:                 none.
113     Originator: Blake Chaffin 6/6/2007   */
114  
115 -/* { dg-do run { xfail *-*-* } } */
116  #include "ffitest.h"
117  
118  static void
119 Index: libffi/testsuite/libffi.call/err_bad_typedef.c
120 ===================================================================
121 --- libffi.orig/testsuite/libffi.call/err_bad_typedef.c
122 +++ libffi/testsuite/libffi.call/err_bad_typedef.c
123 @@ -4,7 +4,6 @@
124     PR:                 none.
125     Originator: Blake Chaffin 6/6/2007   */
126  
127 -/* { dg-do run { xfail *-*-* } } */
128  #include "ffitest.h"
129  
130  int main (void)