From patchwork Tue Jul 23 09:56:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 261022 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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id A584C2C00BF for ; Tue, 23 Jul 2013 19:56:32 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=JhdwIjzcKfXSEBbQF wCcdbeudban3FpJA4KpnNByEHiTCS7DaJkKPHWw1HvHX1rPAcEnCpOU4f0CE1Uyj wCUy42p7WeU46tXEugwmu+Rt0NGcMaeR1R5P1hH8GDUBW6uIhxOQwcAyGo9pkeKe uhLqR1shsxIZCHSB3/yKeSkOMA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=oPI4KeZZ1jJVmz3qhtxyo31 BweQ=; b=YjtRAKbZeC0Ig5jyn1Dmz/jrLItULD956m71+1R9zhVoovKxV2yzIKX Fn7JJOey0HcxGAajvK5pBQDgnOpedbwiS5nNQGjJDwEhSxIsASGUh7eCZJc32Wwc IP53Xff2V4tP2LGXDi2skGVCtb7UgD6BvseKmh938hsOfNuosrKw= Received: (qmail 18212 invoked by alias); 23 Jul 2013 09:56:26 -0000 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 Received: (qmail 18182 invoked by uid 89); 23 Jul 2013 09:56:25 -0000 X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL, BAYES_50, FSL_NEW_HELO_USER, KHOP_THREADED, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_W, RDNS_NONE, SPF_PASS, TW_SF, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from Unknown (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 23 Jul 2013 09:56:25 +0000 Received: from ucsinet21.oracle.com (ucsinet21.oracle.com [156.151.31.93]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r6N9uGnI026623 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 23 Jul 2013 09:56:17 GMT Received: from userz7021.oracle.com (userz7021.oracle.com [156.151.31.85]) by ucsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r6N9uGjr003055 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Tue, 23 Jul 2013 09:56:16 GMT Received: from abhmt115.oracle.com (abhmt115.oracle.com [141.146.116.67]) by userz7021.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r6N9uGoX003049; Tue, 23 Jul 2013 09:56:16 GMT Received: from poldo4.casa (/79.33.220.41) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 23 Jul 2013 02:56:15 -0700 Message-ID: <51EE533D.1050600@oracle.com> Date: Tue, 23 Jul 2013 11:56:13 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: Chung-Ju Wu CC: "gcc-patches@gcc.gnu.org" , libstdc++ Subject: Re: [v3] libstdc++/57920 References: <51ED2095.9000403@oracle.com> <51EE4C40.7040803@oracle.com> <51EE4E02.20007@oracle.com> In-Reply-To: X-Virus-Found: No ... in the future, when we manage to actually avoid including from I think we can avoid including it from if we play a bit with void*. Should be safe aliasing-wise. Something like the below, completely untested. Paolo. //////////////// Index: include/bits/random.h =================================================================== --- include/bits/random.h (revision 201148) +++ include/bits/random.h (working copy) @@ -1638,10 +1638,10 @@ union { - FILE* _M_file; - mt19937 _M_mt; + void* _M_file; + mt19937 _M_mt; + }; }; - }; /* @} */ // group random_generators Index: include/std/random =================================================================== --- include/std/random (revision 201160) +++ include/std/random (working copy) @@ -36,7 +36,6 @@ #else #include -#include // For FILE #include #include #include Index: src/c++11/random.cc =================================================================== --- src/c++11/random.cc (revision 201160) +++ src/c++11/random.cc (working copy) @@ -30,6 +30,8 @@ # include #endif +#include + #ifdef _GLIBCXX_HAVE_UNISTD_H # include #endif @@ -102,7 +104,7 @@ std::__throw_runtime_error(__N("random_device::" "random_device(const std::string&)")); - _M_file = std::fopen(fname, "rb"); + _M_file = reinterpret_cast(std::fopen(fname, "rb")); if (! _M_file) goto fail; } @@ -117,7 +119,7 @@ random_device::_M_fini() { if (_M_file) - std::fclose(_M_file); + std::fclose(reinterpret_cast(_M_file)); } random_device::result_type @@ -130,10 +132,11 @@ result_type __ret; #ifdef _GLIBCXX_HAVE_UNISTD_H - read(fileno(_M_file), reinterpret_cast(&__ret), sizeof(result_type)); + read(fileno(reinterpret_cast(_M_file)), + reinterpret_cast(&__ret), sizeof(result_type)); #else std::fread(reinterpret_cast(&__ret), sizeof(result_type), - 1, _M_file); + 1, reinterpret_cast(_M_file)); #endif return __ret; }