Basic Libraries for Linux
C Python Other
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
3rds update fcunit Feb 11, 2015
benchmark flog: Add a debugging benchmark case as well as a validation script Apr 9, 2017
fcache Fix compiling issue on lower version of gcc Jul 19, 2016
fco Compatible with Raspberry pi Oct 28, 2016
fconf Replace malloc with calloc to avoid the uninitialization issue Jan 13, 2015
fev Add more interfaces to fev_timer_service, user would manually trigger… Dec 14, 2016
fhash fhash: Data address must be 32 bit-aligned Oct 29, 2016
flist Add memory barrier for flist and fmbuf Oct 13, 2016
flock refactor flock api and makefile Jan 12, 2015
flog flog: Add a debugging benchmark case as well as a validation script Apr 9, 2017
fmbuf fmbuf: Add fmbuf_empty() Apr 9, 2017
fnet Update LICENSE and fix fnet_(peer|sock)name issues in AF_INET6 Mar 7, 2017
fthread_pool Compatible with Raspberry pi Oct 28, 2016
ftime change api name 'fgettime to ftime_gettime' Feb 11, 2015
include/flibs flog: Correct API document Apr 11, 2017
tests flog: Refine mode to a int flags Apr 9, 2017
.Makefile.bench refine and pass benchmark test Feb 11, 2015
.Makefile.doc pass doc generation Jan 12, 2015
.Makefile.inc Compatible with Raspberry pi Oct 28, 2016
.Makefile.libs Add the global libflibs.a and libflibs.so Oct 27, 2016
.Makefile.objs Add the global libflibs.a and libflibs.so Oct 27, 2016
.Makefile.targets flog: Add a debugging benchmark case as well as a validation script Apr 9, 2017
.Makefile.tests Compatible with Raspberry pi Oct 28, 2016
.api_doxyfile update comments of fhash May 29, 2014
.clang-format Add .clang-format and .ycm_extra_conf.py Dec 27, 2013
.gitignore refine and pass fev UT Feb 11, 2015
.gitmodules correct typo Feb 12, 2015
.travis.yml Update Changelog, and run benchmark in CI Apr 9, 2017
.ycm_extra_conf.py add submodule fcunit and pass flist and fhash UT Feb 11, 2015
ChangeLog.md Update Changelog, and run benchmark in CI Apr 9, 2017
LICENSE Update LICENSE and fix fnet_(peer|sock)name issues in AF_INET6 Mar 7, 2017
Makefile Compatible with Raspberry pi Oct 28, 2016
README.md Update README.md Oct 27, 2016

README.md

Build Status

Common Libraries (Linux Platform)

Lastest Release

See Here

ChangeLog

See change log

Library contains

Lib Name Description
flist Lockfree list in one-producer one-consumer
fhash Hash table
flock A wraper, which safe and easy to use pthread condition
flog A High Performance Logging System
fmbuf A light-weight buffer
fconf A simple format config lib
ftime Easy to create system timer
fthread_pool Simple thread pool, which easy to use
fnet Wrap the system api, easy to use the network api
fev Event framework, including buffer, network, timer service
fcache A simple cache with LRU
fco C coroutine
fut Unit test framework. notes: Migrated to fcunit
fmempool Thread cache memory pool. notes: Migrated to skull-malloc
fpcap Pcap file convertion lib. notes: Migrated to fpcap

NOTE: After run as above, you can find the libraries have been installed in the specified folder or current folder, which named as "final_libraries"

API Documents

See Wiki

Compile

git clone git@github.com:finaldie/final_libs.git flibs
cd flibs
git submodule update --init --recursive
make
make check
make valgrind-check

Benchmark

make bench
make bench-run

Flags

  • Change the compiler, such as using clang:
make CC=clang
  • Build shared library instead of static library:
make SHARED=true
  • Build debug version without any optimization parameters
make debug=true
  • Build 32bit libraries under 64bit platform
make BIT=32
  • Build in parallel
make -j4   # replace the number 4 according to your real cpu number to speed up the compile time

Example (on 64bit platform)

  • Build 64bit static-link libraries
make -j4 && make -j4 check
  • Build 64bit dynamic-link libraries
make SHARED=true -j4 && make SHARED=true check
  • Install flibs to system
make install

notes: By default, the prefix is /usr/local, so the flibs will be installed to /usr/local, if you want to change the prefix, just run the following:

make SHARED=true prefix=$(other_location) -j4
make prefix=$(other_location) install

Use flibs in a Project

After installing flibs into system, basically we need few steps to use it:

  • Include the headers from your source file
  • Link the statis/dynamic lib from your Makefile
  • Add -D_POSIX_C_SOURCE=200809L in your compiling options

Let's see an example Source file and Makefile, e.g. use fhash:

// main.c
#include <stdlib.h>
#include <stdio.h>
#include <flibs/fhash.h>

int main(int argc, char** argv)
{
    // 1. Create string hash table
    fhash* tbl = fhash_str_create(0, FHASH_MASK_AUTO_REHASH);

    // 2. Set a key-value into table
    const char* key = "hello";
    fhash_str_set(tbl, key, "world");

    // 3. Get the value from table
    const char* value = fhash_str_get(tbl, key);
    printf("Key: %s, value: %s\n", key, value);

    // 4. Destroy the hash table
    fhash_str_delete(tbl);
    return 0;
}
# Makefile
all:
       	gcc -Wall -g -O2 -D_POSIX_C_SOURCE=200809L -o demo main.c -lflibs

Then Build and Run it:

final@ubuntu1404: ~/code/github/flibs/demo>make
gcc -Wall -g -O2 -D_POSIX_C_SOURCE=200809L -o demo main.c -lflibs
final@ubuntu1404: ~/code/github/flibs/demo>./demo
Key: hello, value: world

Have fun :)