summaryrefslogtreecommitdiff
path: root/src/user/lib/std/string.c
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2012-05-19 11:45:49 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2012-05-19 11:45:49 +0200
commit499ca6c243b05da176a2d4bd9a2317f0b28afc7f (patch)
treef55ff788632b017ab8de83b71ad02b0998e1dda5 /src/user/lib/std/string.c
parent7b466345af0d3a7dc5622617ce443a90c64e34a4 (diff)
downloadTCE-499ca6c243b05da176a2d4bd9a2317f0b28afc7f.tar.gz
TCE-499ca6c243b05da176a2d4bd9a2317f0b28afc7f.zip
Introducing FWIK, the userland C++ framework. Far from complete.
Diffstat (limited to 'src/user/lib/std/string.c')
-rw-r--r--src/user/lib/std/string.c80
1 files changed, 0 insertions, 80 deletions
diff --git a/src/user/lib/std/string.c b/src/user/lib/std/string.c
deleted file mode 100644
index 21dbd03..0000000
--- a/src/user/lib/std/string.c
+++ /dev/null
@@ -1,80 +0,0 @@
-#include <string.h>
-
-int strlen(const char *str) {
- int i = 0;
- while (str[i++]);
- return i-1;
-}
-
-char *strchr(const char *str, int c) {
- while (*str) {
- if (*str == c) return (char*)str;
- str++;
- }
- return NULL;
-}
-
-char *strcpy(char *dest, const char *src) {
- memcpy(dest, src, strlen(src) + 1);
- return (char*)src;
-}
-
-char *strdup(const char *src) {
- char* ret = (char*)malloc(strlen(src) + 1);
- if (ret == NULL) return ret;
- strcpy(ret, src);
- return ret;
-}
-
-char *strcat(char *dest, const char *src) {
- char *dest2 = dest;
- dest2 += strlen(dest) - 1;
- while (*src) {
- *dest2 = *src;
- src++;
- dest2++;
- }
- *dest2 = 0;
- return dest;
-}
-
-int strcmp(const char *s1, const char *s2) {
- while ((*s1) && (*s1 == *s2)) {
- s1++;
- s2++;
- }
- return (* (unsigned char*)s1 - *(unsigned char*)s2);
-}
-
-void *memcpy(void *vd, const void *vs, int count) {
- uint8_t *dest = (uint8_t*)vd, *src = (uint8_t*)vs;
- int 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;
-}
-
-void *memset(void *dest, int val, int count) {
- uint8_t *dest_c = (uint8_t*)dest;
- int i;
- for (i = 0; i < count; i++) {
- dest_c[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;
-}