Add vlibc scaffold, build system, and documentation
Establish the repository layout per Vox guidelines (layouts/C.md, building/C.md): Autotools build (GCC-only, C23), five compatibility profiles (--enable-onlyposix/--enable-muslmimic/--enable-muslext/ --enable-spoof, default vlibc), alongside/overwrite install methods, vlibc-gcc/vlibc-clang drivers, static-linking requirement (except spoof), benchmark harness, and tooling (.clang-format/.clang-tidy/ .clangd + compile_commands.json).
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Benchmark harness for vlibc (musts/BENCHMARKING.md).
|
||||
*
|
||||
* Every vlibc component is benchmarked against the software it replaces.
|
||||
* This stub times vlibc_version() and is the skeleton that per-component
|
||||
* benchmarks build on. Reconfigure with --with-libc=musl or --with-libc=glibc
|
||||
* to link the same harness against a reference libc for comparison.
|
||||
*/
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <vlibc.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#define ITERATIONS 100000000ULL
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
volatile const char *version = NULL;
|
||||
struct timespec start;
|
||||
struct timespec end;
|
||||
double whole;
|
||||
double frac;
|
||||
double seconds;
|
||||
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &start) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (unsigned long long i = 0; i < ITERATIONS; i++)
|
||||
{
|
||||
version = vlibc_version();
|
||||
}
|
||||
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &end) != 0)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
whole = (double)(end.tv_sec - start.tv_sec);
|
||||
frac = (double)(end.tv_nsec - start.tv_nsec) / 1000000000.0;
|
||||
seconds = whole + frac;
|
||||
|
||||
printf("vlibc_version() x %llu: %.3f s (%.2f ns/call), version=%s\n", ITERATIONS, seconds,
|
||||
seconds * 1000000000.0 / ITERATIONS, (const char *)version);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user