]>
Commit | Line | Data |
---|---|---|
9b850dd9 | 1 | /* Area: ffi_call |
b1760f7f | 2 | Purpose: Check strlen function call with additional arguments. |
9b850dd9 KT |
3 | Limitations: none. |
4 | PR: none. | |
5 | Originator: From the original ffitest.c */ | |
6 | ||
b1760f7f | 7 | /* { dg-do run } */ |
9b850dd9 KT |
8 | |
9 | #include "ffitest.h" | |
10 | ||
b1760f7f | 11 | static size_t ABI_ATTR my_f(char *s, float a) |
9b850dd9 KT |
12 | { |
13 | return (size_t) ((int) strlen(s) + (int) a); | |
14 | } | |
15 | ||
16 | int main (void) | |
17 | { | |
18 | ffi_cif cif; | |
19 | ffi_type *args[MAX_ARGS]; | |
20 | void *values[MAX_ARGS]; | |
21 | ffi_arg rint; | |
22 | char *s; | |
23 | float v2; | |
24 | args[0] = &ffi_type_pointer; | |
25 | args[1] = &ffi_type_float; | |
26 | values[0] = (void*) &s; | |
27 | values[1] = (void*) &v2; | |
28 | ||
29 | /* Initialize the cif */ | |
b1760f7f | 30 | CHECK(ffi_prep_cif(&cif, ABI_NUM, 2, |
9b850dd9 KT |
31 | &ffi_type_sint, args) == FFI_OK); |
32 | ||
33 | s = "a"; | |
34 | v2 = 0.0; | |
b1760f7f | 35 | ffi_call(&cif, FFI_FN(my_f), &rint, values); |
9b850dd9 KT |
36 | CHECK(rint == 1); |
37 | ||
38 | s = "1234567"; | |
39 | v2 = -1.0; | |
b1760f7f | 40 | ffi_call(&cif, FFI_FN(my_f), &rint, values); |
9b850dd9 KT |
41 | CHECK(rint == 6); |
42 | ||
43 | s = "1234567890123456789012345"; | |
44 | v2 = 1.0; | |
b1760f7f | 45 | ffi_call(&cif, FFI_FN(my_f), &rint, values); |
9b850dd9 KT |
46 | CHECK(rint == 26); |
47 | ||
9b850dd9 KT |
48 | exit(0); |
49 | } |