diff options
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r-- | Python/sysmodule.c | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 20bfa555b3..2680e6bf27 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -774,7 +774,7 @@ Set the flags used by the interpreter for dlopen calls, such as when the\n\ interpreter loads extension modules. Among other things, this will enable\n\ a lazy resolving of symbols when importing a module, if called as\n\ sys.setdlopenflags(0). To share symbols across extension modules, call as\n\ -sys.setdlopenflags(ctypes.RTLD_GLOBAL). Symbolic names for the flag modules\n\ +sys.setdlopenflags(os.RTLD_GLOBAL). Symbolic names for the flag modules\n\ can be found in the os module (RTLD_xxx constants, e.g. os.RTLD_LAZY)."); static PyObject * @@ -790,7 +790,7 @@ PyDoc_STRVAR(getdlopenflags_doc, "getdlopenflags() -> int\n\ \n\ Return the current value of the flags that are used for dlopen calls.\n\ -The flag constants are defined in the ctypes and DLFCN modules."); +The flag constants are defined in the os module."); #endif /* HAVE_DLOPEN */ @@ -894,6 +894,19 @@ one higher than you might expect, because it includes the (temporary)\n\ reference as an argument to getrefcount()." ); +static PyObject * +sys_getallocatedblocks(PyObject *self) +{ + return PyLong_FromSsize_t(_Py_GetAllocatedBlocks()); +} + +PyDoc_STRVAR(getallocatedblocks_doc, +"getallocatedblocks() -> integer\n\ +\n\ +Return the number of memory blocks currently allocated, regardless of their\n\ +size." +); + #ifdef COUNT_ALLOCS static PyObject * sys_getcounts(PyObject *self) @@ -1062,6 +1075,8 @@ static PyMethodDef sys_methods[] = { {"getdlopenflags", (PyCFunction)sys_getdlopenflags, METH_NOARGS, getdlopenflags_doc}, #endif + {"getallocatedblocks", (PyCFunction)sys_getallocatedblocks, METH_NOARGS, + getallocatedblocks_doc}, #ifdef COUNT_ALLOCS {"getcounts", (PyCFunction)sys_getcounts, METH_NOARGS}, #endif @@ -1349,9 +1364,6 @@ static PyStructSequence_Field flags_fields[] = { {"no_site", "-S"}, {"ignore_environment", "-E"}, {"verbose", "-v"}, -#ifdef RISCOS - {"riscos_wimp", "???"}, -#endif /* {"unbuffered", "-u"}, */ /* {"skip_first", "-x"}, */ {"bytes_warning", "-b"}, @@ -1364,11 +1376,7 @@ static PyStructSequence_Desc flags_desc = { "sys.flags", /* name */ flags__doc__, /* doc */ flags_fields, /* fields */ -#ifdef RISCOS - 13 -#else 12 -#endif }; static PyObject* @@ -1393,9 +1401,6 @@ make_flags(void) SetFlag(Py_NoSiteFlag); SetFlag(Py_IgnoreEnvironmentFlag); SetFlag(Py_VerboseFlag); -#ifdef RISCOS - SetFlag(Py_RISCOSWimpFlag); -#endif /* SetFlag(saw_unbuffered_flag); */ /* SetFlag(skipfirstline); */ SetFlag(Py_BytesWarningFlag); @@ -1561,7 +1566,6 @@ PyObject * _PySys_Init(void) { PyObject *m, *v, *sysdict, *version_info; - char *s; m = PyModule_Create(&sysmodule); if (m == NULL) @@ -1638,20 +1642,14 @@ _PySys_Init(void) PyLong_FromLong(0x10FFFF)); SET_SYS_FROM_STRING("builtin_module_names", list_builtin_module_names()); - { - /* Assumes that longs are at least 2 bytes long. - Should be safe! */ - unsigned long number = 1; - char *value; - - s = (char *) &number; - if (s[0] == 0) - value = "big"; - else - value = "little"; - SET_SYS_FROM_STRING("byteorder", - PyUnicode_FromString(value)); - } +#if PY_BIG_ENDIAN + SET_SYS_FROM_STRING("byteorder", + PyUnicode_FromString("big")); +#else + SET_SYS_FROM_STRING("byteorder", + PyUnicode_FromString("little")); +#endif + #ifdef MS_COREDLL SET_SYS_FROM_STRING("dllhandle", PyLong_FromVoidPtr(PyWin_DLLhModule)); |