aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libc/memrchr.c
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-02-07 04:22:22 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-02-07 04:22:22 +0000
commitd36ae3e4c44c6547467f7ca92298ebad99700cb3 (patch)
tree76d9e0cabe45c1ed6d9ea87a5deb9c75c4345653 /lib/libc/memrchr.c
parentf94bb7f616791b95961e9d25c0a7b0c79fd45edc (diff)
parentcabe6937f2c9d0a50e4631c0545bddd650233ae8 (diff)
downloadplatform_external_arm-trusted-firmware-android11-gsi.tar.gz
platform_external_arm-trusted-firmware-android11-gsi.tar.bz2
platform_external_arm-trusted-firmware-android11-gsi.zip
Change-Id: Id9d1eda28e2f504532858d4c602eeebec865f19e
Diffstat (limited to 'lib/libc/memrchr.c')
-rw-r--r--lib/libc/memrchr.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/libc/memrchr.c b/lib/libc/memrchr.c
new file mode 100644
index 000000000..01caef3ae
--- /dev/null
+++ b/lib/libc/memrchr.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2019, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <string.h>
+
+#undef memrchr
+
+void *memrchr(const void *src, int c, size_t len)
+{
+ const unsigned char *s = src + (len - 1);
+
+ while (len--) {
+ if (*s == (unsigned char)c) {
+ return (void*) s;
+ }
+
+ s--;
+ }
+
+ return NULL;
+}