[vlc-commits] [Git][videolan/vlc][3.0.x] 6 commits: contrib: ffmpeg: add RISC-V

Rémi Denis-Courmont (@Courmisch) gitlab at videolan.org
Sun May 29 08:18:02 UTC 2022



Rémi Denis-Courmont pushed to branch 3.0.x at VideoLAN / VLC


Commits:
e9bc5aea by Rémi Denis-Courmont at 2022-05-29T07:32:18+00:00
contrib: ffmpeg: add RISC-V

Note that a newer version of FFmpeg is necessary to get actual
platform-specific acceleration. This merely allows plain C build.

(cherry picked from commit 13bfd3b4b89d89bd323a64b2fcb798e511d8f01c)

- - - - -
57f68f4a by Rémi Denis-Courmont at 2022-05-29T07:32:18+00:00
contrib: postproc: add RISC-V

(cherry picked from commit 197442ca280865815d3b55882bd3813fbdc8753f)

- - - - -
d82e6673 by Rémi Denis-Courmont at 2022-05-29T07:32:18+00:00
contrib: check for FPU on RISC-V

(cherry picked from commit e0c0e00927ca65f1f4ed7edddf312a58d2bbac94)

- - - - -
1f523e7d by Rémi Denis-Courmont at 2022-05-29T07:32:18+00:00
linux: include <assert.h>

Needed for following backport.

- - - - -
9e07e155 by Rémi Denis-Courmont at 2022-05-29T07:32:18+00:00
linux: use futex_time64 where applicable

This adds support for 32-bit RISC-V, which only supports 64-bit time_t,
and thus lacks a plain futex system call. This also adds (future)
support for building with a 64-bit time_t ABI on a 32-bit platform.

(cherry picked from commit 949fb1d03d57d18009e20bb821f9d3e70db17ab8)

- - - - -
272dbce8 by Rémi Denis-Courmont at 2022-05-29T07:32:18+00:00
cpu: compile-time RISC-V FPU detection

(cherry picked from commit 96ae63596e4715259e607d3f88f005f0128cb5e3)

- - - - -


5 changed files:

- contrib/src/ffmpeg/rules.mak
- contrib/src/main.mak
- contrib/src/postproc/rules.mak
- include/vlc_cpu.h
- src/linux/thread.c


Changes:

=====================================
contrib/src/ffmpeg/rules.mak
=====================================
@@ -122,6 +122,11 @@ ifeq ($(ARCH),mips64el)
 FFMPEGCONF += --arch=mips64
 endif
 
+# RISC-V stuff
+ifneq ($(findstring $(ARCH),riscv32 riscv64),)
+FFMPEGCONF += --arch=riscv
+endif
+
 # x86 stuff
 ifeq ($(ARCH),i386)
 ifndef HAVE_DARWIN_OS


=====================================
contrib/src/main.mak
=====================================
@@ -187,6 +187,10 @@ ifeq ($(call cppcheck, __SOFTFP__),)
 HAVE_FPU = 1
 endif
 endif
+else ifneq ($(filter riscv%, $(ARCH)),)
+ifneq ($(call cppcheck, __riscv_flen),)
+HAVE_FPU = 1
+endif
 else ifneq ($(call cppcheck, __mips_hard_float),)
 HAVE_FPU = 1
 endif


=====================================
contrib/src/postproc/rules.mak
=====================================
@@ -50,6 +50,11 @@ ifeq ($(ARCH),mips64el)
 POSTPROCCONF += --arch=mips64
 endif
 
+# RISC-V stuff
+ifneq ($(findstring $(ARCH),riscv32 riscv64),)
+POSTPROCCONF += --arch=riscv
+endif
+
 # x86 stuff
 ifeq ($(ARCH),i386)
 POSTPROCCONF += --arch=x86


=====================================
include/vlc_cpu.h
=====================================
@@ -181,6 +181,11 @@ VLC_API unsigned vlc_CPU(void);
 # elif defined (__mips_hard_float)
 #  define HAVE_FPU 1
 
+# elif defined (__riscv)
+#  ifdef __riscv_flen
+#   define HAVE_FPU 1
+#  endif
+
 # else
 /**
  * Are single precision floating point operations "fast"?


=====================================
src/linux/thread.c
=====================================
@@ -22,6 +22,7 @@
 # include "config.h"
 #endif
 
+#include <assert.h>
 #include <errno.h>
 #include <limits.h>
 #include <stdlib.h>
@@ -50,7 +51,27 @@ unsigned long vlc_thread_id(void)
 static int sys_futex(void *addr, int op, unsigned val,
                      const struct timespec *to, void *addr2, int val3)
 {
-    return syscall(__NR_futex, addr, op, val, to, addr2, val3);
+    /* The futex Linux kernel system call exists in two variants:
+     * - the original one for use with long time_t, which suffers from the
+     *   year 2038 problem on 32-bit architectures,
+     * - the "time64" one for use with 64-bit time_t, which lacks backward
+     *   binary compatibility with 32-bit long time_t on 32-bit architectures.
+     */
+    static_assert (sizeof (time_t) == sizeof (long) || sizeof (time_t) == 8,
+                   "Unrecognised time_t type definition");
+
+#if !defined (__NR_futex)
+    /* Recent 32-bit platforms (e.g. riscv32) only support 64-bit time_t. */
+    static_assert (sizeof (time_t) == 8, "Expected 64-bit time_t");
+    const long num = __NR_futex_time64;
+#elif !defined (__NR_futex_time64)
+    static_assert (sizeof (time_t) == sizeof (long), "Expected long time_t");
+    const long num = __NR_futex;
+#else
+    const long num = sizeof (time_t) == sizeof (long)
+                     ? __NR_futex : __NR_futex_time64;
+#endif
+    return syscall(num, addr, op, val, to, addr2, val3);
 }
 
 static int vlc_futex_wake(void *addr, int nr)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/22f6fdb9d4a754aa93fd610ea3c4f41ca5e1f990...272dbce8e36cd7eb122001a7592fd44573e48e80

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/22f6fdb9d4a754aa93fd610ea3c4f41ca5e1f990...272dbce8e36cd7eb122001a7592fd44573e48e80
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