[time] rename {big}time_t -> lk_{big}time_t

-This avoids a collision with posix time_t and makes gcc complain
less about printf format mismatches.
This commit is contained in:
Travis Geiselbrecht
2012-09-30 20:27:59 -07:00
parent 62e5410007
commit 1262105ab9
26 changed files with 90 additions and 86 deletions

View File

@@ -44,10 +44,10 @@ static void *null_memcpy(void *dst, const void *src, size_t len)
return dst;
}
static time_t bench_memcpy_routine(void *memcpy_routine(void *, const void *, size_t), size_t srcalign, size_t dstalign)
static lk_time_t bench_memcpy_routine(void *memcpy_routine(void *, const void *, size_t), size_t srcalign, size_t dstalign)
{
int i;
time_t t0;
lk_time_t t0;
t0 = current_time();
for (i=0; i < ITERATIONS; i++) {
@@ -58,7 +58,7 @@ static time_t bench_memcpy_routine(void *memcpy_routine(void *, const void *, si
static void bench_memcpy(void)
{
time_t null, libc, mine;
lk_time_t null, libc, mine;
size_t srcalign, dstalign;
printf("memcpy speed test\n");
@@ -133,10 +133,10 @@ static void validate_memcpy(void)
}
}
static time_t bench_memset_routine(void *memset_routine(void *, int, size_t), size_t dstalign)
static lk_time_t bench_memset_routine(void *memset_routine(void *, int, size_t), size_t dstalign)
{
int i;
time_t t0;
lk_time_t t0;
t0 = current_time();
for (i=0; i < ITERATIONS; i++) {
@@ -147,7 +147,7 @@ static time_t bench_memset_routine(void *memset_routine(void *, int, size_t), si
static void bench_memset(void)
{
time_t libc, mine;
lk_time_t libc, mine;
size_t dstalign;
printf("memset speed test\n");

View File

@@ -113,7 +113,7 @@ static __ALWAYS_INLINE inline void cm3_trigger_preempt(void)
/* systick */
void cm3_systick_init(void);
void cm3_systick_set_periodic(uint32_t systick_clk_freq, time_t period);
void cm3_systick_set_periodic(uint32_t systick_clk_freq, lk_time_t period);
void cm3_systick_cancel_periodic(void);
/* extern void _systick(void); // override this */

View File

@@ -35,7 +35,7 @@ void cm3_systick_init(void)
NVIC_SetPriority(SysTick_IRQn, cm3_medium_priority());
}
void cm3_systick_set_periodic(uint32_t systick_clk_freq, time_t period)
void cm3_systick_set_periodic(uint32_t systick_clk_freq, lk_time_t period)
{
LTRACEF("clk_freq %u, period %u\n", systick_clk_freq, (uint)period);

View File

@@ -55,7 +55,7 @@ typedef struct event {
void event_init(event_t *, bool initial, uint flags);
void event_destroy(event_t *);
status_t event_wait(event_t *);
status_t event_wait_timeout(event_t *, time_t); /* wait on the event with a timeout */
status_t event_wait_timeout(event_t *, lk_time_t); /* wait on the event with a timeout */
status_t event_signal(event_t *, bool reschedule);
status_t event_unsignal(event_t *);
#define event_initialized(e) ((e)->magic == EVENT_MAGIC)

View File

@@ -50,7 +50,7 @@ typedef struct mutex {
void mutex_init(mutex_t *);
void mutex_destroy(mutex_t *);
status_t mutex_acquire(mutex_t *);
status_t mutex_acquire_timeout(mutex_t *, time_t); /* try to acquire the mutex with a timeout value */
status_t mutex_acquire_timeout(mutex_t *, lk_time_t); /* try to acquire the mutex with a timeout value */
status_t mutex_release(mutex_t *);
#endif

View File

@@ -109,7 +109,7 @@ void thread_set_priority(int priority);
thread_t *thread_create(const char *name, thread_start_routine entry, void *arg, int priority, size_t stack_size);
status_t thread_resume(thread_t *);
void thread_exit(int retcode) __NO_RETURN;
void thread_sleep(time_t delay);
void thread_sleep(lk_time_t delay);
void dump_thread(thread_t *t);
void dump_all_threads(void);
@@ -193,7 +193,7 @@ void wait_queue_destroy(wait_queue_t *, bool reschedule);
* a timeout other than INFINITE_TIME will set abort after the specified time
* and return ERR_TIMED_OUT. a timeout of 0 will immediately return.
*/
status_t wait_queue_block(wait_queue_t *, time_t timeout);
status_t wait_queue_block(wait_queue_t *, lk_time_t timeout);
/*
* release one or more threads from the wait queue.
@@ -217,8 +217,8 @@ status_t thread_unblock_from_wait_queue(thread_t *t, bool reschedule, status_t w
#endif
#if THREAD_STATS
struct thread_stats {
bigtime_t idle_time;
bigtime_t last_idle_timestamp;
lk_bigtime_t idle_time;
lk_bigtime_t last_idle_timestamp;
int reschedules;
int context_switches;
int preempts;

View File

@@ -29,7 +29,7 @@
void timer_init(void);
struct timer;
typedef enum handler_return (*timer_callback)(struct timer *, time_t now, void *arg);
typedef enum handler_return (*timer_callback)(struct timer *, lk_time_t now, void *arg);
#define TIMER_MAGIC 'timr'
@@ -37,8 +37,8 @@ typedef struct timer {
int magic;
struct list_node node;
time_t scheduled_time;
time_t periodic_time;
lk_time_t scheduled_time;
lk_time_t periodic_time;
timer_callback callback;
void *arg;
@@ -51,8 +51,8 @@ typedef struct timer {
* - Timers currently are dispatched from a 10ms periodic tick
*/
void timer_initialize(timer_t *);
void timer_set_oneshot(timer_t *, time_t delay, timer_callback, void *arg);
void timer_set_periodic(timer_t *, time_t period, timer_callback, void *arg);
void timer_set_oneshot(timer_t *, lk_time_t delay, timer_callback, void *arg);
void timer_set_periodic(timer_t *, lk_time_t period, timer_callback, void *arg);
void timer_cancel(timer_t *);
#endif

View File

@@ -23,8 +23,10 @@
#ifndef __PLATFORM_H
#define __PLATFORM_H
time_t current_time(void);
bigtime_t current_time_hires(void);
#include <sys/types.h>
lk_time_t current_time(void);
lk_bigtime_t current_time_hires(void);
/* super early platform initialization, before almost everything */
void platform_early_init(void);

View File

@@ -23,9 +23,11 @@
#ifndef __PLATFORM_TIMER_H
#define __PLATFORM_TIMER_H
typedef enum handler_return (*platform_timer_callback)(void *arg, time_t now);
#include <sys/types.h>
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, time_t interval);
typedef enum handler_return (*platform_timer_callback)(void *arg, lk_time_t now);
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, lk_time_t interval);
#endif

View File

@@ -45,8 +45,8 @@ typedef uintptr_t paddr_t;
typedef int kobj_id;
typedef unsigned long time_t;
typedef unsigned long long bigtime_t;
typedef unsigned long lk_time_t;
typedef unsigned long long lk_bigtime_t;
#define INFINITE_TIME ULONG_MAX
#define TIME_GTE(a, b) ((long)((a) - (b)) >= 0)

View File

@@ -80,16 +80,16 @@ static int cmd_threadstats(int argc, const cmd_args *argv)
return 0;
}
static enum handler_return threadload(struct timer *t, time_t now, void *arg)
static enum handler_return threadload(struct timer *t, lk_time_t now, void *arg)
{
static struct thread_stats old_stats;
static bigtime_t last_idle_time;
static lk_bigtime_t last_idle_time;
bigtime_t idle_time = thread_stats.idle_time;
lk_bigtime_t idle_time = thread_stats.idle_time;
if (current_thread == idle_thread) {
idle_time += current_time_hires() - thread_stats.last_idle_timestamp;
}
bigtime_t busy_time = 1000000ULL - (idle_time - last_idle_time);
lk_bigtime_t busy_time = 1000000ULL - (idle_time - last_idle_time);
uint busypercent = (busy_time * 10000) / (1000000);

View File

@@ -108,7 +108,7 @@ void event_destroy(event_t *e)
* @return 0 on success, ERR_TIMED_OUT on timeout,
* other values on other errors.
*/
status_t event_wait_timeout(event_t *e, time_t timeout)
status_t event_wait_timeout(event_t *e, lk_time_t timeout)
{
status_t ret = NO_ERROR;

View File

@@ -127,7 +127,7 @@ err:
* @return NO_ERROR on success, ERR_TIMED_OUT on timeout,
* other values on error
*/
status_t mutex_acquire_timeout(mutex_t *m, time_t timeout)
status_t mutex_acquire_timeout(mutex_t *m, lk_time_t timeout)
{
status_t ret = NO_ERROR;

View File

@@ -345,7 +345,7 @@ void thread_resched(void)
THREAD_STATS_INC(context_switches);
if (oldthread == idle_thread) {
bigtime_t now = current_time_hires();
lk_bigtime_t now = current_time_hires();
thread_stats.idle_time += now - thread_stats.last_idle_timestamp;
}
if (newthread == idle_thread) {
@@ -486,7 +486,7 @@ enum handler_return thread_timer_tick(void)
}
/* timer callback to wake up a sleeping thread */
static enum handler_return thread_sleep_handler(timer_t *timer, time_t now, void *arg)
static enum handler_return thread_sleep_handler(timer_t *timer, lk_time_t now, void *arg)
{
thread_t *t = (thread_t *)arg;
@@ -511,7 +511,7 @@ static enum handler_return thread_sleep_handler(timer_t *timer, time_t now, void
* other threads are running. When the timer expires, this thread will
* be placed at the head of the run queue.
*/
void thread_sleep(time_t delay)
void thread_sleep(lk_time_t delay)
{
timer_t timer;
@@ -662,7 +662,7 @@ void wait_queue_init(wait_queue_t *wait)
wait->count = 0;
}
static enum handler_return wait_queue_timeout_handler(timer_t *timer, time_t now, void *arg)
static enum handler_return wait_queue_timeout_handler(timer_t *timer, lk_time_t now, void *arg)
{
thread_t *thread = (thread_t *)arg;
@@ -694,7 +694,7 @@ static enum handler_return wait_queue_timeout_handler(timer_t *timer, time_t now
* @return ERR_TIMED_OUT on timeout, else returns the return
* value specified when the queue was woken by wait_queue_wake_one().
*/
status_t wait_queue_block(wait_queue_t *wait, time_t timeout)
status_t wait_queue_block(wait_queue_t *wait, lk_time_t timeout)
{
timer_t timer;

View File

@@ -46,7 +46,7 @@
static struct list_node timer_queue;
static enum handler_return timer_tick(void *arg, time_t now);
static enum handler_return timer_tick(void *arg, lk_time_t now);
/**
* @brief Initialize a timer object
@@ -78,9 +78,9 @@ static void insert_timer_in_queue(timer_t *timer)
list_add_tail(&timer_queue, &timer->node);
}
static void timer_set(timer_t *timer, time_t delay, time_t period, timer_callback callback, void *arg)
static void timer_set(timer_t *timer, lk_time_t delay, lk_time_t period, timer_callback callback, void *arg)
{
time_t now;
lk_time_t now;
LTRACEF("timer %p, delay %d, period %d, callback %p, arg %p, now %d\n", timer, delay, period, callback, arg);
@@ -125,9 +125,9 @@ static void timer_set(timer_t *timer, time_t delay, time_t period, timer_callbac
* @param arg The argument to pass to the callback
*
* The timer function is declared as:
* enum handler_return callback(struct timer *, time_t now, void *arg) { ... }
* enum handler_return callback(struct timer *, lk_time_t now, void *arg) { ... }
*/
void timer_set_oneshot(timer_t *timer, time_t delay, timer_callback callback, void *arg)
void timer_set_oneshot(timer_t *timer, lk_time_t delay, timer_callback callback, void *arg)
{
if (delay == 0)
delay = 1;
@@ -146,9 +146,9 @@ void timer_set_oneshot(timer_t *timer, time_t delay, timer_callback callback, vo
* @param arg The argument to pass to the callback
*
* The timer function is declared as:
* enum handler_return callback(struct timer *, time_t now, void *arg) { ... }
* enum handler_return callback(struct timer *, lk_time_t now, void *arg) { ... }
*/
void timer_set_periodic(timer_t *timer, time_t period, timer_callback callback, void *arg)
void timer_set_periodic(timer_t *timer, lk_time_t period, timer_callback callback, void *arg)
{
if (period == 0)
period = 1;
@@ -185,8 +185,8 @@ void timer_cancel(timer_t *timer)
LTRACEF("clearing old hw timer, nothing in the queue\n");
platform_stop_timer();
} else if (newhead != oldhead) {
time_t delay;
time_t now = current_time();
lk_time_t delay;
lk_time_t now = current_time();
if (TIME_LT(newhead->scheduled_time, now))
delay = 0;
@@ -202,7 +202,7 @@ void timer_cancel(timer_t *timer)
}
/* called at interrupt time to process any pending timers */
static enum handler_return timer_tick(void *arg, time_t now)
static enum handler_return timer_tick(void *arg, lk_time_t now)
{
timer_t *timer;
enum handler_return ret = INT_NO_RESCHEDULE;
@@ -252,7 +252,7 @@ static enum handler_return timer_tick(void *arg, time_t now)
/* has to be the case or it would have fired already */
ASSERT(TIME_GT(timer->scheduled_time, now));
time_t delay = timer->scheduled_time - now;
lk_time_t delay = timer->scheduled_time - now;
LTRACEF("setting new timer for %u msecs for event %p\n", (uint)delay, timer);
platform_set_oneshot_timer(timer_tick, NULL, delay);

View File

@@ -74,7 +74,7 @@ usage:
return -1;
}
time_t t = current_time();
lk_time_t t = current_time();
ssize_t err = bio_read(dev, (void *)address, offset, len);
t = current_time() - t;
dprintf(INFO, "bio_read returns %d, took %u msecs (%d bytes/sec)\n", (int)err, (uint)t, (uint32_t)((uint64_t)err * 1000 / t));
@@ -98,7 +98,7 @@ usage:
return -1;
}
time_t t = current_time();
lk_time_t t = current_time();
ssize_t err = bio_write(dev, (void *)address, offset, len);
t = current_time() - t;
dprintf(INFO, "bio_write returns %d, took %u msecs (%d bytes/sec)\n", (int)err, (uint)t, (uint32_t)((uint64_t)err * 1000 / t));
@@ -121,7 +121,7 @@ usage:
return -1;
}
time_t t = current_time();
lk_time_t t = current_time();
ssize_t err = bio_erase(dev, offset, len);
t = current_time() - t;
dprintf(INFO, "bio_erase returns %d, took %u msecs (%d bytes/sec)\n", (int)err, (uint)t, (uint32_t)((uint64_t)err * 1000 / t));

View File

@@ -34,7 +34,7 @@
void spin(uint32_t usecs)
{
bigtime_t start = current_time_hires();
lk_bigtime_t start = current_time_hires();
while ((current_time_hires() - start) < usecs)
;

View File

@@ -31,7 +31,7 @@
static platform_timer_callback t_callback;
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, time_t interval)
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, lk_time_t interval)
{
enter_critical_section();
@@ -48,9 +48,9 @@ status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg
return NO_ERROR;
}
bigtime_t current_time_hires(void)
lk_bigtime_t current_time_hires(void)
{
bigtime_t time;
lk_bigtime_t time;
*REG(SYSINFO_TIME_LATCH) = 1;
time = *REG(SYSINFO_TIME_SECS) * 1000000ULL;
time += *REG(SYSINFO_TIME_USECS);
@@ -58,9 +58,9 @@ bigtime_t current_time_hires(void)
return time;
}
time_t current_time(void)
lk_time_t current_time(void)
{
time_t time;
lk_time_t time;
*REG(SYSINFO_TIME_LATCH) = 1;
time = *REG(SYSINFO_TIME_SECS) * 1000;
time += *REG(SYSINFO_TIME_USECS) / 1000;

View File

@@ -34,7 +34,7 @@
static platform_timer_callback timer_func;
static volatile time_t ticks = 0;
static volatile lk_time_t ticks = 0;
#if FIXED_1KHZ_TIMER
static volatile int timer_interval;
@@ -43,12 +43,12 @@ static volatile int timer_downcount;
static int timer_ms_per_tick;
#endif
time_t current_time(void)
lk_time_t current_time(void)
{
return ticks;
}
bigtime_t current_time_hires(void)
lk_bigtime_t current_time_hires(void)
{
return ticks * 1000ULL;
}
@@ -75,7 +75,7 @@ static enum handler_return pit_irq_handler(void *arg)
}
status_t platform_set_periodic_timer(platform_timer_callback callback,
void *arg, time_t interval)
void *arg, lk_time_t interval)
{
unsigned n;

View File

@@ -98,7 +98,7 @@ int i2c_transmit(int bus, uint8_t address, const void *buf, size_t count)
I2C_REG(bus, I2C_CNT) = count;
I2C_REG(bus, I2C_CON) = (1<<15)|(1<<10)|(1<<9)|(1<<1)|(1<<0); // enable, master, transmit, STP, STT
time_t t = current_time();
lk_time_t t = current_time();
const uint8_t *ptr = (const uint8_t *)buf;
for(;;) {
@@ -158,7 +158,7 @@ int i2c_receive(int bus, uint8_t address, void *buf, size_t count)
I2C_REG(bus, I2C_CNT) = count;
I2C_REG(bus, I2C_CON) = (1<<15)|(1<<10)|(1<<1)|(1<<0); // enable, master, STP, STT
time_t t = current_time();
lk_time_t t = current_time();
uint8_t *ptr = (uint8_t *)buf;
for(;;) {

View File

@@ -31,7 +31,7 @@
#include <platform/omap3.h>
#include "platform_p.h"
static time_t tick_interval;
static lk_time_t tick_interval;
static platform_timer_callback t_callback;
static void *callback_arg;
@@ -42,7 +42,7 @@ static const ulong timer_base = OMAP34XX_GPT2;
#define TIMER_REG(reg) *REG32(timer_base + (reg))
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, time_t interval)
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, lk_time_t interval)
{
enter_critical_section();
@@ -64,7 +64,7 @@ status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg
return NO_ERROR;
}
time_t current_time(void)
lk_time_t current_time(void)
{
uint32_t delta_ticks;
uint32_t delta_ticks2;
@@ -77,10 +77,10 @@ retry:
uint64_t longtime = delta_ticks * 1000ULL / 32768ULL;
return (time_t)longtime;
return (lk_time_t)longtime;
}
bigtime_t current_time_hires(void)
lk_bigtime_t current_time_hires(void)
{
uint32_t delta_ticks;
uint32_t delta_ticks2;
@@ -93,7 +93,7 @@ retry:
uint64_t longtime = delta_ticks * 1000000ULL / 32768ULL;
return (bigtime_t)longtime;
return (lk_bigtime_t)longtime;
}
static enum handler_return os_timer_tick(void *arg)
{

View File

@@ -99,7 +99,7 @@ void platform_dputc(char c)
uart_putc(0, c);
}
static enum handler_return debug_timer_callback(timer_t *t, time_t now, void *arg)
static enum handler_return debug_timer_callback(timer_t *t, lk_time_t now, void *arg)
{
signed char c;
c = uart_getc(0, false);

View File

@@ -30,14 +30,14 @@
#include <platform/omap5912.h>
#include "platform_p.h"
static time_t system_time = 0;
static lk_time_t system_time = 0;
static time_t tick_interval;
static lk_time_t tick_interval;
static uint32_t ticks_per_interval;
static platform_timer_callback t_callback;
static void *callback_arg;
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, time_t interval)
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, lk_time_t interval)
{
enter_critical_section();
@@ -55,9 +55,9 @@ status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg
return NO_ERROR;
}
time_t current_time(void)
lk_time_t current_time(void)
{
time_t t;
lk_time_t t;
uint32_t delta_ticks;
uint32_t delta_ticks2;
@@ -73,9 +73,9 @@ retry:
return t;
}
bigtime_t current_time_hires(void)
lk_bigtime_t current_time_hires(void)
{
time_t t;
lk_time_t t;
uint32_t delta_ticks;
uint32_t delta_ticks2;

View File

@@ -48,7 +48,7 @@ void _systick(void)
bool resched = false;
if (cb) {
time_t now = current_time();
lk_time_t now = current_time();
if (cb(cb_args, now) == INT_RESCHEDULE)
resched = true;
}
@@ -61,7 +61,7 @@ void _systick(void)
dec_critical_section();
}
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, time_t interval)
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, lk_time_t interval)
{
LTRACEF("callback %p, arg %p, interval %d\n", callback, arg, interval);
@@ -80,12 +80,12 @@ void sam3_tc0_irq(void)
ticks += 0xffff;
}
time_t current_time(void)
lk_time_t current_time(void)
{
return current_time_hires() / 1000;
}
bigtime_t current_time_hires(void)
lk_bigtime_t current_time_hires(void)
{
uint64_t t;
do {
@@ -99,7 +99,7 @@ bigtime_t current_time_hires(void)
} while (0);
/* convert ticks to usec */
bigtime_t res = t / (TICK_RATE / 1000000);
lk_bigtime_t res = t / (TICK_RATE / 1000000);
return res;
}

View File

@@ -48,8 +48,8 @@ void stm32_flash_nor_early_init(void)
void stm32_flash_nor_init(void)
{
TRACEF("flash size %d\n", FLASH_SIZE);
TRACEF("page size %d\n", FLASH_PAGE_SIZE);
TRACEF("flash size %zu\n", FLASH_SIZE);
TRACEF("page size %zu\n", FLASH_PAGE_SIZE);
}
const struct flash_nor_bank *flash_nor_get_bank(unsigned int bank)

View File

@@ -61,7 +61,7 @@ void _systick(void)
dec_critical_section();
}
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, time_t interval)
status_t platform_set_periodic_timer(platform_timer_callback callback, void *arg, lk_time_t interval)
{
LTRACEF("callback %p, arg %p, interval %u\n", callback, arg, (uint)interval);
@@ -113,12 +113,12 @@ void stm32_TIM2_IRQ(void)
stm32_tim_irq(2);
}
time_t current_time(void)
lk_time_t current_time(void)
{
return ticks;
}
bigtime_t current_time_hires(void)
lk_bigtime_t current_time_hires(void)
{
uint64_t tusec;
uint32_t count1, count2;