2022-06-08 14:41:09 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
#ifdef _WIN32
|
2022-08-24 16:34:59 +00:00
|
|
|
#define EXPORTER __declspec(dllexport)
|
2022-08-14 18:26:13 +00:00
|
|
|
#else
|
|
|
|
#define EXPORTER
|
|
|
|
#endif
|
|
|
|
|
2022-09-20 15:00:55 +00:00
|
|
|
/* Structs */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int a, b;
|
|
|
|
float c, d;
|
|
|
|
} Split;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float c, d;
|
|
|
|
int a, b;
|
|
|
|
} SplitFlip;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int u, v, w, x, y, z;
|
|
|
|
} SixInts;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
} intint;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
int c;
|
|
|
|
} intintint;
|
|
|
|
|
2024-06-23 16:22:25 +00:00
|
|
|
typedef struct {
|
|
|
|
uint64_t a;
|
|
|
|
uint64_t b;
|
|
|
|
} uint64pair;
|
|
|
|
|
2022-09-20 15:00:55 +00:00
|
|
|
typedef struct {
|
|
|
|
int64_t a;
|
|
|
|
int64_t b;
|
|
|
|
int64_t c;
|
|
|
|
} big;
|
|
|
|
|
|
|
|
/* Functions */
|
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-08 14:41:09 +00:00
|
|
|
int int_fn(int a, int b) {
|
|
|
|
return (a << 2) + b;
|
|
|
|
}
|
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-08 14:41:09 +00:00
|
|
|
double my_fn(int64_t a, int64_t b, const char *x) {
|
|
|
|
return (double)(a + b) + 0.5 + strlen(x);
|
|
|
|
}
|
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-08 14:41:09 +00:00
|
|
|
double double_fn(double x, double y, double z) {
|
|
|
|
return (x + y) * z * 3;
|
|
|
|
}
|
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-08 14:41:09 +00:00
|
|
|
double double_many(double x, double y, double z, double w, double a, double b) {
|
|
|
|
return x + y + z + w + a + b;
|
|
|
|
}
|
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-08 14:41:09 +00:00
|
|
|
double double_lots(
|
2022-06-08 14:50:31 +00:00
|
|
|
double a,
|
|
|
|
double b,
|
|
|
|
double c,
|
|
|
|
double d,
|
|
|
|
double e,
|
|
|
|
double f,
|
|
|
|
double g,
|
|
|
|
double h,
|
|
|
|
double i,
|
|
|
|
double j) {
|
|
|
|
return i + j;
|
2022-06-08 14:41:09 +00:00
|
|
|
}
|
|
|
|
|
2022-08-14 20:20:30 +00:00
|
|
|
EXPORTER
|
|
|
|
double double_lots_2(
|
|
|
|
double a,
|
|
|
|
double b,
|
|
|
|
double c,
|
|
|
|
double d,
|
|
|
|
double e,
|
|
|
|
double f,
|
|
|
|
double g,
|
|
|
|
double h,
|
|
|
|
double i,
|
|
|
|
double j) {
|
|
|
|
return a +
|
2022-08-24 16:34:59 +00:00
|
|
|
10.0 * b +
|
|
|
|
100.0 * c +
|
|
|
|
1000.0 * d +
|
|
|
|
10000.0 * e +
|
|
|
|
100000.0 * f +
|
|
|
|
1000000.0 * g +
|
|
|
|
10000000.0 * h +
|
|
|
|
100000000.0 * i +
|
|
|
|
1000000000.0 * j;
|
2022-08-14 20:20:30 +00:00
|
|
|
}
|
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-08 14:41:09 +00:00
|
|
|
double float_fn(float x, float y, float z) {
|
|
|
|
return (x + y) * z;
|
|
|
|
}
|
2022-06-10 01:27:56 +00:00
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-10 01:27:56 +00:00
|
|
|
int intint_fn(double x, intint ii) {
|
|
|
|
printf("double: %g\n", x);
|
|
|
|
return ii.a + ii.b;
|
|
|
|
}
|
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-10 01:27:56 +00:00
|
|
|
int intintint_fn(double x, intintint iii) {
|
|
|
|
printf("double: %g\n", x);
|
|
|
|
return iii.a + iii.b + iii.c;
|
|
|
|
}
|
2022-06-10 17:24:50 +00:00
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-10 17:24:50 +00:00
|
|
|
intint return_struct(int i) {
|
|
|
|
intint ret;
|
|
|
|
ret.a = i;
|
|
|
|
ret.b = i * i;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-10 17:24:50 +00:00
|
|
|
big struct_big(int i, double d) {
|
|
|
|
big ret;
|
|
|
|
ret.a = i;
|
|
|
|
ret.b = (int64_t) d;
|
|
|
|
ret.c = ret.a + ret.b + 1000;
|
|
|
|
return ret;
|
|
|
|
}
|
2022-06-10 17:33:01 +00:00
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-10 17:33:01 +00:00
|
|
|
void void_fn(void) {
|
|
|
|
printf("void fn ran\n");
|
|
|
|
}
|
|
|
|
|
2022-09-18 02:18:07 +00:00
|
|
|
EXPORTER
|
|
|
|
void void_fn_2(double y) {
|
2022-09-15 18:58:54 +00:00
|
|
|
printf("y = %f\n", y);
|
|
|
|
}
|
|
|
|
|
2022-08-14 18:26:13 +00:00
|
|
|
EXPORTER
|
2022-06-10 17:33:01 +00:00
|
|
|
void void_ret_fn(int x) {
|
|
|
|
printf("void fn ran: %d\n", x);
|
|
|
|
}
|
2022-09-18 02:18:07 +00:00
|
|
|
|
2022-09-20 14:28:46 +00:00
|
|
|
EXPORTER
|
|
|
|
int intintint_fn_2(intintint iii, int i) {
|
2022-09-20 20:36:03 +00:00
|
|
|
fprintf(stderr, "iii.a = %d, iii.b = %d, iii.c = %d, i = %d\n", iii.a, iii.b, iii.c, i);
|
2022-09-20 14:28:46 +00:00
|
|
|
return i * (iii.a + iii.b + iii.c);
|
|
|
|
}
|
|
|
|
|
2022-09-18 02:18:07 +00:00
|
|
|
EXPORTER
|
|
|
|
float split_fn(Split s) {
|
|
|
|
return s.a * s.c + s.b * s.d;
|
|
|
|
}
|
2022-09-20 14:28:46 +00:00
|
|
|
|
|
|
|
EXPORTER
|
|
|
|
float split_flip_fn(SplitFlip s) {
|
|
|
|
return s.a * s.c + s.b * s.d;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORTER
|
|
|
|
Split split_ret_fn(int x, float y) {
|
|
|
|
Split ret;
|
|
|
|
ret.a = x;
|
|
|
|
ret.b = x;
|
|
|
|
ret.c = y;
|
|
|
|
ret.d = y;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORTER
|
|
|
|
SplitFlip split_flip_ret_fn(int x, float y) {
|
|
|
|
SplitFlip ret;
|
|
|
|
ret.a = x;
|
|
|
|
ret.b = x;
|
|
|
|
ret.c = y;
|
|
|
|
ret.d = y;
|
|
|
|
return ret;
|
|
|
|
}
|
2022-09-20 15:00:55 +00:00
|
|
|
|
|
|
|
EXPORTER
|
|
|
|
SixInts sixints_fn(void) {
|
|
|
|
return (SixInts) {
|
|
|
|
6666, 1111, 2222, 3333, 4444, 5555
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORTER
|
|
|
|
int sixints_fn_2(int x, SixInts s) {
|
|
|
|
return x + s.u + s.v + s.w + s.x + s.y + s.z;
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORTER
|
|
|
|
int sixints_fn_3(SixInts s, int x) {
|
|
|
|
return x + s.u + s.v + s.w + s.x + s.y + s.z;
|
|
|
|
}
|
2024-06-23 16:22:25 +00:00
|
|
|
|
|
|
|
EXPORTER
|
|
|
|
intint stack_spill_fn(uint8_t a, uint8_t b, uint8_t c, uint8_t d,
|
|
|
|
uint8_t e, uint8_t f, uint8_t g, uint8_t h,
|
|
|
|
float i, float j, float k, float l,
|
|
|
|
float m, float n, float o, float p,
|
|
|
|
float s1, int8_t s2, uint8_t s3, double s4, uint8_t s5, intint s6) {
|
|
|
|
return (intint) {
|
|
|
|
(a | b | c | d | e | f | g | h) + (i + j + k + l + m + n + o + p),
|
|
|
|
s1 * s6.a + s2 * s6.b + s3 * s4 * s5
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPORTER
|
|
|
|
double stack_spill_fn_2(uint64pair a, uint64pair b, uint64pair c, int8_t d, uint64pair e, int8_t f) {
|
|
|
|
return (double)(a.a * c.a + a.b * c.b + b.a * e.a) * f - (double)(b.b * e.b) + d;
|
|
|
|
}
|