Merge pull request #848 from emlslxl/master
cleanup the coding style for include/src.
This commit is contained in:
commit
ed46356eb4
|
@ -97,7 +97,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
|
|||
#define RT_UNUSED __attribute__((unused))
|
||||
#define RT_USED __attribute__((used))
|
||||
#define ALIGN(n) __attribute__((aligned(n)))
|
||||
#define WEAK __weak
|
||||
#define WEAK __weak
|
||||
#define rt_inline static __inline
|
||||
/* module compiling */
|
||||
#ifdef RT_USING_MODULE
|
||||
|
@ -121,7 +121,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
|
|||
#ifdef RT_USING_NEWLIB
|
||||
#include <stdarg.h>
|
||||
#else
|
||||
/* the version of GNU GCC must be greater than 4.x */
|
||||
/* the version of GNU GCC must be greater than 4.x */
|
||||
typedef __builtin_va_list __gnuc_va_list;
|
||||
typedef __gnuc_va_list va_list;
|
||||
#define va_start(v,l) __builtin_va_start(v,l)
|
||||
|
@ -142,7 +142,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
|
|||
#define RT_UNUSED __attribute__((unused))
|
||||
#define RT_USED __attribute__((used))
|
||||
#define ALIGN(n) __attribute__((aligned(n)))
|
||||
#define WEAK __attribute__((weak))
|
||||
#define WEAK __attribute__((weak))
|
||||
#define rt_inline static inline
|
||||
#define RTT_API
|
||||
#elif defined (_MSC_VER)
|
||||
|
@ -151,7 +151,7 @@ typedef rt_base_t rt_off_t; /**< Type for offset */
|
|||
#define RT_UNUSED
|
||||
#define RT_USED
|
||||
#define ALIGN(n) __declspec(align(n))
|
||||
#define WEAK
|
||||
#define WEAK
|
||||
#define rt_inline static __inline
|
||||
#define RTT_API
|
||||
#elif defined (__TI_COMPILER_VERSION__)
|
||||
|
@ -177,20 +177,20 @@ typedef int (*init_fn_t)(void);
|
|||
#ifdef _MSC_VER /* we do not support MS VC++ compiler */
|
||||
#define INIT_EXPORT(fn, level)
|
||||
#else
|
||||
#if RT_DEBUG_INIT
|
||||
struct rt_init_desc
|
||||
{
|
||||
const char* fn_name;
|
||||
const init_fn_t fn;
|
||||
};
|
||||
#define INIT_EXPORT(fn, level) \
|
||||
const char __rti_##fn##_name[] = #fn; \
|
||||
const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn."level) = \
|
||||
{ __rti_##fn##_name, fn};
|
||||
#else
|
||||
#define INIT_EXPORT(fn, level) \
|
||||
const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn
|
||||
#endif
|
||||
#if RT_DEBUG_INIT
|
||||
struct rt_init_desc
|
||||
{
|
||||
const char* fn_name;
|
||||
const init_fn_t fn;
|
||||
};
|
||||
#define INIT_EXPORT(fn, level) \
|
||||
const char __rti_##fn##_name[] = #fn; \
|
||||
const struct rt_init_desc __rt_init_desc_##fn SECTION(".rti_fn."level) = \
|
||||
{ __rti_##fn##_name, fn};
|
||||
#else
|
||||
#define INIT_EXPORT(fn, level) \
|
||||
const init_fn_t __rt_init_##fn SECTION(".rti_fn."level) = fn
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
#define INIT_EXPORT(fn, level)
|
||||
|
@ -206,7 +206,7 @@ typedef int (*init_fn_t)(void);
|
|||
/* file system initialization (dfs-elm, dfs-rom, ...) */
|
||||
#define INIT_FS_EXPORT(fn) INIT_EXPORT(fn, "4")
|
||||
/* environment initialization (mount disk, ...) */
|
||||
#define INIT_ENV_EXPORT(fn) INIT_EXPORT(fn, "5")
|
||||
#define INIT_ENV_EXPORT(fn) INIT_EXPORT(fn, "5")
|
||||
/* appliation initialization (rtgui application etc ...) */
|
||||
#define INIT_APP_EXPORT(fn) INIT_EXPORT(fn, "6")
|
||||
|
||||
|
@ -759,8 +759,8 @@ enum rt_device_class_type
|
|||
RT_Device_Class_Pipe, /**< Pipe device */
|
||||
RT_Device_Class_Portal, /**< Portal device */
|
||||
RT_Device_Class_Timer, /**< Timer device */
|
||||
RT_Device_Class_Miscellaneous, /**< Miscellaneous device */
|
||||
RT_Device_Class_Unknown /**< unknown device */
|
||||
RT_Device_Class_Miscellaneous, /**< Miscellaneous device */
|
||||
RT_Device_Class_Unknown /**< unknown device */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -778,9 +778,9 @@ enum rt_device_class_type
|
|||
#define RT_DEVICE_FLAG_SUSPENDED 0x020 /**< device is suspended */
|
||||
#define RT_DEVICE_FLAG_STREAM 0x040 /**< stream mode */
|
||||
|
||||
#define RT_DEVICE_CTRL_CONFIG 0x03 /* configure device */
|
||||
#define RT_DEVICE_CTRL_SET_INT 0x10 /* enable receive irq */
|
||||
#define RT_DEVICE_CTRL_CLR_INT 0x11 /* disable receive irq */
|
||||
#define RT_DEVICE_CTRL_CONFIG 0x03 /* configure device */
|
||||
#define RT_DEVICE_CTRL_SET_INT 0x10 /* enable receive irq */
|
||||
#define RT_DEVICE_CTRL_CLR_INT 0x11 /* disable receive irq */
|
||||
#define RT_DEVICE_CTRL_GET_INT 0x12
|
||||
|
||||
#define RT_DEVICE_FLAG_INT_RX 0x100 /**< INT mode on Rx */
|
||||
|
@ -969,15 +969,15 @@ struct rt_module
|
|||
{
|
||||
struct rt_object parent; /**< inherit from object */
|
||||
|
||||
rt_uint32_t vstart_addr; /**< VMA base address for the
|
||||
rt_uint32_t vstart_addr; /**< VMA base address for the
|
||||
first LOAD segment. */
|
||||
rt_uint8_t *module_space; /**< module memory space */
|
||||
|
||||
void *module_entry; /**< the entry address of module */
|
||||
rt_thread_t module_thread; /**< the main thread of module */
|
||||
|
||||
rt_uint8_t* module_cmd_line; /**< module command line */
|
||||
rt_uint32_t module_cmd_size; /**< the size of module command line */
|
||||
rt_uint8_t *module_cmd_line; /**< module command line */
|
||||
rt_uint32_t module_cmd_size; /**< the size of module command line */
|
||||
|
||||
#ifdef RT_USING_SLAB
|
||||
/* module memory allocator */
|
||||
|
|
|
@ -262,8 +262,8 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap,
|
|||
void *start_addr,
|
||||
rt_uint32_t size);
|
||||
rt_err_t rt_memheap_detach(struct rt_memheap *heap);
|
||||
void* rt_memheap_alloc(struct rt_memheap *heap, rt_uint32_t size);
|
||||
void *rt_memheap_realloc(struct rt_memheap* heap, void* ptr, rt_size_t newsize);
|
||||
void *rt_memheap_alloc(struct rt_memheap *heap, rt_uint32_t size);
|
||||
void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize);
|
||||
void rt_memheap_free(void *ptr);
|
||||
#endif
|
||||
|
||||
|
@ -429,7 +429,7 @@ rt_module_t rt_module_load(const char *name, void *module_ptr);
|
|||
rt_err_t rt_module_unload(rt_module_t module);
|
||||
#ifdef RT_USING_DFS
|
||||
rt_module_t rt_module_open(const char *filename);
|
||||
rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int size);
|
||||
rt_module_t rt_module_exec_cmd(const char *path, const char *cmd_line, int size);
|
||||
#endif
|
||||
void *rt_module_malloc(rt_size_t size);
|
||||
void *rt_module_realloc(void *ptr, rt_size_t size);
|
||||
|
@ -496,7 +496,7 @@ void rt_kputs(const char *str);
|
|||
#endif
|
||||
rt_int32_t rt_vsprintf(char *dest, const char *format, va_list arg_ptr);
|
||||
rt_int32_t rt_vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args);
|
||||
rt_int32_t rt_sprintf(char *buf ,const char *format, ...);
|
||||
rt_int32_t rt_sprintf(char *buf, const char *format, ...);
|
||||
rt_int32_t rt_snprintf(char *buf, rt_size_t size, const char *format, ...);
|
||||
|
||||
#if defined(RT_USING_DEVICE) && defined(RT_USING_CONSOLE)
|
||||
|
@ -517,8 +517,8 @@ void *rt_memset(void *src, int c, rt_ubase_t n);
|
|||
void *rt_memcpy(void *dest, const void *src, rt_ubase_t n);
|
||||
|
||||
rt_int32_t rt_strncmp(const char *cs, const char *ct, rt_ubase_t count);
|
||||
rt_int32_t rt_strcmp (const char *cs, const char *ct);
|
||||
rt_size_t rt_strlen (const char *src);
|
||||
rt_int32_t rt_strcmp(const char *cs, const char *ct);
|
||||
rt_size_t rt_strlen(const char *src);
|
||||
char *rt_strdup(const char *s);
|
||||
|
||||
char *rt_strstr(const char *str1, const char *str2);
|
||||
|
@ -531,10 +531,10 @@ rt_uint32_t rt_strcasecmp(const char *a, const char *b);
|
|||
void rt_show_version(void);
|
||||
|
||||
#ifdef RT_DEBUG
|
||||
extern void (*rt_assert_hook)(const char* ex, const char* func, rt_size_t line);
|
||||
void rt_assert_set_hook(void (*hook)(const char* ex, const char* func, rt_size_t line));
|
||||
extern void (*rt_assert_hook)(const char *ex, const char *func, rt_size_t line);
|
||||
void rt_assert_set_hook(void (*hook)(const char *ex, const char *func, rt_size_t line));
|
||||
|
||||
void rt_assert_handler(const char* ex, const char* func, rt_size_t line);
|
||||
void rt_assert_handler(const char *ex, const char *func, rt_size_t line);
|
||||
#endif /* RT_DEBUG */
|
||||
|
||||
/**@}*/
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
|
||||
#ifdef RT_USING_COMPONENTS_INIT
|
||||
/*
|
||||
* Components Initialization will initialize some driver and components as following
|
||||
* Components Initialization will initialize some driver and components as following
|
||||
* order:
|
||||
* rti_start --> 0
|
||||
* BOARD_EXPORT --> 1
|
||||
|
@ -51,17 +51,17 @@
|
|||
* COMPONENT_EXPORT --> 3
|
||||
* FS_EXPORT --> 4
|
||||
* ENV_EXPORT --> 5
|
||||
* APP_EXPORT --> 6
|
||||
*
|
||||
* APP_EXPORT --> 6
|
||||
*
|
||||
* rti_end --> 6.end
|
||||
*
|
||||
* These automatically initializaiton, the driver or component initial function must
|
||||
* These automatically initializaiton, the driver or component initial function must
|
||||
* be defined with:
|
||||
* INIT_BOARD_EXPORT(fn);
|
||||
* INIT_DEVICE_EXPORT(fn);
|
||||
* ...
|
||||
* INIT_APP_EXPORT(fn);
|
||||
* etc.
|
||||
* etc.
|
||||
*/
|
||||
static int rti_start(void)
|
||||
{
|
||||
|
@ -155,11 +155,11 @@ int $Sub$$main(void)
|
|||
#elif defined(__ICCARM__)
|
||||
extern int main(void);
|
||||
/* __low_level_init will auto called by IAR cstartup */
|
||||
extern void __iar_data_init3( void );
|
||||
extern void __iar_data_init3(void);
|
||||
int __low_level_init(void)
|
||||
{
|
||||
// call IAR table copy function.
|
||||
__iar_data_init3();
|
||||
// call IAR table copy function.
|
||||
__iar_data_init3();
|
||||
rt_hw_interrupt_disable();
|
||||
rtthread_startup();
|
||||
return 0;
|
||||
|
@ -221,7 +221,7 @@ void rt_application_init(void)
|
|||
|
||||
int rtthread_startup(void)
|
||||
{
|
||||
rt_hw_interrupt_disable();
|
||||
rt_hw_interrupt_disable();
|
||||
|
||||
/* board level initalization
|
||||
* NOTE: please initialize heap inside board initialization.
|
||||
|
|
12
src/idle.c
12
src/idle.c
|
@ -55,7 +55,7 @@ static void (*rt_thread_idle_hook)();
|
|||
|
||||
/**
|
||||
* @ingroup Hook
|
||||
* This function sets a hook function to idle thread loop. When the system performs
|
||||
* This function sets a hook function to idle thread loop. When the system performs
|
||||
* idle loop, this hook function should be invoked.
|
||||
*
|
||||
* @param hook the specified hook function
|
||||
|
@ -77,7 +77,7 @@ rt_inline int _has_defunct_thread(void)
|
|||
* into a "if".
|
||||
*
|
||||
* So add the volatile qualifier here. */
|
||||
const volatile rt_list_t *l = (const volatile rt_list_t*)&rt_thread_defunct;
|
||||
const volatile rt_list_t *l = (const volatile rt_list_t *)&rt_thread_defunct;
|
||||
|
||||
return l->next != l;
|
||||
}
|
||||
|
@ -155,8 +155,8 @@ void rt_thread_idle_excute(void)
|
|||
rt_module_free((rt_module_t)thread->module_id, thread->stack_addr);
|
||||
else
|
||||
#endif
|
||||
/* release thread's stack */
|
||||
RT_KERNEL_FREE(thread->stack_addr);
|
||||
/* release thread's stack */
|
||||
RT_KERNEL_FREE(thread->stack_addr);
|
||||
/* delete thread object */
|
||||
rt_object_delete((rt_object_t)thread);
|
||||
#endif
|
||||
|
@ -185,12 +185,12 @@ static void rt_thread_idle_entry(void *parameter)
|
|||
{
|
||||
while (1)
|
||||
{
|
||||
#ifdef RT_USING_IDLE_HOOK
|
||||
#ifdef RT_USING_IDLE_HOOK
|
||||
if (rt_thread_idle_hook != RT_NULL)
|
||||
{
|
||||
rt_thread_idle_hook();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
rt_thread_idle_excute();
|
||||
}
|
||||
|
|
16
src/ipc.c
16
src/ipc.c
|
@ -1382,8 +1382,8 @@ rt_err_t rt_mb_delete(rt_mailbox_t mb)
|
|||
else
|
||||
#endif
|
||||
|
||||
/* free mailbox pool */
|
||||
RT_KERNEL_FREE(mb->msg_pool);
|
||||
/* free mailbox pool */
|
||||
RT_KERNEL_FREE(mb->msg_pool);
|
||||
|
||||
/* delete mailbox object */
|
||||
rt_object_delete(&(mb->parent.parent));
|
||||
|
@ -1775,7 +1775,7 @@ rt_err_t rt_mq_init(rt_mq_t mq,
|
|||
for (temp = 0; temp < mq->max_msgs; temp ++)
|
||||
{
|
||||
head = (struct rt_mq_message *)((rt_uint8_t *)mq->msg_pool +
|
||||
temp * (mq->msg_size + sizeof(struct rt_mq_message)));
|
||||
temp * (mq->msg_size + sizeof(struct rt_mq_message)));
|
||||
head->next = mq->msg_queue_free;
|
||||
mq->msg_queue_free = head;
|
||||
}
|
||||
|
@ -1849,7 +1849,7 @@ rt_mq_t rt_mq_create(const char *name,
|
|||
mq->max_msgs = max_msgs;
|
||||
|
||||
/* allocate message pool */
|
||||
mq->msg_pool = RT_KERNEL_MALLOC((mq->msg_size + sizeof(struct rt_mq_message))* mq->max_msgs);
|
||||
mq->msg_pool = RT_KERNEL_MALLOC((mq->msg_size + sizeof(struct rt_mq_message)) * mq->max_msgs);
|
||||
if (mq->msg_pool == RT_NULL)
|
||||
{
|
||||
rt_mq_delete(mq);
|
||||
|
@ -1866,7 +1866,7 @@ rt_mq_t rt_mq_create(const char *name,
|
|||
for (temp = 0; temp < mq->max_msgs; temp ++)
|
||||
{
|
||||
head = (struct rt_mq_message *)((rt_uint8_t *)mq->msg_pool +
|
||||
temp * (mq->msg_size + sizeof(struct rt_mq_message)));
|
||||
temp * (mq->msg_size + sizeof(struct rt_mq_message)));
|
||||
head->next = mq->msg_queue_free;
|
||||
mq->msg_queue_free = head;
|
||||
}
|
||||
|
@ -1902,8 +1902,8 @@ rt_err_t rt_mq_delete(rt_mq_t mq)
|
|||
else
|
||||
#endif
|
||||
|
||||
/* free message queue pool */
|
||||
RT_KERNEL_FREE(mq->msg_pool);
|
||||
/* free message queue pool */
|
||||
RT_KERNEL_FREE(mq->msg_pool);
|
||||
|
||||
/* delete message queue object */
|
||||
rt_object_delete(&(mq->parent.parent));
|
||||
|
@ -1942,7 +1942,7 @@ rt_err_t rt_mq_send(rt_mq_t mq, void *buffer, rt_size_t size)
|
|||
temp = rt_hw_interrupt_disable();
|
||||
|
||||
/* get a free list, there must be an empty item */
|
||||
msg = (struct rt_mq_message*)mq->msg_queue_free;
|
||||
msg = (struct rt_mq_message *)mq->msg_queue_free;
|
||||
/* message queue is full */
|
||||
if (msg == RT_NULL)
|
||||
{
|
||||
|
|
|
@ -118,7 +118,7 @@ int *_rt_errno(void)
|
|||
|
||||
tid = rt_thread_self();
|
||||
if (tid != RT_NULL)
|
||||
return (int *)&(tid->error);
|
||||
return (int *) & (tid->error);
|
||||
|
||||
return (int *)&_errno;
|
||||
}
|
||||
|
@ -464,9 +464,9 @@ rt_int32_t rt_strcmp(const char *cs, const char *ct)
|
|||
RTM_EXPORT(rt_strcmp);
|
||||
/**
|
||||
* The strnlen() function returns the number of characters in the
|
||||
* string pointed to by s, excluding the terminating null byte ('\0'),
|
||||
* but at most maxlen. In doing this, strnlen() looks only at the
|
||||
* first maxlen characters in the string pointed to by s and never
|
||||
* string pointed to by s, excluding the terminating null byte ('\0'),
|
||||
* but at most maxlen. In doing this, strnlen() looks only at the
|
||||
* first maxlen characters in the string pointed to by s and never
|
||||
* beyond s+maxlen.
|
||||
*
|
||||
* @param s the string
|
||||
|
@ -547,13 +547,13 @@ rt_inline rt_int32_t divide(rt_int32_t *n, rt_int32_t base)
|
|||
/* optimized for processor which does not support divide instructions. */
|
||||
if (base == 10)
|
||||
{
|
||||
res = ((rt_uint32_t)*n) % 10U;
|
||||
*n = ((rt_uint32_t)*n) / 10U;
|
||||
res = ((rt_uint32_t) * n) % 10U;
|
||||
*n = ((rt_uint32_t) * n) / 10U;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = ((rt_uint32_t)*n) % 16U;
|
||||
*n = ((rt_uint32_t)*n) / 16U;
|
||||
res = ((rt_uint32_t) * n) % 16U;
|
||||
*n = ((rt_uint32_t) * n) / 16U;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
@ -561,7 +561,7 @@ rt_inline rt_int32_t divide(rt_int32_t *n, rt_int32_t base)
|
|||
|
||||
rt_inline int skip_atoi(const char **s)
|
||||
{
|
||||
register int i=0;
|
||||
register int i = 0;
|
||||
while (isdigit(**s))
|
||||
i = i * 10 + *((*s)++) - '0';
|
||||
|
||||
|
@ -640,7 +640,7 @@ static char *print_number(char *buf,
|
|||
|
||||
i = 0;
|
||||
if (num == 0)
|
||||
tmp[i++]='0';
|
||||
tmp[i++] = '0';
|
||||
else
|
||||
{
|
||||
while (num != 0)
|
||||
|
@ -655,12 +655,12 @@ static char *print_number(char *buf,
|
|||
size -= i;
|
||||
#endif
|
||||
|
||||
if (!(type&(ZEROPAD | LEFT)))
|
||||
if (!(type & (ZEROPAD | LEFT)))
|
||||
{
|
||||
if ((sign)&&(size>0))
|
||||
if ((sign) && (size > 0))
|
||||
size--;
|
||||
|
||||
while (size-->0)
|
||||
while (size-- > 0)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = ' ';
|
||||
|
@ -681,7 +681,7 @@ static char *print_number(char *buf,
|
|||
#ifdef RT_PRINTF_SPECIAL
|
||||
if (type & SPECIAL)
|
||||
{
|
||||
if (base==8)
|
||||
if (base == 8)
|
||||
{
|
||||
if (buf <= end)
|
||||
*buf = '0';
|
||||
|
@ -694,7 +694,7 @@ static char *print_number(char *buf,
|
|||
++ buf;
|
||||
if (buf <= end)
|
||||
{
|
||||
*buf = type & LARGE? 'X' : 'x';
|
||||
*buf = type & LARGE ? 'X' : 'x';
|
||||
}
|
||||
++ buf;
|
||||
}
|
||||
|
@ -768,7 +768,7 @@ rt_int32_t rt_vsnprintf(char *buf,
|
|||
/* Make sure end is always >= buf */
|
||||
if (end < buf)
|
||||
{
|
||||
end = ((char *)-1);
|
||||
end = ((char *) - 1);
|
||||
size = end - buf;
|
||||
}
|
||||
|
||||
|
@ -929,7 +929,7 @@ rt_int32_t rt_vsnprintf(char *buf,
|
|||
++ str;
|
||||
continue;
|
||||
|
||||
/* integer number formats - set up the flags and "break" */
|
||||
/* integer number formats - set up the flags and "break" */
|
||||
case 'o':
|
||||
base = 8;
|
||||
break;
|
||||
|
@ -1028,7 +1028,7 @@ RTM_EXPORT(rt_snprintf);
|
|||
*/
|
||||
rt_int32_t rt_vsprintf(char *buf, const char *format, va_list arg_ptr)
|
||||
{
|
||||
return rt_vsnprintf(buf, (rt_size_t) -1, format, arg_ptr);
|
||||
return rt_vsnprintf(buf, (rt_size_t) - 1, format, arg_ptr);
|
||||
}
|
||||
RTM_EXPORT(rt_vsprintf);
|
||||
|
||||
|
@ -1044,7 +1044,7 @@ rt_int32_t rt_sprintf(char *buf, const char *format, ...)
|
|||
va_list arg_ptr;
|
||||
|
||||
va_start(arg_ptr, format);
|
||||
n = rt_vsprintf(buf ,format, arg_ptr);
|
||||
n = rt_vsprintf(buf, format, arg_ptr);
|
||||
va_end(arg_ptr);
|
||||
|
||||
return n;
|
||||
|
@ -1183,7 +1183,7 @@ RTM_EXPORT(rt_kprintf);
|
|||
*
|
||||
* @return the allocated memory block on successful, otherwise returns RT_NULL
|
||||
*/
|
||||
void* rt_malloc_align(rt_size_t size, rt_size_t align)
|
||||
void *rt_malloc_align(rt_size_t size, rt_size_t align)
|
||||
{
|
||||
void *align_ptr;
|
||||
void *ptr;
|
||||
|
@ -1198,7 +1198,7 @@ void* rt_malloc_align(rt_size_t size, rt_size_t align)
|
|||
ptr = rt_malloc(align_size);
|
||||
if (ptr != RT_NULL)
|
||||
{
|
||||
/* the allocated memory block is aligned */
|
||||
/* the allocated memory block is aligned */
|
||||
if (((rt_uint32_t)ptr & (align - 1)) == 0)
|
||||
{
|
||||
align_ptr = (void *)((rt_uint32_t)ptr + align);
|
||||
|
@ -1228,7 +1228,7 @@ void rt_free_align(void *ptr)
|
|||
{
|
||||
void *real_ptr;
|
||||
|
||||
real_ptr = (void *)*(rt_uint32_t *)((rt_uint32_t)ptr - sizeof(void *));
|
||||
real_ptr = (void *) * (rt_uint32_t *)((rt_uint32_t)ptr - sizeof(void *));
|
||||
rt_free(real_ptr);
|
||||
}
|
||||
RTM_EXPORT(rt_free_align);
|
||||
|
@ -1284,13 +1284,14 @@ rt_ubase_t __rt_ffs(rt_ubase_t value)
|
|||
|
||||
#ifdef RT_DEBUG
|
||||
/* RT_ASSERT(EX)'s hook */
|
||||
void (*rt_assert_hook)(const char* ex, const char* func, rt_size_t line);
|
||||
void (*rt_assert_hook)(const char *ex, const char *func, rt_size_t line);
|
||||
/**
|
||||
* This function will set a hook function to RT_ASSERT(EX). It will run when the expression is false.
|
||||
*
|
||||
* @param hook the hook function
|
||||
*/
|
||||
void rt_assert_set_hook(void (*hook)(const char* ex, const char* func, rt_size_t line)) {
|
||||
void rt_assert_set_hook(void (*hook)(const char *ex, const char *func, rt_size_t line))
|
||||
{
|
||||
rt_assert_hook = hook;
|
||||
}
|
||||
|
||||
|
@ -1301,30 +1302,30 @@ void rt_assert_set_hook(void (*hook)(const char* ex, const char* func, rt_size_t
|
|||
* @param func the function name when assertion.
|
||||
* @param line the file line number when assertion.
|
||||
*/
|
||||
void rt_assert_handler(const char* ex_string, const char* func, rt_size_t line)
|
||||
void rt_assert_handler(const char *ex_string, const char *func, rt_size_t line)
|
||||
{
|
||||
volatile char dummy = 0;
|
||||
|
||||
if (rt_assert_hook == RT_NULL)
|
||||
{
|
||||
#ifdef RT_USING_MODULE
|
||||
if (rt_module_self() != RT_NULL)
|
||||
{
|
||||
/* unload assertion module */
|
||||
rt_module_unload(rt_module_self());
|
||||
if (rt_module_self() != RT_NULL)
|
||||
{
|
||||
/* unload assertion module */
|
||||
rt_module_unload(rt_module_self());
|
||||
|
||||
/* re-schedule */
|
||||
rt_schedule();
|
||||
}
|
||||
else
|
||||
/* re-schedule */
|
||||
rt_schedule();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
rt_kprintf("(%s) assertion failed at function:%s, line number:%d \n", ex_string, func, line);
|
||||
while (dummy == 0);
|
||||
}
|
||||
{
|
||||
rt_kprintf("(%s) assertion failed at function:%s, line number:%d \n", ex_string, func, line);
|
||||
while (dummy == 0);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else
|
||||
{
|
||||
rt_assert_hook(ex_string, func, line);
|
||||
}
|
||||
}
|
||||
|
@ -1339,7 +1340,7 @@ void *memmove(void *dest, const void *src, size_t n) __attribute__((weak, alias(
|
|||
int memcmp(const void *s1, const void *s2, size_t n) __attribute__((weak, alias("rt_memcmp")));
|
||||
|
||||
size_t strlen(const char *s) __attribute__((weak, alias("rt_strlen")));
|
||||
char *strstr(const char *s1,const char *s2) __attribute__((weak, alias("rt_strstr")));
|
||||
char *strstr(const char *s1, const char *s2) __attribute__((weak, alias("rt_strstr")));
|
||||
int strcasecmp(const char *a, const char *b) __attribute__((weak, alias("rt_strcasecmp")));
|
||||
char *strncpy(char *dest, const char *src, size_t n) __attribute__((weak, alias("rt_strncpy")));
|
||||
int strncmp(const char *cs, const char *ct, size_t count) __attribute__((weak, alias("rt_strncmp")));
|
||||
|
|
10
src/mem.c
10
src/mem.c
|
@ -335,7 +335,7 @@ void *rt_malloc(rt_size_t size)
|
|||
*/
|
||||
mem->used = 1;
|
||||
#ifdef RT_MEM_STATS
|
||||
used_mem += mem->next - ((rt_uint8_t*)mem - heap_ptr);
|
||||
used_mem += mem->next - ((rt_uint8_t *)mem - heap_ptr);
|
||||
if (max_mem < used_mem)
|
||||
max_mem = used_mem;
|
||||
#endif
|
||||
|
@ -355,7 +355,7 @@ void *rt_malloc(rt_size_t size)
|
|||
rt_sem_release(&heap_sem);
|
||||
RT_ASSERT((rt_uint32_t)mem + SIZEOF_STRUCT_MEM + size <= (rt_uint32_t)heap_end);
|
||||
RT_ASSERT((rt_uint32_t)((rt_uint8_t *)mem + SIZEOF_STRUCT_MEM) % RT_ALIGN_SIZE == 0);
|
||||
RT_ASSERT((((rt_uint32_t)mem) & (RT_ALIGN_SIZE-1)) == 0);
|
||||
RT_ASSERT((((rt_uint32_t)mem) & (RT_ALIGN_SIZE - 1)) == 0);
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_MEM,
|
||||
("allocate memory at 0x%x, size: %d\n",
|
||||
|
@ -443,7 +443,7 @@ void *rt_realloc(void *rmem, rt_size_t newsize)
|
|||
|
||||
ptr2 = ptr + SIZEOF_STRUCT_MEM + newsize;
|
||||
mem2 = (struct heap_mem *)&heap_ptr[ptr2];
|
||||
mem2->magic= HEAP_MAGIC;
|
||||
mem2->magic = HEAP_MAGIC;
|
||||
mem2->used = 0;
|
||||
mem2->next = mem->next;
|
||||
mem2->prev = ptr;
|
||||
|
@ -516,7 +516,7 @@ void rt_free(void *rmem)
|
|||
|
||||
if (rmem == RT_NULL)
|
||||
return;
|
||||
RT_ASSERT((((rt_uint32_t)rmem) & (RT_ALIGN_SIZE-1)) == 0);
|
||||
RT_ASSERT((((rt_uint32_t)rmem) & (RT_ALIGN_SIZE - 1)) == 0);
|
||||
RT_ASSERT((rt_uint8_t *)rmem >= (rt_uint8_t *)heap_ptr &&
|
||||
(rt_uint8_t *)rmem < (rt_uint8_t *)heap_end);
|
||||
|
||||
|
@ -556,7 +556,7 @@ void rt_free(void *rmem)
|
|||
}
|
||||
|
||||
#ifdef RT_MEM_STATS
|
||||
used_mem -= (mem->next - ((rt_uint8_t*)mem - heap_ptr));
|
||||
used_mem -= (mem->next - ((rt_uint8_t *)mem - heap_ptr));
|
||||
#endif
|
||||
|
||||
/* finally, see if prev or next are free also */
|
||||
|
|
|
@ -96,7 +96,7 @@ rt_err_t rt_memheap_init(struct rt_memheap *memheap,
|
|||
item->prev_free = item;
|
||||
|
||||
item->next = (struct rt_memheap_item *)
|
||||
((rt_uint8_t *)item + memheap->available_size + RT_MEMHEAP_SIZE);
|
||||
((rt_uint8_t *)item + memheap->available_size + RT_MEMHEAP_SIZE);
|
||||
item->prev = item->next;
|
||||
|
||||
/* block list header */
|
||||
|
@ -315,10 +315,10 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
|
|||
header_ptr = (struct rt_memheap_item *)
|
||||
((rt_uint8_t *)ptr - RT_MEMHEAP_SIZE);
|
||||
oldsize = MEMITEM_SIZE(header_ptr);
|
||||
/* re-allocate memory */
|
||||
/* re-allocate memory */
|
||||
if (newsize > oldsize)
|
||||
{
|
||||
void* new_ptr;
|
||||
void *new_ptr;
|
||||
struct rt_memheap_item *next_ptr;
|
||||
|
||||
/* lock memheap */
|
||||
|
@ -371,7 +371,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
|
|||
next_ptr->prev->next = next_ptr->next;
|
||||
|
||||
/* build a new one on the right place */
|
||||
next_ptr = (struct rt_memheap_item*)((char*)ptr + newsize);
|
||||
next_ptr = (struct rt_memheap_item *)((char *)ptr + newsize);
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_MEMHEAP,
|
||||
("new free block: block[0x%08x] nextm[0x%08x] prevm[0x%08x]",
|
||||
|
@ -410,7 +410,7 @@ void *rt_memheap_realloc(struct rt_memheap *heap, void *ptr, rt_size_t newsize)
|
|||
rt_sem_release(&(heap->lock));
|
||||
|
||||
/* re-allocate a memory block */
|
||||
new_ptr = (void*)rt_memheap_alloc(heap, newsize);
|
||||
new_ptr = (void *)rt_memheap_alloc(heap, newsize);
|
||||
if (new_ptr != RT_NULL)
|
||||
{
|
||||
rt_memcpy(new_ptr, ptr, oldsize < newsize ? oldsize : newsize);
|
||||
|
@ -503,8 +503,8 @@ void rt_memheap_free(void *ptr)
|
|||
struct rt_memheap_item *header_ptr, *new_ptr;
|
||||
rt_uint32_t insert_header;
|
||||
|
||||
/* NULL check */
|
||||
if (ptr == RT_NULL) return;
|
||||
/* NULL check */
|
||||
if (ptr == RT_NULL) return;
|
||||
|
||||
/* set initial status as OK */
|
||||
insert_header = 1;
|
||||
|
@ -610,7 +610,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr)
|
|||
|
||||
void *rt_malloc(rt_size_t size)
|
||||
{
|
||||
void* ptr;
|
||||
void *ptr;
|
||||
|
||||
/* try to allocate in system heap */
|
||||
ptr = rt_memheap_alloc(&_heap, size);
|
||||
|
|
|
@ -299,8 +299,8 @@ rt_err_t rt_mp_delete(rt_mp_t mp)
|
|||
else
|
||||
#endif
|
||||
|
||||
/* release allocated room */
|
||||
rt_free(mp->start_address);
|
||||
/* release allocated room */
|
||||
rt_free(mp->start_address);
|
||||
|
||||
/* detach object */
|
||||
rt_object_delete(&(mp->parent));
|
||||
|
|
90
src/module.c
90
src/module.c
|
@ -138,7 +138,7 @@ void list_symbol(void)
|
|||
index != _rt_module_symtab_end;
|
||||
index ++)
|
||||
{
|
||||
rt_kprintf("%s\n", index->name);
|
||||
rt_kprintf("%s\n", index->name);
|
||||
}
|
||||
|
||||
return ;
|
||||
|
@ -259,10 +259,10 @@ static int rt_module_arm_relocate(struct rt_module *module,
|
|||
j1 = (lower >> 13) & 1;
|
||||
j2 = (lower >> 11) & 1;
|
||||
offset = (sign << 24) |
|
||||
((~(j1 ^ sign) & 1) << 23) |
|
||||
((~(j2 ^ sign) & 1) << 22) |
|
||||
((upper & 0x03ff) << 12) |
|
||||
((lower & 0x07ff) << 1);
|
||||
((~(j1 ^ sign) & 1) << 23) |
|
||||
((~(j2 ^ sign) & 1) << 22) |
|
||||
((upper & 0x03ff) << 12) |
|
||||
((lower & 0x07ff) << 1);
|
||||
if (offset & 0x01000000)
|
||||
offset -= 0x02000000;
|
||||
offset += sym_val - (Elf32_Addr)where;
|
||||
|
@ -517,7 +517,7 @@ static struct rt_module *_load_shared_object(const char *name,
|
|||
|
||||
/* set module entry */
|
||||
module->module_entry = module->module_space
|
||||
+ elf_module->e_entry - vstart_addr;
|
||||
+ elf_module->e_entry - vstart_addr;
|
||||
|
||||
/* handle relocation section */
|
||||
for (index = 0; index < elf_module->e_shnum; index ++)
|
||||
|
@ -538,7 +538,7 @@ static struct rt_module *_load_shared_object(const char *name,
|
|||
symtab = (Elf32_Sym *)((rt_uint8_t *)module_ptr +
|
||||
shdr[shdr[index].sh_link].sh_offset);
|
||||
strtab = (rt_uint8_t *)module_ptr +
|
||||
shdr[shdr[shdr[index].sh_link].sh_link].sh_offset;
|
||||
shdr[shdr[shdr[index].sh_link].sh_link].sh_offset;
|
||||
nr_reloc = (rt_uint32_t)(shdr[index].sh_size / sizeof(Elf32_Rel));
|
||||
|
||||
/* relocate every items */
|
||||
|
@ -555,7 +555,7 @@ static struct rt_module *_load_shared_object(const char *name,
|
|||
#ifdef MODULE_USING_386
|
||||
|| ( (ELF_ST_BIND(sym->st_info) == STB_GLOBAL) && (ELF_ST_TYPE(sym->st_info) == STT_OBJECT) )
|
||||
#endif
|
||||
)
|
||||
)
|
||||
{
|
||||
rt_module_arm_relocate(module, rel,
|
||||
(Elf32_Addr)(module->module_space
|
||||
|
@ -597,7 +597,7 @@ static struct rt_module *_load_shared_object(const char *name,
|
|||
/* find .dynsym section */
|
||||
rt_uint8_t *shstrab;
|
||||
shstrab = (rt_uint8_t *)module_ptr +
|
||||
shdr[elf_module->e_shstrndx].sh_offset;
|
||||
shdr[elf_module->e_shstrndx].sh_offset;
|
||||
if (rt_strcmp((const char *)(shstrab + shdr[index].sh_name), ELF_DYNSYM) == 0)
|
||||
break;
|
||||
}
|
||||
|
@ -609,10 +609,10 @@ static struct rt_module *_load_shared_object(const char *name,
|
|||
Elf32_Sym *symtab = RT_NULL;
|
||||
rt_uint8_t *strtab = RT_NULL;
|
||||
|
||||
symtab =(Elf32_Sym *)((rt_uint8_t *)module_ptr + shdr[index].sh_offset);
|
||||
symtab = (Elf32_Sym *)((rt_uint8_t *)module_ptr + shdr[index].sh_offset);
|
||||
strtab = (rt_uint8_t *)module_ptr + shdr[shdr[index].sh_link].sh_offset;
|
||||
|
||||
for (i = 0; i < shdr[index].sh_size/sizeof(Elf32_Sym); i++)
|
||||
for (i = 0; i < shdr[index].sh_size / sizeof(Elf32_Sym); i++)
|
||||
{
|
||||
if ((ELF_ST_BIND(symtab[i].st_info) == STB_GLOBAL) &&
|
||||
(ELF_ST_TYPE(symtab[i].st_info) == STT_FUNC))
|
||||
|
@ -620,9 +620,9 @@ static struct rt_module *_load_shared_object(const char *name,
|
|||
}
|
||||
|
||||
module->symtab = (struct rt_module_symtab *)rt_malloc
|
||||
(count * sizeof(struct rt_module_symtab));
|
||||
(count * sizeof(struct rt_module_symtab));
|
||||
module->nsym = count;
|
||||
for (i = 0, count = 0; i < shdr[index].sh_size/sizeof(Elf32_Sym); i++)
|
||||
for (i = 0, count = 0; i < shdr[index].sh_size / sizeof(Elf32_Sym); i++)
|
||||
{
|
||||
rt_size_t length;
|
||||
|
||||
|
@ -686,7 +686,7 @@ static struct rt_module* _load_relocated_object(const char *name,
|
|||
|
||||
/* allocate module */
|
||||
module = (struct rt_module *)
|
||||
rt_object_allocate(RT_Object_Class_Module, (const char *)name);
|
||||
rt_object_allocate(RT_Object_Class_Module, (const char *)name);
|
||||
if (module == RT_NULL)
|
||||
return RT_NULL;
|
||||
|
||||
|
@ -777,9 +777,9 @@ static struct rt_module* _load_relocated_object(const char *name,
|
|||
symtab = (Elf32_Sym *)((rt_uint8_t *)module_ptr +
|
||||
shdr[shdr[index].sh_link].sh_offset);
|
||||
strtab = (rt_uint8_t *)module_ptr +
|
||||
shdr[shdr[shdr[index].sh_link].sh_link].sh_offset;
|
||||
shdr[shdr[shdr[index].sh_link].sh_link].sh_offset;
|
||||
shstrab = (rt_uint8_t *)module_ptr +
|
||||
shdr[elf_module->e_shstrndx].sh_offset;
|
||||
shdr[elf_module->e_shstrndx].sh_offset;
|
||||
nr_reloc = (rt_uint32_t)(shdr[index].sh_size / sizeof(Elf32_Rel));
|
||||
|
||||
/* relocate every items */
|
||||
|
@ -803,7 +803,7 @@ static struct rt_module* _load_relocated_object(const char *name,
|
|||
rt_module_arm_relocate(module, rel,
|
||||
(Elf32_Addr)(rodata_addr + sym->st_value));
|
||||
}
|
||||
else if (rt_strncmp((const char*)
|
||||
else if (rt_strncmp((const char *)
|
||||
(shstrab + shdr[sym->st_shndx].sh_name), ELF_BSS, 5) == 0)
|
||||
{
|
||||
/* relocate bss section */
|
||||
|
@ -854,7 +854,7 @@ static struct rt_module* _load_relocated_object(const char *name,
|
|||
else
|
||||
{
|
||||
rt_module_arm_relocate(module, rel,
|
||||
(Elf32_Addr)((rt_uint8_t*)
|
||||
(Elf32_Addr)((rt_uint8_t *)
|
||||
module->module_space
|
||||
- module_addr
|
||||
+ sym->st_value));
|
||||
|
@ -868,7 +868,7 @@ static struct rt_module* _load_relocated_object(const char *name,
|
|||
}
|
||||
|
||||
#define RT_MODULE_ARG_MAX 8
|
||||
static int _rt_module_split_arg(char* cmd, rt_size_t length, char* argv[])
|
||||
static int _rt_module_split_arg(char *cmd, rt_size_t length, char *argv[])
|
||||
{
|
||||
int argc = 0;
|
||||
char *ptr = cmd;
|
||||
|
@ -876,10 +876,10 @@ static int _rt_module_split_arg(char* cmd, rt_size_t length, char* argv[])
|
|||
while ((ptr - cmd) < length)
|
||||
{
|
||||
/* strip bank and tab */
|
||||
while ((*ptr == ' ' || *ptr == '\t') && (ptr -cmd)< length)
|
||||
while ((*ptr == ' ' || *ptr == '\t') && (ptr - cmd) < length)
|
||||
*ptr++ = '\0';
|
||||
/* check whether it's the end of line */
|
||||
if ((ptr - cmd)>= length) break;
|
||||
if ((ptr - cmd) >= length) break;
|
||||
|
||||
/* handle string with quote */
|
||||
if (*ptr == '"')
|
||||
|
@ -887,7 +887,7 @@ static int _rt_module_split_arg(char* cmd, rt_size_t length, char* argv[])
|
|||
argv[argc++] = ++ptr;
|
||||
|
||||
/* skip this string */
|
||||
while (*ptr != '"' && (ptr-cmd) < length)
|
||||
while (*ptr != '"' && (ptr - cmd) < length)
|
||||
if (*ptr ++ == '\\') ptr ++;
|
||||
if ((ptr - cmd) >= length) break;
|
||||
|
||||
|
@ -908,11 +908,11 @@ static int _rt_module_split_arg(char* cmd, rt_size_t length, char* argv[])
|
|||
}
|
||||
|
||||
/* module main thread entry */
|
||||
static void module_main_entry(void* parameter)
|
||||
static void module_main_entry(void *parameter)
|
||||
{
|
||||
int argc;
|
||||
char *argv[RT_MODULE_ARG_MAX];
|
||||
typedef int (*main_func_t)(int argc, char** argv);
|
||||
typedef int (*main_func_t)(int argc, char **argv);
|
||||
|
||||
rt_module_t module = (rt_module_t) parameter;
|
||||
if (module == RT_NULL)
|
||||
|
@ -934,7 +934,7 @@ static void module_main_entry(void* parameter)
|
|||
}
|
||||
|
||||
rt_memset(argv, 0x00, sizeof(argv));
|
||||
argc = _rt_module_split_arg((char*)module->module_cmd_line,
|
||||
argc = _rt_module_split_arg((char *)module->module_cmd_line,
|
||||
module->module_cmd_size, argv);
|
||||
if (argc == 0)
|
||||
return;
|
||||
|
@ -948,19 +948,19 @@ static void module_main_entry(void* parameter)
|
|||
}
|
||||
|
||||
/**
|
||||
* This function will load a module with a main function from memory and create a
|
||||
* This function will load a module with a main function from memory and create a
|
||||
* main thread for it
|
||||
*
|
||||
* @param name the name of module, which shall be unique
|
||||
* @param module_ptr the memory address of module image
|
||||
* @argc the count of argument
|
||||
* @argd the argument data, which should be a
|
||||
* @argd the argument data, which should be a
|
||||
*
|
||||
* @return the module object
|
||||
*/
|
||||
rt_module_t rt_module_do_main(const char *name,
|
||||
void *module_ptr,
|
||||
const char* cmd_line,
|
||||
const char *cmd_line,
|
||||
int line_size)
|
||||
{
|
||||
rt_module_t module;
|
||||
|
@ -1010,7 +1010,7 @@ rt_module_t rt_module_do_main(const char *name,
|
|||
if (line_size && cmd_line)
|
||||
{
|
||||
/* set module argument */
|
||||
module->module_cmd_line = (rt_uint8_t*)rt_malloc(line_size + 1);
|
||||
module->module_cmd_line = (rt_uint8_t *)rt_malloc(line_size + 1);
|
||||
if (module->module_cmd_line)
|
||||
{
|
||||
rt_memcpy(module->module_cmd_line, cmd_line, line_size);
|
||||
|
@ -1088,7 +1088,7 @@ rt_module_t rt_module_load(const char *name, void *module_ptr)
|
|||
#ifdef RT_USING_DFS
|
||||
#include <dfs_posix.h>
|
||||
|
||||
static char* _module_name(const char *path)
|
||||
static char *_module_name(const char *path)
|
||||
{
|
||||
const char *first, *end, *ptr;
|
||||
char *name;
|
||||
|
@ -1136,7 +1136,7 @@ rt_module_t rt_module_open(const char *path)
|
|||
/* check parameters */
|
||||
RT_ASSERT(path != RT_NULL);
|
||||
|
||||
if (stat(path, &s) !=0)
|
||||
if (stat(path, &s) != 0)
|
||||
{
|
||||
rt_kprintf("Module: access %s failed\n", path);
|
||||
|
||||
|
@ -1197,7 +1197,7 @@ rt_module_t rt_module_open(const char *path)
|
|||
*
|
||||
* @return the module object
|
||||
*/
|
||||
rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int size)
|
||||
rt_module_t rt_module_exec_cmd(const char *path, const char *cmd_line, int size)
|
||||
{
|
||||
struct stat s;
|
||||
int fd, length;
|
||||
|
@ -1212,7 +1212,7 @@ rt_module_t rt_module_exec_cmd(const char *path, const char* cmd_line, int size)
|
|||
RT_ASSERT(path != RT_NULL);
|
||||
|
||||
/* get file size */
|
||||
if (stat(path, &s) !=0)
|
||||
if (stat(path, &s) != 0)
|
||||
{
|
||||
rt_kprintf("Module: access %s failed\n", path);
|
||||
goto __exit;
|
||||
|
@ -1649,7 +1649,7 @@ static void rt_module_free_page(rt_module_t module,
|
|||
}
|
||||
else if (page[i].npage == npages)
|
||||
{
|
||||
for (index = i; index < module->page_cnt-1; index ++)
|
||||
for (index = i; index < module->page_cnt - 1; index ++)
|
||||
{
|
||||
page[index].page_ptr = page[index + 1].page_ptr;
|
||||
page[index].npage = page[index + 1].npage;
|
||||
|
@ -1688,8 +1688,8 @@ void *rt_module_malloc(rt_size_t size)
|
|||
RT_DEBUG_NOT_IN_INTERRUPT;
|
||||
|
||||
nunits = (size + sizeof(struct rt_mem_head) - 1) /
|
||||
sizeof(struct rt_mem_head)
|
||||
+ 1;
|
||||
sizeof(struct rt_mem_head)
|
||||
+ 1;
|
||||
|
||||
RT_ASSERT(size != 0);
|
||||
RT_ASSERT(nunits != 0);
|
||||
|
@ -1732,7 +1732,7 @@ void *rt_module_malloc(rt_size_t size)
|
|||
|
||||
/* allocate pages from system heap */
|
||||
npage = (size + sizeof(struct rt_mem_head) + RT_MM_PAGE_SIZE - 1) /
|
||||
RT_MM_PAGE_SIZE;
|
||||
RT_MM_PAGE_SIZE;
|
||||
if ((up = (struct rt_mem_head *)rt_module_malloc_page(npage)) == RT_NULL)
|
||||
return RT_NULL;
|
||||
|
||||
|
@ -1765,7 +1765,7 @@ void rt_module_free(rt_module_t module, void *addr)
|
|||
RT_DEBUG_NOT_IN_INTERRUPT;
|
||||
|
||||
RT_ASSERT(addr);
|
||||
RT_ASSERT((((rt_uint32_t)addr) & (sizeof(struct rt_mem_head) -1)) == 0);
|
||||
RT_ASSERT((((rt_uint32_t)addr) & (sizeof(struct rt_mem_head) - 1)) == 0);
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_MODULE, ("rt_module_free 0x%x\n", addr));
|
||||
|
||||
|
@ -1798,8 +1798,8 @@ void rt_module_free(rt_module_t module, void *addr)
|
|||
if ((b->size * sizeof(struct rt_page_info) % RT_MM_PAGE_SIZE) != 0)
|
||||
{
|
||||
rt_size_t nunits = npage *
|
||||
RT_MM_PAGE_SIZE /
|
||||
sizeof(struct rt_mem_head);
|
||||
RT_MM_PAGE_SIZE /
|
||||
sizeof(struct rt_mem_head);
|
||||
/* split memory */
|
||||
r = b + nunits;
|
||||
r->next = b->next;
|
||||
|
@ -1835,8 +1835,8 @@ void rt_module_free(rt_module_t module, void *addr)
|
|||
if ((n->size * sizeof(struct rt_page_info) % RT_MM_PAGE_SIZE) != 0)
|
||||
{
|
||||
rt_size_t nunits = npage *
|
||||
RT_MM_PAGE_SIZE /
|
||||
sizeof(struct rt_mem_head);
|
||||
RT_MM_PAGE_SIZE /
|
||||
sizeof(struct rt_mem_head);
|
||||
/* split memory */
|
||||
r = n + nunits;
|
||||
r->next = n->next;
|
||||
|
@ -1921,8 +1921,8 @@ void *rt_module_realloc(void *ptr, rt_size_t size)
|
|||
}
|
||||
|
||||
nunits = (size + sizeof(struct rt_mem_head) - 1) /
|
||||
sizeof(struct rt_mem_head)
|
||||
+1;
|
||||
sizeof(struct rt_mem_head)
|
||||
+ 1;
|
||||
b = (struct rt_mem_head *)ptr - 1;
|
||||
|
||||
if (nunits <= b->size)
|
||||
|
@ -1984,7 +1984,7 @@ void *rt_module_realloc(void *ptr, rt_size_t size)
|
|||
{
|
||||
if ((p = rt_module_malloc(size)) == RT_NULL)
|
||||
return RT_NULL;
|
||||
rt_memmove(p, (b+1), ((b->size) * sizeof(struct rt_mem_head)));
|
||||
rt_memmove(p, (b + 1), ((b->size) * sizeof(struct rt_mem_head)));
|
||||
rt_module_free(self_module, (void *)(b + 1));
|
||||
|
||||
return (void *)(p);
|
||||
|
|
14
src/object.c
14
src/object.c
|
@ -211,7 +211,7 @@ void rt_object_init(struct rt_object *object,
|
|||
#ifdef RT_USING_MODULE
|
||||
/* get module object information */
|
||||
information = (rt_module_self() != RT_NULL) ?
|
||||
&rt_module_self()->module_object[type] : &rt_object_container[type];
|
||||
&rt_module_self()->module_object[type] : &rt_object_container[type];
|
||||
#else
|
||||
/* get object information */
|
||||
information = &rt_object_container[type];
|
||||
|
@ -362,8 +362,8 @@ void rt_object_delete(rt_object_t object)
|
|||
else
|
||||
#endif
|
||||
|
||||
/* free the memory of object */
|
||||
RT_KERNEL_FREE(object);
|
||||
/* free the memory of object */
|
||||
RT_KERNEL_FREE(object);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -424,7 +424,7 @@ rt_object_t rt_object_find(const char *name, rt_uint8_t type)
|
|||
|
||||
if (*name_ptr == '/')
|
||||
{
|
||||
struct rt_module* module = RT_NULL;
|
||||
struct rt_module *module = RT_NULL;
|
||||
|
||||
/* get the name length of module */
|
||||
module_name_length = name_ptr - name;
|
||||
|
@ -435,15 +435,15 @@ rt_object_t rt_object_find(const char *name, rt_uint8_t type)
|
|||
/* find module */
|
||||
information = &rt_object_container[RT_Object_Class_Module];
|
||||
for (node = information->object_list.next;
|
||||
node != &(information->object_list);
|
||||
node = node->next)
|
||||
node != &(information->object_list);
|
||||
node = node->next)
|
||||
{
|
||||
object = rt_list_entry(node, struct rt_object, list);
|
||||
if ((rt_strncmp(object->name, name, module_name_length) == 0) &&
|
||||
(module_name_length == RT_NAME_MAX || object->name[module_name_length] == '\0'))
|
||||
{
|
||||
/* get module */
|
||||
module = (struct rt_module*)object;
|
||||
module = (struct rt_module *)object;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,19 +90,19 @@ static void _rt_scheduler_stack_check(struct rt_thread *thread)
|
|||
RT_ASSERT(thread != RT_NULL);
|
||||
|
||||
if (*((rt_uint8_t *)thread->stack_addr) != '#' ||
|
||||
(rt_uint32_t)thread->sp <= (rt_uint32_t)thread->stack_addr ||
|
||||
(rt_uint32_t)thread->sp <= (rt_uint32_t)thread->stack_addr ||
|
||||
(rt_uint32_t)thread->sp >
|
||||
(rt_uint32_t)thread->stack_addr + (rt_uint32_t)thread->stack_size)
|
||||
{
|
||||
rt_uint32_t level;
|
||||
|
||||
rt_kprintf("thread:%s stack overflow\n", thread->name);
|
||||
#ifdef RT_USING_FINSH
|
||||
#ifdef RT_USING_FINSH
|
||||
{
|
||||
extern long list_thread(void);
|
||||
list_thread();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
level = rt_hw_interrupt_disable();
|
||||
while (level);
|
||||
}
|
||||
|
|
34
src/slab.c
34
src/slab.c
|
@ -222,8 +222,8 @@ static int zone_page_cnt;
|
|||
#define PAGE_TYPE_LARGE 0x02
|
||||
struct memusage
|
||||
{
|
||||
rt_uint32_t type:2 ; /* page type */
|
||||
rt_uint32_t size:30; /* pages allocated or offset from zone */
|
||||
rt_uint32_t type: 2 ; /* page type */
|
||||
rt_uint32_t size: 30; /* pages allocated or offset from zone */
|
||||
};
|
||||
static struct memusage *memusage = RT_NULL;
|
||||
#define btokup(addr) \
|
||||
|
@ -238,7 +238,7 @@ struct rt_page_head
|
|||
rt_size_t page; /* number of page */
|
||||
|
||||
/* dummy */
|
||||
char dummy[RT_MM_PAGE_SIZE - (sizeof(struct rt_page_head*) + sizeof (rt_size_t))];
|
||||
char dummy[RT_MM_PAGE_SIZE - (sizeof(struct rt_page_head *) + sizeof(rt_size_t))];
|
||||
};
|
||||
static struct rt_page_head *rt_page_list;
|
||||
static struct rt_semaphore heap_sem;
|
||||
|
@ -248,7 +248,7 @@ void *rt_page_alloc(rt_size_t npages)
|
|||
struct rt_page_head *b, *n;
|
||||
struct rt_page_head **prev;
|
||||
|
||||
if(npages == 0)
|
||||
if (npages == 0)
|
||||
return RT_NULL;
|
||||
|
||||
/* lock heap */
|
||||
|
@ -383,7 +383,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr)
|
|||
|
||||
/* calculate zone size */
|
||||
zone_size = ZALLOC_MIN_ZONE_SIZE;
|
||||
while (zone_size < ZALLOC_MAX_ZONE_SIZE && (zone_size << 1) < (limsize/1024))
|
||||
while (zone_size < ZALLOC_MAX_ZONE_SIZE && (zone_size << 1) < (limsize / 1024))
|
||||
zone_size <<= 1;
|
||||
|
||||
zone_limit = zone_size / 4;
|
||||
|
@ -398,7 +398,7 @@ void rt_system_heap_init(void *begin_addr, void *end_addr)
|
|||
/* allocate memusage array */
|
||||
limsize = npages * sizeof(struct memusage);
|
||||
limsize = RT_ALIGN(limsize, RT_MM_PAGE_SIZE);
|
||||
memusage = rt_page_alloc(limsize/RT_MM_PAGE_SIZE);
|
||||
memusage = rt_page_alloc(limsize / RT_MM_PAGE_SIZE);
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_SLAB, ("memusage 0x%x, size 0x%x\n",
|
||||
(rt_uint32_t)memusage, limsize));
|
||||
|
@ -411,20 +411,20 @@ void rt_system_heap_init(void *begin_addr, void *end_addr)
|
|||
rt_inline int zoneindex(rt_uint32_t *bytes)
|
||||
{
|
||||
/* unsigned for shift opt */
|
||||
rt_uint32_t n = (rt_uint32_t)*bytes;
|
||||
rt_uint32_t n = (rt_uint32_t) * bytes;
|
||||
|
||||
if (n < 128)
|
||||
{
|
||||
*bytes = n = (n + 7) & ~7;
|
||||
|
||||
/* 8 byte chunks, 16 zones */
|
||||
return(n / 8 - 1);
|
||||
return (n / 8 - 1);
|
||||
}
|
||||
if (n < 256)
|
||||
{
|
||||
*bytes = n = (n + 15) & ~15;
|
||||
|
||||
return(n / 16 + 7);
|
||||
return (n / 16 + 7);
|
||||
}
|
||||
if (n < 8192)
|
||||
{
|
||||
|
@ -432,35 +432,35 @@ rt_inline int zoneindex(rt_uint32_t *bytes)
|
|||
{
|
||||
*bytes = n = (n + 31) & ~31;
|
||||
|
||||
return(n / 32 + 15);
|
||||
return (n / 32 + 15);
|
||||
}
|
||||
if (n < 1024)
|
||||
{
|
||||
*bytes = n = (n + 63) & ~63;
|
||||
|
||||
return(n / 64 + 23);
|
||||
return (n / 64 + 23);
|
||||
}
|
||||
if (n < 2048)
|
||||
{
|
||||
*bytes = n = (n + 127) & ~127;
|
||||
|
||||
return(n / 128 + 31);
|
||||
return (n / 128 + 31);
|
||||
}
|
||||
if (n < 4096)
|
||||
{
|
||||
*bytes = n = (n + 255) & ~255;
|
||||
|
||||
return(n / 256 + 39);
|
||||
return (n / 256 + 39);
|
||||
}
|
||||
*bytes = n = (n + 511) & ~511;
|
||||
|
||||
return(n / 512 + 47);
|
||||
return (n / 512 + 47);
|
||||
}
|
||||
if (n < 16384)
|
||||
{
|
||||
*bytes = n = (n + 1023) & ~1023;
|
||||
|
||||
return(n / 1024 + 55);
|
||||
return (n / 1024 + 55);
|
||||
}
|
||||
|
||||
rt_kprintf("Unexpected byte count %d", n);
|
||||
|
@ -737,7 +737,7 @@ void *rt_realloc(void *ptr, rt_size_t size)
|
|||
|
||||
zoneindex(&size);
|
||||
if (z->z_chunksize == size)
|
||||
return(ptr); /* same chunk */
|
||||
return (ptr); /* same chunk */
|
||||
|
||||
/*
|
||||
* Allocate memory for the new request size. Note that zoneindex has
|
||||
|
@ -803,7 +803,7 @@ void rt_free(void *ptr)
|
|||
RT_OBJECT_HOOK_CALL(rt_free_hook, (ptr));
|
||||
|
||||
#ifdef RT_USING_MODULE
|
||||
if(rt_module_self() != RT_NULL)
|
||||
if (rt_module_self() != RT_NULL)
|
||||
{
|
||||
rt_module_free(rt_module_self(), ptr);
|
||||
|
||||
|
|
18
src/thread.c
18
src/thread.c
|
@ -55,7 +55,7 @@ static void (*rt_thread_inited_hook) (rt_thread_t thread);
|
|||
|
||||
/**
|
||||
* @ingroup Hook
|
||||
* This function sets a hook function when the system suspend a thread.
|
||||
* This function sets a hook function when the system suspend a thread.
|
||||
*
|
||||
* @param hook the specified hook function
|
||||
*
|
||||
|
@ -68,7 +68,7 @@ void rt_thread_suspend_sethook(void (*hook)(rt_thread_t thread))
|
|||
|
||||
/**
|
||||
* @ingroup Hook
|
||||
* This function sets a hook function when the system resume a thread.
|
||||
* This function sets a hook function when the system resume a thread.
|
||||
*
|
||||
* @param hook the specified hook function
|
||||
*
|
||||
|
@ -81,13 +81,13 @@ void rt_thread_resume_sethook(void (*hook)(rt_thread_t thread))
|
|||
|
||||
/**
|
||||
* @ingroup Hook
|
||||
* This function sets a hook function when a thread is initialized.
|
||||
* This function sets a hook function when a thread is initialized.
|
||||
*
|
||||
* @param hook the specified hook function
|
||||
*/
|
||||
void rt_thread_inited_sethook(void (*hook)(rt_thread_t thread))
|
||||
{
|
||||
rt_thread_inited_hook = hook;
|
||||
rt_thread_inited_hook = hook;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -151,8 +151,8 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread,
|
|||
/* init thread stack */
|
||||
rt_memset(thread->stack_addr, '#', thread->stack_size);
|
||||
thread->sp = (void *)rt_hw_stack_init(thread->entry, thread->parameter,
|
||||
(void *)((char *)thread->stack_addr + thread->stack_size - 4),
|
||||
(void *)rt_thread_exit);
|
||||
(void *)((char *)thread->stack_addr + thread->stack_size - 4),
|
||||
(void *)rt_thread_exit);
|
||||
|
||||
/* priority init */
|
||||
RT_ASSERT(priority < RT_THREAD_PRIORITY_MAX);
|
||||
|
@ -185,7 +185,7 @@ static rt_err_t _rt_thread_init(struct rt_thread *thread,
|
|||
0,
|
||||
RT_TIMER_FLAG_ONE_SHOT);
|
||||
|
||||
RT_OBJECT_HOOK_CALL(rt_thread_inited_hook,(thread));
|
||||
RT_OBJECT_HOOK_CALL(rt_thread_inited_hook, (thread));
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ rt_err_t rt_thread_suspend(rt_thread_t thread)
|
|||
/* enable interrupt */
|
||||
rt_hw_interrupt_enable(temp);
|
||||
|
||||
RT_OBJECT_HOOK_CALL(rt_thread_suspend_hook,(thread));
|
||||
RT_OBJECT_HOOK_CALL(rt_thread_suspend_hook, (thread));
|
||||
return RT_EOK;
|
||||
}
|
||||
RTM_EXPORT(rt_thread_suspend);
|
||||
|
@ -686,7 +686,7 @@ rt_err_t rt_thread_resume(rt_thread_t thread)
|
|||
/* insert to schedule ready list */
|
||||
rt_schedule_insert_thread(thread);
|
||||
|
||||
RT_OBJECT_HOOK_CALL(rt_thread_resume_hook,(thread));
|
||||
RT_OBJECT_HOOK_CALL(rt_thread_resume_hook, (thread));
|
||||
return RT_EOK;
|
||||
}
|
||||
RTM_EXPORT(rt_thread_resume);
|
||||
|
|
60
src/timer.c
60
src/timer.c
|
@ -28,7 +28,7 @@
|
|||
* 2010-05-12 Bernard fix the timer check bug.
|
||||
* 2010-11-02 Charlie re-implement tick overflow issue
|
||||
* 2012-12-15 Bernard fix the next timeout issue in soft timer
|
||||
* 2014-07-12 Bernard does not lock scheduler when invoking soft-timer
|
||||
* 2014-07-12 Bernard does not lock scheduler when invoking soft-timer
|
||||
* timeout function.
|
||||
*/
|
||||
|
||||
|
@ -147,13 +147,13 @@ void rt_timer_dump(rt_list_t timer_heads[])
|
|||
{
|
||||
rt_list_t *list;
|
||||
|
||||
for (list = timer_heads[RT_TIMER_SKIP_LIST_LEVEL-1].next;
|
||||
list != &timer_heads[RT_TIMER_SKIP_LIST_LEVEL-1];
|
||||
for (list = timer_heads[RT_TIMER_SKIP_LIST_LEVEL - 1].next;
|
||||
list != &timer_heads[RT_TIMER_SKIP_LIST_LEVEL - 1];
|
||||
list = list->next)
|
||||
{
|
||||
struct rt_timer *timer = rt_list_entry(list,
|
||||
struct rt_timer,
|
||||
row[RT_TIMER_SKIP_LIST_LEVEL-1]);
|
||||
row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
|
||||
rt_kprintf("%d", rt_timer_count_height(timer));
|
||||
}
|
||||
rt_kprintf("\n");
|
||||
|
@ -303,9 +303,9 @@ rt_err_t rt_timer_start(rt_timer_t timer)
|
|||
/* timer check */
|
||||
RT_ASSERT(timer != RT_NULL);
|
||||
|
||||
/* stop timer firstly */
|
||||
level = rt_hw_interrupt_disable();
|
||||
/* remove timer from list */
|
||||
/* stop timer firstly */
|
||||
level = rt_hw_interrupt_disable();
|
||||
/* remove timer from list */
|
||||
_rt_timer_remove(timer);
|
||||
/* change status of timer */
|
||||
timer->parent.flag &= ~RT_TIMER_FLAG_ACTIVATED;
|
||||
|
@ -339,7 +339,7 @@ rt_err_t rt_timer_start(rt_timer_t timer)
|
|||
row_head[0] = &timer_list[0];
|
||||
for (row_lvl = 0; row_lvl < RT_TIMER_SKIP_LIST_LEVEL; row_lvl++)
|
||||
{
|
||||
for (;row_head[row_lvl] != timer_list[row_lvl].prev;
|
||||
for (; row_head[row_lvl] != timer_list[row_lvl].prev;
|
||||
row_head[row_lvl] = row_head[row_lvl]->next)
|
||||
{
|
||||
struct rt_timer *t;
|
||||
|
@ -363,7 +363,7 @@ rt_err_t rt_timer_start(rt_timer_t timer)
|
|||
}
|
||||
}
|
||||
if (row_lvl != RT_TIMER_SKIP_LIST_LEVEL - 1)
|
||||
row_head[row_lvl+1] = row_head[row_lvl]+1;
|
||||
row_head[row_lvl + 1] = row_head[row_lvl] + 1;
|
||||
}
|
||||
|
||||
/* Interestingly, this super simple timer insert counter works very very
|
||||
|
@ -373,8 +373,8 @@ rt_err_t rt_timer_start(rt_timer_t timer)
|
|||
random_nr++;
|
||||
tst_nr = random_nr;
|
||||
|
||||
rt_list_insert_after(row_head[RT_TIMER_SKIP_LIST_LEVEL-1],
|
||||
&(timer->row[RT_TIMER_SKIP_LIST_LEVEL-1]));
|
||||
rt_list_insert_after(row_head[RT_TIMER_SKIP_LIST_LEVEL - 1],
|
||||
&(timer->row[RT_TIMER_SKIP_LIST_LEVEL - 1]));
|
||||
for (row_lvl = 2; row_lvl <= RT_TIMER_SKIP_LIST_LEVEL; row_lvl++)
|
||||
{
|
||||
if (!(tst_nr & RT_TIMER_SKIP_LIST_MASK))
|
||||
|
@ -384,7 +384,7 @@ rt_err_t rt_timer_start(rt_timer_t timer)
|
|||
break;
|
||||
/* Shift over the bits we have tested. Works well with 1 bit and 2
|
||||
* bits. */
|
||||
tst_nr >>= (RT_TIMER_SKIP_LIST_MASK+1)>>1;
|
||||
tst_nr >>= (RT_TIMER_SKIP_LIST_MASK + 1) >> 1;
|
||||
}
|
||||
|
||||
timer->parent.flag |= RT_TIMER_FLAG_ACTIVATED;
|
||||
|
@ -498,7 +498,7 @@ void rt_timer_check(void)
|
|||
/* disable interrupt */
|
||||
level = rt_hw_interrupt_disable();
|
||||
|
||||
while (!rt_list_isempty(&rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL-1]))
|
||||
while (!rt_list_isempty(&rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]))
|
||||
{
|
||||
t = rt_list_entry(rt_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next,
|
||||
struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
|
||||
|
@ -507,7 +507,7 @@ void rt_timer_check(void)
|
|||
* It supposes that the new tick shall less than the half duration of
|
||||
* tick max.
|
||||
*/
|
||||
if ((current_tick - t->timeout_tick) < RT_TICK_MAX/2)
|
||||
if ((current_tick - t->timeout_tick) < RT_TICK_MAX / 2)
|
||||
{
|
||||
RT_OBJECT_HOOK_CALL(rt_timer_timeout_hook, (t));
|
||||
|
||||
|
@ -570,13 +570,13 @@ void rt_soft_timer_check(void)
|
|||
|
||||
current_tick = rt_tick_get();
|
||||
|
||||
/* lock scheduler */
|
||||
rt_enter_critical();
|
||||
/* lock scheduler */
|
||||
rt_enter_critical();
|
||||
|
||||
for (n = rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL-1].next;
|
||||
n != &(rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL-1]);)
|
||||
for (n = rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1].next;
|
||||
n != &(rt_soft_timer_list[RT_TIMER_SKIP_LIST_LEVEL - 1]);)
|
||||
{
|
||||
t = rt_list_entry(n, struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL-1]);
|
||||
t = rt_list_entry(n, struct rt_timer, row[RT_TIMER_SKIP_LIST_LEVEL - 1]);
|
||||
|
||||
/*
|
||||
* It supposes that the new tick shall less than the half duration of
|
||||
|
@ -592,8 +592,8 @@ void rt_soft_timer_check(void)
|
|||
/* remove timer from timer list firstly */
|
||||
_rt_timer_remove(t);
|
||||
|
||||
/* not lock scheduler when performing timeout function */
|
||||
rt_exit_critical();
|
||||
/* not lock scheduler when performing timeout function */
|
||||
rt_exit_critical();
|
||||
/* call timeout function */
|
||||
t->timeout_func(t->parameter);
|
||||
|
||||
|
@ -602,8 +602,8 @@ void rt_soft_timer_check(void)
|
|||
|
||||
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("current tick: %d\n", current_tick));
|
||||
|
||||
/* lock scheduler */
|
||||
rt_enter_critical();
|
||||
/* lock scheduler */
|
||||
rt_enter_critical();
|
||||
|
||||
if ((t->parent.flag & RT_TIMER_FLAG_PERIODIC) &&
|
||||
(t->parent.flag & RT_TIMER_FLAG_ACTIVATED))
|
||||
|
@ -621,8 +621,8 @@ void rt_soft_timer_check(void)
|
|||
else break; /* not check anymore */
|
||||
}
|
||||
|
||||
/* unlock scheduler */
|
||||
rt_exit_critical();
|
||||
/* unlock scheduler */
|
||||
rt_exit_critical();
|
||||
|
||||
RT_DEBUG_LOG(RT_DEBUG_TIMER, ("software timer check leave\n"));
|
||||
}
|
||||
|
@ -649,7 +649,7 @@ static void rt_thread_timer_entry(void *parameter)
|
|||
/* get current tick */
|
||||
current_tick = rt_tick_get();
|
||||
|
||||
if ((next_timeout - current_tick) < RT_TICK_MAX/2)
|
||||
if ((next_timeout - current_tick) < RT_TICK_MAX / 2)
|
||||
{
|
||||
/* get the delta timeout tick */
|
||||
next_timeout = next_timeout - current_tick;
|
||||
|
@ -672,9 +672,9 @@ void rt_system_timer_init(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(rt_timer_list)/sizeof(rt_timer_list[0]); i++)
|
||||
for (i = 0; i < sizeof(rt_timer_list) / sizeof(rt_timer_list[0]); i++)
|
||||
{
|
||||
rt_list_init(rt_timer_list+i);
|
||||
rt_list_init(rt_timer_list + i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -689,10 +689,10 @@ void rt_system_timer_thread_init(void)
|
|||
int i;
|
||||
|
||||
for (i = 0;
|
||||
i < sizeof(rt_soft_timer_list)/sizeof(rt_soft_timer_list[0]);
|
||||
i < sizeof(rt_soft_timer_list) / sizeof(rt_soft_timer_list[0]);
|
||||
i++)
|
||||
{
|
||||
rt_list_init(rt_soft_timer_list+i);
|
||||
rt_list_init(rt_soft_timer_list + i);
|
||||
}
|
||||
|
||||
/* start software timer thread */
|
||||
|
|
Loading…
Reference in New Issue