All source listed below is under MIT license if no LICENSE file stating different is available.

RLIB

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.

Extensive tested and benchmarked

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. Gif of build process

ENVIRONMENT VARIABLES

Disabling color

Set env RDISABLE_COLORS = 1 to disable color on stdout. stderr will still have colors for gui.

Compiler and Flags

  • 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.

Main Targets

all:

Runs the following steps in sequence:

  • Testing (test_* targets).
  • Formatting code (format_all).
  • Building the project (build).
  • Installing executables (install).

format_all:

Runs clang-format to format all .c, .h, and .cpp files in the directory.

build:

Builds the rlib shared library (librlib.so) and an executable rlibso that uses this library:

  • Compiles rlib.c into librlib.so.
  • Compiles rlibso.c linking it with librlib.so.
  • Runs the rlibso executable.

install:

Installs the rmerge and clean executables to /usr/bin using sudo.

Testing Targets (test_*)

Each test_* target follows these steps:

build_*:

Compiles a specific .c file into an executable in the ./build directory.

run_*:

Runs the corresponding executable.

Example for rlexer:

  • build_rlexer: Compiles rlexer.c to ./build/rlexer.
  • run_rlexer: Runs ./build/rlexer.

Backup

backup:

Compresses the source files, Makefile, and additional project files into a rlib.rzip archive.

Special Cases

test_rbench_cpp:

Builds and runs a C++ benchmark program:

  • Compiles rbench.cpp along with other necessary files.
  • Runs the resulting executable.

Other Targets

format_rlib_c:

Specifically formats the rlib.c file.

build_*:

Targets that compile source files into executables.

run_*:

Targets that run the compiled executables.

.github/workflows
resources
_rlib.h
.clang-format
.gitignore
arena.c
arena.h
build.gif
clean
license.h
main.h
Makefile
nsock.c
nsock.h
r.c
rargs.h
rautocomplete.c
rautocomplete.h
rbench.c
rbench.cpp
rbench.h
rbuffer.c
rbuffer.h
rcase.c
rcase.h
rcat.c
rcat.h
rcov.c
rcov.h
README.md
reditor.c
remo.c
remo.h
rfalloc.c
rhashtable.c
rhashtable.h
rhttp.c
rhttp.h
rhttpc.c
ricli.c
rinterp.c
rio.c
rio.h
rjson.c
rjson.h
rkeytable.c
rkeytable.h
rlexer.c
rlexer.h
rlib.c
rlib.h
rlibrlibso.c
rlibso.c
rliza.c
rliza.h
rliza.py
rmalloc.c
rmalloc.h
rmath.h
rmerge.c
rmerge.h
rnet.c
rnet.h
rprint.c
rprint.h
rrex3.c
rrex3.h
rrex4.c
rrex4.h
rstring_list.c
rstring_list.h
rstring.c
rstring.h
rtemp.c
rtemp.h
rterm.c
rterm.h
rterminal.c
rterminal.h
rtest.h
rtime.c
rtime.h
rtree.c
rtree.h
rtypes.c
rtypes.h
uuid.h