From patchwork Fri Apr 27 16:38:37 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: 155542 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 6C0A2B6F6E for ; Sat, 28 Apr 2012 02:39:00 +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=1336149541; 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=tyG+YBsPsC+L+spzxMkGDrbG+o4=; b=kW31nQSb4q0tw8P /Bfj/QleoANRudE3AHiWQ3pG/zCwq3dXYMsDXPraalrzQPBkK/L2hiXiqWmeJe6H uJTvHrnhxfHBqYVkbzkudF/5BwvKG1jKw+2lex4xa2+eGODEFuaV6ktPUtoxxtwl yPoEWwZ3K1NJqVrgG4kz5esYf0Y4= 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=bYuUMR3L4w+95zOr84xP0jctZkfXGr9/P0XuIbEUqxOTe82wn91c/VCq2DljKe ouPuDqa0I6BypZWqKX6YmrymzaOxzq22+rBl0Vq/lkEqPo0o4JQUwPJALC7/ZqJz R4Yjno0tfPB0RW4Tu3e4KH4UDGhYRnN5rjJS9p4c8e04U=; Received: (qmail 5098 invoked by alias); 27 Apr 2012 16:38:56 -0000 Received: (qmail 4957 invoked by uid 22791); 27 Apr 2012 16:38:54 -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, TW_FN, 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:38:40 +0000 Received: by iakk32 with SMTP id k32so1512434iak.20 for ; Fri, 27 Apr 2012 09:38:39 -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=2rDVPnD+rDFH9Lkqpbtq4PzWBG+GjC6WSHS7K7LNm7U=; b=R+V+h0Jdlvt7AKuNptoCtXSqKN4jCIBCL7hkRQRfPxsBGhntF9LzIzBt++SpigxZWk NO0bcR3ua37qXEOWgrkQZ+ppGSnz9FqwONtWenAHm6eaEI9YxwHFYn60beLcc/nLynct F0jBLBdR7okxd7AQmGZtc8/wfOZLpseN3pp37UPqwS7tMOoFDYaU1vg5+iouDMlQhkef nId5ExKwO+yWtQ9lllCQLigsTR2y9vMolqk3+N0RDUj8IuIrvwx6bCkyr1SGmiZglcUf JtQ7OqCDApEIvgJ5tYj26yO5SjwopIjgTwcHTtzSA6HvJf9Dm7a0TJMf7VT7AptQuCox Rndw== Received: by 10.50.187.169 with SMTP id ft9mr3457250igc.59.1335544719293; Fri, 27 Apr 2012 09:38:39 -0700 (PDT) Received: by 10.50.187.169 with SMTP id ft9mr3457233igc.59.1335544719197; Fri, 27 Apr 2012 09:38:39 -0700 (PDT) Received: from coign.google.com ([2620:0:1000:2301:f2de:f1ff:fe40:72a8]) by mx.google.com with ESMTPS id c2sm7317243igj.1.2012.04.27.09.38.37 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 27 Apr 2012 09:38:38 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: libgo patch committed: Provide i386 long double math fns if needed Date: Fri, 27 Apr 2012 09:38:37 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-Gm-Message-State: ALoCoQkNIRDbcfzvXOotLQKK5lkM/ozGPSuzi8Pu+QFU2QYgD9Ni8GnNFBjsWeAEPoYCi1suBIpFBct/cFudP1byT2VzbYdcXQ2BqBVioGXGOmF4B2Qbzg5ke/4JcHOtdV30ue0bN2KVlbMVqguEgqWF6+lpIk8CVfmV55JdYcKy8dA3PzFWGFg= 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 patch to libgo provides the long double math functions if they are not in the system libm. This is needed on i386 because the Go frontend automatically converts calls to these functions from float64 (aka C double) to C long double, as guided by express_precision_type. This is done so that the compiler can use the x87 instructions when available. However, when not optimizing, the compiler will still emit a call to the function. This occurs in particular when running the libgo math test; I'm not sure it actually happens at any other time. This patch provides a sufficient implementation of these functions for use by Go. This fixes another 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 a253ccfa3489 libgo/configure.ac --- a/libgo/configure.ac Fri Apr 27 09:30:57 2012 -0700 +++ b/libgo/configure.ac Fri Apr 27 09:33:21 2012 -0700 @@ -489,6 +489,11 @@ AC_TYPE_OFF_T AC_CHECK_TYPES([loff_t]) +LIBS_hold="$LIBS" +LIBS="$LIBS -lm" +AC_CHECK_FUNCS(cosl expl logl sinl tanl acosl asinl atanl atan2l expm1l ldexpl log10l log1pl) +LIBS="$LIBS_hold" + CFLAGS_hold="$CFLAGS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" LIBS_hold="$LIBS" diff -r a253ccfa3489 libgo/runtime/go-nosys.c --- a/libgo/runtime/go-nosys.c Fri Apr 27 09:30:57 2012 -0700 +++ b/libgo/runtime/go-nosys.c Fri Apr 27 09:33:21 2012 -0700 @@ -13,6 +13,7 @@ #include #include +#include #include #include #include @@ -239,3 +240,116 @@ return -1; } #endif + +/* Long double math functions. These are needed on old i386 systems + that don't have them in libm. The compiler translates calls to + these functions on float64 to call an 80-bit floating point + function instead, because when optimizing that function can be + executed as an x87 instructure. However, when not optimizing, this + translates into a call to the math function. So on systems that + don't provide these functions, we provide a version that just calls + the float64 version. */ + +#ifndef HAVE_COSL +long double +cosl (long double a) +{ + return (long double) cos ((double) a); +} +#endif + +#ifndef HAVE_EXPL +long double +expl (long double a) +{ + return (long double) exp ((double) a); +} +#endif + +#ifndef HAVE_LOGL +long double +logl (long double a) +{ + return (long double) log ((double) a); +} +#endif + +#ifndef HAVE_SINL +long double +sinl (long double a) +{ + return (long double) sin ((double) a); +} +#endif + +#ifndef HAVE_TANL +long double +tanl (long double a) +{ + return (long double) tan ((double) a); +} +#endif + +#ifndef HAVE_ACOSL +long double +acosl (long double a) +{ + return (long double) acos ((double) a); +} +#endif + +#ifndef HAVE_ASINL +long double +asinl (long double a) +{ + return (long double) asin ((double) a); +} +#endif + +#ifndef HAVE_ATANL +long double +atanl (long double a) +{ + return (long double) atan ((double) a); +} +#endif + +#ifndef HAVE_ATAN2L +long double +atan2l (long double a, long double b) +{ + return (long double) atan2 ((double) a, (double) b); +} +#endif + +#ifndef HAVE_EXPM1L +long double +expm1l (long double a) +{ + return (long double) expm1 ((double) a); +} +#endif + +#ifndef HAVE_LDEXPL +long double +ldexpl (long double a, int exp) +{ + return (long double) ldexp ((double) a, exp); +} +#endif + +#ifndef HAVE_LOG10L +long double +log10l (long double a) +{ + return (long double) log10 ((double) a); +} +#endif + +#ifndef HAVE_LOG1PL +long double +log1pl (long double a) +{ + return (long double) log1p ((double) a); +} +#endif