Linux kernel header files and kernel library files

Source: Internet
Author: User

Unlike user-space applications, the kernel cannot invoke standard C libraries or any other libraries that are not part of the kernel. The main reason is the speed and size limits.

The standard C library is too big for the kernel.

Many of the commonly used LIBC functions have been implemented in the kernel. The library files in the kernel are stored in the root directory of the kernel under the Lib directory.

As the commonly used string manipulation functions are defined in LIB/STRING.C, the host needs to include the header file <linux/string.h> into the call.

With regard to the kernel's header file, the kernel cannot contain header files outside the kernel, as if the kernel cannot call libraries outside the kernel.

1) The basic header file is placed in the kernel's include/directory, such as the following referenced header file

#include <linux/i2c.h>

Located in Include/linux/i2c.h

2) the platform-related header files are located under Arch/<architecture>/include/asm, prefixed with asm/when the header files are included, as follows:

#include <asm/ioctl.h>

printf () cannot be called in the kernel, but the kernel provides PRINTK () for us to use.

PRINTK () is similar to the use of printf (), as follows:

PRINTK ("Hello world! A string '%s ' and an integer '%d ' \ n', str, i);

A notable difference between PRINTK () and printf () is that PRINTK () allows the use of priority tags. The priority flag is used by the SYSLOGD process to determine where to display

The kernel prints information. The following example:

" This was an error!\n ");

Note that there is no comma after the priority tag Kern_err.

Linux kernel header files and kernel library files

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.