Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel: remove SyOriginalArgv & SyOriginalArgc #5887

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 22 additions & 8 deletions src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1052,13 +1052,22 @@
** The general idea is to put all kernel-specific info in here, and clean up
** the assortment of global variables previously used
*/
static Obj KernelArgs;

static void InitKernelArgs(int argc, char * argv[])
{
// make command line available to GAP level
KernelArgs = NEW_PLIST_IMM(T_PLIST, argc);
for (int i = 0; i < argc; i++) {
PushPlist(KernelArgs, MakeImmString(argv[i]));
}
}

static Obj FuncKERNEL_INFO(Obj self)
{
Obj res = NEW_PREC(0);
UInt r;
Obj tmp;
UInt i;

AssPRec(res, RNamName("GAP_ARCHITECTURE"), MakeImmString(GAPARCH));
AssPRec(res, RNamName("KERNEL_VERSION"), MakeImmString(SyKernelVersion));
Expand All @@ -1073,15 +1082,11 @@
AssPRec(res, RNamName("uname"), SyGetOsRelease());

// make command line available to GAP level
tmp = NEW_PLIST_IMM(T_PLIST, 16);
for (i = 0; SyOriginalArgv[i]; i++) {
PushPlist(tmp, MakeImmString(SyOriginalArgv[i]));
}
AssPRec(res, RNamName("COMMAND_LINE"), tmp);
AssPRec(res, RNamName("COMMAND_LINE"), KernelArgs);

// make environment available to GAP level
tmp = NEW_PREC(0);
for (i = 0; environ[i]; i++) {
for (int i = 0; environ[i]; i++) {
Char * p = strchr(environ[i], '=');
if (!p) {
// should never happen...
Expand Down Expand Up @@ -1317,6 +1322,7 @@
{
// register global bags with the garbage collector
InitGlobalBag( &WindowCmdString, "src/gap.c:WindowCmdString" );
InitGlobalBag( &KernelArgs, "src/gap.c:KernelArgs" );

// init filters and functions
InitHdlrFuncsFromTable( GVarFuncs );
Expand Down Expand Up @@ -1434,8 +1440,10 @@
char * argv [],
UInt handleSignals )
{
const int argc = *pargc;

// initialize the basic system and gasman
InitSystem( *pargc, argv, handleSignals );
InitSystem(argc, argv, handleSignals);

// Initialise memory -- have to do this here to make sure we are at top of C stack
InitBags(
Expand Down Expand Up @@ -1490,6 +1498,9 @@
LoadWorkspace(SyRestoring);
SyRestoring = NULL;

// make command line available to GAP level
InitKernelArgs(argc, argv);

Check warning on line 1502 in src/gap.c

View check run for this annotation

Codecov / codecov/patch

src/gap.c#L1502

Added line #L1502 was not covered by tests

// Call POST_RESTORE which is a GAP function that now takes control,
// calls the post restore functions and then runs a GAP session
Obj POST_RESTORE = ValGVar(GVarName("POST_RESTORE"));
Expand All @@ -1513,6 +1524,9 @@
// check initialisation
ModulesCheckInit();

// make command line available to GAP level
InitKernelArgs(argc, argv);

// read the init files
// this now actually runs the GAP session, we only get
// past here when we're about to exit.
Expand Down
2 changes: 0 additions & 2 deletions src/sysopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ extern Char * SyRestoring;

extern UInt SyInitializing;

extern Char ** SyOriginalArgv;
extern UInt SyOriginalArgc;

/****************************************************************************
**
Expand Down
9 changes: 0 additions & 9 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,11 +541,6 @@ static const struct optInfo options[] = {
{ 0, "", 0, 0, 0}};


Char ** SyOriginalArgv;
UInt SyOriginalArgc;



void InitSystem (
Int argc,
Char * argv [],
Expand Down Expand Up @@ -600,10 +595,6 @@ void InitSystem (
SyInstallAnswerIntr();
}

// save the original command line for export to GAP
SyOriginalArgc = argc;
SyOriginalArgv = argv;

// scan the command line for options that we have to process in the kernel
// we just scan the whole command line looking for the keys for the options we recognise
// anything else will presumably be dealt with in the library
Expand Down
Loading