chore: tweak compiler builtins and attibutes
continuous-integration/drone Build is failing Details

* No need to use __attribute__((noreturn))
* Use __builtin_unreachable for debug asserts in non-debug builds
This commit is contained in:
CismonX 2023-08-05 21:33:04 +08:00
parent b3e0bf9566
commit 430e4e981a
Signed by: cismonx
GPG Key ID: 3094873E29A482FB
3 changed files with 10 additions and 10 deletions

View File

@ -70,10 +70,9 @@ AM_CONDITIONAL([BUILD_ARIFY], [test x${enable_arify} != xno])
# -- Checks for compiler builtins and attributes --
ARIF_TRY_APPLY([AX_GCC_FUNC_ATTRIBUTE],
[constructor], [destructor], [noreturn])
ARIF_TRY_APPLY([AX_GCC_VAR_ATTRIBUTE],
[unused])
ARIF_TRY_APPLY([AX_GCC_BUILTIN], [__builtin_unreachable])
ARIF_TRY_APPLY([AX_GCC_FUNC_ATTRIBUTE], [constructor], [destructor])
ARIF_TRY_APPLY([AX_GCC_VAR_ATTRIBUTE], [unused])
# -- Checks for header files --
@ -85,7 +84,8 @@ AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
# -- Checks for library functions.
# -- Checks for library functions
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([atexit memchr strcasecmp])

View File

@ -20,10 +20,10 @@
* along with ARIF. If not, see <https://www.gnu.org/licenses/>.
*/
#ifdef HAVE_FUNC_ATTRIBUTE_NORETURN
# define ARIF_NORETURN __attribute__((noreturn))
#ifdef HAVE__BUILTIN_UNREACHABLE
# define ARIF_UNREACHABLE() __builtin_unreachable()
#else
# define ARIF_NORETURN
# define ARIF_UNREACHABLE()
#endif
#ifdef HAVE_VAR_ATTRIBUTE_UNUSED
@ -44,5 +44,5 @@
#ifdef ARIF_DEBUG
# define ARIF_DEBUG_ASSERT(expr) assert(expr)
#else
# define ARIF_DEBUG_ASSERT(expr)
# define ARIF_DEBUG_ASSERT(expr) if (!(expr)) { ARIF_UNREACHABLE(); }
#endif

View File

@ -54,7 +54,7 @@ struct options {
static void append_str (char const *, char **, char);
static char * concat_str (char const *, char const *, char);
static int parse_options (int, char *const [], struct options *);
static void print_usage (char const *) ARIF_NORETURN;
static void print_usage (char const *);
static void set_envs (struct options *);
// Forward declaration end