Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 3FD682BF80 for ; Fri, 16 Dec 2011 05:37:00 -0400 (AST) Received: from [213.9.93.70] (helo=mail.piware.de) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RbUDr-00062m-7w for pgsql-bugs@postgresql.org; Fri, 16 Dec 2011 09:37:00 +0000 Received: from localhost.localdomain (p549B5F97.dip.t-dialin.net [84.155.95.151]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "Martin Pitt (ThinkPad)", Issuer "piware CA" (verified OK)) by mail.piware.de (Postfix) with ESMTPS id 1EDB41517A61 for ; Fri, 16 Dec 2011 10:36:20 +0100 (CET) Received: by localhost.localdomain (Postfix, from userid 1000) id 4324D20337; Fri, 16 Dec 2011 10:36:46 +0100 (CET) Date: Fri, 16 Dec 2011 10:36:46 +0100 From: Martin Pitt To: PostgreSQL Bugs Subject: TAS patch for building on armel/armhf thumb Message-ID: <20111216093646.GD2722@piware.de> Mail-Followup-To: PostgreSQL Bugs MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="q9KOos5vDmpwPx9o" Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Host-Lookup-Failed: Reverse DNS lookup failed for 213.9.93.70 (failed) X-Pg-Spam-Score: -1.1 (-) X-Archive-Number: 201112/127 X-Sequence-Number: 31938 --q9KOos5vDmpwPx9o Content-Type: multipart/mixed; boundary="raC6veAxrt5nqIoY" Content-Disposition: inline --raC6veAxrt5nqIoY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, if you build postgresql (tested all releases from 8.4 up to trunk) for ARM with the -mthumb instruction set (much better performance), it fails with gcc -g -O2 -g -Wall -O2 -fPIC -Wall -Wmissing-prototypes -Wpointer-arith -W= declaration-after-statement -Wendif-labels -fno-strict-aliasing -fwrapv -g = -I../../../../src/include -D_GNU_SOURCE -I/usr/include/libxml2 -I/usr/inclu= de/tcl8.5 -c -o xlog.o xlog.c /tmp/cc8Wkglp.s: Assembler messages: /tmp/cc8Wkglp.s:1456: Error: selected processor does not support `swpb r3,r= 3,[r0]' /tmp/cc8Wkglp.s:1587: Error: selected processor does not support `swpb r2,r= 2,[r0]' A fair while ago, Alexander Sack from Linaro applied a patch to our packages to drop the Assembler bits and instead use gcc's atomic builtins [1], which provide a proper implementation for thumb, too. The original patch spectacularly failed on our slightly newer Panda boards (our old builders were Freescale Babbage boards), but I got that to work yesterday. Now it's working on Babbage, Panda, both with and without hard float (armhf) enabled. I'm not sure how appropriate it is for upstream to have GCC-isms in the code, but even if it can't land upstream, perhaps it is useful for other porters/packagers. Thanks, Martin [1] http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html --=20 Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org) --raC6veAxrt5nqIoY Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="01-armel-tas.patch" Content-Transfer-Encoding: quoted-printable Description: use gcc intrinsics rather than assembler to implement tas Author: Alexander Sack Author: Martin Pitt Bug-Ubuntu: https://launchpad.net/bugs/497331 Bug-Ubuntu: https://launchpad.net/bugs/904828 Index: postgresql-9.1-9.1.2/src/include/storage/s_lock.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- postgresql-9.1-9.1.2.orig/src/include/storage/s_lock.h 2011-12-01 22:47= :20.000000000 +0100 +++ postgresql-9.1-9.1.2/src/include/storage/s_lock.h 2011-12-15 21:17:32.9= 65569760 +0100 @@ -255,21 +255,15 @@ #if defined(__arm__) || defined(__arm) #define HAS_TEST_AND_SET =20 -typedef unsigned char slock_t; +typedef unsigned int slock_t; =20 #define TAS(lock) tas(lock) +#define S_UNLOCK(lock) __sync_lock_release(lock) =20 static __inline__ int tas(volatile slock_t *lock) { - register slock_t _res =3D 1; - - __asm__ __volatile__( - " swpb %0, %0, [%2] \n" -: "+r"(_res), "+m"(*lock) -: "r"(lock) -: "memory"); - return (int) _res; + return __sync_lock_test_and_set (lock, 1); } =20 #endif /* __arm__ */ --raC6veAxrt5nqIoY-- --q9KOos5vDmpwPx9o Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBCAAGBQJO6xEuAAoJEPmIJawmtHuf4OsQAI7qWiF73M8OQZ4fqecmoY5k BYmGfcNLwZhiBD2PQHaXiMFGB3qYMA/i9Mb7wsWzlAi600F90RrQYdbCt8ik+GrA 52UZF1E5yNyfIihqtlQMtKza+ROSEZhurbkU8hLcjZT+SOrrozJoFUxdZtP73qqX 4jK0m2QQdCz5zaC7pazJZspuMwdUbILeRoza9FIEmUNuf2G1TYkPHk/T51O3LPUa xfjSg6LH+prD2zClSL+5HeHVit18WjbWgyM8vjeFDh92271Ne9gmYBHfqY6eZUSc B5MH1cE/fsIIBpxy6bsPKVmasy5NDFZUdAEKUEI9O0F6Zel9YN8WoV/IwaYrZxCr MaHzjF/kFQ9rLnBPltmLkmZFZL2Uv2XYIiqepGDY6k4ZtRlykCFiJeRcyXhD9dzf N+6aaf6sJn6DNKAGsBo0dDh3mxwUWWP4aD9VtNOmX9igbvUndtN+z+SQTWykHyrb HkMaCAgCD26aXgwH+YzNYHD9RofrszFsJyRbv0lS467wNEXsgPt9mTpLcN24FXBi So+Ubd96knwO3l9h0AvsGiBfrMEjI5ozkBvZ0iY2CFDO/uW+sImsiMbZlocVPpMe WJwXQngyOaLOcTY0/4iWupha9GhXM4mpVBD4kNEz3iWKxHIOztbTXoobNycIdp6S ntnu8fEwElrVKoOFWCSp =WcS6 -----END PGP SIGNATURE----- --q9KOos5vDmpwPx9o--