[fpc-devel] OpenBSD compiler

Marco van de Voort marcov at stack.nl
Fri Oct 7 18:51:14 CEST 2011


In our previous episode, Tomas Hajny said:
> > Some status update after some play yesterday evening:
>  .
>  .
> > 4. The next big crash is, as usual for a new port, in
> > fexpand/expandfilename/readdir.
>  .
> 
> I assume you probably meant FindFirst rather than FExpand/ExpandFileName,
> right? FExpand needs only GetDir and GetEnv/GetEnvironmentVariable which
> should hardly be a reason for a crash of any new port hopefully...

Don't worry. I'm not dissing your fexpand :-)

The unix implementation of getdir can actually enumerate directories.

So the problem is in readdir, but on *nix ports the crash will be in
expandfilename because getdir stresses readdir hard, and in the compiler
that happens before the first findfirst.

The problem of readdir is simply that it is one of the few core
functionalities with a sizable userland part, and the implementations can be
fairly different across OSes. (with even two choices for the kernel call
used)

I ran into it already with the original FreeBSD port (done just before 1.0,
merged in slightly after 1.0) This because in the original Linux port,
readdir WAS a system call.

Another such traditional issue is the handling of seek and truncate, because
they are syscalls with 64-bit types. Some OSes that call syscalls with
values in registers still call them as if they were on the stack, and insert
extra zero parameters to "align", and some don't, with variations per
architecture.




More information about the fpc-devel mailing list