From patchwork Sat Feb 12 18:30:56 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 82941 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 9D480B7113 for ; Sun, 13 Feb 2011 05:31:06 +1100 (EST) Received: (qmail 24051 invoked by alias); 12 Feb 2011 18:31:04 -0000 Received: (qmail 24038 invoked by uid 22791); 12 Feb 2011 18:31:03 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-iw0-f175.google.com (HELO mail-iw0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 12 Feb 2011 18:30:59 +0000 Received: by iwn8 with SMTP id 8so3589276iwn.20 for ; Sat, 12 Feb 2011 10:30:56 -0800 (PST) MIME-Version: 1.0 Received: by 10.42.228.199 with SMTP id jf7mr2410363icb.459.1297535456755; Sat, 12 Feb 2011 10:30:56 -0800 (PST) Received: by 10.42.230.68 with HTTP; Sat, 12 Feb 2011 10:30:56 -0800 (PST) Date: Sat, 12 Feb 2011 18:30:56 +0000 Message-ID: Subject: [v3] avoid duplicate definitions in in C++0x mode From: Jonathan Wakely To: "libstdc++" , gcc-patches 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 2011-02-12 Paolo Carlini * include/tr1/cmath (fabs): Define. * include/tr1/complex (acos, asin, atan): Avoid duplicate definitions in C++0x mode. 2011-02-12 Jonathan Wakely * testsuite/tr1/headers/c++200x/complex.cc: New. tested x86_64-linux, committed to trunk Index: include/tr1/cmath =================================================================== --- include/tr1/cmath (revision 169994) +++ include/tr1/cmath (working copy) @@ -1,6 +1,7 @@ // TR1 cmath -*- C++ -*- -// Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -575,7 +576,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return expm1(__type(__x)); } - using std::fabs; + // Note: we deal with fabs in a special way, because an using std::fabs + // would bring in also the overloads for complex types, which in C++0x + // mode have a different return type. + using ::fabs; + + inline float + fabs(float __x) + { return __builtin_fabsf(__x); } + + inline long double + fabs(long double __x) + { return __builtin_fabsl(__x); } + + template + inline typename __gnu_cxx::__enable_if<__is_integer<_Tp>::__value, + double>::__type + fabs(_Tp __x) + { return __builtin_fabs(__x); } inline float fdim(float __x, float __y) Index: include/tr1/complex =================================================================== --- include/tr1/complex (revision 169994) +++ include/tr1/complex (working copy) @@ -1,6 +1,7 @@ // TR1 complex -*- C++ -*- -// Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 +// Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -44,16 +45,24 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @{ */ - // Forward declarations. +#ifdef __GXX_EXPERIMENTAL_CXX0X__ + using std::acos; + using std::asin; + using std::atan; +#else template std::complex<_Tp> acos(const std::complex<_Tp>&); template std::complex<_Tp> asin(const std::complex<_Tp>&); template std::complex<_Tp> atan(const std::complex<_Tp>&); +#endif template std::complex<_Tp> acosh(const std::complex<_Tp>&); template std::complex<_Tp> asinh(const std::complex<_Tp>&); template std::complex<_Tp> atanh(const std::complex<_Tp>&); + + // The std::fabs return type in C++0x mode is different (just _Tp). template std::complex<_Tp> fabs(const std::complex<_Tp>&); +#ifndef __GXX_EXPERIMENTAL_CXX0X__ template inline std::complex<_Tp> __complex_acos(const std::complex<_Tp>& __z) @@ -170,6 +179,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return __complex_atan(__z); } #endif +#endif // __GXX_EXPERIMENTAL_CXX0X__ + template std::complex<_Tp> __complex_acosh(const std::complex<_Tp>& __z) Index: testsuite/tr1/headers/c++200x/complex.cc =================================================================== --- testsuite/tr1/headers/c++200x/complex.cc (revision 0) +++ testsuite/tr1/headers/c++200x/complex.cc (revision 0) @@ -0,0 +1,26 @@ +// { dg-do compile } +// { dg-options "-std=gnu++0x" } + +// Copyright (C) 2011 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +// check for duplicates of complex overloads of acos, asin, atan and fabs + +#include +#include +#include +