Changeset 439 for trunk/src/emx


Ignore:
Timestamp:
Jul 25, 2003, 3:37:21 PM (22 years ago)
Author:
bird
Message:

#577: Fixed problem with the use of atexit(ehTerm) for DLLs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/startup/dllinit.c

    • Property cvs2svn:cvs-rev changed from 1.5 to 1.6
    r438 r439  
    1 /* This is the startup code for gcc.dll (and can be used as well for any other
    2    DLL which uses exceptions). It should call __ehInit() as any other dynamic
    3    library which uses exceptions, otherwise the C++ programs linked to it will
    4    fail to catch exceptions.
    5 
    6  -= This is duplicated in libgcc and this copy must be removed when  =-
    7  -= we've done a new release!                                        =-
    8 
    9     */
    10 
     1/*  */
     2#include <emx/startup.h>
    113extern int _CRT_init (void);
    124extern void __ctordtorInit (void);
    135extern void __ctordtorTerm (void);
    14 extern void __ehInit (void);
    15 extern void __ehTerm (void);
     6extern void __ehInitDLL (void);
     7#pragma weak __ehInitDLL
     8extern void __ehTermDLL (void);
     9#pragma weak __ehTermDLL
    1610
    17 unsigned long _System _DLL_InitTerm (unsigned long mod_handle, unsigned long flag)
     11/**
     12 * This is the typical DLL startup code. __ehInitDLL and __ehTermDLL is called
     13 * are for exception handler stuff in gcc, the two functions will be linked if
     14 * there is exception handler info in the module. (Btw. if these calls wasn't
     15 * made we would fail to catch exceptions in C++ code.)
     16 * @returns 1 on success.
     17 * @returns 0 on failure.
     18 * @param   hmod    Handle of this DLL.
     19 * @param   flag    0 init.
     20 *                  1 term.
     21 * @remark  This function is called from dll0.asm.
     22 */
     23unsigned _System _DLL_InitTerm (unsigned hmod, unsigned flag)
    1824{
    1925  switch (flag)
     
    2127    case 0:
    2228      if (_CRT_init () != 0)
    23         return 0;
     29        break;
     30      if (__ehInitDLL)
     31        __ehInitDLL ();
    2432      __ctordtorInit ();
    25       __ehInit ();
    2633      return 1;
    2734    case 1:
    28       __ehTerm ();
    2935      __ctordtorTerm ();
     36      if (__ehTermDLL)
     37        __ehTermDLL ();
    3038      return 1;
    31     default:
    32       return 0;
    3339  }
     40  return 0;
    3441}
Note: See TracChangeset for help on using the changeset viewer.