1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
#include <ISO_Fortran_binding.h>
intptr_t assumed_rank_alloc_f (CFI_cdesc_t *);
intptr_t assumed_rank_pointer_f (CFI_cdesc_t *);
intptr_t assumed_rank_f (CFI_cdesc_t *);
intptr_t assumed_rank_cont_f (CFI_cdesc_t *);
intptr_t assumed_shape_f (CFI_cdesc_t *);
intptr_t assumed_shape_cont_f (CFI_cdesc_t *);
intptr_t deferred_shape_alloc_f (CFI_cdesc_t *);
intptr_t deferred_shape_pointer_f (CFI_cdesc_t *);
static void
basic_check(CFI_cdesc_t *x)
{
if (!x->base_addr)
__builtin_abort ();
if (x->elem_len != sizeof(int32_t))
__builtin_abort ();
if (x->version != CFI_VERSION)
__builtin_abort ();
if (x->rank != 4)
__builtin_abort ();
if (x->type != CFI_type_int32_t)
__builtin_abort ();
if (x->attribute == CFI_attribute_other)
{
if (x->dim[0].lower_bound != 0)
__builtin_abort ();
if (x->dim[1].lower_bound != 0)
__builtin_abort ();
if (x->dim[2].lower_bound != 0)
__builtin_abort ();
if (x->dim[3].lower_bound != 0)
__builtin_abort ();
}
}
intptr_t
assumed_rank_alloc_c (CFI_cdesc_t *x)
{
basic_check (x);
if (!CFI_is_contiguous (x))
__builtin_abort ();
if (x->attribute != CFI_attribute_allocatable)
__builtin_abort ();
intptr_t addr = (intptr_t) x->base_addr;
intptr_t addr2 = assumed_rank_alloc_f (x);
if (addr != addr2 || addr != (intptr_t) x->base_addr)
__builtin_abort ();
return addr;
}
intptr_t
assumed_rank_pointer_c (CFI_cdesc_t *x)
{
basic_check (x);
if (x->attribute != CFI_attribute_pointer)
__builtin_abort ();
intptr_t addr = (intptr_t) x->base_addr;
intptr_t addr2 = assumed_rank_pointer_f (x);
if (addr != addr2 || addr != (intptr_t) x->base_addr)
__builtin_abort ();
return addr;
}
intptr_t
assumed_rank_c (CFI_cdesc_t *x)
{
basic_check (x);
if (x->attribute != CFI_attribute_other)
__builtin_abort ();
intptr_t addr = (intptr_t) x->base_addr;
intptr_t addr2 = assumed_rank_f (x);
if (addr != addr2 || addr != (intptr_t) x->base_addr)
__builtin_abort ();
return addr;
}
intptr_t
assumed_rank_cont_c (CFI_cdesc_t *x)
{
basic_check (x);
if (!CFI_is_contiguous (x))
__builtin_abort ();
if (x->attribute != CFI_attribute_other)
__builtin_abort ();
intptr_t addr = (intptr_t) x->base_addr;
intptr_t addr2 = assumed_rank_cont_f (x);
if (addr != addr2 || addr != (intptr_t) x->base_addr)
__builtin_abort ();
return addr;
}
intptr_t
assumed_shape_c (CFI_cdesc_t *x, int num)
{
basic_check (x);
if (x->attribute != CFI_attribute_other)
__builtin_abort ();
intptr_t addr = (intptr_t) x->base_addr;
intptr_t addr2;
if (num == 1 || num == 2 || num == 3)
{
if (!CFI_is_contiguous (x))
__builtin_abort ();
}
else
{
if (CFI_is_contiguous (x))
__builtin_abort ();
}
if (num == 1 || num == 4)
addr2 = assumed_shape_f (x);
else if (num == 2 || num == 5)
addr2 = assumed_shape_cont_f (x);
else if (num == 3 || num == 6)
addr2 = assumed_rank_cont_f (x);
else
__builtin_abort ();
if (num == 1 || num == 2 || num == 3)
{
if (addr != addr2)
__builtin_abort ();
}
else
{
if (CFI_is_contiguous (x))
__builtin_abort ();
}
if (addr != (intptr_t) x->base_addr)
__builtin_abort ();
return addr2;
}
intptr_t
assumed_shape_cont_c (CFI_cdesc_t *x)
{
basic_check (x);
if (!CFI_is_contiguous (x))
__builtin_abort ();
if (x->attribute != CFI_attribute_other)
__builtin_abort ();
intptr_t addr = (intptr_t) x->base_addr;
intptr_t addr2 = assumed_shape_cont_f (x);
if (addr != addr2 || addr != (intptr_t) x->base_addr)
__builtin_abort ();
return addr;
}
intptr_t
deferred_shape_alloc_c (CFI_cdesc_t *x)
{
basic_check (x);
if (!CFI_is_contiguous (x))
__builtin_abort ();
if (x->attribute != CFI_attribute_allocatable)
__builtin_abort ();
intptr_t addr = (intptr_t) x->base_addr;
intptr_t addr2 = deferred_shape_alloc_f (x);
if (addr != addr2 || addr != (intptr_t) x->base_addr)
__builtin_abort ();
return addr;
}
intptr_t
deferred_shape_pointer_c (CFI_cdesc_t *x)
{
basic_check (x);
if (x->attribute != CFI_attribute_pointer)
__builtin_abort ();
intptr_t addr = (intptr_t) x->base_addr;
intptr_t addr2 = deferred_shape_pointer_f (x);
if (addr != addr2 || addr != (intptr_t) x->base_addr)
__builtin_abort ();
return addr;
}
|