summaryrefslogtreecommitdiffstats
path: root/include/c/mem/chr/memrchr.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/c/mem/chr/memrchr.h')
-rw-r--r--include/c/mem/chr/memrchr.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/include/c/mem/chr/memrchr.h b/include/c/mem/chr/memrchr.h
new file mode 100644
index 0000000..01b7f0d
--- /dev/null
+++ b/include/c/mem/chr/memrchr.h
@@ -0,0 +1,30 @@
+// Copyright 2022 Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: LGPL-3.0-or-later WITH LGPL-3.0-linking-exception
+
+
+#ifndef INCLUDE_C_MEM_CHR_MEMRCHR_H_
+#define INCLUDE_C_MEM_CHR_MEMRCHR_H_
+
+
+#include <string.h>
+#include <sys/types.h>
+
+#include <c/qual/const/const.h>
+
+
+#define c_memrchr(mem, c, sz) c_const_generic_func(c_memrchr, mem, c, sz)
+
+
+#pragma clang assume_nonnull begin
+inline const void *(c_memrchr)(const void *mem, u_char c, size_t sz);
+
+
+inline const void *
+(c_memrchr)(const void *mem, u_char c, size_t sz)
+{
+ return memrchr(mem, c, sz);
+}
+#pragma clang assume_nonnull end
+
+
+#endif // Header guard