Skip to content

core/thread_flags: remove #error from header file#13671

Merged
bergzand merged 1 commit intoRIOT-OS:masterfrom
jia200x:pr/move_thread_flags_error
Mar 31, 2020
Merged

core/thread_flags: remove #error from header file#13671
bergzand merged 1 commit intoRIOT-OS:masterfrom
jia200x:pr/move_thread_flags_error

Conversation

@jia200x
Copy link
Copy Markdown
Member

@jia200x jia200x commented Mar 20, 2020

Contribution description

This commit removes the #error from the thread_flags header.
This #error makes the usage of
if(IS_USED(MODULE_THAT_DEPENDS_ON_THREAD_FLAGS)) pattern harder,
because the error is triggered each time the header is included.
If a module uses any thread_flags function it will fail in link time
anyway.

Testing procedure

Try removing the core_thread_flags dependency from any component that requires thread flags (e.g /tests/thread_flags_xtimer. It should fail.

Issues/PRs references

#13669

This commit removes the #error from the thread_flags header.
This #error makes the usage of
if(IS_USED(MODULE_THAT_DEPENDS_ON_THREAD_FLAGS)) pattern harder,
because the error is triggered each time the header is included.
If a module uses any thread_flags function it will fail in link time
anyway.
@jia200x jia200x added the Area: core Area: RIOT kernel. Handle PRs marked with this with care! label Mar 20, 2020
@kaspar030
Copy link
Copy Markdown
Contributor

This #error makes the usage of
if(IS_USED(MODULE_THAT_DEPENDS_ON_THREAD_FLAGS)) pattern harder,
because the error is triggered each time the header is included.

don't include headers you don''t use?

@miri64
Copy link
Copy Markdown
Member

miri64 commented Mar 21, 2020

This #error makes the usage of
if(IS_USED(MODULE_THAT_DEPENDS_ON_THREAD_FLAGS)) pattern harder,
because the error is triggered each time the header is included.

don't include headers you don''t use?

This leads to a lot of ugly #ifdefs if the module is used optionally.

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Mar 21, 2020

This leads to a lot of ugly #ifdefs if the module is used optionally.

This.

You need to add the header files for that pattern:

#include "A.h"

if (IS_USED(MODULE_A)) {
    function_in_header_a();
}
another_function();

It will fail if you didn't include "A.h" header.

@kaspar030
Copy link
Copy Markdown
Contributor

This leads to a lot of ugly #ifdefs if the module is used optionally.

This.

Yes, but as soon as we add static inline thread_flags_get() { return sched_active_thread->thread_flags; } because it is useful, you have to make the define conditional anyways. I'm sorry your macro breaks.

@jia200x
Copy link
Copy Markdown
Member Author

jia200x commented Mar 23, 2020

Yes, but as soon as we add static inline thread_flags_get() { return sched_active_thread->thread_flags; } because it is useful, you have to make the define conditional anyways. I'm sorry your macro breaks.

Well, the function doesn't exist now, right? And as soon as someone add it, you only need to guard the function instead of a whole snippet of code. That's what it was done in #13669

@miri64
Copy link
Copy Markdown
Member

miri64 commented Mar 23, 2020

Yes, but as soon as we add static inline thread_flags_get() { return sched_active_thread->thread_flags; } because it is useful, you have to make the define conditional anyways. I'm sorry your macro breaks.

Then we introduce that like this:

static inline thread_flags_t thread_flags_get()
{
#if IS_USED(MODULE_CORE_THREAD_FLAGS)
    return sched_active_thread->thread_flags;
#else
    return 0U;
#endif
}

@kaspar030 kaspar030 added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Mar 31, 2020
Copy link
Copy Markdown
Contributor

@kaspar030 kaspar030 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

@bergzand
Copy link
Copy Markdown
Member

And go!

@bergzand bergzand merged commit 46b6a95 into RIOT-OS:master Mar 31, 2020
@leandrolanzieri leandrolanzieri added the Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer label Apr 3, 2020
@leandrolanzieri leandrolanzieri added this to the Release 2020.04 milestone Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: core Area: RIOT kernel. Handle PRs marked with this with care! CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Impact: minor The PR is small in size and might only require a quick look of a knowledgeable reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants