From 70975eef572b9e132bbaade16ba9edb76f15f287 Mon Sep 17 00:00:00 2001 From: Brian Gaeke Date: Fri, 5 Sep 2003 18:42:01 +0000 Subject: Make CreateArgv part of lli rather than part of ExecutionEngine. Switch Interpreter and JIT's "run" methods to take a Function and a vector of GenericValues. Move (almost all of) the stuff that constructs a canonical call to main() into lli (new methods "callAsMain", "makeStringVector"). Nuke getCurrentExecutablePath(), enableTracing(), getCurrentFunction(), isStopped(), and many dead decls from interpreter. Add linux strdup() support to interpreter. Make interpreter's atexit handler runner and JIT's runAtExitHandlers() look more alike, in preparation for refactoring. atexit() is spelled "atexit", not "at_exit". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8366 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/ExecutionEngine/JIT/Intercept.cpp | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'lib/ExecutionEngine/JIT/Intercept.cpp') diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp index 10fd97015f..09cbe28740 100644 --- a/lib/ExecutionEngine/JIT/Intercept.cpp +++ b/lib/ExecutionEngine/JIT/Intercept.cpp @@ -12,33 +12,38 @@ #include "Config/dlfcn.h" // dlsym access #include -// AtExitList - List of functions registered with the at_exit function -static std::vector AtExitList; +// AtExitHandlers - List of functions to call when the program exits, +// registered with the atexit() library function. +static std::vector AtExitHandlers; +/// runAtExitHandlers - Run any functions registered by the program's +/// calls to atexit(3), which we intercept and store in +/// AtExitHandlers. +/// void VM::runAtExitHandlers() { - while (!AtExitList.empty()) { - void (*Fn)() = AtExitList.back(); - AtExitList.pop_back(); + while (!AtExitHandlers.empty()) { + void (*Fn)() = AtExitHandlers.back(); + AtExitHandlers.pop_back(); Fn(); } } //===----------------------------------------------------------------------===// -// Function stubs that are invoked instead of raw system calls +// Function stubs that are invoked instead of certain library calls //===----------------------------------------------------------------------===// // NoopFn - Used if we have nothing else to call... static void NoopFn() {} -// jit_exit - Used to intercept the "exit" system call. +// jit_exit - Used to intercept the "exit" library call. static void jit_exit(int Status) { - VM::runAtExitHandlers(); // Run at_exit handlers... + VM::runAtExitHandlers(); // Run atexit handlers... exit(Status); } -// jit_atexit - Used to intercept the "at_exit" system call. +// jit_atexit - Used to intercept the "atexit" library call. static int jit_atexit(void (*Fn)(void)) { - AtExitList.push_back(Fn); // Take note of at_exit handler... + AtExitHandlers.push_back(Fn); // Take note of atexit handler... return 0; // Always successful } -- cgit v1.2.3-70-g09d2