omega-bridge
Omega-first language interoperability: checked conversion backends and native language bindings
Brought by drakestapleton
omega-bridge / tests / native / v2 / fsuse.c
| 1 | /* A freestanding object that uses the C API (tests/native/v2/run.sh): built with -ffreestanding |
| 2 | * -fno-builtin from omega_api_decl.h, its undefined symbols must be the API functions it calls and |
| 3 | * nothing else; no abort, no C library function. fsmain.c links it with omega_api_defs.c and runs it. */ |
| 4 | #include "omega_api_decl.h" |
| 5 | |
| 6 | int fs_check(void) |
| 7 | { |
| 8 | static const uint8_t abc[3] = {'a', 'b', 'c'}; |
| 9 | lay_blk c = {0}; |
| 10 | uint8_t o[16]; |
| 11 | uint8_t s8[8] = {1, 2, 3, 4, 5, 6, 7, 8}; |
| 12 | int bad = 0; |
| 13 | if (bsum(abc, 3) != 294) |
| 14 | bad |= 1; |
| 15 | absorb(&c, abc, 3); |
| 16 | if (c.a != 294 || c.n != 3) |
| 17 | bad |= 2; |
| 18 | if (digest(&c, o) != 3 || o[8] != 294 % 256 || o[9] != 1) |
| 19 | bad |= 4; |
| 20 | if (swap8(s8, 8, s8) != 8 || s8[0] != 8 || s8[7] != 1) |
| 21 | bad |= 8; |
| 22 | return bad; |
| 23 | } |