11#ifndef INCLUDED_LIBVOLK_COMMON_H
12#define INCLUDED_LIBVOLK_COMMON_H
18#define __VOLK_ATTR_ALIGNED(x) __declspec(align(x))
19#define __VOLK_ATTR_UNUSED
20#define __VOLK_ATTR_INLINE __forceinline
21#define __VOLK_ATTR_DEPRECATED __declspec(deprecated)
22#define __VOLK_ATTR_EXPORT __declspec(dllexport)
23#define __VOLK_ATTR_IMPORT __declspec(dllimport)
24#define __VOLK_PREFETCH(addr)
25#define __VOLK_ASM __asm
26#define __VOLK_VOLATILE
27#elif defined(__clang__)
31#define __VOLK_ATTR_ALIGNED(x) __attribute__((aligned(x)))
32#define __VOLK_ATTR_UNUSED __attribute__((unused))
33#define __VOLK_ATTR_INLINE __attribute__((always_inline))
34#define __VOLK_ATTR_DEPRECATED __attribute__((deprecated))
35#define __VOLK_ASM __asm__
36#define __VOLK_VOLATILE __volatile__
37#define __VOLK_ATTR_EXPORT __attribute__((visibility("default")))
38#define __VOLK_ATTR_IMPORT __attribute__((visibility("default")))
39#define __VOLK_PREFETCH(addr) __builtin_prefetch(addr)
41#define __VOLK_ATTR_ALIGNED(x) __attribute__((aligned(x)))
42#define __VOLK_ATTR_UNUSED __attribute__((unused))
43#define __VOLK_ATTR_INLINE __attribute__((always_inline))
44#define __VOLK_ATTR_DEPRECATED __attribute__((deprecated))
45#define __VOLK_ASM __asm__
46#define __VOLK_VOLATILE __volatile__
48#define __VOLK_ATTR_EXPORT __attribute__((visibility("default")))
49#define __VOLK_ATTR_IMPORT __attribute__((visibility("default")))
51#define __VOLK_ATTR_EXPORT
52#define __VOLK_ATTR_IMPORT
54#define __VOLK_PREFETCH(addr) __builtin_prefetch(addr)
56#define __VOLK_ATTR_ALIGNED(x) __declspec(align(x))
57#define __VOLK_ATTR_UNUSED
58#define __VOLK_ATTR_INLINE __forceinline
59#define __VOLK_ATTR_DEPRECATED __declspec(deprecated)
60#define __VOLK_ATTR_EXPORT __declspec(dllexport)
61#define __VOLK_ATTR_IMPORT __declspec(dllimport)
62#define __VOLK_PREFETCH(addr)
63#define __VOLK_ASM __asm
64#define __VOLK_VOLATILE
66#define __VOLK_ATTR_ALIGNED(x)
67#define __VOLK_ATTR_UNUSED
68#define __VOLK_ATTR_INLINE
69#define __VOLK_ATTR_DEPRECATED
70#define __VOLK_ATTR_EXPORT
71#define __VOLK_ATTR_IMPORT
72#define __VOLK_PREFETCH(addr)
73#define __VOLK_ASM __asm__
74#define __VOLK_VOLATILE __volatile__
81#pragma warning(disable : 4244)
83#pragma warning(disable : 4305)
90#if defined(__cplusplus) && (__GNUC__)
91#define __VOLK_DECL_BEGIN extern "C" {
92#define __VOLK_DECL_END }
94#define __VOLK_DECL_BEGIN
95#define __VOLK_DECL_END
103#define VOLK_API __VOLK_ATTR_EXPORT
105#define VOLK_API __VOLK_ATTR_IMPORT
117#include <x86intrin.h>
152#define bit128_p(x) ((union bit128*)(x))
153#define bit256_p(x) ((union bit256*)(x))
162 float const result = log2f(f);
163 return isinf(result) ? copysignf(127.0f, result) : result;
170#define volk_log2to10factor (0x1.815182p1)
181 const float a1 = +0x1.ffffeap-1f;
182 const float a3 = -0x1.55437p-2f;
183 const float a5 = +0x1.972be6p-3f;
184 const float a7 = -0x1.1436ap-3f;
185 const float a9 = +0x1.5785aap-4f;
186 const float a11 = -0x1.2f3004p-5f;
187 const float a13 = +0x1.01a37cp-7f;
189 const float x_times_x = x * x;
191 arctan = fmaf(x_times_x, arctan, a11);
192 arctan = fmaf(x_times_x, arctan, a9);
193 arctan = fmaf(x_times_x, arctan, a7);
194 arctan = fmaf(x_times_x, arctan, a5);
195 arctan = fmaf(x_times_x, arctan, a3);
196 arctan = fmaf(x_times_x, arctan, a1);
209 const float pi_2 = 0x1.921fb6p0f;
231 const float pi = 0x1.921fb6p1f;
232 const float pi_2 = 0x1.921fb6p0f;
234 if (fabs(x) == 0.f) {
235 return (fabs(y) == 0.f) ? copysignf(0.f, y) : copysignf(pi_2, y);
237 const int swap = fabs(x) < fabs(y);
238 const float input = swap ? (x / y) : (y / x);
240 result = swap ? (input >= 0.f ? pi_2 : -pi_2) - result : result;
242 result += copysignf(pi, y);