mirror of
https://git.telodendria.io/Telodendria/Cytoplasm.git
synced 2024-11-25 21:48:49 +03:00
Push Main return value into MainArgs.
This prevents weird things from happing on some architectures.
This commit is contained in:
parent
3a78e50044
commit
0e60cd5195
2 changed files with 11 additions and 11 deletions
2
make.sh
2
make.sh
|
@ -36,7 +36,7 @@ addprefix() {
|
||||||
: "${LDFLAGS:=-lm -pthread}"
|
: "${LDFLAGS:=-lm -pthread}"
|
||||||
|
|
||||||
if [ "${DEBUG}" = "1" ]; then
|
if [ "${DEBUG}" = "1" ]; then
|
||||||
CFLAGS="${CFLAGS} -o0 -g"
|
CFLAGS="${CFLAGS} -O0 -g"
|
||||||
LD_EXTRA=""
|
LD_EXTRA=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
20
src/RtStub.c
20
src/RtStub.c
|
@ -43,18 +43,18 @@ typedef struct MainArgs
|
||||||
{
|
{
|
||||||
Array *args;
|
Array *args;
|
||||||
HashMap *env;
|
HashMap *env;
|
||||||
|
int ret;
|
||||||
} MainArgs;
|
} MainArgs;
|
||||||
|
|
||||||
static void *
|
static void *
|
||||||
MainThread(void *argp)
|
MainThread(void *argp)
|
||||||
{
|
{
|
||||||
long ret;
|
|
||||||
MainArgs *args = argp;
|
MainArgs *args = argp;
|
||||||
|
|
||||||
args = argp;
|
args = argp;
|
||||||
ret = Main(args->args, args->env);
|
args->ret = Main(args->args, args->env);
|
||||||
|
|
||||||
return (void *) ret;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -62,7 +62,6 @@ main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
pthread_t mainThread;
|
pthread_t mainThread;
|
||||||
size_t i;
|
size_t i;
|
||||||
int ret;
|
|
||||||
|
|
||||||
char *key;
|
char *key;
|
||||||
char *val;
|
char *val;
|
||||||
|
@ -74,13 +73,14 @@ main(int argc, char **argv)
|
||||||
|
|
||||||
args.args = NULL;
|
args.args = NULL;
|
||||||
args.env = NULL;
|
args.env = NULL;
|
||||||
|
args.ret = EXIT_FAILURE;
|
||||||
|
|
||||||
args.args = ArrayCreate();
|
args.args = ArrayCreate();
|
||||||
|
|
||||||
if (!args.args)
|
if (!args.args)
|
||||||
{
|
{
|
||||||
Log(LOG_ERR, "Bootstrap error: Unable to allocate memory for arguments.");
|
Log(LOG_ERR, "Bootstrap error: Unable to allocate memory for arguments.");
|
||||||
ret = EXIT_FAILURE;
|
args.ret = EXIT_FAILURE;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ main(int argc, char **argv)
|
||||||
if (!args.env)
|
if (!args.env)
|
||||||
{
|
{
|
||||||
Log(LOG_ERR, "Bootstrap error: Unable to allocate memory for environment.");
|
Log(LOG_ERR, "Bootstrap error: Unable to allocate memory for environment.");
|
||||||
ret = EXIT_FAILURE;
|
args.ret = EXIT_FAILURE;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,15 +117,15 @@ main(int argc, char **argv)
|
||||||
if (pthread_create(&mainThread, NULL, MainThread, &args) != 0)
|
if (pthread_create(&mainThread, NULL, MainThread, &args) != 0)
|
||||||
{
|
{
|
||||||
Log(LOG_ERR, "Bootstrap error: Unable to create main thread.");
|
Log(LOG_ERR, "Bootstrap error: Unable to create main thread.");
|
||||||
ret = EXIT_FAILURE;
|
args.ret = EXIT_FAILURE;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pthread_join(mainThread, (void **) &ret) != 0)
|
if (pthread_join(mainThread, NULL) != 0)
|
||||||
{
|
{
|
||||||
/* Should never happen */
|
/* Should never happen */
|
||||||
Log(LOG_ERR, "Unable to join main thread.");
|
Log(LOG_ERR, "Unable to join main thread.");
|
||||||
ret = EXIT_FAILURE;
|
args.ret = EXIT_FAILURE;
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,5 +158,5 @@ finish:
|
||||||
|
|
||||||
MemoryFreeAll();
|
MemoryFreeAll();
|
||||||
|
|
||||||
return ret;
|
return args.ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue