diff options
author | Alexis211 <alexis211@gmail.com> | 2010-02-06 20:51:56 +0100 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2010-02-06 20:51:56 +0100 |
commit | 6a52d123672b7a00af6e22b4c138205be2042a94 (patch) | |
tree | cd9b0a13490159369a66c850850596fd4b418139 /src/stem/lib | |
parent | 3558f18daf50281ee1cd68cca96cd967dbac04ba (diff) | |
download | TCE-6a52d123672b7a00af6e22b4c138205be2042a94.tar.gz TCE-6a52d123672b7a00af6e22b4c138205be2042a94.zip |
Reorganisation
Diffstat (limited to 'src/stem/lib')
-rw-r--r-- | src/stem/lib/bitset.c | 35 | ||||
-rw-r--r-- | src/stem/lib/bitset.h | 19 | ||||
-rw-r--r-- | src/stem/lib/stdlib.c | 39 | ||||
-rw-r--r-- | src/stem/lib/stdlib.h | 12 | ||||
-rw-r--r-- | src/stem/lib/types.h | 15 |
5 files changed, 0 insertions, 120 deletions
diff --git a/src/stem/lib/bitset.c b/src/stem/lib/bitset.c deleted file mode 100644 index a6d334b..0000000 --- a/src/stem/lib/bitset.c +++ /dev/null @@ -1,35 +0,0 @@ -#include "bitset.h" - -void bitset_set(struct bitset* t, uint32_t num) { - uint32_t idx = INDEX_FROM_BIT(num); - uint32_t off = OFFSET_FROM_BIT(num); - t->bits[idx] |= (0x1 << off); -} - -void bitset_clear(struct bitset* t, uint32_t num) { - uint32_t idx = INDEX_FROM_BIT(num); - uint32_t off = OFFSET_FROM_BIT(num); - t->bits[idx] &= ~(0x1 << off); -} - -uint32_t bitset_test(struct bitset* t, uint32_t num) { - uint32_t idx = INDEX_FROM_BIT(num); - uint32_t off = OFFSET_FROM_BIT(num); - return (t->bits[idx] & (0x1 << off)); -} - -uint32_t bitset_firstFree(struct bitset* t) { - uint32_t i, j; - for (i = 0; i < INDEX_FROM_BIT(t->size); i++) { - if (t->bits[i] != 0xFFFFFFFF) { - for (j = 0; j < 32; j++) { - uint32_t toTest = 0x1 << j; - if (!(t->bits[i] & toTest)) { - return i*4*8+j; - } - } - } - } - return (uint32_t) - 1; -} - diff --git a/src/stem/lib/bitset.h b/src/stem/lib/bitset.h deleted file mode 100644 index fe9e8c2..0000000 --- a/src/stem/lib/bitset.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef DEF_BITSET_H -#define DEF_BITSET_H - -#include <types.h> - -#define INDEX_FROM_BIT(a) (a/(8*4)) -#define OFFSET_FROM_BIT(a) (a%(8*4)) - -struct bitset { - uint32_t *bits; - uint32_t size; -}; - -void bitset_set(struct bitset* t, uint32_t num); -void bitset_clear(struct bitset* t, uint32_t num); -uint32_t bitset_test(struct bitset* t, uint32_t num); -uint32_t bitset_firstFree(struct bitset* t); - -#endif diff --git a/src/stem/lib/stdlib.c b/src/stem/lib/stdlib.c deleted file mode 100644 index c5245e7..0000000 --- a/src/stem/lib/stdlib.c +++ /dev/null @@ -1,39 +0,0 @@ -#include "stdlib.h" - -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; -} - -int strlen(const char *str) { - int i = 0; - while (str[i++]); - return i; -} diff --git a/src/stem/lib/stdlib.h b/src/stem/lib/stdlib.h deleted file mode 100644 index 704c410..0000000 --- a/src/stem/lib/stdlib.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef DEF_STDLIB_H -#define DEF_STDLIB_H - -#include <types.h> - -void *memcpy(void *dest, const void *src, int count); -uint8_t *memset(uint8_t *dest, uint8_t val, int count); -uint16_t *memsetw(uint16_t *dest, uint16_t val, int count); -int strlen(const char *str); - -#endif - diff --git a/src/stem/lib/types.h b/src/stem/lib/types.h deleted file mode 100644 index b7b19ab..0000000 --- a/src/stem/lib/types.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef DEF_TYPES_H -#define DEF_TYPES_H - -typedef unsigned long long uint64_t; -typedef unsigned int uint32_t; -typedef unsigned short uint16_t; -typedef unsigned char uint8_t; -typedef long long int64_t; -typedef int int32_t; -typedef short int16_t; -typedef char int8_t; - -typedef unsigned int size_t; - -#endif |