[fpc-pascal] syscalls and fpc

ik idokan at gmail.com
Sat Feb 16 21:55:24 CET 2008


On Feb 16, 2008 10:03 PM, Florian Klaempfl <florian at freepascal.org> wrote:
> ik schrieb:
> > 1. There is a support only for up to 6 parameters (plus the instruction itself).
>
> Which syscall has more parameters?

I don't know, but then again, up until now I did not require to use
syscall on my own (at least using FPC, because I used "write" using
"pure" assembly). But now that I do require, I found a design that I
find it problematic. But as I understand, I'm the only one that think
there is a problem, so I'll give up and I'll not bother you on this
again.

>
> > 2. It support only integer base parameters, while you can not pass
> > pointers, chars, array, record or floating point types.
>
> Did you just calculate how much functions it would take to support all
> these combinations besides the fact that no kernel function takes e.g.
> floats.

Exactly my point on the design in the first place. The corrent design
takes integers only. Regarding the Linux Kernel, I did not knew about
the floating points issues, but what about pointers, arrays, structs
etc ?

>
> > 3. Each OS changes/add/remove functions frequently, so assuming one of
> > the above making the functions unusable for anything that is not an
> > integer and up to 6 parameters.
>
> Example? Did you realize that the linux supports _only_ one calling
> convention: taking the syscall number in a register and the other
> parameters in the remaining six registers?

Yes and no, I did used assembly with syscalls for "write" (several
years ago), but I can't find any documentation about syscall that
write about it. In fact the only documentation I did found (even using
google and not only using man. However on "man 2 syscalls" I found the
following line:
"It  is  different with select and mmap.  These use five or more
parameters, and caused problems the way parameter passing on the i386
used to be set up."

At the end of the above paragraph:
"These  days  passing  five parameters is not a problem any more, and
there is a __NR__newselect (used by libc 6) that corresponds directly
to sys_select() and similarly __NR_mmap2."

So originally the problem was 5 parameters not 6 ! and there are
functions that might have more then 6 parameters, but they recommend
an "alias" that uses less, and points to the original functions.
BTW, why the C function uses var_args and not using overloads or other
"magic" to pass the valid amount of parameters ?
<int syscall(int number, ...);>

And there are changes for every type of bit:
"On newer platforms that only have 64-bit file access and 32-bit uids
(e.g., alpha, ia64, s390x) there are no *64 or *32 calls.  Where the
*64  and  *32  calls  exist,  the other versions are obsolete."

The manual is dated to 2002-01-07 (I copied it from the man page).


>
> >
> > 1. Is there a way to implement the above with array of const ?
>
> Just add typecasts and a wrapper. Array of const is slow and not
> suitable for such low level stuff.

OK

>
> > 2. Is there a way to implement the above without using assembly,
>
> Just add type casts.
>


Ido
-- 
http://ik.homelinux.org/



More information about the fpc-pascal mailing list