Skip to content

Commit

Permalink
Introduce ATTR_RETNONNULL to indicate functions that will never retur…
Browse files Browse the repository at this point in the history
…n NULL
  • Loading branch information
BenBE committed Jul 11, 2024
1 parent ce9849c commit 0720b10
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ in the source distribution for its full text.

#endif /* HAVE_ATTR_NONNULL */

#ifdef HAVE_ATTR_RETNONNULL

#define ATTR_RETNONNULL __attribute__((returns_nonnull))

#else

#define ATTR_RETNONNULL

#endif /* HAVE_ATTR_RETNONNULL */

#ifdef HAVE_ATTR_ALLOC_SIZE

#define ATTR_ALLOC_SIZE1(a) __attribute__((alloc_size (a)))
Expand Down
15 changes: 15 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,21 @@ AC_COMPILE_IFELSE([
AC_MSG_RESULT(no))
CFLAGS="$old_CFLAGS"

AC_MSG_CHECKING(for returns_nonnull)
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wno-error -Werror=attributes"
AC_COMPILE_IFELSE([
AC_LANG_SOURCE(
[[
/* Attribute supported in GCC 4.9 or later */
__attribute__((returns_nonnull)) void* foo(void);
]]
)],
AC_DEFINE([HAVE_ATTR_RETNONNULL], 1, [The returns_nonnull attribute is supported.])
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
CFLAGS="$old_CFLAGS"

AC_MSG_CHECKING(for NaN support)
dnl Note: AC_RUN_IFELSE does not try compiling the program at all when
dnl $cross_compiling is 'yes'.
Expand Down

0 comments on commit 0720b10

Please sign in to comment.