X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=compiler.h;h=dfb32207f20cec9d4967a801189f507470b5e41e;hb=a5175fd44dd7528960b1216182afb4fe96c4664e;hp=bf96ecb57d014ee6068de798094643ba5d2cefa6;hpb=b81657391042e045769c544cf749f2f382d6e9a5;p=bertos.git diff --git a/compiler.h b/compiler.h index bf96ecb5..dfb32207 100755 --- a/compiler.h +++ b/compiler.h @@ -3,7 +3,7 @@ * * * \version $Id$ @@ -15,6 +15,17 @@ /* * $Log$ + * Revision 1.4 2004/06/27 15:20:26 aleph + * Change UNUSED() macro to accept two arguments: type and name; + * Add macro GNUC_PREREQ to detect GCC version during build; + * Some spacing cleanups and typo fix + * + * Revision 1.3 2004/06/06 18:00:39 bernie + * PP_CAT(): New macro. + * + * Revision 1.2 2004/06/03 11:27:09 bernie + * Add dual-license information. + * * Revision 1.1 2004/05/23 17:48:35 bernie * Add top-level files. * @@ -24,6 +35,15 @@ #include "arch_config.h" + +#if defined __GNUC__ && defined __GNUC_MINOR__ + #define GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else + #define GNUC_PREREQ(maj, min) 0 +#endif + + #if defined(__IAR_SYSTEMS_ICC) || defined(__IAR_SYSTEMS_ICC__) #pragma language=extended #define INTERRUPT(x) interrupt [x] @@ -33,7 +53,7 @@ /* GCC attributes */ #define FORMAT(type,fmt,first) /* nothing */ #define NORETURN /* nothing */ - #define UNUSED(arg) arg + #define UNUSED(type,arg) type arg /* Imported from . Unfortunately, we can't just include * this header because it typedefs jmp_buf to be an array of chars. @@ -81,7 +101,7 @@ /* GCC attributes */ #define FORMAT(type,fmt,first) /* nothing */ #define NORETURN /* nothing */ - #define UNUSED(arg) arg + #define UNUSED(type,arg) type arg #define INLINE static inline #ifdef __cplusplus @@ -106,7 +126,7 @@ /* GCC attributes */ #define FORMAT(type,fmt,first) __attribute__((__format__(type, fmt, first))) #define NORETURN __attribute__((__noreturn__)) - #define UNUSED(arg) __attribute__((__unused__)) arg + #define UNUSED(type,arg) __attribute__((__unused__)) type arg //FIXME #define INLINE static inline #define INLINE extern inline @@ -135,15 +155,17 @@ #include #include #define FLASH __attribute__((progmem)) - #define REGISTER /* nothing */ + #define REGISTER /* nothing */ /* Missing printf-family functions in avr-libc/stdio.h */ #include #include - int vsprintf(char *buf, const char *fmt, va_list ap); + #if !GNUC_PREREQ(3,4) + int vsprintf(char *buf, const char *fmt, va_list ap); + #endif int vsprintf_P(char *buf, const char * PROGMEM fmt, va_list ap); - /* Support for hardvard architectures */ + /* Support for harvard architectures */ #ifdef _PROGMEM #define PGM_READ_CHAR(s) pgm_read_byte(s) #define PGM_FUNC(x) x ## _P @@ -173,9 +195,9 @@ /* GCC attributes */ #define FORMAT(type,fmt,first) /* nothing */ #define NORETURN /* nothing */ - #define UNUSED(arg) arg + #define UNUSED(type,arg) type arg - /* Support for hardvard architectures */ + /* Support for harvard architectures */ #define PGM_READ_CHAR(s) (*(s)) #define PGM_FUNC /* nothing */ #define PGM_ATTR /* nothing */ @@ -238,6 +260,10 @@ #define UINT32_LOG2(x) \ ((x < 65536UL) ? UINT16_LOG2(x) : UINT16_LOG2((x) >> 16) + 16) +/*! Concatenate two different preprocessor tokens (allowing macros to expand) */ +#define PP_CAT(x,y) PP_CAT__(x,y) +#define PP_CAT__(x,y) x ## y + /* Type definitions - should go in */ #if !(defined(size_t) || defined(_SIZE_T_DEFINED)) #define size_t unsigned int