Reid Spencer | cbad701 | 2004-09-11 04:59:30 +0000 | [diff] [blame] | 1 | //===-- Process.cpp - Implement OS Process Concept --------------*- C++ -*-===// |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 2 | // |
Reid Spencer | cbad701 | 2004-09-11 04:59:30 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 7 | // |
Reid Spencer | cbad701 | 2004-09-11 04:59:30 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This header file implements the operating system Process concept. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Reid Spencer | 0098e64 | 2004-12-27 06:15:29 +0000 | [diff] [blame] | 14 | #include "llvm/Config/config.h" |
Chandler Carruth | 0184a84 | 2012-12-31 11:17:50 +0000 | [diff] [blame] | 15 | #include "llvm/Support/Process.h" |
| 16 | #include "llvm/Support/ErrorHandling.h" |
Reid Spencer | cbad701 | 2004-09-11 04:59:30 +0000 | [diff] [blame] | 17 | |
Chandler Carruth | 9b4aba8 | 2012-12-31 11:45:20 +0000 | [diff] [blame] | 18 | using namespace llvm; |
Reid Spencer | cbad701 | 2004-09-11 04:59:30 +0000 | [diff] [blame] | 19 | using namespace sys; |
| 20 | |
| 21 | //===----------------------------------------------------------------------===// |
| 22 | //=== WARNING: Implementation here must contain only TRULY operating system |
Misha Brukman | f976c85 | 2005-04-21 22:55:34 +0000 | [diff] [blame] | 23 | //=== independent code. |
Reid Spencer | cbad701 | 2004-09-11 04:59:30 +0000 | [diff] [blame] | 24 | //===----------------------------------------------------------------------===// |
| 25 | |
Chandler Carruth | 0184a84 | 2012-12-31 11:17:50 +0000 | [diff] [blame] | 26 | // Empty virtual destructor to anchor the vtable for the process class. |
| 27 | process::~process() {} |
| 28 | |
| 29 | self_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 Carruth | c9bdcac | 2012-12-31 11:39:02 +0000 | [diff] [blame] | 37 | #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 Carruth | 0184a84 | 2012-12-31 11:17:50 +0000 | [diff] [blame] | 45 | // 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. |
| 49 | self_process::~self_process() { |
| 50 | llvm_unreachable("This destructor must never be executed!"); |
| 51 | } |
| 52 | |
Chandler Carruth | c9bdcac | 2012-12-31 11:39:02 +0000 | [diff] [blame] | 53 | #if defined(_MSC_VER) |
| 54 | #pragma warning(pop) |
| 55 | #endif |
| 56 | |
Reid Spencer | cbad701 | 2004-09-11 04:59:30 +0000 | [diff] [blame] | 57 | |
| 58 | // Include the platform-specific parts of this class. |
Reid Spencer | 0098e64 | 2004-12-27 06:15:29 +0000 | [diff] [blame] | 59 | #ifdef LLVM_ON_UNIX |
Reid Spencer | bccc8ab | 2005-01-09 23:29:00 +0000 | [diff] [blame] | 60 | #include "Unix/Process.inc" |
Reid Spencer | 0098e64 | 2004-12-27 06:15:29 +0000 | [diff] [blame] | 61 | #endif |
| 62 | #ifdef LLVM_ON_WIN32 |
Michael J. Spencer | 1f6efa3 | 2010-11-29 18:16:10 +0000 | [diff] [blame] | 63 | #include "Windows/Process.inc" |
Reid Spencer | 0098e64 | 2004-12-27 06:15:29 +0000 | [diff] [blame] | 64 | #endif |