[llvm-commits] CVS: llvm/runtime/GCCLibraries/crtend/Makefile README.txt crtend.c listend.ll

Chris Lattner lattner at cs.uiuc.edu
Wed Mar 8 22:16:41 PST 2006



Changes in directory llvm/runtime/GCCLibraries/crtend:

Makefile updated: 1.32 -> 1.33
README.txt updated: 1.1 -> 1.2
crtend.c updated: 1.5 -> 1.6
listend.ll (r1.4) removed
---
Log message:

Make the new and old front-ends more similar: now neither uses __main.


---
Diffs of the changes:  (+5 -60)

 Makefile   |    4 ++--
 README.txt |    2 +-
 crtend.c   |   59 ++---------------------------------------------------------
 3 files changed, 5 insertions(+), 60 deletions(-)


Index: llvm/runtime/GCCLibraries/crtend/Makefile
diff -u llvm/runtime/GCCLibraries/crtend/Makefile:1.32 llvm/runtime/GCCLibraries/crtend/Makefile:1.33
--- llvm/runtime/GCCLibraries/crtend/Makefile:1.32	Sun Jan 29 20:03:56 2006
+++ llvm/runtime/GCCLibraries/crtend/Makefile	Thu Mar  9 00:16:28 2006
@@ -20,7 +20,7 @@
 LIBRARYNAME = crtend
 BYTECODE_DESTINATION = $(CFERuntimeLibDir)
 
-MainSrc      := crtend.c listend.ll
+MainSrc      := crtend.c
 GenericEHSrc := Exception.cpp
 SJLJEHSrc    := SJLJ-Exception.cpp
 
@@ -29,7 +29,7 @@
 
 include $(LEVEL)/Makefile.common
 
-MainObj      := $(ObjDir)/crtend.bc $(ObjDir)/listend.bc
+MainObj      := $(ObjDir)/crtend.bc
 GenericEHObj := $(ObjDir)/Exception.bc
 SJLJEHObj    := $(ObjDir)/SJLJ-Exception.bc
 


Index: llvm/runtime/GCCLibraries/crtend/README.txt
diff -u llvm/runtime/GCCLibraries/crtend/README.txt:1.1 llvm/runtime/GCCLibraries/crtend/README.txt:1.2
--- llvm/runtime/GCCLibraries/crtend/README.txt:1.1	Sat Nov 29 03:22:53 2003
+++ llvm/runtime/GCCLibraries/crtend/README.txt	Thu Mar  9 00:16:28 2006
@@ -1,7 +1,7 @@
 This directory contains the C and C++ runtime libraries for the LLVM GCC
 front-ends.  It is composed of four distinct pieces:
 
-1. __main and static ctor/dtor support.  This is used by both C and C++ codes.
+1. __main: now dead, but provided for compatibility.
 
 2. Generic EH support routines.  This is used by C/C++ programs that use
    setjmp/longjmp, and by C++ programs that make use of exceptions.


Index: llvm/runtime/GCCLibraries/crtend/crtend.c
diff -u llvm/runtime/GCCLibraries/crtend/crtend.c:1.5 llvm/runtime/GCCLibraries/crtend/crtend.c:1.6
--- llvm/runtime/GCCLibraries/crtend/crtend.c:1.5	Wed Aug  4 19:20:51 2004
+++ llvm/runtime/GCCLibraries/crtend/crtend.c	Thu Mar  9 00:16:28 2006
@@ -7,65 +7,10 @@
  *
  *===----------------------------------------------------------------------===*
  *
- * This file defines the __main function, which is used to run static
- * constructors and destructors in C++ programs, or with C programs that use GCC
- * extensions to accomplish the same effect.
- *
- * The main data structures used to implement this functionality is the
- * llvm.global_ctors and llvm.global_dtors lists, which are null terminated
- * lists of TorRec (defined below) structures.
+ * This file defines the __main function, which we preserve for backwards 
+ * compatibility.
  *
 \*===----------------------------------------------------------------------===*/
 
-#include <stdlib.h>
-
-/* TorRec - The record type for each element of the ctor/dtor list */
-typedef struct TorRec {
-  int Priority;
-  void (*FP)(void);
-} TorRec;
-
-/* __llvm_getGlobalCtors, __llvm_getGlobalDtors - Interface to the LLVM
- * listend.ll file to get access to the start of the ctor and dtor lists...
- */
-TorRec *__llvm_getGlobalCtors(void);
-TorRec *__llvm_getGlobalDtors(void);
-
-static void run_destructors(void);
-
-/* __main - A call to this function is automatically inserted into the top of
- * the "main" function in the program compiled.  This function is responsible
- * for calling static constructors before the program starts executing.
- */
 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!
-   */
-  if (__llvm_getGlobalDtors()[0].FP)
-    if (atexit(run_destructors))
-      abort();  /* Should be able to install ONE atexit handler! */
-
-  /* FIXME: This should sort the list by priority! */
-  if (R->FP)
-    for (; R->FP; ++R)
-      R->FP();
-}
-
-static void run_destructors(void) {
-  /* Loop over all of the destructor records, calling each function pointer. */
-  TorRec *R = __llvm_getGlobalDtors();
-
-  /* FIXME: This should sort the list by priority! */
-  for (; R->FP; ++R)
-    R->FP();
 }






More information about the llvm-commits mailing list