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

Unit test for FFI calls with special, non-standard, or platform-dependent primitive types. More...

#include "common/double_tap.h"
#include "common/infix_config.h"
#include <infix/infix.h>
Include dependency graph for 403_special_types.c:

Macros

#define DBLTAP_IMPLEMENTATION
 
#define HAS_DISTINCT_LONG_DOUBLE   1
 

Functions

long double passthrough_long_double (long double v)
 
bool check_s128 (__int128_t val)
 
bool check_u128 (__uint128_t val)
 
__int128_t return_s128 (void)
 
bool s128_callback_handler (__int128_t val)
 
 subtest ("Special type: long double")
 
 subtest ("Special type: __int128_t")
 
 subtest ("Special type: __uint128_t")
 

Variables

const __int128_t S128_CONSTANT = (((__int128_t)0x12345678ABCDDCBA) << 64) | 0x1122334455667788
 
const __uint128_t U128_CONSTANT = (((__uint128_t)0xFFFFFFFFFFFFFFFF) << 64) | 0xAABBCCDDEEFF0011
 
 TEST
 

Detailed Description

Unit test for FFI calls with special, non-standard, or platform-dependent primitive types.

This test file validates the ABI implementation for primitive types that have unique or complex calling convention rules.

The test covers:

  • **long double**: This type's size and representation vary by platform. On System V x64, it's an 80-bit extended-precision float passed on the x87 FPU stack, while on Windows and AArch64, it's often an alias for double. This test verifies the correct handling for platforms where it is a distinct type.
  • **__int128_t / __uint128_t**: These are 128-bit integer types provided as a compiler extension by GCC and Clang (but not MSVC). They are typically passed in a pair of general-purpose registers (e.g., RDI/RSI on SysV x64). This test verifies their handling in both forward and reverse calls.

Each test is conditionally compiled to run only on architectures and compilers that support the specific type, ensuring the test suite remains portable.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

◆ HAS_DISTINCT_LONG_DOUBLE

#define HAS_DISTINCT_LONG_DOUBLE   1

Function Documentation

◆ check_s128()

bool check_s128 ( __int128_t  val)

◆ check_u128()

bool check_u128 ( __uint128_t  val)

◆ passthrough_long_double()

long double passthrough_long_double ( long double  v)

◆ return_s128()

__int128_t return_s128 ( void  )

◆ s128_callback_handler()

bool s128_callback_handler ( __int128_t  val)

◆ subtest() [1/3]

subtest ( "Special type: __int128_t"  )

◆ subtest() [2/3]

subtest ( "Special type: __uint128_t"  )

◆ subtest() [3/3]

subtest ( "Special type: long double"  )

Variable Documentation

◆ S128_CONSTANT

const __int128_t S128_CONSTANT = (((__int128_t)0x12345678ABCDDCBA) << 64) | 0x1122334455667788

◆ TEST

TEST
Initial value:
{
plan(3)
#define plan(count)
Definition double_tap.h:163

◆ U128_CONSTANT

const __uint128_t U128_CONSTANT = (((__uint128_t)0xFFFFFFFFFFFFFFFF) << 64) | 0xAABBCCDDEEFF0011