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

Tests basic FFI calls with simple function signatures. More...

#include "common/double_tap.h"
#include <infix/infix.h>
#include <math.h>
Include dependency graph for 002_simple_calls.c:

Macros

#define DBLTAP_IMPLEMENTATION
 

Functions

int add_ints (int a, int b)
 A simple function that adds two integers.
 
float multiply_floats (float a, float b)
 A simple function that multiplies two floats.
 
void do_nothing ()
 A simple function with no arguments or return value.
 
bool is_negative (int val)
 A function to check if an integer is negative. Used for sign-extension tests.
 
 subtest ("int(int, int)")
 
 subtest ("float(float, float)")
 
 subtest ("void(void)")
 
 subtest ("Argument Sign-Extension: bool(int)")
 

Variables

 TEST
 

Detailed Description

Tests basic FFI calls with simple function signatures.

Copyright (c) 2025 Sanko Robinson

This source code is dual-licensed under the Artistic License 2.0 or the MIT License. You may choose to use this code under the terms of either license.

SPDX-License-Identifier: (Artistic-2.0 OR MIT)

The documentation blocks within this file are licensed under the Creative Commons Attribution 4.0 International License (CC BY 4.0).

SPDX-License-Identifier: CC-BY-4.0

This test suite verifies the FFI for the most common and fundamental function signatures, ensuring that the library correctly handles basic integer and floating-point arguments, void returns, and proper sign-extension of integer types.

It consolidates several smaller, single-purpose tests into one cohesive file with the following subtests:

  • int(int, int): Verifies multiple integer arguments and an integer return.
  • float(float, float): Verifies multiple float arguments and a float return.
  • void(void): Verifies calls to functions with no arguments and no return value.
  • bool(int): Specifically tests that signed integer arguments are correctly sign-extended across the FFI boundary, a crucial requirement for ABI correctness.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

Function Documentation

◆ add_ints()

int add_ints ( int  a,
int  b 
)

A simple function that adds two integers.

◆ do_nothing()

void do_nothing ( )

A simple function with no arguments or return value.

◆ is_negative()

bool is_negative ( int  val)

A function to check if an integer is negative. Used for sign-extension tests.

◆ multiply_floats()

float multiply_floats ( float  a,
float  b 
)

A simple function that multiplies two floats.

◆ subtest() [1/4]

subtest ( "Argument Sign-Extension: bool(int)"  )

◆ subtest() [2/4]

subtest ( "float(float, float)"  )

◆ subtest() [3/4]

subtest ( "int(int, int)"  )

◆ subtest() [4/4]

subtest ( "void(void)"  )

Variable Documentation

◆ TEST

TEST
Initial value:
{
plan(4)
#define plan(count)
Definition double_tap.h:132