From 51611517de6b6682bc451b69b79008f4a589ff13 Mon Sep 17 00:00:00 2001 From: dand-oss Date: Fri, 21 Sep 2012 21:16:58 -0500 Subject: [PATCH] Change static string in header file to extern - static will unnecessarily create and intialize a string in the data segment of each compiled cpp that includes it --- llvm/wrap.cpp | 2 + llvm/wrap.h | 112 +++++++++++++++++++++++++------------------------- 2 files changed, 59 insertions(+), 55 deletions(-) diff --git a/llvm/wrap.cpp b/llvm/wrap.cpp index 47cbdc9..6702ade 100644 --- a/llvm/wrap.cpp +++ b/llvm/wrap.cpp @@ -30,6 +30,8 @@ #include "wrap.h" +const char PYCAP_OBJECT_NAME[] = "llvm.wrap.h"; + /*===----------------------------------------------------------------------===*/ /* Type ctor/dtor */ /*===----------------------------------------------------------------------===*/ diff --git a/llvm/wrap.h b/llvm/wrap.h index a57a46e..116f139 100644 --- a/llvm/wrap.h +++ b/llvm/wrap.h @@ -91,7 +91,7 @@ typedef long long llvmwrap_ll; /* Type ctor/dtor */ /*===----------------------------------------------------------------------===*/ -static const char PYCAP_OBJECT_NAME[] = "llvm.wrap.h"; +extern const char PYCAP_OBJECT_NAME[] ; // Cast python object to aTYPE template @@ -180,7 +180,6 @@ PyObject* make_list( aTYPE p[], size_t n ) ****************************************************************************** *****************************************************************************/ - #define _wrap_none2none(func) \ static PyObject * \ _w ## func(PyObject * self, PyObject * args) \ @@ -223,7 +222,7 @@ _w ## func (PyObject *self, PyObject *args) \ return NULL; \ \ return pycap_new( func( arg1 ) ); \ - _CATCH_ALL \ + _CATCH_ALL \ } /** @@ -576,7 +575,7 @@ _w ## func (PyObject *self, PyObject *args) \ static PyObject * \ _w ## func (PyObject *self, PyObject *args) \ { \ - _TRY \ + _TRY \ PyObject *obj1, *obj2; \ int arg3; \ \ @@ -977,70 +976,73 @@ _w ## func (PyObject *self, PyObject *args) \ * Wrap LLVM functions of the type * outtype func(intype1 arg1, intype2 arg2, intype3 arg3, intype arg4) */ -#define _wrap_objobjobjobj2obj(func, intype1, intype2, intype3, intype4, outtype) \ -static PyObject * \ -_w ## func (PyObject *self, PyObject *args) \ -{ \ - _TRY \ - PyObject *obj1, *obj2, *obj3, *obj4; \ - \ - if (!PyArg_ParseTuple(args, "OOOO", &obj1, &obj2, &obj3, &obj4)) \ - return NULL; \ - \ - const intype1 arg1 = pycap_get< intype1 > (obj1); \ - const intype2 arg2 = pycap_get< intype2 > (obj2); \ - const intype3 arg3 = pycap_get< intype3 > (obj3); \ - const intype4 arg4 = pycap_get< intype4 > (obj4); \ - return pycap_new( func( arg1, arg2, arg3, arg4 ) ); \ - _CATCH_ALL \ +#define _wrap_objobjobjobj2obj(func, intype1, intype2, intype3, \ + intype4, outtype) \ +static PyObject * \ +_w ## func (PyObject *self, PyObject *args) \ +{ \ + _TRY \ + PyObject *obj1, *obj2, *obj3, *obj4; \ + \ + if (!PyArg_ParseTuple(args, "OOOO", &obj1, &obj2, &obj3, &obj4)) \ + return NULL; \ + \ + const intype1 arg1 = pycap_get< intype1 > (obj1); \ + const intype2 arg2 = pycap_get< intype2 > (obj2); \ + const intype3 arg3 = pycap_get< intype3 > (obj3); \ + const intype4 arg4 = pycap_get< intype4 > (obj4); \ + return pycap_new( func( arg1, arg2, arg3, arg4 ) );\ + _CATCH_ALL \ } /** * Wrap LLVM functions of the type * outtype func(intype1 arg1, intype2 arg2, intype3 arg3, intype arg4, const char *arg5) */ -#define _wrap_objobjobjobjstr2obj(func, intype1, intype2, intype3, intype4, outtype)\ -static PyObject * \ -_w ## func (PyObject *self, PyObject *args) \ -{ \ - _TRY \ - PyObject *obj1, *obj2, *obj3, *obj4; \ - const char *arg5; \ - \ +#define _wrap_objobjobjobjstr2obj(func, intype1, intype2, intype3, \ + intype4, outtype)\ +static PyObject * \ +_w ## func (PyObject *self, PyObject *args) \ +{ \ + _TRY \ + PyObject *obj1, *obj2, *obj3, *obj4; \ + const char *arg5; \ + \ if (!PyArg_ParseTuple(args, "OOOOs", &obj1, &obj2, &obj3, &obj4, &arg5)) \ - return NULL; \ - \ - const intype1 arg1 = pycap_get< intype1 > (obj1); \ - const intype2 arg2 = pycap_get< intype2 > (obj2); \ - const intype3 arg3 = pycap_get< intype3 > (obj3); \ - const intype4 arg4 = pycap_get< intype4 > (obj4); \ - \ - return pycap_new( func( arg1, arg2, arg3, arg4, arg5 ) ); \ - _CATCH_ALL \ + return NULL; \ + \ + const intype1 arg1 = pycap_get< intype1 > (obj1); \ + const intype2 arg2 = pycap_get< intype2 > (obj2); \ + const intype3 arg3 = pycap_get< intype3 > (obj3); \ + const intype4 arg4 = pycap_get< intype4 > (obj4); \ + \ + return pycap_new( func( arg1, arg2, arg3, arg4, arg5 ) );\ + _CATCH_ALL \ } /** * Wrap LLVM functions of the type * outtype func(intype1 arg1, enum_intype2 arg2, intype3 arg3, intype4 arg4, const char *arg5) */ -#define _wrap_objenumobjobjstr2obj(func, intype1, intype2, intype3, intype4, outtype) \ -static PyObject * \ -_w ## func (PyObject *self, PyObject *args) \ -{ \ - _TRY \ - PyObject *obj1, *obj3, *obj4; \ - intype2 arg2 ; \ - const char *arg5; \ - \ - if (!PyArg_ParseTuple(args, "OiOOs", &obj1, &arg2, &obj3, &obj4, &arg5)) \ - return NULL; \ - \ - const intype1 arg1 = pycap_get< intype1 > (obj1); \ - const intype3 arg3 = pycap_get< intype3 > (obj3); \ - const intype4 arg4 = pycap_get< intype4 > (obj4); \ - \ - return pycap_new( func( arg1, arg2, arg3, arg4, arg5 ) ); \ - _CATCH_ALL \ +#define _wrap_objenumobjobjstr2obj(func, intype1, intype2, intype3, \ + intype4, outtype) \ +static PyObject * \ +_w ## func (PyObject *self, PyObject *args) \ +{ \ + _TRY \ + PyObject *obj1, *obj3, *obj4; \ + intype2 arg2 ; \ + const char *arg5; \ + \ + if (!PyArg_ParseTuple(args, "OiOOs", &obj1, &arg2, &obj3, &obj4, &arg5)) \ + return NULL; \ + \ + const intype1 arg1 = pycap_get< intype1 > (obj1); \ + const intype3 arg3 = pycap_get< intype3 > (obj3); \ + const intype4 arg4 = pycap_get< intype4 > (obj4); \ + \ + return pycap_new( func( arg1, arg2, arg3, arg4, arg5 ) ); \ + _CATCH_ALL \ } /**