C Library (libc)
Last updated
Last updated
Assoc. Prof. Wiroon Sriborrirux, Founder of Advance Innovation Center (AIC) and Bangsaen Design House (BDH), Electrical Engineering Department, Faculty of Engineering, Burapha University
The LIBC (C library) provided by RT-Thread consists of three parts: the compiler built-in LIBC leveling layer and the POSIX layer. The layout is shown in the following figure:
The LIBC balancing layer is responsible for docking the underlying stub functions of the built-in LIBC of the compiler toolchain and balancing the differences in the implementation of the built-in LIBC API of different compilers. It provides a unified functional interface for the upper POSIX layer and is located in the components/libc/compiler file directory. Balancing is required because the standard C library functions provided by the built-in LIBC of the four compilation toolchains GCC (newlib), Keil-MDK, IAR, and Visual Studio (WIN32) have different levels of support. The LIBC balancing layer is responsible for balancing the standard C libraries provided by the four different compilation chains to the same level. The LIBC balancing layer does not require manual intervention by the user. It will automatically perform balancing according to the compilation platform and toolchain used by the user when compiling the project. It ensures that the upper layer does not need to distinguish which compilation platform and toolchain LIBC is used, and can use a common header file to reference the relevant functions of LIBC.
ANSI C, ISO C, Standard C refers to the standard for the C language published by the American National Standards Institute (ANSI) and the International Organization for Standardization (ISO). Historically, this name was used exclusively to refer to the original and best-supported version of this standard (called C89 or C90). Software developers using C are encouraged to follow the requirements of the standard because it encourages the use of cross-platform code. The first standard for C was published by ANSI. Although this document was later adopted by the International Organization for Standardization (ISO) and the revisions published by ISO were also adopted by ANSI, the name ANSI C (rather than ISO C) is still widely used. Some software developers use the name ISO C, while others use the neutral name Standard C. For example, the commonly mentioned C89 (ANSI X3.159-1989), C99 (ISO/IEC 9899:1999), and C11 (ISO/IEC 9899:2011) actually refer to different versions of the standard.
This standard is usually supported by the built-in LIBC of the compiler/toolchain. For example, the built-in LIBC provided by Keil-MDK, IAR, etc. all meet this standard.
Portable Operating System Interface (POSIX) is the general name of a series of interrelated standards that define APIs for running software on various UNIX operating systems. Its official name is IEEE Std 1003, and its international standard name is ISO/IEC 9945. ISO/ANSI C is a subset of POSIX.
For LIBC, the widely used POSIX standard is the 1003.1 standard, whose full name is IEEE Std 1003.1 (abbreviated as POSIX.1). IEEE Std 1003.1-2001, IEEE Std 1003.1-2008, etc. are the updated versions of POSIX.1 released at different times.
This standard is POSIX's real-time profile. This standard is a subset of IEEE Std 1003.1. IEEE Std. 1003.13 defines four subsets:
Minimal: Minimal Embedded Subset Specification - PSE51
Controller: Industrial Controller Subset Specification - PSE52
Dedicated: A larger subset of embedded systems specifications - PSE53
Multi-Purpose: A subset specification for large-scale general-purpose systems with real-time requirements - PSE54
Currently, RT-Thread has implemented the PSE51 specification and part of the PSE52 specification.
File
API
PSE51
PSE52
PSE53
PSE54
RT-Thread
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
√
*
*
*
√
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
√
*
*
√
*
*
√
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
√
*
*
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
*
*
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
*
*
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
*
*
*
*
√
*
*
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
*
*
*
*
*
*
√
*
*
*
*
*
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
*
*
*
*
√
*
*
*
*
*
*
*
*
√
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√
*
*
*
*
√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