diff options
author | Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br> | 2008-11-26 23:45:09 -0200 |
---|---|---|
committer | Paulo Cesar Pereira de Andrade <pcpa@mandriva.com.br> | 2008-11-26 23:45:09 -0200 |
commit | 498cce64f12de67271316417de821460e8eee066 (patch) | |
tree | 8a97dc7589a43ffe7cccaafda420676c6d6706a2 | |
parent | f876004608f8a4737f66e1fc0e83ff7e7d6d150b (diff) |
Mark Xalloc, Xrealloc, and Xfree as weak symbols.
Maybe a _X_WEAK macro could be added to <X11/Xfuncproto.h>, but that
could actually encourage use of __attribute__((weak)), what is not
intended.
This change uses the same semantics used in libXfont to declare
weak symbols that are overridden by the ones defined in the X Server.
-rw-r--r-- | Alloc.c | 19 |
1 files changed, 16 insertions, 3 deletions
@@ -40,7 +40,20 @@ in this Software without prior written authorization from The Open Group. #include <X11/Xdmcp.h> #include <stdlib.h> -void * +/* this probably works for Mach-O too, but probably not for PE */ +#if defined(__ELF__) && defined(__GNUC__) && (__GNUC__ >= 3) +#define weak __attribute__((weak)) +#else +#define weak +#endif + +#ifdef __SUNPRO_C +#pragma weak Xalloc +#pragma weak Xrealloc +#pragma weak Xfree +#endif + +weak void * Xalloc (unsigned long amount) { if (amount == 0) @@ -48,7 +61,7 @@ Xalloc (unsigned long amount) return malloc (amount); } -void * +weak void * Xrealloc (void *old, unsigned long amount) { if (amount == 0) @@ -58,7 +71,7 @@ Xrealloc (void *old, unsigned long amount) return realloc ((char *) old, amount); } -void +weak void Xfree (void *old) { if (old) |