Skip to content

Commit

Permalink
[mono] Use C11 _Noreturn (or [[noreturn]]) instead of GCC attribute (#…
Browse files Browse the repository at this point in the history
…93131)

* [mono] Use C11 _Noreturn (or [[noreturn]]) instead of GCC attribute
  • Loading branch information
lambdageek authored Oct 7, 2023
1 parent b21d709 commit f21a266
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
1 change: 0 additions & 1 deletion src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -824,7 +824,6 @@ else()
set(EGLIB_BREAKPOINT "G_STMT_START { raise(SIGTRAP); } G_STMT_END")
if(GCC)
set(EGLIB_GNUC_UNUSED "__attribute__((__unused__))")
set(EGLIB_GNUC_NORETURN "__attribute__((__noreturn__))")
if(HOST_AMD64 OR HOST_X86)
set(EGLIB_BREAKPOINT "G_STMT_START { __asm__(\"int \$03\"); } G_STMT_END")
endif()
Expand Down
1 change: 0 additions & 1 deletion src/mono/cmake/eglib-config.h.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
#define G_GNUC_PRETTY_FUNCTION @EGLIB_GNUC_PRETTY@
#define G_GNUC_UNUSED @EGLIB_GNUC_UNUSED@
#define G_BYTE_ORDER @TARGET_BYTE_ORDER@
#define G_GNUC_NORETURN @EGLIB_GNUC_NORETURN@
#define G_SEARCHPATH_SEPARATOR_S "@EGLIB_SEARCHSEP@"
#define G_SEARCHPATH_SEPARATOR '@EGLIB_SEARCHSEP@'
#define G_DIR_SEPARATOR '@EGLIB_PATHSEP@'
Expand Down
20 changes: 16 additions & 4 deletions src/mono/mono/eglib/glib.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@
#define G_EXTERN_C /* nothing */
#endif

#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
#define G_ATTR_NORETURN [[noreturn]]
#elif (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
#define G_ATTR_NORETURN _Noreturn
#else
#error Mono requires _Noreturn (C11 or newer)
#endif

#ifdef __cplusplus

#define g_cast monoeg_g_cast // in case not inlined (see eglib-remap.h)
Expand Down Expand Up @@ -715,10 +723,14 @@ G_EXTERN_C // Used by MonoPosixHelper or MonoSupportW, at least.
void g_log (const gchar *log_domain, GLogLevelFlags log_level, const gchar *format, ...);
void g_log_disabled (const gchar *log_domain, GLogLevelFlags log_level, const char *file, int line);
G_EXTERN_C // Used by MonoPosixHelper or MonoSupportW, at least.
void g_assertion_message (const gchar *format, ...) G_GNUC_NORETURN;
void mono_assertion_message_disabled (const char *file, int line) G_GNUC_NORETURN;
void mono_assertion_message (const char *file, int line, const char *condition) G_GNUC_NORETURN;
void mono_assertion_message_unreachable (const char *file, int line) G_GNUC_NORETURN;
G_ATTR_NORETURN void
g_assertion_message (const gchar *format, ...);
G_ATTR_NORETURN void
mono_assertion_message_disabled (const char *file, int line);
G_ATTR_NORETURN void
mono_assertion_message (const char *file, int line, const char *condition);
G_ATTR_NORETURN void
mono_assertion_message_unreachable (const char *file, int line);
const char * g_get_assertion_message (void);

#ifndef DISABLE_ASSERT_MESSAGES
Expand Down

0 comments on commit f21a266

Please sign in to comment.