comparison Python/sysmodule.c @ 18689:064de84385ca legacy-trunk

Patch #412229: Add functions sys.getdlopenflags and sys.setdlopenflags. Add dlopenflags to PyInterpreterState, and use it in dlopen calls.
author Martin v. Löwis <martin@v.loewis.de>
date Wed, 18 Jul 2001 16:17:16 +0000
parents e427afb5637f
children 4462c57f6c94
comparison
equal deleted inserted replaced
18688:4c59e934e765 18689:064de84385ca
392 \n\ 392 \n\
393 Return the current value of the recursion limit, the maximum depth\n\ 393 Return the current value of the recursion limit, the maximum depth\n\
394 of the Python interpreter stack. This limit prevents infinite\n\ 394 of the Python interpreter stack. This limit prevents infinite\n\
395 recursion from causing an overflow of the C stack and crashing Python."; 395 recursion from causing an overflow of the C stack and crashing Python.";
396 396
397 #ifdef HAVE_DLOPEN
398 static PyObject *
399 sys_setdlopenflags(PyObject *self, PyObject *args)
400 {
401 int new_val;
402 PyThreadState *tstate = PyThreadState_Get();
403 if (!PyArg_ParseTuple(args, "i:setdlopenflags", &new_val))
404 return NULL;
405 if (!tstate)
406 return NULL;
407 tstate->interp->dlopenflags = new_val;
408 Py_INCREF(Py_None);
409 return Py_None;
410 }
411
412 static char setdlopenflags_doc[] =
413 "setdlopenflags(n) -> None\n\
414 \n\
415 Set the flags that will be used for dlopen() calls. Among other\n\
416 things, this will enable a lazy resolving of symbols when imporing\n\
417 a module, if called as sys.setdlopenflags(0)\n\
418 To share symols across extension modules, call as\n\
419 sys.setdlopenflags(dl.RTLD_NOW|dl.RTLD_GLOBAL)";
420
421 static PyObject *
422 sys_getdlopenflags(PyObject *self, PyObject *args)
423 {
424 PyThreadState *tstate = PyThreadState_Get();
425 if (!PyArg_ParseTuple(args, ":getdlopenflags"))
426 return NULL;
427 if (!tstate)
428 return NULL;
429 return PyInt_FromLong(tstate->interp->dlopenflags);
430 }
431
432 static char getdlopenflags_doc[] =
433 "getdlopenflags() -> int\n\
434 \n\
435 Return the current value of the flags that are used for dlopen()\n\
436 calls. The flag constants are defined in the dl module.";
437 #endif
438
397 #ifdef USE_MALLOPT 439 #ifdef USE_MALLOPT
398 /* Link with -lmalloc (or -lmpc) on an SGI */ 440 /* Link with -lmalloc (or -lmpc) on an SGI */
399 #include <malloc.h> 441 #include <malloc.h>
400 442
401 static PyObject * 443 static PyObject *
499 {"exc_info", sys_exc_info, 1, exc_info_doc}, 541 {"exc_info", sys_exc_info, 1, exc_info_doc},
500 {"excepthook", sys_excepthook, 1, excepthook_doc}, 542 {"excepthook", sys_excepthook, 1, excepthook_doc},
501 {"exit", sys_exit, 0, exit_doc}, 543 {"exit", sys_exit, 0, exit_doc},
502 {"getdefaultencoding", sys_getdefaultencoding, 1, 544 {"getdefaultencoding", sys_getdefaultencoding, 1,
503 getdefaultencoding_doc}, 545 getdefaultencoding_doc},
546 #ifdef HAVE_DLOPEN
547 {"getdlopenflags", sys_getdlopenflags, 1,
548 getdlopenflags_doc},
549 #endif
504 #ifdef COUNT_ALLOCS 550 #ifdef COUNT_ALLOCS
505 {"getcounts", sys_getcounts, 1}, 551 {"getcounts", sys_getcounts, 1},
506 #endif 552 #endif
507 #ifdef DYNAMIC_EXECUTION_PROFILE 553 #ifdef DYNAMIC_EXECUTION_PROFILE
508 {"getdxp", _Py_GetDXProfile, 1}, 554 {"getdxp", _Py_GetDXProfile, 1},
520 #endif 566 #endif
521 {"setdefaultencoding", sys_setdefaultencoding, 1, 567 {"setdefaultencoding", sys_setdefaultencoding, 1,
522 setdefaultencoding_doc}, 568 setdefaultencoding_doc},
523 {"setcheckinterval", sys_setcheckinterval, 1, 569 {"setcheckinterval", sys_setcheckinterval, 1,
524 setcheckinterval_doc}, 570 setcheckinterval_doc},
571 #ifdef HAVE_DLOPEN
572 {"setdlopenflags", sys_setdlopenflags, 1,
573 setdlopenflags_doc},
574 #endif
525 {"setprofile", sys_setprofile, 0, setprofile_doc}, 575 {"setprofile", sys_setprofile, 0, setprofile_doc},
526 {"setrecursionlimit", sys_setrecursionlimit, 1, 576 {"setrecursionlimit", sys_setrecursionlimit, 1,
527 setrecursionlimit_doc}, 577 setrecursionlimit_doc},
528 {"settrace", sys_settrace, 0, settrace_doc}, 578 {"settrace", sys_settrace, 0, settrace_doc},
529 {NULL, NULL} /* sentinel */ 579 {NULL, NULL} /* sentinel */
657 \n\ 707 \n\
658 displayhook() -- print an object to the screen, and save it in __builtin__._\n\ 708 displayhook() -- print an object to the screen, and save it in __builtin__._\n\
659 excepthook() -- print an exception and its traceback to sys.stderr\n\ 709 excepthook() -- print an exception and its traceback to sys.stderr\n\
660 exc_info() -- return thread-safe information about the current exception\n\ 710 exc_info() -- return thread-safe information about the current exception\n\
661 exit() -- exit the interpreter by raising SystemExit\n\ 711 exit() -- exit the interpreter by raising SystemExit\n\
712 getdlopenflags() -- returns flags to be used for dlopen() calls\n\
662 getrefcount() -- return the reference count for an object (plus one :-)\n\ 713 getrefcount() -- return the reference count for an object (plus one :-)\n\
663 getrecursionlimit() -- return the max recursion depth for the interpreter\n\ 714 getrecursionlimit() -- return the max recursion depth for the interpreter\n\
664 setcheckinterval() -- control how often the interpreter checks for events\n\ 715 setcheckinterval() -- control how often the interpreter checks for events\n\
716 setdlopenflags() -- set the flags to be used for dlopen() calls\n\
665 setprofile() -- set the global profiling function\n\ 717 setprofile() -- set the global profiling function\n\
666 setrecursionlimit() -- set the max recursion depth for the interpreter\n\ 718 setrecursionlimit() -- set the max recursion depth for the interpreter\n\
667 settrace() -- set the global debug tracing function\n\ 719 settrace() -- set the global debug tracing function\n\
668 " 720 "
669 #endif /* MS_WIN16 */ 721 #endif /* MS_WIN16 */