From 6a52d123672b7a00af6e22b4c138205be2042a94 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sat, 6 Feb 2010 20:51:56 +0100 Subject: Reorganisation --- src/stem/lib/bitset.c | 35 ----------------------------------- src/stem/lib/bitset.h | 19 ------------------- src/stem/lib/stdlib.c | 39 --------------------------------------- src/stem/lib/stdlib.h | 12 ------------ src/stem/lib/types.h | 15 --------------- 5 files changed, 120 deletions(-) delete mode 100644 src/stem/lib/bitset.c delete mode 100644 src/stem/lib/bitset.h delete mode 100644 src/stem/lib/stdlib.c delete mode 100644 src/stem/lib/stdlib.h delete mode 100644 src/stem/lib/types.h (limited to 'src/stem/lib') 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 - -#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 - -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 -- cgit v1.2.3