summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2008-11-26 23:45:09 -0200
committerPaulo Cesar Pereira de Andrade <pcpa@mandriva.com.br>2008-11-26 23:45:09 -0200
commit498cce64f12de67271316417de821460e8eee066 (patch)
tree8a97dc7589a43ffe7cccaafda420676c6d6706a2
parentf876004608f8a4737f66e1fc0e83ff7e7d6d150b (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.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/Alloc.c b/Alloc.c
index 40cbacf..1c32270 100644
--- a/Alloc.c
+++ b/Alloc.c
@@ -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)