Skip to content

Commit

Permalink
allow signal handling by the GAP kernel to be disabled for embedding …
Browse files Browse the repository at this point in the history
…in other applications
  • Loading branch information
embray committed Jan 31, 2019
1 parent 2013da1 commit 1ba3127
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 18 deletions.
7 changes: 4 additions & 3 deletions src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ int realmain( int argc, char * argv[] )
SetupGAPLocation(argc, argv);

/* initialize everything and read init.g which runs the GAP session */
InitializeGap( &argc, argv );
InitializeGap( &argc, argv, 1 );
if (!STATE(UserHasQUIT)) { /* maybe the user QUIT from the initial
read of init.g somehow*/
/* maybe compile in which case init.g got skipped */
Expand Down Expand Up @@ -1698,10 +1698,11 @@ static Obj POST_RESTORE;

void InitializeGap (
int * pargc,
char * argv [] )
char * argv [],
UInt handleSignals )
{
/* initialize the basic system and gasman */
InitSystem( *pargc, argv );
InitSystem( *pargc, argv, handleSignals );

/* Initialise memory -- have to do this here to make sure we are at top of C stack */
InitBags(SyStorMin,
Expand Down
4 changes: 2 additions & 2 deletions src/gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ enum {

/****************************************************************************
**
*F InitializeGap( <argc>, <argv> ) . . . . . . . . . . . . . . . . init GAP
*F InitializeGap( <argc>, <argv>, <handleSignals> ) . . . . . . . init GAP
*/
void InitializeGap(int * pargc, char * argv[]);
void InitializeGap(int * pargc, char * argv[], UInt handleSignals);


/****************************************************************************
Expand Down
5 changes: 3 additions & 2 deletions src/libgap-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
void GAP_Initialize(int argc,
char ** argv,
GAP_CallbackFunc markBagsCallback,
GAP_CallbackFunc errorCallback)
GAP_CallbackFunc errorCallback,
int handleSignals)
{
InitializeGap(&argc, argv);
InitializeGap(&argc, argv, handleSignals);
SetExtraMarkFuncBags(markBagsCallback);
STATE(JumpToCatchCallback) = errorCallback;

Expand Down
3 changes: 2 additions & 1 deletion src/libgap-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ typedef void (*GAP_CallbackFunc)(void);
void GAP_Initialize(int argc,
char ** argv,
GAP_CallbackFunc markBagsCallback,
GAP_CallbackFunc errorCallback);
GAP_CallbackFunc errorCallback,
int handleSignals);


////
Expand Down
7 changes: 5 additions & 2 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,8 @@ UInt SyOriginalArgc;

void InitSystem (
Int argc,
Char * argv [] )
Char * argv [],
UInt handleSignals )
{
Char * *ptrlist;
UInt i; /* loop variable */
Expand Down Expand Up @@ -1098,7 +1099,9 @@ void InitSystem (
rl_initialize ();
#endif

SyInstallAnswerIntr();
if (handleSignals) {
SyInstallAnswerIntr();
}

#if defined(SYS_DEFAULT_PATHS)
SySetGapRootPath( SYS_DEFAULT_PATHS );
Expand Down
10 changes: 5 additions & 5 deletions src/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -510,16 +510,16 @@ Int RegisterSyLongjmpObserver(voidfunc);

/****************************************************************************
**
*F InitSystem( <argc>, <argv> ) . . . . . . . . . initialize system package
*F InitSystem( <argc>, <argv>, <handleSignals> ) . initialize system package
**
** 'InitSystem' is called very early during the initialization from 'main'.
** It is passed the command line array <argc>, <argv> to look for options.
**
** For UNIX it initializes the default files 'stdin', 'stdout' and 'stderr',
** installs the handler 'syAnswerIntr' to answer the user interrupts
** '<ctr>-C', scans the command line for options, sets up the GAP root paths,
** locates the '.gaprc' file (if any), and more.
** and if handleSignals is non-zero installs the handler 'syAnswerIntr' to
** answer the user interrupts '<ctr>-C', scans the command line for options,
** sets up the GAP root paths, locates the '.gaprc' file (if any), and more.
*/
void InitSystem(Int argc, Char * argv[]);
void InitSystem(Int argc, Char * argv[], UInt handleSignals);

#endif // GAP_SYSTEM_H
2 changes: 1 addition & 1 deletion tst/testlibgap/basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
int main(int argc, char ** argv)
{
printf("# Initializing GAP...\n");
GAP_Initialize(argc, argv, 0, 0);
GAP_Initialize(argc, argv, 0, 0, 1);
test_eval("1+2+3;");
test_eval("g:=FreeGroup(2);");
test_eval("a:=g.1;");
Expand Down
2 changes: 1 addition & 1 deletion tst/testlibgap/wscreate.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "common.h"
int main(int argc, char ** argv)
{
GAP_Initialize(argc, argv, 0, 0);
GAP_Initialize(argc, argv, 0, 0, 1);
test_eval("g:=FreeGroup(2);");
test_eval("a:=g.1;");
test_eval("b:=g.2;");
Expand Down
2 changes: 1 addition & 1 deletion tst/testlibgap/wsload.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ int main(int argc, char ** argv)
args[argc] = lpar;
args[argc+1] = wsname;
args[argc+2] = NULL;
GAP_Initialize(argc+2, args, 0, 0);
GAP_Initialize(argc+2, args, 0, 0, 1);
printf("# looking at saved stuff...\n");
test_eval("g;");
test_eval("a;");
Expand Down

0 comments on commit 1ba3127

Please sign in to comment.