blob: fa816f68c8a4f3c36833cb9e091ac3013c79a0de [file] [log] [blame]
Reid Spencer52a7efa2004-08-29 19:20:41 +00001//===-- Program.cpp - Implement OS Program Concept --------------*- C++ -*-===//
Misha Brukmanf976c852005-04-21 22:55:34 +00002//
Reid Spencer52a7efa2004-08-29 19:20:41 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanf976c852005-04-21 22:55:34 +00007//
Reid Spencer52a7efa2004-08-29 19:20:41 +00008//===----------------------------------------------------------------------===//
9//
10// This header file implements the operating system Program concept.
11//
12//===----------------------------------------------------------------------===//
13
Michael J. Spencer1f6efa32010-11-29 18:16:10 +000014#include "llvm/Support/Program.h"
Reid Spencer424ac892004-12-27 06:16:25 +000015#include "llvm/Config/config.h"
Chris Lattnerb221ecb2010-04-18 03:33:55 +000016using namespace llvm;
Reid Spencer52a7efa2004-08-29 19:20:41 +000017using namespace sys;
18
19//===----------------------------------------------------------------------===//
20//=== WARNING: Implementation here must contain only TRULY operating system
Misha Brukmanf976c852005-04-21 22:55:34 +000021//=== independent code.
Reid Spencer52a7efa2004-08-29 19:20:41 +000022//===----------------------------------------------------------------------===//
23
Mikhail Glushenkov31406192009-07-18 21:43:12 +000024int
25Program::ExecuteAndWait(const Path& path,
26 const char** args,
27 const char** envp,
28 const Path** redirects,
29 unsigned secondsToWait,
30 unsigned memoryLimit,
Andrew Trick7c863eb2011-05-11 16:31:24 +000031 std::string* ErrMsg,
32 const char* SignalPrefix) {
Mikhail Glushenkov31406192009-07-18 21:43:12 +000033 Program prg;
34 if (prg.Execute(path, args, envp, redirects, memoryLimit, ErrMsg))
Andrew Trick7c863eb2011-05-11 16:31:24 +000035 return prg.Wait(path, secondsToWait, ErrMsg, SignalPrefix);
Mikhail Glushenkov31406192009-07-18 21:43:12 +000036 else
37 return -1;
38}
39
40void
41Program::ExecuteNoWait(const Path& path,
42 const char** args,
43 const char** envp,
44 const Path** redirects,
45 unsigned memoryLimit,
46 std::string* ErrMsg) {
47 Program prg;
48 prg.Execute(path, args, envp, redirects, memoryLimit, ErrMsg);
49}
50
Reid Spencer52a7efa2004-08-29 19:20:41 +000051// Include the platform-specific parts of this class.
Reid Spencer424ac892004-12-27 06:16:25 +000052#ifdef LLVM_ON_UNIX
Reid Spencerbccc8ab2005-01-09 23:29:00 +000053#include "Unix/Program.inc"
Reid Spencer424ac892004-12-27 06:16:25 +000054#endif
55#ifdef LLVM_ON_WIN32
Michael J. Spencer1f6efa32010-11-29 18:16:10 +000056#include "Windows/Program.inc"
Reid Spencer424ac892004-12-27 06:16:25 +000057#endif