hyln9 / ikarus

Optimizing incremental native-code compiler for R6RS scheme. This is a forked repository.
https://launchpad.net/ikarus
Other
5 stars 0 forks source link

gimme errno #177

Closed hyln9 closed 10 years ago

hyln9 commented 10 years ago

Unleash the power of my imagination by providing an additional MAKE-C-CALLOUT, say MAKE-C-CALLOUT*, whose return value returns two values: the return value from the foreign function and the value of "errno" (as integer) just after the call.

(Note: I have asked the same to Fujita, for Ypsilon.)

Launchpad Details: #LP301269 Marco Maggi - 2008-11-23 07:46:52 -0500

hyln9 commented 10 years ago

What's the bug?

Launchpad Details: #LPC Abdulaziz Ghuloum - 2008-11-23 09:49:13 -0500

hyln9 commented 10 years ago

I should have tagged it as a request (but I dunno how to do it other than putting "request" in the title). So, let's put it this whay: bug, there is no way to access "errno" after a foreign function call so it is impossible to correctly detect errors for system function calls.

Launchpad Details: #LPC Marco Maggi - 2008-11-24 02:08:06 -0500

hyln9 commented 10 years ago

On Nov 24, 2008, at 2:08 AM, Marco Maggi wrote:

it is impossible to correctly detect errors for system function calls.

Is this because ikarus may itself do some system calls in the time
between you calling the system function and the time you request errno?

Launchpad Details: #LPC Abdulaziz Ghuloum - 2008-11-24 02:18:13 -0500

hyln9 commented 10 years ago

"Abdulaziz Ghuloum" wrote:

Is this because ikarus may itself do some system calls in the time between you calling the system function and the time you request errno?

Yes. And even if Ikarus does not do it, other implementations may do; if not now, in the future. I am writing an ffi wrapper for both Ikarus and Ypsilon, and having the implementations provide the general solution by themselves seems more foresighted.

Launchpad Details: #LPC Marco Maggi - 2008-11-25 01:29:26 -0500

hyln9 commented 10 years ago

On Nov 25, 2008, at 1:29 AM, Marco Maggi wrote:

"Abdulaziz Ghuloum" wrote:

Is this because ikarus may itself do some system calls in the time between you calling the system function and the time you request errno?

Yes. ...

Would it be sufficient to provide an "errno" procedure that returns the value of errno immediately after the foreign procedure is called and before ikarus uses any other system procedure?

Launchpad Details: #LPC Abdulaziz Ghuloum - 2008-11-25 03:18:33 -0500

hyln9 commented 10 years ago

"Abdulaziz Ghuloum" wrote:

Would it be sufficient to provide an "errno" procedure that returns the value of errno immediately after the foreign procedure is called and before ikarus uses any other system procedure?

Yes. If you want to follow the "dlerror" and "ferror" models it is fine with me.

Launchpad Details: #LPC Marco Maggi - 2008-11-25 14:36:41 -0500

hyln9 commented 10 years ago

Added. Thanks for the suggestion.

Ikarus Scheme version 0.0.3+ (revision 1693, build 2008-11-25) Copyright (c) 2006-2008 Abdulaziz Ghuloum

(import (ypsilon-compat)) (import (ikarus foreign)) (define libc (load-shared-object "libc.dylib")) ;;; this is mac os (define chmod (c-function libc "libc" int stdcall chmod (char* int))) (chmod "/tmp" #o777) -1 (errno) 1 (chmod "/tmp/foobar" #o600) -1 (errno) 2

Launchpad Details: #LPC Abdulaziz Ghuloum - 2008-11-25 22:54:19 -0500