2d37b2ee6718f3e67bdbe925a89f83137ef5b882
[platform/upstream/libffi.git] / patches / fix-xfails
1 Index: libffi/ChangeLog
2 ===================================================================
3 --- libffi.orig/ChangeLog
4 +++ libffi/ChangeLog
5 @@ -113,7 +113,12 @@
6  
7  2011-02-09  Anthony Green <green@moxielogic.com>
8  
9 -       * README: Mention ARM iOS.
10 +       * testsuite/libffi.call/err_bad_typedef.c: Remove xfail.
11 +       * testsuite/libffi.call/err_bad_abi.c: Remove xfail.
12 +       * src/x86/ffi64.c (UNLIKELY, LIKELY): Define.
13 +       (ffi_prep_closure_loc): Check for bad ABI.
14 +       * src/prep_cif.c (UNLIKELY, LIKELY): Define.
15 +       (initialize_aggregate): Check for bad types.
16  
17  2011-02-09  Landon Fuller <landonf@macports.org>
18  
19 @@ -133,6 +138,7 @@
20         * src/closures.c: Handle FFI_EXEC_TRAMPOLINE_TABLE case.
21         * build-ios.sh: New file.
22         * fficonfig.h.in, configure, Makefile.in: Rebuilt.
23 +       * README: Mention ARM iOS.
24  
25  2011-02-08  Oren Held  <orenhe@il.ibm.com>
26  
27 Index: libffi/src/prep_cif.c
28 ===================================================================
29 --- libffi.orig/src/prep_cif.c
30 +++ libffi/src/prep_cif.c
31 @@ -1,5 +1,5 @@
32  /* -----------------------------------------------------------------------
33 -   prep_cif.c - Copyright (c) 2012  Anthony Green
34 +   prep_cif.c - Copyright (c) 2011, 2012  Anthony Green
35                  Copyright (c) 1996, 1998, 2007  Red Hat, Inc.
36  
37     Permission is hereby granted, free of charge, to any person obtaining
38 @@ -27,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 @@ -46,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 @@ -95,10 +105,11 @@ ffi_status ffi_prep_cif(ffi_cif *cif, ff
67  
68    FFI_ASSERT(cif != NULL);
69  #ifndef X86_WIN32
70 -  FFI_ASSERT((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI));
71 +  if ((abi > FFI_FIRST_ABI) && (abi <= FFI_DEFAULT_ABI))
72 +    return FFI_BAD_ABI;
73  #else
74 -  FFI_ASSERT(abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI
75 -            || abi == FFI_THISCALL);
76 +  if (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI || abi == FFI_THISCALL)
77 +    return FFI_BAD_ABI;
78  #endif
79  
80    cif->abi = abi;
81 Index: libffi/src/x86/ffi64.c
82 ===================================================================
83 --- libffi.orig/src/x86/ffi64.c
84 +++ libffi/src/x86/ffi64.c
85 @@ -28,6 +28,12 @@
86  #include <ffi.h>
87  #include <ffi_common.h>
88  
89 +#ifndef __GNUC__
90 +#define __builtin_expect(x, expected_value) (x)
91 +#endif
92 +#define LIKELY(x)    __builtin_expect((x),1)
93 +#define UNLIKELY(x)  __builtin_expect((x),1)
94 +
95  #include <stdlib.h>
96  #include <stdarg.h>
97  
98 @@ -498,6 +504,13 @@ ffi_prep_closure_loc (ffi_closure* closu
99  {
100    volatile unsigned short *tramp;
101  
102 +  /* Sanity check on the cif ABI.  */
103 +  {
104 +    int abi = cif->abi;
105 +    if (UNLIKELY (! (abi > FFI_FIRST_ABI && abi < FFI_LAST_ABI)))
106 +      return FFI_BAD_ABI;
107 +  }
108 +
109    tramp = (volatile unsigned short *) &closure->tramp[0];
110  
111    tramp[0] = 0xbb49;           /* mov <code>, %r11     */
112 Index: libffi/testsuite/libffi.call/err_bad_abi.c
113 ===================================================================
114 --- libffi.orig/testsuite/libffi.call/err_bad_abi.c
115 +++ libffi/testsuite/libffi.call/err_bad_abi.c
116 @@ -4,7 +4,8 @@
117     PR:                 none.
118     Originator: Blake Chaffin 6/6/2007   */
119  
120 -/* { dg-do run { xfail *-*-* } } */
121 +/* { dg-do run } */
122 +
123  #include "ffitest.h"
124  
125  static void
126 Index: libffi/testsuite/libffi.call/err_bad_typedef.c
127 ===================================================================
128 --- libffi.orig/testsuite/libffi.call/err_bad_typedef.c
129 +++ libffi/testsuite/libffi.call/err_bad_typedef.c
130 @@ -4,7 +4,8 @@
131     PR:                 none.
132     Originator: Blake Chaffin 6/6/2007   */
133  
134 -/* { dg-do run { xfail *-*-* } } */
135 +/* { dg-do run } */
136 +
137  #include "ffitest.h"
138  
139  int main (void)