[vlc-devel] [PATCH 1/6] os2: implement vlc_once()

Kamil Rytarowski n54 at gmx.com
Mon Apr 2 02:20:25 CEST 2018


On 31.03.2018 15:11, Rémi Denis-Courmont wrote:
> Le mercredi 28 mars 2018, 09:05:45 EEST KO Myung-Hun a écrit :
>> Rémi Denis-Courmont wrote:
>>> Le maanantaina 26. maaliskuuta 2018, 14.16.42 EEST KO Myung-Hun a écrit :
>>>> Rémi Denis-Courmont wrote:
>>>>> POSIX model is simpler here, but it wouldn't work with C11 either.
>>>>
>>>> How about this ?
>>>
>>> I don't understand the logic. Seems insanely complicated.
>>
>> Ooops... Really ?
>>
>> Then another try.
> 
> Same problem. I bail out.
> 

Just follow an existing approach like in NetBSD:

     53 int
     54 pthread_once(pthread_once_t *once_control, void (*routine)(void))
     55 {
     56 	if (__predict_false(__uselibcstub))
     57 		return __libc_thr_once_stub(once_control, routine);
     58
     59 	if (once_control->pto_done == 0) {
     60 		pthread_mutex_lock(&once_control->pto_mutex);
     61 		pthread_cleanup_push(&once_cleanup, &once_control->pto_mutex);
     62 		if (once_control->pto_done == 0) {
     63 			routine();
     64 			once_control->pto_done = 1;
     65 		}
     66 		pthread_cleanup_pop(1);
     67 	}
     68
     69 	return 0;
     70 }

https://nxr.netbsd.org/xref/src/lib/libpthread/pthread_once.c#54

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 850 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20180402/fc6e5ea1/attachment.sig>


More information about the vlc-devel mailing list