infix
A JIT-Powered FFI Library for C
Loading...
Searching...
No Matches
862_packed_layout.c File Reference

Regression test for packed struct layout and by-value returns. More...

#include "common/compat_c23.h"
#include "common/double_tap.h"
#include "common/infix_internals.h"
#include "types.h"
#include <infix/infix.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for 862_packed_layout.c:

Classes

struct  packed_char_int
 
struct  packed_char_u64
 
struct  packed_int_char_int
 
struct  packed_mixed
 

Macros

#define DBLTAP_IMPLEMENTATION
 

Functions

PackedABC return_packed_abc (void)
 
PackedTiny return_packed_tiny (void)
 
PackedSix return_packed_six (void)
 
static infix_typecreate_packed_abc_type (infix_arena_t *arena)
 
static infix_typecreate_packed_tiny_type (infix_arena_t *arena)
 
static infix_typecreate_packed_six_type (infix_arena_t *arena)
 
 subtest ("Parsed !{char,int} -- size and offsets")
 
 subtest ("Parsed !{char,uint64_t} -- size and offsets")
 
 subtest ("Parsed !{int,char,int} -- three members")
 
 subtest ("Parsed !{char,short,int,longlong} -- mixed types")
 
 subtest ("Print roundtrip for packed struct")
 
 subtest ("By-value return -- PackedABC (9 bytes)")
 
 subtest ("By-value return -- PackedTiny (3 bytes)")
 
 subtest ("By-value return -- PackedSix (6 bytes)")
 

Variables

 TEST
 

Detailed Description

Regression test for packed struct layout and by-value returns.

Verifies that packed structs parsed via infix_type_from_signature (the !{...} syntax) produce correct member offsets and total sizes through the _layout_struct code path. Also verifies that packed structs with non-power-of-2 sizes are correctly returned by value through forward trampolines.

On AAPCS64, structs <= 16 bytes are returned in X0 (bytes 0-7) and X1 (bytes 8-15). The forward trampoline epilogue must decompose the return buffer write into correct sub-register stores for each chunk. Prior to the fix, sizes other than {1, 2, 4, 8, 16} hit default: break; and wrote zero bytes.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

Function Documentation

◆ create_packed_abc_type()

static infix_type * create_packed_abc_type ( infix_arena_t arena)
static

◆ create_packed_six_type()

static infix_type * create_packed_six_type ( infix_arena_t arena)
static

◆ create_packed_tiny_type()

static infix_type * create_packed_tiny_type ( infix_arena_t arena)
static

◆ return_packed_abc()

PackedABC return_packed_abc ( void  )

◆ return_packed_six()

PackedSix return_packed_six ( void  )

◆ return_packed_tiny()

PackedTiny return_packed_tiny ( void  )

◆ subtest() [1/8]

subtest ( "By-value return -- PackedABC (9 bytes)"  )

◆ subtest() [2/8]

subtest ( "By-value return -- PackedSix (6 bytes)"  )

◆ subtest() [3/8]

subtest ( "By-value return -- PackedTiny (3 bytes)"  )

◆ subtest() [4/8]

subtest ( "Parsed !{char,int} -- size and offsets"  )

◆ subtest() [5/8]

subtest ( "Parsed !{char,short,int,longlong} -- mixed types"  )

◆ subtest() [6/8]

subtest ( "Parsed !{char,uint64_t} -- size and offsets"  )

◆ subtest() [7/8]

subtest ( "Parsed !{int,char,int} -- three members"  )

◆ subtest() [8/8]

subtest ( "Print roundtrip for packed struct"  )

Variable Documentation

◆ TEST

TEST
Initial value:
{
plan(8)
#define plan(count)
Definition double_tap.h:192