/* * author: Pierre Schnizer * created: March 2004 * file: pygsl/src/initmodule.c * $Id: initmodule.c,v 1.8 2005/06/07 06:24:42 schnizer Exp $ * * Changes: * 7. October 2003: * Removed the error handler from this file. It is now in * Lib/error_helpers.c Each module must call init_pygsl() * in its init routine. This is necessary to support platforms * where the gsl library is statically linked to the various * modules. */ #include #include #include #include #define _PyGSL_API_MODULE 1 #include #include #include /* Taken from Modules/getbuildinfo */ #ifndef DATE #ifdef __DATE__ #define DATE __DATE__ #else #define DATE "xx/xx/xx" #endif #endif #ifndef TIME #ifdef __TIME__ #define TIME __TIME__ #else #define TIME "xx:xx:xx" #endif #endif /* End */ /* * Used as a buffer to generate error messages. */ static char pygsl_error_str[512]; #include "profile.c" #include "error_helpers.c" #include "general_helpers.c" #include "complex_helpers.c" #include "block_helpers.c" #include "function_helpers.c" #include "rng_helpers.c" static PyObject * debuglist = NULL; static int PyGSL_register_debug_flag(int * ptr, const char * module_name) { #if DEBUG == 1 PyObject * cobj; FUNC_MESS_BEGIN(); if ((cobj = PyCObject_FromVoidPtr((void *) ptr, NULL)) == NULL){ fprintf(stderr, "Could not create PyCObject for ptr %p to debug flag for module %s\n", (void * ) ptr, module_name); return GSL_EFAILED; } DEBUG_MESS(2, "Registering ptr %p for module %s", (void *) ptr, module_name); if(PyList_Append(debuglist, cobj) != 0){ return GSL_EFAILED; } *ptr = pygsl_debug_level; FUNC_MESS_END(); return GSL_SUCCESS; #endif GSL_ERROR("Why does it try to add the pointer? Should use the compile time value DEBUG!", GSL_ESANITY); } static PyObject * PyGSL_set_debug_level(PyObject *self, PyObject *args) { FUNC_MESS_BEGIN(); #if DEBUG == 1 { PyObject *o; int tmp, i, max, *ptr; if(!PyArg_ParseTuple(args, "i", &tmp)) return NULL; if(tmp >= 0 && tmp