Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Jul 2018 22:03:29 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r335913 - head/sys/amd64/include
Message-ID:  <201807032203.w63M3T47033074@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Tue Jul  3 22:03:28 2018
New Revision: 335913
URL: https://svnweb.freebsd.org/changeset/base/335913

Log:
  Use 'e' instead of 'i' constraints with 64-bit atomic operations on amd64.
  
  The ADD, AND, OR, and SUB instructions take at most a 32-bit
  sign-extended immediate operand.  64-bit constants that do not fit into
  that constraint need to be loaded into a register.  The 'i' constraint
  tells the compiler it can pass any integer constant to the assembler,
  whereas the 'e' constrain only permits constants that fit into a 32-bit
  sign-extended value.  This fixes using
  atomic_add/clear/set/subtract_long/64 with constants that do not fit into
  a 32-bit sign-extended immediate.
  
  Reported by:	several folks
  Tested by:	Pete Wright <pete@nomadlogic.org>
  MFC after:	2 weeks

Modified:
  head/sys/amd64/include/atomic.h

Modified: head/sys/amd64/include/atomic.h
==============================================================================
--- head/sys/amd64/include/atomic.h	Tue Jul  3 21:29:04 2018	(r335912)
+++ head/sys/amd64/include/atomic.h	Tue Jul  3 22:03:28 2018	(r335913)
@@ -446,10 +446,10 @@ ATOMIC_ASM(clear,    int,   "andl %1,%0",  "ir", ~v);
 ATOMIC_ASM(add,	     int,   "addl %1,%0",  "ir",  v);
 ATOMIC_ASM(subtract, int,   "subl %1,%0",  "ir",  v);
 
-ATOMIC_ASM(set,	     long,  "orq %1,%0",   "ir",  v);
-ATOMIC_ASM(clear,    long,  "andq %1,%0",  "ir", ~v);
-ATOMIC_ASM(add,	     long,  "addq %1,%0",  "ir",  v);
-ATOMIC_ASM(subtract, long,  "subq %1,%0",  "ir",  v);
+ATOMIC_ASM(set,	     long,  "orq %1,%0",   "er",  v);
+ATOMIC_ASM(clear,    long,  "andq %1,%0",  "er", ~v);
+ATOMIC_ASM(add,	     long,  "addq %1,%0",  "er",  v);
+ATOMIC_ASM(subtract, long,  "subq %1,%0",  "er",  v);
 
 #define	ATOMIC_LOADSTORE(TYPE)					\
 	ATOMIC_LOAD(TYPE);					\



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