summaryrefslogtreecommitdiffstats
path: root/include/c/mem/chr/memchr.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/c/mem/chr/memchr.h')
-rw-r--r--include/c/mem/chr/memchr.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/c/mem/chr/memchr.h b/include/c/mem/chr/memchr.h
new file mode 100644
index 0000000..9c4eb29
--- /dev/null
+++ b/include/c/mem/chr/memchr.h
@@ -0,0 +1,31 @@
+// 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_MEMCHR_H_
+#define INCLUDE_C_MEM_CHR_MEMCHR_H_
+
+
+#include <string.h>
+#include <sys/types.h>
+
+#include <c/qual/const/const.h>
+#include <c/qual/nullable/nullable.h>
+
+
+#define c_memchr(mem, c, sz) c_const_generic_func(c_memchr, mem, c, sz)
+
+
+#pragma clang assume_nonnull begin
+inline const void *c_nullable (c_memchr)(const void *mem, u_char c, size_t sz);
+
+
+inline const void *c_nullable
+(c_memchr)(const void *mem, u_char c, size_t sz)
+{
+ return memchr(mem, c, sz);
+}
+#pragma clang assume_nonnull end
+
+
+#endif // Header guard