summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-03 16:47:01 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-03 16:47:01 -0400
commit86d2e0776812650bdeef4c8d9d70aaae6746ad95 (patch)
tree25b06527f6fc7256a1e126649e4e654fff7466f8 /lib
parentremove doc (diff)
downloadcomus-86d2e0776812650bdeef4c8d9d70aaae6746ad95.tar.gz
comus-86d2e0776812650bdeef4c8d9d70aaae6746ad95.tar.bz2
comus-86d2e0776812650bdeef4c8d9d70aaae6746ad95.zip
volatile string fns
Diffstat (limited to 'lib')
-rw-r--r--lib/memcpyv.c11
-rw-r--r--lib/memmovev.c20
-rw-r--r--lib/memsetv.c10
3 files changed, 41 insertions, 0 deletions
diff --git a/lib/memcpyv.c b/lib/memcpyv.c
new file mode 100644
index 0000000..205d9c1
--- /dev/null
+++ b/lib/memcpyv.c
@@ -0,0 +1,11 @@
+#include <string.h>
+
+void *memcpyv(volatile void *restrict dest, const volatile void *restrict src,
+ size_t n)
+{
+ char *d = dest;
+ const char *s = src;
+ for (; n; n--)
+ *d++ = *s++;
+ return dest;
+}
diff --git a/lib/memmovev.c b/lib/memmovev.c
new file mode 100644
index 0000000..d2fc683
--- /dev/null
+++ b/lib/memmovev.c
@@ -0,0 +1,20 @@
+#include <string.h>
+
+void *memmovev(volatile void *dest, const volatile void *src, size_t n)
+{
+ char *d = dest;
+ const char *s = src;
+
+ if (d == s)
+ return d;
+
+ if (d < s) {
+ for (; n; n--)
+ *d++ = *s++;
+ } else {
+ while (n)
+ n--, d[n] = s[n];
+ }
+
+ return dest;
+}
diff --git a/lib/memsetv.c b/lib/memsetv.c
new file mode 100644
index 0000000..9039cb7
--- /dev/null
+++ b/lib/memsetv.c
@@ -0,0 +1,10 @@
+#include <string.h>
+
+void *memsetv(volatile void *dest, int c, size_t n)
+{
+ unsigned char *d = dest;
+ for (; n; n--) {
+ *d++ = c;
+ };
+ return dest;
+}