diff --git a/include/ucore/ucore_backtrace.h b/include/ucore/backtrace.h similarity index 100% rename from include/ucore/ucore_backtrace.h rename to include/ucore/backtrace.h diff --git a/include/ucore/ucore_bitvec.h b/include/ucore/bitvec.h similarity index 100% rename from include/ucore/ucore_bitvec.h rename to include/ucore/bitvec.h diff --git a/include/ucore/ucore_buffer.h b/include/ucore/buffer.h similarity index 100% rename from include/ucore/ucore_buffer.h rename to include/ucore/buffer.h diff --git a/include/ucore/ucore_clock.h b/include/ucore/clock.h similarity index 78% rename from include/ucore/ucore_clock.h rename to include/ucore/clock.h index 3d2c10f..45adf32 100644 --- a/include/ucore/ucore_clock.h +++ b/include/ucore/clock.h @@ -1,5 +1,5 @@ -#ifndef UCORE_CLOCK_H_ -#define UCORE_CLOCK_H_ +#ifndef uc_CLOCK_H_ +#define uc_CLOCK_H_ #include #include @@ -26,7 +26,7 @@ struct UCoreClock { /** A cached clock where clock.now() returns * the cached value. The cache is updated - * from the real_clock whenever ucore_cached_clock_update() + * from the real_clock whenever uc_cached_clock_update() * is called. */ struct UCoreCachedClock { @@ -40,7 +40,7 @@ struct UCoreCachedClock { /** A settable clock where clock.now() returns * the user settable value. The user updates the clock - * with ucore_settable_clock_set(). + * with uc_settable_clock_set(). */ struct UCoreSettableClock { /** The clock*/ @@ -53,25 +53,25 @@ struct UCoreSettableClock { /** A clock where now() calls gettimeofday() */ -extern struct UCoreClock ucore_timeofday_clock; +extern struct UCoreClock uc_timeofday_clock; /** * A clock where now() calls time(). * This clock will just have seconds resolution. */ -extern struct UCoreClock ucore_time_clock; +extern struct UCoreClock uc_time_clock; /** * Initialize a cached clock where now() calls time(). * This clock will this just have seconds resolution. * @param clock clock to initialize */ -void ucore_cached_clock_init(struct UCoreCachedClock *uclock, +void uc_cached_clock_init(struct UCoreCachedClock *uclock, struct UCoreClock *real_clock); /** Update the cached clock from the real_clock */ -void ucore_cached_clock_update(struct UCoreCachedClock *uclock); +void uc_cached_clock_update(struct UCoreCachedClock *uclock); /** @@ -79,12 +79,12 @@ void ucore_cached_clock_update(struct UCoreCachedClock *uclock); * This clock will this just have seconds resolution. * @param clock clock to initialize */ -void ucore_settable_clock_init(struct UCoreSettableClock *uclock); +void uc_settable_clock_init(struct UCoreSettableClock *uclock); /** * Set the new timeval this clock will return **/ -void ucore_settable_clock_set_tv(struct UCoreSettableClock *uclock, +void uc_settable_clock_set_tv(struct UCoreSettableClock *uclock, const struct timeval *tv); /** @@ -92,7 +92,7 @@ void ucore_settable_clock_set_tv(struct UCoreSettableClock *uclock, * Convenience function that takes seconds/microseconds as arguments * instead of a struct timeval. **/ -void ucore_settable_clock_set(struct UCoreSettableClock *uclock, +void uc_settable_clock_set(struct UCoreSettableClock *uclock, time_t secs, suseconds_t usecs); #endif diff --git a/include/ucore/ucore_hash.h b/include/ucore/hash.h similarity index 100% rename from include/ucore/ucore_hash.h rename to include/ucore/hash.h diff --git a/include/ucore/ucore_heapsort.h b/include/ucore/heapsort.h similarity index 100% rename from include/ucore/ucore_heapsort.h rename to include/ucore/heapsort.h diff --git a/include/ucore/iomux.h b/include/ucore/iomux.h index 55b7d23..774b6d2 100644 --- a/include/ucore/iomux.h +++ b/include/ucore/iomux.h @@ -1,7 +1,7 @@ #ifndef IO_MUX_H_ #define IO_MUX_H_ -#include "ucore_timers.h" +#include "timers.h" #define MUX_EV_READ (1U << 0x00) #define MUX_EV_WRITE (1U << 0x01) diff --git a/include/ucore/iomux_impl.h b/include/ucore/iomux_impl.h index e63de01..4770810 100644 --- a/include/ucore/iomux_impl.h +++ b/include/ucore/iomux_impl.h @@ -2,7 +2,7 @@ #define IO_MUX_IMPL_H_ #include "iomux.h" -#include "ucore_timers.h" +#include "timers.h" /** struct for IOMux implementations */ struct IOMux { diff --git a/include/ucore/ucore_logging.h b/include/ucore/logging.h similarity index 100% rename from include/ucore/ucore_logging.h rename to include/ucore/logging.h diff --git a/include/ucore/ucore_math.h b/include/ucore/math.h similarity index 100% rename from include/ucore/ucore_math.h rename to include/ucore/math.h diff --git a/include/ucore/ucore_mersenne_twister.h b/include/ucore/mersenne_twister.h similarity index 100% rename from include/ucore/ucore_mersenne_twister.h rename to include/ucore/mersenne_twister.h diff --git a/include/ucore/ucore_pack.h b/include/ucore/pack.h similarity index 100% rename from include/ucore/ucore_pack.h rename to include/ucore/pack.h diff --git a/include/ucore/ucore_rbtree.h b/include/ucore/rbtree.h similarity index 100% rename from include/ucore/ucore_rbtree.h rename to include/ucore/rbtree.h diff --git a/include/ucore/ucore_read_file.h b/include/ucore/read_file.h similarity index 100% rename from include/ucore/ucore_read_file.h rename to include/ucore/read_file.h diff --git a/include/ucore/ucore_salloc.h b/include/ucore/salloc.h similarity index 100% rename from include/ucore/ucore_salloc.h rename to include/ucore/salloc.h diff --git a/include/ucore/ucore_seq.h b/include/ucore/seq.h similarity index 100% rename from include/ucore/ucore_seq.h rename to include/ucore/seq.h diff --git a/include/ucore/ucore_string.h b/include/ucore/string.h similarity index 100% rename from include/ucore/ucore_string.h rename to include/ucore/string.h diff --git a/include/ucore/ucore_threadqueue.h b/include/ucore/threadqueue.h similarity index 100% rename from include/ucore/ucore_threadqueue.h rename to include/ucore/threadqueue.h diff --git a/include/ucore/ucore_timers.h b/include/ucore/timers.h similarity index 99% rename from include/ucore/ucore_timers.h rename to include/ucore/timers.h index aa08354..8a94131 100644 --- a/include/ucore/ucore_timers.h +++ b/include/ucore/timers.h @@ -4,7 +4,7 @@ #include #include #include -#include "ucore_rbtree.h" +#include "rbtree.h" struct UCTimer; diff --git a/include/ucore/ucore_utils.h b/include/ucore/utils.h similarity index 100% rename from include/ucore/ucore_utils.h rename to include/ucore/utils.h diff --git a/include/ucore/ucore_version.h b/include/ucore/version.h similarity index 100% rename from include/ucore/ucore_version.h rename to include/ucore/version.h diff --git a/src/SConscript b/src/SConscript index 3f704bd..0c2b678 100644 --- a/src/SConscript +++ b/src/SConscript @@ -8,7 +8,7 @@ ucore_env = env.Clone() #substitute @version_xx@ strings subst_version_info = dict(('@' + key + '@', version_info[key]) for key in version_info) subst_version_info['@build_host@'] = platform.node() -ucore_env.Substfile('ucore_version.c.in', SUBST_DICT = subst_version_info) +ucore_env.Substfile('version.c.in', SUBST_DICT = subst_version_info) sources = ucore_env.Glob('*.c') diff --git a/src/ucore_backtrace.c b/src/backtrace.c similarity index 96% rename from src/ucore_backtrace.c rename to src/backtrace.c index 5110693..58e1fb2 100644 --- a/src/ucore_backtrace.c +++ b/src/backtrace.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include "ucore/backtrace.h" #define MAX_BACKTRACE_SYMBOLS 96 diff --git a/src/ucore_base64_dec.c b/src/base64_dec.c similarity index 98% rename from src/ucore_base64_dec.c rename to src/base64_dec.c index 66c94aa..5ac2e98 100644 --- a/src/ucore_base64_dec.c +++ b/src/base64_dec.c @@ -1,5 +1,5 @@ #include -#include +#include "ucore/string.h" static const uint8_t basecode[128] = { diff --git a/src/ucore_base64_enc.c b/src/base64_enc.c similarity index 96% rename from src/ucore_base64_enc.c rename to src/base64_enc.c index 71aaa88..bc8126e 100644 --- a/src/ucore_base64_enc.c +++ b/src/base64_enc.c @@ -1,6 +1,6 @@ #include #include -#include +#include "ucore/string.h" static const char basecode[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; #define PAD '=' diff --git a/src/ucore_bcd.c b/src/bcd.c similarity index 96% rename from src/ucore_bcd.c rename to src/bcd.c index cfdf373..6d5da81 100644 --- a/src/ucore_bcd.c +++ b/src/bcd.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include "ucore/string.h" size_t uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler) diff --git a/src/ucore_bitvec.c b/src/bitvec.c similarity index 98% rename from src/ucore_bitvec.c rename to src/bitvec.c index c05c919..5933597 100644 --- a/src/ucore_bitvec.c +++ b/src/bitvec.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include "ucore/bitvec.h" #ifdef __GNUC__ #define likely(expr) __builtin_expect((expr), 1) diff --git a/src/ucore_buffer.c b/src/buffer.c similarity index 98% rename from src/ucore_buffer.c rename to src/buffer.c index 296fcda..610f0ab 100644 --- a/src/ucore_buffer.c +++ b/src/buffer.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include "ucore/buffer.h" GBuf* uc_new_gbuf(size_t initsz) diff --git a/src/clock.c b/src/clock.c new file mode 100644 index 0000000..1256847 --- /dev/null +++ b/src/clock.c @@ -0,0 +1,82 @@ +#include "ucore/clock.h" +#include "ucore/utils.h" + +#ifdef __GNUC__ +#define UNUSED __attribute__((__unused__)) +#else +#define UNUSED +#endif + +static void uc_timeofday_now(struct UCoreClock *clock UNUSED, struct timeval *tv) +{ + gettimeofday(tv, NULL); +} + +static void uc_time_now(struct UCoreClock *clock UNUSED, struct timeval *tv) +{ + tv->tv_sec = time(NULL); + tv->tv_usec = 0; +} + +struct UCoreClock uc_timeofday_clock = { + .name = "gettimeofday", + .now = uc_timeofday_now, +}; + +struct UCoreClock uc_time_clock = { + .name = "time", + .now = uc_time_now, +}; + +static void uc_cached_clock_now(struct UCoreClock *uclock UNUSED, + struct timeval *tv) +{ + struct UCoreCachedClock *cached_clock; + cached_clock = CONTAINER_OF(uclock, struct UCoreCachedClock, clock), + + *tv = cached_clock->cache; +} + +void uc_cached_clock_init(struct UCoreCachedClock *uclock, struct UCoreClock *real_clock) +{ + uclock->clock.name = "cached clock"; + uclock->clock.now = uc_cached_clock_now; + + uclock->real_clock = real_clock; + + uc_cached_clock_update(uclock); +} + +void uc_cached_clock_update(struct UCoreCachedClock *uclock) +{ + uclock->real_clock->now(&uclock->clock, &uclock->cache); +} + +static void uc_settable_clock_now(struct UCoreClock *uclock, struct timeval *tv) +{ + struct UCoreSettableClock *cached_clock; + cached_clock = CONTAINER_OF(uclock, struct UCoreSettableClock, clock), + + *tv = cached_clock->now; +} + +void uc_settable_clock_init(struct UCoreSettableClock *uclock) +{ + uclock->clock.name = "settable clock"; + uclock->clock.now = uc_settable_clock_now; + + uclock->now.tv_sec = 0; + uclock->now.tv_usec = 0; +} + +void uc_settable_clock_set_tv(struct UCoreSettableClock *uclock, const struct timeval *tv) +{ + uclock->now = *tv; +} + +void uc_settable_clock_set(struct UCoreSettableClock *uclock, time_t secs, suseconds_t usecs) +{ + uclock->now.tv_sec = secs; + uclock->now.tv_usec = usecs; +} + diff --git a/src/ucore_crc32.c b/src/crc32.c similarity index 99% rename from src/ucore_crc32.c rename to src/crc32.c index 936ef4b..f9ba84a 100644 --- a/src/ucore_crc32.c +++ b/src/crc32.c @@ -1,4 +1,4 @@ -#include +#include "ucore/hash.h" static const uint32_t crc32_table[256] = { 0x0,0x4C11DB7,0x9823B6E,0xD4326D9,0x130476DC,0x17C56B6B,0x1A864DB2,0x1E475005,0x2608EDB8,0x22C9F00F,0x2F8AD6D6, diff --git a/src/ucore_dayofweek.c b/src/dayofweek.c similarity index 100% rename from src/ucore_dayofweek.c rename to src/dayofweek.c diff --git a/src/ucore_djbhash.c b/src/djbhash.c similarity index 84% rename from src/ucore_djbhash.c rename to src/djbhash.c index c5cee16..b06db0c 100644 --- a/src/ucore_djbhash.c +++ b/src/djbhash.c @@ -1,4 +1,4 @@ -#include +#include "ucore/hash.h" uint32_t uc_djbhash(const char *str) diff --git a/src/ucore_elfhash.c b/src/elfhash.c similarity index 90% rename from src/ucore_elfhash.c rename to src/elfhash.c index bb31dac..c2a7578 100644 --- a/src/ucore_elfhash.c +++ b/src/elfhash.c @@ -1,4 +1,4 @@ -#include +#include "ucore/hash.h" uint32_t uc_elfhash(const char *str, uint32_t len) diff --git a/src/ucore_gcd32.c b/src/gcd32.c similarity index 80% rename from src/ucore_gcd32.c rename to src/gcd32.c index f1141a2..852aeaa 100644 --- a/src/ucore_gcd32.c +++ b/src/gcd32.c @@ -1,4 +1,4 @@ -#include +#include "ucore/math.h" uint32_t uc_gcd_32(uint32_t a, uint32_t b) diff --git a/src/ucore_gcd64.c b/src/gcd64.c similarity index 80% rename from src/ucore_gcd64.c rename to src/gcd64.c index 4b6f120..d20719a 100644 --- a/src/ucore_gcd64.c +++ b/src/gcd64.c @@ -1,4 +1,4 @@ -#include +#include "ucore/math.h" uint64_t uc_gcd_64(uint64_t a, uint64_t b) diff --git a/src/ucore_getfields.c b/src/getfields.c similarity index 95% rename from src/ucore_getfields.c rename to src/getfields.c index 2e1866c..504ffdb 100644 --- a/src/ucore_getfields.c +++ b/src/getfields.c @@ -1,5 +1,5 @@ #include -#include +#include "ucore/string.h" int getfields(char *str, char **args, int max, int mflag, const char *set) diff --git a/src/ucore_hash64int.c b/src/hash64int.c similarity index 92% rename from src/ucore_hash64int.c rename to src/hash64int.c index c504c24..f51161b 100644 --- a/src/ucore_hash64int.c +++ b/src/hash64int.c @@ -1,5 +1,5 @@ #include -#include +#include "ucore/hash.h" uint64_t uc_hash64shift(uint64_t key) diff --git a/src/ucore_hashint.c b/src/hashint.c similarity index 85% rename from src/ucore_hashint.c rename to src/hashint.c index 69dabce..71c5be7 100644 --- a/src/ucore_hashint.c +++ b/src/hashint.c @@ -1,4 +1,4 @@ -#include +#include "ucore/hash.h" uint32_t uc_hashuint(uint32_t a) diff --git a/src/ucore_heapsort.c b/src/heapsort.c similarity index 96% rename from src/ucore_heapsort.c rename to src/heapsort.c index 45bfa60..683703d 100644 --- a/src/ucore_heapsort.c +++ b/src/heapsort.c @@ -1,5 +1,5 @@ #include -#include +#include "ucore/heapsort.h" static void uc_sift(unsigned char *base, size_t start, size_t count, size_t width, diff --git a/src/ucore_hex.c b/src/hex.c similarity index 97% rename from src/ucore_hex.c rename to src/hex.c index 3fbaa5e..37ff338 100644 --- a/src/ucore_hex.c +++ b/src/hex.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include "ucore/string.h" static const char hx_chars[] = "0123456789ABCDEF" ; diff --git a/src/ucore_human_bytesz.c b/src/human_bytesz.c similarity index 95% rename from src/ucore_human_bytesz.c rename to src/human_bytesz.c index 031c1c6..00edcb4 100644 --- a/src/ucore_human_bytesz.c +++ b/src/human_bytesz.c @@ -1,6 +1,6 @@ #include #include -#include +#include "ucore/string.h" char * uc_human_bytesz(uint64_t bytes, char *result, size_t result_len) diff --git a/src/iomux_epoll.c b/src/iomux_epoll.c index b90b9d7..67e53c9 100644 --- a/src/iomux_epoll.c +++ b/src/iomux_epoll.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include "ucore/iomux_impl.h" //epoll (linux specific) IO mux. //We stuff the struct IOMuxFD pointer in the event.data.ptr slot diff --git a/src/iomux_impl.c b/src/iomux_impl.c index fb203f7..2e47b31 100644 --- a/src/iomux_impl.c +++ b/src/iomux_impl.c @@ -3,14 +3,14 @@ #include #include #include -#include +#include "ucore/clock.h" //dispatchers for the IOMux implementations */ struct IOMux *iomux_create(enum IOMUX_TYPE type) { - return iomux_create_ex(type, &ucore_timeofday_clock); + return iomux_create_ex(type, &uc_timeofday_clock); } struct IOMux *iomux_create_ex(enum IOMUX_TYPE type, struct UCoreClock *uclock) diff --git a/src/iomux_select.c b/src/iomux_select.c index f867cca..ebad214 100644 --- a/src/iomux_select.c +++ b/src/iomux_select.c @@ -5,8 +5,8 @@ #include #include #include -#include -#include +#include "ucore/iomux_impl.h" +#include "ucore/utils.h" #define IOMUX_GROW_CHUNK (32) diff --git a/src/ucore_logging.c b/src/logging.c similarity index 99% rename from src/ucore_logging.c rename to src/logging.c index beecadf..975ca07 100644 --- a/src/ucore_logging.c +++ b/src/logging.c @@ -6,7 +6,7 @@ #include #include #include -#include +#include "ucore/logging.h" struct uc_log_destination { diff --git a/src/ucore_mersenne_twister.c b/src/mersenne_twister.c similarity index 96% rename from src/ucore_mersenne_twister.c rename to src/mersenne_twister.c index 90a48db..4e59b8a 100644 --- a/src/ucore_mersenne_twister.c +++ b/src/mersenne_twister.c @@ -1,7 +1,7 @@ /*Copyright (c) 2004 Nils O. Selåsdal */ /*Straight forward attempt at a Mersenne Twister PRNG */ -#include +#include "ucore/mersenne_twister.h" /*Beware , pollution. But the names are from the spec */ diff --git a/src/ucore_murmurhash.c b/src/murmurhash.c similarity index 97% rename from src/ucore_murmurhash.c rename to src/murmurhash.c index 98ed200..d98d690 100644 --- a/src/ucore_murmurhash.c +++ b/src/murmurhash.c @@ -1,4 +1,4 @@ -#include +#include "ucore/hash.h" // 'm' and 'r' are mixing constants generated offline. // They're not really 'magic', they just happen to work well. diff --git a/src/ucore_phi32.c b/src/phi32.c similarity index 92% rename from src/ucore_phi32.c rename to src/phi32.c index 5fcb8dc..653a354 100644 --- a/src/ucore_phi32.c +++ b/src/phi32.c @@ -1,4 +1,4 @@ -#include +#include "ucore/math.h" /* Euler's Totient Function is denoted by the Greek letter phi, and is defined as follows: diff --git a/src/ucore_phi64.c b/src/phi64.c similarity index 92% rename from src/ucore_phi64.c rename to src/phi64.c index 905bfe2..7fd63a3 100644 --- a/src/ucore_phi64.c +++ b/src/phi64.c @@ -1,4 +1,4 @@ -#include +#include "ucore/math.h" /* Euler's Totient Function is denoted by the Greek letter phi, and is defined as follows: diff --git a/src/ucore_pjwhash.c b/src/pjwhash.c similarity index 86% rename from src/ucore_pjwhash.c rename to src/pjwhash.c index 3610f1d..901f03f 100644 --- a/src/ucore_pjwhash.c +++ b/src/pjwhash.c @@ -1,4 +1,4 @@ -#include +#include "ucore/hash.h" uint32_t uc_pjwhash(const char *str,size_t len) diff --git a/src/ucore_rbtree.c b/src/rbtree.c similarity index 99% rename from src/ucore_rbtree.c rename to src/rbtree.c index e19e575..5522e4d 100644 --- a/src/ucore_rbtree.c +++ b/src/rbtree.c @@ -1,5 +1,5 @@ #include -#include +#include "ucore/rbtree.h" //modified from generated code of tree.h static void diff --git a/src/ucore_read_file.c b/src/read_file.c similarity index 97% rename from src/ucore_read_file.c rename to src/read_file.c index 59f2dd7..4d019a5 100644 --- a/src/ucore_read_file.c +++ b/src/read_file.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include "ucore/read_file.h" #define CHUNK_SZ 1024 diff --git a/src/ucore_salloc.c b/src/salloc.c similarity index 98% rename from src/ucore_salloc.c rename to src/salloc.c index bb1e459..50858e9 100644 --- a/src/ucore_salloc.c +++ b/src/salloc.c @@ -2,7 +2,7 @@ #include #include #include -#include +#include "ucore/salloc.h" typedef struct Chunk Chunk; struct Chunk { diff --git a/src/ucore_saxhash.c b/src/saxhash.c similarity index 86% rename from src/ucore_saxhash.c rename to src/saxhash.c index cd98ff9..dbaf879 100644 --- a/src/ucore_saxhash.c +++ b/src/saxhash.c @@ -1,4 +1,4 @@ -#include +#include "ucore/hash.h" uint32_t uc_sax_hash(void *key, size_t len) diff --git a/src/ucore_sdmhash.c b/src/sdmhash.c similarity index 100% rename from src/ucore_sdmhash.c rename to src/sdmhash.c diff --git a/src/ucore_sprintb.c b/src/sprintb.c similarity index 89% rename from src/ucore_sprintb.c rename to src/sprintb.c index 80a0154..55fe576 100644 --- a/src/ucore_sprintb.c +++ b/src/sprintb.c @@ -1,6 +1,6 @@ #include #include -#include +#include "ucore/string.h" char* diff --git a/src/ucore_sprintbc.c b/src/sprintbc.c similarity index 90% rename from src/ucore_sprintbc.c rename to src/sprintbc.c index 3b43a61..c4f035a 100644 --- a/src/ucore_sprintbc.c +++ b/src/sprintbc.c @@ -1,6 +1,6 @@ #include #include -#include +#include "ucore/string.h" char* uc_sprintbc(char *result, unsigned char value) diff --git a/src/ucore_sprintbll.c b/src/sprintbll.c similarity index 90% rename from src/ucore_sprintbll.c rename to src/sprintbll.c index b073970..160bcd2 100644 --- a/src/ucore_sprintbll.c +++ b/src/sprintbll.c @@ -1,6 +1,6 @@ #include #include -#include +#include "ucore/string.h" char* uc_sprintbll(char *result, unsigned long long value) diff --git a/src/ucore_sprintbs.c b/src/sprintbs.c similarity index 90% rename from src/ucore_sprintbs.c rename to src/sprintbs.c index 5022c22..d4058dd 100644 --- a/src/ucore_sprintbs.c +++ b/src/sprintbs.c @@ -1,6 +1,6 @@ #include #include -#include +#include "ucore/string.h" char* uc_sprintbs(char *result, unsigned short value) diff --git a/src/ucore_strtolower.c b/src/strtolower.c similarity index 79% rename from src/ucore_strtolower.c rename to src/strtolower.c index d956b6c..cb6b0fe 100644 --- a/src/ucore_strtolower.c +++ b/src/strtolower.c @@ -1,5 +1,5 @@ #include -#include +#include "ucore/string.h" void uc_str_tolower(char *s) diff --git a/src/ucore_strtoupper.c b/src/strtoupper.c similarity index 79% rename from src/ucore_strtoupper.c rename to src/strtoupper.c index 1a02492..0ff5099 100644 --- a/src/ucore_strtoupper.c +++ b/src/strtoupper.c @@ -1,5 +1,5 @@ #include -#include +#include "ucore/string.h" void uc_str_toupper(char *s) diff --git a/src/ucore_threadqueue.c b/src/threadqueue.c similarity index 99% rename from src/ucore_threadqueue.c rename to src/threadqueue.c index 3fcfe42..14d087d 100644 --- a/src/ucore_threadqueue.c +++ b/src/threadqueue.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include "ucore/threadqueue.h" /** * @param timeout a timeout duration diff --git a/src/ucore_timers.c b/src/timers.c similarity index 97% rename from src/ucore_timers.c rename to src/timers.c index 9d25b4d..3dd3bb7 100644 --- a/src/ucore_timers.c +++ b/src/timers.c @@ -1,6 +1,6 @@ #include -#include -#include +#include "ucore/timers.h" +#include "ucore/clock.h" static int timers_cmp(const void *a_, const void *b_) @@ -37,7 +37,7 @@ static void uc_timer_real_add(struct UCTimers *timers, struct UCTimer *timer) void uc_timers_init(struct UCTimers *t) { - uc_timers_init_ex(t, &ucore_timeofday_clock); + uc_timers_init_ex(t, &uc_timeofday_clock); } void uc_timers_init_ex(struct UCTimers *t, struct UCoreClock *uclock) diff --git a/src/ucore_tval.c b/src/tval.c similarity index 100% rename from src/ucore_tval.c rename to src/tval.c diff --git a/src/ucore_clock.c b/src/ucore_clock.c deleted file mode 100644 index c9ce354..0000000 --- a/src/ucore_clock.c +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include - -#ifdef __GNUC__ -#define UNUSED __attribute__((__unused__)) -#else -#define UNUSED -#endif - -static void ucore_timeofday_now(struct UCoreClock *clock UNUSED, struct timeval *tv) -{ - gettimeofday(tv, NULL); -} - -static void ucore_time_now(struct UCoreClock *clock UNUSED, struct timeval *tv) -{ - tv->tv_sec = time(NULL); - tv->tv_usec = 0; -} - -struct UCoreClock ucore_timeofday_clock = { - .name = "gettimeofday", - .now = ucore_timeofday_now, -}; - -struct UCoreClock ucore_time_clock = { - .name = "time", - .now = ucore_time_now, -}; - -static void ucore_cached_clock_now(struct UCoreClock *uclock UNUSED, - struct timeval *tv) -{ - struct UCoreCachedClock *cached_clock; - cached_clock = CONTAINER_OF(uclock, struct UCoreCachedClock, clock), - - *tv = cached_clock->cache; -} - -void ucore_cached_clock_init(struct UCoreCachedClock *uclock, struct UCoreClock *real_clock) -{ - uclock->clock.name = "cached clock"; - uclock->clock.now = ucore_cached_clock_now; - - uclock->real_clock = real_clock; - - ucore_cached_clock_update(uclock); -} - -void ucore_cached_clock_update(struct UCoreCachedClock *uclock) -{ - uclock->real_clock->now(&uclock->clock, &uclock->cache); -} - -static void ucore_settable_clock_now(struct UCoreClock *uclock, struct timeval *tv) -{ - struct UCoreSettableClock *cached_clock; - cached_clock = CONTAINER_OF(uclock, struct UCoreSettableClock, clock), - - *tv = cached_clock->now; -} - -void ucore_settable_clock_init(struct UCoreSettableClock *uclock) -{ - uclock->clock.name = "settable clock"; - uclock->clock.now = ucore_settable_clock_now; - - uclock->now.tv_sec = 0; - uclock->now.tv_usec = 0; -} - -void ucore_settable_clock_set_tv(struct UCoreSettableClock *uclock, const struct timeval *tv) -{ - uclock->now = *tv; -} - -void ucore_settable_clock_set(struct UCoreSettableClock *uclock, time_t secs, suseconds_t usecs) -{ - uclock->now.tv_sec = secs; - uclock->now.tv_usec = usecs; -} - diff --git a/src/ucore_version.c.in b/src/version.c.in similarity index 100% rename from src/ucore_version.c.in rename to src/version.c.in diff --git a/test/backtrace.c b/test/backtrace.c index 975a5e6..c68eecd 100644 --- a/test/backtrace.c +++ b/test/backtrace.c @@ -1,5 +1,5 @@ #include -#include +#include //note , compiling this without -rdynamic does not //translate addresses to function names. Use the addr2line in that case diff --git a/test/logging.c b/test/logging.c index 2d8591b..45d36f2 100644 --- a/test/logging.c +++ b/test/logging.c @@ -1,5 +1,5 @@ -#include -#include +#include +#include #include enum { MAIN, diff --git a/test/phi.c b/test/phi.c index 829161f..3e9517b 100644 --- a/test/phi.c +++ b/test/phi.c @@ -1,6 +1,6 @@ #include #include -#include "ucore_math.h" +#include int main(int argc, char *argv[]) { diff --git a/test/salloc_vg.c b/test/salloc_vg.c index 4a9342b..ebd2b28 100644 --- a/test/salloc_vg.c +++ b/test/salloc_vg.c @@ -1,5 +1,5 @@ #include -#include +#include // Intended to be run under valgrind. Should show no errors diff --git a/test/seq.c b/test/seq.c index 0a78f55..7de6b0b 100644 --- a/test/seq.c +++ b/test/seq.c @@ -1,5 +1,5 @@ #include -#include +#include void check_before(uint32_t a, uint32_t b) diff --git a/test/test_bcd.c b/test/test_bcd.c index 0d24977..82b7598 100644 --- a/test/test_bcd.c +++ b/test/test_bcd.c @@ -1,5 +1,5 @@ #include -#include +#include START_TEST (test_2bcd_1234567890) diff --git a/test/test_bitvec.c b/test/test_bitvec.c index e5fe0b7..564de9a 100644 --- a/test/test_bitvec.c +++ b/test/test_bitvec.c @@ -1,5 +1,5 @@ #include -#include +#include START_TEST (test_bitvec_1) diff --git a/test/test_buffer.c b/test/test_buffer.c index 416eadd..63a58e1 100644 --- a/test/test_buffer.c +++ b/test/test_buffer.c @@ -1,6 +1,6 @@ #include #include -#include +#include START_TEST (test_new_gbuf) diff --git a/test/test_clock.c b/test/test_clock.c index b7c824b..46b58a5 100644 --- a/test/test_clock.c +++ b/test/test_clock.c @@ -1,6 +1,6 @@ #include #include -#include +#include START_TEST (test_settable_clock) @@ -8,14 +8,14 @@ START_TEST (test_settable_clock) struct timeval tv; struct timeval tv_tmp; - ucore_settable_clock_init(&my_clock); + uc_settable_clock_init(&my_clock); my_clock.clock.now(&my_clock.clock, &tv); fail_if(tv.tv_sec != 0); fail_if(tv.tv_usec != 0); - ucore_settable_clock_set(&my_clock, 10001, 1002); + uc_settable_clock_set(&my_clock, 10001, 1002); my_clock.clock.now(&my_clock.clock, &tv); @@ -27,7 +27,7 @@ START_TEST (test_settable_clock) tv_tmp.tv_sec = 123456789; tv_tmp.tv_usec = 44; - ucore_settable_clock_set_tv(&my_clock, &tv_tmp); + uc_settable_clock_set_tv(&my_clock, &tv_tmp); my_clock.clock.now(&my_clock.clock, &tv); @@ -40,7 +40,7 @@ START_TEST (test_cached_clock) struct UCoreCachedClock my_clock; struct timeval tv1,tv2; - ucore_cached_clock_init(&my_clock, &ucore_timeofday_clock); + uc_cached_clock_init(&my_clock, &uc_timeofday_clock); my_clock.clock.now(&my_clock.clock, &tv1); @@ -54,7 +54,7 @@ START_TEST (test_cached_clock) fail_if(timercmp(&tv1, &tv2, !=)); usleep(100); - ucore_cached_clock_update(&my_clock); + uc_cached_clock_update(&my_clock); my_clock.clock.now(&my_clock.clock, &tv1); fail_if(!timercmp(&tv1, &tv2, !=)); diff --git a/test/test_containerof.c b/test/test_containerof.c index 7e3e93a..f8db97b 100644 --- a/test/test_containerof.c +++ b/test/test_containerof.c @@ -1,5 +1,5 @@ #include -#include +#include struct Inner { diff --git a/test/test_hex.c b/test/test_hex.c index a3c7bc4..87ca984 100644 --- a/test/test_hex.c +++ b/test/test_hex.c @@ -1,6 +1,6 @@ #include #include -#include +#include START_TEST (test_uc_hex_encode_1) diff --git a/test/test_logging.c b/test/test_logging.c index 9511171..97ce98d 100644 --- a/test/test_logging.c +++ b/test/test_logging.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include #define FILE_NAME "logfile_test.log" #define SUBDIR "log_subdir" diff --git a/test/test_pack.c b/test/test_pack.c index 9ebef75..1115370 100644 --- a/test/test_pack.c +++ b/test/test_pack.c @@ -1,5 +1,5 @@ #include -#include +#include START_TEST (test_pack16_le_1) diff --git a/test/test_read_file.c b/test/test_read_file.c index 040073b..0bb4990 100644 --- a/test/test_read_file.c +++ b/test/test_read_file.c @@ -5,7 +5,7 @@ #include #include #include -#include +#include START_TEST (test_read_file_non_existing_file) diff --git a/test/test_threadqueue.c b/test/test_threadqueue.c index 5868fb2..933645a 100644 --- a/test/test_threadqueue.c +++ b/test/test_threadqueue.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include struct thr_msg { struct uc_threadmsg msg; diff --git a/test/threadqueue.c b/test/threadqueue.c index 9359b36..15a41bf 100644 --- a/test/threadqueue.c +++ b/test/threadqueue.c @@ -1,6 +1,6 @@ #include #include -#include +#include struct uc_threadqueue queue; diff --git a/test/threadqueue_signal.c b/test/threadqueue_signal.c index 0f0b07f..b956521 100644 --- a/test/threadqueue_signal.c +++ b/test/threadqueue_signal.c @@ -3,7 +3,7 @@ #include #include #include -#include +#include struct uc_threadqueue queue; diff --git a/test/timers.c b/test/timers.c index 1c60b65..fe37df4 100644 --- a/test/timers.c +++ b/test/timers.c @@ -1,8 +1,8 @@ #include #include #include -#include -#include +#include +#include struct MyStruct { diff --git a/test/udp_heartbeat.c b/test/udp_heartbeat.c index 7b72d87..e976fb8 100644 --- a/test/udp_heartbeat.c +++ b/test/udp_heartbeat.c @@ -12,11 +12,11 @@ #include #include #include -#include -#include +#include +#include #include -#include -#include +#include +#include #define HB_MAGIX 0xBEA7BEA7