mirror of
https://github.com/apache/nuttx.git
synced 2025-01-12 23:18:36 +08:00
Compare commits
3 commits
32cb6fa44a
...
efd38ca5ec
Author | SHA1 | Date | |
---|---|---|---|
|
efd38ca5ec | ||
|
aa0aecbd80 | ||
|
903212ef67 |
2 changed files with 18 additions and 12 deletions
|
@ -397,16 +397,17 @@ retry:
|
||||||
|
|
||||||
pool->nalloc++;
|
pool->nalloc++;
|
||||||
spin_unlock_irqrestore(&pool->lock, flags);
|
spin_unlock_irqrestore(&pool->lock, flags);
|
||||||
blk = kasan_unpoison(blk, pool->blocksize);
|
|
||||||
#ifdef CONFIG_MM_FILL_ALLOCATIONS
|
|
||||||
memset(blk, MM_ALLOC_MAGIC, pool->blocksize);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if CONFIG_MM_BACKTRACE >= 0
|
#if CONFIG_MM_BACKTRACE >= 0
|
||||||
mempool_add_backtrace(pool, (FAR struct mempool_backtrace_s *)
|
mempool_add_backtrace(pool, (FAR struct mempool_backtrace_s *)
|
||||||
((FAR char *)blk + pool->blocksize));
|
((FAR char *)blk + pool->blocksize));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
blk = kasan_unpoison(blk, pool->blocksize);
|
||||||
|
#ifdef CONFIG_MM_FILL_ALLOCATIONS
|
||||||
|
memset(blk, MM_ALLOC_MAGIC, pool->blocksize);
|
||||||
|
#endif
|
||||||
|
|
||||||
return blk;
|
return blk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ static struct timespec g_clock_wall_time;
|
||||||
static uint64_t g_clock_last_counter;
|
static uint64_t g_clock_last_counter;
|
||||||
static uint64_t g_clock_mask;
|
static uint64_t g_clock_mask;
|
||||||
static long g_clock_adjust;
|
static long g_clock_adjust;
|
||||||
|
static spinlock_t g_clock_lock = SP_UNLOCKED;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
|
@ -72,7 +73,7 @@ static int clock_get_current_time(FAR struct timespec *ts,
|
||||||
time_t sec;
|
time_t sec;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = spin_lock_irqsave(&g_clock_lock);
|
||||||
|
|
||||||
ret = up_timer_gettick(&counter);
|
ret = up_timer_gettick(&counter);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -96,7 +97,7 @@ static int clock_get_current_time(FAR struct timespec *ts,
|
||||||
ts->tv_sec = base->tv_sec + sec;
|
ts->tv_sec = base->tv_sec + sec;
|
||||||
|
|
||||||
errout_in_critical_section:
|
errout_in_critical_section:
|
||||||
leave_critical_section(flags);
|
spin_unlock_irqrestore(&g_clock_lock, flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ int clock_timekeeping_set_wall_time(FAR const struct timespec *ts)
|
||||||
uint64_t counter;
|
uint64_t counter;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = spin_lock_irqsave(&g_clock_lock);
|
||||||
|
|
||||||
ret = up_timer_gettick(&counter);
|
ret = up_timer_gettick(&counter);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -137,7 +138,7 @@ int clock_timekeeping_set_wall_time(FAR const struct timespec *ts)
|
||||||
g_clock_last_counter = counter;
|
g_clock_last_counter = counter;
|
||||||
|
|
||||||
errout_in_critical_section:
|
errout_in_critical_section:
|
||||||
leave_critical_section(flags);
|
spin_unlock_irqrestore(&g_clock_lock, flags);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +189,7 @@ int adjtime(FAR const struct timeval *delta, FAR struct timeval *olddelta)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = spin_lock_irqsave(&g_clock_lock);
|
||||||
|
|
||||||
adjust_usec = delta->tv_sec * USEC_PER_SEC + delta->tv_usec;
|
adjust_usec = delta->tv_sec * USEC_PER_SEC + delta->tv_usec;
|
||||||
|
|
||||||
|
@ -199,7 +200,7 @@ int adjtime(FAR const struct timeval *delta, FAR struct timeval *olddelta)
|
||||||
|
|
||||||
g_clock_adjust = adjust_usec;
|
g_clock_adjust = adjust_usec;
|
||||||
|
|
||||||
leave_critical_section(flags);
|
spin_unlock_irqrestore(&g_clock_lock, flags);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +218,7 @@ void clock_update_wall_time(void)
|
||||||
time_t sec;
|
time_t sec;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
flags = enter_critical_section();
|
flags = spin_lock_irqsave(&g_clock_lock);
|
||||||
|
|
||||||
ret = up_timer_gettick(&counter);
|
ret = up_timer_gettick(&counter);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
@ -271,7 +272,7 @@ void clock_update_wall_time(void)
|
||||||
g_clock_last_counter = counter;
|
g_clock_last_counter = counter;
|
||||||
|
|
||||||
errout_in_critical_section:
|
errout_in_critical_section:
|
||||||
leave_critical_section(flags);
|
spin_unlock_irqrestore(&g_clock_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -280,6 +281,9 @@ errout_in_critical_section:
|
||||||
|
|
||||||
void clock_inittimekeeping(FAR const struct timespec *tp)
|
void clock_inittimekeeping(FAR const struct timespec *tp)
|
||||||
{
|
{
|
||||||
|
irqstate_t flags;
|
||||||
|
|
||||||
|
flags = spin_lock_irqsave(&g_clock_lock);
|
||||||
up_timer_getmask(&g_clock_mask);
|
up_timer_getmask(&g_clock_mask);
|
||||||
|
|
||||||
if (tp)
|
if (tp)
|
||||||
|
@ -292,6 +296,7 @@ void clock_inittimekeeping(FAR const struct timespec *tp)
|
||||||
}
|
}
|
||||||
|
|
||||||
up_timer_gettick(&g_clock_last_counter);
|
up_timer_gettick(&g_clock_last_counter);
|
||||||
|
spin_unlock_irqrestore(&g_clock_lock, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
#endif /* CONFIG_CLOCK_TIMEKEEPING */
|
||||||
|
|
Loading…
Reference in a new issue