File size: 4,951 Bytes
3dcad1f |
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 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
/* Copyright 2010-2011,2018
Free Software Foundation, Inc.
This file is part of Guile.
Guile is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Guile is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public
License along with Guile. If not, see
<https://www.gnu.org/licenses/>. */
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <string.h>
#include <libguile.h>
void test_ffi_v_ (void);
void test_ffi_v_ (void)
{
return;
}
void test_ffi_v_u8 (uint8_t a);
void test_ffi_v_u8 (uint8_t a)
{
return;
}
void test_ffi_v_s64 (int64_t a);
void test_ffi_v_s64 (int64_t a)
{
return;
}
int8_t test_ffi_s8_ (void);
int8_t test_ffi_s8_ (void)
{
return -100;
}
int8_t test_ffi_s8_u8 (uint8_t a);
int8_t test_ffi_s8_u8 (uint8_t a)
{
return -100 + a;
}
int8_t test_ffi_s8_s64 (int64_t a);
int8_t test_ffi_s8_s64 (int64_t a)
{
return -100 + a;
}
uint8_t test_ffi_u8_ (void);
uint8_t test_ffi_u8_ (void)
{
return 200;
}
uint8_t test_ffi_u8_u8 (uint8_t a);
uint8_t test_ffi_u8_u8 (uint8_t a)
{
return 200 + a;
}
uint8_t test_ffi_u8_s64 (int64_t a);
uint8_t test_ffi_u8_s64 (int64_t a)
{
return 200 + a;
}
int16_t test_ffi_s16_ (void);
int16_t test_ffi_s16_ (void)
{
return -20000;
}
int16_t test_ffi_s16_u8 (uint8_t a);
int16_t test_ffi_s16_u8 (uint8_t a)
{
return -20000 + a;
}
int16_t test_ffi_s16_s64 (int64_t a);
int16_t test_ffi_s16_s64 (int64_t a)
{
return -20000 + a;
}
uint16_t test_ffi_u16_ (void);
uint16_t test_ffi_u16_ (void)
{
return 40000;
}
uint16_t test_ffi_u16_u8 (uint8_t a);
uint16_t test_ffi_u16_u8 (uint8_t a)
{
return 40000 + a;
}
uint16_t test_ffi_u16_s64 (int64_t a);
uint16_t test_ffi_u16_s64 (int64_t a)
{
return 40000 + a;
}
int32_t test_ffi_s32_ (void);
int32_t test_ffi_s32_ (void)
{
return -2000000000;
}
int32_t test_ffi_s32_u8 (uint8_t a);
int32_t test_ffi_s32_u8 (uint8_t a)
{
return -2000000000 + a;
}
int32_t test_ffi_s32_s64 (int64_t a);
int32_t test_ffi_s32_s64 (int64_t a)
{
return -2000000000 + a;
}
uint32_t test_ffi_u32_ (void);
uint32_t test_ffi_u32_ (void)
{
return 4000000000U;
}
uint32_t test_ffi_u32_u8 (uint8_t a);
uint32_t test_ffi_u32_u8 (uint8_t a)
{
return 4000000000U + a;
}
uint32_t test_ffi_u32_s64 (int64_t a);
uint32_t test_ffi_u32_s64 (int64_t a)
{
return 4000000000U + a;
}
/* FIXME: use 64-bit literals */
int64_t test_ffi_s64_ (void);
int64_t test_ffi_s64_ (void)
{
return -2000000000;
}
int64_t test_ffi_s64_u8 (uint8_t a);
int64_t test_ffi_s64_u8 (uint8_t a)
{
return -2000000000 + a;
}
int64_t test_ffi_s64_s64 (int64_t a);
int64_t test_ffi_s64_s64 (int64_t a)
{
return -2000000000 + a;
}
uint64_t test_ffi_u64_ (void);
uint64_t test_ffi_u64_ (void)
{
return 4000000000UL;
}
uint64_t test_ffi_u64_u8 (uint8_t a);
uint64_t test_ffi_u64_u8 (uint8_t a)
{
return 4000000000UL + a;
}
uint64_t test_ffi_u64_s64 (int64_t a);
uint64_t test_ffi_u64_s64 (int64_t a)
{
return 4000000000UL + a;
}
int64_t test_ffi_sum (int8_t a, int16_t b,
int32_t c, int64_t d);
int64_t test_ffi_sum (int8_t a, int16_t b,
int32_t c, int64_t d)
{
return d + c + b + a;
}
int64_t test_ffi_sum_many (uint8_t a, uint16_t b,
uint32_t c, uint64_t d,
int8_t e, int16_t f,
int32_t g, int64_t h,
int8_t i, int16_t j,
int32_t k, int64_t l);
int64_t test_ffi_sum_many (uint8_t a, uint16_t b,
uint32_t c, uint64_t d,
int8_t e, int16_t f,
int32_t g, int64_t h,
int8_t i, int16_t j,
int32_t k, int64_t l)
{
return l + k + j + i + h + g + f + e + d + c + b + a;
}
struct foo
{
int8_t a;
int16_t b;
int32_t c;
int64_t d;
};
int64_t test_ffi_sum_struct (struct foo foo);
int64_t test_ffi_sum_struct (struct foo foo)
{
return foo.d + foo.c + foo.b + foo.a;
}
void* test_ffi_memcpy (void *dest, void *src, int32_t n);
void* test_ffi_memcpy (void *dest, void *src, int32_t n)
{
return memcpy (dest, src, n);
}
int test_ffi_callback_1 (int (*f) (int), int x);
int test_ffi_callback_1 (int (*f) (int), int x)
{
return f (x) + 7;
}
double test_ffi_callback_2 (double (*f) (float, int, double),
float x, int y, double z);
double test_ffi_callback_2 (double (*f) (float, int, double),
float x, int y, double z)
{
return f (x, y, z);
}
|