提交 43a6a907 编写于 作者: B bernard.xiong

use builtin va_arg in GCC 4.x

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1400 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 8e5f4287
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* 2008-07-12 Bernard remove all rt_int8, rt_uint32_t etc typedef * 2008-07-12 Bernard remove all rt_int8, rt_uint32_t etc typedef
* 2010-10-26 yi.qiu add module support * 2010-10-26 yi.qiu add module support
* 2010-11-10 Bernard add cleanup callback function in thread exit. * 2010-11-10 Bernard add cleanup callback function in thread exit.
* 2011-05-09 Bernard use builtin va_arg in GCC 4.x
*/ */
#ifndef __RT_DEF_H__ #ifndef __RT_DEF_H__
#define __RT_DEF_H__ #define __RT_DEF_H__
...@@ -97,17 +98,25 @@ typedef rt_uint32_t rt_off_t; /**< Type for offset */ ...@@ -97,17 +98,25 @@ typedef rt_uint32_t rt_off_t; /**< Type for offset */
#ifdef RT_USING_NEWLIB #ifdef RT_USING_NEWLIB
#include <stdarg.h> #include <stdarg.h>
#else #else
typedef void *__sys_va_list; #if __GNUC__ < 4
typedef __sys_va_list va_list; typedef void *__sys_va_list;
#define __va_rounded_size(type) \ typedef __sys_va_list va_list;
(((sizeof (type) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) #define __va_rounded_size(type) \
#define va_start(ap, lastarg) \ (((sizeof (type) + sizeof (int) - 1) / sizeof (int)) * sizeof (int))
(ap = ((char *) &(lastarg) + __va_rounded_size(lastarg))) #define va_start(ap, lastarg) \
#define va_end(ap) ((void)0) (ap = ((char *) &(lastarg) + __va_rounded_size(lastarg)))
/* little endian */ #define va_end(ap) ((void)0)
#define va_arg(ap, type) \ /* little endian */
(ap = (__sys_va_list) ((char *) (ap) + __va_rounded_size (type)), \ #define va_arg(ap, type) \
*((type *) (void *) ((char *) (ap) - __va_rounded_size (type)))) (ap = (__sys_va_list) ((char *) (ap) + __va_rounded_size (type)), \
*((type *) (void *) ((char *) (ap) - __va_rounded_size (type))))
#else
typedef __builtin_va_list __gnuc_va_list;
typedef __gnuc_va_list va_list;
#define va_start(v,l) __builtin_va_start(v,l)
#define va_end(v) __builtin_va_end(v)
#define va_arg(v,l) __builtin_va_arg(v,l)
#endif
#endif #endif
#define SECTION(x) __attribute__((section(x))) #define SECTION(x) __attribute__((section(x)))
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册