From: quale@spock.cs.wisc.edu (Doug Quale) Subject: Re: function-->macro bugs. Date: Sun, 22 Nov 1992 03:28:01 GMT
In article <1992Nov21.123616.10447@klaava.Helsinki.FI> wirzeniu@klaava.Helsinki.FI (Lars Wirzenius) writes:
>jy10033@ehsn11.cen.uiuc.edu (Joshua M Yelon) writes:
>>but I'm curious: how _do_ you replace a library routine?
>
>You change the library source code. Only standard way to go. In ANSI
>C, programs mustn't go around changing standard library routines. The
>reason for this is that the rest of the library might depend on
>certain weird behaviour of the routine under some circumstances, which
>the replacement doesn't have. For instance, the library might have a
>hidden flag, __make_malloc_free_instead__, which the real malloc
>checks.
>
>
>>Or is there simply no way to do it?
>
In my admittedly imperfect understanding, this is not true in POSIX.
The library routines are *required* not to behave on behavior of other
routines. If you look at GNUs libc, glibc, you'll find that all the
library routines that are called by other library routines have names
not in the user namespace (beginning with underscores), so that if
the user replaces a library routine it will not break anything else.
In order to replace a standard routine, you must:
1) not include the header file that declares it
2) make it static
Since I may be all wet, someone who understands this stuff thoroughly
should probably comment.
-- Doug Quale quale@saavik.cs.wisc.edu