From owner-svn-src-all@FreeBSD.ORG Thu Dec 15 19:42:26 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3DDAA106564A; Thu, 15 Dec 2011 19:42:26 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 126338FC18; Thu, 15 Dec 2011 19:42:26 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pBFJgPV4067326; Thu, 15 Dec 2011 19:42:25 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pBFJgPPk067323; Thu, 15 Dec 2011 19:42:25 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201112151942.pBFJgPPk067323@svn.freebsd.org> From: Dimitry Andric Date: Thu, 15 Dec 2011 19:42:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r228536 - in head/lib/libthr/arch: amd64/include i386/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Dec 2011 19:42:26 -0000 Author: dim Date: Thu Dec 15 19:42:25 2011 New Revision: 228536 URL: http://svn.freebsd.org/changeset/base/228536 Log: The TCB_GET32() and TCB_GET64() macros in the i386 and amd64-specific versions of pthread_md.h have a special case of dereferencing a null pointer. Clang warns about this with: In file included from lib/libthr/arch/i386/i386/pthread_md.c:36: lib/libthr/arch/i386/include/pthread_md.h:96:10: error: indirection of non-volatile null pointer will be deleted, not trap [-Werror,-Wnull-dereference] return (TCB_GET32(tcb_self)); ^~~~~~~~~~~~~~~~~~~ lib/libthr/arch/i386/include/pthread_md.h:73:13: note: expanded from: : "m" (*(u_int *)(__tcb_offset(name)))); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/libthr/arch/i386/include/pthread_md.h:96:10: note: consider using __builtin_trap() or qualifying pointer with 'volatile' Since this indirection is done relative to the fs or gs segment, to retrieve thread-specific data, it is an exception to the rule. Therefore, add a volatile qualifier to tell the compiler we really want to dereference a zero address. MFC after: 1 week Modified: head/lib/libthr/arch/amd64/include/pthread_md.h head/lib/libthr/arch/i386/include/pthread_md.h Modified: head/lib/libthr/arch/amd64/include/pthread_md.h ============================================================================== --- head/lib/libthr/arch/amd64/include/pthread_md.h Thu Dec 15 17:54:23 2011 (r228535) +++ head/lib/libthr/arch/amd64/include/pthread_md.h Thu Dec 15 19:42:25 2011 (r228536) @@ -71,7 +71,7 @@ struct tcb { u_long __i; \ __asm __volatile("movq %%fs:%1, %0" \ : "=r" (__i) \ - : "m" (*(u_long *)(__tcb_offset(name)))); \ + : "m" (*(volatile u_long *)(__tcb_offset(name)))); \ __result = (__tcb_type(name))__i; \ \ __result; \ Modified: head/lib/libthr/arch/i386/include/pthread_md.h ============================================================================== --- head/lib/libthr/arch/i386/include/pthread_md.h Thu Dec 15 17:54:23 2011 (r228535) +++ head/lib/libthr/arch/i386/include/pthread_md.h Thu Dec 15 19:42:25 2011 (r228536) @@ -70,7 +70,7 @@ struct tcb { u_int __i; \ __asm __volatile("movl %%gs:%1, %0" \ : "=r" (__i) \ - : "m" (*(u_int *)(__tcb_offset(name)))); \ + : "m" (*(volatile u_int *)(__tcb_offset(name)))); \ __result = (__tcb_type(name))__i; \ \ __result; \