From patchwork Wed Feb 4 19:20:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jan Kratochvil X-Patchwork-Id: 4917 Received: (qmail 4721 invoked by alias); 4 Feb 2015 19:20:38 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 4699 invoked by uid 89); 4 Feb 2015 19:20:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 04 Feb 2015 19:20:36 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t14JKWQB009660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 4 Feb 2015 14:20:33 -0500 Received: from host1.jankratochvil.net (ovpn-116-113.ams2.redhat.com [10.36.116.113]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t14JKTou011943 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NO); Wed, 4 Feb 2015 14:20:31 -0500 Date: Wed, 4 Feb 2015 20:20:28 +0100 From: Jan Kratochvil To: Pedro Alves Cc: gdb-patches@sourceware.org, Paul_Koning@dell.com Subject: [patchv2] Fix Python 3 build error on 32-bit hosts Message-ID: <20150204192028.GA12310@host1.jankratochvil.net> References: <20150204174311.GA24375@host1.jankratochvil.net> <54D26BCA.2000505@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <54D26BCA.2000505@redhat.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes On Wed, 04 Feb 2015 19:58:18 +0100, Pedro Alves wrote: > I agree with Paul here. I think checking Python version is sufficient. I should point out that version checking is error prone to distro backports. > I'd be fine with providing a fallback Py_hash_t in python/python-internal.h, > where we already do a series of fallback definitions and fixes for older > Python, such as e.g. Py_ssize_t. Done. Jan gdb/ 2015-02-04 Jan Kratochvil * python/python-internal.h (Py_hash_t): Define it for Python <3.2. * python/py-value.c (valpy_fetch_lazy): Use it. Remove cast to the return type. diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 0ee8544..23d4755 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -169,6 +169,10 @@ typedef unsigned long gdb_py_ulongest; #endif /* HAVE_LONG_LONG */ +#if PY_VERSION_HEX < 0x03020000 +typedef long Py_hash_t; +#endif + /* Python 2.6 did not wrap Py_DECREF in 'do {...} while (0)', leading to 'suggest explicit braces to avoid ambiguous ‘else’' gcc errors. Wrap it ourselves, so that callers don't need to care. */ diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 4c4d36e..5a13777 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -895,10 +895,10 @@ valpy_fetch_lazy (PyObject *self, PyObject *args) /* Calculate and return the address of the PyObject as the value of the builtin __hash__ call. */ -static long +static Py_hash_t valpy_hash (PyObject *self) { - return (long) (intptr_t) self; + return (intptr_t) self; } enum valpy_opcode