GC_PROTECT'ed the necessary variables (specifically, where >1 arg to

a function 'may GC')
This commit is contained in:
steven-jenkins 2002-02-11 15:38:35 +00:00
parent bf57bfb356
commit 65407be26c
1 changed files with 50 additions and 17 deletions

View File

@ -61,17 +61,18 @@ s48_value wait_pid(s48_value s48_pid, s48_value s48_flags)
pid_t pid = (pid_t) s48_extract_integer (s48_pid);
int flags = s48_extract_integer (s48_flags);
pid_t result_pid;
s48_value sch_retval = S48_UNSPECIFIC;
s48_value sch_result_pid = S48_UNSPECIFIC;
s48_value sch_status = S48_UNSPECIFIC;
s48_value sch_status_list = S48_UNSPECIFIC;
s48_value sch_retval = S48_UNSPECIFIC;
S48_DECLARE_GC_PROTECT(4);
S48_DECLARE_GC_PROTECT(3);
S48_GC_PROTECT_4(sch_result_pid, sch_status, sch_status_list, sch_retval);
S48_GC_PROTECT_3(sch_result_pid, sch_status, sch_status_list);
result_pid = waitpid(pid, &status, flags);
if (result_pid == -1)
if (errno == ECHILD) sch_result_pid = s48_enter_fixnum (0);
if (errno == ECHILD) sch_result_pid = s48_enter_fixnum(0);
else s48_raise_os_error_2 (errno, s48_pid, s48_flags);
else {
sch_result_pid = s48_enter_integer (result_pid);
@ -79,7 +80,7 @@ s48_value wait_pid(s48_value s48_pid, s48_value s48_flags)
}
sch_status_list = s48_cons (sch_status, S48_NULL);
sch_retval = s48_cons (sch_result_pid, sch_status_list);
S48_GC_UNPROTECT();
return sch_retval;
@ -126,8 +127,8 @@ s48_value scheme_exec(s48_value prog, s48_value argv, s48_value env)
}
s48_stop_alarm_interrupts();
execve(s48_extract_string (prog), unix_argv, unix_env); /* Do it. */
s48_start_alarm_interrupts();
e = errno;
s48_start_alarm_interrupts();
if( env != S48_TRUE ) {
Free(unix_env);
}
@ -164,12 +165,16 @@ s48_value scsh_fork()
s48_value scheme_pipe()
{
int fds[2];
s48_value sch_retval = S48_UNSPECIFIC;
if(pipe(fds) == -1)
s48_raise_os_error(errno);
else
return s48_cons (s48_enter_fixnum (fds[0]),
s48_cons (s48_enter_fixnum (fds [1]),
S48_NULL));
else {
sch_retval = s48_cons(s48_enter_fixnum(fds[0]),
s48_cons(s48_enter_fixnum (fds[1]), S48_NULL));
}
return sch_retval;
}
s48_value scsh_kill (s48_value sch_pid, s48_value sch_signal)
@ -317,14 +322,37 @@ s48_value scheme_cwd()
s48_value process_times()
{
struct tms tms;
s48_value sch_result_utime = S48_UNSPECIFIC;
s48_value sch_result_stime = S48_UNSPECIFIC;
s48_value sch_result_cutime = S48_UNSPECIFIC;
s48_value sch_result_cstime = S48_UNSPECIFIC;
s48_value sch_result_retval = S48_UNSPECIFIC;
S48_DECLARE_GC_PROTECT(4);
clock_t t = times(&tms);
if (t == -1) s48_raise_os_error(errno);
return
s48_cons(s48_enter_integer (tms.tms_utime),
s48_cons(s48_enter_integer (tms.tms_stime),
s48_cons(s48_enter_integer (tms.tms_cutime),
s48_cons(s48_enter_integer (tms.tms_cstime),
S48_NULL))));
S48_GC_PROTECT_4(sch_result_utime,
sch_result_stime,
sch_result_cutime,
sch_result_cstime);
sch_result_utime = s48_enter_integer(tms.tms_utime);
sch_result_stime = s48_enter_integer(tms.tms_stime);
sch_result_cutime = s48_enter_integer(tms.tms_cutime);
sch_result_cstime = s48_enter_integer(tms.tms_cstime);
sch_result_retval = s48_cons(sch_result_utime,
s48_cons(sch_result_stime,
s48_cons(sch_result_cutime,
s48_cons(sch_result_cstime, S48_NULL))));
S48_GC_UNPROTECT();
return sch_result_retval;
}
s48_value cpu_clock_ticks_per_sec()
@ -671,12 +699,17 @@ s48_value get_groups()
get_groups();
}
else{
S48_DECLARE_GC_PROTECT(1);
S48_GC_PROTECT_1(l);
while (i > 0){
l = s48_cons(s48_enter_integer(gp[--i]), l);
}
if (veclen > 20) Free(gp);
S48_GC_UNPROTECT();
return l;
}
}