https://github.com/python/cpython/commit/c600310663277e24607890298e6d9bf7e1d4f584
commit: c600310663277e24607890298e6d9bf7e1d4f584
branch: main
author: Bénédikt Tran <10796600+picn...@users.noreply.github.com>
committer: picnixz <10796600+picn...@users.noreply.github.com>
date: 2025-05-30T14:44:03+02:00
summary:

gh-134586: mark `_mi_assert_fail` as `noreturn`, `cold` and `throw` (#134624)

We add the following attributes on `_mi_assert_fail` to help IDE introspection:

* `__attribute__((__noreturn__))`
* `__attribute__((cold))`
* `__THROW` (GCC only)

files:
M Include/internal/mimalloc/mimalloc/types.h

diff --git a/Include/internal/mimalloc/mimalloc/types.h 
b/Include/internal/mimalloc/mimalloc/types.h
index 4f77bd7bc525db..a04169f7fb84e8 100644
--- a/Include/internal/mimalloc/mimalloc/types.h
+++ b/Include/internal/mimalloc/mimalloc/types.h
@@ -50,6 +50,32 @@ terms of the MIT license. A copy of the license can be found 
in the file
 #define mi_decl_cache_align
 #endif
 
+#if (MI_DEBUG)
+#if defined(_MSC_VER)
+#define mi_decl_noreturn        __declspec(noreturn)
+#elif (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__clang__)
+#define mi_decl_noreturn        __attribute__((__noreturn__))
+#else
+#define mi_decl_noreturn
+#endif
+
+/*
+ * 'cold' attribute seems to have been fully supported since GCC 4.x.
+ * See https://github.com/gcc-mirror/gcc/commit/52bf96d2f299e9e6.
+ */
+#if (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__)
+#define mi_decl_cold            __attribute__((cold))
+#else
+#define mi_decl_cold
+#endif
+
+#if (defined(__GNUC__) && defined(__THROW))
+#define mi_decl_throw           __THROW
+#else
+#define mi_decl_throw
+#endif
+#endif
+
 // ------------------------------------------------------
 // Variants
 // ------------------------------------------------------
@@ -582,7 +608,8 @@ struct mi_heap_s {
 
 #if (MI_DEBUG)
 // use our own assertion to print without memory allocation
-void _mi_assert_fail(const char* assertion, const char* fname, unsigned int 
line, const char* func );
+mi_decl_noreturn mi_decl_cold mi_decl_throw
+void _mi_assert_fail(const char* assertion, const char* fname, unsigned int 
line, const char* func);
 #define mi_assert(expr)     ((expr) ? (void)0 : 
_mi_assert_fail(#expr,__FILE__,__LINE__,__func__))
 #else
 #define mi_assert(x)

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: arch...@mail-archive.com

Reply via email to