Changeset 439 for trunk/src/gcc


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.

Location:
trunk/src/gcc/gcc/config/i386
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gcc/gcc/config/i386/emx-dllinit.c

    • Property cvs2svn:cvs-rev changed from 1.2 to 1.3
    r438 r439  
    22   DLL which uses exceptions). It should call __ehInit() as any other dynamic
    33   library which uses exceptions, otherwise the C++ programs linked to it will
    4    fail to catch exceptions. */
     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    */
    510
    611extern int _CRT_init (void);
    712extern void __ctordtorInit (void);
    813extern void __ctordtorTerm (void);
    9 extern void __ehInit (void);
    10 extern void __ehTerm (void);
     14extern void __ehInitDLL (void);
     15#pragma weak __ehInitDLL
     16extern void __ehTermDLL (void);
     17#pragma weak __ehTermDLL
    1118
    1219unsigned long _System _DLL_InitTerm (unsigned long mod_handle, unsigned long flag)
     
    1623    case 0:
    1724      if (_CRT_init () != 0)
    18         return 0;
     25        break;
     26      if (__ehInitDLL)
     27        __ehInitDLL ();
    1928      __ctordtorInit ();
    20       __ehInit ();
    2129      return 1;
    2230    case 1:
    23       __ehTerm ();
    2431      __ctordtorTerm ();
     32      if (__ehTermDLL)
     33        __ehTermDLL ();
    2534      return 1;
    26     default:
    27       return 0;
    2835  }
     36  return 0;
    2937}
  • trunk/src/gcc/gcc/config/i386/emx-eh.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r438 r439  
    66extern void __register_frame_table (void *begin);
    77extern void __deregister_frame (void *begin);
     8
     9/** Exception handler stuff init indicator. 0 means not inited, 1 means inited. */
     10static int inited;
    811extern void __ehInit (void);
    912extern void __ehTerm (void);
     13extern void __ehTermDLL (void);
    1014
    11 void __ehTerm (void)
     15/**
     16 * Inits exception handler stuff.
     17 * Intended external caller is _DLL_InitTerm.
     18 */
     19void __ehInitDLL (void)
    1220{
    13   static int done;
    14 
    15   if (!done)
     21  if (!inited)
    1622    {
    1723      int *ptr = &__eh_frame__;
    18       done = 1;
     24      inited = 1;
     25      __register_frame_table (&ptr [*ptr == -2 ? 1 : 2]);
     26    }
     27}
     28
     29/**
     30 * Terminates exception handler stuff.
     31 * Intended external caller is _DLL_InitTerm.
     32 */
     33void __ehTermDLL (void)
     34{
     35  if (inited)
     36    {
     37      int *ptr = &__eh_frame__;
     38      inited = 0;
    1939      __deregister_frame (&ptr [*ptr == -2 ? 1 : 2]);
    2040    }
    2141}
    2242
     43
     44/**
     45 * atexit() procedure used pto terminate exception stuff in programs.
     46 * Registered by __ehInit.
     47 */
     48static void __ehTerm (void)
     49{
     50  __ehTermDLL();
     51}
     52
     53/**
     54 * Init exception handler stuff for a program.
     55 * Intended external caller is GCC generated main() code.
     56 */
    2357void __ehInit (void)
    2458{
    25   static int done;
    26 
    27   if (!done)
     59  if (!inited)
    2860    {
    29       int *ptr = &__eh_frame__;
    30       done = 1;
    31       __register_frame_table (&ptr [*ptr == -2 ? 1 : 2]);
    3261      atexit (__ehTerm);
     62      __ehInitDLL();
    3363    }
    3464}
     65
Note: See TracChangeset for help on using the changeset viewer.