RTEMS | cpukit/error: Make RTEMS_ERROR_* shifts 16-bit host clean (!1069)
SHIVAM DEOLANKAR (@D3athSkulll)
gitlab at rtems.org
Sat Feb 21 21:29:33 UTC 2026
SHIVAM DEOLANKAR commented on a discussion on cpukit/include/rtems/error.h: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1069#note_143193
> + * Define Error Flags
> + */
> +#define RTEMS_ERROR_BITS (sizeof(rtems_error_code_t) * CHAR_BIT)
> +
> +#define RTEMS_ERROR_ERRNO (((rtems_error_code_t)1) << (RTEMS_ERROR_BITS - 2))
> +
> +#define RTEMS_ERROR_PANIC (((rtems_error_code_t)1) << (RTEMS_ERROR_BITS - 3))
> +
> +#define RTEMS_ERROR_ABORT (((rtems_error_code_t)1) << (RTEMS_ERROR_BITS - 4))
> +
> +#define RTEMS_ERROR_MASK (RTEMS_ERROR_ERRNO | RTEMS_ERROR_PANIC | RTEMS_ERROR_ABORT)
>
> -#define RTEMS_ERROR_MASK \
> - (RTEMS_ERROR_ERRNO | RTEMS_ERROR_ABORT | RTEMS_ERROR_PANIC) /* all */
> +_Static_assert(RTEMS_ERROR_BITS >= 8,
> + "rtems_error_code_t too small for error flags");
It would fail only when rtems_error_code_t is defined to be smaller than 8 bits. which is unlikely currently.
I added it to document the assumption that error flags require a minimal bit width atleast and it also serves a compile time check or guard in case our underlying type is changed in future.
--
View it on GitLab: https://gitlab.rtems.org/rtems/rtos/rtems/-/merge_requests/1069#note_143193
You're receiving this email because of your account on gitlab.rtems.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/bugs/attachments/20260221/9753e66c/attachment-0001.htm>
More information about the bugs
mailing list