This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gccgo] Use O_BINARY


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<std::string> 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;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]