[rtems commit] posix: Change pthread_once to be SMP safe.

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Aug 14 08:50:24 UTC 2013


On 2013-08-14 10:37, Chris Johns wrote:
> Sebastian Huber wrote:
>> On 2013-08-14 10:00, Chris Johns wrote:
>>>>> + r = pthread_mutex_init( &_POSIX_Once_Lock, &mattr );
>>>>> + if ( r != 0 )
>>>>> + rtems_fatal( RTEMS_FATAL_SOURCE_ASSERT, 0x80aa2000 | r );
>>>>
>>>> This is a configuration error. We need a proper error code for this with
>>>> source INTERNAL_ERROR_POSIX_API.
>>>
>>> Agree. I will change it to INTERNAL_ERROR_POSIX_API. I am not sure
>>> what you
>>> mean by proper error code.
>>
>> I just realized that we need new enums for the RTEMS and POSIX API
>> errors. The fatal error handling in the RTEMS and POSIX API is currently
>> a hack due to the missing unique (source, code) pair identifying the
>> exact error location.
>>
>> So we need enums similar to Internal_errors_Core_list for the RTEMS and
>> POSIX API associated with the error sources INTERNAL_ERROR_RTEMS_API and
>> INTERNAL_ERROR_POSIX_API.
>>
>
> In the case of the POSIX API it may pay to define values with the bottom 8 bits
> an errno error code. This would match the current 2 uses in the internal error
> in the POSIX. For example for the pthread_once mutex init it would be ...
>
>   _Internal_error_Occurred( INTERNAL_ERROR_POSIX_API, true,
>                 _POSIX_Error( POSIX_PTHREAD_ONCE_ERROR, eno ));
>
> Note, POSIX_PTHREAD_ONCE_ERROR can be whatever.
>
> Chris

This looks good, but I would use

void _POSIX_Fatal_error( POSIX_Fatal_domain domain, int eno )
{
   uint32_t code = ( domain << 8 ) | ( ( uint32_t ) eno & 0xffU );

   _Internal_error_Occurred( INTERNAL_ERROR_POSIX_API, false, code );
}

-- 
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.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.



More information about the devel mailing list