From patchwork Fri Apr 27 16:33:08 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: 155539 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 741D4B6F6E for ; Sat, 28 Apr 2012 02:33:34 +1000 (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=1336149215; 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=hEjxBYO4TnAQqMotYDNLEPjV+ME=; b=td1MFwvVFZmw71o riYSdJWqqyjs0untjAlhCKip6eExTk18OY2xrCItlpvFnfQrftJHpW9cNNo1xiC7 a+mqcw2TiVC84eCGCzbLvPzrP7GbYPd9AmHt0+noPj7aS7hWfsypOPEw1WPsA1yf 9E8KAdbWTvCIXcvFVWLYUEwUCZZY= 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:X-Google-DKIM-Signature: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=oI91axUyrO2nxb/c6FNVLYvN4qPYgNiyhD2zkVoB9qEA1qZZyEcIx6iJEd6tFg zlvL3D1Bep/U2xt5lvEOJOtKU7EbKLXdYKkg9trI3Zct7idJJFXSDhwD1MFI0y6g mfpCvGoBnd+W8AqDARTlRQCOFMNtahnVHJnNIs3HUCH+s=; Received: (qmail 17241 invoked by alias); 27 Apr 2012 16:33:26 -0000 Received: (qmail 17207 invoked by uid 22791); 27 Apr 2012 16:33:23 -0000 X-SWARE-Spam-Status: No, hits=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from mail-iy0-f175.google.com (HELO mail-iy0-f175.google.com) (209.85.210.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 27 Apr 2012 16:33:10 +0000 Received: by iakk32 with SMTP id k32so1502424iak.20 for ; Fri, 27 Apr 2012 09:33:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type:x-gm-message-state; bh=Dp1A4uieVFxDHeceRT7cQLsG6yL1tqRLTmcRV/MGHsI=; b=QhPvyCF5dC83Mj2cjYXYb9kLdB3PCi5KHI794c9hCgKwy4Bj1EJd6p1jMUbjOABQsF bHfldqZphory8kGijzLnaBd8MUlVuVcGN4Zs4R34WC+GgRW4EWOvRG0iOmqkPXtGlHUj Qn5kw6agx8wcQ98IG1j7ctJnPwfAoc25ZlJDO4C8xyNaPpZke8F3lp3+peOXmW/+Dvec 9Bp8ehSTBJ/giGR9c+f/0/0twSnYDY2wf++hhFgViDdsFM2J+1inJE10nTF/uYR8ZNyl IUpEPMJeT/uBqkCDv1tQjOoGLHZPcH/dZSbvuM4xch8QskxsZs97FpQHkOrxMebOqpWN qnHw== Received: by 10.42.138.200 with SMTP id d8mr9969328icu.45.1335544390369; Fri, 27 Apr 2012 09:33:10 -0700 (PDT) Received: by 10.42.138.200 with SMTP id d8mr9969310icu.45.1335544390188; Fri, 27 Apr 2012 09:33:10 -0700 (PDT) Received: from coign.google.com ([2620:0:1000:2301:f2de:f1ff:fe40:72a8]) by mx.google.com with ESMTPS id pa6sm7230919igc.12.2012.04.27.09.33.08 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Apr 2012 09:33:09 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed: Work around bug in Solaris 9 ldexp Date: Fri, 27 Apr 2012 09:33:08 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmB6S6Q9Xh8ed4SSAlVHpEqeB2Fh7f05lfCKFqKGDPUvhgTSHwNmKl2UTr9hW4abvd3NYVtWe/nXuAEeEogZq70e+3J7r8STDprbFXKtRQXJAohvZD0LsuFCfBs1alfgVX+OzxxlragZayX8Oj/kRLd/bXJWavmIuONZA63HjguSMrHCNI= 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 The Solaris 9 ldexp function has a bug: ldexp(-1, -1075) returns positive zero when it should return negative zero. This patch works around this bug in the Go math package. This fixes part of PR 52358. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu and i386-sun-solaris2.9. Committed to mainline and 4.7 branch. Ian diff -r c1d1d764b7a6 libgo/go/math/ldexp.go --- a/libgo/go/math/ldexp.go Fri Apr 27 09:26:59 2012 -0700 +++ b/libgo/go/math/ldexp.go Fri Apr 27 09:29:05 2012 -0700 @@ -16,7 +16,18 @@ func libc_ldexp(float64, int) float64 func Ldexp(frac float64, exp int) float64 { - return libc_ldexp(frac, exp) + r := libc_ldexp(frac, exp) + + // Work around a bug in the implementation of ldexp on Solaris + // 9. If multiplying a negative number by 2 raised to a + // negative exponent underflows, we want to return negative + // zero, but the Solaris 9 implementation returns positive + // zero. This workaround can be removed when and if we no + // longer care about Solaris 9. + if r == 0 && frac < 0 && exp < 0 { + r = Copysign(0, frac) + } + return r } func ldexp(frac float64, exp int) float64 {