chris@162: /** chris@162: * Copyright (c) 2014, 2015, Enzien Audio Ltd. chris@162: * chris@162: * Permission to use, copy, modify, and/or distribute this software for any chris@162: * purpose with or without fee is hereby granted, provided that the above chris@162: * copyright notice and this permission notice appear in all copies. chris@162: * chris@162: * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH chris@162: * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY chris@162: * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, chris@162: * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM chris@162: * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR chris@162: * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR chris@162: * PERFORMANCE OF THIS SOFTWARE. chris@162: */ chris@162: chris@162: #ifndef _HEAVY_UTILS_MAC_H_ chris@162: #define _HEAVY_UTILS_MAC_H_ chris@162: chris@162: #include "Utils.h" chris@162: chris@162: #if HV_APPLE chris@162: #include chris@162: #if HV_SIMD_AVX || HV_SIMD_SSE chris@162: #include chris@162: #include chris@162: #elif HV_SIMD_NEON chris@162: #include chris@162: #endif chris@162: #include chris@162: #include chris@162: #include chris@162: #include chris@162: #include chris@162: #include chris@162: #include chris@162: #include chris@162: chris@162: #define HV_EXPORT chris@162: #define HV_FORCE_INLINE inline __attribute__((always_inline)) chris@162: chris@162: // Memory management chris@162: #define hv_alloca(_n) alloca(_n) chris@162: #if HV_SIMD_AVX || HV_SIMD_SSE chris@162: #define hv_malloc(_n) _mm_malloc(_n, 32) // 32 to ensure AVX compatability (16 otherwise) chris@162: #define hv_free(x) _mm_free(x) chris@162: #else chris@162: #define hv_malloc(_n) malloc(_n) chris@162: #define hv_free(x) free(x) chris@162: #endif chris@162: #define hv_realloc(a, b) realloc(a, b) chris@162: #define hv_memcpy(a, b, c) memcpy(a, b, c) chris@162: #define hv_memset(a, b) memset(a, 0, b) chris@162: chris@162: // Strings chris@162: #define hv_strlen(a) strlen(a) chris@162: #define hv_strncat(a, b, c) strncat(a, b, c) chris@162: #define hv_strncpy(a, b, c) strncpy(a, b, c) chris@162: #define hv_strcmp(a, b) strcmp(a, b) chris@162: #define hv_strncmp(a, b, c) strncmp(a, b, c) chris@162: #define hv_snprintf(a, b, c, ...) snprintf(a, b, c, __VA_ARGS__) chris@162: chris@162: // Math chris@162: #define hv_max_f(a, b) fmaxf(a, b) chris@162: #define hv_min_f(a, b) fminf(a, b) chris@162: #define hv_max_d(a, b) fmax(a, b) chris@162: #define hv_min_d(a, b) fmin(a, b) chris@162: #define hv_sin_f(a) sinf(a) chris@162: #define hv_sinh_f(a) sinhf(a) chris@162: #define hv_cos_f(a) cosf(a) chris@162: #define hv_cosh_f(a) coshf(a) chris@162: #define hv_tan_f(a) tanf(a) chris@162: #define hv_tanh_f(a) tanhf(a) chris@162: #define hv_asin_f(a) asinf(a) chris@162: #define hv_asinh_f(a) asinhf(a) chris@162: #define hv_acos_f(a) acosf(a) chris@162: #define hv_acosh_f(a) acoshf(a) chris@162: #define hv_atan_f(a) atanf(a) chris@162: #define hv_atanh_f(a) atanhf(a) chris@162: #define hv_atan2_f(a, b) atan2f(a, b) chris@162: #define hv_exp_f(a) expf(a) chris@162: #define hv_abs_f(a) fabsf(a) chris@162: #define hv_sqrt_f(a) sqrtf(a) chris@162: #define hv_log_f(a) logf(a) chris@162: #define hv_log2_f(a) log2f(a) chris@162: #define hv_log10_f(a) log10f(a) chris@162: #define hv_ceil_f(a) ceilf(a) chris@162: #define hv_floor_f(a) floorf(a) chris@162: #define hv_round_f(a) roundf(a) chris@162: #define hv_pow_f(a, b) powf(a, b) chris@162: #define hv_fma_f(a, b, c) ((a*b)+c) // TODO(joe): use 'fmaf(a, b, c)' once emscripten supports it chris@162: chris@162: // Utilities chris@162: #define hv_assert(e) assert(e) chris@162: #define hv_clear_buffer(b, n) memset(b, 0, (n)*sizeof(float)) chris@162: chris@162: #endif // HV_APPLE chris@162: #endif // _HEAVY_UTILS_MAC_H_