OLD | NEW |
1 //===- llvm/Support/Unix/Program.cpp -----------------------------*- C++ -*-===/
/ | 1 //===- llvm/Support/Unix/Program.cpp -----------------------------*- C++ -*-===/
/ |
2 // | 2 // |
3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
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 // This file implements the Unix specific portion of the Program class. | 10 // This file implements the Unix specific portion of the Program class. |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 | 303 |
304 PI.Pid = child; | 304 PI.Pid = child; |
305 | 305 |
306 return true; | 306 return true; |
307 } | 307 } |
308 | 308 |
309 namespace llvm { | 309 namespace llvm { |
310 | 310 |
311 ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait, | 311 ProcessInfo sys::Wait(const ProcessInfo &PI, unsigned SecondsToWait, |
312 bool WaitUntilTerminates, std::string *ErrMsg) { | 312 bool WaitUntilTerminates, std::string *ErrMsg) { |
313 #ifdef HAVE_SYS_WAIT_H | 313 // @LOCALMOD-BEGIN |
| 314 #if defined(HAVE_SYS_WAIT_H) && !defined(PNACL_BROWSER_TRANSLATOR) |
| 315 // @LOCALMOD-END |
314 struct sigaction Act, Old; | 316 struct sigaction Act, Old; |
315 assert(PI.Pid && "invalid pid to wait on, process not started?"); | 317 assert(PI.Pid && "invalid pid to wait on, process not started?"); |
316 | 318 |
317 int WaitPidOptions = 0; | 319 int WaitPidOptions = 0; |
318 pid_t ChildPid = PI.Pid; | 320 pid_t ChildPid = PI.Pid; |
319 if (WaitUntilTerminates) { | 321 if (WaitUntilTerminates) { |
320 SecondsToWait = 0; | 322 SecondsToWait = 0; |
321 } else if (SecondsToWait) { | 323 } else if (SecondsToWait) { |
322 // Install a timeout handler. The handler itself does nothing, but the | 324 // Install a timeout handler. The handler itself does nothing, but the |
323 // simple fact of having a handler at all causes the wait below to return | 325 // simple fact of having a handler at all causes the wait below to return |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 436 |
435 OS << Contents; | 437 OS << Contents; |
436 | 438 |
437 if (OS.has_error()) | 439 if (OS.has_error()) |
438 return std::make_error_code(std::errc::io_error); | 440 return std::make_error_code(std::errc::io_error); |
439 | 441 |
440 return EC; | 442 return EC; |
441 } | 443 } |
442 | 444 |
443 bool llvm::sys::argumentsFitWithinSystemLimits(ArrayRef<const char*> Args) { | 445 bool llvm::sys::argumentsFitWithinSystemLimits(ArrayRef<const char*> Args) { |
| 446 #if defined(__native_client__) |
| 447 static long ArgMax = -1; |
| 448 #else // !__native_client__ |
444 static long ArgMax = sysconf(_SC_ARG_MAX); | 449 static long ArgMax = sysconf(_SC_ARG_MAX); |
| 450 #endif // __native_client__ |
445 | 451 |
446 // System says no practical limit. | 452 // System says no practical limit. |
447 if (ArgMax == -1) | 453 if (ArgMax == -1) |
448 return true; | 454 return true; |
449 | 455 |
450 // Conservatively account for space required by environment variables. | 456 // Conservatively account for space required by environment variables. |
451 long HalfArgMax = ArgMax / 2; | 457 long HalfArgMax = ArgMax / 2; |
452 | 458 |
453 size_t ArgLength = 0; | 459 size_t ArgLength = 0; |
454 for (ArrayRef<const char*>::iterator I = Args.begin(), E = Args.end(); | 460 for (ArrayRef<const char*>::iterator I = Args.begin(), E = Args.end(); |
455 I != E; ++I) { | 461 I != E; ++I) { |
456 ArgLength += strlen(*I) + 1; | 462 ArgLength += strlen(*I) + 1; |
457 if (ArgLength > size_t(HalfArgMax)) { | 463 if (ArgLength > size_t(HalfArgMax)) { |
458 return false; | 464 return false; |
459 } | 465 } |
460 } | 466 } |
461 return true; | 467 return true; |
462 } | 468 } |
463 } | 469 } |
OLD | NEW |