In the system include file <iomacros. h> there are several recursive
definitions:
#define critical __attribute__ ((critical))
#define reentrant __attribute__ ((reentrant))
#define saveprologue __attribute__ ((saveprologue))
These cause problems as shown in the source file attbug.c:
**************************************************************************************
// ATTBUG.C demonstrates recursive definition bugs
#include <iomacros.h>
int a ( int x ) __attribute__ ((naked));
int a ( int x )
{
return( x + 1 );
}
int b ( int x ) __attribute__ ((critical));
int b ( int x )
{
return( x + 1 );
}
int c ( int x ) __attribute__ ((reentrant));
int c ( int x )
{
return( x + 1 );
}
int main()
{
int x = 1;
x = a(x) + b(x) + c(x);
return(x);
}
**************************************************************************************
Preprocessing with
msp430-gcc -E attbug.c > attbug.i
gives:
**************************************************************************************
# 1 "attbug.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "attbug.c"
# 1 "/usr/msp430/include/iomacros.h" 1 3
# 35 "/usr/msp430/include/iomacros.h" 3
# 1 "/usr/msp430/include/sys/inttypes.h" 1 3
# 38 "/usr/msp430/include/sys/inttypes.h" 3
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef int int16_t;
typedef unsigned int uint16_t;
typedef long int32_t;
typedef unsigned long uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
typedef int16_t intptr_t;
typedef uint16_t uintptr_t;
# 36 "/usr/msp430/include/iomacros.h" 2 3
# 4 "attbug.c" 2
int a ( int x ) __attribute__ ((naked));
int a ( int x )
{
return( x + 1 );
}
int b ( int x ) __attribute__ ((__attribute__ ((critical))));
int b ( int x )
{
return( x + 1 );
}
int c ( int x ) __attribute__ ((__attribute__ ((reentrant))));
int c ( int x )
{
return( x + 1 );
}
int main()
{
int x = 1;
x = a(x) + b(x) + c(x);
return(x);
}
**************************************************************************************
The compiler correctly rejects the recursively-expanded definitions, giving
error mesages which are correct ,but somwhat opaque if you have not seen the
preprocessed file:
$ msp430-gcc attbug.c
attbug.c:13: syntax error before "__attribute__"
attbug.c:13: syntax error before ')' token
attbug.c:21: syntax error before "__attribute__"
attbug.c:21: syntax error before ')' token
This makes it impossible to use the critical, reentrant, and saveprologue
attributes. I put in the naked attribute merely to show that other
attributes defined for the msp430 preprocess and compile correctly.
System is Gentoo Linux:
r...@triffid attbug $ uname -a
Linux triffid 2.6.10 #3 Wed Jan 19 16:52:47 MST 2005 i686 AMD Athlon(tm)
Processor AuthenticAMD GNU/Linux
mspgcc tools rebuilt today using the ebuild at:
http://www.dotat.dk/ebuilds/
which takes current sources from cvs, and the merge command:
emerge msp430-binutils msp430-gcc msp430-libc msp430-tools.
Several earlier versions on other machines have the same definitions in
<iomacros.h>.
All the best,
rick
--
Rick Jenkins <[email protected]>
Hartman Technica http://www.hartmantech.com
Phone +1 (403) 230-1987 voice & fax
221 35 Avenue. N.E., Calgary, Alberta, Canada T2E 2K5