From c8db9fe9058d10f1c0d1e0b4d8775d5245d77857 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Tue, 20 Oct 2020 17:55:31 -0400 Subject: [PATCH] add string.h --- src/string.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/string.h diff --git a/src/string.h b/src/string.h new file mode 100644 index 0000000..abf500b --- /dev/null +++ b/src/string.h @@ -0,0 +1,26 @@ +#ifndef STRING_H +#define STRING_H + +#include + +static inline size_t strlen(const char * s) +{ + size_t r = 0u; + while (*s++ != (char)0) + { + r++; + } + return r; +} + +static inline char * strcpy(char * dest, const char * src) +{ + return __builtin_strcpy(dest, src); +} + +static inline char * strncpy(char * dest, const char * src, size_t n) +{ + return __builtin_strncpy(dest, src, n); +} + +#endif