1================ 2String Functions 3================ 4 5.. include:: check.rst 6 7--------------- 8Source location 9--------------- 10 11- The main source for string functions is located at: 12 ``libc/src/string``. 13 14- The source for string conversion functions is located at: 15 ``libc/src/stdlib`` and 16 ``libc/src/__support``. 17 18- The tests are located at: 19 ``libc/test/src/string``, 20 ``libc/test/src/stdlib``, and 21 ``libc/test/src/__support`` 22 respectively. 23 24--------------------- 25Implementation Status 26--------------------- 27 28Primary memory functions 29======================== 30 31.. TODO(gchatelet): add details about the memory functions. 32 33 34============= ========= 35Function Name Available 36============= ========= 37bzero |check| 38bcmp |check| 39bcopy |check| 40memcpy |check| 41memset |check| 42memcmp |check| 43memmove |check| 44============= ========= 45 46 47Other Raw Memory Functions 48========================== 49 50============= ========= 51Function Name Available 52============= ========= 53memchr |check| 54memrchr |check| 55memccpy |check| 56mempcpy |check| 57============= ========= 58 59String Memory Functions 60======================= 61 62============= ========= 63Function Name Available 64============= ========= 65stpcpy |check| 66stpncpy |check| 67strcpy |check| 68strncpy |check| 69strcat |check| 70strncat |check| 71strdup |check| 72strndup |check| 73============= ========= 74 75String Examination Functions 76============================ 77 78============= ========= 79Function Name Available 80============= ========= 81strlen |check| 82strnlen |check| 83strcmp |check| 84strncmp |check| 85strchr |check| 86strrchr |check| 87strspn |check| 88strcspn |check| 89strpbrk |check| 90strstr |check| 91strtok |check| 92strtok_r |check| 93============= ========= 94 95String Conversion Functions 96============================ 97 98These functions are not in strings.h, but are still primarily string 99functions, and are therefore tracked along with the rest of the string 100functions. 101 102The String to float functions were implemented using the Eisel-Lemire algorithm 103(read more about the algorithm here: `The Eisel-Lemire ParseNumberF64 Algorithm 104<https://nigeltao.github.io/blog/2020/eisel-lemire.html>`_). This improved 105the performance of string to float and double, and allowed it to complete this 106comprehensive test 15% faster than glibc: `Parse Number FXX Test Data 107<https://github.com/nigeltao/parse-number-fxx-test-data>`_. The test was done 108with LLVM-libc built on 2022-04-14 and Debian GLibc version 2.33-6. The targets 109``libc_str_to_float_comparison_test`` and 110``libc_system_str_to_float_comparison_test`` were built and run on the test data 11110 times each, skipping the first run since it was an outlier. 112 113 114============= ========= 115Function Name Available 116============= ========= 117atof |check| 118atoi |check| 119atol |check| 120atoll |check| 121strtol |check| 122strtoll |check| 123strtoul |check| 124strtoull |check| 125strtof |check| 126strtod |check| 127strtold |check| 128strtoimax |check| 129strtoumax |check| 130============= ========= 131 132String Error Functions 133====================== 134 135============= ========= 136Function Name Available 137============= ========= 138strerror |check| 139strerror_r |check| 140============= ========= 141 142Localized String Functions 143========================== 144 145These functions require locale.h, and will be finished when locale support is 146implemented in LLVM-libc. 147 148============= ========= 149Function Name Available 150============= ========= 151strcoll Partially 152strxfrm Partially 153============= ========= 154 155--------------------------- 156\<name\>_s String Functions 157--------------------------- 158 159Many String functions have an equivalent _s version, which is intended to be 160more secure and safe than the previous standard. These functions add runtime 161error detection and overflow protection. While they can be seen as an 162improvement, adoption remains relatively low among users. In addition, they are 163being considered for removal, see 164`Field Experience With Annex K — Bounds Checking Interfaces 165<http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1967.htm>`_. For these reasons, 166there is no ongoing work to implement them. 167