[vlc-commits] [Git][videolan/vlc][master] openbsd: add initial support
Steve Lhomme (@robUx4)
gitlab at videolan.org
Wed Feb 26 18:42:42 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
6bf07c64 by Brad Smith at 2025-02-26T18:26:16+00:00
openbsd: add initial support
- thread id
- thread naming
- CPU feature detection
- - - - -
4 changed files:
- configure.ac
- src/Makefile.am
- + src/openbsd/cpu.c
- + src/openbsd/thread.c
Changes:
=====================================
configure.ac
=====================================
@@ -494,6 +494,7 @@ AS_IF([test "${SYS}" = "mingw32"],[
])
AM_CONDITIONAL([HAVE_FREEBSD], [test "${SYS}" = "freebsd"])
+AM_CONDITIONAL([HAVE_OPENBSD], [test "${SYS}" = "openbsd"])
AM_CONDITIONAL([HAVE_LINUX], [test "${SYS}" = "linux"])
AM_CONDITIONAL([HAVE_ANDROID], [test "${VENDOR}" = "android"])
AM_CONDITIONAL([HAVE_OS2], [test "${SYS}" = "os2"])
=====================================
src/Makefile.am
=====================================
@@ -492,6 +492,12 @@ libvlccore_la_SOURCES += \
freebsd/thread.c
endif
+if HAVE_OPENBSD
+libvlccore_la_SOURCES += \
+ openbsd/cpu.c \
+ openbsd/thread.c
+endif
+
if HAVE_LINUX
libvlccore_la_SOURCES += \
linux/cpu.c \
=====================================
src/openbsd/cpu.c
=====================================
@@ -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
=====================================
src/openbsd/thread.c
=====================================
@@ -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);
+}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6bf07c64aa262cfb8a11a29ea70794546853c36c
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6bf07c64aa262cfb8a11a29ea70794546853c36c
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list