[Tinyx-devel] [PATCH] LIBC: memset and memcpy
Status: Planning
Brought to you by:
davidcohen
|
From: Felipe B. <me...@fe...> - 2008-01-09 15:38:39
|
string.c is mostly complete now, we shall need strerror though
during debugging but this can be done in a separate file.
Signed-off-by: Felipe Balbi <me...@fe...>
---
include/libc/string.h | 2 ++
lib/libc/string.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/include/libc/string.h b/include/libc/string.h
index 9106e7a..8a53d41 100644
--- a/include/libc/string.h
+++ b/include/libc/string.h
@@ -22,6 +22,8 @@
#ifndef __TINYX_LIBC_STRING_H
#define __TINYX_LIBC_STRING_H
+void *memset(void *mem, int data, size_t count)
+void *memcpy(void *dest, const void *src, size_t count)
char *strcat(char *str1, const char *str2);
char *strchr(const char *str, int ch);
int strcoll(const char *str1, const char *str2);
diff --git a/lib/libc/string.c b/lib/libc/string.c
index f54a876..0b9be1c 100644
--- a/lib/libc/string.c
+++ b/lib/libc/string.c
@@ -22,6 +22,37 @@
#include <libc/string.h>
/**
+ * memset - Fill a memory region with data
+ * @mem: Pointer to the start of the area.
+ * @data: The byte to fill the area with
+ * @count: The size of the area.
+ */
+void *memset(void *mem, int data, size_t count)
+{
+ char *tmp = mem;
+
+ while (count--)
+ *tmp++ = data;
+ return mem;
+}
+
+/**
+ * memcpy - Copy memory areas
+ * @dest: Destination of copy task
+ * @src: Where the data to copy from is
+ * @count: The size of the area.
+ */
+void *memcpy(void *dest, const void *src, size_t count)
+{
+ char *tmp = dest;
+ const char *s = src;
+
+ while (count--)
+ *tmp++ = *s++;
+ return dest;
+}
+
+/**
* strcat - Apend one string to another
* @str1: The destination string
* @str2: The source string
--
1.5.4.rc1.21.g0e545-dirty
|