All, In the past we have been successful in accessing
standard Windows functions from VisualWorks. Now we want to do the same thing
for Linux and we encountered unexpected difficulties. Typically a Linux
function returns 0 for success and -1 for failure and the reason for the
failure is described in a global variable called errno. In C you can use
perror(“something”) to wrote an error description to stdout. After a lot of experiencing we got the function fstat()
(called as _fxstat()) to be found, but it returns -1 and we have no idea what
the reason could be as we do not know how to access errno. We do not want to write our own wrapper functions in
C but call everything directly using DLLCC. Does anybody have exeriences with
what we want to achieve? Georg |
Georg Heeg wrote:
> All, > > > > In the past we have been successful in accessing standard Windows functions > from VisualWorks. Now we want to do the same thing for Linux and we > encountered unexpected difficulties. Typically a Linux function returns 0 > for success and -1 for failure and the reason for the failure is described > in a global variable called errno. In C you can use perror("something") to > wrote an error description to stdout. > > > > After a lot of experiencing we got the function fstat() (called as > _fxstat()) to be found, but it returns -1 and we have no idea what the > reason could be as we do not know how to access errno. > > > > We do not want to write our own wrapper functions in C but call everything > directly using DLLCC. Does anybody have exeriences with what we want to > achieve? > > > > > > Georg > > it is the same problem as with fstat. From the man pages for errno: | errno is defined by the ISO C standard to be a modifiable lvalue of type int, and must not be explic- | itly declared; errno may be a macro. errno is thread-local; setting it in one thread does not affect | its value in any other thread. In /usr/include/bits/errno.h, errno is really defined as a macro on linux: | # ifndef __ASSEMBLER__ | /* Function to get address of global `errno' variable. */ | extern int *__errno_location (void) __THROW __attribute__ ((__const__)); | | # if !defined _LIBC || defined _LIBC_REENTRANT | /* When using threads, errno is a per-thread value. */ | # define errno (*__errno_location ()) | # endif | # endif /* !__ASSEMBLER__ */ So, if you define UnixSystemSupport>>errno as __erno_location <C:int *__errno_location(void)> You can then use "UnixSystemSupport new __erno_location contents" to get the errno value. Ralf |
In reply to this post by Georg Heeg
Georg Heeg wrote:
> In the past we have been successful in accessing standard Windows functions > from VisualWorks. Now we want to do the same thing for Linux and we > encountered unexpected difficulties. Typically a Linux function returns 0 > for success and -1 for failure and the reason for the failure is described > in a global variable called errno. In C you can use perror("something") to > wrote an error description to stdout. > > After a lot of experiencing we got the function fstat() (called as > _fxstat()) to be found, but it returns -1 and we have no idea what the > reason could be as we do not know how to access errno. > The OE supports this convention if you --declare the C pragma with the __syscall initializer and --add boilerplate error handling code to the external method. errno will be copied into the 'parameter' of the SytemError passed to the error handling code. This feature is (under)documented at the bottom of page 141 of the DLLCC pdf of vw74. For an example see UnixSystemSupport>>setCurrentDirectory: Unfortunately the errorhandling is broken (MNU) in that subhierarchy, but the basic OE support can be shown to work there anyway by evaluating something like UnixSystemSupport new setCurrentDirectory: 'no such directory' and inspecting the resulting SystemError being passed around where the ivar 'parameter' should hold 2 (ENOENT). HTH, Reinout ------- |
Free forum by Nabble | Edit this page |