Hello again,

> Author: fijal
> Date: Mon Jul 23 13:52:26 2007
> New Revision: 45269
>
> Modified:
>    pypy/dist/pypy/rpython/module/ll_os.py
>    pypy/dist/pypy/rpython/module/test/test_posix.py
> Log:
> Add os.uname. RPython level. segfaults ll2ctypes in some strange way,
> I'm not sure I want to know
>
>
> Modified: pypy/dist/pypy/rpython/module/ll_os.py
> ==============================================================================
> --- pypy/dist/pypy/rpython/module/ll_os.py    (original)
> +++ pypy/dist/pypy/rpython/module/ll_os.py    Mon Jul 23 13:52:26 2007
> @@ -110,6 +110,34 @@
>      register_external(os.setsid, [], int, export_name="ll_os.ll_os_setsid",
>                        llimpl=setsid_lltypeimpl)
>
> +# ------------------------------- os.uname ------------------------------
> +
> +if hasattr(os, 'uname'):
> +    UTSNAMEP = rffi.CStruct('utsname', ('sysname', rffi.CCHARP),
> +                            ('nodename', rffi.CCHARP),
> +                            ('release', rffi.CCHARP),
> +                            ('version', rffi.CCHARP),
> +                            ('machine', rffi.CCHARP),
> +                            ('stuff', rffi.CCHARP))

I think the error comes from the ctypes interpretation of the
structure. utsname is not made of char* pointers, but (at least on the
debian machine I have access to) the members are actually fixed arrays
of chars, the lengths of which are not public, but well specified in
sys/utsname.h.

It should make no difference when translated, because the code looks
like v->sysname etc.
ctypes on the other hand needs to know the precise sizeof and offsets
of each member.

I tried to modify the _socket module to also use rffi, and had the same problem.

I think that we will need a tool similar to
pypy.rpython.rctypes.tool.ctypes_platform, which generates and
compiles C code to get the different sizes and offsets.
(We will need support for C defines as well)

Hope this helps,

-- 
Amaury Forgeot d'Arc
_______________________________________________
pypy-dev@codespeak.net
http://codespeak.net/mailman/listinfo/pypy-dev

Reply via email to