From c4e2aadc88db638eed6090fa81a690235a11d3bd Mon Sep 17 00:00:00 2001 From: Oleg Oshmyan Date: Sat, 12 Feb 2022 19:44:43 +0200 Subject: Consistently use x86 asm code if we've built it We detect x86 and enable building asm code in `configure`. However, before this commit, we don't actually use that code unless we detect x86 via the C compiler's predefined macros. We could check more macros to support more C compilers, but what we really want is to use the same trigger for both building and using this code. To that end, add ARCH_X86 to config.h iff x86 asm is being built. --- configure.ac | 3 +++ libass/ass_bitmap.c | 2 +- libass/ass_render.c | 2 +- libass/ass_utils.c | 2 +- libass/ass_utils.h | 2 +- 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index 7186578..d97cb98 100644 --- a/configure.ac +++ b/configure.ac @@ -322,6 +322,9 @@ AM_CONDITIONAL([DIRECTWRITE], [test "x$directwrite" = xtrue]) ## Define C Macros not relating to libraries AM_COND_IF([ASM], [ AC_DEFINE(CONFIG_ASM, 1, [ASM enabled]) + AM_COND_IF([X86], [ + AC_DEFINE(ARCH_X86, 1, [targeting a 32- or 64-bit x86 host architecture]) + ]) ], [ AC_DEFINE(CONFIG_ASM, 0, [ASM enabled]) ]) diff --git a/libass/ass_bitmap.c b/libass/ass_bitmap.c index 5e2ca77..b11fcfa 100644 --- a/libass/ass_bitmap.c +++ b/libass/ass_bitmap.c @@ -42,7 +42,7 @@ #undef ALIGN #undef DECORATE -#if (defined(__i386__) || defined(__x86_64__)) && CONFIG_ASM +#if CONFIG_ASM && ARCH_X86 #define ALIGN 4 #define DECORATE(func) ass_##func##_sse2 diff --git a/libass/ass_render.c b/libass/ass_render.c index d5c931a..5a73c35 100644 --- a/libass/ass_render.c +++ b/libass/ass_render.c @@ -74,7 +74,7 @@ ASS_Renderer *ass_renderer_init(ASS_Library *library) priv->ftlibrary = ft; // images_root and related stuff is zero-filled in calloc -#if (defined(__i386__) || defined(__x86_64__)) && CONFIG_ASM +#if CONFIG_ASM && ARCH_X86 if (has_avx2()) priv->engine = &ass_bitmap_engine_avx2; else if (has_sse2()) diff --git a/libass/ass_utils.c b/libass/ass_utils.c index 57f6306..3248cf3 100644 --- a/libass/ass_utils.c +++ b/libass/ass_utils.c @@ -31,7 +31,7 @@ #include "ass_utils.h" #include "ass_string.h" -#if (defined(__i386__) || defined(__x86_64__)) && CONFIG_ASM +#if CONFIG_ASM && ARCH_X86 #include "x86/cpuid.h" diff --git a/libass/ass_utils.h b/libass/ass_utils.h index baee383..9d6e166 100644 --- a/libass/ass_utils.h +++ b/libass/ass_utils.h @@ -50,7 +50,7 @@ #define FEATURE_MASK(feat) (((uint32_t) 1) << (feat)) -#if (defined(__i386__) || defined(__x86_64__)) && CONFIG_ASM +#if CONFIG_ASM && ARCH_X86 int has_sse2(void); int has_avx(void); int has_avx2(void); -- cgit v1.2.3