mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2025-12-30 22:30:51 -08:00
Implemented mp_process_yield (Built on Dan Corkill's patches)
This commit is contained in:
parent
7ca1c3f2e2
commit
d49b134654
10 changed files with 149 additions and 0 deletions
|
|
@ -1073,6 +1073,7 @@ EXPORTS
|
|||
mp_make_process
|
||||
mp_process_active_p
|
||||
mp_process_enable
|
||||
mp_process_yield
|
||||
;mp_process_interrupt
|
||||
mp_process_kill
|
||||
mp_process_name
|
||||
|
|
|
|||
|
|
@ -211,6 +211,8 @@ typedef unsigned int uint32_t;
|
|||
#define HAVE_LONG_LONG 1
|
||||
/* the tzset() function gets the current time zone */
|
||||
#define HAVE_TZSET 1
|
||||
/* whether we have sched_yield() that gives priority to other threads */
|
||||
/* #undef HAVE_SCHED_YIELD */
|
||||
|
||||
/* what characters are used to mark beginning of new line */
|
||||
#define ECL_NEWLINE_IS_CRLF 1
|
||||
|
|
|
|||
|
|
@ -1504,6 +1504,7 @@ cl_symbols[] = {
|
|||
{MP_ "MAKE-PROCESS", MP_ORDINARY, mp_make_process, -1, OBJNULL},
|
||||
{MP_ "PROCESS-ACTIVE-P", MP_ORDINARY, mp_process_active_p, 1, OBJNULL},
|
||||
{MP_ "PROCESS-ENABLE", MP_ORDINARY, mp_process_enable, 1, OBJNULL},
|
||||
{MP_ "PROCESS-YIELD", MP_ORDINARY, mp_process_yield, 0, OBJNULL},
|
||||
{MP_ "PROCESS-KILL", MP_ORDINARY, mp_process_kill, 1, OBJNULL},
|
||||
{MP_ "PROCESS-NAME", MP_ORDINARY, mp_process_name, 1, OBJNULL},
|
||||
{MP_ "PROCESS-PRESET", MP_ORDINARY, mp_process_preset, -1, OBJNULL},
|
||||
|
|
|
|||
|
|
@ -1504,6 +1504,7 @@ cl_symbols[] = {
|
|||
{MP_ "MAKE-PROCESS","mp_make_process"},
|
||||
{MP_ "PROCESS-ACTIVE-P","mp_process_active_p"},
|
||||
{MP_ "PROCESS-ENABLE","mp_process_enable"},
|
||||
{MP_ "PROCESS-YIELD","mp_process_yield"},
|
||||
{MP_ "PROCESS-KILL","mp_process_kill"},
|
||||
{MP_ "PROCESS-NAME","mp_process_name"},
|
||||
{MP_ "PROCESS-PRESET","mp_process_preset"},
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@
|
|||
#ifdef HAVE_GETTIMEOFDAY
|
||||
# include <sys/time.h>
|
||||
#endif
|
||||
#ifdef HAVE_SCHED_YIELD
|
||||
# include <sched.h>
|
||||
#endif
|
||||
|
||||
#ifndef WITH___THREAD
|
||||
static pthread_key_t cl_env_key;
|
||||
|
|
@ -207,6 +210,17 @@ mp_process_kill(cl_object process)
|
|||
@(return Ct)
|
||||
}
|
||||
|
||||
cl_object
|
||||
mp_process_yield(void)
|
||||
{
|
||||
#ifdef HAVE_SCHED_YIELD
|
||||
sched_yield();
|
||||
#else
|
||||
sleep(0); /* Use sleep(0) to yield to a >= priority thread */
|
||||
#endif
|
||||
@(return)
|
||||
}
|
||||
|
||||
cl_object
|
||||
mp_process_enable(cl_object process)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@
|
|||
#include <signal.h>
|
||||
#include <ecl/ecl.h>
|
||||
#include <ecl/internal.h>
|
||||
#ifdef HAVE_SCHED_YIELD
|
||||
# include <sched.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* We have to put this explicit definition here because Boehm GC
|
||||
|
|
@ -219,6 +222,17 @@ mp_process_kill(cl_object process)
|
|||
return mp_interrupt_process(process, @'mp::exit-process');
|
||||
}
|
||||
|
||||
cl_object
|
||||
mp_process_yield(void)
|
||||
{
|
||||
#ifdef HAVE_SCHED_YIELD
|
||||
sched_yield();
|
||||
#else
|
||||
sleep(0); /* Use sleep(0) to yield to a >= priority thread */
|
||||
#endif
|
||||
@(return)
|
||||
}
|
||||
|
||||
cl_object
|
||||
mp_process_enable(cl_object process)
|
||||
{
|
||||
|
|
|
|||
111
src/configure
vendored
111
src/configure
vendored
|
|
@ -11775,6 +11775,117 @@ done
|
|||
|
||||
|
||||
|
||||
for ac_func in sched_yield
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
{ echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||
echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; }
|
||||
if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
/* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
|
||||
For example, HP-UX 11i <limits.h> declares gettimeofday. */
|
||||
#define $ac_func innocuous_$ac_func
|
||||
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func (); below.
|
||||
Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
|
||||
<limits.h> exists even on freestanding compilers. */
|
||||
|
||||
#ifdef __STDC__
|
||||
# include <limits.h>
|
||||
#else
|
||||
# include <assert.h>
|
||||
#endif
|
||||
|
||||
#undef $ac_func
|
||||
|
||||
/* Override any GCC internal prototype to avoid an error.
|
||||
Use char because int might match the return type of a GCC
|
||||
builtin and then its argument prototype would still apply. */
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
char $ac_func ();
|
||||
/* The GNU C library defines this for functions which it implements
|
||||
to always fail with ENOSYS. Some functions are actually named
|
||||
something starting with __ and the normal name is an alias. */
|
||||
#if defined __stub_$ac_func || defined __stub___$ac_func
|
||||
choke me
|
||||
#endif
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
return $ac_func ();
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext conftest$ac_exeext
|
||||
if { (ac_try="$ac_link"
|
||||
case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_link") 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
|
||||
{ (case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_try") 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; } &&
|
||||
{ ac_try='test -s conftest$ac_exeext'
|
||||
{ (case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_try") 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
eval "$as_ac_var=yes"
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
eval "$as_ac_var=no"
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
fi
|
||||
ac_res=`eval echo '${'$as_ac_var'}'`
|
||||
{ echo "$as_me:$LINENO: result: $ac_res" >&5
|
||||
echo "${ECHO_T}$ac_res" >&6; }
|
||||
if test `eval echo '${'$as_ac_var'}'` = yes; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
if test ${with_cxx} = "no" ; then
|
||||
ECL_CC=${CC}
|
||||
|
|
|
|||
|
|
@ -446,6 +446,8 @@ AC_CHECK_FUNCS( [nanosleep alarm times isnanf select setenv putenv] \
|
|||
AC_CHECK_FUNCS( [expf logf sqrtf cosf sinf tanf sinhf coshf tanhf] \
|
||||
[floorf ceilf fabsf frexpf ldexpf])
|
||||
|
||||
AC_CHECK_FUNCS( [sched_yield] )
|
||||
|
||||
dnl =====================================================================
|
||||
dnl Checks for system services
|
||||
|
||||
|
|
|
|||
|
|
@ -247,6 +247,8 @@ typedef unsigned @CL_FIXNUM_TYPE@ cl_hashkey;
|
|||
#undef HAVE_FABSF
|
||||
#undef HAVE_FREXPF
|
||||
#undef HAVE_LDEXPF
|
||||
/* whether we have sched_yield() that gives priority to other threads */
|
||||
#undef HAVE_SCHED_YIELD
|
||||
|
||||
/*
|
||||
* we do not manage to get proper signal handling of floating point
|
||||
|
|
|
|||
|
|
@ -1394,6 +1394,7 @@ extern cl_object mp_interrupt_process(cl_object process, cl_object function);
|
|||
extern cl_object mp_make_process _ARGS((cl_narg narg, ...));
|
||||
extern cl_object mp_process_active_p(cl_object process);
|
||||
extern cl_object mp_process_enable(cl_object process);
|
||||
extern cl_object mp_process_yield(void);
|
||||
extern cl_object mp_process_interrupt(cl_object process, cl_object function);
|
||||
extern cl_object mp_process_kill(cl_object process);
|
||||
extern cl_object mp_process_name(cl_object process);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue