Interpreter.h revision 249423
1193323Sed//===-- Interpreter.h - Abstract Execution Engine Interface -----*- C++ -*-===//
2193323Sed//
3193323Sed//                     The LLVM Compiler Infrastructure
4193323Sed//
5193323Sed// This file is distributed under the University of Illinois Open Source
6193323Sed// License. See LICENSE.TXT for details.
7193323Sed//
8193323Sed//===----------------------------------------------------------------------===//
9193323Sed//
10193323Sed// This file forces the interpreter to link in on certain operating systems.
11193323Sed// (Windows).
12193323Sed//
13193323Sed//===----------------------------------------------------------------------===//
14193323Sed
15249423Sdim#ifndef LLVM_EXECUTIONENGINE_INTERPRETER_H
16249423Sdim#define LLVM_EXECUTIONENGINE_INTERPRETER_H
17193323Sed
18193323Sed#include "llvm/ExecutionEngine/ExecutionEngine.h"
19193323Sed#include <cstdlib>
20193323Sed
21195098Sedextern "C" void LLVMLinkInInterpreter();
22193323Sed
23193323Sednamespace {
24193323Sed  struct ForceInterpreterLinking {
25193323Sed    ForceInterpreterLinking() {
26239462Sdim      // We must reference the interpreter in such a way that compilers will not
27193323Sed      // delete it all as dead code, even with whole program optimization,
28193323Sed      // yet is effectively a NO-OP. As the compiler isn't smart enough
29193323Sed      // to know that getenv() never returns -1, this will do the job.
30193323Sed      if (std::getenv("bar") != (char*) -1)
31193323Sed        return;
32193323Sed
33195098Sed      LLVMLinkInInterpreter();
34193323Sed    }
35193323Sed  } ForceInterpreterLinking;
36193323Sed}
37193323Sed
38193323Sed#endif
39