From owner-freebsd-arch@FreeBSD.ORG Tue Sep 18 20:14:54 2012 Return-Path: Delivered-To: arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7442B106568F for ; Tue, 18 Sep 2012 20:14:54 +0000 (UTC) (envelope-from phk@phk.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id 31CB38FC19 for ; Tue, 18 Sep 2012 20:14:53 +0000 (UTC) Received: from critter.freebsd.dk (unknown [192.168.61.3]) by phk.freebsd.dk (Postfix) with ESMTP id DF87E3B74F; Tue, 18 Sep 2012 20:14:52 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.14.5/8.14.5) with ESMTP id q8IKEqu1023179; Tue, 18 Sep 2012 20:14:52 GMT (envelope-from phk@phk.freebsd.dk) To: Jilles Tjoelker From: "Poul-Henning Kamp" In-Reply-To: Your message of "Tue, 18 Sep 2012 21:53:53 +0200." <20120918195353.GA56160@stack.nl> Content-Type: text/plain; charset=ISO-8859-1 Date: Tue, 18 Sep 2012 20:14:52 +0000 Message-ID: <23178.1347999292@critter.freebsd.dk> Cc: arch@freebsd.org Subject: Re: Aliasing issue with TAILQ on ppc64 ? X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Sep 2012 20:14:54 -0000 In message <20120918195353.GA56160@stack.nl>, Jilles Tjoelker writes: >A dirty workaround is -fno-strict-aliasing but this reduces optimization >opportunities all over the code. Even if it works, I don't think we should mandate that for all code using >An obvious fix is to make TAILQ_ENTRY and TAILQ_HEAD the same type (and >not just structurally identical) or to add an intermediate struct which >is the same between them. I've tried something along those lines several times, but I have so far not been able to make it work, without a major change to the TAILQ_* api, which I am not prepared to push. >However, I think the TAILQ_LAST and TAILQ_PREV macros are better >rewritten using __containerof, I really don't think that is an improvement, I'd prefer a typesafe standard C solution which static checker tools like Coverity and FlexeLint can see how works. I suspect it would be enough to make the tqh_last and tqe_prev pointer be volatile pointers to struct type pointers, but absent a deeper understanding of whats actually going on I can't tell if that would be a proper solution or merely obfuscation and workaround. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk@FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence.