Home

Awesome

ffsys

ffsys is a cross-platform interface that wraps the system functions of different OS to provide you with a unified userspace API. In other words, you write the single chunk of code that is translated to system-specific code during compilation, and that's how it works on different OS.

Supported OS:

ffsys advantages:

Features

Main:

FileDescription
base.hDetect CPU, OS and compiler; base types; heap memory functions
globals.hDefine the global symbols needed by ffsys. Include this file into one of your compilation units to make the linker happy.

I/O, FS:

FileDescription
std.hStandard I/O
file.hFiles
filemap.hFile mapping
pipe.hUnnamed and named pipes
queue.hKernel queue
kcall.hKernel call queue (to call kernel functions asynchronously)
dir.hFile-system directory functions
dirscan.hScan directory for files
path.hNative file-system paths
filemon.hFile system monitoring (Linux, Windows) (incompatible)
volume.hVolumes (Windows)
winreg.hWindows Registry

Process, thread, IPC:

FileDescription
process.hProcess
environ.hProcess environment
thread.hThreads
signal.hUNIX signals, CPU exceptions
semaphore.hSemaphores
perf.hProcess/thread performance counters
dylib.hDynamically loaded libraries
backtrace.hBacktrace

Network:

FileDescription
socket.hSockets, network address
netconf.hNetwork configuration
netlink.hLinux netlink helper functions

Misc:

FileDescription
time.hDate and time
timer.hSystem timer
timerqueue.hTimer queue
string.hNative system string
error.hSystem error codes
random.hRandom number generator

How to use

ffsys code is split between 2 repos:

Step 1. In your terminal window:

cd YOUR_PROJECT
git clone https://github.com/stsaz/ffsys
git clone https://github.com/stsaz/ffbase

Step 2. In your Makefile:

FFSYS := YOUR_PROJECT/ffsys
FFBASE := YOUR_PROJECT/ffbase
CFLAGS += -I$(FFSYS) -I$(FFBASE)

Optional preprocessor flags:

FlagDescription
FF_MUSLUNIX: Compile for musl C library

Step 3. In your C source files:

#include <ffsys/...>

Test

git clone https://github.com/stsaz/ffbase
git clone https://github.com/stsaz/ffsys
cd ffsys/test
make -j8
./ffsystest all

on FreeBSD:

gmake -j8

on Linux for Windows:

make -j8 OS=windows COMPILER=gcc CROSS_PREFIX=x86_64-w64-mingw32-