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

Cookbook Chapter 4: Proving Reentrancy with Nested FFI Calls. More...

#include <infix/infix.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for Ch04_Reentrancy.c:

Functions

static int multiply (int a, int b)
 
static void nested_call_handler (infix_context_t *ctx, void *ret, void **args)
 
static int harness (int(*func)(int), int input)
 
int main ()
 

Detailed Description

Cookbook Chapter 4: Proving Reentrancy with Nested FFI Calls.

This test demonstrates that infix is fully reentrant, meaning it is safe to make an infix FFI call from within a handler that was invoked by another infix FFI call.

The call chain is:

  1. C main function (Forward Call) -> harness function
  2. harness function (Native Call) -> infix Reverse Callback
  3. Reverse Callback Handler (Forward Call) -> multiply function

This works because infix uses no global mutable state; all context is either passed directly or stored in thread-local storage.

Function Documentation

◆ harness()

static int harness ( int(*)(int)  func,
int  input 
)
static

◆ main()

int main ( void  )

◆ multiply()

static int multiply ( int  a,
int  b 
)
static

◆ nested_call_handler()

static void nested_call_handler ( infix_context_t ctx,
void *  ret,
void **  args 
)
static