Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sys/pm_layered: align pm_blocker_t for speed #18846

Merged
merged 3 commits into from
Nov 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sys/include/pm_layered.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

#include <stdint.h>
#include "periph_cpu.h"
#include "architecture.h"

#ifdef __cplusplus
extern "C" {
Expand All @@ -55,7 +56,7 @@ extern "C" {
*/
typedef struct {
uint8_t blockers[PM_NUM_MODES]; /**< number of blockers for the mode */
} pm_blocker_t;
} WORD_ALIGNED pm_blocker_t;

/**
* @brief Block a power mode
Expand Down
5 changes: 3 additions & 2 deletions sys/pm_layered/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
*/

#include <assert.h>
#include <string.h>

#include "board.h"
#include "irq.h"
Expand Down Expand Up @@ -75,6 +74,7 @@ void pm_set_lowest(void)
irq_restore(state);
}

__attribute__((optimize(3)))
void pm_block(unsigned mode)
{
DEBUG("[pm_layered] pm_block(%d)\n", mode);
Expand All @@ -85,6 +85,7 @@ void pm_block(unsigned mode)
irq_restore(state);
}

__attribute__((optimize(3)))
void pm_unblock(unsigned mode)
{
DEBUG("[pm_layered] pm_unblock(%d)\n", mode);
Expand All @@ -100,7 +101,7 @@ pm_blocker_t pm_get_blocker(void)
pm_blocker_t result;

unsigned state = irq_disable();
memcpy(&result, &pm_blocker, sizeof(result));
result = pm_blocker;
irq_restore(state);

return result;
Expand Down