[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21694: 'clone' syscall binding unreliable
From: |
Mark H Weaver |
Subject: |
bug#21694: 'clone' syscall binding unreliable |
Date: |
Wed, 28 Oct 2015 00:53:28 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
address@hidden (Ludovic Courtès) writes:
> Mark H Weaver <address@hidden> skribis:
>
>> address@hidden (Ludovic Courtès) writes:
>
> [...]
>
>>> ;; The libc interface to sys_clone is not useful for Scheme programs, so
>>> the
>>> -;; low-level system call is wrapped instead.
>>> +;; low-level system call is wrapped instead. The 'syscall' function is
>>> +;; declared in <unistd.h> as a variadic function; in practice, it expects 6
>>> +;; pointer-sized arguments, as shown in, e.g., x86_64/syscall.S.
>>> (define clone
>>> (let* ((ptr (dynamic-func "syscall" (dynamic-link)))
>>> - (proc (pointer->procedure int ptr (list int int '*)))
>>> + (proc (pointer->procedure long ptr
>>> + (list long
>>> ;sysno
>>> + unsigned-long
>>> ;flags
>>
>> 'long' and 'unsigned long' might not be the same size as a pointer.
>> Better to use 'size_t' for both of these. While not strictly guaranteed
>> to be the same size as a pointer, in practice they should be the same
>> except on architectures with segmented memory models.
>>
>> What do you think?
>
> I had the same reaction, but posix/unistd.h in libc really uses these
> types for ‘syscall’ so I thought it’d be best to stick to them.
Okay, makes sense.
Thanks,
Mark