003-09-17 Theodore A. Roth * include/inttypes.h: Add note about -mint8 patch for gcc to change the size of long long from 64 bits to 32 bits. * include/avr/pgmspace.h: Replace prog_int with prog_int16_t. Replace prog_long with prog_int32_t. Replace prog_long_long with prog_int64_t. Add typedefs for prog_uint16_t, prog_uint32_t and prog_uint64_t. Only define pgm_read_byte_far or pgm_read_word_far if RAMPZ is defined and __USING_MINT8 is not defined. Index: include/inttypes.h =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/include/inttypes.h,v retrieving revision 1.5 diff -u -p -r1.5 inttypes.h --- include/inttypes.h 17 Dec 2002 22:02:27 -0000 1.5 +++ include/inttypes.h 17 Sep 2003 22:45:28 -0000 @@ -44,7 +44,14 @@ over rolling your own typedefs. \note If avr-gcc's \c -mint8 option is used, no 32-bit types will be - available. */ + available. + + \todo There is a pending patch that may go into gcc to change the + behaviour of the -mint8 option. The current (2003-09-17) situation for + -mint8 is sizeof(int) == 1, sizeof(long) == 2 and sizeof(long long) == 8. + Note the absence of a 4-byte, 32-bit type. The patch proposes to change + sozeof(long long) to be 4 bytes (32 bits). When and if the patch is + included in gcc, we will need to change avr-libc accordingly. */ #if __INT_MAX__ == 127 # define __USING_MINT8 1 Index: include/avr/pgmspace.h =================================================================== RCS file: /cvsroot/avr-libc/avr-libc/include/avr/pgmspace.h,v retrieving revision 1.17 diff -u -p -r1.17 pgmspace.h --- include/avr/pgmspace.h 17 Sep 2003 17:49:33 -0000 1.17 +++ include/avr/pgmspace.h 17 Sep 2003 22:45:28 -0000 @@ -89,9 +89,15 @@ extern "C" { typedef void prog_void PROGMEM; typedef char prog_char PROGMEM; typedef unsigned char prog_uchar PROGMEM; -typedef int prog_int PROGMEM; -typedef long prog_long PROGMEM; -typedef long long prog_long_long PROGMEM; + +typedef int16_t prog_int16_t PROGMEM; +typedef uint16_t prog_uint16_t PROGMEM; +#if !defined(__USING_MINT8) +typedef int32_t prog_int32_t PROGMEM; +typedef uint32_t prog_uint32_t PROGMEM; +#endif +typedef int64_t prog_int64_t PROGMEM; +typedef uint64_t prog_uint64_t PROGMEM; /** \ingroup avr_pgmspace \def PSTR(s) @@ -184,10 +190,13 @@ typedef long long prog_long_long PROGMEM #define pgm_read_word_near(address_short) __LPM_word((uint16_t)(address_short)) -#ifdef RAMPZ /* >64K program memory (ATmega103, ATmega128) */ +#if defined(RAMPZ) && !defined(__USING_MINT8) /* Only for devices with more than 64K of program memory. - RAMPZ must be defined (see iom103.h, iom128.h). */ + RAMPZ must be defined (see iom103.h, iom128.h). + + These can not be defined if the user is compiling with the -mint8 option + since (u)int32_t is not defined in that case. */ /* The classic functions are needed for ATmega103. */ @@ -278,10 +287,6 @@ typedef long long prog_long_long PROGMEM #define __ELPM_word(addr) __ELPM_word_classic__(addr) #endif -#endif - -#ifdef RAMPZ - /** \ingroup avr_pgmspace \def pgm_read_byte_far(address_long) Read a byte from the program space with a 32-bit (far) address. @@ -289,7 +294,7 @@ typedef long long prog_long_long PROGMEM \note The address is a byte address. The address is in the program space. */ -#define pgm_read_byte_far(address_long) __ELPM((unsigned long)(address_long)) +#define pgm_read_byte_far(address_long) __ELPM((uint32_t)(address_long)) /** \ingroup avr_pgmspace \def pgm_read_word_far(address_long) @@ -298,14 +303,9 @@ typedef long long prog_long_long PROGMEM \note The address is a byte address. The address is in the program space. */ -#define pgm_read_word_far(address_long) __ELPM_word((unsigned long)(address_long)) - -#else +#define pgm_read_word_far(address_long) __ELPM_word((uint32_t)(address_long)) -#define pgm_read_byte_far(address_long) pgm_read_byte_near(address_long) -#define pgm_read_word_far(address_long) pgm_read_word_near(address_long) - -#endif +#endif /* RAMPZ and ! __USING_MINT8 */ /** \ingroup avr_pgmspace \def pgm_read_byte(address_short)