This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: allow plugins to disable poison
- From: Taras Glek <tglek at mozilla dot com>
- To: Paolo Bonzini <bonzini at gnu dot org>
- Cc: gcc-patches at gcc dot gnu dot org, Diego Novillo <dnovillo at google dot com>
- Date: Wed, 07 Oct 2009 14:31:07 -0700
- Subject: Re: allow plugins to disable poison
- References: <4ACBB5DF.3050506@mozilla.com> <4ACBCA16.9020303@gnu.org>
Paolo Bonzini wrote:
On 10/06/2009 11:25 PM, Taras Glek wrote:
Hi,
Current GCC poison behavior prevents plugins from using malloc() &
friends which causes conflicts with 3rd party headers that call malloc
from their headers.
* system.h: Do not use poison when PLUGIN_NO_POISON is defined
While I don't disagree with this change in principle, I think malloc
and realloc should be the only poisonings disabled. Also, it would be
nice if this was done automatically for all plugins, for example by
doing in gcc-plugin.h
I disagree. GCC poisons a lot of identifiers and the risk of collisions
with other headers is fairly high.
#ifndef IN_GCC
#define IN_GCC
+#define IN_GCC_PLUGIN
#endif
Yes, good idea. I updated the patch.
* system.h: Do not use poison when PLUGIN_NO_POISON is defined
* gcc-plugin.h: Define IN_GCC_PLUGIN
Taras
Index: gcc/gcc-plugin.h
===================================================================
--- gcc/gcc-plugin.h (revision 152497)
+++ gcc/gcc-plugin.h (working copy)
@@ -22,6 +22,7 @@
#ifndef IN_GCC
#define IN_GCC
+#define IN_GCC_PLUGIN
#endif
#include "config.h"
Index: gcc/system.h
===================================================================
--- gcc/system.h (revision 152497)
+++ gcc/system.h (working copy)
@@ -661,7 +661,7 @@
#define realloc xrealloc
#endif
-#if (GCC_VERSION >= 3000)
+#if (GCC_VERSION >= 3000) && !defined(IN_GCC_PLUGIN)
/* Note autoconf checks for prototype declarations and includes
system.h while doing so. Only poison these tokens if actually