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
|
namespace;
include rt;
// structs by value in native calls: a zc struct of word fields is passed to a c
// function as its words. the helper library is built by test.sh (build/sbv.so).
struct Pair { int a; int b; }
struct Vec { float x; float y; }
struct Trio { int a; int b; int c; }
extern long pair_sum(struct Pair p);
extern long pair_sum2(struct Pair p, struct Pair q);
extern long vec_scaled(struct Vec v, long k);
extern long many(long a, long b, long c, long d, long e, long f, struct Pair p);
extern long trio_sum(long a, long b, long c, long d, long e, long f, struct Trio t);
extern long eight(long a, long b, long c, long d, long e, long f, long g, long h, struct Pair p);
int main() {
Pair p; Pair q; Vec v; Trio t;
rt.cload(b"build/sbv.so");
p.a = 3; p.b = 4;
rt.put_n(pair_sum(p)); rt.put_c(32);
q.a = 10; q.b = 20;
rt.put_n(pair_sum2(p, q)); rt.put_c(32);
v.x = 1.5; v.y = 2.0;
rt.put_n(vec_scaled(v, 2)); rt.put_c(32);
rt.put_n(many(1, 2, 3, 4, 5, 6, p)); rt.put_c(32);
t.a = 7; t.b = 8; t.c = 9;
rt.put_n(trio_sum(1, 2, 3, 4, 5, 6, t)); rt.put_c(32);
rt.put_n(eight(1, 2, 3, 4, 5, 6, 7, 8, p)); rt.put_c(10);
return 0;
}
|