I'm just reading through a header files for task code in ESP8266 SDK.

I found this line and wondering what does the word PRIVILEGED_FUNCTION after the function arguments braces means ?

void vTaskDelay( const TickType_t xTicksToDelay ) PRIVILEGED_FUNCTION;

PRIVILEGED_FUNCTION is defined here, but why it's used after the function braces ?

/* Ensure API functions go in the privileged execution section. */
#define PRIVILEGED_FUNCTION __attribute__((section("privileged_functions")))
#define PRIVILEGED_DATA __attribute__((section("privileged_data")))

That's impossible to tell without looking in the source code for that SDK.

However it will just be a pre-processor macro which probably expands out to one or more attributes, some of which may be specific to the XTensa LX106 compiler.

Update after your edit:

It places the function in the privileged_function section. That section is then placed into a specific area of memory by the linker.

To further examine what it does you will have to look in the linker script to see how it handles that section, and what that means from the chip's perspective, by cross-referencing that with the chip's technical datasheet.

  • OK, let me check where that word is defined. – R1S8K Aug 26 '20 at 14:23
  • I edited the post. – R1S8K Aug 26 '20 at 14:26
  • 1
    It’s called writing code. – Delta_G Aug 26 '20 at 17:09
  • 1
    It's called adding attributes to a function prototype. They can go anywhere in the prototype. – Majenko Aug 26 '20 at 19:46
  • 1
    @R1S8K yep, that's right. – Majenko Aug 26 '20 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.