Re: Use weak functions in the RTEMS core?

2020-04-14 Thread Gedare Bloom
On Mon, Apr 13, 2020 at 11:48 PM Sebastian Huber wrote: > > On 09/04/2020 17:25, Gedare Bloom wrote: > > > On Wed, Apr 8, 2020 at 10:53 PM Sebastian Huber > > wrote: > >> On 09/04/2020 03:32, Chris Johns wrote: > >> > >>> On 2020-04-09 03:43, Sebastian Huber wrote: > On 08/04/2020 19:34, Jon

Re: Use weak functions in the RTEMS core?

2020-04-13 Thread Sebastian Huber
On 09/04/2020 17:25, Gedare Bloom wrote: On Wed, Apr 8, 2020 at 10:53 PM Sebastian Huber wrote: On 09/04/2020 03:32, Chris Johns wrote: On 2020-04-09 03:43, Sebastian Huber wrote: On 08/04/2020 19:34, Jonathan Brandmeyer wrote: Instead of treating weak references as a single level of indir

Re: Use weak functions in the RTEMS core?

2020-04-09 Thread Jonathan Brandmeyer
On Thu, Apr 9, 2020 at 9:25 AM Gedare Bloom wrote: > On Wed, Apr 8, 2020 at 10:53 PM Sebastian Huber > wrote: > > > > On 09/04/2020 03:32, Chris Johns wrote: > > > > > On 2020-04-09 03:43, Sebastian Huber wrote: > > >> On 08/04/2020 19:34, Jonathan Brandmeyer wrote: > > >>> Instead of treating w

Re: Use weak functions in the RTEMS core?

2020-04-09 Thread Gedare Bloom
On Wed, Apr 8, 2020 at 10:53 PM Sebastian Huber wrote: > > On 09/04/2020 03:32, Chris Johns wrote: > > > On 2020-04-09 03:43, Sebastian Huber wrote: > >> On 08/04/2020 19:34, Jonathan Brandmeyer wrote: > >>> Instead of treating weak references as a single level of > >>> indirection, I think you ha

Re: Use weak functions in the RTEMS core?

2020-04-08 Thread Sebastian Huber
On 09/04/2020 03:32, Chris Johns wrote: On 2020-04-09 03:43, Sebastian Huber wrote: On 08/04/2020 19:34, Jonathan Brandmeyer wrote: Instead of treating weak references as a single level of indirection, I think you have to treat them as a single overridable interface.  In a dynamically-linked

Re: Use weak functions in the RTEMS core?

2020-04-08 Thread Chris Johns
On 2020-04-09 03:43, Sebastian Huber wrote: On 08/04/2020 19:34, Jonathan Brandmeyer wrote: Instead of treating weak references as a single level of indirection, I think you have to treat them as a single overridable interface.  In a dynamically-linked application, we might try to perform an ov

Re: Use weak functions in the RTEMS core?

2020-04-08 Thread Sebastian Huber
On 08/04/2020 19:34, Jonathan Brandmeyer wrote: If you encounter problems like this, then weak functions are used for the wrong thing. Exhibit A: zynq_setup_mmu_and_cache.  It is referred to only by the BSP's startup sequence.  So it is a reference from librtemsbsp to librtemsbsp by

Re: Use weak functions in the RTEMS core?

2020-04-08 Thread Jonathan Brandmeyer
On Wed, Apr 8, 2020 at 10:30 AM Sebastian Huber < sebastian.hu...@embedded-brains.de> wrote: > On 08/04/2020 17:57, Jonathan Brandmeyer wrote: > > > There are a couple more disadvantages. > > > > Which definition is pulled into the final link depends on the order > > that the object files are list

Re: Use weak functions in the RTEMS core?

2020-04-08 Thread Sebastian Huber
On 08/04/2020 17:57, Jonathan Brandmeyer wrote: There are a couple more disadvantages. Which definition is pulled into the final link depends on the order that the object files are listed on the command-line.  If the weak one is seen first, then the linker will resolve the symbol against the

Re: Use weak functions in the RTEMS core?

2020-04-08 Thread Jonathan Brandmeyer
There are a couple more disadvantages. Which definition is pulled into the final link depends on the order that the object files are listed on the command-line. If the weak one is seen first, then the linker will resolve the symbol against the weak definition and it won't even search into subsequ

Re: Use weak functions in the RTEMS core?

2020-04-08 Thread Sebastian Huber
Hello, another use case for a weak function could be the heap. If you only allocate memory and never free it, then the implementation can be very simple: https://git.rtems.org/rtems/tree/cpukit/score/src/memoryallocate.c#n49 We could use something like this in heapallocate.c: RTEMS_WEAK voi

Re: Use weak functions in the RTEMS core?

2020-04-08 Thread Sebastian Huber
On 08/04/2020 14:06, Andrew Butterfield wrote:  from my perspective as part of the qualification effort I suspect that weak functions are easier to reason about and verify than global pointers? Is my suspicion reasonable - I am more familiar with pointers (global or otherwise) than I am with h

Re: Use weak functions in the RTEMS core?

2020-04-08 Thread Sebastian Huber
On 08/04/2020 10:16, Sebastian Huber wrote: Hello, weak functions are already used in several places in RTEMS, but not in RTEMS core components. In we have currently only a RTEMS_WEAK_ALIAS() macro: testsuites/sptests/spmisc01/init.c:int weak_alias_func(void) RTEMS_WEAK_ALIAS(noinline_fun

Use weak functions in the RTEMS core?

2020-04-08 Thread Sebastian Huber
Hello, weak functions are already used in several places in RTEMS, but not in RTEMS core components. In we have currently only a RTEMS_WEAK_ALIAS() macro: testsuites/sptests/spmisc01/init.c:int weak_alias_func(void) RTEMS_WEAK_ALIAS(noinline_func); cpukit/libfs/src/defaults/default_mmap.c:)