-- Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany Phone : +49 89 189 47 41-16 Fax : +49 89 189 47 41-09 E-Mail : sebastian.hu...@embedded-brains.de PGP : Public key available on request. Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
From 5d113ea4a4464987aa4a6bf2d3166d08810ef74d Mon Sep 17 00:00:00 2001 From: Sebastian Huber <sebastian.hu...@embedded-brains.de> Date: Thu, 2 Jan 2020 11:31:48 +0100 Subject: [PATCH] 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. --- cpukit/include/rtems/score/status.h | 8 +++++--- 1 file 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. -- 2.16.4
_______________________________________________ devel mailing list devel@rtems.org http://lists.rtems.org/mailman/listinfo/devel