mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
Use Py_ssize_t for _Py_RefTotal.
I tried to handle Win64 properly, but please review.
This commit is contained in:
parent
9589ee276a
commit
4281cef205
3 changed files with 14 additions and 8 deletions
|
@ -568,7 +568,7 @@ environment the global variable trick is not safe.)
|
||||||
* #ifdefs (we used to do that -- it was impenetrable).
|
* #ifdefs (we used to do that -- it was impenetrable).
|
||||||
*/
|
*/
|
||||||
#ifdef Py_REF_DEBUG
|
#ifdef Py_REF_DEBUG
|
||||||
PyAPI_DATA(long) _Py_RefTotal;
|
PyAPI_DATA(Py_ssize_t) _Py_RefTotal;
|
||||||
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname,
|
PyAPI_FUNC(void) _Py_NegativeRefcount(const char *fname,
|
||||||
int lineno, PyObject *op);
|
int lineno, PyObject *op);
|
||||||
#define _Py_INC_REFTOTAL _Py_RefTotal++
|
#define _Py_INC_REFTOTAL _Py_RefTotal++
|
||||||
|
|
|
@ -29,6 +29,16 @@
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef Py_REF_DEBUG
|
||||||
|
# define PRINT_TOTAL_REFS()
|
||||||
|
#else /* Py_REF_DEBUG */
|
||||||
|
# if defined(MS_WIN64)
|
||||||
|
# define PRINT_TOTAL_REFS() fprintf(stderr, "[%zd refs]\n", _Py_RefTotal);
|
||||||
|
# else /* ! MS_WIN64 */
|
||||||
|
# define PRINT_TOTAL_REFS() fprintf(stderr, "[%ld refs]\n", _Py_RefTotal);
|
||||||
|
# endif /* MS_WIN64 */
|
||||||
|
#endif
|
||||||
|
|
||||||
extern char *Py_GetPath(void);
|
extern char *Py_GetPath(void);
|
||||||
|
|
||||||
extern grammar _PyParser_Grammar; /* From graminit.c */
|
extern grammar _PyParser_Grammar; /* From graminit.c */
|
||||||
|
@ -382,9 +392,7 @@ Py_Finalize(void)
|
||||||
dump_counts();
|
dump_counts();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Py_REF_DEBUG
|
PRINT_TOTAL_REFS()
|
||||||
fprintf(stderr, "[%ld refs]\n", _Py_RefTotal);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef Py_TRACE_REFS
|
#ifdef Py_TRACE_REFS
|
||||||
/* Display all objects still alive -- this can invoke arbitrary
|
/* Display all objects still alive -- this can invoke arbitrary
|
||||||
|
@ -674,9 +682,7 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename, PyCompilerFlags *flag
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ret = PyRun_InteractiveOneFlags(fp, filename, flags);
|
ret = PyRun_InteractiveOneFlags(fp, filename, flags);
|
||||||
#ifdef Py_REF_DEBUG
|
PRINT_TOTAL_REFS()
|
||||||
fprintf(stderr, "[%ld refs]\n", _Py_RefTotal);
|
|
||||||
#endif
|
|
||||||
if (ret == E_EOF)
|
if (ret == E_EOF)
|
||||||
return 0;
|
return 0;
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -604,7 +604,7 @@ sys_getrefcount(PyObject *self, PyObject *arg)
|
||||||
static PyObject *
|
static PyObject *
|
||||||
sys_gettotalrefcount(PyObject *self)
|
sys_gettotalrefcount(PyObject *self)
|
||||||
{
|
{
|
||||||
return PyInt_FromLong(_Py_RefTotal);
|
return PyInt_FromSsize_t(_Py_RefTotal);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* Py_TRACE_REFS */
|
#endif /* Py_TRACE_REFS */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue