Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
fb7d630d
Commit
fb7d630d
authored
Feb 03, 2009
by
Lisandro Dalcin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid the need to load refnanny module using RTLD_GLOBAL
parent
9db97fa5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
27 deletions
+56
-27
Cython/Compiler/ModuleNode.py
Cython/Compiler/ModuleNode.py
+23
-16
Cython/Runtime/refnanny.pyx
Cython/Runtime/refnanny.pyx
+33
-11
No files found.
Cython/Compiler/ModuleNode.py
View file @
fb7d630d
...
...
@@ -1585,7 +1585,12 @@ class ModuleNode(Nodes.Node, Nodes.BlockNode):
code
.
putln
(
"PyObject* %s;"
%
Naming
.
retval_cname
)
tempdecl_code
=
code
.
insertion_point
()
code
.
put_setup_refcount_context
(
header3
)
code
.
putln
(
"#ifdef CYTHON_REFNANNY"
)
code
.
putln
(
"void* __pyx_refchk = NULL;"
)
code
.
putln
(
"__Pyx_Refnanny = (__Pyx_RefnannyAPIStruct*) PyCObject_Import((char *)
\
"
refnanny
\
"
, (char *)
\
"
RefnannyAPI
\
"
);"
)
code
.
putln
(
"if (!__Pyx_Refnanny) Py_FatalError(
\
"
failed to import refnanny module
\
"
);"
)
code
.
putln
(
"__pyx_refchk = __Pyx_Refnanny->NewContext(
\
"
%s
\
"
, __LINE__);"
%
header3
)
code
.
putln
(
"#endif"
)
code
.
putln
(
"%s = PyTuple_New(0); %s"
%
(
Naming
.
empty_tuple
,
code
.
error_goto_if_null
(
Naming
.
empty_tuple
,
self
.
pos
)));
...
...
@@ -2323,27 +2328,29 @@ bad:
refcount_utility_code
=
UtilityCode
(
proto
=
"""
#ifdef CYTHON_REFNANNY
__PYX_EXTERN_C void __Pyx_Refnanny_INCREF(void*, PyObject*, int);
__PYX_EXTERN_C void __Pyx_Refnanny_GOTREF
(void*, PyObject*, int);
__PYX_EXTERN_C void __Pyx_Refnanny_GIVEREF
(void*, PyObject*, int);
__PYX_EXTERN_C void __Pyx_Refnanny_INCREF
(void*, PyObject*, int);
__PYX_EXTERN_C void __Pyx_Refnanny_DECREF
(void*, PyObject*, int);
__PYX_EXTERN_C void* __Pyx_Refnanny_NewContext(
char*, int);
__PYX_EXTERN_C int __Pyx_Refnanny_FinishContext
(void*);
#define __Pyx_INCREF(r) __Pyx_Refnanny_INCREF(__pyx_refchk, r, __LINE__)
#define __Pyx_GOTREF(r) __Pyx_Refnanny_GOTREF(__pyx_refchk, r, __LINE__)
#define __Pyx_
GIVEREF(r) __Pyx_Refnanny_GIVEREF(__pyx_refchk, r
, __LINE__)
#define __Pyx_DECREF(r) __Pyx_Refnanny
_DECREF(__pyx_refchk, r
, __LINE__)
typedef struct {
void (*INCREF)
(void*, PyObject*, int);
void (*DECREF)
(void*, PyObject*, int);
void (*GOTREF)
(void*, PyObject*, int);
void (*GIVEREF)
(void*, PyObject*, int);
void* (*NewContext)(const
char*, int);
int (*FinishContext)
(void*);
} __Pyx_RefnannyAPIStruct;
static __Pyx_RefnannyAPIStruct* __Pyx_Refnanny = NULL;
#define __Pyx_
INCREF(r) __Pyx_Refnanny->INCREF(__pyx_refchk, (r)
, __LINE__)
#define __Pyx_DECREF(r) __Pyx_Refnanny
->DECREF(__pyx_refchk, (r)
, __LINE__)
#define __Pyx_XDECREF(r) if((r) == NULL) ; else __Pyx_DECREF(r)
#define __Pyx_GOTREF(r) __Pyx_Refnanny->GOTREF(__pyx_refchk, (r), __LINE__)
#define __Pyx_GIVEREF(r) __Pyx_Refnanny->GIVEREF(__pyx_refchk, (r), __LINE__)
#define __Pyx_SetupRefcountContext(name)
\
void* __pyx_refchk = __Pyx_Refnanny
_NewContext((char*)name
, __LINE__)
#define __Pyx_FinishRefcountContext() __Pyx_Refnanny
_
FinishContext(__pyx_refchk)
void* __pyx_refchk = __Pyx_Refnanny
->NewContext((name)
, __LINE__)
#define __Pyx_FinishRefcountContext() __Pyx_Refnanny
->
FinishContext(__pyx_refchk)
#else
#define __Pyx_INCREF(r) Py_INCREF(r)
#define __Pyx_GOTREF(r)
#define __Pyx_GIVEREF(r)
#define __Pyx_DECREF(r) Py_DECREF(r)
#define __Pyx_XDECREF(r) Py_XDECREF(r)
#define __Pyx_GOTREF(r)
#define __Pyx_GIVEREF(r)
#define __Pyx_SetupRefcountContext(name)
#define __Pyx_FinishRefcountContext() 0
#endif /* CYTHON_REFNANNY */
...
...
Cython/Runtime/refnanny.pyx
View file @
fb7d630d
...
...
@@ -54,7 +54,7 @@ class RefnannyContext(object):
# print self.errors
raise
RefnannyException
(
"
\
n
"
.
join
(
self
.
errors
))
cdef
public
void
*
__Pyx_
Refnanny_NewContext
(
char
*
funcname
,
int
lineno
)
except
NULL
:
cdef
void
*
Refnanny_NewContext
(
char
*
funcname
,
int
lineno
)
except
NULL
:
if
exc
.
PyErr_Occurred
()
!=
NULL
:
print
"error flag set on newcontext?"
return
NULL
...
...
@@ -62,8 +62,8 @@ cdef public void* __Pyx_Refnanny_NewContext(char* funcname, int lineno) except N
Py_INCREF
(
ctx
)
return
<
void
*>
ctx
cdef
public
void
__Pyx_
Refnanny_GOTREF
(
void
*
ctx
,
void
*
p_obj
,
int
lineno
):
cdef
exc
.
PyObject
*
type
,
*
value
,
*
tb
cdef
public
void
Refnanny_GOTREF
(
void
*
ctx
,
void
*
p_obj
,
int
lineno
):
cdef
exc
.
PyObject
*
type
=
NULL
,
*
value
=
NULL
,
*
tb
=
NULL
if
ctx
==
NULL
:
return
exc
.
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
try
:
...
...
@@ -78,8 +78,8 @@ cdef public void __Pyx_Refnanny_GOTREF(void* ctx, void* p_obj, int lineno):
Py_XDECREF
(
<
object
>
tb
)
raise
cdef
public
void
__Pyx_
Refnanny_GIVEREF
(
void
*
ctx
,
void
*
p_obj
,
int
lineno
):
cdef
exc
.
PyObject
*
type
,
*
value
,
*
tb
cdef
public
void
Refnanny_GIVEREF
(
void
*
ctx
,
void
*
p_obj
,
int
lineno
):
cdef
exc
.
PyObject
*
type
=
NULL
,
*
value
=
NULL
,
*
tb
=
NULL
if
ctx
==
NULL
:
return
exc
.
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
try
:
...
...
@@ -94,18 +94,18 @@ cdef public void __Pyx_Refnanny_GIVEREF(void* ctx, void* p_obj, int lineno):
Py_XDECREF
(
<
object
>
tb
)
raise
cdef
public
void
__Pyx_
Refnanny_INCREF
(
void
*
ctx
,
void
*
obj
,
int
lineno
):
cdef
public
void
Refnanny_INCREF
(
void
*
ctx
,
void
*
obj
,
int
lineno
):
if
obj
is
not
NULL
:
Py_INCREF
(
<
object
>
obj
)
__Pyx_
Refnanny_GOTREF
(
ctx
,
obj
,
lineno
)
Refnanny_GOTREF
(
ctx
,
obj
,
lineno
)
cdef
public
void
__Pyx_
Refnanny_DECREF
(
void
*
ctx
,
void
*
obj
,
int
lineno
):
cdef
public
void
Refnanny_DECREF
(
void
*
ctx
,
void
*
obj
,
int
lineno
):
# GIVEREF raises exception if we hit 0
#
__Pyx_
Refnanny_GIVEREF
(
ctx
,
obj
,
lineno
)
Refnanny_GIVEREF
(
ctx
,
obj
,
lineno
)
if
obj
is
not
NULL
:
Py_DECREF
(
<
object
>
obj
)
cdef
public
int
__Pyx_
Refnanny_FinishContext
(
void
*
ctx
)
except
-
1
:
cdef
exc
.
PyObject
*
type
,
*
value
,
*
tb
cdef
public
int
Refnanny_FinishContext
(
void
*
ctx
)
except
-
1
:
cdef
exc
.
PyObject
*
type
=
NULL
,
*
value
=
NULL
,
*
tb
=
NULL
if
ctx
==
NULL
:
assert
False
exc
.
PyErr_Fetch
(
&
type
,
&
value
,
&
tb
)
...
...
@@ -123,3 +123,25 @@ cdef public int __Pyx_Refnanny_FinishContext(void* ctx) except -1:
return
0
cdef
extern
from
"Python.h"
:
object
PyCObject_FromVoidPtr
(
void
*
,
void
(
*
)(
void
*
))
ctypedef
struct
RefnannyAPIStruct
:
void
(
*
INCREF
)(
void
*
,
void
*
,
int
)
void
(
*
DECREF
)(
void
*
,
void
*
,
int
)
void
(
*
GOTREF
)(
void
*
,
void
*
,
int
)
void
(
*
GIVEREF
)(
void
*
,
void
*
,
int
)
void
*
(
*
NewContext
)(
char
*
,
int
)
except
NULL
int
(
*
FinishContext
)(
void
*
)
except
-
1
cdef
RefnannyAPIStruct
api
api
.
INCREF
=
Refnanny_INCREF
api
.
DECREF
=
Refnanny_DECREF
api
.
GOTREF
=
Refnanny_GOTREF
api
.
GIVEREF
=
Refnanny_GIVEREF
api
.
NewContext
=
Refnanny_NewContext
api
.
FinishContext
=
Refnanny_FinishContext
RefnannyAPI
=
PyCObject_FromVoidPtr
(
&
api
,
NULL
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment