gimme errno

Bug #301269 reported by Marco Maggi
2
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Fix Committed
Low
Abdulaziz Ghuloum

Bug Description

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.)

Related branches

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

What's the bug?

Revision history for this message
Marco Maggi (mrc-mgg) wrote :

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.

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote : Re: [Bug 301269] Re: gimme errno

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?

Revision history for this message
Marco Maggi (mrc-mgg) 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. 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.

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

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?

Revision history for this message
Marco Maggi (mrc-mgg) wrote :

"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.

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

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
>

Changed in ikarus:
assignee: nobody → aghuloum
importance: Undecided → Low
status: New → Fix Committed
Changed in ikarus:
milestone: none → 0.0.4
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.