summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/config/linux/aarch64/entrypoints.txt2
-rw-r--r--libc/config/linux/arm/entrypoints.txt2
-rw-r--r--libc/config/linux/riscv64/entrypoints.txt2
-rw-r--r--libc/config/linux/x86_64/entrypoints.txt2
-rw-r--r--libc/spec/bsd_ext.td10
-rw-r--r--libc/src/string/CMakeLists.txt20
-rw-r--r--libc/test/src/string/CMakeLists.txt34
7 files changed, 66 insertions, 6 deletions
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 6fb32065856d..7d76e83d27a3 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -33,6 +33,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.bcmp
libc.src.string.bcopy
libc.src.string.bzero
+ libc.src.string.index
libc.src.string.memccpy
libc.src.string.memchr
libc.src.string.memcmp
@@ -41,6 +42,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.mempcpy
libc.src.string.memrchr
libc.src.string.memset
+ libc.src.string.rindex
libc.src.string.stpcpy
libc.src.string.stpncpy
libc.src.string.strcasecmp
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 4ae8b0f44a8b..5ed49d03eb9c 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -24,6 +24,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.bcmp
libc.src.string.bcopy
libc.src.string.bzero
+ libc.src.string.index
libc.src.string.memccpy
libc.src.string.memchr
libc.src.string.memcmp
@@ -32,6 +33,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.mempcpy
libc.src.string.memrchr
libc.src.string.memset
+ libc.src.string.rindex
libc.src.string.stpcpy
libc.src.string.stpncpy
libc.src.string.strcasecmp
diff --git a/libc/config/linux/riscv64/entrypoints.txt b/libc/config/linux/riscv64/entrypoints.txt
index 0c59d91cc0c5..936949f779af 100644
--- a/libc/config/linux/riscv64/entrypoints.txt
+++ b/libc/config/linux/riscv64/entrypoints.txt
@@ -33,6 +33,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.bcmp
libc.src.string.bcopy
libc.src.string.bzero
+ libc.src.string.index
libc.src.string.memccpy
libc.src.string.memchr
libc.src.string.memcmp
@@ -41,6 +42,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.mempcpy
libc.src.string.memrchr
libc.src.string.memset
+ libc.src.string.rindex
libc.src.string.stpcpy
libc.src.string.stpncpy
libc.src.string.strcasecmp
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 13c788df6400..9e450eadc9d4 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -33,6 +33,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.bcmp
libc.src.string.bcopy
libc.src.string.bzero
+ libc.src.string.index
libc.src.string.memccpy
libc.src.string.memchr
libc.src.string.memcmp
@@ -41,6 +42,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.mempcpy
libc.src.string.memrchr
libc.src.string.memset
+ libc.src.string.rindex
libc.src.string.stpcpy
libc.src.string.stpncpy
libc.src.string.strcasecmp
diff --git a/libc/spec/bsd_ext.td b/libc/spec/bsd_ext.td
index 3420c2098449..3829e57e9765 100644
--- a/libc/spec/bsd_ext.td
+++ b/libc/spec/bsd_ext.td
@@ -39,6 +39,16 @@ def BsdExtensions : StandardSpec<"BSDExtensions"> {
RetValSpec<IntType>,
[ArgSpec<ConstCharPtr>, ArgSpec<ConstCharPtr>, ArgSpec<SizeTType>]
>,
+ FunctionSpec<
+ "index",
+ RetValSpec<CharPtr>,
+ [ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
+ >,
+ FunctionSpec<
+ "rindex",
+ RetValSpec<CharPtr>,
+ [ArgSpec<ConstCharPtr>, ArgSpec<IntType>]
+ >,
]
>;
diff --git a/libc/src/string/CMakeLists.txt b/libc/src/string/CMakeLists.txt
index f6980ca632bb..f51e68c99193 100644
--- a/libc/src/string/CMakeLists.txt
+++ b/libc/src/string/CMakeLists.txt
@@ -32,6 +32,16 @@ add_entrypoint_object(
)
add_entrypoint_object(
+ index
+ SRCS
+ index.cpp
+ HDRS
+ index.h
+ DEPENDS
+ .string_utils
+)
+
+add_entrypoint_object(
memccpy
SRCS
memccpy.cpp
@@ -68,6 +78,16 @@ add_entrypoint_object(
)
add_entrypoint_object(
+ rindex
+ SRCS
+ rindex.cpp
+ HDRS
+ rindex.h
+ DEPENDS
+ .string_utils
+)
+
+add_entrypoint_object(
stpcpy
SRCS
stpcpy.cpp
diff --git a/libc/test/src/string/CMakeLists.txt b/libc/test/src/string/CMakeLists.txt
index ed9d38aa482a..6bb4c562a239 100644
--- a/libc/test/src/string/CMakeLists.txt
+++ b/libc/test/src/string/CMakeLists.txt
@@ -14,6 +14,23 @@ add_libc_unittest(
LibcMemoryHelpers
)
+add_header_library(
+ strchr_test_support
+ HDRS
+ StrchrTest.h
+)
+
+add_libc_unittest(
+ index_test
+ SUITE
+ libc_string_unittests
+ SRCS
+ index_test.cpp
+ DEPENDS
+ libc.src.string.index
+ .strchr_test_support
+)
+
add_libc_unittest(
memccpy_test
SUITE
@@ -55,6 +72,17 @@ add_libc_unittest(
)
add_libc_unittest(
+ rindex_test
+ SUITE
+ libc_string_unittests
+ SRCS
+ rindex_test.cpp
+ DEPENDS
+ libc.src.string.rindex
+ .strchr_test_support
+)
+
+add_libc_unittest(
stpcpy_test
SUITE
libc_string_unittests
@@ -84,12 +112,6 @@ add_libc_unittest(
libc.src.string.strcat
)
-add_header_library(
- strchr_test_support
- HDRS
- StrchrTest.h
-)
-
add_libc_unittest(
strchr_test
SUITE