blob: 1e21d64e601f43cc85da8fa054faad2ef7d7a7b5 [file] [log] [blame]
Reid Spencercbad7012004-09-11 04:59:30 +00001//===-- Process.cpp - Implement OS Process Concept --------------*- C++ -*-===//
Misha Brukmanf976c852005-04-21 22:55:34 +00002//
Reid Spencercbad7012004-09-11 04:59:30 +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 Spencercbad7012004-09-11 04:59:30 +00008//===----------------------------------------------------------------------===//
9//
10// This header file implements the operating system Process concept.
11//
12//===----------------------------------------------------------------------===//
13
Reid Spencer0098e642004-12-27 06:15:29 +000014#include "llvm/Config/config.h"
Chandler Carruth0184a842012-12-31 11:17:50 +000015#include "llvm/Support/Process.h"
16#include "llvm/Support/ErrorHandling.h"
Reid Spencercbad7012004-09-11 04:59:30 +000017
Chandler Carruth9b4aba82012-12-31 11:45:20 +000018using namespace llvm;
Reid Spencercbad7012004-09-11 04:59:30 +000019using namespace sys;
20
21//===----------------------------------------------------------------------===//
22//=== WARNING: Implementation here must contain only TRULY operating system
Misha Brukmanf976c852005-04-21 22:55:34 +000023//=== independent code.
Reid Spencercbad7012004-09-11 04:59:30 +000024//===----------------------------------------------------------------------===//
25
Chandler Carruth0184a842012-12-31 11:17:50 +000026// Empty virtual destructor to anchor the vtable for the process class.
27process::~process() {}
28
29self_process *process::get_self() {
30 // Use a function local static for thread safe initialization and allocate it
31 // as a raw pointer to ensure it is never destroyed.
32 static self_process *SP = new self_process();
33
34 return SP;
35}
36
Chandler Carruthc9bdcac2012-12-31 11:39:02 +000037#if defined(_MSC_VER)
38// Visual Studio complains that the self_process destructor never exits. This
39// doesn't make much sense, as that's the whole point of calling abort... Just
40// silence this warning.
41#pragma warning(push)
42#pragma warning(disable:4722)
43#endif
44
Chandler Carruth0184a842012-12-31 11:17:50 +000045// The destructor for the self_process subclass must never actually be
46// executed. There should be at most one instance of this class, and that
47// instance should live until the process terminates to avoid the potential for
48// racy accesses during shutdown.
49self_process::~self_process() {
50 llvm_unreachable("This destructor must never be executed!");
51}
52
Chandler Carruthc9bdcac2012-12-31 11:39:02 +000053#if defined(_MSC_VER)
54#pragma warning(pop)
55#endif
56
Reid Spencercbad7012004-09-11 04:59:30 +000057
58// Include the platform-specific parts of this class.
Reid Spencer0098e642004-12-27 06:15:29 +000059#ifdef LLVM_ON_UNIX
Reid Spencerbccc8ab2005-01-09 23:29:00 +000060#include "Unix/Process.inc"
Reid Spencer0098e642004-12-27 06:15:29 +000061#endif
62#ifdef LLVM_ON_WIN32
Michael J. Spencer1f6efa32010-11-29 18:16:10 +000063#include "Windows/Process.inc"
Reid Spencer0098e642004-12-27 06:15:29 +000064#endif