This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [patch] to gcc: use xexit/xatexit in fixinc


Alexandre Oliva <aoliva@redhat.com> wrote:

> Isn't it main() that calls __main()?

Yes.

> In this case, there'd be no way
> to intercept returning from main().  Besides, we can't expect to have
> any help from the bootstrap compiler.

Exactly.

> So we really have to change
> programs in GCC so that they don't depend on exit()/atexit() on
> platforms that don't offer the latter, and we need our own
> work-around.  The unfortunate thing is that, since there aren't that
> many systems out there that don't offer atexit(), the fallback won't
> be tested as much.

Well, if 4.3BSD ever breaks, expect me to yell and scream right away. :-) Not
sure if this is enough testing for you...

> Makes me wonder whether we shouldn't just switch
> to xatexit()/xexit() on *all* systems, so that we get the same exit
> code exercised on all platforms.

I have already posted a patch earlier doing this. Being under the impression
that the powers that be prefer to #define exit to xexit and atexit to xatexit
in fixinc/fixlib.h only when !HAVE_ATEXIT, I've made a patch for this approach
as well. It appears below.

--
Michael Sokolov
Public Service Agent
International Engineering and Science Task Force

1351 VINE AVE APT 27		Phone: +1-714-738-5409
FULLERTON CA 92833-4291 USA	(home office)

E-mail: msokolov@ivan.Harhan.ORG (ARPA TCP/SMTP)

2001-01-01  Michael Sokolov  <msokolov@ivan.Harhan.ORG>

	* configure.in (AC_CHECK_FUNCS): Add atexit.
	* configure, config.in: Regenerate.
	* fixinc/fixfixes.c (main): Use exit instead of return.
	* fixinc/fixincl.c (main): Likewise.
	* fixinc/fixlib.h: #define exit to xexit and atexit to xatexit if
	!HAVE_ATEXIT.

Index: configure.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/configure.in,v
retrieving revision 1.468
diff -p -r1.468 configure.in
*** configure.in	2000/12/18 18:12:44	1.468
--- configure.in	2001/01/02 01:46:40
*************** if test $gcc_cv_enum_bf_unsigned = yes; 
*** 525,531 ****
      [Define if enumerated bitfields are treated as unsigned values.])
  fi
  
! AC_CHECK_FUNCS(strtoul bsearch putenv popen bcopy \
  	strchr strrchr kill getrlimit setrlimit atoll atoq \
  	sysconf isascii gettimeofday strsignal putc_unlocked fputc_unlocked \
  	fputs_unlocked getrusage valloc iconv nl_langinfo)
--- 525,531 ----
      [Define if enumerated bitfields are treated as unsigned values.])
  fi
  
! AC_CHECK_FUNCS(atexit strtoul bsearch putenv popen bcopy \
  	strchr strrchr kill getrlimit setrlimit atoll atoq \
  	sysconf isascii gettimeofday strsignal putc_unlocked fputc_unlocked \
  	fputs_unlocked getrusage valloc iconv nl_langinfo)
Index: fixinc/fixfixes.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixfixes.c,v
retrieving revision 1.40
diff -p -r1.40 fixfixes.c
*** fixfixes.c	2000/12/13 20:07:45	1.40
--- fixfixes.c	2001/01/02 01:46:42
*************** main( argc, argv )
*** 772,778 ****
      {
      usage_failure:
        fputs (z_usage, stderr);
!       return EXIT_FAILURE;
      }
  
    {
--- 772,778 ----
      {
      usage_failure:
        fputs (z_usage, stderr);
!       exit (EXIT_FAILURE);
      }
  
    {
*************** main( argc, argv )
*** 791,797 ****
    if (freopen (argv[3], "r", stdin) != stdin)
      {
        fprintf (stderr, z_reopen, errno, strerror( errno ), argv[3], "in");
!       return EXIT_FAILURE;
      }
  
    pz_tmptmp = (char*)xmalloc( strlen( argv[4] ) + 5 );
--- 791,797 ----
    if (freopen (argv[3], "r", stdin) != stdin)
      {
        fprintf (stderr, z_reopen, errno, strerror( errno ), argv[3], "in");
!       exit (EXIT_FAILURE);
      }
  
    pz_tmptmp = (char*)xmalloc( strlen( argv[4] ) + 5 );
*************** main( argc, argv )
*** 810,816 ****
    if (freopen (pz_tmptmp, "w", stdout) != stdout)
      {
        fprintf (stderr, z_reopen, errno, strerror( errno ), pz_tmptmp, "out");
!       return EXIT_FAILURE;
      }
  
    apply_fix (pFix, argv[1]);
--- 810,816 ----
    if (freopen (pz_tmptmp, "w", stdout) != stdout)
      {
        fprintf (stderr, z_reopen, errno, strerror( errno ), pz_tmptmp, "out");
!       exit (EXIT_FAILURE);
      }
  
    apply_fix (pFix, argv[1]);
*************** main( argc, argv )
*** 821,829 ****
      {
        fprintf (stderr, "error %d (%s) renaming %s to %s\n", errno,
                 strerror( errno ), pz_tmptmp, argv[4]);
!       return EXIT_FAILURE;
      }
  
!   return EXIT_SUCCESS;
  }
  #endif
--- 821,829 ----
      {
        fprintf (stderr, "error %d (%s) renaming %s to %s\n", errno,
                 strerror( errno ), pz_tmptmp, argv[4]);
!       exit (EXIT_FAILURE);
      }
  
!   exit (EXIT_SUCCESS);
  }
  #endif
Index: fixinc/fixincl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixincl.c,v
retrieving revision 1.48
diff -p -r1.48 fixincl.c
*** fixincl.c	2000/12/13 22:25:21	1.48
--- fixincl.c	2001/01/02 01:46:50
*************** Altering  %5d of them\n";
*** 184,190 ****
  # ifdef SEPARATE_FIX_PROC
    unlink( pz_temp_file );
  # endif
!   return EXIT_SUCCESS;
  }
  
  
--- 184,190 ----
  # ifdef SEPARATE_FIX_PROC
    unlink( pz_temp_file );
  # endif
!   exit (EXIT_SUCCESS);
  }
  
  
Index: fixinc/fixlib.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/fixinc/fixlib.h,v
retrieving revision 1.20
diff -p -r1.20 fixlib.h
*** fixlib.h	2000/12/13 20:07:46	1.20
--- fixlib.h	2001/01/02 01:46:56
*************** typedef int t_success;
*** 77,82 ****
--- 77,87 ----
  
  #define EXIT_BROKEN  3
  
+ #ifndef HAVE_ATEXIT
+ #define exit(n)   xexit(n)
+ #define atexit(p) xatexit(p)
+ #endif
+ 
  #define NUL             '\0'
  
  #ifndef NOPROCESS

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]