RE: Mangle functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Undefined means that this situation is not specified by the standard.  
> The compiler is free to assume that this points to a valid instance and to
> do what it wants with it.  So if you ever switch to another compiler or
the > gcc folks decide for whatever reason to do something fancy in methods,
you > are lost. This is not very likely, but nevertheless an avoidable risk.
For > principle reasons such risks should be avoided.

Except that this is only required if the method needs to implicitly access
either the class's data or other class methods - not the case with the
interrupt handlers being discussed here. But I concede that whether a this
is provided by the compiler when the "signal" attribute is used is compiler
specific, sometimes even context specific. As we agree - use "static".

> > Yes, this is almost working. In the avr-gcc case, a plethora of
> > processors
> > have much the same peripherals and the compiler managers have rightly
> > standardized on common names for common peripherals, with the
> > translation to
> > the correct vector done via processor specific macros. My last
> > problem looks
> > like it should be easy but I have run out of ideas. It is in the
> > method
> > declaration. For example:
> >
> > static void MyOverflowInterrupt(void) asm(TIMER0_OVF_vect)
> >                 __attribute__ ((signal, __INTR_ATTRS));
> >
> > Somewhere in the device header for a particular processor is the
> line:
> >
> > #define TIMER0_OVF_vect      _VECTOR(16)
> >
> > And elsewhere is defined:
> >
> > #define _VECTOR(N)  __vector_ ## N
> >
> > So the definition becomes the almost correct:
> >
> > static void MyOverflowInterrupt(void) asm(__vector_16)
> >                 __attribute__ ((signal, __INTR_ATTRS));
> >
> > How do I get it to be:
> >
> > static void MyOverflowInterrupt(void) asm("__vector_16")
> >                 __attribute__ ((signal, __INTR_ATTRS));
> 
> Oh, this one is actually easy :-)
> 
> You just need another macro-indirection that uses the "stringify"
> operator (#) of the pre-processor:
> 
>  >>>>
> lohmann@mocca:~/tmp$ cat test.cpp
> #define TIMER0_OVF_vect      _VECTOR(16)
> #define _VECTOR(N)  __vector_ ## N
> 
> #define IRQ_VECTOR(vec) asm(#vec) __attribute__ ((signal,
> __INTR_ATTRS))
> 
> class Timer0 {
>    static void MyOverflowInterrupt(void) IRQ_VECTOR(TIMER0_OVF_vect);
> };
> <<<<
> 
> After pre-processing this becomes:
> 
>  >>>>
> lohmann@mocca:~/tmp$ g++ -E test.cpp
> 
> class Timer0 {
>    static void MyOverflowInterrupt(void) asm("TIMER0_OVF_vect")
> __attribute__ ((signal, __INTR_ATTRS));
> };
> <<<<
> 
> Daniel
> 
> P.S. Answers to to the list, please. Other readers might  be
> interested and contribute as well.

Sorry, I was not too clear here. The user does not really know the vector
number, only the "TIMER_OVF_vect" name. So the user definition:

static void MyOverflowInterrupt(void) asm(TIMER0_OVF_vect) 
                 __attribute__ ((signal, __INTR_ATTRS));

must end up after macro substitution being presented to the compiler like:

static void MyOverflowInterrupt(void) asm("__vector_16") 
                 __attribute__ ((signal, __INTR_ATTRS));

Perhaps not quite so easy :-(
Ron







E-mail message checked by Spyware Doctor (5.5.0.178)
Database version: 5.09090
http://www.pctools.com/spyware-doctor/

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux