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: consistent types for argc, argv #5897

Merged
merged 1 commit into from
Jan 8, 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
17 changes: 10 additions & 7 deletions src/gap.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,14 @@ static Obj FuncSHELL(Obj self,
return (Obj)0;
}

int realmain( int argc, char * argv[] )
int realmain(int argc, const char * argv[])
{
UInt type; // result of compile
Obj func; // function (compiler)
Int4 crc; // crc of file to compile

// initialize everything and read init.g which runs the GAP session
InitializeGap( &argc, argv, 1 );
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 @@ -1054,7 +1054,7 @@ static Obj FuncSHOULD_QUIT_ON_BREAK(Obj self)
*/
static Obj KernelArgs;

static void InitKernelArgs(int argc, char * argv[])
static void InitKernelArgs(int argc, const char * argv[])
{
// make command line available to GAP level
KernelArgs = NEW_PLIST_IMM(T_PLIST, argc);
Expand Down Expand Up @@ -1434,11 +1434,14 @@ StructInitInfo * InitInfoGap ( void )
** `PostRestore': Everything in `InitLibrary' execpt creating objects. In
** general `InitLibrary' will create all objects and then calls
** `PostRestore'. This function is only used when restoring.
**
** Note that this function does not take the usual argc, argv pair for a
** list of arguments, but instead a pointer to argc is passed. This is a
** trick to get a pointer to the execution stack on the level of the calling
** function. We use the resulting pointer as a hint to the garbage collector
** as to where the execution stack (might) start.
*/
void InitializeGap (
int * pargc,
char * argv [],
UInt handleSignals )
void InitializeGap(int * pargc, const char * argv[], BOOL handleSignals)
{
const int argc = *pargc;

Expand Down
2 changes: 1 addition & 1 deletion src/gap.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ BOOL IsUsingLibGap(void);
**
*F InitializeGap( <argc>, <argv>, <handleSignals> ) . . . . . . . init GAP
*/
void InitializeGap(int * pargc, char * argv[], UInt handleSignals);
void InitializeGap(int * pargc, const char * argv[], BOOL handleSignals);


/****************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/gasman.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,7 +1139,7 @@

Int EnableMemCheck = 0;

Int enableMemCheck(Char ** argv, void * dummy)
int enableMemCheck(const char * argv[], void * dummy)

Check warning on line 1142 in src/gasman.c

View check run for this annotation

Codecov / codecov/patch

src/gasman.c#L1142

Added line #L1142 was not covered by tests
{
fputs("# Warning: --enableMemCheck causes SEVERE slowdowns. Starting GAP may take several days!\n", stderr);
EnableMemCheck = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/gasman_intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ void CallbackForAllBags(void (*func)(Bag));
**
*/
#ifdef GAP_MEM_CHECK
Int enableMemCheck(Char ** argv, void * dummy);
int enableMemCheck(const char * argv[], void * dummy);
extern Int EnableMemCheck;
#endif

Expand Down
12 changes: 6 additions & 6 deletions src/hpc/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -299,13 +299,13 @@ void InitMainThread(void)
TLS(CountActive) = 1;
}

static NOINLINE void RunThreadedMain2(int (*mainFunction)(int, char **),
static NOINLINE void RunThreadedMain2(int (*mainFunction)(int, const char **),
int argc,
char ** argv);
const char ** argv);

void RunThreadedMain(int (*mainFunction)(int, char **),
void RunThreadedMain(int (*mainFunction)(int, const char **),
int argc,
char ** argv)
const char ** argv)
{
#ifndef USE_NATIVE_TLS
#ifdef STACK_GROWS_UP
Expand Down Expand Up @@ -335,9 +335,9 @@ void RunThreadedMain(int (*mainFunction)(int, char **),
RunThreadedMain2(mainFunction, argc, argv);
}

static void RunThreadedMain2(int (*mainFunction)(int, char **),
static void RunThreadedMain2(int (*mainFunction)(int, const char **),
int argc,
char ** argv)
const char ** argv)
{
int i;
static pthread_mutex_t main_thread_mutex;
Expand Down
4 changes: 2 additions & 2 deletions src/hpc/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ void AddGCRoots(void);
void RemoveGCroots(void);

void RunThreadedMain(
int (*mainFunction)(int, char **),
int (*mainFunction)(int, const char **),
int argc,
char **argv );
const char **argv );

void CreateMainRegion(void);
Obj RunThread(void (*start)(void *), void *arg);
Expand Down
2 changes: 1 addition & 1 deletion src/libgap-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void GAP_Initialize(int argc,
{
UsingLibGap = TRUE;

InitializeGap(&argc, argv, handleSignals);
InitializeGap(&argc, (const char **)argv, handleSignals);
SetExtraMarkFuncBags(markBagsCallback);
STATE(JumpToCatchCallback) = errorCallback;

Expand Down
4 changes: 2 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include <mach-o/dyld.h>
#endif

extern int realmain(int argc, char * argv[]);
extern int realmain(int argc, const char * argv[]);

/****************************************************************************
**
Expand Down Expand Up @@ -188,7 +188,7 @@ static void SetupInitialGapRoot(const char * argv0)
}
#endif

int main(int argc, char * argv[])
int main(int argc, const char * argv[])
{
InstallBacktraceHandlers();
SetupInitialGapRoot(argv[0]);
Expand Down
8 changes: 4 additions & 4 deletions src/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@


static void
enableAtStartup(char * filename, Int repeats, TickMethod tickMethod)
enableAtStartup(const char * filename, Int repeats, TickMethod tickMethod)
{
if (profileState.status == Profile_Active) {
Panic("-P or -C can only be passed once\n");
Expand Down Expand Up @@ -685,7 +685,7 @@
// This function is for when GAP is started with -c, and
// enables profiling at startup. If anything goes wrong,
// we quit straight away.
Int enableCodeCoverageAtStartup( Char **argv, void * dummy)
int enableCodeCoverageAtStartup(const char * argv[], void * dummy)
{
enableAtStartup(argv[0], 0, Tick_Mem);
return 1;
Expand All @@ -694,7 +694,7 @@
// This function is for when GAP is started with -P, and
// enables profiling at startup. If anything goes wrong,
// we quit straight away.
Int enableProfilingAtStartup( Char **argv, void * dummy)
int enableProfilingAtStartup(const char * argv[], void * dummy)

Check warning on line 697 in src/profile.c

View check run for this annotation

Codecov / codecov/patch

src/profile.c#L697

Added line #L697 was not covered by tests
{
TickMethod tickMethod = Tick_WallTime;
#ifdef HAVE_GETTIMEOFDAY
Expand All @@ -708,7 +708,7 @@
return 1;
}

Int enableMemoryProfilingAtStartup(Char ** argv, void * dummy)
int enableMemoryProfilingAtStartup(const char * argv[], void * dummy)

Check warning on line 711 in src/profile.c

View check run for this annotation

Codecov / codecov/patch

src/profile.c#L711

Added line #L711 was not covered by tests
{
enableAtStartup(argv[0], 1, Tick_Mem);
return 1;
Expand Down
6 changes: 3 additions & 3 deletions src/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

#include "common.h"

Int enableProfilingAtStartup(Char ** argv, void * dummy);
Int enableMemoryProfilingAtStartup(Char ** argv, void * dummy);
Int enableCodeCoverageAtStartup(Char ** argv, void * dummy);
int enableProfilingAtStartup(const char * argv[], void * dummy);
int enableMemoryProfilingAtStartup(const char * argv[], void * dummy);
int enableCodeCoverageAtStartup(const char * argv[], void * dummy);
void pauseProfiling(void);
void unpauseProfiling(void);

Expand Down
10 changes: 5 additions & 5 deletions src/sysopt.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ extern UInt SyCTRD;
*V SyCompileName . . . . . . . . . . . . . . . . . . . . . . with this name
*V SyCompileMagic1 . . . . . . . . . . . . . . . . . . and this magic string
*/
extern Int SyCompilePlease;
extern Char * SyCompileOutput;
extern Char * SyCompileInput;
extern Char * SyCompileName;
extern Char * SyCompileMagic1;
extern BOOL SyCompilePlease;
extern const char * SyCompileOutput;
extern const char * SyCompileInput;
extern const char * SyCompileName;
extern const char * SyCompileMagic1;


/****************************************************************************
Expand Down
53 changes: 25 additions & 28 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,11 @@
*V SyCompileName . . . . . . . . . . . . . . . . . . . . . . with this name
*V SyCompileMagic1 . . . . . . . . . . . . . . . . . . and this magic string
*/
Int SyCompilePlease;
Char * SyCompileOutput;
Char * SyCompileInput;
Char * SyCompileName;
Char * SyCompileMagic1;
BOOL SyCompilePlease;
const char * SyCompileOutput;
const char * SyCompileInput;
const char * SyCompileName;
const char * SyCompileMagic1;


/****************************************************************************
Expand Down Expand Up @@ -322,7 +322,7 @@
static const UInt maxmem = 4000000000UL;
#endif

static BOOL ParseMemory(Char * s, UInt *result)
static BOOL ParseMemory(const char * s, UInt * result)
{
char * end;
const double size = strtod(s, &end);
Expand Down Expand Up @@ -372,25 +372,25 @@
struct optInfo {
Char shortkey;
Char longkey[50];
Int (*handler)(Char **, void *);
int (*handler)(const char * argv[], void *);
void *otherArg;
UInt minargs;
};


static Int toggle( Char ** argv, void *Variable )
static int toggle(const char * argv[], void * Variable)
{
UInt * variable = (UInt *) Variable;
*variable = !*variable;
return 0;
}

#ifdef HPCGAP
static Int storePosInteger( Char **argv, void *Where )
static int storePosInteger(const char * argv[], void * Where)
{
UInt *where = (UInt *)Where;
UInt n;
Char *p = argv[0];
const char *p = argv[0];

Check warning on line 393 in src/system.c

View check run for this annotation

Codecov / codecov/patch

src/system.c#L393

Added line #L393 was not covered by tests
n = 0;
while (IsDigit(*p)) {
n = n * 10 + (*p-'0');
Expand All @@ -406,16 +406,16 @@
#endif

#ifdef GAP_ENABLE_SAVELOAD
static Int storeString( Char **argv, void *Where )
static int storeString(const char * argv[], void * Where)
{
Char **where = (Char **)Where;
*where = argv[0];
return 1;
const char ** where = (const char **)Where;
*where = argv[0];
return 1;
}
#endif

#ifdef USE_GASMAN
static Int storeMemory( Char **argv, void *Where )
static int storeMemory(const char * argv[], void * Where)
{
UInt * where = (UInt *)Where;
if (!ParseMemory(argv[0], where))
Expand All @@ -425,7 +425,7 @@
#endif

#if defined(USE_GASMAN) || defined(USE_BOEHM_GC)
static Int storeMemory2( Char **argv, void *Where )
static int storeMemory2(const char * argv[], void * Where)
{
UInt * where = (UInt *)Where;
if (!ParseMemory(argv[0], where))
Expand All @@ -435,9 +435,9 @@
}
#endif

static Int processCompilerArgs( Char **argv, void * dummy)
static int processCompilerArgs(const char * argv[], void * dummy)
{
SyCompilePlease = 1;
SyCompilePlease = TRUE;
SyCompileOutput = argv[0];
SyCompileInput = argv[1];
SyCompileName = argv[2];
Expand All @@ -446,21 +446,21 @@
}

#ifdef GAP_ENABLE_SAVELOAD
static Int unsetString( Char **argv, void *Where)
static int unsetString(const char * argv[], void * Where)
{
*(Char **)Where = (Char *)0;
return 0;
}
#endif

static Int forceLineEditing( Char **argv,void *Level)
static int forceLineEditing(const char * argv[], void * Level)
{
UInt level = (UInt)Level;
SyLineEdit = level;
return 0;
}

static Int setGapRootPath( Char **argv, void *Dummy)
static int setGapRootPath(const char * argv[], void * Dummy)
{
SySetGapRootPath( argv[0] );
return 1;
Expand All @@ -470,7 +470,7 @@
#ifndef GAP_MEM_CHECK
// Provide stub with helpful error message

static Int enableMemCheck(Char ** argv, void * dummy)
static int enableMemCheck(const char * argv[], void * dummy)
{
fputs("# Error: --enableMemCheck not supported by this copy of GAP\n", stderr);
fputs(" pass --enable-memory-checking to ./configure\n", stderr);
Expand All @@ -479,7 +479,7 @@
#endif


static Int printVersion(Char ** argv, void * dummy)
static int printVersion(const char * argv[], void * dummy)
{
fputs("GAP ", stdout);
fputs(SyBuildVersion, stdout);
Expand Down Expand Up @@ -540,17 +540,14 @@
{ 0, "", 0, 0, 0}};


void InitSystem (
Int argc,
Char * argv [],
UInt handleSignals )
void InitSystem(int argc, const char * argv[], BOOL handleSignals)
{
UInt i; // loop variable
Int res; // return from option processing function

// Initialize global and static variables
SyCTRD = 1;
SyCompilePlease = 0;
SyCompilePlease = FALSE;
SyDebugLoading = 0;
SyLineEdit = 1;
#ifdef HAVE_LIBREADLINE
Expand Down
2 changes: 1 addition & 1 deletion src/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,6 @@ void Panic_(const char * file, int line, const char * fmt, ...) NORETURN
** 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[], UInt handleSignals);
void InitSystem(int argc, const char * argv[], BOOL handleSignals);

#endif // GAP_SYSTEM_H
Loading