gpt4 book ai didi

c -/usr/include/unistd.h 和 limit.h 来自 glibc 或内核

转载 作者:太空狗 更新时间:2023-10-29 12:18:52 25 4
gpt4 key购买 nike

我们知道 unistd.h 是一个重要的头文件,但是我不确定它是来自内核源代码还是在我们安装 libc 之前安装的?

最佳答案

在软呢帽

# rpm -qf /usr/include/unistd.h
eglibc-headers-2.13-2.21.i686

我们可以在头文件中看到这部分

this file is part of the GNU C Library.

而在内核版本2.6.32.21中我们可以看到

/* kernel/include/linux/unistd.h */
#include <asm/unistd.h>

我们假设 X86

/* kernel/arch/x86/include/asm/unistd.h */
# ifdef CONFIG_X86_32
# include "unistd_32.h"
# else
# include "unistd_64.h"
# endif

并且在文件中有系统调用。不是我们通常使用unistd.h

/*
* This file contains the system call numbers.
*/

#define __NR_restart_syscall 0
#define __NR_exit 1
#define __NR_fork 2
#define __NR_read 3
#define __NR_write 4
#define __NR_open 5
#define __NR_close 6
#define __NR_waitpid 7
#define __NR_creat 8

关于c -/usr/include/unistd.h 和 limit.h 来自 glibc 或内核,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16826909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com