From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 94883 invoked by alias); 10 Nov 2016 20:35:17 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Received: (qmail 94848 invoked by uid 89); 10 Nov 2016 20:35:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 spammy=H*i:sk:1478809, H*f:sk:1478809, H*F:D*pl X-HELO: smtpo76.poczta.onet.pl Received: from smtpo76.poczta.onet.pl (HELO smtpo76.poczta.onet.pl) (141.105.16.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 10 Nov 2016 20:35:06 +0000 Received: from INFERNUS (213-238-95-10.adsl.inetia.pl [213.238.95.10]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: freddie_chopin@op.pl) by smtp.poczta.onet.pl (Onet) with ESMTPSA id 3tFFCk74QBzTB8FJY for ; Thu, 10 Nov 2016 21:34:58 +0100 (CET) Message-ID: <1478810097.1322.3.camel@op.pl> Subject: Re: [PATCH, newlib] Allow locking routine to be retargeted From: Freddie Chopin To: newlib@sourceware.org Date: Thu, 10 Nov 2016 20:35:00 -0000 In-Reply-To: <1478809956.1322.1.camel@gmail.com> References: <1478792031.1254.1.camel@op.pl> <60acaa10-fb22-8655-fd67-0536fe359871@foss.arm.com> <1478809956.1322.1.camel@gmail.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2016/txt/msg01086.txt.bz2 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