diff --git a/ChangeLog b/ChangeLog index f72e7af43..3d9196322 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Tue Sep 8 05:04:06 1998 Tim Janik + + * glib.h: abandon the use of ATEXIT(), we keep the fallback + macros for backwards compatibility. people ought to use g_atexit(). + + * gutils.c (g_atexit): new function to take over the implementation + of ATEXIT. this function is guarranteed to succeed, similar to + g_malloc(). + Mon Sep 7 20:07:38 PDT 1998 Manish Singh * configure.in: comment the -std1 check and save LIBS properly diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index f72e7af43..3d9196322 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,12 @@ +Tue Sep 8 05:04:06 1998 Tim Janik + + * glib.h: abandon the use of ATEXIT(), we keep the fallback + macros for backwards compatibility. people ought to use g_atexit(). + + * gutils.c (g_atexit): new function to take over the implementation + of ATEXIT. this function is guarranteed to succeed, similar to + g_malloc(). + Mon Sep 7 20:07:38 PDT 1998 Manish Singh * configure.in: comment the -std1 check and save LIBS properly diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f72e7af43..3d9196322 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,12 @@ +Tue Sep 8 05:04:06 1998 Tim Janik + + * glib.h: abandon the use of ATEXIT(), we keep the fallback + macros for backwards compatibility. people ought to use g_atexit(). + + * gutils.c (g_atexit): new function to take over the implementation + of ATEXIT. this function is guarranteed to succeed, similar to + g_malloc(). + Mon Sep 7 20:07:38 PDT 1998 Manish Singh * configure.in: comment the -std1 check and save LIBS properly diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index f72e7af43..3d9196322 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,12 @@ +Tue Sep 8 05:04:06 1998 Tim Janik + + * glib.h: abandon the use of ATEXIT(), we keep the fallback + macros for backwards compatibility. people ought to use g_atexit(). + + * gutils.c (g_atexit): new function to take over the implementation + of ATEXIT. this function is guarranteed to succeed, similar to + g_malloc(). + Mon Sep 7 20:07:38 PDT 1998 Manish Singh * configure.in: comment the -std1 check and save LIBS properly diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index f72e7af43..3d9196322 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,12 @@ +Tue Sep 8 05:04:06 1998 Tim Janik + + * glib.h: abandon the use of ATEXIT(), we keep the fallback + macros for backwards compatibility. people ought to use g_atexit(). + + * gutils.c (g_atexit): new function to take over the implementation + of ATEXIT. this function is guarranteed to succeed, similar to + g_malloc(). + Mon Sep 7 20:07:38 PDT 1998 Manish Singh * configure.in: comment the -std1 check and save LIBS properly diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index f72e7af43..3d9196322 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,12 @@ +Tue Sep 8 05:04:06 1998 Tim Janik + + * glib.h: abandon the use of ATEXIT(), we keep the fallback + macros for backwards compatibility. people ought to use g_atexit(). + + * gutils.c (g_atexit): new function to take over the implementation + of ATEXIT. this function is guarranteed to succeed, similar to + g_malloc(). + Mon Sep 7 20:07:38 PDT 1998 Manish Singh * configure.in: comment the -std1 check and save LIBS properly diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index f72e7af43..3d9196322 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,12 @@ +Tue Sep 8 05:04:06 1998 Tim Janik + + * glib.h: abandon the use of ATEXIT(), we keep the fallback + macros for backwards compatibility. people ought to use g_atexit(). + + * gutils.c (g_atexit): new function to take over the implementation + of ATEXIT. this function is guarranteed to succeed, similar to + g_malloc(). + Mon Sep 7 20:07:38 PDT 1998 Manish Singh * configure.in: comment the -std1 check and save LIBS properly diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f72e7af43..3d9196322 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,12 @@ +Tue Sep 8 05:04:06 1998 Tim Janik + + * glib.h: abandon the use of ATEXIT(), we keep the fallback + macros for backwards compatibility. people ought to use g_atexit(). + + * gutils.c (g_atexit): new function to take over the implementation + of ATEXIT. this function is guarranteed to succeed, similar to + g_malloc(). + Mon Sep 7 20:07:38 PDT 1998 Manish Singh * configure.in: comment the -std1 check and save LIBS properly diff --git a/glib.h b/glib.h index 72857820c..4ce67979b 100644 --- a/glib.h +++ b/glib.h @@ -276,6 +276,27 @@ extern "C" { #endif /* !__GNUC__ */ +/* we try to provide a usefull equivalent for ATEXIT if it is + * not defined, but use is actually abandoned. people should + * use g_atexit() instead. + * keep this in sync with gutils.c. + */ +#ifndef ATEXIT +# ifdef HAVE_ATEXIT +# ifdef NeXT /* @#%@! NeXTStep */ +# define ATEXIT(proc) (!atexit (proc)) +# else /* !NeXT */ +# define ATEXIT(proc) (atexit (proc)) +# endif /* !NeXT */ +# elif defined (HAVE_ON_EXIT) +# define ATEXIT(proc) (on_exit ((void (*)(int, void *))(proc), NULL)) +# else +# error Could not determine proper atexit() implementation +# endif +#else +# define G_NATIVE_ATEXIT +#endif /* ATEXIT */ + /* Hacker macro to place breakpoints for x86 machines. * Actual use is strongly deprecated of course ;) */ @@ -286,19 +307,6 @@ extern "C" { #endif /* __i386__ */ -#ifndef ATEXIT -# ifdef HAVE_ATEXIT -# ifdef NeXT /* @#%@! NeXTStep */ -# define ATEXIT(proc) (!atexit (proc)) -# else -# define ATEXIT(proc) (atexit (proc)) -# endif /* NeXT */ -# elif defined (HAVE_ON_EXIT) -# define ATEXIT(proc) (on_exit ((void (*)(int, void *))(proc), NULL)) -# endif -#endif /* ATEXIT */ - - /* Provide macros for easily allocating memory. The macros * will cast the allocated memory to the specified type * in order to avoid compiler warnings. (Makes the code neater). @@ -663,6 +671,7 @@ typedef void (*GScannerMsgFunc) (GScanner *scanner, typedef gint (*GTraverseFunc) (gpointer key, gpointer value, gpointer data); +typedef void (*GVoidFunc) (void); struct _GList @@ -1237,6 +1246,13 @@ gchar* g_get_current_dir (void); } G_STMT_END #endif +/* we use a GLib function as a replacement for ATEXIT, so + * the programmer is not required to check the return value + * (if there is any in the implementation) and doesn't encounter + * missing include files. + */ +void g_atexit (GVoidFunc func); + /* Bit tests */ diff --git a/glib/glib.h b/glib/glib.h index 72857820c..4ce67979b 100644 --- a/glib/glib.h +++ b/glib/glib.h @@ -276,6 +276,27 @@ extern "C" { #endif /* !__GNUC__ */ +/* we try to provide a usefull equivalent for ATEXIT if it is + * not defined, but use is actually abandoned. people should + * use g_atexit() instead. + * keep this in sync with gutils.c. + */ +#ifndef ATEXIT +# ifdef HAVE_ATEXIT +# ifdef NeXT /* @#%@! NeXTStep */ +# define ATEXIT(proc) (!atexit (proc)) +# else /* !NeXT */ +# define ATEXIT(proc) (atexit (proc)) +# endif /* !NeXT */ +# elif defined (HAVE_ON_EXIT) +# define ATEXIT(proc) (on_exit ((void (*)(int, void *))(proc), NULL)) +# else +# error Could not determine proper atexit() implementation +# endif +#else +# define G_NATIVE_ATEXIT +#endif /* ATEXIT */ + /* Hacker macro to place breakpoints for x86 machines. * Actual use is strongly deprecated of course ;) */ @@ -286,19 +307,6 @@ extern "C" { #endif /* __i386__ */ -#ifndef ATEXIT -# ifdef HAVE_ATEXIT -# ifdef NeXT /* @#%@! NeXTStep */ -# define ATEXIT(proc) (!atexit (proc)) -# else -# define ATEXIT(proc) (atexit (proc)) -# endif /* NeXT */ -# elif defined (HAVE_ON_EXIT) -# define ATEXIT(proc) (on_exit ((void (*)(int, void *))(proc), NULL)) -# endif -#endif /* ATEXIT */ - - /* Provide macros for easily allocating memory. The macros * will cast the allocated memory to the specified type * in order to avoid compiler warnings. (Makes the code neater). @@ -663,6 +671,7 @@ typedef void (*GScannerMsgFunc) (GScanner *scanner, typedef gint (*GTraverseFunc) (gpointer key, gpointer value, gpointer data); +typedef void (*GVoidFunc) (void); struct _GList @@ -1237,6 +1246,13 @@ gchar* g_get_current_dir (void); } G_STMT_END #endif +/* we use a GLib function as a replacement for ATEXIT, so + * the programmer is not required to check the return value + * (if there is any in the implementation) and doesn't encounter + * missing include files. + */ +void g_atexit (GVoidFunc func); + /* Bit tests */ diff --git a/glib/gutils.c b/glib/gutils.c index 8a3b03d7c..f69256e4c 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -38,6 +38,41 @@ const guint glib_interface_age = GLIB_INTERFACE_AGE; const guint glib_binary_age = GLIB_BINARY_AGE; +void +g_atexit (GVoidFunc func) +{ + gint result; + gchar *error = NULL; + + /* keep this in sync with glib.h */ + +#ifdef G_NATIVE_ATEXIT + result = ATEXIT (func); + if (result) + error = g_strerror (errno); +#elif defined (HAVE_ATEXIT) +# ifdef NeXT /* @#%@! NeXTStep */ + result = !atexit ((void (*)(void)) func); + if (result) + error = g_strerror (errno); +# else + result = atexit ((void (*)(void)) func); + if (result) + error = g_strerror (errno); +# endif /* NeXT */ +#elif defined (HAVE_ON_EXIT) + result = on_exit ((void (*)(int, void *)) func, NULL); + if (result) + error = g_strerror (errno); +#else + result = 0; + error = "no implementation"; +#endif /* G_NATIVE_ATEXIT */ + + if (error) + g_error ("Could not register atexit() function: %s", error); +} + gint g_snprintf (gchar *str, gulong n, diff --git a/gutils.c b/gutils.c index 8a3b03d7c..f69256e4c 100644 --- a/gutils.c +++ b/gutils.c @@ -38,6 +38,41 @@ const guint glib_interface_age = GLIB_INTERFACE_AGE; const guint glib_binary_age = GLIB_BINARY_AGE; +void +g_atexit (GVoidFunc func) +{ + gint result; + gchar *error = NULL; + + /* keep this in sync with glib.h */ + +#ifdef G_NATIVE_ATEXIT + result = ATEXIT (func); + if (result) + error = g_strerror (errno); +#elif defined (HAVE_ATEXIT) +# ifdef NeXT /* @#%@! NeXTStep */ + result = !atexit ((void (*)(void)) func); + if (result) + error = g_strerror (errno); +# else + result = atexit ((void (*)(void)) func); + if (result) + error = g_strerror (errno); +# endif /* NeXT */ +#elif defined (HAVE_ON_EXIT) + result = on_exit ((void (*)(int, void *)) func, NULL); + if (result) + error = g_strerror (errno); +#else + result = 0; + error = "no implementation"; +#endif /* G_NATIVE_ATEXIT */ + + if (error) + g_error ("Could not register atexit() function: %s", error); +} + gint g_snprintf (gchar *str, gulong n,