From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5858 invoked by alias); 12 Feb 2015 21:23:08 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 5831 invoked by uid 89); 12 Feb 2015 21:23:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients 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; Thu, 12 Feb 2015 21:23:06 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1CLN54L008504 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 12 Feb 2015 16:23:05 -0500 Received: from anchor.twiddle.net (vpn-232-190.phx2.redhat.com [10.3.232.190]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1CLN4So004090; Thu, 12 Feb 2015 16:23:05 -0500 Message-ID: <54DD19B7.6060401@redhat.com> Date: Thu, 12 Feb 2015 21:23:00 -0000 From: Richard Henderson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [libstdc++/65033] Give alignment info to libatomic Content-Type: multipart/mixed; boundary="------------080906050800080506050204" X-IsSubscribed: yes X-SW-Source: 2015-02/txt/msg00797.txt.bz2 This is a multi-part message in MIME format. --------------080906050800080506050204 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Content-length: 1087 When we fixed PR54005, making sure that atomic_is_lock_free returns the same value for all objects of a given type, we probably should have changed the interface so that we would pass size and alignment rather than size and object pointer. Instead, we decided that passing null for the object pointer would be sufficient. But as this PR shows, we really do need to take alignment into account. The following patch constructs a fake object pointer that is maximally misaligned. This allows the interface to both the builtin and to libatomic to remain unchanged. Which probably makes this back-portable to maintenance releases as well. I believe that for all of our current systems, size_t == uintptr_t, so the reinterpret_cast ought not generate warnings. The test case is problematic, as there's currently no good place to put it. The libstdc++ testsuite doesn't have the libatomic library path configured, and the libatomic testsuite doesn't have the libstdc++ include paths configured. Yet another example where we really need an install tree for testing. Thoughts? Ok? r~ --------------080906050800080506050204 Content-Type: text/plain; charset=UTF-8; name="z" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="z" Content-length: 3860 CSogaW5jbHVkZS9iaXRzL2F0b21pY19iYXNlLmggKF9fYXRvbWljX2Jhc2U8 VD46OmlzX2xvY2tfZnJlZSk6IEJ1aWxkCglhIGZha2UgcG9pbnRlciBpbmRp Y2F0aW5nIHR5cGUgYWxpZ25tZW50LgoJKF9fYXRvbWljX2Jhc2U8VCAqPjo6 aXNfbG9ja19mcmVlKTogTGlrZXdpc2UuCgkqIGluY2x1ZGUvc3RkL2F0b21p YyAoYXRvbWljPFQ+Ojppc19sb2NrX2ZyZWUpOiBMaWtld2lzZS4KCmRpZmYg LS1naXQgYS9saWJzdGRjKystdjMvaW5jbHVkZS9iaXRzL2F0b21pY19iYXNl LmggYi9saWJzdGRjKystdjMvaW5jbHVkZS9iaXRzL2F0b21pY19iYXNlLmgK aW5kZXggZmU2NTI0Zi4uODEwNGM5OCAxMDA2NDQKLS0tIGEvbGlic3RkYysr LXYzL2luY2x1ZGUvYml0cy9hdG9taWNfYmFzZS5oCisrKyBiL2xpYnN0ZGMr Ky12My9pbmNsdWRlL2JpdHMvYXRvbWljX2Jhc2UuaApAQCAtMzQ2LDExICsz NDYsMTkgQEAgX0dMSUJDWFhfQkVHSU5fTkFNRVNQQUNFX1ZFUlNJT04KIAog ICAgICAgYm9vbAogICAgICAgaXNfbG9ja19mcmVlKCkgY29uc3Qgbm9leGNl cHQKLSAgICAgIHsgcmV0dXJuIF9fYXRvbWljX2lzX2xvY2tfZnJlZShzaXpl b2YoX01faSksIG51bGxwdHIpOyB9CisgICAgICB7CisJLy8gUHJvZHVjZSBh IGZha2UsIG1pbmltYWxseSBhbGlnbmVkIHBvaW50ZXIuCisJdm9pZCAqX19h ID0gcmVpbnRlcnByZXRfY2FzdDx2b2lkICo+KC1fX2FsaWdub2YoX01faSkp OworCXJldHVybiBfX2F0b21pY19pc19sb2NrX2ZyZWUoc2l6ZW9mKF9NX2kp LCBfX2EpOworICAgICAgfQogCiAgICAgICBib29sCiAgICAgICBpc19sb2Nr X2ZyZWUoKSBjb25zdCB2b2xhdGlsZSBub2V4Y2VwdAotICAgICAgeyByZXR1 cm4gX19hdG9taWNfaXNfbG9ja19mcmVlKHNpemVvZihfTV9pKSwgbnVsbHB0 cik7IH0KKyAgICAgIHsKKwkvLyBQcm9kdWNlIGEgZmFrZSwgbWluaW1hbGx5 IGFsaWduZWQgcG9pbnRlci4KKwl2b2lkICpfX2EgPSByZWludGVycHJldF9j YXN0PHZvaWQgKj4oLV9fYWxpZ25vZihfTV9pKSk7CisJcmV0dXJuIF9fYXRv bWljX2lzX2xvY2tfZnJlZShzaXplb2YoX01faSksIF9fYSk7CisgICAgICB9 CiAKICAgICAgIF9HTElCQ1hYX0FMV0FZU19JTkxJTkUgdm9pZAogICAgICAg c3RvcmUoX19pbnRfdHlwZSBfX2ksIG1lbW9yeV9vcmRlciBfX20gPSBtZW1v cnlfb3JkZXJfc2VxX2NzdCkgbm9leGNlcHQKQEAgLTY1MywxMSArNjYxLDE5 IEBAIF9HTElCQ1hYX0JFR0lOX05BTUVTUEFDRV9WRVJTSU9OCi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2F0b21pYworKysgYi9saWJzdGRjKystdjMvaW5jbHVkZS9zdGQvYXRvbWlj CkBAIC0xOTgsMTEgKzE5OCwxOSBAQCBfR0xJQkNYWF9CRUdJTl9OQU1FU1BB Q0VfVkVSU0lPTgogCiAgICAgICBib29sCiAgICAgICBpc19sb2NrX2ZyZWUo KSBjb25zdCBub2V4Y2VwdAotICAgICAgeyByZXR1cm4gX19hdG9taWNfaXNf bG9ja19mcmVlKHNpemVvZihfTV9pKSwgbnVsbHB0cik7IH0KKyAgICAgIHsK KwkvLyBQcm9kdWNlIGEgZmFrZSwgbWluaW1hbGx5IGFsaWduZWQgcG9pbnRl ci4KKwl2b2lkICpfX2EgPSByZWludGVycHJldF9jYXN0PHZvaWQgKj4oLV9f YWxpZ25vZihfTV9pKSk7CisJcmV0dXJuIF9fYXRvbWljX2lzX2xvY2tfZnJl ZShzaXplb2YoX01faSksIF9fYSk7CisgICAgICB9CiAKICAgICAgIGJvb2wK ICAgICAgIGlzX2xvY2tfZnJlZSgpIGNvbnN0IHZvbGF0aWxlIG5vZXhjZXB0 Ci0gICAgICB7IHJldHVybiBfX2F0b21pY19pc19sb2NrX2ZyZWUoc2l6ZW9m KF9NX2kpLCBudWxscHRyKTsgfQorICAgICAgeworCS8vIFByb2R1Y2UgYSBm YWtlLCBtaW5pbWFsbHkgYWxpZ25lZCBwb2ludGVyLgorCXZvaWQgKl9fYSA9 IHJlaW50ZXJwcmV0X2Nhc3Q8dm9pZCAqPigtX19hbGlnbm9mKF9NX2kpKTsK KwlyZXR1cm4gX19hdG9taWNfaXNfbG9ja19mcmVlKHNpemVvZihfTV9pKSwg X19hKTsKKyAgICAgIH0KIAogICAgICAgdm9pZAogICAgICAgc3RvcmUoX1Rw IF9faSwgbWVtb3J5X29yZGVyIF9fbSA9IG1lbW9yeV9vcmRlcl9zZXFfY3N0 KSBub2V4Y2VwdAo= --------------080906050800080506050204 Content-Type: text/x-c++src; name="65033.cc" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="65033.cc" Content-length: 1081 // Copyright (C) 2015 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // You should have received a copy of the GNU General Public License along // with this library; see the file COPYING3. If not see // . // { dg-require-atomic-builtins "" } // { dg-options "-std=3Dgnu++11" } #include #include struct S2 { char a[2]; }; struct S3 { char a[3]; }; int main() { std::atomic s2; std::atomic s3; VERIFY( s2.is_lock_free() =3D=3D false ); VERIFY( s3.is_lock_free() =3D=3D false ); } --------------080906050800080506050204--