From b9fc58968940f8cc8afa3cc066e09a98e57a786f Mon Sep 17 00:00:00 2001 From: doko Date: Wed, 9 Sep 2015 17:27:29 +0000 Subject: * libgo: Fix PR go/67508, rewrite lfstack packing/unpacking to look more like that in Go (Michael Hudson). LP: #1472650. git-svn-id: svn://anonscm.debian.org/gcccvs/branches/sid/gcc-5@8219 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca --- debian/changelog | 2 + debian/patches/pr67508.diff | 107 ++++++++++++++++++++++++++++++++++++++++++++ debian/rules.patch | 1 + 3 files changed, 110 insertions(+) create mode 100644 debian/patches/pr67508.diff diff --git a/debian/changelog b/debian/changelog index a47fc85..64e7ae9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ gcc-5 (5.2.1-17) UNRELEASED; urgency=medium Closes: #796906. * Don't ignore anymore bootstrap comparison failures on sh4. Closes: #796939. * Fix stage1 cross build for KFreeBSD. Closes: #796901. + * libgo: Fix PR go/67508, rewrite lfstack packing/unpacking to look more + like that in Go (Michael Hudson). LP: #1472650. [ Aurelien Jarno ] * Use --with-mips-plt on mips*. diff --git a/debian/patches/pr67508.diff b/debian/patches/pr67508.diff new file mode 100644 index 0000000..906a4cf --- /dev/null +++ b/debian/patches/pr67508.diff @@ -0,0 +1,107 @@ +# DP: libgo: Fix PR go/67508, rewrite lfstack packing/unpacking +# DP: to look more like that in Go + +From 95eb3733500feffc2eeeec5bcfac7e34583514e2 Mon Sep 17 00:00:00 2001 +From: Michael Hudson-Doyle +Date: Fri, 31 Jul 2015 11:45:45 +1200 +Subject: [PATCH] runtime: rewrite lfstack packing/unpacking to look more like that in Go + +Change-Id: I4ca61240c3f69c6dce1fde8d859f8507dfab80fc +--- + +diff --git a/libgo/runtime/lfstack.goc b/libgo/runtime/lfstack.goc +index 060a0cc..9eb80d9 100644 +--- a/src/libgo/runtime/lfstack.goc ++++ b/src/libgo/runtime/lfstack.goc +@@ -9,25 +9,41 @@ + #include "arch.h" + + #if __SIZEOF_POINTER__ == 8 +-// Amd64 uses 48-bit virtual addresses, 47-th bit is used as kernel/user flag. +-// So we use 17msb of pointers as ABA counter. +-# define PTR_BITS 47 +-#else +-# define PTR_BITS 32 +-#endif +-#define PTR_MASK ((1ull<> CNT_BITS) << 3); ++} ++#else ++static inline uint64 lfPack(LFNode *node, uintptr cnt) { ++ return ((uint64)(uintptr)(node)<<32) | cnt; ++} ++static inline LFNode* lfUnpack(uint64 val) { ++ return (LFNode*)(uintptr)(val >> 32); ++} + #endif + + void +@@ -35,16 +51,16 @@ + { + uint64 old, new; + +- if((uintptr)node != ((uintptr)node&PTR_MASK)) { ++ if(node != lfUnpack(lfPack(node, 0))) { + runtime_printf("p=%p\n", node); + runtime_throw("runtime_lfstackpush: invalid pointer"); + } + + node->pushcnt++; +- new = (uint64)(uintptr)node|(((uint64)node->pushcnt&CNT_MASK)<pushcnt); + for(;;) { + old = runtime_atomicload64(head); +- node->next = (LFNode*)(uintptr)(old&PTR_MASK); ++ node->next = lfUnpack(old); + if(runtime_cas64(head, old, new)) + break; + } +@@ -60,11 +76,11 @@ + old = runtime_atomicload64(head); + if(old == 0) + return nil; +- node = (LFNode*)(uintptr)(old&PTR_MASK); ++ node = lfUnpack(old); + node2 = runtime_atomicloadp(&node->next); + new = 0; + if(node2 != nil) +- new = (uint64)(uintptr)node2|(((uint64)node2->pushcnt&CNT_MASK)<pushcnt); + if(runtime_cas64(head, old, new)) + return node; + } diff --git a/debian/rules.patch b/debian/rules.patch index f1975d3..dd98282 100644 --- a/debian/rules.patch +++ b/debian/rules.patch @@ -89,6 +89,7 @@ debian_patches += \ gccgo-sendfile-fix \ pr66368 \ pr67280 \ + pr67508 \ ifeq ($(libstdcxx_abi),new) debian_patches += libstdc++-functexcept -- cgit v1.2.3