It both reduces flash size and move symbols to read-only sections.
The scheduler_tasks table is one known not to be in read-only section before due
to the FastDelegate implementation. Before and after this patch:
ArduPlane $ size ArduPlane.elf{.old,}
text data bss dec hex filename
733368 8252 67352 808972 c580c ArduPlane.elf.old
730632 8236 64792 803660 c434c ArduPlane.elf
ArduPlane $ nm -C ArduPlane.elf.old|grep scheduler_tasks
0000000000402800 t _GLOBAL__sub_I__ZN5Plane15scheduler_tasksE
00000000006b54c0 B Plane::scheduler_tasks
ArduPlane $ nm -C ArduPlane.elf|grep scheduler_tasks
0000000000490900 R Plane::scheduler_tasks
As can be seen above, now the scheduler_tasks symbol is in a read-only data
section and in all of them we decreased the total size.
For APM2 we have a little increase in the text size size.
ArduPlane $ size ArduPlane.elf{.old,}
text data bss dec hex filename
241940 942 4447 247329 3c621 ArduPlane.elf.old
242222 942 4431 247595 3c72b ArduPlane.elf
ArduPlane $ nm -C ArduPlane.elf.old|grep scheduler_tasks
00001f8f T Plane::scheduler_tasks
ArduPlane $ nm -C ArduPlane.elf|grep scheduler_tasks
00001f8f T Plane::scheduler_tasks
It both reduces flash size and move symbols to read-only sections.
The scheduler_tasks table is one known not to be in read-only section before due
to the FastDelegate implementation. Before and after this patch:
APMrover2 $ size APMrover2.elf{.old,}
text data bss dec hex filename
611406 4832 40920 657158 a0706 APMrover2.elf.old
609686 4824 38936 653446 9f886 APMrover2.elf
APMrover2 $ nm -C APMrover2.elf{.old,} |grep tasks
0000000000696f80 B Rover::scheduler_tasks
000000000047c440 R Rover::scheduler_tasks
As can be seen above, now the scheduler_tasks symbol is in a read-only data
section and in all of them we decreased the total size.
For APM2 we have a similar situation, but the table was already in text section
because it was using plain C pointers:
APMrover2 $ size APMrover2.elf{.old,}
text data bss dec hex filename
189518 1038 3494 194050 2f602 APMrover2.elf.old
189216 1038 3480 193734 2f4c6 APMrover2.elf
APMrover2 $ nm -C APMrover2.elf{.old,} |grep tasks
00001f92 T Rover::scheduler_tasks
00001f8a T Rover::scheduler_tasks
Now that we are using C++11 we can use variadic templates to simplify
the FastDelegate classes. It also simplifies moving away from the
FastDelegate implementation.
Start to add code behind APM_BUILD_FUNCTOR to support changing the
functor implementation (without breaking the build while the change is
not complete).
This is a Functor implementation that should cover the use cases we have
for FastDelegate. In contrary to the latter, it can be constructed at
compile time so the compiler can safely put it in a read-only section
which covers the cases in which we are not using it.
Use the simpler "if (delegate_name)" since it allows simpler
implementation in the class, i.e. the bool operator rather than having
to compare to another object.
Use the simpler "if (delegate_name)" since it allows simpler
implementation in the class, i.e. the bool operator rather than having
to compare to another object.
Use the simpler "if (delegate_name)" since it allows simpler
implementation in the class, i.e. the bool operator rather than having
to compare to another object.