Re: static class member as interrupt handler works, but not if class is templated

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

 



In C++ for interrupt vectors in drivers I set up an array of pointers to
function all the peripheral driver code  like this for timer counters.

static voidCallback_t _isr_funcs[TC_INST_NUM]={NULL};

Then in each handler if the pointer is not null I call it.  This is a lot
of work and overhead but it works.

On Sun, Apr 11, 2021 at 8:21 AM David Brown <david.brown@xxxxxxxxxxxx>
wrote:

> On 10/04/2021 22:11, Klaus via Gcc-help wrote:
> > Hi,
> >
> >
> >
> > Am 10.04.21 um 17:26 schrieb Jonathan Wakely:
> >
> >>
> >>     Dummy<1> d1;
> >>
> >>
> >> This doesn't cause the instantiation of the member function.
> >>
> >> Have you tried an explicit instantiation?
> >>
> >> template class Dummy<1>;
> >
> > Did not change anything.
> >
> > If I use my original code, I get the instantiation of the function:
> >
> > 0000007e <Dummy<1>::Handler()>:
> >   7e:    18 95           reti
> >
> > But it is simply not named as "__vector_10" which is the problem. The
> > member function is instantiated but still with wrong name even with my
> > or your code.
> >
> > Klaus
> >
> >
>
> To my knowledge, there isn't a better way than to make specific
> dedicated stand-alone functions:
>
> static void Handler_1() __asm__("__vector_10")
> __attribute__((__signal__, __used__, __externally_visibile__))
> {
>         Dummy<1>::Handler();
> }
>
> For device drivers like that, you have a specific number of
> instantiations that match the number of peripherals on the particular
> microcontroller.  And they each have different vectors.  There really
> isn't any other better way, to my knowledge.  (You can use a bit of
> pre-processing macros and conditional compilation to automate it a bit,
> generating as many of these functions as there are UARTs or whatever
> defined in the device header files for the microcontroller.)
>
>



[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