[PATCH RTEMS 5] cpukit/include: Fix including in C++
Joel Sherrill
joel at rtems.org
Sat Aug 27 01:13:58 UTC 2022
I'm ok with these but which were actually causing trouble?
On Fri, Aug 26, 2022, 8:12 PM <chrisj at rtems.org> wrote:
> From: Chris Johns <chrisj at rtems.org>
>
> Closes #4709
> ---
> cpukit/include/link_elf.h | 8 ++++++++
> cpukit/include/linux/rbtree.h | 10 +++++++++-
> cpukit/include/rtems/capture.h | 4 ++--
> cpukit/include/rtems/posix/muteximpl.h | 7 +++----
> cpukit/include/rtems/posix/pthreadattrimpl.h | 2 +-
> cpukit/include/rtems/rtl/rtl-obj.h | 20 +++++++++++++++----
> cpukit/include/rtems/rtl/rtl.h | 2 +-
> cpukit/include/rtems/score/priority.h | 4 ++--
> cpukit/include/rtems/score/priorityimpl.h | 2 +-
> cpukit/include/rtems/score/scheduleredfimpl.h | 4 ++--
> cpukit/include/rtems/score/tls.h | 2 +-
> cpukit/include/rtems/score/watchdogimpl.h | 2 +-
> 12 files changed, 47 insertions(+), 20 deletions(-)
>
> diff --git a/cpukit/include/link_elf.h b/cpukit/include/link_elf.h
> index 6cab3c2c7f..6483c021fd 100644
> --- a/cpukit/include/link_elf.h
> +++ b/cpukit/include/link_elf.h
> @@ -13,6 +13,10 @@
> #include <stdint.h>
> #include <rtems/rtl/rtl-obj-fwd.h>
>
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> enum sections
> {
> rap_text = 0,
> @@ -76,4 +80,8 @@ int _rtld_linkmap_add (rtems_rtl_obj* obj);
> * Remove link map from the list.
> */
> void _rtld_linkmap_delete (rtems_rtl_obj* obj);
> +
> +#ifdef __cplusplus
> +}
> +#endif
> #endif /* _LINK_ELF_H_ */
> diff --git a/cpukit/include/linux/rbtree.h b/cpukit/include/linux/rbtree.h
> index 8fc575240f..ec0fac1af9 100644
> --- a/cpukit/include/linux/rbtree.h
> +++ b/cpukit/include/linux/rbtree.h
> @@ -17,6 +17,10 @@
>
> #include <rtems/score/rbtree.h>
>
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> #define rb_node RBTree_Node
>
> #define rb_left Node.rbe_left
> @@ -96,7 +100,7 @@ static inline struct rb_node *rb_last( struct rb_root
> *root )
>
> static inline void rb_replace_node(
> struct rb_node *victim,
> - struct rb_node *replacement,
> + struct rb_node *replacement,
> struct rb_root *root
> )
> {
> @@ -138,4 +142,8 @@ static inline struct rb_node *rb_parent( struct
> rb_node *node )
> node = next \
> )
>
> +#ifdef __cplusplus
> +}
> +#endif
> +
> #endif /* _LINUX_RBTREE_H */
> diff --git a/cpukit/include/rtems/capture.h
> b/cpukit/include/rtems/capture.h
> index c37d652211..4ab638ec24 100644
> --- a/cpukit/include/rtems/capture.h
> +++ b/cpukit/include/rtems/capture.h
> @@ -838,7 +838,7 @@ rtems_capture_task_flags (rtems_tcb* tcb)
> static inline rtems_capture_control*
> rtems_capture_task_control (rtems_tcb* tcb)
> {
> - return tcb->Capture.control;
> + return (rtems_capture_control*) tcb->Capture.control;
> }
>
> /**
> @@ -853,7 +853,7 @@ rtems_capture_task_control (rtems_tcb* tcb)
> static inline uint32_t
> rtems_capture_task_control_flags (rtems_tcb* tcb)
> {
> - rtems_capture_control* control = tcb->Capture.control;
> + rtems_capture_control* control = rtems_capture_task_control (tcb);
> if (!control)
> return 0;
> return control->flags;
> diff --git a/cpukit/include/rtems/posix/muteximpl.h
> b/cpukit/include/rtems/posix/muteximpl.h
> index 435b43634d..3d717420f2 100644
> --- a/cpukit/include/rtems/posix/muteximpl.h
> +++ b/cpukit/include/rtems/posix/muteximpl.h
> @@ -2,8 +2,8 @@
> * @file
> *
> * @brief Private Inlined Routines for POSIX Mutex's.
> - *
> - * This include file contains the static inline implementation of the
> private
> + *
> + * This include file contains the static inline implementation of the
> private
> * inlined routines for POSIX mutex's.
> */
>
> @@ -104,7 +104,7 @@ RTEMS_INLINE_ROUTINE POSIX_Mutex_Protocol
> _POSIX_Mutex_Get_protocol(
> unsigned long flags
> )
> {
> - return flags & POSIX_MUTEX_PROTOCOL_MASK;
> + return (POSIX_Mutex_Protocol) (flags & POSIX_MUTEX_PROTOCOL_MASK);
> }
>
> RTEMS_INLINE_ROUTINE bool _POSIX_Mutex_Is_recursive(
> @@ -484,4 +484,3 @@ bool _POSIX_Mutex_Auto_initialization(
> POSIX_Mutex_Control *the_mutex );
>
> #endif
> /* end of include file */
> -
> diff --git a/cpukit/include/rtems/posix/pthreadattrimpl.h
> b/cpukit/include/rtems/posix/pthreadattrimpl.h
> index b5e02ec1c7..7cd69142a6 100644
> --- a/cpukit/include/rtems/posix/pthreadattrimpl.h
> +++ b/cpukit/include/rtems/posix/pthreadattrimpl.h
> @@ -72,7 +72,7 @@ RTEMS_INLINE_ROUTINE void
> _POSIX_Threads_Get_sched_param_sporadic(
> #if defined(RTEMS_POSIX_API)
> const POSIX_API_Control *api;
>
> - api = the_thread->API_Extensions[ THREAD_API_POSIX ];
> + api = (const POSIX_API_Control*) the_thread->API_Extensions[
> THREAD_API_POSIX ];
> param->sched_ss_low_priority = _POSIX_Priority_From_core(
> scheduler,
> api->Sporadic.Low_priority.priority
> diff --git a/cpukit/include/rtems/rtl/rtl-obj.h
> b/cpukit/include/rtems/rtl/rtl-obj.h
> index f27ae3259d..c1fe51306b 100644
> --- a/cpukit/include/rtems/rtl/rtl-obj.h
> +++ b/cpukit/include/rtems/rtl/rtl-obj.h
> @@ -231,7 +231,7 @@ struct rtems_rtl_obj
> size_t tramps_size; /**< Size of the trampoline memory. */
> void* tramp_brk; /**< Trampoline memory allocator. MD
> * relocators can take memory from
> the
> - * break upto the size. */
> + * break up to the size. */
> size_t tramp_relocs; /**< Number of slots reserved for
> * relocs. The remainder are for
> * unresolved symbols. */
> @@ -333,7 +333,7 @@ static inline bool rtems_rtl_obj_text_inside (const
> rtems_rtl_obj* obj,
> {
> return
> (address >= obj->text_base) &&
> - (address < (obj->text_base + obj->text_size));
> + ((char*) address < ((char*) obj->text_base + obj->text_size));
> }
>
> /**
> @@ -367,6 +367,18 @@ static inline bool rtems_rtl_obj_has_symbol (const
> rtems_rtl_obj* obj,
> sym < (obj->global_table + obj->global_syms));
> }
>
> +/**
> + * Is there space in the trampoline memory for a trapoline.
> + *
> + * @param obj The object file's descriptor to check for available space.
> + * @param size The size to be allocated.
> + * @retval bool Returns @true if the space is available.
> + */
> +static inline size_t rtems_rtl_obj_tramp_avail_space (const
> rtems_rtl_obj* obj)
> +{
> + return (char*) obj->tramp_brk - (char*) obj->trampoline;
> +}
> +
> /**
> * Is there space in the trampoline memory for a trapoline.
> *
> @@ -378,7 +390,7 @@ static inline bool rtems_rtl_obj_has_tramp_space
> (const rtems_rtl_obj* obj,
> const size_t
> size)
> {
> return (obj->trampoline != NULL &&
> - ((obj->tramp_brk - obj->trampoline) + size) <=
> obj->tramps_size);
> + (rtems_rtl_obj_tramp_avail_space (obj) + size) <=
> obj->tramps_size);
> }
>
> /**
> @@ -402,7 +414,7 @@ static inline size_t rtems_rtl_obj_trampoline_slots
> (const rtems_rtl_obj* obj)
> static inline size_t rtems_rtl_obj_trampolines (const rtems_rtl_obj* obj)
> {
> return obj->trampoline == NULL || obj->tramp_size == 0 ?
> - 0 : (obj->tramp_brk - obj->trampoline) / obj->tramp_size;
> + 0 : rtems_rtl_obj_tramp_avail_space (obj) / obj->tramp_size;
> }
>
> /**
> diff --git a/cpukit/include/rtems/rtl/rtl.h
> b/cpukit/include/rtems/rtl/rtl.h
> index 67d7e96be3..3c74370187 100644
> --- a/cpukit/include/rtems/rtl/rtl.h
> +++ b/cpukit/include/rtems/rtl/rtl.h
> @@ -88,7 +88,7 @@ extern struct r_debug _rtld_debug;
> * Debugger break function. Call when debugging to have it read the
> _rtld_debug
> * variable.
> */
> -extern void _rtld_debug_state (void);
> +void _rtld_debug_state (void);
>
> /**
> * The type of constructor/destructor function.
> diff --git a/cpukit/include/rtems/score/priority.h
> b/cpukit/include/rtems/score/priority.h
> index 54b91a871b..a6c65d3c4c 100644
> --- a/cpukit/include/rtems/score/priority.h
> +++ b/cpukit/include/rtems/score/priority.h
> @@ -24,12 +24,12 @@
> #include <rtems/score/cpu.h>
> #include <rtems/score/rbtree.h>
>
> -struct _Scheduler_Control;
> -
> #ifdef __cplusplus
> extern "C" {
> #endif
>
> +struct _Scheduler_Control;
> +
> /**
> * @defgroup RTEMSScorePriority Priority Handler
> *
> diff --git a/cpukit/include/rtems/score/priorityimpl.h
> b/cpukit/include/rtems/score/priorityimpl.h
> index b33419acdb..3b92d3375a 100644
> --- a/cpukit/include/rtems/score/priorityimpl.h
> +++ b/cpukit/include/rtems/score/priorityimpl.h
> @@ -389,7 +389,7 @@ RTEMS_INLINE_ROUTINE bool _Priority_Less(
> const Priority_Control *the_left;
> const Priority_Node *the_right;
>
> - the_left = left;
> + the_left = (const Priority_Control*) left;
> the_right = RTEMS_CONTAINER_OF( right, Priority_Node, Node.RBTree );
>
> return *the_left < the_right->priority;
> diff --git a/cpukit/include/rtems/score/scheduleredfimpl.h
> b/cpukit/include/rtems/score/scheduleredfimpl.h
> index f2bec2dfbe..fc8c67c163 100644
> --- a/cpukit/include/rtems/score/scheduleredfimpl.h
> +++ b/cpukit/include/rtems/score/scheduleredfimpl.h
> @@ -100,7 +100,7 @@ RTEMS_INLINE_ROUTINE bool _Scheduler_EDF_Less(
> Priority_Control prio_left;
> Priority_Control prio_right;
>
> - the_left = left;
> + the_left = (const Priority_Control*) left;
> the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node );
>
> prio_left = *the_left;
> @@ -128,7 +128,7 @@ RTEMS_INLINE_ROUTINE bool
> _Scheduler_EDF_Priority_less_equal(
> Priority_Control prio_left;
> Priority_Control prio_right;
>
> - the_left = left;
> + the_left = (const Priority_Control*) left;
> the_right = RTEMS_CONTAINER_OF( right, Scheduler_EDF_Node, Node );
>
> prio_left = *the_left;
> diff --git a/cpukit/include/rtems/score/tls.h
> b/cpukit/include/rtems/score/tls.h
> index 65a49d87be..322be30c7a 100644
> --- a/cpukit/include/rtems/score/tls.h
> +++ b/cpukit/include/rtems/score/tls.h
> @@ -222,7 +222,7 @@ static inline void *_TLS_TCB_at_area_begin_initialize(
> void *tls_area )
> {
> void *tls_block = (char *) tls_area
> + _TLS_Get_thread_control_block_area_size( (uintptr_t) _TLS_Alignment
> );
> - TLS_Thread_control_block *tcb = tls_area;
> + TLS_Thread_control_block *tcb = (TLS_Thread_control_block*) tls_area;
> uintptr_t aligned_size = _TLS_Heap_align_up( (uintptr_t) _TLS_Size );
> TLS_Dynamic_thread_vector *dtv = (TLS_Dynamic_thread_vector *)
> ((char *) tls_block + aligned_size);
> diff --git a/cpukit/include/rtems/score/watchdogimpl.h
> b/cpukit/include/rtems/score/watchdogimpl.h
> index a52fb1c2cb..ed9d1ef5cd 100644
> --- a/cpukit/include/rtems/score/watchdogimpl.h
> +++ b/cpukit/include/rtems/score/watchdogimpl.h
> @@ -150,7 +150,7 @@ RTEMS_INLINE_ROUTINE Watchdog_State
> _Watchdog_Get_state(
> const Watchdog_Control *the_watchdog
> )
> {
> - return RB_COLOR( &the_watchdog->Node.RBTree, Node );
> + return (Watchdog_State) RB_COLOR( &the_watchdog->Node.RBTree, Node );
> }
>
> /**
> --
> 2.24.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20220826/1e6080a2/attachment-0001.htm>
More information about the devel
mailing list