Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Dec 2011 23:41:24 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r229047 - in stable/9/lib/libthr/arch: amd64/include i386/include
Message-ID:  <201112302341.pBUNfOVK036438@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Fri Dec 30 23:41:24 2011
New Revision: 229047
URL: http://svn.freebsd.org/changeset/base/229047

Log:
  MFC r228536:
  
  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.

Modified:
  stable/9/lib/libthr/arch/amd64/include/pthread_md.h
  stable/9/lib/libthr/arch/i386/include/pthread_md.h
Directory Properties:
  stable/9/lib/libthr/   (props changed)

Modified: stable/9/lib/libthr/arch/amd64/include/pthread_md.h
==============================================================================
--- stable/9/lib/libthr/arch/amd64/include/pthread_md.h	Fri Dec 30 22:59:00 2011	(r229046)
+++ stable/9/lib/libthr/arch/amd64/include/pthread_md.h	Fri Dec 30 23:41:24 2011	(r229047)
@@ -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: stable/9/lib/libthr/arch/i386/include/pthread_md.h
==============================================================================
--- stable/9/lib/libthr/arch/i386/include/pthread_md.h	Fri Dec 30 22:59:00 2011	(r229046)
+++ stable/9/lib/libthr/arch/i386/include/pthread_md.h	Fri Dec 30 23:41:24 2011	(r229047)
@@ -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;						\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201112302341.pBUNfOVK036438>