mirror of
https://github.com/openharmony/third_party_dav1d.git
synced 2026-07-01 03:23:19 -04:00
Use #if HAVE_* instead of #ifdef HAVE_*
This commit is contained in:
committed by
Ronald S. Bultje
parent
b8110a4c14
commit
90f833894d
+16
-6
@@ -30,22 +30,32 @@
|
||||
#include "dav1d/dav1d.h"
|
||||
|
||||
#include <SDL.h>
|
||||
#ifdef HAVE_PLACEBO
|
||||
#if HAVE_PLACEBO
|
||||
# include <libplacebo/config.h>
|
||||
#endif
|
||||
|
||||
// Check libplacebo Vulkan rendering
|
||||
#if defined(HAVE_VULKAN) && defined(SDL_VIDEO_VULKAN)
|
||||
#if HAVE_VULKAN && defined(SDL_VIDEO_VULKAN)
|
||||
# if defined(PL_HAVE_VULKAN) && PL_HAVE_VULKAN
|
||||
# define HAVE_RENDERER_PLACEBO
|
||||
# define HAVE_PLACEBO_VULKAN
|
||||
# define HAVE_RENDERER_PLACEBO 1
|
||||
# define HAVE_PLACEBO_VULKAN 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Check libplacebo OpenGL rendering
|
||||
#if defined(PL_HAVE_OPENGL) && PL_HAVE_OPENGL
|
||||
# define HAVE_RENDERER_PLACEBO
|
||||
# define HAVE_PLACEBO_OPENGL
|
||||
# define HAVE_RENDERER_PLACEBO 1
|
||||
# define HAVE_PLACEBO_OPENGL 1
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_RENDERER_PLACEBO
|
||||
#define HAVE_RENDERER_PLACEBO 0
|
||||
#endif
|
||||
#ifndef HAVE_PLACEBO_VULKAN
|
||||
#define HAVE_PLACEBO_VULKAN 0
|
||||
#endif
|
||||
#ifndef HAVE_PLACEBO_OPENGL
|
||||
#define HAVE_PLACEBO_OPENGL 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
||||
@@ -26,17 +26,17 @@
|
||||
|
||||
#include "dp_renderer.h"
|
||||
|
||||
#ifdef HAVE_RENDERER_PLACEBO
|
||||
#if HAVE_RENDERER_PLACEBO
|
||||
#include <assert.h>
|
||||
|
||||
#include <libplacebo/renderer.h>
|
||||
#include <libplacebo/utils/dav1d.h>
|
||||
|
||||
#ifdef HAVE_PLACEBO_VULKAN
|
||||
#if HAVE_PLACEBO_VULKAN
|
||||
# include <libplacebo/vulkan.h>
|
||||
# include <SDL_vulkan.h>
|
||||
#endif
|
||||
#ifdef HAVE_PLACEBO_OPENGL
|
||||
#if HAVE_PLACEBO_OPENGL
|
||||
# include <libplacebo/opengl.h>
|
||||
# include <SDL_opengl.h>
|
||||
#endif
|
||||
@@ -53,7 +53,7 @@ typedef struct renderer_priv_ctx
|
||||
pl_log log;
|
||||
// Placebo renderer
|
||||
pl_renderer renderer;
|
||||
#ifdef HAVE_PLACEBO_VULKAN
|
||||
#if HAVE_PLACEBO_VULKAN
|
||||
// Placebo Vulkan handle
|
||||
pl_vulkan vk;
|
||||
// Placebo Vulkan instance
|
||||
@@ -61,7 +61,7 @@ typedef struct renderer_priv_ctx
|
||||
// Vulkan surface
|
||||
VkSurfaceKHR surf;
|
||||
#endif
|
||||
#ifdef HAVE_PLACEBO_OPENGL
|
||||
#if HAVE_PLACEBO_OPENGL
|
||||
// Placebo OpenGL handle
|
||||
pl_opengl gl;
|
||||
// SDL OpenGL context
|
||||
@@ -125,7 +125,7 @@ static Dav1dPlayRendererPrivateContext*
|
||||
return rd_priv_ctx;
|
||||
}
|
||||
|
||||
#ifdef HAVE_PLACEBO_OPENGL
|
||||
#if HAVE_PLACEBO_OPENGL
|
||||
static void *placebo_renderer_create_gl(const Dav1dPlaySettings *settings)
|
||||
{
|
||||
SDL_Window *sdlwin = NULL;
|
||||
@@ -181,7 +181,7 @@ static void *placebo_renderer_create_gl(const Dav1dPlaySettings *settings)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PLACEBO_VULKAN
|
||||
#if HAVE_PLACEBO_VULKAN
|
||||
static void *placebo_renderer_create_vk(const Dav1dPlaySettings *settings)
|
||||
{
|
||||
SDL_Window *sdlwin = NULL;
|
||||
@@ -278,14 +278,14 @@ static void placebo_renderer_destroy(void *cookie)
|
||||
for (int i = 0; i < 3; i++)
|
||||
pl_tex_destroy(rd_priv_ctx->gpu, &(rd_priv_ctx->plane_tex[i]));
|
||||
|
||||
#ifdef HAVE_PLACEBO_VULKAN
|
||||
#if HAVE_PLACEBO_VULKAN
|
||||
if (rd_priv_ctx->vk) {
|
||||
pl_vulkan_destroy(&(rd_priv_ctx->vk));
|
||||
vkDestroySurfaceKHR(rd_priv_ctx->vk_inst->instance, rd_priv_ctx->surf, NULL);
|
||||
pl_vk_inst_destroy(&(rd_priv_ctx->vk_inst));
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_PLACEBO_OPENGL
|
||||
#if HAVE_PLACEBO_OPENGL
|
||||
if (rd_priv_ctx->gl)
|
||||
pl_opengl_destroy(&(rd_priv_ctx->gl));
|
||||
if (rd_priv_ctx->gl_context)
|
||||
@@ -392,7 +392,7 @@ static void placebo_release_pic(Dav1dPicture *pic, void *cookie)
|
||||
SDL_UnlockMutex(rd_priv_ctx->lock);
|
||||
}
|
||||
|
||||
#ifdef HAVE_PLACEBO_VULKAN
|
||||
#if HAVE_PLACEBO_VULKAN
|
||||
const Dav1dPlayRenderInfo rdr_placebo_vk = {
|
||||
.name = "placebo-vk",
|
||||
.create_renderer = placebo_renderer_create_vk,
|
||||
@@ -407,7 +407,7 @@ const Dav1dPlayRenderInfo rdr_placebo_vk = {
|
||||
const Dav1dPlayRenderInfo rdr_placebo_vk = { NULL };
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PLACEBO_OPENGL
|
||||
#if HAVE_PLACEBO_OPENGL
|
||||
const Dav1dPlayRenderInfo rdr_placebo_gl = {
|
||||
.name = "placebo-gl",
|
||||
.create_renderer = placebo_renderer_create_gl,
|
||||
|
||||
@@ -48,19 +48,23 @@ if sdl2_dependency.found()
|
||||
|
||||
placebo_dependency = dependency('libplacebo', version: '>= 4.160.0', required: false)
|
||||
|
||||
if placebo_dependency.found()
|
||||
have_vulkan = false
|
||||
have_placebo = placebo_dependency.found()
|
||||
if have_placebo
|
||||
dav1dplay_deps += placebo_dependency
|
||||
dav1dplay_cflags += '-DHAVE_PLACEBO'
|
||||
|
||||
# If libplacebo is found, we might be able to use Vulkan
|
||||
# with it, in which case we need the Vulkan library too.
|
||||
vulkan_dependency = dependency('vulkan', required: false)
|
||||
if vulkan_dependency.found()
|
||||
dav1dplay_deps += vulkan_dependency
|
||||
dav1dplay_cflags += '-DHAVE_VULKAN'
|
||||
have_vulkan = true
|
||||
endif
|
||||
endif
|
||||
|
||||
dav1dplay_cflags += '-DHAVE_PLACEBO=' + (have_placebo ? '1' : '0')
|
||||
dav1dplay_cflags += '-DHAVE_VULKAN=' + (have_vulkan ? '1' : '0')
|
||||
|
||||
dav1dplay = executable('dav1dplay',
|
||||
dav1dplay_sources,
|
||||
rev_target,
|
||||
|
||||
+59
-64
@@ -103,6 +103,10 @@ if host_machine.system() in ['linux', 'gnu', 'emscripten']
|
||||
add_project_arguments('-D_GNU_SOURCE', language: 'c')
|
||||
endif
|
||||
|
||||
have_clock_gettime = false
|
||||
have_posix_memalign = false
|
||||
have_memalign = false
|
||||
have_aligned_alloc = false
|
||||
if host_machine.system() == 'windows'
|
||||
cdata.set('_WIN32_WINNT', '0x0601')
|
||||
cdata.set('UNICODE', 1) # Define to 1 for Unicode (Wide Chars) APIs
|
||||
@@ -150,26 +154,25 @@ else
|
||||
|
||||
rt_dependency = []
|
||||
if cc.has_function('clock_gettime', prefix : '#include <time.h>', args : test_args)
|
||||
cdata.set('HAVE_CLOCK_GETTIME', 1)
|
||||
have_clock_gettime = true
|
||||
elif host_machine.system() not in ['darwin', 'ios', 'tvos']
|
||||
rt_dependency = cc.find_library('rt', required: false)
|
||||
if not cc.has_function('clock_gettime', prefix : '#include <time.h>', args : test_args, dependencies : rt_dependency)
|
||||
error('clock_gettime not found')
|
||||
endif
|
||||
cdata.set('HAVE_CLOCK_GETTIME', 1)
|
||||
have_clock_gettime = true
|
||||
endif
|
||||
|
||||
if cc.has_function('posix_memalign', prefix : '#include <stdlib.h>', args : test_args)
|
||||
cdata.set('HAVE_POSIX_MEMALIGN', 1)
|
||||
endif
|
||||
if cc.has_function('memalign', prefix : '#include <malloc.h>', args : test_args)
|
||||
cdata.set('HAVE_MEMALIGN', 1)
|
||||
endif
|
||||
if cc.has_function('aligned_alloc', prefix : '#include <stdlib.h>', args : test_args)
|
||||
cdata.set('HAVE_ALIGNED_ALLOC', 1)
|
||||
endif
|
||||
have_posix_memalign = cc.has_function('posix_memalign', prefix : '#include <stdlib.h>', args : test_args)
|
||||
have_memalign = cc.has_function('memalign', prefix : '#include <malloc.h>', args : test_args)
|
||||
have_aligned_alloc = cc.has_function('aligned_alloc', prefix : '#include <stdlib.h>', args : test_args)
|
||||
endif
|
||||
|
||||
cdata.set10('HAVE_CLOCK_GETTIME', have_clock_gettime)
|
||||
cdata.set10('HAVE_POSIX_MEMALIGN', have_posix_memalign)
|
||||
cdata.set10('HAVE_MEMALIGN', have_memalign)
|
||||
cdata.set10('HAVE_ALIGNED_ALLOC', have_aligned_alloc)
|
||||
|
||||
# check for fseeko on android. It is not always available if _FILE_OFFSET_BITS is defined to 64
|
||||
have_fseeko = true
|
||||
if host_machine.system() == 'android'
|
||||
@@ -186,12 +189,12 @@ if host_machine.system() == 'android'
|
||||
endif
|
||||
|
||||
libdl_dependency = []
|
||||
have_dlsym = false
|
||||
if host_machine.system() == 'linux'
|
||||
libdl_dependency = cc.find_library('dl', required : false)
|
||||
if cc.has_function('dlsym', prefix : '#include <dlfcn.h>', args : test_args, dependencies : libdl_dependency)
|
||||
cdata.set('HAVE_DLSYM', 1)
|
||||
endif
|
||||
have_dlsym = cc.has_function('dlsym', prefix : '#include <dlfcn.h>', args : test_args, dependencies : libdl_dependency)
|
||||
endif
|
||||
cdata.set10('HAVE_DLSYM', have_dlsym)
|
||||
|
||||
libm_dependency = cc.find_library('m', required: false)
|
||||
|
||||
@@ -220,23 +223,13 @@ if host_machine.cpu_family().startswith('wasm')
|
||||
stdatomic_dependencies += thread_dependency.partial_dependency(compile_args: true)
|
||||
endif
|
||||
|
||||
if cc.check_header('sys/types.h')
|
||||
cdata.set('HAVE_SYS_TYPES_H', 1)
|
||||
endif
|
||||
|
||||
if cc.check_header('unistd.h')
|
||||
cdata.set('HAVE_UNISTD_H', 1)
|
||||
endif
|
||||
|
||||
if cc.check_header('io.h')
|
||||
cdata.set('HAVE_IO_H', 1)
|
||||
endif
|
||||
|
||||
if cc.check_header('pthread_np.h')
|
||||
cdata.set('HAVE_PTHREAD_NP_H', 1)
|
||||
test_args += '-DHAVE_PTHREAD_NP_H'
|
||||
endif
|
||||
cdata.set10('HAVE_SYS_TYPES_H', cc.check_header('sys/types.h'))
|
||||
cdata.set10('HAVE_UNISTD_H', cc.check_header('unistd.h'))
|
||||
cdata.set10('HAVE_IO_H', cc.check_header('io.h'))
|
||||
|
||||
have_pthread_np = cc.check_header('pthread_np.h')
|
||||
cdata.set10('HAVE_PTHREAD_NP_H', have_pthread_np)
|
||||
test_args += '-DHAVE_PTHREAD_NP_H=' + (have_pthread_np ? '1' : '0')
|
||||
|
||||
# Function checks
|
||||
|
||||
@@ -249,41 +242,32 @@ else
|
||||
getopt_dependency = []
|
||||
endif
|
||||
|
||||
have_getauxval = false
|
||||
have_elf_aux_info = false
|
||||
if (host_machine.cpu_family() == 'aarch64' or
|
||||
host_machine.cpu_family().startswith('arm') or
|
||||
host_machine.cpu_family().startswith('loongarch') or
|
||||
host_machine.cpu() == 'ppc64le' or
|
||||
host_machine.cpu_family().startswith('riscv'))
|
||||
if cc.has_function('getauxval', prefix : '#include <sys/auxv.h>', args : test_args)
|
||||
cdata.set('HAVE_GETAUXVAL', 1)
|
||||
endif
|
||||
if cc.has_function('elf_aux_info', prefix : '#include <sys/auxv.h>', args : test_args)
|
||||
cdata.set('HAVE_ELF_AUX_INFO', 1)
|
||||
endif
|
||||
have_getauxval = cc.has_function('getauxval', prefix : '#include <sys/auxv.h>', args : test_args)
|
||||
have_elf_aux_info = cc.has_function('elf_aux_info', prefix : '#include <sys/auxv.h>', args : test_args)
|
||||
endif
|
||||
|
||||
cdata.set10('HAVE_GETAUXVAL', have_getauxval)
|
||||
cdata.set10('HAVE_ELF_AUX_INFO', have_elf_aux_info)
|
||||
|
||||
pthread_np_prefix = '''
|
||||
#include <pthread.h>
|
||||
#ifdef HAVE_PTHREAD_NP_H
|
||||
#if HAVE_PTHREAD_NP_H
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
'''
|
||||
if cc.has_function('pthread_getaffinity_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency)
|
||||
cdata.set('HAVE_PTHREAD_GETAFFINITY_NP', 1)
|
||||
endif
|
||||
if cc.has_function('pthread_setaffinity_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency)
|
||||
cdata.set('HAVE_PTHREAD_SETAFFINITY_NP', 1)
|
||||
endif
|
||||
if cc.has_function('pthread_setname_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency)
|
||||
cdata.set('HAVE_PTHREAD_SETNAME_NP', 1)
|
||||
endif
|
||||
if cc.has_function('pthread_set_name_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency)
|
||||
cdata.set('HAVE_PTHREAD_SET_NAME_NP', 1)
|
||||
endif
|
||||
cdata.set10('HAVE_PTHREAD_GETAFFINITY_NP', cc.has_function('pthread_getaffinity_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency))
|
||||
cdata.set10('HAVE_PTHREAD_SETAFFINITY_NP', cc.has_function('pthread_setaffinity_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency))
|
||||
cdata.set10('HAVE_PTHREAD_SETNAME_NP', cc.has_function('pthread_setname_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency))
|
||||
cdata.set10('HAVE_PTHREAD_SET_NAME_NP', cc.has_function('pthread_set_name_np', prefix : pthread_np_prefix, args : test_args, dependencies : thread_dependency))
|
||||
|
||||
if cc.compiles('int x = _Generic(0, default: 0);', name: '_Generic', args: test_args)
|
||||
cdata.set('HAVE_C11_GENERIC', 1)
|
||||
endif
|
||||
cdata.set10('HAVE_C11_GENERIC', cc.compiles('int x = _Generic(0, default: 0);', name: '_Generic', args: test_args))
|
||||
|
||||
# Compiler flag tests
|
||||
|
||||
@@ -364,6 +348,17 @@ endif
|
||||
|
||||
cdata.set10('ARCH_AARCH64', host_machine.cpu_family() == 'aarch64' or host_machine.cpu() == 'arm64')
|
||||
cdata.set10('ARCH_ARM', host_machine.cpu_family().startswith('arm') and host_machine.cpu() != 'arm64')
|
||||
|
||||
have_as_func = false
|
||||
have_as_arch = false
|
||||
aarch64_extensions = {
|
||||
'dotprod': 'udot v0.4s, v0.16b, v0.16b',
|
||||
'i8mm': 'usdot v0.4s, v0.16b, v0.16b',
|
||||
'sve': 'whilelt p0.s, x0, x1',
|
||||
'sve2': 'sqrdmulh z0.s, z0.s, z0.s',
|
||||
}
|
||||
supported_aarch64_archexts = []
|
||||
supported_aarch64_instructions = []
|
||||
if (is_asm_enabled and
|
||||
(host_machine.cpu_family() == 'aarch64' or
|
||||
host_machine.cpu_family().startswith('arm')))
|
||||
@@ -374,7 +369,6 @@ if (is_asm_enabled and
|
||||
);
|
||||
'''
|
||||
have_as_func = cc.compiles(as_func_code)
|
||||
cdata.set10('HAVE_AS_FUNC', have_as_func)
|
||||
|
||||
# fedora package build infrastructure uses a gcc specs file to enable
|
||||
# '-fPIE' by default. The chosen way only adds '-fPIE' to the C compiler
|
||||
@@ -395,7 +389,6 @@ if (is_asm_enabled and
|
||||
|
||||
if host_machine.cpu_family() == 'aarch64'
|
||||
have_as_arch = cc.compiles('''__asm__ (".arch armv8-a");''')
|
||||
cdata.set10('HAVE_AS_ARCH_DIRECTIVE', have_as_arch)
|
||||
as_arch_str = ''
|
||||
if have_as_arch
|
||||
as_arch_level = 'armv8-a'
|
||||
@@ -424,13 +417,7 @@ if (is_asm_enabled and
|
||||
cdata.set('AS_ARCH_LEVEL', as_arch_level)
|
||||
as_arch_str = '".arch ' + as_arch_level + '\\n"'
|
||||
endif
|
||||
extensions = {
|
||||
'dotprod': 'udot v0.4s, v0.16b, v0.16b',
|
||||
'i8mm': 'usdot v0.4s, v0.16b, v0.16b',
|
||||
'sve': 'whilelt p0.s, x0, x1',
|
||||
'sve2': 'sqrdmulh z0.s, z0.s, z0.s',
|
||||
}
|
||||
foreach name, instr : extensions
|
||||
foreach name, instr : aarch64_extensions
|
||||
# Test for support for the various extensions. First test if
|
||||
# the assembler supports the .arch_extension directive for
|
||||
# enabling/disabling the extension, then separately check whether
|
||||
@@ -441,19 +428,27 @@ if (is_asm_enabled and
|
||||
code += '".arch_extension ' + name + '\\n"'
|
||||
code += ');'
|
||||
supports_archext = cc.compiles(code)
|
||||
cdata.set10('HAVE_AS_ARCHEXT_' + name.to_upper() + '_DIRECTIVE', supports_archext)
|
||||
code = '__asm__ (' + as_arch_str
|
||||
if supports_archext
|
||||
supported_aarch64_archexts += name
|
||||
code += '".arch_extension ' + name + '\\n"'
|
||||
endif
|
||||
code += '"' + instr + '\\n"'
|
||||
code += ');'
|
||||
supports_instr = cc.compiles(code, name: name.to_upper())
|
||||
cdata.set10('HAVE_' + name.to_upper(), supports_instr)
|
||||
if cc.compiles(code, name: name.to_upper())
|
||||
supported_aarch64_instructions += name
|
||||
endif
|
||||
endforeach
|
||||
endif
|
||||
endif
|
||||
|
||||
cdata.set10('HAVE_AS_FUNC', have_as_func)
|
||||
cdata.set10('HAVE_AS_ARCH_DIRECTIVE', have_as_arch)
|
||||
foreach name, _ : aarch64_extensions
|
||||
cdata.set10('HAVE_AS_ARCHEXT_' + name.to_upper() + '_DIRECTIVE', name in supported_aarch64_archexts)
|
||||
cdata.set10('HAVE_' + name.to_upper(), name in supported_aarch64_instructions)
|
||||
endforeach
|
||||
|
||||
cdata.set10('ARCH_X86', host_machine.cpu_family().startswith('x86'))
|
||||
cdata.set10('ARCH_X86_64', host_machine.cpu_family() == 'x86_64')
|
||||
cdata.set10('ARCH_X86_32', host_machine.cpu_family() == 'x86')
|
||||
|
||||
+3
-3
@@ -32,7 +32,7 @@
|
||||
#include "src/cpu.h"
|
||||
#include "src/arm/cpu.h"
|
||||
|
||||
#if defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO)
|
||||
#if HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO
|
||||
#include <sys/auxv.h>
|
||||
|
||||
#if ARCH_AARCH64
|
||||
@@ -43,7 +43,7 @@
|
||||
#define HWCAP2_AARCH64_I8MM (1 << 13)
|
||||
|
||||
COLD unsigned dav1d_get_cpu_flags_arm(void) {
|
||||
#ifdef HAVE_GETAUXVAL
|
||||
#if HAVE_GETAUXVAL
|
||||
unsigned long hw_cap = getauxval(AT_HWCAP);
|
||||
unsigned long hw_cap2 = getauxval(AT_HWCAP2);
|
||||
#else
|
||||
@@ -69,7 +69,7 @@ COLD unsigned dav1d_get_cpu_flags_arm(void) {
|
||||
#define HWCAP_ARM_I8MM (1 << 27)
|
||||
|
||||
COLD unsigned dav1d_get_cpu_flags_arm(void) {
|
||||
#ifdef HAVE_GETAUXVAL
|
||||
#if HAVE_GETAUXVAL
|
||||
unsigned long hw_cap = getauxval(AT_HWCAP);
|
||||
#else
|
||||
unsigned long hw_cap = 0;
|
||||
|
||||
@@ -38,13 +38,13 @@
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PTHREAD_GETAFFINITY_NP
|
||||
#if HAVE_PTHREAD_GETAFFINITY_NP
|
||||
#include <pthread.h>
|
||||
#ifdef HAVE_PTHREAD_NP_H
|
||||
#if HAVE_PTHREAD_NP_H
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
#if defined(__FreeBSD__)
|
||||
@@ -91,7 +91,7 @@ COLD int dav1d_num_logical_processors(Dav1dContext *const c) {
|
||||
GetNativeSystemInfo(&system_info);
|
||||
return system_info.dwNumberOfProcessors;
|
||||
#endif
|
||||
#elif defined(HAVE_PTHREAD_GETAFFINITY_NP) && defined(CPU_COUNT)
|
||||
#elif HAVE_PTHREAD_GETAFFINITY_NP && defined(CPU_COUNT)
|
||||
cpu_set_t affinity;
|
||||
if (!pthread_getaffinity_np(pthread_self(), sizeof(affinity), &affinity))
|
||||
return CPU_COUNT(&affinity);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__linux__) && defined(HAVE_DLSYM)
|
||||
#if defined(__linux__) && HAVE_DLSYM
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
@@ -90,7 +90,7 @@ static void close_internal(Dav1dContext **const c_out, int flush);
|
||||
|
||||
NO_SANITIZE("cfi-icall") // CFI is broken with dlsym()
|
||||
static COLD size_t get_stack_size_internal(const pthread_attr_t *const thread_attr) {
|
||||
#if defined(__linux__) && defined(HAVE_DLSYM) && defined(__GLIBC__)
|
||||
#if defined(__linux__) && HAVE_DLSYM && defined(__GLIBC__)
|
||||
/* glibc has an issue where the size of the TLS is subtracted from the stack
|
||||
* size instead of allocated separately. As a result the specified stack
|
||||
* size may be insufficient when used in an application with large amounts
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@
|
||||
#include "src/cpu.h"
|
||||
#include "src/loongarch/cpu.h"
|
||||
|
||||
#if defined(HAVE_GETAUXVAL)
|
||||
#if HAVE_GETAUXVAL
|
||||
#include <sys/auxv.h>
|
||||
|
||||
#define LA_HWCAP_LSX ( 1 << 4 )
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
COLD unsigned dav1d_get_cpu_flags_loongarch(void) {
|
||||
unsigned flags = dav1d_get_default_cpu_flags();
|
||||
#if defined(HAVE_GETAUXVAL)
|
||||
#if HAVE_GETAUXVAL
|
||||
unsigned long hw_cap = getauxval(AT_HWCAP);
|
||||
flags |= (hw_cap & LA_HWCAP_LSX) ? DAV1D_LOONGARCH_CPU_FLAG_LSX : 0;
|
||||
flags |= (hw_cap & LA_HWCAP_LASX) ? DAV1D_LOONGARCH_CPU_FLAG_LASX : 0;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(_WIN32) || defined(HAVE_MEMALIGN)
|
||||
#if defined(_WIN32) || HAVE_MEMALIGN
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
@@ -90,13 +90,13 @@ static inline void *dav1d_alloc_aligned_internal(const size_t sz, const size_t a
|
||||
assert(!(align & (align - 1)));
|
||||
#ifdef _WIN32
|
||||
return _aligned_malloc(sz, align);
|
||||
#elif defined(HAVE_POSIX_MEMALIGN)
|
||||
#elif HAVE_POSIX_MEMALIGN
|
||||
void *ptr;
|
||||
if (posix_memalign(&ptr, align, sz)) return NULL;
|
||||
return ptr;
|
||||
#elif defined(HAVE_MEMALIGN)
|
||||
#elif HAVE_MEMALIGN
|
||||
return memalign(align, sz);
|
||||
#elif defined(HAVE_ALIGNED_ALLOC)
|
||||
#elif HAVE_ALIGNED_ALLOC
|
||||
// The C11 standard specifies that the size parameter
|
||||
// must be an integral multiple of alignment.
|
||||
return aligned_alloc(align, ROUND_UP(sz, align));
|
||||
|
||||
+5
-5
@@ -32,23 +32,23 @@
|
||||
#include "src/cpu.h"
|
||||
#include "src/ppc/cpu.h"
|
||||
|
||||
#if (defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO)) && ARCH_PPC64LE
|
||||
#define HAVE_AUX ((HAVE_GETAUXVAL || HAVE_ELF_AUX_INFO) && ARCH_PPC64LE)
|
||||
#if HAVE_AUX
|
||||
#include <sys/auxv.h>
|
||||
#define HAVE_AUX
|
||||
#endif
|
||||
|
||||
COLD unsigned dav1d_get_cpu_flags_ppc(void) {
|
||||
unsigned flags = dav1d_get_default_cpu_flags();
|
||||
#if defined(HAVE_GETAUXVAL) && ARCH_PPC64LE
|
||||
#if HAVE_GETAUXVAL && ARCH_PPC64LE
|
||||
unsigned long hw_cap = getauxval(AT_HWCAP);
|
||||
unsigned long hw_cap2 = getauxval(AT_HWCAP2);
|
||||
#elif defined(HAVE_ELF_AUX_INFO) && ARCH_PPC64LE
|
||||
#elif HAVE_ELF_AUX_INFO && ARCH_PPC64LE
|
||||
unsigned long hw_cap = 0;
|
||||
unsigned long hw_cap2 = 0;
|
||||
elf_aux_info(AT_HWCAP, &hw_cap, sizeof(hw_cap));
|
||||
elf_aux_info(AT_HWCAP2, &hw_cap2, sizeof(hw_cap2));
|
||||
#endif
|
||||
#ifdef HAVE_AUX
|
||||
#if HAVE_AUX
|
||||
flags |= (hw_cap & PPC_FEATURE_HAS_VSX) ? DAV1D_PPC_CPU_FLAG_VSX : 0;
|
||||
flags |= (hw_cap2 & PPC_FEATURE2_ARCH_3_00) ? DAV1D_PPC_CPU_FLAG_PWR9 : 0;
|
||||
#endif
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@
|
||||
#include "src/cpu.h"
|
||||
#include "src/riscv/cpu.h"
|
||||
|
||||
#if defined(HAVE_GETAUXVAL)
|
||||
#if HAVE_GETAUXVAL
|
||||
#include <sys/auxv.h>
|
||||
|
||||
#define HWCAP_RVV (1 << ('v' - 'a'))
|
||||
@@ -43,7 +43,7 @@ int dav1d_has_compliant_rvv(void);
|
||||
|
||||
COLD unsigned dav1d_get_cpu_flags_riscv(void) {
|
||||
unsigned flags = dav1d_get_default_cpu_flags();
|
||||
#if defined(HAVE_GETAUXVAL)
|
||||
#if HAVE_GETAUXVAL
|
||||
unsigned long hw_cap = getauxval(AT_HWCAP);
|
||||
flags |= (hw_cap & HWCAP_RVV) && dav1d_has_compliant_rvv() ? DAV1D_RISCV_CPU_FLAG_V : 0;
|
||||
#endif
|
||||
|
||||
+5
-5
@@ -137,7 +137,7 @@ static inline int pthread_cond_broadcast(pthread_cond_t *const cond) {
|
||||
#define _SYS_PARAM_H_
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_PTHREAD_NP_H
|
||||
#if HAVE_PTHREAD_NP_H
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
|
||||
@@ -153,25 +153,25 @@ static inline void dav1d_set_thread_name(const char *const name) {
|
||||
prctl(PR_SET_NAME, name);
|
||||
}
|
||||
|
||||
#elif defined(HAVE_PTHREAD_SETNAME_NP) && defined(__APPLE__)
|
||||
#elif HAVE_PTHREAD_SETNAME_NP && defined(__APPLE__)
|
||||
|
||||
static inline void dav1d_set_thread_name(const char *const name) {
|
||||
pthread_setname_np(name);
|
||||
}
|
||||
|
||||
#elif defined(HAVE_PTHREAD_SETNAME_NP) && defined(__NetBSD__)
|
||||
#elif HAVE_PTHREAD_SETNAME_NP && defined(__NetBSD__)
|
||||
|
||||
static inline void dav1d_set_thread_name(const char *const name) {
|
||||
pthread_setname_np(pthread_self(), "%s", (void*)name);
|
||||
}
|
||||
|
||||
#elif defined(HAVE_PTHREAD_SETNAME_NP)
|
||||
#elif HAVE_PTHREAD_SETNAME_NP
|
||||
|
||||
static inline void dav1d_set_thread_name(const char *const name) {
|
||||
pthread_setname_np(pthread_self(), name);
|
||||
}
|
||||
|
||||
#elif defined(HAVE_PTHREAD_SET_NAME_NP)
|
||||
#elif HAVE_PTHREAD_SET_NAME_NP
|
||||
|
||||
static inline void dav1d_set_thread_name(const char *const name) {
|
||||
pthread_set_name_np(pthread_self(), name);
|
||||
|
||||
@@ -45,12 +45,12 @@
|
||||
#endif
|
||||
#else
|
||||
#include <time.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_PTHREAD_SETAFFINITY_NP
|
||||
#if HAVE_PTHREAD_SETAFFINITY_NP
|
||||
#include <pthread.h>
|
||||
#ifdef HAVE_PTHREAD_NP_H
|
||||
#if HAVE_PTHREAD_NP_H
|
||||
#include <pthread_np.h>
|
||||
#endif
|
||||
#endif
|
||||
@@ -736,7 +736,7 @@ int main(int argc, char *argv[]) {
|
||||
} else {
|
||||
fprintf(stderr, "checkasm: running on cpu %lu\n", affinity);
|
||||
}
|
||||
#elif defined(HAVE_PTHREAD_SETAFFINITY_NP) && defined(CPU_SET)
|
||||
#elif HAVE_PTHREAD_SETAFFINITY_NP && defined(CPU_SET)
|
||||
cpu_set_t set;
|
||||
CPU_ZERO(&set);
|
||||
CPU_SET(affinity, &set);
|
||||
|
||||
@@ -254,7 +254,7 @@ void checkasm_simd_warmup(void);
|
||||
* handled orthogonally from integer parameters passed in GPR registers. */
|
||||
#define IGNORED_FP_ARGS 8
|
||||
#endif
|
||||
#ifdef HAVE_C11_GENERIC
|
||||
#if HAVE_C11_GENERIC
|
||||
#define clobber_type(arg) _Generic((void (*)(void*, arg))NULL,\
|
||||
void (*)(void*, int32_t ): clobber_mask |= 1 << mpos++,\
|
||||
void (*)(void*, uint32_t): clobber_mask |= 1 << mpos++,\
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ static unsigned get_seed(void) {
|
||||
static unsigned get_seed(void) {
|
||||
#ifdef __APPLE__
|
||||
return (unsigned) mach_absolute_time();
|
||||
#elif defined(HAVE_CLOCK_GETTIME)
|
||||
#elif HAVE_CLOCK_GETTIME
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return (unsigned) (1000000000ULL * ts.tv_sec + ts.tv_nsec);
|
||||
|
||||
+3
-3
@@ -38,10 +38,10 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_IO_H
|
||||
#if HAVE_IO_H
|
||||
# include <io.h>
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
@@ -68,7 +68,7 @@ static uint64_t get_time_nanos(void) {
|
||||
uint64_t seconds = t.QuadPart / frequency.QuadPart;
|
||||
uint64_t fractions = t.QuadPart % frequency.QuadPart;
|
||||
return 1000000000 * seconds + 1000000000 * fractions / frequency.QuadPart;
|
||||
#elif defined(HAVE_CLOCK_GETTIME)
|
||||
#elif HAVE_CLOCK_GETTIME
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return 1000000000ULL * ts.tv_sec + ts.tv_nsec;
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#if HAVE_UNISTD_H
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#if HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user