1 Star 1 Fork 1

流水源 / sc

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

Overview

License: BSD codecov

Portable, stand-alone C libraries and data structures. (C99)

Each folder is stand-alone with a single header/source pair in it. There is no
build for libraries, just copy files you want.

e.g., If you want the logger, copy sc_log.h and sc_log.c to your project.

Features

  • High performance & minimal memory usage
  • Portability between many operating systems and architectures
  • Tests with 100% branch coverage and multiple sanitizers
  • Drag & drop source code distribution

Test

There is 100% branch-coverage on Linux and CI runs on

OS         : Linux, MacOS, FreeBSD and Windows  
Compilers  : GCC, Clang, MSVC  
Arch       : x64, aarch64, armv6(32 bit), armv7(32 bit), ppc64le, s390x(big endian), riscv64  
Sanitizers : valgrind and clang/gcc sanitizers(address, undefined, thread)

List

Library Description
array Generic array/vector
buffer Buffer for encoding/decoding variables, best fit for protocol/serialization implementations
condition Condition wrapper for Posix and Windows
crc32 Crc32c, uses crc32c CPU instruction if available
heap Min heap which can be used as max heap/priority queue as well
ini Ini parser
linked list Intrusive linked list
logger Logger
map A high performance open addressing hashmap
memory map Mmap wrapper for Posix and Windows
mutex Mutex wrapper for Posix and Windows
option Cmdline argument parser. Very basic one
perf Benchmark utility to get performance counters info via perf_event_open()
queue Generic queue which can be used as dequeue/stack/list as well
sc Utility functions
signal Signal safe snprintf & Signal handler (handling CTRL+C, printing backtrace on crash etc)
socket Pipe / tcp sockets(also unix domain sockets) /Epoll/Kqueue/WSAPoll for Posix and Windows
string Length prefixed, null terminated C strings.
thread Thread wrapper for Posix and Windows.
time Time and sleep functions for Posix and Windows
timer Hashed timing wheel implementation with fast poll / cancel ops
uri A basic uri parser

Q&A


  • Is it any better than library X ?
    I often use these libraries for high performance server-side applications. Also,
    I care about readable and easy to debug code. In summary, these libraries show
    my taste(trade-offs) about performance/api-design/readability. You may or may
    not like it.

  • Why don't you change API here at X, so it will be easier to use?
    Send a pull request please but be sure you don't introduce an undefined
    behavior. It's possible to provide better APIs, especially to generic libraries,
    if you don't care about undefined behaviors. I try to avoid it.

  • What is the most efficient way to use these libraries?
    Just like any other code. Add to your project as source files and ideally use
    -O3 -flto + PGO. It may not make any difference for your use case though.

  • Is library X being used in any product?
    Some libraries are used in the production but please always test yourself.

  • Is there any release?
    Please use the master branch. It's considered stable.

  • Will you keep API stable?
    Please don't expect a stable API. These libraries are quite
    small (most of them are less than a few hundreds lines of code) and ideally you
    are supposed to read the code and understand what it does and adapt it to your
    needs. So, you should not update libraries blindly. I expect you to handle
    any possible API differences easily. That being said, I'll do my best to keep
    API stable.

BSD-3-Clause Copyright 2021 Ozan Tezcan All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

sc - 可移植的且独立的C库和数据结构 sc 是一套可移植的、独立的 C 库和数据结构(C99)。每个文件夹都是独立的,其中有一个单独的头文件/源文件。例如,如果你想要记录器,复制 sc_log.h 和 sc_log.c 到你的项目。 展开 收起
C 等 2 种语言
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/water_source/sc.git
git@gitee.com:water_source/sc.git
water_source
sc
sc
master

搜索帮助