Hot!XC8 Reentrant and non Reentrant function specifiers

Author
eduardobrl10
New Member
  • Total Posts : 1
  • Reward points : 0
  • Joined: 2017/08/14 14:36:21
  • Location: 0
  • Status: offline
2018/04/17 07:58:22 (permalink)
0

XC8 Reentrant and non Reentrant function specifiers

Hi, i'm using xc8 in compiled stack mode and i have functions that are called by main and interruptions. As a consequence the compiler duplicate those functions.
 
But i don't want some functions to be duplicated, because i'am sure that they don't will be called inside the main and the interrupts routines at the same time. But i don't find a way to do that.
 
I tried to use the function identifier "__reentrant" (Section 5.8.1.3 of the XC8 C Compiler User’s Guide), but they are not recognize by the compiler. Anyone know how can i fix this problem ?
 
I am using XC8 (v1.45)
#1

6 Replies Related Threads

    du00000001
    Just Some Member
    • Total Posts : 2019
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: XC8 Reentrant and non Reentrant function specifiers 2018/04/17 12:46:35 (permalink)
    0
    You haven't got the point:
    "compiled stack" results in the function accessing fixed locations for the parameters passed - or even accessing the "original" variable if there is only a single call to a function within the context. Thus ...
    (Contrary to marketing, compilers are not really "omniscient".)

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #2
    qɥb
    Monolothic Member
    • Total Posts : 3264
    • Reward points : 0
    • Joined: 2017/09/09 05:07:30
    • Location: Jupiter
    • Status: offline
    Re: XC8 Reentrant and non Reentrant function specifiers 2018/04/17 13:43:57 (permalink)
    0
    Funnily enough, the XC8 User Guide tells you exactly what to do.
    See: "5.9.7.1 DISABLING DUPLICATION"
     

    This forum is mis-configured so it only works correctly if you access it via https protocol.
    The Microchip website links to it using http protocol. Will they ever catch on?
    PicForum "it just works"
    #3
    jack@kksound
    code tags!
    • Total Posts : 2690
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: XC8 Reentrant and non Reentrant function specifiers 2018/04/17 13:59:07 (permalink)
    0
    Also since you did not specifiy the pic processor you are using, possibly this (from the XC8 User Guide) explains your results:
    The reentrant specifier only has an effect if the target device supports a software stack. In addition, not all functions allow reentrancy. Interrupt functions must always use the compiled stack, but functions they call may use the software stack. Functions encoded for baseline and mid-range devices always use the non-reentrant model and the compiled stack.

    #4
    mad_c
    Super Member
    • Total Posts : 1091
    • Reward points : 0
    • Joined: 2010/12/12 17:48:27
    • Location: Brisbane, Australia
    • Status: offline
    Re: XC8 Reentrant and non Reentrant function specifiers 2018/04/17 14:02:07 (permalink)
    +5 (5)
    eduardobrl10
    But i don't want some functions to be duplicated, because i'am sure that they don't will be called inside the main and the interrupts routines at the same time. But i don't find a way to do that.

    Hi,
     
    You have several options. You can select the hybrid stack model, which will, instead of duplicating the functions, make them use the software stack so that they are reentrant. You can perform the above manually by using the reentrant keywords with each function; or you can ask the compiler to ignore the potential reentrancy issue by using the interrupt_level pragma to prevent them from being duplicated. All of these are described in the User's Guide.
     
    Jeff.
     
    #5
    du00000001
    Just Some Member
    • Total Posts : 2019
    • Reward points : 0
    • Joined: 2016/05/03 13:52:42
    • Location: Germany
    • Status: offline
    Re: XC8 Reentrant and non Reentrant function specifiers 2018/04/17 14:14:20 (permalink)
    +1 (1)
    And don't forget: RTFM!

    PEBKAC / EBKAC / POBCAK / PICNIC (eventually see en.wikipedia.org)
    #6
    mlp
    boots too small
    • Total Posts : 575
    • Reward points : 0
    • Joined: 2012/09/10 15:12:07
    • Location: previously Microchip XC8 team
    • Status: offline
    Re: XC8 Reentrant and non Reentrant function specifiers 2018/04/18 15:35:02 (permalink)
    +3 (3)
    du00000001
    And don't forget: RTFM!



    Jeff puts a lot of work into maintaining the Friendly Manual - I'm astounded at his patience when people ignore it.

    Mark (this opinion available for hire)
    #7
    Jump to:
    © 2018 APG vNext Commercial Version 4.5