public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH 2/4] Gccgo port to s390[x] -- part II
@ 2014-11-04 12:15 Dominik Vogt
  2014-11-05  3:40 ` [gofrontend-dev] " Ian Taylor
  2014-11-05  3:55 ` Ian Taylor
  0 siblings, 2 replies; 3+ messages in thread
From: Dominik Vogt @ 2014-11-04 12:15 UTC (permalink / raw)
  To: gcc-patches; +Cc: gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 101 bytes --]

See commit comment and ChangeLog for details.

Ciao

Dominik ^_^  ^_^

-- 

Dominik Vogt
IBM Germany

[-- Attachment #2: 0002-ChangeLog --]
[-- Type: text/plain, Size: 281 bytes --]

ChangeLog
2014-11-04  Dominik Vogt  <vogt@linux.vnet.ibm.com>

	* libgo/go/sync/atomic/atomic_test.go: Use LoadInt32() to access sync
	variables.
	* libgo/go/math/all_test.go (tolerance): Fix bug in calculation.
	(alike): Less strict precision requirements.
	(TestLog2): Likewise.

[-- Attachment #3: 0002-libgo-Test-fixes-for-s390-x.patch --]
[-- Type: text/x-diff, Size: 4182 bytes --]

From f62844a6e4a0f76c30fe3f1cffc0933f21bbf43d Mon Sep 17 00:00:00 2001
From: Dominik Vogt <vogt@linux.vnet.ibm.com>
Date: Tue, 4 Nov 2014 10:13:16 +0100
Subject: [PATCH 2/4] libgo: Test fixes for s390[x].

1) libgo/math: Fix TestLog2 failures.

Fixes necessary to successfully run the test on s390x.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63269 for details.

2) libgo/sync/atomic: Fix tests for sync_atomic.CompareAndSwap...().

*addr must not be accessed directly as the compiler can optimise the access to
memory away, or make mulitple accesses (which it actually does on s390x). As Go
does have no way to express that the memory is volatile, read it with the
sync_atomic.Load...() function family instead.
---
 libgo/go/math/all_test.go           |  9 ++++++---
 libgo/go/sync/atomic/atomic_test.go | 16 ++++++++--------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/libgo/go/math/all_test.go b/libgo/go/math/all_test.go
index 0d8b10f..0d19e14 100644
--- a/libgo/go/math/all_test.go
+++ b/libgo/go/math/all_test.go
@@ -1671,8 +1671,8 @@ func tolerance(a, b, e float64) bool {
 		d = -d
 	}
 
-	if a != 0 {
-		e = e * a
+	if b != 0 {
+		e = e * b
 		if e < 0 {
 			e = -e
 		}
@@ -1687,6 +1687,9 @@ func alike(a, b float64) bool {
 	switch {
 	case IsNaN(a) && IsNaN(b):
 		return true
+	case a == 0 && !IsNaN(b) && !IsInf(b, 0):
+		// allow deviations when the expected value is zero
+		return true
 	case a == b:
 		return Signbit(a) == Signbit(b)
 	}
@@ -2284,7 +2287,7 @@ func TestLog2(t *testing.T) {
 	for i := -1074; i <= 1023; i++ {
 		f := Ldexp(1, i)
 		l := Log2(f)
-		if l != float64(i) {
+		if !veryclose(l, float64(i)) {
 			t.Errorf("Log2(2**%d) = %g, want %d", i, l, i)
 		}
 	}
diff --git a/libgo/go/sync/atomic/atomic_test.go b/libgo/go/sync/atomic/atomic_test.go
index d2af4f4..eaa3b6b 100644
--- a/libgo/go/sync/atomic/atomic_test.go
+++ b/libgo/go/sync/atomic/atomic_test.go
@@ -858,7 +858,7 @@ func hammerCompareAndSwapInt32(uaddr *uint32, count int) {
 	addr := (*int32)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadInt32(addr)
 			if CompareAndSwapInt32(addr, v, v+1) {
 				break
 			}
@@ -869,7 +869,7 @@ func hammerCompareAndSwapInt32(uaddr *uint32, count int) {
 func hammerCompareAndSwapUint32(addr *uint32, count int) {
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadUint32(addr)
 			if CompareAndSwapUint32(addr, v, v+1) {
 				break
 			}
@@ -883,7 +883,7 @@ func hammerCompareAndSwapUintptr32(uaddr *uint32, count int) {
 	addr := (*uintptr)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadUintptr(addr)
 			if CompareAndSwapUintptr(addr, v, v+1) {
 				break
 			}
@@ -897,7 +897,7 @@ func hammerCompareAndSwapPointer32(uaddr *uint32, count int) {
 	addr := (*unsafe.Pointer)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadPointer(addr)
 			if CompareAndSwapPointer(addr, v, unsafe.Pointer(uintptr(v)+1)) {
 				break
 			}
@@ -1039,7 +1039,7 @@ func hammerCompareAndSwapInt64(uaddr *uint64, count int) {
 	addr := (*int64)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadInt64(addr)
 			if CompareAndSwapInt64(addr, v, v+1) {
 				break
 			}
@@ -1050,7 +1050,7 @@ func hammerCompareAndSwapInt64(uaddr *uint64, count int) {
 func hammerCompareAndSwapUint64(addr *uint64, count int) {
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadUint64(addr)
 			if CompareAndSwapUint64(addr, v, v+1) {
 				break
 			}
@@ -1064,7 +1064,7 @@ func hammerCompareAndSwapUintptr64(uaddr *uint64, count int) {
 	addr := (*uintptr)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadUintptr(addr)
 			if CompareAndSwapUintptr(addr, v, v+1) {
 				break
 			}
@@ -1078,7 +1078,7 @@ func hammerCompareAndSwapPointer64(uaddr *uint64, count int) {
 	addr := (*unsafe.Pointer)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadPointer(addr)
 			if CompareAndSwapPointer(addr, v, unsafe.Pointer(uintptr(v)+1)) {
 				break
 			}
-- 
1.8.4.2


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gofrontend-dev] [PATCH 2/4] Gccgo port to s390[x] -- part II
  2014-11-04 12:15 [PATCH 2/4] Gccgo port to s390[x] -- part II Dominik Vogt
@ 2014-11-05  3:40 ` Ian Taylor
  2014-11-05  3:55 ` Ian Taylor
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Taylor @ 2014-11-05  3:40 UTC (permalink / raw)
  To: Dominik Vogt, gcc-patches, gofrontend-dev

[-- Attachment #1: Type: text/plain, Size: 270 bytes --]

Part of this patch duplicates a patch that is already applied to the
master Go library, so I explicitly backported that patch
(https://codereview.appspot.com/111320044) instead.

Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu.
Committed to mainline.

Ian

[-- Attachment #2: foo.txt --]
[-- Type: text/plain, Size: 1955 bytes --]

diff -r 3b8f536b76d8 libgo/go/sync/atomic/atomic_test.go
--- a/libgo/go/sync/atomic/atomic_test.go	Tue Nov 04 14:36:54 2014 -0800
+++ b/libgo/go/sync/atomic/atomic_test.go	Tue Nov 04 19:37:03 2014 -0800
@@ -858,7 +858,7 @@
 	addr := (*int32)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadInt32(addr)
 			if CompareAndSwapInt32(addr, v, v+1) {
 				break
 			}
@@ -869,7 +869,7 @@
 func hammerCompareAndSwapUint32(addr *uint32, count int) {
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadUint32(addr)
 			if CompareAndSwapUint32(addr, v, v+1) {
 				break
 			}
@@ -883,7 +883,7 @@
 	addr := (*uintptr)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadUintptr(addr)
 			if CompareAndSwapUintptr(addr, v, v+1) {
 				break
 			}
@@ -897,7 +897,7 @@
 	addr := (*unsafe.Pointer)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadPointer(addr)
 			if CompareAndSwapPointer(addr, v, unsafe.Pointer(uintptr(v)+1)) {
 				break
 			}
@@ -1039,7 +1039,7 @@
 	addr := (*int64)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadInt64(addr)
 			if CompareAndSwapInt64(addr, v, v+1) {
 				break
 			}
@@ -1050,7 +1050,7 @@
 func hammerCompareAndSwapUint64(addr *uint64, count int) {
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadUint64(addr)
 			if CompareAndSwapUint64(addr, v, v+1) {
 				break
 			}
@@ -1064,7 +1064,7 @@
 	addr := (*uintptr)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadUintptr(addr)
 			if CompareAndSwapUintptr(addr, v, v+1) {
 				break
 			}
@@ -1078,7 +1078,7 @@
 	addr := (*unsafe.Pointer)(unsafe.Pointer(uaddr))
 	for i := 0; i < count; i++ {
 		for {
-			v := *addr
+			v := LoadPointer(addr)
 			if CompareAndSwapPointer(addr, v, unsafe.Pointer(uintptr(v)+1)) {
 				break
 			}

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gofrontend-dev] [PATCH 2/4] Gccgo port to s390[x] -- part II
  2014-11-04 12:15 [PATCH 2/4] Gccgo port to s390[x] -- part II Dominik Vogt
  2014-11-05  3:40 ` [gofrontend-dev] " Ian Taylor
@ 2014-11-05  3:55 ` Ian Taylor
  1 sibling, 0 replies; 3+ messages in thread
From: Ian Taylor @ 2014-11-05  3:55 UTC (permalink / raw)
  To: Dominik Vogt, gcc-patches, gofrontend-dev

For the rest of this patch, I replied on the bug
(http://gcc.gnu.org/PR63269).  I'm not persuaded that the approach
this patch takes is correct.

Ian

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-05  3:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-04 12:15 [PATCH 2/4] Gccgo port to s390[x] -- part II Dominik Vogt
2014-11-05  3:40 ` [gofrontend-dev] " Ian Taylor
2014-11-05  3:55 ` Ian Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).