| 1 |
#include <stdlib.h> |
| 2 |
|
| 3 |
#include <ISO_Fortran_binding.h> |
| 4 |
#include "dump-descriptors.h" |
| 5 |
|
| 6 |
extern void ctest1 (CFI_cdesc_t *a); |
| 7 |
extern void ctest2 (CFI_cdesc_t *a); |
| 8 |
|
| 9 |
static void |
| 10 |
ctest (CFI_cdesc_t *a) |
| 11 |
{ |
| 12 |
int i; |
| 13 |
int *p; |
| 14 |
|
| 15 |
/* Dump the descriptor contents to test that we can access the fields |
| 16 |
correctly, etc. */ |
| 17 |
dump_CFI_cdesc_t (a); |
| 18 |
|
| 19 |
/* Make sure we got a valid descriptor. */ |
| 20 |
if (!a->base_addr) |
| 21 |
abort (); |
| 22 |
if (a->elem_len != sizeof(int)) |
| 23 |
abort (); |
| 24 |
if (a->rank != 1) |
| 25 |
abort (); |
| 26 |
if (a->type != CFI_type_int) |
| 27 |
abort (); |
| 28 |
if (a->attribute != CFI_attribute_other) |
| 29 |
abort (); |
| 30 |
if (a->dim[0].sm != sizeof(int)) |
| 31 |
abort (); |
| 32 |
if (!CFI_is_contiguous (a)) |
| 33 |
abort (); |
| 34 |
|
| 35 |
/* Negate the elements of the array. */ |
| 36 |
p = (int *)a->base_addr; |
| 37 |
for (i = 0; i < a->dim[0].extent; i++) |
| 38 |
p[i] = -p[i]; |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
/* The two entry points are declared differently on the C side, but both |
| 43 |
should do the same thing. */ |
| 44 |
|
| 45 |
void |
| 46 |
ctest1 (CFI_cdesc_t *a) |
| 47 |
{ |
| 48 |
ctest (a); |
| 49 |
} |
| 50 |
|
| 51 |
void |
| 52 |
ctest2 (CFI_cdesc_t *a) |
| 53 |
{ |
| 54 |
ctest (a); |
| 55 |
} |
| 56 |
|