From patchwork Wed Nov 17 22:34:37 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 71627 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 8E052B70A5 for ; Thu, 18 Nov 2010 09:34:57 +1100 (EST) Received: (qmail 27924 invoked by alias); 17 Nov 2010 22:34:50 -0000 Received: (qmail 27779 invoked by uid 22791); 17 Nov 2010 22:34:49 -0000 X-SWARE-Spam-Status: No, hits=-4.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 17 Nov 2010 22:34:44 +0000 Received: from hpaq5.eem.corp.google.com (hpaq5.eem.corp.google.com [172.25.149.5]) by smtp-out.google.com with ESMTP id oAHMYfk4028753 for ; Wed, 17 Nov 2010 14:34:41 -0800 Received: from ywp6 (ywp6.prod.google.com [10.192.16.6]) by hpaq5.eem.corp.google.com with ESMTP id oAHMWqJ0020445 for ; Wed, 17 Nov 2010 14:34:40 -0800 Received: by ywp6 with SMTP id 6so1632628ywp.31 for ; Wed, 17 Nov 2010 14:34:40 -0800 (PST) Received: by 10.151.149.18 with SMTP id b18mr15041328ybo.197.1290033280192; Wed, 17 Nov 2010 14:34:40 -0800 (PST) Received: from coign.google.com (dhcp-172-22-124-218.mtv.corp.google.com [172.22.124.218]) by mx.google.com with ESMTPS id q31sm4230569yba.18.2010.11.17.14.34.38 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 17 Nov 2010 14:34:39 -0800 (PST) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org, gofrontend-dev@googlegroups.com Subject: [gccgo] Use O_BINARY Date: Wed, 17 Nov 2010 14:34:37 -0800 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true 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 the Go frontend uses O_BINARY when opening an import file. O_BINARY is #defined to 0 if it is not defined in a header file. Committed to gccgo branch. Ian diff -r 098977b2e132 go/import-archive.cc --- a/go/import-archive.cc Wed Nov 17 14:28:32 2010 -0800 +++ b/go/import-archive.cc Wed Nov 17 14:33:09 2010 -0800 @@ -8,6 +8,10 @@ #include "import.h" +#ifndef O_BINARY +#define O_BINARY 0 +#endif + // Archive magic numbers. static const char armag[] = @@ -365,7 +369,7 @@ nfile = p->second; else { - int nfd = open(filename.c_str(), O_RDONLY); + int nfd = open(filename.c_str(), O_RDONLY | O_BINARY); if (nfd < 0) { error_at(this->location_, "%s: can't open nested archive %s", @@ -391,7 +395,7 @@ } // An external member of a thin archive. - *memfd = open(filename.c_str(), O_RDONLY); + *memfd = open(filename.c_str(), O_RDONLY | O_BINARY); if (*memfd < 0) { error_at(this->location_, "%s: %m", filename.c_str()); diff -r 098977b2e132 go/import.cc --- a/go/import.cc Wed Nov 17 14:28:32 2010 -0800 +++ b/go/import.cc Wed Nov 17 14:33:09 2010 -0800 @@ -15,6 +15,10 @@ #include "export.h" #include "import.h" +#ifndef O_BINARY +#define O_BINARY 0 +#endif + // The list of paths we search for import files. static std::vector search_path; @@ -84,7 +88,7 @@ source_location location) { std::string found_filename = filename; - int fd = open(found_filename.c_str(), O_RDONLY); + int fd = open(found_filename.c_str(), O_RDONLY | O_BINARY); if (fd >= 0) { @@ -128,7 +132,7 @@ Import::try_suffixes(std::string* pfilename) { std::string filename = *pfilename + ".gox"; - int fd = open(filename.c_str(), O_RDONLY); + int fd = open(filename.c_str(), O_RDONLY | O_BINARY); if (fd >= 0) { *pfilename = filename; @@ -138,7 +142,7 @@ const char* basename = lbasename(pfilename->c_str()); size_t basename_pos = basename - pfilename->c_str(); filename = pfilename->substr(0, basename_pos) + "lib" + basename + ".so"; - fd = open(filename.c_str(), O_RDONLY); + fd = open(filename.c_str(), O_RDONLY | O_BINARY); if (fd >= 0) { *pfilename = filename; @@ -146,7 +150,7 @@ } filename = pfilename->substr(0, basename_pos) + "lib" + basename + ".a"; - fd = open(filename.c_str(), O_RDONLY); + fd = open(filename.c_str(), O_RDONLY | O_BINARY); if (fd >= 0) { *pfilename = filename; @@ -154,7 +158,7 @@ } filename = *pfilename + ".o"; - fd = open(filename.c_str(), O_RDONLY); + fd = open(filename.c_str(), O_RDONLY | O_BINARY); if (fd >= 0) { *pfilename = filename;