[PATCH v2 06/13] score: Add CPU_THREAD_LOCAL_STORAGE_VARIANT

Chris Johns chrisj at rtems.org
Fri Oct 7 03:44:42 UTC 2022


On 6/10/2022 7:23 pm, Sebastian Huber wrote:
> +#if CPU_THREAD_LOCAL_STORAGE_VARIANT == 10
> +  tls_data = (void *)
> +    RTEMS_ALIGN_UP( (uintptr_t) tls_area + sizeof( *tcb ), alignment );
> +  tcb = (TLS_Thread_control_block *) ((char *) tls_data - sizeof( *tcb ));
> +  return_value = tls_data;
> +#elif CPU_THREAD_LOCAL_STORAGE_VARIANT == 11
> +  tcb_size = RTEMS_ALIGN_UP( sizeof( *tcb ), alignment );
> +  tls_data = (void *)
> +    RTEMS_ALIGN_UP( (uintptr_t) tls_area + tcb_size, alignment );
> +  tcb = (TLS_Thread_control_block *) ((char *) tls_data - tcb_size);
> +  return_value = tcb;
> +#elif CPU_THREAD_LOCAL_STORAGE_VARIANT == 20
> +  alignment_2 = RTEMS_ALIGN_UP( alignment, CPU_SIZEOF_POINTER );
> +  tls_area = (void *) RTEMS_ALIGN_UP( (uintptr_t) tls_area, alignment_2 );
> +  size = _TLS_Get_size();
> +  tcb = (TLS_Thread_control_block *)
> +    ((char *) tls_area + RTEMS_ALIGN_UP( size, alignment_2 ));
> +  tls_data = (char *) tcb - RTEMS_ALIGN_UP( size, alignment );
> +  return_value = tcb;
> +#else
> +#error "unexpected CPU_THREAD_LOCAL_STORAGE_VARIANT value"

What are the expected values? I can see 10, 11, 20.

Can this please be changed to something readable? For example:

#if CPU_THREAD_LOCAL_STORAGE_VARIANT == CPU_THREAD_LOCAL_STORAGE_BLAH

#elif CPU_THREAD_LOCAL_STORAGE_VARIANT == CPU_THREAD_LOCAL_STORAGE_BLAH_BLAH

> +#endif
> +
> +  _TLS_Initialize_TCB_and_DTV( tls_data, tcb, dtv );
> +  _TLS_Copy_and_clear( tls_data );
> +
> +  return return_value;
>  }

Chris


More information about the devel mailing list