annotate projects/heavy/circularBuffer/Utils_mac.h @ 163:20b52283c7b4 heavy-updated

- added circular buffer pd/heavy example (works but process needs to be killed manually if launched via ssh?)
author chnrx <chris.heinrichs@gmail.com>
date Thu, 12 Nov 2015 15:55:30 +0000
parents
children
rev   line source
chris@163 1 /**
chris@163 2 * Copyright (c) 2014, 2015, Enzien Audio Ltd.
chris@163 3 *
chris@163 4 * Permission to use, copy, modify, and/or distribute this software for any
chris@163 5 * purpose with or without fee is hereby granted, provided that the above
chris@163 6 * copyright notice and this permission notice appear in all copies.
chris@163 7 *
chris@163 8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
chris@163 9 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
chris@163 10 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
chris@163 11 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
chris@163 12 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
chris@163 13 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
chris@163 14 * PERFORMANCE OF THIS SOFTWARE.
chris@163 15 */
chris@163 16
chris@163 17 #ifndef _HEAVY_UTILS_MAC_H_
chris@163 18 #define _HEAVY_UTILS_MAC_H_
chris@163 19
chris@163 20 #include "Utils.h"
chris@163 21
chris@163 22 #if HV_APPLE
chris@163 23 #include <alloca.h>
chris@163 24 #if HV_SIMD_AVX || HV_SIMD_SSE
chris@163 25 #include <immintrin.h>
chris@163 26 #include <mm_malloc.h>
chris@163 27 #elif HV_SIMD_NEON
chris@163 28 #include <arm_neon.h>
chris@163 29 #endif
chris@163 30 #include <assert.h>
chris@163 31 #include <math.h>
chris@163 32 #include <stdarg.h>
chris@163 33 #include <stdbool.h>
chris@163 34 #include <stdint.h>
chris@163 35 #include <stdio.h>
chris@163 36 #include <stdlib.h>
chris@163 37 #include <string.h>
chris@163 38
chris@163 39 #define HV_EXPORT
chris@163 40 #define HV_FORCE_INLINE inline __attribute__((always_inline))
chris@163 41
chris@163 42 // Memory management
chris@163 43 #define hv_alloca(_n) alloca(_n)
chris@163 44 #if HV_SIMD_AVX || HV_SIMD_SSE
chris@163 45 #define hv_malloc(_n) _mm_malloc(_n, 32) // 32 to ensure AVX compatability (16 otherwise)
chris@163 46 #define hv_free(x) _mm_free(x)
chris@163 47 #else
chris@163 48 #define hv_malloc(_n) malloc(_n)
chris@163 49 #define hv_free(x) free(x)
chris@163 50 #endif
chris@163 51 #define hv_realloc(a, b) realloc(a, b)
chris@163 52 #define hv_memcpy(a, b, c) memcpy(a, b, c)
chris@163 53 #define hv_memset(a, b) memset(a, 0, b)
chris@163 54
chris@163 55 // Strings
chris@163 56 #define hv_strlen(a) strlen(a)
chris@163 57 #define hv_strncat(a, b, c) strncat(a, b, c)
chris@163 58 #define hv_strncpy(a, b, c) strncpy(a, b, c)
chris@163 59 #define hv_strcmp(a, b) strcmp(a, b)
chris@163 60 #define hv_strncmp(a, b, c) strncmp(a, b, c)
chris@163 61 #define hv_snprintf(a, b, c, ...) snprintf(a, b, c, __VA_ARGS__)
chris@163 62
chris@163 63 // Math
chris@163 64 #define hv_max_f(a, b) fmaxf(a, b)
chris@163 65 #define hv_min_f(a, b) fminf(a, b)
chris@163 66 #define hv_max_d(a, b) fmax(a, b)
chris@163 67 #define hv_min_d(a, b) fmin(a, b)
chris@163 68 #define hv_sin_f(a) sinf(a)
chris@163 69 #define hv_sinh_f(a) sinhf(a)
chris@163 70 #define hv_cos_f(a) cosf(a)
chris@163 71 #define hv_cosh_f(a) coshf(a)
chris@163 72 #define hv_tan_f(a) tanf(a)
chris@163 73 #define hv_tanh_f(a) tanhf(a)
chris@163 74 #define hv_asin_f(a) asinf(a)
chris@163 75 #define hv_asinh_f(a) asinhf(a)
chris@163 76 #define hv_acos_f(a) acosf(a)
chris@163 77 #define hv_acosh_f(a) acoshf(a)
chris@163 78 #define hv_atan_f(a) atanf(a)
chris@163 79 #define hv_atanh_f(a) atanhf(a)
chris@163 80 #define hv_atan2_f(a, b) atan2f(a, b)
chris@163 81 #define hv_exp_f(a) expf(a)
chris@163 82 #define hv_abs_f(a) fabsf(a)
chris@163 83 #define hv_sqrt_f(a) sqrtf(a)
chris@163 84 #define hv_log_f(a) logf(a)
chris@163 85 #define hv_log2_f(a) log2f(a)
chris@163 86 #define hv_log10_f(a) log10f(a)
chris@163 87 #define hv_ceil_f(a) ceilf(a)
chris@163 88 #define hv_floor_f(a) floorf(a)
chris@163 89 #define hv_round_f(a) roundf(a)
chris@163 90 #define hv_pow_f(a, b) powf(a, b)
chris@163 91 #define hv_fma_f(a, b, c) ((a*b)+c) // TODO(joe): use 'fmaf(a, b, c)' once emscripten supports it
chris@163 92
chris@163 93 // Utilities
chris@163 94 #define hv_assert(e) assert(e)
chris@163 95 #define hv_clear_buffer(b, n) memset(b, 0, (n)*sizeof(float))
chris@163 96
chris@163 97 #endif // HV_APPLE
chris@163 98 #endif // _HEAVY_UTILS_MAC_H_