Complete Linux kernel profiling-header file (1)

Source: Internet
Author: User
Before using a function, the program should declare the function. For ease of use, we usually put the declaration of the same class of functions, data structures, and constants in a header file (headerf

Before using a function, the program should declare the function. For ease of use, we usually put the declaration of the same class of functions, data structures, and constants in a header file. The header file can also contain any related type definition and macro (macros ). In the program source code file, the pre-processing command "# include" is used to reference related header files.

The following form of a control line statement in the program will replace the row with the content of the file filename:

# Include

Of course, the file name filename cannot contain> and line breaks, and ", ', or/* characters. The compilation system will search for this file in a series of defined places. Similarly, the following form of control lines allows the compiler to first search for the filename file in the directory where the source program is located:

# Include "filename"

If not, the compiler executes the same search process as above. In this form, filename cannot contain line breaks and ", ', or/* characters, but can contain> characters.

In general application source code, header files are closely related to library files in the development environment. each function in the library must be declared in the header file. Header files (usually placed in the system/usr/include/directory) in the application development environment can be seen as the provided function libraries (such as libc. a) is an integral part of the function. it is the usage instructions or interface declaration of the library function. After the compiler converts the source code program to the target module, the linker program combines all the target modules of the program, including the modules in any library files used. To form an executable program.

For the standard C function library, there are 15 basic header files. Each header file indicates the function description or structure definition of a specific type of function, such as I/O operation functions and character processing functions. For details about The Standard function Library and its implementation, refer to The book The Standard C Library compiled by Plauger.

For the kernel source code described in this book, the header files involved can be considered as a brief description of the services provided by the kernel and its function libraries, and are specialized header files for the kernel and its related programs. These header files mainly describe all the data structures, initialization data, constants, and macro definitions used by the kernel, as well as a small amount of program code. Except for a few specialized header files (such as the block device header file blk. h), the header files used in the Linux 0.12 kernel are placed in the include/directory of the kernel code tree. Therefore, compiling the Linux 0.12 kernel requires no header files in the/usr/include/directory provided by the development environment. Of course, except for the tools/build. c program. Although this program is included in the kernel source code tree, it is only a tool or application used to create a kernel image file in combination and will not be linked to the kernel code.

Starting from version 0.95, the header files in the kernel code tree must be copied to the/usr/include/linux directory to compile the kernel smoothly. That is, starting from this version of the kernel, the header file has been combined with the header file used by the development environment.

14.1 include/Files in the directory

The header files used by the kernel are stored in the include/directory. The files in this directory are shown in Table 11-1. Note: For ease of use and compatibility, the naming method used by Linus when compiling the kernel program header file is similar to that used by the standard C library header file, many header file names and even some of them are basically the same as the header file of the standard C library, but these kernel header files are still kernel source code or dedicated to programs that are closely related to the kernel. In a Linux system, they coexist with standard library header files. The common practice is to place these header files under the subdirectory in the standard library header file directory for use by programs that require kernel data structures or constants.

In addition, due to copyright issues, Linus tries to re-compile some header files to replace the header files of the standard C library with copyright restrictions. Therefore, these header files in the kernel source code overlap with those in the development environment. In Linux, the header files under the asm/, linux/, and sys/subdirectories in the list of 14-1 usually need to be copied to the Directory (/usr/include) where the header files of the standard C library are located) and other files, if there is no conflict with the standard library header file, you can directly put it under the standard library header file directory, or change it to the three subdirectories here.

The asm/directory is mainly used to store function declaration or data structure header files closely related to the computer architecture. For example, Intel CPU port I/O assembly macro file I/O. h, interrupt descriptor setting assembly macro header file system. h, etc. The linux/directory contains some header files used by linux kernel programs. These include the header file sched. h used by the scheduler, the memory management header file mm. h, and the terminal management data structure file tty. h. The sys/directory stores several header files related to kernel resources. However, starting from version 0.98, all the header files in the sys/directory under the kernel directory were moved to the linux/directory.

The Linux 0.12 kernel contains 32 header files (*. h), including 4 in the asm/subdirectory, 10 in the linux/subdirectory, and 5 in the sys/subdirectory. Starting from the next section, we will first describe the 13 header files under the include/directory, and then describe the files in each subdirectory in sequence. Sort by file name.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.