This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH, newlib] Allow locking routine to be retargeted


On Thu, 2016-11-10 at 21:32 +0100, Freddie Chopin wrote:
> void __lock_acquire(_LOCK_T lock)
> {
> 	if (lock == 0)
> 	{
> 		// lock not yet really initialized...
> 		disableInterrupts();
> 		if (lock == 0)	// re-check due to possible race
> condition
> 			lock = malloc(sizeof(RealMutexFromYourRtos));
> 
> 		assert(lock != 0);
> 		rtos_mutex_create(lock);
> 		enableInterrupts();
> 	}
> 
> 	rtos_mutex_lock((RealMutexFromYourRtos*)lock);
> }

I've obviously missed some curly braces for the inner "if", but I guess
you get my idea anyway (;

Regards,
FCh


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]