Anas Nashif | 6e1fbd9 | 2016-12-24 08:40:16 -0500 | [diff] [blame] | 1 | .. _c_library_v2: |
| 2 | |
| 3 | Standard C Library |
| 4 | ################## |
| 5 | |
| 6 | The kernel currently provides only the minimal subset of the standard C library |
Anas Nashif | 7d82e17 | 2019-09-15 23:47:55 -0400 | [diff] [blame] | 7 | required to meet the needs of Zephyr and its subsystems and features, primarily |
| 8 | in the areas of string manipulation and display. |
Anas Nashif | 6e1fbd9 | 2016-12-24 08:40:16 -0500 | [diff] [blame] | 9 | |
| 10 | Applications that require a more extensive C library can either submit |
Anas Nashif | 7d82e17 | 2019-09-15 23:47:55 -0400 | [diff] [blame] | 11 | contributions that enhance the existing library or substitute with a |
| 12 | replacement library. |
Anas Nashif | 6e1fbd9 | 2016-12-24 08:40:16 -0500 | [diff] [blame] | 13 | |
David B. Kinder | f5ea8fe | 2017-02-27 13:15:43 -0800 | [diff] [blame] | 14 | The Zephyr SDK and other supported toolchains comes with a bare-metal C library |
Anas Nashif | 6e1fbd9 | 2016-12-24 08:40:16 -0500 | [diff] [blame] | 15 | based on ``newlib`` that can be used with Zephyr by selecting the |
| 16 | :option:`CONFIG_NEWLIB_LIBC` in the application configuration file. Part of the |
| 17 | support for ``newlib`` is a set of hooks available under |
| 18 | :file:`lib/libc/newlib/libc-hooks.c` which integrates the c library with basic |
| 19 | kernel services. |
Anas Nashif | 7d82e17 | 2019-09-15 23:47:55 -0400 | [diff] [blame] | 20 | |
| 21 | |
| 22 | Minimal C Library |
| 23 | ***************** |
| 24 | |
| 25 | The minimal C library is part of Zephyr and provides a minimal set of C |
| 26 | functions needed by Zephyr. |
| 27 | |
| 28 | The following functions are implemented in the minimal C |
| 29 | library included with Zephyr: |
| 30 | |
David B. Kinder | f652129 | 2019-09-17 14:19:02 -0700 | [diff] [blame] | 31 | .. rst-class:: rst-columns |
Anas Nashif | 7d82e17 | 2019-09-15 23:47:55 -0400 | [diff] [blame] | 32 | |
| 33 | - abs() |
| 34 | - atoi() |
| 35 | - bsearch() |
| 36 | - calloc() |
| 37 | - free() |
| 38 | - gmtime() |
| 39 | - gmtime_r() |
| 40 | - isalnum() |
| 41 | - isalpha() |
| 42 | - isdigit() |
| 43 | - isgraph() |
| 44 | - isprint() |
| 45 | - isspace() |
| 46 | - isupper() |
| 47 | - isxdigit() |
| 48 | - localtime() |
| 49 | - malloc() |
| 50 | - memchr() |
| 51 | - memcmp() |
| 52 | - memcpy() |
| 53 | - memmove() |
| 54 | - memset() |
| 55 | - mktime() |
| 56 | - rand() |
| 57 | - realloc() |
| 58 | - snprintf() |
| 59 | - sprintf() |
| 60 | - strcat() |
| 61 | - strchr() |
| 62 | - strcmp() |
| 63 | - strcpy() |
| 64 | - strlen() |
| 65 | - trncat() |
| 66 | - strncmp() |
| 67 | - strncpy() |
| 68 | - strrchr() |
| 69 | - strstr() |
| 70 | - strtol() |
| 71 | - trtoul() |
| 72 | - time() |
| 73 | - tolower() |
| 74 | - toupper() |
| 75 | - vsnprintf() |
| 76 | - vsprintf() |