跳转至

工具函数

以下是更系统化的分类整理,基于 POSIX标准 的核心工具函数和接口,按功能大类细分,便于快速定位:


1. 文件与目录操作

  • 基础文件IO
    open, close, read, write, lseek, fcntl
    fopen, fclose, fread, fwrite, fseek, ftell
  • 目录操作
    opendir, readdir, closedir, mkdir, rmdir
  • 路径处理
    realpath(解析绝对路径), basename, dirname(路径分割)
  • 链接与文件删除
    link(硬链接), symlink(软链接), readlink, unlink(删除文件/软链)
  • 文件锁定
    fcntl(记录锁), flock(BSD风格锁,非POSIX但常见)

2. 文件属性与权限

  • 元数据获取
    stat, fstat, lstat(文件状态,含struct stat解析)
  • 权限管理
    chmod, fchmod, chown, fchown, access(权限检查)
  • 文件类型判断宏
    S_ISREG(), S_ISDIR(), S_ISLNK()(判断文件类型)
  • 时间戳修改
    utime, utimes(修改访问/修改时间)

3. 进程管理

  • 进程创建与控制
    fork, exec系列(execl, execvp等), wait, waitpid, exit
  • 进程组与会话
    setsid, setpgid, getpgid, getpgrp
  • 守护进程工具
    daemon(非POSIX但常见于BSD/Linux)

4. 信号处理

  • 信号注册与发送
    signal, sigaction, kill, raise, sigqueue
  • 信号集操作
    sigemptyset, sigaddset, sigdelset, sigprocmask
  • 高级控制
    sigwait, sigsuspend, alarm(定时信号)

5. 进程间通信(IPC)

  • 管道
    pipe, popen, pclose
  • POSIX消息队列
    mq_open, mq_send, mq_receive, mq_close
  • 信号量
    sem_init, sem_wait, sem_post, sem_destroy
  • 共享内存
    shm_open, mmap, munmap, shm_unlink

6. 环境变量与命令行

  • 环境变量操作
    getenv, setenv, unsetenv, putenv
  • 命令行解析
    getopt, getopt_long(GNU扩展,非POSIX但广泛支持)

7. 时间与日期

  • 时间获取
    time, gettimeofday, clock_gettime(高精度时间)
  • 时间转换
    localtime, gmtime, strftime, mktime

8. 字符串与内存

  • 字符串处理
    strdup, strndup, strtok_r(线程安全分割)
  • 内存管理
    malloc, calloc, realloc, free

9. 用户与权限

  • 用户/组信息
    getuid, geteuid, getpwuid, getpwnam, getgroups
  • 切换身份
    setuid, seteuid, setgid

10. 终端与I/O控制

  • 终端属性
    tcgetattr, tcsetattr, cfmakeraw(设置原始模式)
  • 行控制
    ttyname, isatty, tcflush, tcflow

11. 错误处理与调试

  • 错误码处理
    errno, perror, strerror, strerror_r(线程安全)
  • 断言
    assert(标准C库,但常用于POSIX环境)

12. 动态库与执行

  • 动态加载
    dlopen, dlsym, dlclose(POSIX动态链接接口)
  • 执行外部命令
    system, exec系列

13. 资源管理

  • 资源限制
    getrlimit, setrlimit(限制进程资源)
  • 文件描述符控制
    dup, dup2, fileno(流转描述符)

14. 网络通信(基础POSIX)

  • 套接字基础
    socket, bind, listen, accept, connect
  • 地址转换
    inet_pton, inet_ntop(IP地址格式转换)

15. 正则表达式

  • 模式匹配
    regcomp, regexec, regfree(POSIX正则表达式)

16. 其他工具类

  • 文件系统同步
    sync, fsync(强制写入磁盘)
  • 文件截断
    truncate, ftruncate
  • 模式扩展
    glob(文件名通配符扩展)

此分类覆盖了POSIX系统编程的核心工具,适合作为开发时的快速索引。具体函数行为需结合man手册或标准文档查询细节(如参数、返回值、线程安全性等)。

jemalloc

jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. jemalloc first came into use as the FreeBSD libc allocator in 2005, and since then it has found its way into numerous applications that rely on its predictable behavior. In 2010 jemalloc development efforts broadened to include developer support features such as heap profiling and extensive monitoring/tuning hooks. Modern jemalloc releases continue to be integrated back into FreeBSD, and therefore versatility remains critical. Ongoing development efforts trend toward making jemalloc among the best allocators for a broad range of demanding applications, and eliminating/mitigating weaknesses that have practical repercussions for real world applications.

The COPYING file contains copyright and licensing information.

The INSTALL file contains information on how to configure, build, and install jemalloc.

The ChangeLog file contains a brief summary of changes for each release.

URL: https://jemalloc.net/

jemalloc 是一种通用的 malloc(3) 实现,注重避免内存碎片化并提供可扩展的并发支持。jemalloc 最早于 2005 年作为 FreeBSD 的 libc 分配器投入使用,自那时起,它凭借其可预测的行为被广泛应用于众多应用程序中。到 2010 年,jemalloc 的开发工作进一步扩展,增加了开发者支持功能,例如堆分析(heap profiling)和广泛的监控/调优钩子(monitoring/tuning hooks)。现代版本的 jemalloc 仍然持续集成回 FreeBSD 中,因此其多功能性仍然是关键。当前的开发工作致力于使 jemalloc 成为能够满足各种高要求应用场景的最佳分配器之一,并消除或缓解对实际应用有影响的弱点。

COPYING 文件包含版权和许可信息。

INSTALL 文件提供了如何配置、构建和安装 jemalloc 的相关信息。

ChangeLog 文件包含每个版本的简要变更总结。

网址:https://jemalloc.net/