Changeset 1905
- Timestamp:
- Apr 24, 2005, 2:11:40 PM (20 years ago)
- Location:
- trunk/src/emx
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/emx/include/emx/startup.h
-
Property cvs2svn:cvs-rev
changed from
1.5
to1.6
r1904 r1905 50 50 #define _CRT_EXIT1(fun) __asm__ (".stabs \"___crtexit1__\", 23, 0, 0, _" #fun); 51 51 52 extern void (*_atexit_v[64])(void);53 extern int _atexit_n;54 55 52 extern char ** _org_environ; 56 53 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/include/stdlib.h
-
Property cvs2svn:cvs-rev
changed from
1.30
to1.31
r1904 r1905 299 299 void *valloc(size_t); 300 300 #endif 301 int on_exit(void (*)(int, void *), void *); 301 302 /* bird: LIBC stuff - end */ 302 303 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc.def
-
Property cvs2svn:cvs-rev
changed from
1.100
to1.101
r1904 r1905 31 31 "___stdinp" @9 32 32 "___stdoutp" @10 33 "__ atexit_n" @1134 "__ atexit_v" @1233 "___hexdig_D2A" @11 34 "__nl_current_default_domain" @12 35 35 "__emx_optarg" @13 36 36 "__emx_opterr" @14 … … 74 74 "___gettext_germanic_plural" @52 75 75 "__nl_msg_cat_cntr" @53 76 "__nl_domain_bindings" @54 76 77 77 78 … … 1429 1430 "___g_xfmt" @1438 1430 1431 "___hdtoa" @1439 1431 "__ _hexdig_D2A" @14401432 "__std_on_exit" @1440 ; april coding 1432 1433 "___hexdig_init_D2A" @1441 1433 1434 "___hexnan_D2A" @1442 … … 1489 1490 "__std_gethrtime" @1497 1490 1491 ; more intl (configure tests checks for internal variables, arg!) 1491 "__nl_current_default_domain" @1498 1492 "__nl_default_default_domain" @1499 1493 "__nl_default_dirname" @1500 1494 "__nl_domain_bindings" @1501 1495 "__nl_expand_alias" @1502 1496 "__nl_explode_name" @1503 1497 "__nl_normalize_codeset" @1504 1492 "__nl_default_default_domain" @1498 1493 "__nl_default_dirname" @1499 1494 "__nl_expand_alias" @1500 1495 "__nl_explode_name" @1501 1496 "__nl_normalize_codeset" @1502 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/libc06b4.def
-
Property cvs2svn:cvs-rev
changed from
1.1
to1.2
r1904 r1905 32 32 "___stdinp" @9 33 33 "___stdoutp" @10 34 "__atexit_n" @1135 "__atexit_v" @1234 "__atexit_n" = __osmajor @11 ; removed in libc06b5, never used outside exit() and atexit(). 35 "__atexit_v" = __osmajor @12 ; removed in libc06b5, never used outside exit() and atexit(). 36 36 "__emx_optarg" @13 37 37 "__emx_opterr" @14 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/misc/atexit.c
-
Property cvs2svn:cvs-rev
changed from
1.3
to1.4
r1904 r1905 1 /* atexit.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * LIBC atexit(). 5 * 6 * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net> 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 27 28 /******************************************************************************* 29 * Header Files * 30 *******************************************************************************/ 3 31 #include "libc-alias.h" 4 32 #include <stdlib.h> 5 #include <emx/startup.h> 33 #include <InnoTekLIBC/atexit.h> 34 #include <386/builtin.h> 35 #include <emx/umalloc.h> 6 36 7 int _STD(atexit) (void (*func)(void)) 37 38 int _STD(atexit)(void (*pfnCallback)(void)) 8 39 { 9 if (_atexit_n >= sizeof (_atexit_v) / sizeof (_atexit_v[0])) 40 __LIBC_PATEXIT pCur = __libc_atexit_new(); 41 if (pCur) 42 { 43 pCur->u.AtExit.pfnCallback = pfnCallback; 44 pCur->enmType = __LIBC_ATEXITTYPE_ATEXIT; 45 return 0; 46 } 10 47 return -1; 11 _atexit_v[_atexit_n++] = func;12 return 0;13 48 } 49 50 51 /** 52 * Allocate a new atexit entry. 53 * 54 * @returns Pointer to new entry. 55 * @returns NULL on failure. 56 */ 57 __LIBC_PATEXIT __libc_atexit_new(void) 58 { 59 /* 60 * Search existing chunks. 61 * (This is made simple by us not freeing anything.) 62 */ 63 __LIBC_PATEXITCHUNK pChunk; 64 for (pChunk = __libc_gAtExitHead; pChunk; pChunk = pChunk->pNext) 65 { 66 uint32_t i; 67 while ((i = pChunk->c) < sizeof(pChunk->a) / sizeof(pChunk->a[0])) 68 { 69 if (__atomic_cmpxchg32(&pChunk->c, i + 1, i)) 70 { 71 pChunk->a[i].enmType = __LIBC_ATEXITTYPE_TRANS; 72 return &pChunk->a[i]; 73 } 74 } 75 } 76 77 /* 78 * Add a new chunk. 79 */ 80 pChunk = _hcalloc(1, sizeof(*pChunk)); 81 if (!pChunk) 82 return NULL; 83 pChunk->c = 1; 84 pChunk->a[0].enmType = __LIBC_ATEXITTYPE_TRANS; 85 do 86 { 87 pChunk->pNext = __libc_gAtExitHead; 88 } while (__atomic_cmpxchg32((uint32_t volatile *)(void *)&__libc_gAtExitHead, (uint32_t)pChunk, (uint32_t)pChunk->pNext)); /** @todo atomic cmpxchg for ptrs! */ 89 90 return &pChunk->a[0]; 91 } 92 -
Property cvs2svn:cvs-rev
changed from
-
trunk/src/emx/src/lib/startup/exit.c
-
Property cvs2svn:cvs-rev
changed from
1.6
to1.7
r1904 r1905 1 /* exit.c (emx+gcc) -- Copyright (c) 1990-1998 by Eberhard Mattes */ 1 /* $Id: $ */ 2 /** @file 3 * 4 * LIBC exit(). 5 * 6 * Copyright (c) 2005 knut st. osmundsen <bird@anduin.net> 7 * 8 * 9 * This file is part of InnoTek LIBC. 10 * 11 * InnoTek LIBC is free software; you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License as published 13 * by the Free Software Foundation; either version 2 of the License, or 14 * (at your option) any later version. 15 * 16 * InnoTek LIBC is distributed in the hope that it will be useful, 17 * but WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 * GNU Lesser General Public License for more details. 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * along with InnoTek LIBC; if not, write to the Free Software 23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 24 * 25 */ 2 26 3 27 28 /******************************************************************************* 29 * Header Files * 30 *******************************************************************************/ 4 31 #include "libc-alias.h" 5 32 #include <stdlib.h> 6 33 #include <emx/startup.h> 34 #include <InnotekLIBC/atexit.h> 7 35 #define __LIBC_LOG_GROUP __LIBC_LOG_GRP_INITTERM 8 36 #include <InnotekLIBC/logstrict.h> 9 37 10 void (*_atexit_v[64])(void);11 int _atexit_n = 0;12 38 13 void _STD(exit) (int ret) 39 /******************************************************************************* 40 * Global Variables * 41 *******************************************************************************/ 42 /** Static exit list entry. */ 43 static __LIBC_ATEXITCHUNK gAtExitChunk; 44 /** Pointer to the head of the exit list chain - LIFO. */ 45 __LIBC_PATEXITCHUNK __libc_gAtExitHead = &gAtExitChunk; 46 47 48 void _STD(exit)(int ret) 14 49 { 15 LIBCLOG_ENTER("ret=%d\n", ret); 16 int i; 50 LIBCLOG_ENTER("ret=%d\n", ret); 17 51 18 for (i = _atexit_n-1; i >= 0; --i) 52 /* 53 * Call registered at exit callbacks. 54 * 55 * These are called in reverse registration order and we're 56 * removing them from the list as we move along to prevent endless recursions. 57 * (It is allowed to call exit() from a handler, but we must not call that handler again!) 58 */ 59 for (__LIBC_PATEXITCHUNK pChunk = __libc_gAtExitHead; pChunk; pChunk = pChunk->pNext) 19 60 { 20 LIBCLOG_MSG("calling _atexit[%d] %p\n", i, _atexit_v[i]); 21 _atexit_v[i](); 61 while (pChunk->c > 0) 62 { 63 __LIBC_PATEXIT pCur = &pChunk->a[--pChunk->c]; 64 switch (pCur->enmType) 65 { 66 case __LIBC_ATEXITTYPE_ATEXIT: 67 LIBCLOG_MSG("calling atexit: %p()\n", (void *)pCur->u.AtExit.pfnCallback); 68 pCur->u.AtExit.pfnCallback(); 69 break; 70 71 case __LIBC_ATEXITTYPE_ONEXIT: 72 LIBCLOG_MSG("calling onexit: %p(%d,%p)\n", (void *)pCur->u.OnExit.pfnCallback, ret, pCur->u.OnExit.pvUser); 73 pCur->u.OnExit.pfnCallback(ret, pCur->u.OnExit.pvUser); 74 break; 75 76 default: 77 break; 78 } 79 } 22 80 } 23 _CRT_term (); 24 LIBCLOG_MSG("calling _exit\n"); 25 _exit (ret); 81 82 /* 83 * Terminate the CRT and do the real exit. 84 */ 85 _CRT_term (); 86 LIBCLOG_MSG("calling _exit(%d)\n", ret); 87 _exit (ret); 26 88 } -
Property cvs2svn:cvs-rev
changed from
Note:
See TracChangeset
for help on using the changeset viewer.