[glib] Add g_abort()
- From: Руслан Ижбулатов <ruslanizhb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Add g_abort()
- Date: Wed, 27 Apr 2016 13:18:14 +0000 (UTC)
commit 5974428d2561b13072d627f85f012886f0df7ab8
Author: Руслан Ижбулатов <lrn1986 gmail com>
Date: Wed Mar 30 13:56:43 2016 +0000
Add g_abort()
The new g_abort() macro just expands to abort() on systems where abort()
behaves in a sane way. On other systems (read: Windows) it does its best
to emulate a sane abort() behaviour.
https://bugzilla.gnome.org/show_bug.cgi?id=665446
glib/gutils.c | 24 ++++++++++++++++++++++++
glib/gutils.h | 10 ++++++++++
2 files changed, 34 insertions(+), 0 deletions(-)
---
diff --git a/glib/gutils.c b/glib/gutils.c
index 43a2776..4d07941 100644
--- a/glib/gutils.c
+++ b/glib/gutils.c
@@ -2390,3 +2390,27 @@ g_check_setuid (void)
return FALSE;
#endif
}
+
+/**
+ * g_abort:
+ *
+ * A wrapper for the POSIX abort() function.
+ *
+ * On Windows it is a function that makes extra effort (including a call
+ * to abort()) to ensure that a debugger-catchable exception is thrown
+ * before the program terminates.
+ *
+ * See your C library manual for more details about abort().
+ *
+ * Since: 2.50
+ */
+void
+g_abort (void)
+{
+ /* One call to break the debugger */
+ DebugBreak ();
+ /* One call in case CRT does get saner about abort() behaviour */
+ abort ();
+ /* And one call to bind them all and terminate the program for sure */
+ ExitProcess (127);
+}
diff --git a/glib/gutils.h b/glib/gutils.h
index b24bc0b..f84fbcb 100644
--- a/glib/gutils.h
+++ b/glib/gutils.h
@@ -299,6 +299,16 @@ g_bit_storage_impl (gulong number)
#endif
}
+/* Crashes the program. */
+#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_50
+#ifndef G_OS_WIN32
+# define g_abort() abort ()
+#else
+GLIB_AVAILABLE_IN_2_50
+void g_abort (void) G_GNUC_NORETURN G_ANALYZER_NORETURN;
+#endif
+#endif
+
#ifndef G_DISABLE_DEPRECATED
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]