Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/IceCompileServer.cpp

Issue 1370323005: Remove dependence on header file unistd.h. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceCompileServer.cpp - Compile server ------------------===// 1 //===- subzero/src/IceCompileServer.cpp - Compile server ------------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 /// 9 ///
10 /// \file 10 /// \file
(...skipping 11 matching lines...) Expand all
22 #pragma clang diagnostic push 22 #pragma clang diagnostic push
23 #pragma clang diagnostic ignored "-Wunused-parameter" 23 #pragma clang diagnostic ignored "-Wunused-parameter"
24 #include "llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h" 24 #include "llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h"
25 #include "llvm/Support/FileSystem.h" 25 #include "llvm/Support/FileSystem.h"
26 #include "llvm/Support/raw_os_ostream.h" 26 #include "llvm/Support/raw_os_ostream.h"
27 #include "llvm/Support/Signals.h" 27 #include "llvm/Support/Signals.h"
28 #include "llvm/Support/SourceMgr.h" 28 #include "llvm/Support/SourceMgr.h"
29 #include "llvm/Support/StreamingMemoryObject.h" 29 #include "llvm/Support/StreamingMemoryObject.h"
30 #pragma clang diagnostic pop 30 #pragma clang diagnostic pop
31 31
32 #include <cstdio>
32 #include <fstream> 33 #include <fstream>
33 #include <iostream> 34 #include <iostream>
34 #include <thread> 35 #include <thread>
35 36
36 #if defined(HAVE_UNISTD_H)
37 # include <unistd.h>
38 #endif
39 #if defined(_MSC_VER)
40 # include <io.h>
41 # include <fcntl.h>
42 #endif
43
44 namespace Ice { 37 namespace Ice {
45 38
46 namespace { 39 namespace {
47 40
48 // Define a SmallVector backed buffer as a data stream, so that it can hold the 41 // Define a SmallVector backed buffer as a data stream, so that it can hold the
49 // generated binary version of the textual bitcode in the input file. 42 // generated binary version of the textual bitcode in the input file.
50 class TextDataStreamer : public llvm::DataStreamer { 43 class TextDataStreamer : public llvm::DataStreamer {
51 public: 44 public:
52 TextDataStreamer() = default; 45 TextDataStreamer() = default;
53 ~TextDataStreamer() final = default; 46 ~TextDataStreamer() final = default;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 102
110 // Note: This code is (mostly) copied from llvm/lib/Support/ErrorHandling.cpp 103 // Note: This code is (mostly) copied from llvm/lib/Support/ErrorHandling.cpp
111 104
112 // Blast the result out to stderr. We don't try hard to make sure this 105 // Blast the result out to stderr. We don't try hard to make sure this
113 // succeeds (e.g. handling EINTR) and we can't use errs() here because 106 // succeeds (e.g. handling EINTR) and we can't use errs() here because
114 // raw ostreams can call report_fatal_error. 107 // raw ostreams can call report_fatal_error.
115 llvm::SmallVector<char, 64> Buffer; 108 llvm::SmallVector<char, 64> Buffer;
116 llvm::raw_svector_ostream OS(Buffer); 109 llvm::raw_svector_ostream OS(Buffer);
117 OS << "LLVM ERROR: " << Reason << "\n"; 110 OS << "LLVM ERROR: " << Reason << "\n";
118 llvm::StringRef MessageStr = OS.str(); 111 llvm::StringRef MessageStr = OS.str();
119 ssize_t written = ::write(2, MessageStr.data(), MessageStr.size()); 112 ssize_t written =
113 ::fwrite(MessageStr.data(), sizeof(char), MessageStr.size(), ::stdout);
120 (void)written; // If something went wrong, we deliberately just give up. 114 (void)written; // If something went wrong, we deliberately just give up.
121 115
122 // If we reached here, we are failing ungracefully. Run the interrupt handlers 116 // If we reached here, we are failing ungracefully. Run the interrupt handlers
123 // to make sure any special cleanups get done, in particular that we remove 117 // to make sure any special cleanups get done, in particular that we remove
124 // files registered with RemoveFileOnSignal. 118 // files registered with RemoveFileOnSignal.
125 llvm::sys::RunInterruptHandlers(); 119 llvm::sys::RunInterruptHandlers();
126 120
127 exit(0); 121 exit(0);
128 } 122 }
129 123
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 }); 201 });
208 CompileThread.join(); 202 CompileThread.join();
209 } else { 203 } else {
210 getCompiler().run(ExtraFlags, *Ctx.get(), std::move(InputStream)); 204 getCompiler().run(ExtraFlags, *Ctx.get(), std::move(InputStream));
211 } 205 }
212 transferErrorCode(getReturnValue( 206 transferErrorCode(getReturnValue(
213 ExtraFlags, static_cast<ErrorCodes>(Ctx->getErrorStatus()->value()))); 207 ExtraFlags, static_cast<ErrorCodes>(Ctx->getErrorStatus()->value())));
214 } 208 }
215 209
216 } // end of namespace Ice 210 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698