From 3049d3d22e7c09dc5560e3920bc848f841a74f93 Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Tue, 25 Nov 2008 22:52:26 -0500 Subject: [PATCH] Added errno. --- lib/ikarus/foreign.ss | 3 ++- scheme/ikarus.pointers.ss | 4 ++++ scheme/last-revision | 2 +- scheme/makefile.ss | 1 + src/ikarus-data.h | 1 + src/ikarus-ffi.c | 6 ++++++ 6 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/ikarus/foreign.ss b/lib/ikarus/foreign.ss index 0c77d2e..2c662c4 100644 --- a/lib/ikarus/foreign.ss +++ b/lib/ikarus/foreign.ss @@ -25,7 +25,8 @@ pointer->integer integer->pointer pointer? dlopen dlsym dlclose dlerror make-c-callout make-c-callback - pointer-size) + pointer-size + errno) (import (ikarus) (ikarus system $foreign)) diff --git a/scheme/ikarus.pointers.ss b/scheme/ikarus.pointers.ss index 2d867d6..241da99 100644 --- a/scheme/ikarus.pointers.ss +++ b/scheme/ikarus.pointers.ss @@ -2,6 +2,7 @@ (library (ikarus.pointers) (export pointer? integer->pointer pointer->integer dlopen dlerror dlclose dlsym malloc free + errno pointer-ref-c-signed-char pointer-ref-c-signed-short pointer-ref-c-signed-int @@ -264,6 +265,9 @@ (or (foreign-call "ikrt_prepare_callback" data) (die who "cannot prepare foreign callback"))))))) + (define (errno) + (foreign-call "ikrt_last_errno")) + ) diff --git a/scheme/last-revision b/scheme/last-revision index 0fb26ff..f245d2b 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1691 +1692 diff --git a/scheme/makefile.ss b/scheme/makefile.ss index dbd4c79..cc805c2 100755 --- a/scheme/makefile.ss +++ b/scheme/makefile.ss @@ -1475,6 +1475,7 @@ [dlsym $for] [malloc $for] [free $for] + [errno $for] [pointer-ref-c-signed-char $for] [pointer-ref-c-signed-short $for] [pointer-ref-c-signed-int $for] diff --git a/src/ikarus-data.h b/src/ikarus-data.h index 8336d62..1170308 100644 --- a/src/ikarus-data.h +++ b/src/ikarus-data.h @@ -172,6 +172,7 @@ typedef struct ikpcb{ struct timeval collect_utime; struct timeval collect_stime; struct timeval collect_rtime; + int last_errno; } ikpcb; typedef struct { diff --git a/src/ikarus-ffi.c b/src/ikarus-ffi.c index 0f69769..781dc77 100644 --- a/src/ikarus-ffi.c +++ b/src/ikarus-ffi.c @@ -1,6 +1,7 @@ #include "ikarus-data.h" #include "config.h" +#include #if ENABLE_LIBFFI #include @@ -337,6 +338,7 @@ ikrt_ffi_call(ikptr data, ikptr argsvec, ikpcb* pcb) { avalues[n] = NULL; void* rvalue = alloc_room_for_type(cif->rtype); ffi_call(cif, fn, rvalue, avalues); + pcb->last_errno = errno; ikptr val = ffi_to_scheme_value_cast(unfix(rtype), rvalue, pcb); for(i=0; ilast_errno, pcb); +} /*