Date: Tue, 25 Dec 2012 15:51:54 +0100 From: Marcus von Appen <mva@FreeBSD.org> To: rene@FreeBSD.org, bug-followup@FreeBSD.org Cc: freebsd-python@FreeBSD.org Subject: Re: ports/174689: lang/python27: 64-bit pointers returned by C library get reduced to 32-bit Message-ID: <20121225145154.GA1985@medusa.sysfault.org> In-Reply-To: <201212242330.qBONU8F4003854@freefall.freebsd.org> References: <201212242330.qBONU8F4003854@freefall.freebsd.org>
index | next in thread | previous in thread | raw e-mail
[-- Attachment #1 --]
> When initializing libmpg123.so.0 (audio/mpg123) from Python with CDLL,
> the 64-bit pointer value returned by mpg123_new(None, None) gets
> reduced to 32 bits. The equivalent program in C does not have this
> problem.
> from ctypes import *
>
> mpg123 = CDLL('libmpg123.so') # audio/mpg123
> print mpg123
>
> MPG123_OK = 0
> if mpg123.mpg123_init() != MPG123_OK:
> print "mpg123_init() failed"
> else:
> mh = mpg123.mpg123_new(None, None)
[...]
I do not see that you provide any information to ctypes about how the
function mpg123_new() should behave. By default it will assume to return
a ctypes.c_int, which most likely will be a 4-byte value.
>>> import ctypes
>>> print ctypes.sizeof(ctypes.c_int)
4
Furthermore, the mpg123.h header declares the function as
mpg123_handle *mpg123_new(const char* decoder, int *error);
mpg123_handle is a struct typedef. Instead of using a 4-byte int, you
might be better of with properly declaring the arguments
(POINTER(c_char) and POINTER(c_int)) and return
value (c_void_p or a Structure stub) of the function within your ctypes
code.
From what I can see on my test platform, it works properly according to
the basic ctypes definition.
Cheers
Marcus
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.19 (FreeBSD)
iEYEARECAAYFAlDZvYoACgkQi68/ErJnpkcQpgCeMzjD3wGFbgM/ZG4DezZhJB3Y
MvIAoKTYzEaxKOO+COVfWKUjT35GzCkr
=bUdZ
-----END PGP SIGNATURE-----
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121225145154.GA1985>
