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

Unit test for the dynamic library loading and symbol access API. More...

#include "common/compat_c23.h"
#include "common/double_tap.h"
#include "common/infix_config.h"
#include <infix/infix.h>
Include dependency graph for 880_exports.c:

Macros

#define DBLTAP_IMPLEMENTATION
 

Functions

 __attribute__ ((visibility("default")))
 

Detailed Description

Unit test for the dynamic library loading and symbol access API.

This test verifies the functionality of infix_library_open, infix_library_get_symbol, infix_read_global, and infix_write_global.

To perform a realistic test, the test runner opens itself as a dynamic library (using NULL as the path). It then looks up exported symbols within its own executable image.

The test covers:

  • Library Loading: Opening the main executable handle.
  • Symbol Lookup: Finding the address of a known global variable (g_test_export_var).
  • Reading Globals: Using infix_read_global with a signature string to read the variable's value.
  • Writing Globals: Using infix_write_global with a signature string to modify the variable's value.
Note
This test relies on g_test_export_var being exported and visible to dlsym/GetProcAddress. On some platforms/linkers (e.g., MSVC without __declspec(dllexport)), symbols in the main executable are not exported by default. The test includes logic to skip gracefully if the symbol cannot be found, rather than failing.

Macro Definition Documentation

◆ DBLTAP_IMPLEMENTATION

#define DBLTAP_IMPLEMENTATION

Function Documentation

◆ __attribute__()

__attribute__ ( (visibility("default"))  )