0001-Fix-compilation-errors.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. From 372f7b4b76cde4ca1ec4605353dd17898a99de38 Mon Sep 17 00:00:00 2001
  2. From: "Timothy B. Terriberry" <tterribe@xiph.org>
  3. Date: Mon, 15 Apr 2024 11:27:25 -0700
  4. Subject: [PATCH] Fix compilation errors.
  5. vec_avx.h needs x86cpu.h, and x86cpu.h needs to detect SSE2 (or
  6. greater) without the Opus macros.
  7. Also, nobody was defining OPUS_CLEAR (but several things were
  8. including the non-existent os_support.h where it is defined in
  9. libopus), so replace those calls with RNN_CLEAR and remove the
  10. erroneous includes.
  11. Take the opportunity to hoist OPUS_GNUC_PREREQ to common.h, too,
  12. since it is needed in multiple places now.
  13. Fixes GitHub #222
  14. Upstream: https://github.com/xiph/rnnoise/commit/372f7b4b76cde4ca1ec4605353dd17898a99de38
  15. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  16. ---
  17. src/common.h | 8 ++++++++
  18. src/vec.h | 9 ++++-----
  19. src/vec_avx.h | 2 +-
  20. src/vec_neon.h | 5 +++--
  21. src/x86/x86cpu.h | 4 ++--
  22. 5 files changed, 18 insertions(+), 10 deletions(-)
  23. diff --git a/src/common.h b/src/common.h
  24. index 5005bff..f9095ca 100644
  25. --- a/src/common.h
  26. +++ b/src/common.h
  27. @@ -43,6 +43,14 @@ static RNN_INLINE void rnnoise_free (void *ptr)
  28. #define RNN_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst))))
  29. #endif
  30. +# if !defined(OPUS_GNUC_PREREQ)
  31. +# if defined(__GNUC__)&&defined(__GNUC_MINOR__)
  32. +# define OPUS_GNUC_PREREQ(_maj,_min) \
  33. + ((__GNUC__<<16)+__GNUC_MINOR__>=((_maj)<<16)+(_min))
  34. +# else
  35. +# define OPUS_GNUC_PREREQ(_maj,_min) 0
  36. +# endif
  37. +# endif
  38. #endif
  39. diff --git a/src/vec.h b/src/vec.h
  40. index 8e96cbf..71b7afb 100644
  41. --- a/src/vec.h
  42. +++ b/src/vec.h
  43. @@ -30,6 +30,7 @@
  44. #define VEC_H
  45. #include "opus_types.h"
  46. +#include "common.h"
  47. #include <math.h>
  48. #include "arch.h"
  49. #include "x86/x86_arch_macros.h"
  50. @@ -41,8 +42,6 @@
  51. #include "vec_neon.h"
  52. #else
  53. -#include "os_support.h"
  54. -
  55. #define MAX_INPUTS (2048)
  56. #define NO_OPTIMIZATIONS
  57. @@ -50,7 +49,7 @@
  58. static inline void sgemv16x1(float *out, const float *weights, int rows, int cols, int col_stride, const float *x)
  59. {
  60. int i, j;
  61. - OPUS_CLEAR(out, rows);
  62. + RNN_CLEAR(out, rows);
  63. for (i=0;i<rows;i+=16)
  64. {
  65. for (j=0;j<cols;j++)
  66. @@ -84,7 +83,7 @@ static inline void sgemv16x1(float *out, const float *weights, int rows, int col
  67. static inline void sgemv8x1(float *out, const float *weights, int rows, int cols, int col_stride, const float *x)
  68. {
  69. int i, j;
  70. - OPUS_CLEAR(out, rows);
  71. + RNN_CLEAR(out, rows);
  72. for (i=0;i<rows;i+=8)
  73. {
  74. for (j=0;j<cols;j++)
  75. @@ -124,7 +123,7 @@ static inline void sgemv(float *out, const float *weights, int rows, int cols, i
  76. static inline void sparse_sgemv8x4(float *out, const float *w, const int *idx, int rows, const float *x)
  77. {
  78. int i, j;
  79. - OPUS_CLEAR(out, rows);
  80. + RNN_CLEAR(out, rows);
  81. for (i=0;i<rows;i+=8)
  82. {
  83. int cols;
  84. diff --git a/src/vec_avx.h b/src/vec_avx.h
  85. index b73a353..a5040b4 100644
  86. --- a/src/vec_avx.h
  87. +++ b/src/vec_avx.h
  88. @@ -34,7 +34,7 @@
  89. #include <immintrin.h>
  90. #include <math.h>
  91. -/*#include "celt/x86/x86cpu.h"*/
  92. +#include "x86/x86cpu.h"
  93. #define MAX_INPUTS (2048)
  94. diff --git a/src/vec_neon.h b/src/vec_neon.h
  95. index e6432e2..31b736c 100644
  96. --- a/src/vec_neon.h
  97. +++ b/src/vec_neon.h
  98. @@ -32,7 +32,8 @@
  99. #define VEC_NEON_H
  100. #include <arm_neon.h>
  101. -#include "os_support.h"
  102. +#include "opus_types.h"
  103. +#include "common.h"
  104. #if defined(__arm__) && !defined(__aarch64__) && (__ARM_ARCH < 8 || !defined(__clang__))
  105. /* Emulate vcvtnq_s32_f32() for ARMv7 Neon. */
  106. @@ -302,7 +303,7 @@ static inline void sgemv(float *out, const float *weights, int rows, int cols, i
  107. static inline void sparse_sgemv8x4(float *out, const float *w, const int *idx, int rows, const float *x)
  108. {
  109. int i, j;
  110. - OPUS_CLEAR(out, rows);
  111. + RNN_CLEAR(out, rows);
  112. for (i=0;i<rows;i+=8)
  113. {
  114. int cols;
  115. diff --git a/src/x86/x86cpu.h b/src/x86/x86cpu.h
  116. index 97dcdbd..e214aba 100644
  117. --- a/src/x86/x86cpu.h
  118. +++ b/src/x86/x86cpu.h
  119. @@ -36,8 +36,8 @@
  120. int opus_select_arch(void);
  121. # endif
  122. -# if defined(OPUS_X86_MAY_HAVE_SSE2)
  123. -# include "opus_defines.h"
  124. +# if defined(__SSE2__)
  125. +# include "common.h"
  126. /*MOVD should not impose any alignment restrictions, but the C standard does,
  127. and UBSan will report errors if we actually make unaligned accesses.
  128. --
  129. 2.39.5