4
0
mirror of https://github.com/RT-Thread/rt-thread.git synced 2025-02-07 09:34:34 +08:00

fixed coding style in kservice.c

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2522 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
dzzxzz@gmail.com 2012-12-25 08:23:12 +00:00
parent a6b4440643
commit 55f1cb72b6

View File

@ -156,11 +156,11 @@ void *rt_memset(void *s, int c, rt_ubase_t count)
else else
{ {
buffer = 0; buffer = 0;
for (i = 0; i < LBLOCKSIZE; i++) for (i = 0; i < LBLOCKSIZE; i ++)
buffer = (buffer << 8) | d; buffer = (buffer << 8) | d;
} }
while (count >= LBLOCKSIZE*4) while (count >= LBLOCKSIZE * 4)
{ {
*aligned_addr++ = buffer; *aligned_addr++ = buffer;
*aligned_addr++ = buffer; *aligned_addr++ = buffer;
@ -215,7 +215,8 @@ void *rt_memcpy(void *dst, const void *src, rt_ubase_t count)
#else #else
#define UNALIGNED(X, Y) \ #define UNALIGNED(X, Y) \
(((rt_int32_t)X & (sizeof(rt_int32_t) - 1)) | ((rt_int32_t)Y & (sizeof(rt_int32_t) - 1))) (((rt_int32_t)X & (sizeof(rt_int32_t) - 1)) | \
((rt_int32_t)Y & (sizeof(rt_int32_t) - 1)))
#define BIGBLOCKSIZE (sizeof(rt_int32_t) << 2) #define BIGBLOCKSIZE (sizeof(rt_int32_t) << 2)
#define LITTLEBLOCKSIZE (sizeof(rt_int32_t)) #define LITTLEBLOCKSIZE (sizeof(rt_int32_t))
#define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE) #define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE)
@ -498,7 +499,8 @@ void rt_show_version(void)
{ {
rt_kprintf("\n \\ | /\n"); rt_kprintf("\n \\ | /\n");
rt_kprintf("- RT - Thread Operating System\n"); rt_kprintf("- RT - Thread Operating System\n");
rt_kprintf(" / | \\ %d.%d.%d build %s\n", RT_VERSION, RT_SUBVERSION, RT_REVISION, __DATE__); rt_kprintf(" / | \\ %d.%d.%d build %s\n",
RT_VERSION, RT_SUBVERSION, RT_REVISION, __DATE__);
rt_kprintf(" 2006 - 2012 Copyright by rt-thread team\n"); rt_kprintf(" 2006 - 2012 Copyright by rt-thread team\n");
} }
RTM_EXPORT(rt_show_version); RTM_EXPORT(rt_show_version);
@ -543,9 +545,20 @@ rt_inline int skip_atoi(const char **s)
#define LARGE (1 << 6) /* use 'ABCDEF' instead of 'abcdef' */ #define LARGE (1 << 6) /* use 'ABCDEF' instead of 'abcdef' */
#ifdef RT_PRINTF_PRECISION #ifdef RT_PRINTF_PRECISION
static char *print_number(char *buf, char *end, long num, int base, int s, int precision, int type) static char *print_number(char *buf,
char *end,
long num,
int base,
int s,
int precision,
int type)
#else #else
static char *print_number(char *buf, char *end, long num, int base, int s, int type) static char *print_number(char *buf,
char *end,
long num,
int base,
int s,
int type)
#endif #endif
{ {
char c, sign; char c, sign;
@ -577,15 +590,19 @@ static char *print_number(char *buf, char *end, long num, int base, int s, int t
sign = '-'; sign = '-';
num = -num; num = -num;
} }
else if (type & PLUS) sign = '+'; else if (type & PLUS)
else if (type & SPACE) sign = ' '; sign = '+';
else if (type & SPACE)
sign = ' ';
} }
#ifdef RT_PRINTF_SPECIAL #ifdef RT_PRINTF_SPECIAL
if (type & SPECIAL) if (type & SPECIAL)
{ {
if (base == 16) size -= 2; if (base == 16)
else if (base == 8) size--; size -= 2;
else if (base == 8)
size--;
} }
#endif #endif
@ -690,7 +707,10 @@ static char *print_number(char *buf, char *end, long num, int base, int s, int t
return buf; return buf;
} }
static rt_int32_t vsnprintf(char *buf, rt_size_t size, const char *fmt, va_list args) static rt_int32_t vsnprintf(char *buf,
rt_size_t size,
const char *fmt,
va_list args)
{ {
#ifdef RT_PRINTF_LONGLONG #ifdef RT_PRINTF_LONGLONG
unsigned long long num; unsigned long long num;
@ -1134,17 +1154,18 @@ void* rt_malloc_align(rt_size_t size, rt_size_t align)
ptr = rt_malloc(align_size); ptr = rt_malloc(align_size);
if (ptr != RT_NULL) if (ptr != RT_NULL)
{ {
if (((rt_uint32_t)ptr & (align - 1)) == 0) /* 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); align_ptr = (void *)((rt_uint32_t)ptr + align);
} }
else else
{ {
align_ptr = (void*) (((rt_uint32_t)ptr + (align - 1)) & ~(align - 1)); align_ptr = (void *)(((rt_uint32_t)ptr + (align - 1)) & ~(align - 1));
} }
/* set the pointer before alignment pointer to the real pointer */ /* set the pointer before alignment pointer to the real pointer */
*((rt_uint32_t*)((rt_uint32_t)align_ptr - sizeof(void*))) = (rt_uint32_t)ptr; *((rt_uint32_t *)((rt_uint32_t)align_ptr - sizeof(void *))) = (rt_uint32_t)ptr;
ptr = align_ptr; ptr = align_ptr;
} }
@ -1154,8 +1175,8 @@ void* rt_malloc_align(rt_size_t size, rt_size_t align)
RTM_EXPORT(rt_malloc_align); RTM_EXPORT(rt_malloc_align);
/** /**
* This function release the memory block, which is allocated by rt_malloc_align * This function release the memory block, which is allocated by
* function and address is aligned. * rt_malloc_align function and address is aligned.
* *
* @param ptr the memory block pointer * @param ptr the memory block pointer
*/ */
@ -1163,7 +1184,7 @@ void rt_free_align(void *ptr)
{ {
void *real_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); rt_free(real_ptr);
} }
RTM_EXPORT(rt_free_align); RTM_EXPORT(rt_free_align);