+Tue Sep 8 05:04:06 1998 Tim Janik <timj@gtk.org>
+
+ * 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 <yosh@gimp.org>
* configure.in: comment the -std1 check and save LIBS properly
+Tue Sep 8 05:04:06 1998 Tim Janik <timj@gtk.org>
+
+ * 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 <yosh@gimp.org>
* configure.in: comment the -std1 check and save LIBS properly
+Tue Sep 8 05:04:06 1998 Tim Janik <timj@gtk.org>
+
+ * 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 <yosh@gimp.org>
* configure.in: comment the -std1 check and save LIBS properly
+Tue Sep 8 05:04:06 1998 Tim Janik <timj@gtk.org>
+
+ * 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 <yosh@gimp.org>
* configure.in: comment the -std1 check and save LIBS properly
+Tue Sep 8 05:04:06 1998 Tim Janik <timj@gtk.org>
+
+ * 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 <yosh@gimp.org>
* configure.in: comment the -std1 check and save LIBS properly
+Tue Sep 8 05:04:06 1998 Tim Janik <timj@gtk.org>
+
+ * 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 <yosh@gimp.org>
* configure.in: comment the -std1 check and save LIBS properly
+Tue Sep 8 05:04:06 1998 Tim Janik <timj@gtk.org>
+
+ * 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 <yosh@gimp.org>
* configure.in: comment the -std1 check and save LIBS properly
+Tue Sep 8 05:04:06 1998 Tim Janik <timj@gtk.org>
+
+ * 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 <yosh@gimp.org>
* configure.in: comment the -std1 check and save LIBS properly
#endif /* !__GNUC__ */
-/* Hacker macro to place breakpoints for x86 machines.
- * Actual use is strongly deprecated of course ;)
+/* 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.
*/
-#if defined (__i386__) && defined (__GNUC__)
-#define G_BREAKPOINT() G_STMT_START{ __asm__ volatile ("int $03"); }G_STMT_END
-#else /* !__i386__ */
-#define G_BREAKPOINT()
-#endif /* __i386__ */
-
-
#ifndef ATEXIT
# ifdef HAVE_ATEXIT
# ifdef NeXT /* @#%@! NeXTStep */
# define ATEXIT(proc) (!atexit (proc))
-# else
+# else /* !NeXT */
# define ATEXIT(proc) (atexit (proc))
-# endif /* NeXT */
+# 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 ;)
+ */
+#if defined (__i386__) && defined (__GNUC__)
+#define G_BREAKPOINT() G_STMT_START{ __asm__ volatile ("int $03"); }G_STMT_END
+#else /* !__i386__ */
+#define G_BREAKPOINT()
+#endif /* __i386__ */
+
/* Provide macros for easily allocating memory. The macros
* will cast the allocated memory to the specified type
typedef gint (*GTraverseFunc) (gpointer key,
gpointer value,
gpointer data);
+typedef void (*GVoidFunc) (void);
struct _GList
} 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
*/
#endif /* !__GNUC__ */
-/* Hacker macro to place breakpoints for x86 machines.
- * Actual use is strongly deprecated of course ;)
+/* 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.
*/
-#if defined (__i386__) && defined (__GNUC__)
-#define G_BREAKPOINT() G_STMT_START{ __asm__ volatile ("int $03"); }G_STMT_END
-#else /* !__i386__ */
-#define G_BREAKPOINT()
-#endif /* __i386__ */
-
-
#ifndef ATEXIT
# ifdef HAVE_ATEXIT
# ifdef NeXT /* @#%@! NeXTStep */
# define ATEXIT(proc) (!atexit (proc))
-# else
+# else /* !NeXT */
# define ATEXIT(proc) (atexit (proc))
-# endif /* NeXT */
+# 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 ;)
+ */
+#if defined (__i386__) && defined (__GNUC__)
+#define G_BREAKPOINT() G_STMT_START{ __asm__ volatile ("int $03"); }G_STMT_END
+#else /* !__i386__ */
+#define G_BREAKPOINT()
+#endif /* __i386__ */
+
/* Provide macros for easily allocating memory. The macros
* will cast the allocated memory to the specified type
typedef gint (*GTraverseFunc) (gpointer key,
gpointer value,
gpointer data);
+typedef void (*GVoidFunc) (void);
struct _GList
} 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
*/
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,
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,