简体   繁体   English

在Ubuntu中的unistd_64.h

[英]unistd_64.h in Ubuntu

unistd_64 as my understanding (with lots of limited) contains the system call number. unistd_64,因为我的理解(有很多限制)包含系统调用号。 When I search the file from terminal, it shows more than one results under different directories as below: 当我从终端搜索文件时,它在不同目录下显示了多个结果,如下所示:

  1. /usr/include/x86_64-linux-gnu/asm/unistd_64.h /usr/include/x86_64-linux-gnu/asm/unistd_64.h
  2. /usr/src/linux-headers-3.5.0-23/arch/sh/include/asm/unistd_64.h /usr/src/linux-headers-3.5.0-23/arch/sh/include/asm/unistd_64.h
  3. /usr/src/linux-headers-3.5.0-23-generic/arch/x86/include/generated/ asm/.unistd_64.h.cmd /usr/src/linux-headers-3.5.0-23-generic/arch/x86/include/genic/ asm / .unistd_64.h.cmd
  4. /usr/src/linux-headers-3.5.0-23-generic/arch/x86/include/generated/asm/unistd_64.h /usr/src/linux-headers-3.5.0-23-generic/arch/x86/include/genic/asm/unistd_64.h

I don't understand the difference between these files and the use of each file. 我不了解这些文件与每个文件的使用之间的区别。 And the file number 3 has .cmd, what does it mean? 3号文件具有.cmd,这是什么意思?

If you are writing an ordinary C program that needs to know system call numbers, you should not use any of those headers. 如果您正在编写一个需要知道系统调用号的普通C程序,则不应使用任何这些标头。 Instead, you should use <sys/syscall.h> . 相反,您应该使用<sys/syscall.h> Your C program does not need to know the full pathname of this header; 您的C程序不需要知道此标头的完整路径名; #include <sys/syscall.h> is all that is necessary. #include <sys/syscall.h> However, if you want to read it, it will be found somewhere in /usr/include , probably either /usr/include/sys/syscall.h or /usr/include/x86_64-linux-gnu/sys/syscall.h . 但是,如果您想阅读它,可以在/usr/include找到它,可能在/usr/include/sys/syscall.h/usr/include/x86_64-linux-gnu/sys/syscall.h

Now, I will explain the files you found: 现在,我将解释您找到的文件:

  • /usr/include/x86_64-linux-gnu/asm/unistd_64.h : This is a header file that may be used internally by sys/syscall.h . /usr/include/x86_64-linux-gnu/asm/unistd_64.h :这是一个头文件,可以由sys/syscall.h在内部使用。 You can read it, but do not include it directly in your program. 您可以阅读它,但不要直接将其包含在程序中。 It probably defines a whole bunch of names that begin with __NR_ . 它可能定义了以__NR_开头的一大堆名称。 Those names should never be used in an ordinary, "userspace" program: always use the names beginning with SYS_ instead. 这些名称绝对不能在普通的“用户空间”程序中使用:请始终使用以SYS_开头的名称。

  • /usr/src/linux-headers-3.5.0-23/arch/sh/include/asm/unistd_64.h and /usr/src/linux-headers-3.5.0-23-generic/arch/x86/include/generated/asm/unistd_64.h : These are private kernel headers. /usr/src/linux-headers-3.5.0-23/arch/sh/include/asm/unistd_64.h/usr/src/linux-headers-3.5.0-23-generic/arch/x86/include/generated/asm/unistd_64.h :这些是专用内核头文件。 They exist for the sake of people trying to build kernel modules that are developed separately from the kernel proper. 它们的存在是为了帮助人们尝试构建与内核本身分开开发的内核模块。 It's possible that one of them is textually the same as /usr/include/x86_64-linux-gnu/asm/unistd_64 but that is not something you should rely on. 从文本/usr/include/x86_64-linux-gnu/asm/unistd_64 ,其中一个可能与/usr/include/x86_64-linux-gnu/asm/unistd_64但这不是您应依赖的。

  • /usr/src/linux-headers-3.5.0-23-generic/arch/x86/include/generated/ asm/.unistd_64.h.cmd : This is not a header file at all, it is used by the Linux kernel's build system. /usr/src/linux-headers-3.5.0-23-generic/arch/x86/include/generated/ asm/.unistd_64.h.cmd :根本不是头文件,Linux内核使用构建系统。

The first file, which resides in /usr/include (the system include directory) is the one you would include. 第一个文件位于/usr/include (系统包含目录)中,是您要包含的文件。

The others reside in /usr/src , which is a source code directory that should not be referenced. 其他的位于/usr/src ,这是不应引用的源代码目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM