Changeset 1677
- Timestamp:
- Dec 2, 2004, 2:44:21 AM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gcc/gcc/config/i386/emx-ctordtor.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1676 r1677 2 2 Optionally initializes frame unwind info (if emx-eh is linked in). */ 3 3 4 extern int __CTOR_LIST__;5 extern int __DTOR_LIST__;6 extern int __eh_init__;7 extern int __eh_term__;8 extern void __ctordtorInit1 (int *);9 extern void __ctordtorTerm1 (int *);10 4 5 /******************************************************************************* 6 * Header Files * 7 *******************************************************************************/ 8 #include <InnoTekLIBC/fork.h> 9 #include <emx/startup.h> 10 11 12 /******************************************************************************* 13 * Global Variables * 14 *******************************************************************************/ 11 15 /** Init indicator. 0 means not inited, 1 means inited. */ 12 16 static int inited; 13 extern void __ctordtorInit (void); 14 extern void __ctordtorTerm (void); 17 18 19 /******************************************************************************* 20 * Internal Functions * 21 *******************************************************************************/ 22 static int ctordtorForkChild(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation); 23 static void ctordtorForkComplete(void *pvArg, int rc, __LIBC_FORKCTX enmCtx); 24 15 25 16 26 /** 17 27 * Create static C++ objects. 18 28 */ 19 void __ctordtorInit 29 void __ctordtorInit(void) 20 30 { 21 if (!inited)31 if (!inited) 22 32 { 23 inited = 1;24 __ctordtorInit1(&__eh_init__);25 __ctordtorInit1(&__CTOR_LIST__);33 inited = 1; 34 __ctordtorInit1(&__eh_init__); 35 __ctordtorInit1(&__CTOR_LIST__); 26 36 } 27 37 } 38 28 39 29 40 /** 30 41 * Destroy static C++ objects. 31 42 */ 32 void __ctordtorTerm 43 void __ctordtorTerm(void) 33 44 { 34 if (inited)45 if (inited) 35 46 { 36 inited = 0;37 __ctordtorTerm1(&__DTOR_LIST__);38 __ctordtorTerm1(&__eh_term__);47 inited = 0; 48 __ctordtorTerm1(&__DTOR_LIST__); 49 __ctordtorTerm1(&__eh_term__); 39 50 } 40 51 } 52 53 54 _FORK_CHILD1(0xfffffffe, ctordtorForkChild) 55 56 /** 57 * Fork callback which will prevent the dtors from running 58 * unless the fork is successful. 59 * 60 * @returns 0 on success. 61 * @returns -errno on failure. 62 * @param pForkHandle Pointer to fork handle. 63 * @param enmOperation Fork operation. 64 */ 65 int ctordtorForkChild(__LIBC_PFORKHANDLE pForkHandle, __LIBC_FORKOP enmOperation) 66 { 67 int rc = 0; 68 switch (enmOperation) 69 { 70 /* 71 * Register a completion callback. 72 */ 73 case __LIBC_FORK_OP_FORK_CHILD: 74 rc = pForkHandle->pfnCompletionCallback(pForkHandle, ctordtorForkComplete, (void *)inited, __LIBC_FORK_CTX_CHILD); 75 case __LIBC_FORK_OP_EXEC_CHILD: 76 inited = 0; 77 break; 78 79 default: 80 break; 81 82 } 83 return 0; 84 } 85 86 87 /** 88 * Fork completion (child) callback for restoring inited to the correct value. 89 * 90 * @param pvArg The original value of inited. 91 * @param rc The fork result. This is 0 on success. On failure it is the 92 * negative errno value. 93 * @param enmCtx The context the completion callback function is called in. 94 */ 95 static void ctordtorForkComplete(void *pvArg, int rc, __LIBC_FORKCTX enmCtx) 96 { 97 /* 98 * Restore the inited flag. 99 */ 100 inited = !rc && pvArg; 101 102 /* unreferenced */ 103 enmCtx = enmCtx; 104 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.