Re: static class member as interrupt handler works, but not if class is templated
Matthijs Kooijman <[email protected]> Mon, 12 Apr 2021 13:53:38 +0200
| Newsgroups | gmane.comp.gcc.help,gmane.comp.hardware.avr.gcc |
|---|---|
| Message-ID | <[email protected]> |
> > - figure out, where the special handling of the __vector_10 seems to > > happen, and why it is not happening in the class template case. This > > might help diagnose if and where to fix it within the compiler. > > That is compiler internals... yes, if it is a compiler bug, it is the > way to have a solution. But in that case, it seems to be a generic > problem for gcc as attributes are not assigned to any templated class > member functions. No idea if this is related to the target ( avr ) or > generic for all platforms. But I never did any change inside the > compiler. Any help is welcome! My suspiciou would be that this is a generic gcc problem, where the "asm" attribute is not honoured for template functions. It probably also makes some sense, since a template is intended to be instantiated multiple times, and each instantiation gets a name that is generated based on (I believe) the template arguments passed, so I suspect that the "generate a name for this template instantiation" code doesn't look at the asm attribute. Also note that *if* it would, then each instantiation would use the same name and multiple instanations would result in duplicate symbols. If you would bring this up as a gcc bug, I wouldn't be surprised that it would be closed as wontfix for this reason. Another workaround that I think hasn't been suggested yet, would be to just define a global `__vector_10` function and from that just call your templated static member. Combined with the `always_inline` attribute, you can ensure that the call is inlined and there is no runtime overhead (with LTO, this probably already happens when there's just a single call to the member). Maybe not as nice and self-contained as the asm attribute, but it does allow multiple instantiations (where the global function defines which instantiation is going to be used for the ISR). Gr. Matthijs
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEMyF3AetYrDfGJ9el6ZMxy91tJYwFAmB0NLwACgkQ6ZMxy91t JYy4DxAA0MLNypdQpbz+Uy86BWICE/Y30LtLQO+2OA4sa8m6uOIwVCXSL/Q68DZ0 qrkK3QhrMurhb0bbSPuiAlpgtgkWraithqdUWH9lXWr8InewfjHEa+pYUd6P3DgA oFlFAvvb8R6x7nT2SyfAJ7PSnbyS39AWHLTdUibW2UC8+syajTW0f7zip2c1HgEW pvxvixyHblFxSEdcYMKg5Mq2HPup20jXgsQElf3OvQOTLVoBHVD8A30vOZV5A3v3 Vxl0Q4ifOQ+Xyj7NE8NZridTznJO82yAUfs13p/gyfsSvGfWkC4xbjyKBrD/2D2B r1wyxWYWDj/8UgP2pbWeaTFfNk+tj5bV/QJEUPI1cNIigD8rdT4+dXo9KIANJ4CA 0MuEyytT7R9tOGx6VGFqdh4nmM1tPhbZYWh0dJZj8EF/CzMnwJn2IF+iIfM/0EJs gPdY8H9GddkMg5u7p+qrXcWcc+34mybcQ1dEQrJvi3/mCoYHHKF05AL1VyJc41yX c0CbuXuXBBQtg02d4dYPEbZRvvglsPdMoz3wMZ9ay5E9pEnB4G3Y2+lWBrO8LDU5 1Niu2yWaoxEWZ/TrceH6gYKqu3eDXbMDP8f10vR5X2+tgVd850ExpLcM+4sWFcXF s8EOsudE+vdTleJnEq8eiPTP+ajByf9LYfo/uAm8IsnggDupMkI= =0qJz -----END PGP SIGNATURE-----