/**1* @file stdsage.c2*3* Some global C stuff that gets imported into pyrex modules.4*5*/67/******************************************************************************8* Copyright (C) 2006 William Stein <[email protected]>9* 2006 David Harvey <[email protected]>10* 2006 Martin Albrecht <[email protected]>11* 2011 Jeroen Demeyer <[email protected]>12*13* Distributed under the terms of the GNU General Public License (GPL)14* as published by the Free Software Foundation; either version 2 of15* the License, or (at your option) any later version.16* http://www.gnu.org/licenses/17****************************************************************************/181920#include "stdsage.h"21#include "interrupt.h"2223PyObject* global_empty_tuple;2425void init_global_empty_tuple(void) {26_CALLED_ONLY_ONCE;2728global_empty_tuple = PyTuple_New(0);29}303132/*33This function gets called whenever NTL calls Error().34s is the error message generated by NTL.35We just copy the error message into a global buffer, and then abort() to run36the usual interrupt machinery.37*/38void global_NTL_error_callback(const char* s, void* context)39{40set_sage_signal_handler_message(s);41abort();42}434445/* This is called once during Sage startup. On some platforms like46* Cygwin, this is also called from init_csage_module(). */47void init_csage() {48init_global_empty_tuple();49init_memory_functions();50setup_sage_signal_handler();51setup_NTL_error_callback(global_NTL_error_callback, NULL);52}5354/* This is called once for every single module that links in stdsage */55void init_csage_module() {56#if defined(__CYGWIN32__)57init_csage();58#endif59}606162