From owner-freebsd-python@FreeBSD.ORG Tue Dec 25 15:00:01 2012 Return-Path: Delivered-To: freebsd-python@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 65B8DCD5 for ; Tue, 25 Dec 2012 15:00:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 309248FC12 for ; Tue, 25 Dec 2012 15:00:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id qBPF01XP087812 for ; Tue, 25 Dec 2012 15:00:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id qBPF01Br087811; Tue, 25 Dec 2012 15:00:01 GMT (envelope-from gnats) Date: Tue, 25 Dec 2012 15:00:01 GMT Message-Id: <201212251500.qBPF01Br087811@freefall.freebsd.org> To: freebsd-python@FreeBSD.org Cc: From: Marcus von Appen Subject: Re: ports/174689: lang/python27: 64-bit pointers returned by C library get reduced to 32-bit X-BeenThere: freebsd-python@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: Marcus von Appen List-Id: FreeBSD-specific Python issues List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Dec 2012 15:00:01 -0000 The following reply was made to PR ports/174689; it has been noted by GNATS. From: Marcus von Appen 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 Date: Tue, 25 Dec 2012 15:51:54 +0100 --J/dobhs11T7y2rNN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable > 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 =3D CDLL('libmpg123.so') # audio/mpg123 > print mpg123 > > MPG123_OK =3D 0 > if mpg123.mpg123_init() !=3D MPG123_OK: > print "mpg123_init() failed" > else: > mh =3D 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. =46rom what I can see on my test platform, it works properly according to the basic ctypes definition. Cheers Marcus --J/dobhs11T7y2rNN Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.19 (FreeBSD) iEYEARECAAYFAlDZvYoACgkQi68/ErJnpkcQpgCeMzjD3wGFbgM/ZG4DezZhJB3Y MvIAoKTYzEaxKOO+COVfWKUjT35GzCkr =bUdZ -----END PGP SIGNATURE----- --J/dobhs11T7y2rNN--