|
infix
A JIT-Powered FFI Library for C
|
Unit test for reverse trampolines (callbacks) with aggregate types. More...
#include "common/double_tap.h"#include "types.h"#include <infix/infix.h>#include <math.h>#include <string.h>Macros | |
| #define | DBLTAP_IMPLEMENTATION |
Variables | |
| TEST | |
Unit test for reverse trampolines (callbacks) with aggregate types.
This test file verifies that infix can correctly create and execute reverse trampolines for functions that take or return aggregate types (structs, unions, etc.) by value. This is a critical test of the reverse-call JIT-compiler and the ABI implementation's ability to correctly marshal arguments from their native locations (registers/stack) into the generic format for the C handler.
The test covers:
Point struct, which is typically passed in registers. Both the type-safe callback and generic closure models are tested.LargeStruct, which is passed/returned by reference via a hidden pointer, testing the stub's ability to handle this ABI rule.Vector4 struct, which may be an HFA on some platforms.Number union, testing the handling of this aggregate type.PackedStruct with non-natural alignment, testing that the raw bytes are correctly marshalled regardless of internal layout. | #define DBLTAP_IMPLEMENTATION |
| void execute_large_struct_pass_callback | ( | int(*)(LargeStruct) | func_ptr, |
| LargeStruct | s | ||
| ) |
| void execute_large_struct_return_callback | ( | LargeStruct(*)(int) | func_ptr, |
| int | a | ||
| ) |
| void execute_number_union_return_callback | ( | Number(*)(float) | func_ptr, |
| float | f | ||
| ) |
| int large_struct_pass_handler | ( | LargeStruct | s | ) |
| LargeStruct large_struct_return_handler | ( | int | a | ) |
| Number number_union_return_handler | ( | float | f | ) |
| void point_closure_handler | ( | infix_context_t * | ctx, |
| void * | ret, | ||
| void ** | args | ||
| ) |
| int process_packed_struct | ( | PackedStruct | p | ) |
| subtest | ( | "Callback returning large struct: LargeStruct(int)" | ) |
| subtest | ( | "Callback returning union: Number(float)" | ) |
| subtest | ( | "Callback with large struct argument: int(LargeStruct)" | ) |
| subtest | ( | "Callback with struct containing array: int(Vector4)" | ) |
| subtest | ( | "Packed struct" | ) |
| int vector4_callback_handler | ( | Vector4 | v | ) |