1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 03:30:27 +02:00

Foreign-call intrinsic boxes errno

* libguile/intrinsics.h (SCM_FOR_ALL_VM_INTRINSICS):
* libguile/foreign.c (foreign_call):
* libguile/vm-engine.c (foreign-call): Change foreign-call intrinsic to
  handle boxing of errno.
This commit is contained in:
Andy Wingo 2018-06-26 11:07:17 +02:00
parent 5e8e816c61
commit 185d19dfb1
3 changed files with 6 additions and 7 deletions

View file

@ -1018,7 +1018,7 @@ pack (const ffi_type * type, const void *loc, int return_value_p)
#define MAX(A, B) ((A) >= (B) ? (A) : (B))
static SCM
foreign_call (SCM cif_scm, SCM pointer_scm, int *errno_ret,
foreign_call (SCM cif_scm, SCM pointer_scm, SCM *errno_ret,
const union scm_vm_stack_element *argv)
{
/* FOREIGN is the pair that cif_to_procedure set as the 0th element of the
@ -1071,7 +1071,7 @@ foreign_call (SCM cif_scm, SCM pointer_scm, int *errno_ret,
/* off we go! */
errno = 0;
ffi_call (cif, func, rvalue, args);
*errno_ret = errno;
*errno_ret = scm_from_int (errno);
return pack (cif->rtype, rvalue, 1);
}

View file

@ -50,7 +50,7 @@ typedef uint32_t (*scm_t_u32_from_thread_u32_u32_intrinsic) (scm_i_thread*, uint
typedef void (*scm_t_thread_u32_u32_scm_u8_u8_intrinsic) (scm_i_thread*, uint32_t,
uint32_t, SCM, uint8_t,
uint8_t);
typedef SCM (*scm_t_scm_from_scm_scm_intp_sp_intrinsic) (SCM, SCM, int*,
typedef SCM (*scm_t_scm_from_scm_scm_scmp_sp_intrinsic) (SCM, SCM, SCM*,
const union scm_vm_stack_element*);
typedef void (*scm_t_thread_scm_noreturn_intrinsic) (scm_i_thread*, SCM) SCM_NORETURN;
@ -102,7 +102,7 @@ typedef void (*scm_t_thread_scm_noreturn_intrinsic) (scm_i_thread*, SCM) SCM_NOR
M(u32_from_thread_u32_u32, compute_kwargs_npositional, "compute-kwargs-npositional", COMPUTE_KWARGS_NPOSITIONAL) \
M(thread_u32_u32_scm_u8_u8, bind_kwargs, "bind-kwargs", BIND_KWARGS) \
M(thread, push_interrupt_frame, "push-interrupt-frame", PUSH_INTERRUPT_FRAME) \
M(scm_from_scm_scm_intp_sp, foreign_call, "foreign-call", FOREIGN_CALL) \
M(scm_from_scm_scm_scmp_sp, foreign_call, "foreign-call", FOREIGN_CALL) \
M(thread_scm_noreturn, reinstate_continuation_x, "reinstate-continuation!", REINSTATE_CONTINUATION_X) \
/* Add new intrinsics here; also update scm_bootstrap_intrinsics. */

View file

@ -635,8 +635,7 @@ VM_NAME (scm_i_thread *thread, jmp_buf *registers, int resume)
VM_DEFINE_OP (11, foreign_call, "foreign-call", OP1 (X8_C12_C12))
{
uint16_t cif_idx, ptr_idx;
int err = 0;
SCM closure, cif, pointer, ret;
SCM closure, cif, pointer, ret, err;
UNPACK_12_12 (op, cif_idx, ptr_idx);
@ -650,7 +649,7 @@ VM_NAME (scm_i_thread *thread, jmp_buf *registers, int resume)
ALLOC_FRAME (3);
SP_SET (1, ret);
SP_SET (0, scm_vm_intrinsics.s64_to_scm (err));
SP_SET (0, err);
NEXT (1);
}