5b307598c7edc86802b20f1c04c4e625add506d4
[platform/upstream/libffi.git] / testsuite / libffi.call / err_bad_abi.c
1 /* Area:                ffi_prep_cif, ffi_prep_closure
2    Purpose:             Test error return for bad ABIs.
3    Limitations: none.
4    PR:                  none.
5    Originator:  Blake Chaffin 6/6/2007   */
6
7 #include "ffitest.h"
8
9 static void
10 dummy_fn(ffi_cif* cif __UNUSED__, void* resp __UNUSED__, 
11          void** args __UNUSED__, void* userdata __UNUSED__)
12 {}
13
14 int main (void)
15 {
16         ffi_cif cif;
17         void *code;
18         ffi_closure *pcl = ffi_closure_alloc(sizeof(ffi_closure), &code);
19         ffi_type* arg_types[1];
20
21         arg_types[0] = NULL;
22
23         CHECK(ffi_prep_cif(&cif, 255, 0, &ffi_type_void,
24                 arg_types) == FFI_BAD_ABI);
25
26         CHECK(ffi_prep_cif(&cif, FFI_DEFAULT_ABI, 0, &ffi_type_void,
27                 arg_types) == FFI_OK);
28
29         cif.abi= 255;
30
31         CHECK(ffi_prep_closure_loc(pcl, &cif, dummy_fn, NULL, code) == FFI_BAD_ABI);
32
33         exit(0);
34 }