Remove ucore_ prefix from headers and source files
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
#ifndef UCORE_CLOCK_H_
|
#ifndef uc_CLOCK_H_
|
||||||
#define UCORE_CLOCK_H_
|
#define uc_CLOCK_H_
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
@@ -26,7 +26,7 @@ struct UCoreClock {
|
|||||||
|
|
||||||
/** A cached clock where clock.now() returns
|
/** A cached clock where clock.now() returns
|
||||||
* the cached value. The cache is updated
|
* 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.
|
* is called.
|
||||||
*/
|
*/
|
||||||
struct UCoreCachedClock {
|
struct UCoreCachedClock {
|
||||||
@@ -40,7 +40,7 @@ struct UCoreCachedClock {
|
|||||||
|
|
||||||
/** A settable clock where clock.now() returns
|
/** A settable clock where clock.now() returns
|
||||||
* the user settable value. The user updates the clock
|
* the user settable value. The user updates the clock
|
||||||
* with ucore_settable_clock_set().
|
* with uc_settable_clock_set().
|
||||||
*/
|
*/
|
||||||
struct UCoreSettableClock {
|
struct UCoreSettableClock {
|
||||||
/** The clock*/
|
/** The clock*/
|
||||||
@@ -53,25 +53,25 @@ struct UCoreSettableClock {
|
|||||||
|
|
||||||
/** A clock where now() calls gettimeofday()
|
/** A clock where now() calls gettimeofday()
|
||||||
*/
|
*/
|
||||||
extern struct UCoreClock ucore_timeofday_clock;
|
extern struct UCoreClock uc_timeofday_clock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A clock where now() calls time().
|
* A clock where now() calls time().
|
||||||
* This clock will just have seconds resolution.
|
* 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().
|
* Initialize a cached clock where now() calls time().
|
||||||
* This clock will this just have seconds resolution.
|
* This clock will this just have seconds resolution.
|
||||||
* @param clock clock to initialize
|
* @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);
|
struct UCoreClock *real_clock);
|
||||||
|
|
||||||
/** Update the cached clock from the 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.
|
* This clock will this just have seconds resolution.
|
||||||
* @param clock clock to initialize
|
* @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
|
* 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);
|
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
|
* Convenience function that takes seconds/microseconds as arguments
|
||||||
* instead of a struct timeval.
|
* 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);
|
time_t secs, suseconds_t usecs);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#ifndef IO_MUX_H_
|
#ifndef IO_MUX_H_
|
||||||
#define IO_MUX_H_
|
#define IO_MUX_H_
|
||||||
|
|
||||||
#include "ucore_timers.h"
|
#include "timers.h"
|
||||||
|
|
||||||
#define MUX_EV_READ (1U << 0x00)
|
#define MUX_EV_READ (1U << 0x00)
|
||||||
#define MUX_EV_WRITE (1U << 0x01)
|
#define MUX_EV_WRITE (1U << 0x01)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
#define IO_MUX_IMPL_H_
|
#define IO_MUX_IMPL_H_
|
||||||
|
|
||||||
#include "iomux.h"
|
#include "iomux.h"
|
||||||
#include "ucore_timers.h"
|
#include "timers.h"
|
||||||
/** struct for IOMux implementations */
|
/** struct for IOMux implementations */
|
||||||
struct IOMux {
|
struct IOMux {
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "ucore_rbtree.h"
|
#include "rbtree.h"
|
||||||
|
|
||||||
|
|
||||||
struct UCTimer;
|
struct UCTimer;
|
||||||
+1
-1
@@ -8,7 +8,7 @@ ucore_env = env.Clone()
|
|||||||
#substitute @version_xx@ strings
|
#substitute @version_xx@ strings
|
||||||
subst_version_info = dict(('@' + key + '@', version_info[key]) for key in version_info)
|
subst_version_info = dict(('@' + key + '@', version_info[key]) for key in version_info)
|
||||||
subst_version_info['@build_host@'] = platform.node()
|
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')
|
sources = ucore_env.Glob('*.c')
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <execinfo.h>
|
#include <execinfo.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ucore/ucore_backtrace.h>
|
#include "ucore/backtrace.h"
|
||||||
|
|
||||||
#define MAX_BACKTRACE_SYMBOLS 96
|
#define MAX_BACKTRACE_SYMBOLS 96
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
static const uint8_t basecode[128] =
|
static const uint8_t basecode[128] =
|
||||||
{
|
{
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
static const char basecode[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
static const char basecode[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
#define PAD '='
|
#define PAD '='
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler)
|
uc_ascii2bcd(const char *ascii, unsigned char *bcdout, unsigned char filler)
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <ucore/ucore_bitvec.h>
|
#include "ucore/bitvec.h"
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#define likely(expr) __builtin_expect((expr), 1)
|
#define likely(expr) __builtin_expect((expr), 1)
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ucore/ucore_buffer.h>
|
#include "ucore/buffer.h"
|
||||||
|
|
||||||
GBuf*
|
GBuf*
|
||||||
uc_new_gbuf(size_t initsz)
|
uc_new_gbuf(size_t initsz)
|
||||||
+82
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_hash.h>
|
#include "ucore/hash.h"
|
||||||
|
|
||||||
static const uint32_t crc32_table[256] = {
|
static const uint32_t crc32_table[256] = {
|
||||||
0x0,0x4C11DB7,0x9823B6E,0xD4326D9,0x130476DC,0x17C56B6B,0x1A864DB2,0x1E475005,0x2608EDB8,0x22C9F00F,0x2F8AD6D6,
|
0x0,0x4C11DB7,0x9823B6E,0xD4326D9,0x130476DC,0x17C56B6B,0x1A864DB2,0x1E475005,0x2608EDB8,0x22C9F00F,0x2F8AD6D6,
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_hash.h>
|
#include "ucore/hash.h"
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
uc_djbhash(const char *str)
|
uc_djbhash(const char *str)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_hash.h>
|
#include "ucore/hash.h"
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
uc_elfhash(const char *str, uint32_t len)
|
uc_elfhash(const char *str, uint32_t len)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_math.h>
|
#include "ucore/math.h"
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
uc_gcd_32(uint32_t a, uint32_t b)
|
uc_gcd_32(uint32_t a, uint32_t b)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_math.h>
|
#include "ucore/math.h"
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
uc_gcd_64(uint64_t a, uint64_t b)
|
uc_gcd_64(uint64_t a, uint64_t b)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
getfields(char *str, char **args, int max, int mflag, const char *set)
|
getfields(char *str, char **args, int max, int mflag, const char *set)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <ucore/ucore_hash.h>
|
#include "ucore/hash.h"
|
||||||
|
|
||||||
uint64_t
|
uint64_t
|
||||||
uc_hash64shift(uint64_t key)
|
uc_hash64shift(uint64_t key)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_hash.h>
|
#include "ucore/hash.h"
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
uc_hashuint(uint32_t a)
|
uc_hashuint(uint32_t a)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ucore/ucore_heapsort.h>
|
#include "ucore/heapsort.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
uc_sift(unsigned char *base, size_t start, size_t count, size_t width,
|
uc_sift(unsigned char *base, size_t start, size_t count, size_t width,
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
static const char hx_chars[] = "0123456789ABCDEF" ;
|
static const char hx_chars[] = "0123456789ABCDEF" ;
|
||||||
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
char *
|
char *
|
||||||
uc_human_bytesz(uint64_t bytes, char *result, size_t result_len)
|
uc_human_bytesz(uint64_t bytes, char *result, size_t result_len)
|
||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ucore/iomux_impl.h>
|
#include "ucore/iomux_impl.h"
|
||||||
|
|
||||||
//epoll (linux specific) IO mux.
|
//epoll (linux specific) IO mux.
|
||||||
//We stuff the struct IOMuxFD pointer in the event.data.ptr slot
|
//We stuff the struct IOMuxFD pointer in the event.data.ptr slot
|
||||||
|
|||||||
+2
-2
@@ -3,14 +3,14 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ucore/iomux_impl.h>
|
#include <ucore/iomux_impl.h>
|
||||||
#include <ucore/ucore_clock.h>
|
#include "ucore/clock.h"
|
||||||
|
|
||||||
|
|
||||||
//dispatchers for the IOMux implementations */
|
//dispatchers for the IOMux implementations */
|
||||||
|
|
||||||
struct IOMux *iomux_create(enum IOMUX_TYPE type)
|
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)
|
struct IOMux *iomux_create_ex(enum IOMUX_TYPE type, struct UCoreClock *uclock)
|
||||||
|
|||||||
+2
-2
@@ -5,8 +5,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ucore/iomux_impl.h>
|
#include "ucore/iomux_impl.h"
|
||||||
#include <ucore/ucore_utils.h>
|
#include "ucore/utils.h"
|
||||||
|
|
||||||
#define IOMUX_GROW_CHUNK (32)
|
#define IOMUX_GROW_CHUNK (32)
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#include <ucore/ucore_logging.h>
|
#include "ucore/logging.h"
|
||||||
|
|
||||||
|
|
||||||
struct uc_log_destination {
|
struct uc_log_destination {
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
/*Copyright (c) 2004 Nils O. Selåsdal <NOS {on} Utel {dot} no> */
|
/*Copyright (c) 2004 Nils O. Selåsdal <NOS {on} Utel {dot} no> */
|
||||||
/*Straight forward attempt at a Mersenne Twister PRNG */
|
/*Straight forward attempt at a Mersenne Twister PRNG */
|
||||||
|
|
||||||
#include <ucore/ucore_mersenne_twister.h>
|
#include "ucore/mersenne_twister.h"
|
||||||
|
|
||||||
|
|
||||||
/*Beware , pollution. But the names are from the spec */
|
/*Beware , pollution. But the names are from the spec */
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_hash.h>
|
#include "ucore/hash.h"
|
||||||
|
|
||||||
// 'm' and 'r' are mixing constants generated offline.
|
// 'm' and 'r' are mixing constants generated offline.
|
||||||
// They're not really 'magic', they just happen to work well.
|
// They're not really 'magic', they just happen to work well.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_math.h>
|
#include "ucore/math.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Euler's Totient Function is denoted by the Greek letter phi, and is defined as follows:
|
Euler's Totient Function is denoted by the Greek letter phi, and is defined as follows:
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_math.h>
|
#include "ucore/math.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Euler's Totient Function is denoted by the Greek letter phi, and is defined as follows:
|
Euler's Totient Function is denoted by the Greek letter phi, and is defined as follows:
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_hash.h>
|
#include "ucore/hash.h"
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
uc_pjwhash(const char *str,size_t len)
|
uc_pjwhash(const char *str,size_t len)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <ucore/ucore_rbtree.h>
|
#include "ucore/rbtree.h"
|
||||||
//modified from generated code of tree.h
|
//modified from generated code of tree.h
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <ucore/ucore_read_file.h>
|
#include "ucore/read_file.h"
|
||||||
|
|
||||||
#define CHUNK_SZ 1024
|
#define CHUNK_SZ 1024
|
||||||
|
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <ucore/ucore_salloc.h>
|
#include "ucore/salloc.h"
|
||||||
|
|
||||||
typedef struct Chunk Chunk;
|
typedef struct Chunk Chunk;
|
||||||
struct Chunk {
|
struct Chunk {
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <ucore/ucore_hash.h>
|
#include "ucore/hash.h"
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
uc_sax_hash(void *key, size_t len)
|
uc_sax_hash(void *key, size_t len)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
char*
|
char*
|
||||||
uc_sprintbc(char *result, unsigned char value)
|
uc_sprintbc(char *result, unsigned char value)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
char*
|
char*
|
||||||
uc_sprintbll(char *result, unsigned long long value)
|
uc_sprintbll(char *result, unsigned long long value)
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
char*
|
char*
|
||||||
uc_sprintbs(char *result, unsigned short value)
|
uc_sprintbs(char *result, unsigned short value)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
uc_str_tolower(char *s)
|
uc_str_tolower(char *s)
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include "ucore/string.h"
|
||||||
|
|
||||||
void
|
void
|
||||||
uc_str_toupper(char *s)
|
uc_str_toupper(char *s)
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <ucore/ucore_threadqueue.h>
|
#include "ucore/threadqueue.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param timeout a timeout duration
|
* @param timeout a timeout duration
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <ucore/ucore_timers.h>
|
#include "ucore/timers.h"
|
||||||
#include <ucore/ucore_clock.h>
|
#include "ucore/clock.h"
|
||||||
|
|
||||||
|
|
||||||
static int timers_cmp(const void *a_, const void *b_)
|
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)
|
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)
|
void uc_timers_init_ex(struct UCTimers *t, struct UCoreClock *uclock)
|
||||||
@@ -1,82 +0,0 @@
|
|||||||
#include <ucore/ucore_clock.h>
|
|
||||||
#include <ucore/ucore_utils.h>
|
|
||||||
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ucore/ucore_backtrace.h>
|
#include <ucore/backtrace.h>
|
||||||
|
|
||||||
//note , compiling this without -rdynamic does not
|
//note , compiling this without -rdynamic does not
|
||||||
//translate addresses to function names. Use the addr2line in that case
|
//translate addresses to function names. Use the addr2line in that case
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
#include <ucore/ucore_logging.h>
|
#include <ucore/logging.h>
|
||||||
#include <ucore/ucore_utils.h>
|
#include <ucore/utils.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
enum {
|
enum {
|
||||||
MAIN,
|
MAIN,
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "ucore_math.h"
|
#include <ucore/math.h>
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ucore/ucore_salloc.h>
|
#include <ucore/salloc.h>
|
||||||
|
|
||||||
// Intended to be run under valgrind. Should show no errors
|
// Intended to be run under valgrind. Should show no errors
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <ucore/ucore_seq.h>
|
#include <ucore/seq.h>
|
||||||
|
|
||||||
|
|
||||||
void check_before(uint32_t a, uint32_t b)
|
void check_before(uint32_t a, uint32_t b)
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include <ucore/string.h>
|
||||||
|
|
||||||
|
|
||||||
START_TEST (test_2bcd_1234567890)
|
START_TEST (test_2bcd_1234567890)
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <ucore/ucore_bitvec.h>
|
#include <ucore/bitvec.h>
|
||||||
|
|
||||||
|
|
||||||
START_TEST (test_bitvec_1)
|
START_TEST (test_bitvec_1)
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ucore/ucore_buffer.h>
|
#include <ucore/buffer.h>
|
||||||
|
|
||||||
|
|
||||||
START_TEST (test_new_gbuf)
|
START_TEST (test_new_gbuf)
|
||||||
|
|||||||
+6
-6
@@ -1,6 +1,6 @@
|
|||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ucore/ucore_clock.h>
|
#include <ucore/clock.h>
|
||||||
|
|
||||||
|
|
||||||
START_TEST (test_settable_clock)
|
START_TEST (test_settable_clock)
|
||||||
@@ -8,14 +8,14 @@ START_TEST (test_settable_clock)
|
|||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct timeval tv_tmp;
|
struct timeval tv_tmp;
|
||||||
|
|
||||||
ucore_settable_clock_init(&my_clock);
|
uc_settable_clock_init(&my_clock);
|
||||||
|
|
||||||
my_clock.clock.now(&my_clock.clock, &tv);
|
my_clock.clock.now(&my_clock.clock, &tv);
|
||||||
|
|
||||||
fail_if(tv.tv_sec != 0);
|
fail_if(tv.tv_sec != 0);
|
||||||
fail_if(tv.tv_usec != 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);
|
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_sec = 123456789;
|
||||||
tv_tmp.tv_usec = 44;
|
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);
|
my_clock.clock.now(&my_clock.clock, &tv);
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ START_TEST (test_cached_clock)
|
|||||||
struct UCoreCachedClock my_clock;
|
struct UCoreCachedClock my_clock;
|
||||||
struct timeval tv1,tv2;
|
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);
|
my_clock.clock.now(&my_clock.clock, &tv1);
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ START_TEST (test_cached_clock)
|
|||||||
fail_if(timercmp(&tv1, &tv2, !=));
|
fail_if(timercmp(&tv1, &tv2, !=));
|
||||||
|
|
||||||
usleep(100);
|
usleep(100);
|
||||||
ucore_cached_clock_update(&my_clock);
|
uc_cached_clock_update(&my_clock);
|
||||||
my_clock.clock.now(&my_clock.clock, &tv1);
|
my_clock.clock.now(&my_clock.clock, &tv1);
|
||||||
|
|
||||||
fail_if(!timercmp(&tv1, &tv2, !=));
|
fail_if(!timercmp(&tv1, &tv2, !=));
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <ucore/ucore_utils.h>
|
#include <ucore/utils.h>
|
||||||
|
|
||||||
|
|
||||||
struct Inner {
|
struct Inner {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ucore/ucore_string.h>
|
#include <ucore/string.h>
|
||||||
|
|
||||||
|
|
||||||
START_TEST (test_uc_hex_encode_1)
|
START_TEST (test_uc_hex_encode_1)
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ucore/ucore_logging.h>
|
#include <ucore/logging.h>
|
||||||
|
|
||||||
#define FILE_NAME "logfile_test.log"
|
#define FILE_NAME "logfile_test.log"
|
||||||
#define SUBDIR "log_subdir"
|
#define SUBDIR "log_subdir"
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
#include <check.h>
|
#include <check.h>
|
||||||
#include <ucore/ucore_pack.h>
|
#include <ucore/pack.h>
|
||||||
|
|
||||||
|
|
||||||
START_TEST (test_pack16_le_1)
|
START_TEST (test_pack16_le_1)
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <ucore/ucore_read_file.h>
|
#include <ucore/read_file.h>
|
||||||
|
|
||||||
|
|
||||||
START_TEST (test_read_file_non_existing_file)
|
START_TEST (test_read_file_non_existing_file)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ucore/ucore_threadqueue.h>
|
#include <ucore/threadqueue.h>
|
||||||
|
|
||||||
struct thr_msg {
|
struct thr_msg {
|
||||||
struct uc_threadmsg msg;
|
struct uc_threadmsg msg;
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ucore/ucore_threadqueue.h>
|
#include <ucore/threadqueue.h>
|
||||||
|
|
||||||
struct uc_threadqueue queue;
|
struct uc_threadqueue queue;
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ucore/ucore_threadqueue.h>
|
#include <ucore/threadqueue.h>
|
||||||
|
|
||||||
struct uc_threadqueue queue;
|
struct uc_threadqueue queue;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <ucore/ucore_timers.h>
|
#include <ucore/timers.h>
|
||||||
#include <ucore/ucore_utils.h>
|
#include <ucore/utils.h>
|
||||||
|
|
||||||
|
|
||||||
struct MyStruct {
|
struct MyStruct {
|
||||||
|
|||||||
@@ -12,11 +12,11 @@
|
|||||||
#include <sys/queue.h>
|
#include <sys/queue.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <ucore/ucore_logging.h>
|
#include <ucore/logging.h>
|
||||||
#include <ucore/ucore_logging.h>
|
#include <ucore/logging.h>
|
||||||
#include <ucore/iomux.h>
|
#include <ucore/iomux.h>
|
||||||
#include <ucore/ucore_utils.h>
|
#include <ucore/utils.h>
|
||||||
#include <ucore/ucore_pack.h>
|
#include <ucore/pack.h>
|
||||||
|
|
||||||
#define HB_MAGIX 0xBEA7BEA7
|
#define HB_MAGIX 0xBEA7BEA7
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user