官术网_书友最值得收藏!

Delving into C libraries

The first library that we'll discuss here is the glibc library, which is designed for performance, compliance of standards, and portability. It was developed by the Free Software Foundation for the GNU/Linux operating system and is still present today on all GNU/Linux host systems that are actively maintained. It was released under the GNU Lesser General Public License.

The glibc library was initially written by Roland McGrath in the 1980s and it continued to grow until the 1990s when the Linux kernel forked glibc, calling it Linux libc. It was maintained separately until January 1997 when the Free Software Foundation released glibc 2.0. The glibc 2.0 contained so many features that it did not make any sense to continue the development of Linux libc, so they discontinued their fork and returned to using glibc. There are changes that are made in Linux libc that were not merged into glibc because of problems with the authorship of the code.

The glibc library is quite large in terms of its dimensions and isn't a suitable fit for small embedded systems, but it provides the functionality required by the Single UNIX Specification (SUS), POSIX, ISO C11, ISO C99, Berkeley Unix interfaces, System V Interface Definition, and the X/Open Portability Guide, Issue 4.2, with all its extensions common with X/Open System Interface compliant systems along with X/Open UNIX extensions. In addition to this, GLIBC also provides extensions that have been deemed useful or necessary while developing GNU.

The next C library that I'm going to discuss here is the one that resides as the main C library used by the Yocto Project until version 1.7. Here, I'm referring to the eglibc library. This is a version of glibc optimized for the usage of embedded devices and is, at the same time, able to preserve the compatibility standards.

Since 2009, Debian and a number of its derivations chose to move from the GNU C Library to eglibc. This might be because there is a difference in licensing between GNU LGPL and eglibc, and this permits them to accept patches that glibc developers my reject. Since 2014, the official eglibc homepage states that the development of eglibc was discontinued because glibc had also moved to the same licensing, and also, the release of Debian Jessie meant that it had moved back to glibc. This also happened in the case of Yocto support when they also decided to make glibc their primary library support option.

The newlib library is another C library developed with the intention of being used in embedded systems. It is a conglomerate of library components under free software licenses. Developed by Cygnus Support and maintained by Red Hat, it is one of the preferred versions of the C library used for non-Linux embedded systems.

The newlib system calls describe the usage of the C library across multiple operation systems, and also on embedded systems that do not require an operating system. It is included in commercial GCC distributions, such as Red Hat, CodeSourcery, Attolic, KPIT and others. It also supported by architecture vendors that include ARM, Renesas, or Unix-like environments, such as Cygwin, and even proprietary operating systems of the Amiga personal computer.

By 2007, it also got support from the toolchain maintainers of Nintendo DS, PlayStation, portable SDK Game Boy Advance systems, Wii, and GameCube development platforms. Another addition was made to this list in 2013 when Google Native Client SDK included newlib as their primary C library.

Bionic is a derivate of the BSD C library developed by Google for Android based on the Linux kernel. Its development is independent of Android code development. It is licensed as 3-clause BSD license and its goals are publically available. These include the following:

  • Small size: Bionic is smaller in size compared to glibc
  • Speed: This has designed CPUs that work at low frequencies
  • BSD license: Google wished to isolate Android apps from GPL and LGPL licenses, and this is the reason it moved to a non-copyleft license which are as follows:
    • Android is based on a Linux kernel which is based on a GPLv2 license
    • glibc is based on LGPL, which permits the linking of dynamic proprietary libraries but not with static linking

It also has a list of restrictions compared to glibc, as follows:

  • It does not include C++ exception handling, mainly because most the code used for Android is written in Java.
  • It does not have wide character support.
  • It does not include a Standard Template library, although it can be included manually.
  • It functions within Bionic POSIX and even system call headers are wrappers or stubs for Android -specific functions. This may lead to odd behavior sometimes.
  • When Android 4.2 released, it included support for glibc FORTIFY_SOURCE features. These features are very often used in Yocto, and embedded systems in general, but are only present in the gcc version for Android devices with ARM processors.

The next C library that will be discussed is musl. It is a C library intended for use with Linux operating systems for embedded and mobile systems. It has a MIT license and was developed with the idea of having a clean, standard-compliant libc, which is time efficient, since it's been developed from scratch. As a C library, it is optimized for the linking of static libraries. It is compatible with C99 standard and POSIX 2008, and implements Linux, glibc, and BSD non-standard functions.

Next, we'll discuss uClibc, which is a C standard library designed for Linux embedded systems and mobile devices. Although initially developed for μClinux and designed for microcontrollers, it gathered track and became the weapon of choice for anyone who's has limited space on their device. This has become popular due to the following reasons:

  • It focuses on size rather than performance
  • It has a GNU Lesser General Public License (LGPL) free license
  • It is much smaller the glibc and reduces compilation time
  • It has high configurability due to the fact that many of its features can be enabled using a menuconfig interface similar to the one available on packages, such as Linux kernel, U-Boot, or even BusyBox

The uClibc library also has another quality that makes it quite useful. It introduces a new ideology and, because of this, the C library does not try to support as many standards as possible. However, it focuses on embedded Linux and consists of the features necessary for developers who face the limitation of available space. Due to this reason, this library was written from scratch, and even though it has its fair share of limitations, uClibc is an important alternative to glibc. If we take into consideration the fact that most of the features used from C libraries are present in it, the final size is four times smaller, and WindRiver, MontaVista, and TimeSys are active maintainers of it.

The dietlibc library is a standard C library that was developed by Felix von Leitner and released under the GNU GPL v2 license. Although it also contains some commercial licensed components, its design was based on the same idea as uClibc: the possibility of compiling and linking software while having the smallest size possible. It has another resemblance to uClibc; it was developed from scratch and has only implemented the most used and known standard functions. Its primary usage is mainly in the embedded devices market.

The last in the C libraries list is the klibc standard C library. It was developed by H. Peter Anvin and it was developed to be used as part of the early user space during the Linux startup process. It is used by the components that run the the kernel startup process but aren't used in the kernel mode and, hence, they do not have access to the standard C library.

The development of klibc started in 2002 as an initiative to remove the Linux initialization code outside a kernel. Its design makes it suitable for usage in embedded devices. It also has another advantage: it is optimized for small size and correctness of data. The klibc library is loaded during the Linux startup process from initramfs (a temporary Ram filesystem) and is incorporated by default into initramfs using the mkinitramfs script for Debian and Ubuntu-based filesystems. It also has access to a small set of utilities, such as mount, mkdir, dash, mknod, fstype, nfsmount, run-init and so on, which are very useful in the early init stage.

Note

More information on initramfs can be found using the kernel documentation at https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt.

The klibc library is licensed under GNU GPL since it uses some components from the Linux kernel, so, as a whole, it is visible as a GPL licensed software, limiting its applicability in commercial embedded software. However, most of the source code of libraries is written under the BSD license.

主站蜘蛛池模板: 南康市| 山阴县| 章丘市| 修水县| 贵定县| 中阳县| 陆川县| 田林县| 博湖县| 和林格尔县| 咸阳市| 汾阳市| 潞城市| 长葛市| 保山市| 和硕县| 佛山市| 咸丰县| 锦屏县| 凌源市| 廊坊市| 卢龙县| 凉城县| 拜城县| 白朗县| 德昌县| 沈丘县| 奈曼旗| 凤冈县| 竹溪县| 镶黄旗| 贵港市| 朝阳县| 留坝县| 玛纳斯县| 乌苏市| 鄂州市| 巩留县| 安达市| 垣曲县| 武隆县|