sc/README.md

86 lines
4.2 KiB
Markdown
Raw Normal View History

### Overview
2021-02-04 11:17:43 +03:00
2021-02-11 03:35:25 +03:00
Common C libraries and data structures. (C99)
2021-02-06 08:11:54 +03:00
2021-02-10 21:33:03 +03:00
Each folder is stand-alone and contains a single .h .c pair.
There is no build, copy .h .c files you want.
2021-02-04 12:18:23 +03:00
2021-02-04 11:17:43 +03:00
### List
| Library | Description |
|--------------------------------|--------------------------------------------------------------------------------------------|
| **[array](array)** | Generic array/vector |
| **[buffer](buffer)** | Buffer for encoding/decoding variables, best fit for protocol/serialization implementations|
| **[condition](condition)** | Condition wrapper for Posix and Windows |
| **[crc32](crc32)** | Crc32c, uses crc32c CPU instruction if available |
| **[heap](heap)** | Min heap which can be used as max heap/priority queue as well |
| **[ini](ini)** | Ini parser |
| **[linked list](linked-list)** | Intrusive linked list |
| **[logger](logger)** | Logger |
2021-02-05 20:46:59 +03:00
| **[map](map)** | A high performance open addressing hashmap |
| **[memory map](memory-map)** | Mmap wrapper for Posix and Windows |
| **[mutex](mutex)** | Mutex wrapper for Posix and Windows |
| **[option](option)** | Cmdline argument parser. Very basic one |
| **[perf](perf)** | Benchmark utility to get performance counters info via perf_event_open() |
| **[queue](queue)** | Generic queue which can be used as dequeue/stack/list as well |
2021-02-06 16:58:50 +03:00
| **[sc](sc)** | Utility functions |
| **[signal](signal)** | Signal handler & signal safe snprintf (handling CTRL+C, printing backtrace on crash etc) |
| **[socket](socket)** | Pipe / tcp sockets(also unix domain sockets) /Epoll/Kqueue/WSAPoll for Posix and Windows |
| **[string](string)** | Length prefixed, null terminated C strings. |
| **[thread](thread)** | Thread wrapper for Posix and Windows. |
| **[time](time)** | Time and sleep functions for Posix and Windows |
2021-02-06 08:11:54 +03:00
| **[timer](timer)** | Hashed timing wheel implementation with fast poll / cancel ops |
| **[uri](uri)** | A basic uri parser |
### Test
2021-02-09 19:12:15 +03:00
[![codecov](https://codecov.io/gh/tezc/sc/branch/master/graph/badge.svg?token=O8ZHQ0XZ30)](https://codecov.io/gh/tezc/sc)
2021-02-05 20:46:59 +03:00
Although I use on Linux mostly, CI runs with
<pre>
OS : Linux, MacOS, FreeBSD and Windows
Compilers : GCC, Clang, MSVC
Arch : x64, aarch64, armv6, armv7, ppc64le, s390x
Sanitizers : valgrind and clang/gcc sanitizers(address, undefined, thread)
</pre>
To run all tests :
<pre>
#with valgrind
mkdir build; cd build;
2021-02-05 20:46:59 +03:00
cmake .. && make && make valgrind
#with address sanitizer
mkdir build; cd build;
cmake .. -DSANITIZER=address && make && make check
#with undefined sanitizer
mkdir build; cd build;
cmake .. -DSANITIZER=undefined && make && make check
2021-02-05 20:46:59 +03:00
2021-02-09 19:12:15 +03:00
#coverage, requires GCC.
2021-02-05 20:46:59 +03:00
mkdir build; cd build;
cmake .. -DCMAKE_BUILD_TYPE=Coverage; make; make coverage
</pre>
2021-02-04 11:17:43 +03:00
### Using with cmake FetchContent
```cmake
FetchContent_Declare(
sc_lib
GIT_REPOSITORY https://github.com/tezc/sc.git
GIT_TAG master)
FetchContent_MakeAvailable(sc_lib)
add_executable(
myapp
myapp.c
)
target_link_libraries(
myapp
sc_str
)
```