From patchwork Sat Feb 11 00:03:22 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 140736 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B872FB6F98 for ; Sat, 11 Feb 2012 11:03:42 +1100 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1329523425; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: Received:Received:From:To:Subject:Date:Message-ID:User-Agent: MIME-Version:Content-Type:Mailing-List:Precedence:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=SK62GoOLK3CwIXnT5qD+s8Keuxc=; b=o9Uga5KHp91LVJ+ iaP+n7gJevgtIIEVzJhMLGpEN0m5NjG5VYNsk5ReyihW6K9JQHScpJTBVeu29MR9 NQy07G44P41jGTWKzVgUarHof+oXC4m0jAdKZQnJB4vaUfu+o737KdbvDssKjUfS BkabXsO6GrGmbfG0OIz/NKyn7m9k= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:Received:Received:From:To:Subject:Date:Message-ID:User-Agent:MIME-Version:Content-Type:X-Gm-Message-State:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=NE+39zN97IsXVCdgCV2v0+lj7oIuyY4rsq8C7oyrEMiXBBa1Abqb2f5xJiCUBb 0ecA8FZoJeQa2gexZs7rv5CKpK2Dk/+7i55i5WA66cB+6Fe/0WdgqTDFSbWsEoXw UF7UYTFVj8X8NJ0lltv9i+SDnDfJYGX+Ota93ZhKFGyyw=; Received: (qmail 2868 invoked by alias); 11 Feb 2012 00:03:39 -0000 Received: (qmail 2860 invoked by uid 22791); 11 Feb 2012 00:03:38 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-pw0-f47.google.com (HELO mail-pw0-f47.google.com) (209.85.160.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 11 Feb 2012 00:03:25 +0000 Received: by pbcum15 with SMTP id um15so2591169pbc.20 for ; Fri, 10 Feb 2012 16:03:24 -0800 (PST) Received: by 10.68.75.136 with SMTP id c8mr20864525pbw.113.1328918604881; Fri, 10 Feb 2012 16:03:24 -0800 (PST) Received: by 10.68.75.136 with SMTP id c8mr20864459pbw.113.1328918604366; Fri, 10 Feb 2012 16:03:24 -0800 (PST) Received: from coign.google.com ([2620:0:1000:2301:f2de:f1ff:fe40:72a8]) by mx.google.com with ESMTPS id x8sm17286008pbr.11.2012.02.10.16.03.22 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 10 Feb 2012 16:03:23 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed: Fix channels for big-endian & strict-alignment Date: Fri, 10 Feb 2012 16:03:22 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQlrqG7dQEfc1jEeBaE6HxNWLR/8jO7nURqoJZgur0ZMiktNZYCEAxjqzyNS3locNe0pjceEArP2iARJyKOSmvl+BL5NDA0LfpM0f8MPqEh8ftg6fawyFvsH3JO4hsN3i3i0cuQTgOswHs06DjS0O/9EKJT1seB/TlhQbkhKFDudEJ1ELMI= X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This libgo patch fixes the channel code to work correctly on big-endian systems. The older version of the code did this right, but I forgot to handle it in the new version. This patch also fixes the memory structure built for the select statement to work correctly on strict alignment systems. The code was putting a uint16_t array before a pointer array, which would of course cause a SIGBUS on a strict alignment system. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Bootstrapped and ran channel tests on sparc-sun-solaris2.11; the Go testsuite on that system still has some failures but they appear to be due to other problems, such as PR 52205 which I just filed. Committed to mainline. Ian diff -r 93764d4d4aca libgo/runtime/chan.c --- a/libgo/runtime/chan.c Fri Feb 10 07:53:37 2012 -0800 +++ b/libgo/runtime/chan.c Fri Feb 10 15:54:46 2012 -0800 @@ -409,11 +409,20 @@ void __go_send_small(ChanType *t, Hchan* c, uint64 val) { - byte b[sizeof(uint64)]; + union + { + byte b[sizeof(uint64)]; + uint64 v; + } u; + byte *p; - runtime_memclr(b, sizeof(uint64)); - __builtin_memcpy(b, &val, t->__element_type->__size); - runtime_chansend(t, c, b, nil); + u.v = val; +#ifndef WORDS_BIGENDIAN + p = u.b; +#else + p = u.b + sizeof(uint64) - t->__element_type->__size; +#endif + runtime_chansend(t, c, p, nil); } // The compiler generates a call to __go_send_big to send a value @@ -433,9 +442,15 @@ byte b[sizeof(uint64)]; uint64 v; } u; + byte *p; u.v = 0; - runtime_chanrecv(t, c, u.b, nil, nil); +#ifndef WORDS_BIGENDIAN + p = u.b; +#else + p = u.b + sizeof(uint64) - t->__element_type->__size; +#endif + runtime_chanrecv(t, c, p, nil, nil); return u.v; } @@ -654,8 +669,8 @@ sel->tcase = size; sel->ncase = 0; - sel->pollorder = (void*)(sel->scase + size); - sel->lockorder = (void*)(sel->pollorder + size); + sel->lockorder = (void*)(sel->scase + size); + sel->pollorder = (void*)(sel->lockorder + size); *selp = sel; if(debug)