[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [MiNT] sleep patch



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

--
Vincent Rivière