From patchwork Fri Aug 12 15:41:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 109862 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 7567BB6F76 for ; Sat, 13 Aug 2011 01:42:18 +1000 (EST) Received: (qmail 22646 invoked by alias); 12 Aug 2011 15:42:14 -0000 Received: (qmail 22632 invoked by uid 22791); 12 Aug 2011 15:42:12 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from rcsinet15.oracle.com (HELO rcsinet15.oracle.com) (148.87.113.117) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 12 Aug 2011 15:41:59 +0000 Received: from rtcsinet22.oracle.com (rtcsinet22.oracle.com [66.248.204.30]) by rcsinet15.oracle.com (Switch-3.4.4/Switch-3.4.4) with ESMTP id p7CFfuPK018152 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Fri, 12 Aug 2011 15:41:58 GMT Received: from acsmt357.oracle.com (acsmt357.oracle.com [141.146.40.157]) by rtcsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id p7CFft6c013861 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 12 Aug 2011 15:41:56 GMT Received: from abhmt110.oracle.com (abhmt110.oracle.com [141.146.116.62]) by acsmt357.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id p7CFfobD024291; Fri, 12 Aug 2011 10:41:50 -0500 Received: from [192.168.1.4] (/79.43.213.120) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 12 Aug 2011 08:41:49 -0700 Message-ID: <4E4549AF.6000704@oracle.com> Date: Fri, 12 Aug 2011 17:41:35 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110624 Thunderbird/5.0 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] Add missing std::fmod overload 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 Hi, tested x86_64-linux, committed to mainline. Paolo. PS: will add separately tests for the C++11 facilities. ////////////// 2011-08-12 Paolo Carlini * include/c_global/cmath (fmod(_Tp, _Up)): Add. * include/c_std/cmath: Likewise. Index: include/c_std/cmath =================================================================== --- include/c_std/cmath (revision 177696) +++ include/c_std/cmath (working copy) @@ -268,6 +268,13 @@ fmod(long double __x, long double __y) { return __builtin_fmodl(__x, __y); } + template + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value + && __is_integer<_Up>::__value, + double>::__type + fmod(_Tp __x, _Up __y) + { return __builtin_fmod(__x, __y); } + using ::frexp; inline float Index: include/c_global/cmath =================================================================== --- include/c_global/cmath (revision 177696) +++ include/c_global/cmath (working copy) @@ -282,6 +282,18 @@ fmod(long double __x, long double __y) { return __builtin_fmodl(__x, __y); } + template + inline _GLIBCXX_CONSTEXPR + typename __gnu_cxx::__promote_2< + typename __gnu_cxx::__enable_if<__is_arithmetic<_Tp>::__value + && __is_arithmetic<_Up>::__value, + _Tp>::__type, _Up>::__type + fmod(_Tp __x, _Up __y) + { + typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type; + return fmod(__type(__x), __type(__y)); + } + using ::frexp; inline _GLIBCXX_CONSTEXPR float @@ -313,8 +325,8 @@ inline _GLIBCXX_CONSTEXPR typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, double>::__type - ldexp(_Tp __x, int __exp) - { return __builtin_ldexp(__x, __exp); } + ldexp(_Tp __x, int __exp) + { return __builtin_ldexp(__x, __exp); } using ::log;