1# musl libc 2 3## Overview 4The C standard library (libc) provides standard header files and common library implementations (such as input/output processing and string handling) in C language programming. 5 6OpenHarmony uses musl as the libc. musl is a lightweight, fast, simple, and free open-source libc. For details, see [musl libc Reference Manual](http://musl.libc.org/manual.html). 7 8For details about the differences between musl and glibc, see [Functional differences from glibc](https://wiki.musl-libc.org/functional-differences-from-glibc.html). 9 10## libc Components 11 12C11 is implemented by [libc, libm, and libdl](https://en.cppreference.com/w/c/header). 13 14- libc: provides thread-related interfaces and a majority of standard interfaces. 15 16- libm: provides mathematical library interfaces. Currently, OpenHarmony provides a link to libm, and the interfaces are defined in libc. 17 18- libdl: provides dynamic linker interfaces such as dlopen. Currently, OpenHarmony provides a link to libdl, and the interfaces are defined in libc. 19 20 21## musl Version 22 23- 1.2.0 24- 1.2.3 from OpenHarmony 4.0 25- 1.2.5 from OpenHarmony 5.0 26 27## Supported Capabilities 28OpenHarmony provides header files and library interfaces that are compatible (not fully compatible) with C99, C11, and POSIX, and supports Armv7-A, Arm64, and x86_64 architectures. 29 30To better adapt to the basic features of OpenHarmony devices, such as high performance, low memory, high security, lightweight, and multi-form support, OpenHarmony has optimized the musl library and removed the interfaces that are not applicable to embedded devices. 31 32### New Capabilities 331. The dynamic loader supports isolation by namespace. The dynamic libraries that can be loaded by **dlopen()** are restricted by the system namespace. For example, the system dynamic libraries cannot be opened. 342. **dlclose()** can be used to unload a dynamic library. This capability is not supported by musl. 353. The symbol-versioning is supported. 364. **dlopen()** can directly load uncompressed files in a .zip package. 37 38### Debugging Capabilities 39The libc provides dynamic enabling of debug logging (disabled by default). The debug logs help you learn about exceptions of the libc. With this function, you only need to set **param**, which eliminates the need for rebuilding the libc. However, you are advised not to enable debug logging in official versions because it affects the running performance. 40 41#### musl.log 42Set **musl.log.enable** to **true** to enable printing of musl debug logs. You need to enable musl.log before printing other logs. 43``` 44param set musl.log.enable true 45``` 46 47#### Loader Logging 48The loader starts applications and invokes **dlopen** and **dlclose** in the libc. To view exceptions during the loading process, you need to enable the loader logging function. The following describes common operations. 49* Enable the loader logging for all applications. Exercise caution when enabling this function because a large number of logs will be generated. 50``` 51param set musl.log.ld.app true 52``` 53* Enable the loader logging for an application specified by {app_name}. 54``` 55param set musl.log.ld.all false 56param set musl.log.ld.app.{app_name} true 57``` 58* Enable the loader logging for all applications except the specified application. 59``` 60param set musl.log.ld.all true 61param set musl.log.ld.app.{app_name} false 62``` 63 64## Character Encoding Formats Supported by iconv 65 66The following lists the character encoding formats and aliases supported by musl. 67> **NOTE** 68> 69> The character conversion can be successful only when the source character encoding format is correct and the target character encoding format is supported. 70> musl does not support the following target encoding formats: gb18030, gbk, gb2312, big5, and euckr. 71 72| Encoding Format | Alias | Supported by musl| 73|:-- | :-- | :--: | 74|utf8 | | Yes | 75|wchart | | Yes | 76|ucs2be | | Yes | 77|ucs2le | | Yes | 78|utf16be | | Yes | 79|utf16le | | Yes | 80|ucs4be |utf32be | Yes | 81|ucs4le |utf32le | Yes | 82|ascii |usascii, iso646, iso646us | Yes | 83|utf16 | | Yes | 84|ucs4 |utf32 | Yes | 85|ucs2 | | Yes | 86|eucjp | | Yes | 87|shiftjis |sjis, cp932 | Yes | 88|iso2022jp| | Yes | 89|gb18030 | | Yes | 90|gbk | | Yes | 91|gb2312 | | Yes | 92|big5 |bigfive, cp950, big5hkscs | Yes | 93|euckr |ksc5601, ksx1001, cp949 | Yes | 94|iso88591 |latin1 | Yes | 95|iso88592 | | Yes | 96|iso88593 | | Yes | 97|iso88594 | | Yes | 98|iso88595 | | Yes | 99|iso88596 | | Yes | 100|iso88597 | | Yes | 101|iso88598 | | Yes | 102|iso88599 | | Yes | 103|iso885910| | Yes | 104|iso885911|tis620 | Yes | 105|iso885913| | Yes | 106|iso885914| | Yes | 107|iso885915|latin9 | Yes | 108|iso885916| | Yes | 109|cp1250 |windows1250 | Yes | 110|cp1251 |windows1251 | Yes | 111|cp1252 |windows1252 | Yes | 112|cp1253 |windows1253 | Yes | 113|cp1254 |windows1254 | Yes | 114|cp1255 |windows1255 | Yes | 115|cp1256 |windows1256 | Yes | 116|cp1257 |windows1257 | Yes | 117|cp1258 |windows1258 | Yes | 118|koi8r | | Yes | 119|koi8u | | Yes | 120|cp437 | | Yes | 121|cp850 | | Yes | 122|cp866 | | Yes | 123|cp1047 |ibm1047 | Yes | 124 125## musl APIs Not Supported 126 127[Native API Symbols Not Exported](musl-peculiar-symbol.md) 128 129[Restricted musl libc APIs](guidance-on-ndk-libc-interfaces-affected-by-permissions.md) 130 131 132<!--no_check--> 133