X-Git-Url: https://codewiz.org/gitweb?a=blobdiff_plain;f=compiler.h;h=3f2d84848f06c5e94a2e36d7f0e6e3e9d2f050f4;hb=556c951f52f7333fb4bc072b2d2626bb5037c280;hp=638473283a80baf34fbdc473dcf607f160fa55a4;hpb=43bbf2d226d7313b8fd075c07f1d2a50da476e6b;p=bertos.git diff --git a/compiler.h b/compiler.h index 63847328..3f2d8484 100755 --- a/compiler.h +++ b/compiler.h @@ -14,6 +14,18 @@ /*#* *#* $Log$ + *#* Revision 1.41 2005/01/22 04:19:22 bernie + *#* MTIME_INFINITE: New constant. + *#* + *#* Revision 1.40 2005/01/20 18:46:04 aleph + *#* Add progmem datatypes; PSTR() definition. + *#* + *#* Revision 1.39 2005/01/08 08:49:39 bernie + *#* Define PROGMEM on AVR only when not including pgmspace.h. + *#* + *#* Revision 1.38 2004/12/31 16:41:52 bernie + *#* PROGMEM: Define to nothing for non-Harvard processors. + *#* *#* Revision 1.37 2004/12/08 09:43:21 bernie *#* Metrowerks supports variadic macros. *#* @@ -150,7 +162,8 @@ #define REGISTER shortad #define INLINE /* unsupported */ - /* Imported from . Unfortunately, we can't just include + /* + * Imported from . Unfortunately, we can't just include * this header because it typedefs jmp_buf to be an array of chars. * This would allow the compiler to place the buffer on an odd address. * The CPU _should_ be able to perform word accesses to @@ -168,9 +181,9 @@ */ struct _JMP_BUF { - void * sp; /* Stack pointer */ - void * return_addr; /* Return address */ - int lr[6]; /* 6 local registers */ + void *sp; /* Stack pointer */ + void *return_addr; /* Return address */ + int lr[6]; /* 6 local registers */ }; typedef struct _JMP_BUF jmp_buf[1]; @@ -190,10 +203,10 @@ /* FIXME: I can't remember why exactly this was needed (NdBernie) */ #define float double - /* Fake bool support */ + /* MSVC doesn't provide . */ #ifndef __cplusplus - #define true 1 - #define false 0 + #define true (1==1) + #define false (1!=1) typedef int bool; #endif /* !__cplusplus */ @@ -240,9 +253,14 @@ /* Support for harvard architectures */ #ifdef _PROGMEM + #include #define PGM_READ_CHAR(s) pgm_read_byte(s) #define PGM_FUNC(x) x ## _P #define PGM_ATTR PROGMEM + #else + /* We still need this for prototypes */ + #define PROGMEM __attribute__((__progmem__)) + #define PSTR(s) ({static char __c[] PROGMEM = (s); __c;}) #endif #endif @@ -265,6 +283,8 @@ #define COMPILER_TYPEOF 1 #define COMPILER_STATEMENT_EXPRESSIONS 1 + #define typeof __typeof__ + #include #include #include @@ -330,6 +350,9 @@ #ifndef REGISTER #define REGISTER /* nothing */ #endif +#ifndef PROGMEM +#define PROGMEM /* nothing */ +#endif #ifndef INTERRUPT #define INTERRUPT(x) ERROR_NOT_IMPLEMENTED #endif @@ -372,7 +395,6 @@ #define PGM_ATTR /* nothing */ #endif - /* Misc definitions */ #ifndef NULL #define NULL (void *)0 @@ -416,6 +438,17 @@ #include #endif +/*! + * \name Types for variables stored in program memory (harvard processors). + * \{ + */ +typedef PROGMEM int8_t pgm_int8_t; +typedef PROGMEM uint8_t pgm_uint8_t; +typedef PROGMEM int16_t pgm_int16_t; +typedef PROGMEM uint16_t pgm_uint16_t; +typedef PROGMEM int32_t pgm_int32_t; +typedef PROGMEM uint32_t pgm_uint32_t; +/*\}*/ #if CPU_AVR_ATMEGA8 /* @@ -426,11 +459,13 @@ typedef int16_t utime_t; /*!< Type for time expressed in microseconds. */ #define SIZEOF_MTIME_T (16 / CPU_BITS_PER_CHAR) #define SIZEOF_UTIME_T (16 / CPU_BITS_PER_CHAR) + #define MTIME_INFINITE 0x7FFFL #else typedef int32_t mtime_t; /*!< Type for time expressed in milliseconds. */ typedef int32_t utime_t; /*!< Type for time expressed in microseconds. */ #define SIZEOF_MTIME_T (32 / CPU_BITS_PER_CHAR) #define SIZEOF_UTIME_T (32 / CPU_BITS_PER_CHAR) + #define MTIME_INFINITE 0x7FFFFFFFL #endif /*! Bulk storage large enough for both pointers or integers. */