This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: Projects for beginners


On Wed, Jan 31, 2001 at 08:48:58AM -0500, Kaveh R. Ghazi wrote:
> 
>  >     - Get rid of all remaining uses of bcopy (requires understanding
>  >       the code well enough to tell whether they should be memcpy or
>  >       memmove).
>  > 
>  >     - Then apply #pragma GCC poison to bcmp/bzero/bcopy/rindex
>  >     <URL:http://gcc.gnu.org/ml/gcc-patches/2000-11/msg00432.html>
> 
> I'd like to poison malloc/realloc/calloc/strdup too and enforce using
> the "x" versions from libiberty.  But two or three legit uses still
> occur.  Is there a way to say use malloc even though its poisoned?
> 
> Perhaps instead we could #define malloc() to #error and make the legit
> uses call (malloc)() which bypasses the macro?

I hesitate to use #pragma GCC poison at all because it's such a big
hammer.  It will barf, for instance, if the system headers define
macros which refer to any of the above and we use them.

There is no way to #define something to a compile-time #error, however
we could do something like

#define malloc(x) dont_use_malloc_you_luser(x)

then the linker will trap them, and the legitimate users can do
(malloc)(x) as you suggest.  This too is not safe if the system
headers define macros which use malloc.  The only example I can find
is glibc's "optimized" strdup, which we don't want to use anyway, but
I wouldn't rule out others.

zw

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