1*1295d682SXin Li
2*1295d682SXin Li
3*1295d682SXin Li #ifndef COMMON_H
4*1295d682SXin Li #define COMMON_H
5*1295d682SXin Li
6*1295d682SXin Li #include "stdlib.h"
7*1295d682SXin Li #include "string.h"
8*1295d682SXin Li
9*1295d682SXin Li #define RNN_INLINE inline
10*1295d682SXin Li #define OPUS_INLINE inline
11*1295d682SXin Li
12*1295d682SXin Li
13*1295d682SXin Li /** RNNoise wrapper for malloc(). To do your own dynamic allocation, all you need t
14*1295d682SXin Li o do is replace this function and rnnoise_free */
15*1295d682SXin Li #ifndef OVERRIDE_RNNOISE_ALLOC
rnnoise_alloc(size_t size)16*1295d682SXin Li static RNN_INLINE void *rnnoise_alloc (size_t size)
17*1295d682SXin Li {
18*1295d682SXin Li return malloc(size);
19*1295d682SXin Li }
20*1295d682SXin Li #endif
21*1295d682SXin Li
22*1295d682SXin Li /** RNNoise wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and rnnoise_alloc */
23*1295d682SXin Li #ifndef OVERRIDE_RNNOISE_FREE
rnnoise_free(void * ptr)24*1295d682SXin Li static RNN_INLINE void rnnoise_free (void *ptr)
25*1295d682SXin Li {
26*1295d682SXin Li free(ptr);
27*1295d682SXin Li }
28*1295d682SXin Li #endif
29*1295d682SXin Li
30*1295d682SXin Li /** Copy n elements from src to dst. The 0* term provides compile-time type checking */
31*1295d682SXin Li #ifndef OVERRIDE_RNN_COPY
32*1295d682SXin Li #define RNN_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
33*1295d682SXin Li #endif
34*1295d682SXin Li
35*1295d682SXin Li /** Copy n elements from src to dst, allowing overlapping regions. The 0* term
36*1295d682SXin Li provides compile-time type checking */
37*1295d682SXin Li #ifndef OVERRIDE_RNN_MOVE
38*1295d682SXin Li #define RNN_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
39*1295d682SXin Li #endif
40*1295d682SXin Li
41*1295d682SXin Li /** Set n elements of dst to zero */
42*1295d682SXin Li #ifndef OVERRIDE_RNN_CLEAR
43*1295d682SXin Li #define RNN_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst))))
44*1295d682SXin Li #endif
45*1295d682SXin Li
46*1295d682SXin Li
47*1295d682SXin Li
48*1295d682SXin Li #endif
49