committed by
Steve Lhomme
4 changed files with 148 additions and 0 deletions
@ -0,0 +1,95 @@ |
|||
/*****************************************************************************
|
|||
* openbsd/cpu.c: CPU detection code for OpenBSD |
|||
***************************************************************************** |
|||
* Copyright (C) 2012 Rémi Denis-Courmont |
|||
* |
|||
* This program is free software; you can redistribute it and/or modify it |
|||
* under the terms of the GNU Lesser General Public License as published by |
|||
* the Free Software Foundation; either version 2.1 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Lesser General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Lesser General Public License |
|||
* along with this program; if not, write to the Free Software Foundation, |
|||
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
*****************************************************************************/ |
|||
|
|||
#ifdef HAVE_CONFIG_H |
|||
# include "config.h" |
|||
#endif |
|||
|
|||
#include <sys/auxv.h> |
|||
|
|||
#include <vlc_common.h> |
|||
#include <vlc_cpu.h> |
|||
|
|||
#if defined (__aarch64__) |
|||
unsigned vlc_CPU_raw(void) |
|||
{ |
|||
unsigned int flags = 0; |
|||
unsigned long hwcap = 0; |
|||
//unsigned long hwcap2 = 0; // TODO: SVE2
|
|||
|
|||
elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); |
|||
// elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap2)); // TODO: SVE2
|
|||
|
|||
/* HWCAP_FP (HAVE_FPU) is statically assumed. */ |
|||
if (hwcap & HWCAP_ASIMD) |
|||
flags |= VLC_CPU_ARM_NEON; |
|||
if (hwcap & HWCAP_SVE) |
|||
flags |= VLC_CPU_ARM_SVE; |
|||
|
|||
return flags; |
|||
} |
|||
|
|||
#elif defined (__arm__) |
|||
unsigned vlc_CPU_raw(void) |
|||
{ |
|||
unsigned int flags = 0; |
|||
unsigned long hwcap = 0; |
|||
|
|||
elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); |
|||
|
|||
/* TLS implies ARMv6, Thumb-EE and VFP imply ARMv7 */ |
|||
if (hwcap & (HWCAP_TLS|HWCAP_THUMBEE|HWCAP_VFP)) |
|||
flags |= VLC_CPU_ARMv6; /* SIMD */ |
|||
if (hwcap & HWCAP_NEON) |
|||
flags |= VLC_CPU_ARM_NEON; /* Advanced SIMD */ |
|||
|
|||
return flags; |
|||
} |
|||
|
|||
#elif defined (__powerpc__) /* both 32- and 64-bit */ |
|||
unsigned vlc_CPU_raw(void) |
|||
{ |
|||
unsigned int flags = 0; |
|||
unsigned long hwcap = 0; |
|||
|
|||
elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); |
|||
|
|||
if (hwcap & PPC_FEATURE_HAS_ALTIVEC) |
|||
flags |= VLC_CPU_ALTIVEC; |
|||
|
|||
return flags; |
|||
} |
|||
|
|||
#elif defined (__riscv) |
|||
# define HWCAP_RV(letter) (1LU << ((letter) - 'A')) |
|||
|
|||
unsigned vlc_CPU_raw(void) |
|||
{ |
|||
unsigned int flags = 0; |
|||
unsigned long hwcap = 0; |
|||
|
|||
elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)); |
|||
|
|||
if (hwcap & HWCAP_RV('V')) |
|||
flags |= VLC_CPU_RV_V; |
|||
|
|||
return flags; |
|||
} |
|||
#endif |
|||
@ -0,0 +1,46 @@ |
|||
/*****************************************************************************
|
|||
* openbsd/thread.c: OpenBSD specifics for threading |
|||
***************************************************************************** |
|||
* Copyright (C) 2020 Rémi Denis-Courmont |
|||
* |
|||
* This program is free software; you can redistribute it and/or modify it |
|||
* under the terms of the GNU Lesser General Public License as published by |
|||
* the Free Software Foundation; either version 2.1 of the License, or |
|||
* (at your option) any later version. |
|||
* |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU Lesser General Public License for more details. |
|||
* |
|||
* You should have received a copy of the GNU Lesser General Public License |
|||
* along with this program; if not, write to the Free Software Foundation, |
|||
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. |
|||
*****************************************************************************/ |
|||
|
|||
#ifdef HAVE_CONFIG_H |
|||
# include "config.h" |
|||
#endif |
|||
|
|||
#include <unistd.h> |
|||
#include <pthread.h> |
|||
#include <pthread_np.h> |
|||
|
|||
#include <vlc_common.h> |
|||
#include <vlc_threads.h> |
|||
#include <vlc_atomic.h> |
|||
|
|||
unsigned long vlc_thread_id(void) |
|||
{ |
|||
static _Thread_local pid_t tid = -1; |
|||
|
|||
if (unlikely(tid == -1)) |
|||
tid = getthrid(); |
|||
|
|||
return tid; |
|||
} |
|||
|
|||
void (vlc_thread_set_name)(const char *name) |
|||
{ |
|||
pthread_set_name_np(pthread_self(), name); |
|||
} |
|||
Loading…
Reference in new issue