Collection of frequently used C functions by me.
It contains
- An advanced benchmark system.
- An alternative to printf supporting printing of time between messages for e.g. benchmarking. and colors.
- Super fast tree map (much faster than hash table).
- Stdout redirection.
- Terminal progress bar.
- Multi purpose lexer.
- Custom malloc for counting allocations and free's.
- Simple test library that works like assert that also checks memory if rmalloc is used and creates summary and provides exit code.
- Several time functions supporting nano seconds.
- Several math functions for if not available by std (on termux for example).
- Arena blazing fast memory.
All files get merged together to one file called rlib.c
that can be used as a header file.
The result is a single header framework.
Set env RDISABLE_COLORS = 1 to disable color on stdout. stderr will still have colors for gui.
CC = gcc
: Specifies the C compiler (GCC).CFLAGS = -Wall -Wextra -Ofast
: Compiler flags:-Wall
: Enable all warnings.-Wextra
: Enable extra warnings.-Ofast
: Optimize for speed.
LDFLAGS = -lm
: Linker flags to link with the math library.
Runs the following steps in sequence:
- Testing (
test_*
targets). - Formatting code (
format_all
). - Building the project (
build
). - Installing executables (
install
).
Runs clang-format
to format all .c
, .h
, and .cpp
files in the directory.
Builds the rlib
shared library (librlib.so
) and an executable rlibso
that uses this library:
- Compiles
rlib.c
intolibrlib.so
. - Compiles
rlibso.c
linking it withlibrlib.so
. - Runs the
rlibso
executable.
Installs the rmerge
and clean
executables to /usr/bin
using sudo
.
Each test_*
target follows these steps:
Compiles a specific .c
file into an executable in the ./build
directory.
Runs the corresponding executable.
Example for rlexer
:
build_rlexer:
Compilesrlexer.c
to./build/rlexer
.run_rlexer:
Runs./build/rlexer
.
Compresses the source files, Makefile, and additional project files into a rlib.rzip
archive.
Builds and runs a C++ benchmark program:
- Compiles
rbench.cpp
along with other necessary files. - Runs the resulting executable.
Specifically formats the rlib.c
file.
Targets that compile source files into executables.
Targets that run the compiled executables.