summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-12-19 07:51:46 +0000
committerChris Lattner <sabre@nondot.org>2003-12-19 07:51:46 +0000
commit86f3dda18b7b36071c3f8753f868fb0c3ab22ed9 (patch)
tree01d7b0895b9f793bca06a38ad27b48b7de62e958 /runtime
parente4365b2e8c79f9b2d564f31fdcc0568da8e5d60f (diff)
downloadllvm-86f3dda18b7b36071c3f8753f868fb0c3ab22ed9.tar.gz
llvm-86f3dda18b7b36071c3f8753f868fb0c3ab22ed9.tar.bz2
llvm-86f3dda18b7b36071c3f8753f868fb0c3ab22ed9.tar.xz
Add support for people calling main recursively
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10535 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'runtime')
-rw-r--r--runtime/GCCLibraries/crtend/crtend.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/runtime/GCCLibraries/crtend/crtend.c b/runtime/GCCLibraries/crtend/crtend.c
index 50bbdb7081..58f1bf5f9a 100644
--- a/runtime/GCCLibraries/crtend/crtend.c
+++ b/runtime/GCCLibraries/crtend/crtend.c
@@ -34,6 +34,13 @@ void __main(void) {
/* Loop over all of the constructor records, calling each function pointer. */
TorRec *R = __llvm_getGlobalCtors();
+ /* Recursively calling main is not legal C, but lots of people do it for
+ * testing stuff. We might as well work for them.
+ */
+ static _Bool Initialized = 0;
+ if (Initialized) return;
+ Initialized = 1;
+
/* Only register the global dtor handler if there is at least one global
* dtor!
*/