Skip to content

Commit

Permalink
arm: using -EAGAIN directly instead of _k_neg_eagain
Browse files Browse the repository at this point in the history
_k_neg_eagain is there for used in assembly where including
errno.h is not possible. However, the usage in ARM was simply
to assign value to swap_return_value in a C file, which is
no need to use _k_neg_eagain as errno.h can be included.
So change that to use -EAGAIN directly. Saves 4 bytes in
built binaries in rodata.

(cherry picked from commit d1813e5)

Original-Signed-off-by: Daniel Leung <daniel.leung@intel.com>
GitOrigin-RevId: d1813e5
Change-Id: Ic4a6b88a98b165fbe5b0491a8b25f99ca7ef9c53
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/zephyr/+/4962350
Commit-Queue: Al Semjonovs <asemjonovs@google.com>
Reviewed-by: Fabio Baltieri <fabiobaltieri@google.com>
Reviewed-by: Al Semjonovs <asemjonovs@google.com>
Tested-by: Al Semjonovs <asemjonovs@google.com>
  • Loading branch information
dcpleung authored and Chromeos LUCI committed Oct 24, 2023
1 parent 33d029d commit e7258ed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions arch/arm/core/cortex_a_r/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <zephyr/kernel.h>
#include <kernel_internal.h>

extern const int _k_neg_eagain;
#include <errno.h>

/* The 'key' actually represents the BASEPRI register
* prior to disabling interrupts via the BASEPRI mechanism.
Expand All @@ -18,7 +18,7 @@ int arch_swap(unsigned int key)
{
/* store off key and return value */
_current->arch.basepri = key;
_current->arch.swap_return_value = _k_neg_eagain;
_current->arch.swap_return_value = -EAGAIN;

z_arm_cortex_r_svc();
irq_unlock(key);
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/core/cortex_m/swap.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <zephyr/kernel.h>
#include <kernel_internal.h>

extern const int _k_neg_eagain;
#include <errno.h>

/* The 'key' actually represents the BASEPRI register
* prior to disabling interrupts via the BASEPRI mechanism.
Expand All @@ -34,7 +34,7 @@ int arch_swap(unsigned int key)
{
/* store off key and return value */
_current->arch.basepri = key;
_current->arch.swap_return_value = _k_neg_eagain;
_current->arch.swap_return_value = -EAGAIN;

/* set pending bit to make sure we will take a PendSV exception */
SCB->ICSR |= SCB_ICSR_PENDSVSET_Msk;
Expand Down

0 comments on commit e7258ed

Please sign in to comment.