[fpc-devel]fpStat() and LinuxError

Marco van de Voort marcov at stack.nl
Mon Dec 1 11:43:24 CET 2003


> How do I get the error code for fpStat() ?
> 
> The oldlinux.stat() function returns FALSE on failure, and sets LinuxError.
> 
> The libc.stat() function returns (-1) on failure, and sets errno.
> 
> The baseunix.fpStat() function returns (-1) on failure, 
> but it does not set LinuxError. 

LinuxError is legacy, and belongs to oldlinux only. This unit is provided
for 1.0.x legacy only, and I strongly advise you against using it. Unit
oldlinux is also linux/i386 only.

Baseunix follows POSIX conventions, and sets an internal errno on
error and signals the errorcondition using the returnvalue (usually by
returning -1, but some calls returning a type different from cint return
something else. See manpages).

Because the BaseUnix internal errno is threadsafe, access is provided via
functions, (BaseUnix.) fpseterrno and fpgeterrno.

So there are now three errorvariables:

1 oldlinux.linuxerror for calls in unit oldlinux only. _LEGACY_
2 baseunix.fpgeterrno for all units that import unit syscall. (including 
   unix and baseunix, but also sockets, ipc etc)
3 libc's errno (exposed in units that link to libc. Access to this variable
   in a threadsafe manner still has to be centralised in some unit, and
   all importing units adapted.

The idea of this is to have only two vars, instead of all the vars in
all the units.  One, internal for FPC's own syscalls, and one for C libc. 

In the case that the FPC rtl is implemented on top of libc, (like planned
for the future Mac OS X port), both point to the same internally, but the
usercode needs no changing.




More information about the fpc-devel mailing list