Allow to disable inline assembly from configure

This is required for the -fsanitize options that don't
support inline assembly statements.
This commit is contained in:
Andrea Mazzoleni 2016-01-08 22:43:04 +01:00
parent 56a27b394f
commit 9430106c71
3 changed files with 46 additions and 23 deletions

View file

@ -75,8 +75,9 @@
/**
* Architecture.
* Architecture for inline assembly.
*/
#if HAVE_ASSEMBLY
#if defined(__i386__)
#define CONFIG_X86 1
#define CONFIG_X86_32 1
@ -86,6 +87,7 @@
#define CONFIG_X86 1
#define CONFIG_X86_64 1
#endif
#endif
/**
* Includes some platform specific headers.

View file

@ -118,6 +118,14 @@ AC_CHECK_CC_OPT([-Wextra], CFLAGS="$CFLAGS -Wextra", [])
AC_CHECK_CC_OPT([-Wuninitialized], CFLAGS="$CFLAGS -Wuninitialized", [])
AC_CHECK_CC_OPT([-Wshadow], CFLAGS="$CFLAGS -Wshadow", [])
dnl Checks for asm
AC_ARG_ENABLE([asm],
AS_HELP_STRING([--disable-asm], [Disable inline assembly]))
AS_IF([test "x$enable_asm" != "xno"],
[AC_DEFINE([HAVE_ASSEMBLY], [1], [Define to 1 if inline assembly should be used.])]
dnl AS_IF(HAVE_ASSEMBLY) NOT closed here
dnl Checks for AS supporting the SSE2 instructions.
AC_MSG_CHECKING([for sse2])
asmsse2=no
@ -183,6 +191,9 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
[AC_DEFINE([HAVE_AVX2], [1], [Define to 1 if avx2 is supported by the assembler.]) asmavx2=yes])
AC_MSG_RESULT([$asmavx2])
dnl AS_IF(HAVE_ASSEMBLY) closed here
)
dnl Checks for test environment
AS_CASE([$host],
[*-*-mingw*],

View file

@ -15,21 +15,6 @@
#ifndef __RAID_INTERNAL_H
#define __RAID_INTERNAL_H
/*
* Supported architecture.
*
* Detect the target architecture directly from the compiler.
*/
#if defined(__i386__)
#define CONFIG_X86 1
#define CONFIG_X86_32 1
#endif
#if defined(__x86_64__)
#define CONFIG_X86 1
#define CONFIG_X86_64 1
#endif
/*
* Supported instruction sets.
*
@ -45,19 +30,44 @@
/* Includes the project configuration for HAVE_* defines */
#include "config.h"
#if HAVE_SSE2 /* Enables SSE2 only if the assembler supports it */
/* If the compiler supports assembly */
#if HAVE_ASSEMBLY
/* Autodetect from the compiler */
#if defined(__i386__)
#define CONFIG_X86 1
#define CONFIG_X86_32 1
#endif
#if defined(__x86_64__)
#define CONFIG_X86 1
#define CONFIG_X86_64 1
#endif
#endif
/* Enables SSE2, SSSE3, AVX2 only if the assembler supports it */
#if HAVE_SSE2
#define CONFIG_SSE2 1
#endif
#if HAVE_SSSE3 /* Enables SSSE3 only if the assembler supports it */
#if HAVE_SSSE3
#define CONFIG_SSSE3 1
#endif
#if HAVE_AVX2 /* Enables AVX2 only if the assembler supports it */
#if HAVE_AVX2
#define CONFIG_AVX2 1
#endif
#else
/* If no config file, assumes the assembler supports everything in x86 */
#else /* if HAVE_CONFIG_H is not defined */
/* Assume that assembly is always supported */
#if defined(__i386__)
#define CONFIG_X86 1
#define CONFIG_X86_32 1
#endif
#if defined(__x86_64__)
#define CONFIG_X86 1
#define CONFIG_X86_64 1
#endif
/* Assumes that the assembler supports everything */
#ifdef CONFIG_X86
#define CONFIG_SSE2 1
#define CONFIG_SSSE3 1