summaryrefslogtreecommitdiff
path: root/src/library/std
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-04-05 20:32:08 +0200
committerAlexis211 <alexis211@gmail.com>2010-04-05 20:32:08 +0200
commitca4f5906f284e60a7a59ca7450e3e09c4f9356e5 (patch)
treea44542c66cd9533c921f399fc1bee62703d15538 /src/library/std
parent8d94ae49601e0e4023bcdc35191669b2c24f6c96 (diff)
downloadTCE-ca4f5906f284e60a7a59ca7450e3e09c4f9356e5.tar.gz
TCE-ca4f5906f284e60a7a59ca7450e3e09c4f9356e5.zip
Some stuff added to userland.
Diffstat (limited to 'src/library/std')
-rw-r--r--src/library/std/string.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/library/std/string.c b/src/library/std/string.c
new file mode 100644
index 0000000..869256a
--- /dev/null
+++ b/src/library/std/string.c
@@ -0,0 +1,39 @@
+#include <string.h>
+
+int strlen(const char *str) {
+ int i = 0;
+ while (str[i++]);
+ return i;
+}
+
+void *memcpy(void *vd, const void *vs, int count) {
+ uint8_t *dest = (uint8_t*)vd, *src = (uint8_t*)vs;
+ uint32_t f = count % 4, n = count / 4, i;
+ const uint32_t* s = (uint32_t*)src;
+ uint32_t* d = (uint32_t*)dest;
+ for (i = 0; i < n; i++) {
+ d[i] = s[i];
+ }
+ if (f != 0) {
+ for (i = count - f; i < count; i++) {
+ dest[i] = src[i];
+ }
+ }
+ return vd;
+}
+
+uint8_t *memset(uint8_t *dest, uint8_t val, int count) {
+ int i;
+ for (i = 0; i < count; i++) {
+ dest[i] = val;
+ }
+ return dest;
+}
+
+uint16_t *memsetw(uint16_t *dest, uint16_t val, int count) {
+ int i;
+ for (i = 0; i < count; i++) {
+ dest[i] = val;
+ }
+ return dest;
+}