This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
PATCH for providing atexit on SunOS
- To: egcs-patches at cygnus dot com
- Subject: PATCH for providing atexit on SunOS
- From: Manfred Hollstein <manfred at s-direktnet dot de>
- Date: Tue, 30 Jun 1998 12:00:34 +0200 (MET DST)
- Reply-To: manfred at s-direktnet dot de, Manfred dot Hollstein at ks dot sel dot alcatel dot de
gcc/egcs fail e.g. on SunOS to link this small example sucessfully:
struct A
{
A () {}
~A () {}
int a;
};
main ()
{
static A ab;
}
In file cp/decl.c expand_static_init () creates an atexit_fndecl node
for "atexit" which might not be available, at least on SunOS it's not.
My small patch below provides a fake atexit() for those systems which
do not HAVE_ATEXIT but have ON_EXIT.
OK to install?
manfred
1998-06-30 Manfred Hollstein <manfred@s-direktnet.de>
* libgcc2.c (L_exit): Provide a fake for atexit on systems which
define ON_EXIT but not HAVE_ATEXIT.
diff -rup -x CVS -x RCS -x *.o -x *.info* -x *.html* -x *.elc -x *.dvi -x *.orig -x *~ -x version.el egcs-19980629.orig/gcc/libgcc2.c egcs-19980629/gcc/libgcc2.c
--- egcs-19980629.orig/gcc/libgcc2.c Wed Jun 24 14:58:12 1998
+++ egcs-19980629/gcc/libgcc2.c Tue Jun 30 11:24:20 1998
@@ -3003,9 +3003,17 @@ exit (int status)
_exit (status);
}
-#else
+#else /* ON_EXIT defined */
int _exit_dummy_decl = 0; /* prevent compiler & linker warnings */
-#endif
+
+# ifndef HAVE_ATEXIT
+/* Provide a fake for atexit() using ON_EXIT. */
+int atexit (func_ptr func)
+{
+ return ON_EXIT (func, NULL);
+}
+# endif /* HAVE_ATEXIT */
+#endif /* ON_EXIT defined */
#endif /* L_exit */