summaryrefslogtreecommitdiffstats
path: root/cpukit/include/rtems/score/status.h
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2020-01-02 11:31:48 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-02-04 11:25:45 +0100
commitbba1475bc50bb82465978cb8b4c11ebac1cb8956 (patch)
tree96ef6505363d2afea1e299950f48a03ca571aeb1 /cpukit/include/rtems/score/status.h
parentlibtests/malloc04: Fix typo (diff)
downloadrtems-bba1475bc50bb82465978cb8b4c11ebac1cb8956.tar.bz2
score: Optimize STATUS_BUILD()
Do not cast to unsigned int to avoid an unsigned long long enum type. Use a multiplication/division instead to preserve the signedness of the POSIX status.
Diffstat (limited to 'cpukit/include/rtems/score/status.h')
-rw-r--r--cpukit/include/rtems/score/status.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/cpukit/include/rtems/score/status.h b/cpukit/include/rtems/score/status.h
index fe1f0e87e6..b257ccc5db 100644
--- a/cpukit/include/rtems/score/status.h
+++ b/cpukit/include/rtems/score/status.h
@@ -49,9 +49,11 @@ typedef enum {
/**
* @brief Macro to build a status code from Classic and POSIX API parts.
+ *
+ * Uses a multiplication to preserve the signedness of the POSIX status.
*/
#define STATUS_BUILD( classic_status, posix_status ) \
- ( ( ( (unsigned int) ( posix_status ) ) << 8 ) | ( classic_status ) )
+ ( ( ( posix_status ) * 256 ) | ( classic_status ) )
/**
* @brief Macro to get the Classic API status code.
@@ -62,10 +64,10 @@ typedef enum {
/**
* @brief Macro to get the POSIX API status code.
*
- * Performs an arithmetic shift to reconstruct a negative POSIX status.
+ * Uses a division to preserve the signedness of the POSIX status.
*/
#define STATUS_GET_POSIX( status ) \
- ( ( ( (int) ( status ) ) | 0xff ) >> 8 )
+ ( ( status ) / 256 )
/**
* @brief Status codes.