From mint-bounce@lists.fishpool.fi  Fri Feb 27 05:34:42 2009
X-Virus-Scanned: amavisd-new at demon.co.uk
Subject: Re: [MiNT] sleep patch
From: Alan Hourihane <alanh@fairlite.co.uk>
To: Vincent =?ISO-8859-1?Q?Rivi=E8re?= <vincent.riviere@freesbee.fr>
Cc: mint <mint@fishpool.com>
In-Reply-To: <49A7BD66.1040106@freesbee.fr>
References: <49A73EBE.4070902@freesbee.fr>
	 <1235728251.5850.46.camel@jetpack.demon.co.uk>
	 <49A7BD66.1040106@freesbee.fr>
Content-Type: text/plain; charset=UTF-8
Date: Fri, 27 Feb 2009 10:32:54 +0000
Message-Id: <1235730774.5850.71.camel@jetpack.demon.co.uk>
Mime-Version: 1.0
X-Mailer: Evolution 2.22.3.1 
X-ecartis-version: Ecartis v1.0.0
Sender: mint-bounce@lists.fishpool.fi
Errors-to: mint-bounce@lists.fishpool.fi
X-original-sender: alanh@fairlite.co.uk
Precedence: bulk
List-help: <mailto:ecartis@lists.fishpool.fi?Subject=help>
List-unsubscribe: <mailto:mint-request@lists.fishpool.fi?Subject=unsubscribe>
List-Id: <mint.lists.fishpool.fi>
X-List-ID: <mint.lists.fishpool.fi>
List-subscribe: <mailto:mint-request@lists.fishpool.fi?Subject=subscribe>
List-owner: <mailto:tjhukkan@fishpool.fi>
List-post: <mailto:mint@lists.fishpool.fi>
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from quoted-printable to 8bit by mail.sparemint.org id n1RAYgE3028501

On Fri, 2009-02-27 at 11:16 +0100, Vincent Rivière wrote:
> Alan Hourihane wrote:
> >>  unsigned int
> >> -sleep (unsigned int n)
> >> +__sleep (unsigned int n)
> >>  {
> >>  	long stop;
> >>  	long old_alarm_func;
> > 
> > Has this already been fixed with...
> > 
> > weak_alias (__sleep, sleep)
> 
> The previous line was not the fix, it was the bug ;-)
> The syntax is :
> weak_alias (<existing function name>, <new weak name>)
> 
> So without my patch, the weak_alias directive produces a duplicate
> definition of the symbol _sleep when assembling.
> 
> Note for people unfamiliar with weak aliases: it is a means for allowing
> a program to easily override (replace) a MiNTLib function simply by
> defining a function with the same name.
> 
> If a program defines a sleep() function, it will be used by the program
> and the MiNTLib itself. In that case, the weak alias and the __sleep()
> functions are ignored.
> 
> If a program does not define a sleep() function, it would normally
> produce an unresolved external. So the linker looks for a weak alias for
> that function. If there is one, all the references to the alias will be
> treated as references to the implementation provided by the MiNTLib.
> 
> So 2 solutions :
> - remove the weak alias, so sleep() will not be overridable
> - apply my patch, so sleep() will be overridable

Ah yes, my bad. Quite right Vincent.

Applied.

Alan.


