summaryrefslogtreecommitdiffstats
path: root/dynl.c
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:24 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:24 -0800
commit1edcb9b62a1a520eddae8403c19d841c9b18737f (patch)
treebc0a43d9b3905726a76ed6f0528b54275f23d082 /dynl.c
parent5ca6e8e6a4e5c022a6fb5d28f30219c22c99eda8 (diff)
downloadscm-1edcb9b62a1a520eddae8403c19d841c9b18737f.tar.gz
scm-1edcb9b62a1a520eddae8403c19d841c9b18737f.zip
Import Upstream version 5b3upstream/5b3
Diffstat (limited to 'dynl.c')
-rw-r--r--dynl.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/dynl.c b/dynl.c
index 6cd3b58..7e90a8a 100644
--- a/dynl.c
+++ b/dynl.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+/* Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -156,8 +156,7 @@ static iproc subr1s[] = {
void init_dynl()
{
# ifndef RTL
- if (!execpath) execpath = dld_find_executable(CHARS(CAR(progargs)));
- if (dld_init(execpath)) {
+ if ((!execpath) || dld_init(execpath)) {
dld_perror("DLD:");
/* wta(CAR(progargs), "couldn't init", "dld"); */
return;
@@ -420,6 +419,35 @@ SCM l_dyn_call(symb, shl)
/* *loc_loadpath = oloadpath; */
return BOOL_T;
}
+static char s_main_call[] = "dyn:main-call";
+SCM l_dyn_main_call(symb, shl, args)
+ SCM symb, shl, args;
+{
+ int i;
+ int (*func)P((int argc, char **argv)) = 0;
+ char **argv;
+/* SCM oloadpath = *loc_loadpath; */
+ ASSERT(NIMP(symb) && STRINGP(symb), symb, ARG1, s_main_call);
+ ASSERT(NIMP(shl) && CAR(shl)==tc16_shl, shl, ARG2, s_main_call);
+ DEFER_INTS;
+ func = dlsym(SHL(shl), CHARS(symb));
+ if (!func) {
+ const char *dlr = dlerror();
+ ALLOW_INTS;
+ if (dlr) puts(dlr);
+ return BOOL_F;
+ }
+ argv = makargvfrmstrs(args, s_main_call);
+ ALLOW_INTS;
+/* *loc_loadpath = linkpath; */
+ i = (*func) ((int)ilength(args), argv);
+/* *loc_loadpath = oloadpath; */
+ DEFER_INTS;
+ must_free_argv(argv);
+ ALLOW_INTS;
+ return MAKINUM(0L+i);
+}
+
static char s_unlink[] = "dyn:unlink";
SCM l_dyn_unlink(shl)
SCM shl;
@@ -443,6 +471,7 @@ void init_dynl()
tc16_shl = newsmob(&shlsmob);
init_iprocs(subr1s, tc7_subr_1);
make_subr(s_call, tc7_subr_2, l_dyn_call);
+ make_subr(s_main_call, tc7_lsubr_2, l_dyn_main_call);
add_feature("sun-dl");
}
#endif /* SUN_DL */