c-inline: check values vs :one-liner
if c-inline returns multiple values :one-liner
can't be t
. Sanitize this. Either write a compiler note that :one-liner
flag is discarded due to values, or signal a condition.
(defun ecl-waitpid (pid wait)
(ffi:c-inline
(pid wait) (:object :object) (values :object :object :object)
"si_waitpid(#0, #1);" :one-liner t))
expansion is:
;;; Compiling (DEFUN C::GAZONK ...).
;;; Emitting code for C::GAZONK.
/* function definition for GAZONK */
/* optimize speed 3, debug 3, space 0, safety 2 */
static cl_object L1c__gazonk(cl_object v1pid, cl_object v2wait)
{
struct ecl_ihs_frame ihs;
const cl_object _ecl_debug_env = ECL_NIL;
cl_object env0;
const cl_env_ptr cl_env_copy = ecl_process_env();
cl_object value0;
ecl_cs_check(cl_env_copy,value0);
{
{
static const struct ecl_var_debug_info _ecl_descriptors[]={
{"COMMON-LISP-USER::PID",_ecl_object_loc}
,{"COMMON-LISP-USER::WAIT",_ecl_object_loc}};
const cl_index _ecl_debug_info_raw[]={
(cl_index)(ECL_NIL),(cl_index)(_ecl_descriptors),(cl_index)(&v1pid),(cl_index)(&v2wait)};
ecl_def_ct_vector(_ecl_debug_env,ecl_aet_index,_ecl_debug_info_raw,4,,);
ecl_ihs_push(cl_env_copy,&ihs,VV[0],_ecl_debug_env);
TTL:
value0 = si_waitpid(v1pid, v2wait);
cl_env_copy->nvalues = 1;
ecl_ihs_pop(cl_env_copy);
return value0;
}
}
}
not that other values aren't set. Correct expansion is:
;;; Compiling (DEFUN C::GAZONK ...).
;;; Emitting code for C::GAZONK.
/* function definition for GAZONK */
/* optimize speed 3, debug 3, space 0, safety 2 */
static cl_object L1c__gazonk(cl_object v1pid, cl_object v2wait)
{
struct ecl_ihs_frame ihs;
const cl_object _ecl_debug_env = ECL_NIL;
cl_object env0;
const cl_env_ptr cl_env_copy = ecl_process_env();
cl_object value0;
ecl_cs_check(cl_env_copy,value0);
{
{
static const struct ecl_var_debug_info _ecl_descriptors[]={
{"COMMON-LISP-USER::PID",_ecl_object_loc}
,{"COMMON-LISP-USER::WAIT",_ecl_object_loc}};
const cl_index _ecl_debug_info_raw[]={
(cl_index)(ECL_NIL),(cl_index)(_ecl_descriptors),(cl_index)(&v1pid),(cl_index)(&v2wait)};
ecl_def_ct_vector(_ecl_debug_env,ecl_aet_index,_ecl_debug_info_raw,4,,);
ecl_ihs_push(cl_env_copy,&ihs,VV[0],_ecl_debug_env);
TTL:
{
cl_object v3;
cl_object v4;
cl_object v5;
si_waitpid(v1pid, v2wait)
cl_env_copy->values[0] = v3;
cl_env_copy->values[1] = v4;
cl_env_copy->values[2] = v5;cl_env_copy->nvalues=3;
ecl_ihs_pop(cl_env_copy);
return cl_env_copy->values[0];
}
}
}
}