infix
A JIT-Powered FFI Library for C
|
A "barebones" thread-safety test with no testing framework dependency. More...
#include "common/infix_config.h"
#include <infix/infix.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <pthread.h>
Macros | |
#define | NUM_THREADS 8 |
#define | ITERATIONS_PER_THREAD 500 |
Functions | |
void | bare_helgrind_handler (int a, int b) |
A simple C callback function; its only purpose is to be a valid call target. | |
void * | bare_thread_worker (void *arg) |
The main function executed by each worker thread. | |
int | main (void) |
A "barebones" thread-safety test with no testing framework dependency.
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 is designed to be the ultimate proof of thread safety for the infix library. It is intended to be compiled as a standalone executable and run under Valgrind's Helgrind tool.
By removing the dependency on the double_tap.h
testing framework (which is not designed for this kind of stress test and can create noisy, misleading reports), we ensure that the only shared code being stressed is the infix library itself. This provides a clean, unambiguous result.
The test's success is determined by two conditions:
#define ITERATIONS_PER_THREAD 500 |
#define NUM_THREADS 8 |
void bare_helgrind_handler | ( | int | a, |
int | b | ||
) |
A simple C callback function; its only purpose is to be a valid call target.
void * bare_thread_worker | ( | void * | arg | ) |
The main function executed by each worker thread.
Creates, uses, and destroys a reverse trampoline in a tight loop.
int main | ( | void | ) |