1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/media/libopus/celt/os_support.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,92 @@ 1.4 +/* Copyright (C) 2007 Jean-Marc Valin 1.5 + 1.6 + File: os_support.h 1.7 + This is the (tiny) OS abstraction layer. Aside from math.h, this is the 1.8 + only place where system headers are allowed. 1.9 + 1.10 + Redistribution and use in source and binary forms, with or without 1.11 + modification, are permitted provided that the following conditions are 1.12 + met: 1.13 + 1.14 + 1. Redistributions of source code must retain the above copyright notice, 1.15 + this list of conditions and the following disclaimer. 1.16 + 1.17 + 2. Redistributions in binary form must reproduce the above copyright 1.18 + notice, this list of conditions and the following disclaimer in the 1.19 + documentation and/or other materials provided with the distribution. 1.20 + 1.21 + THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1.22 + IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1.23 + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 1.24 + DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 1.25 + INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 1.26 + (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 1.27 + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 1.28 + HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 1.29 + STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 1.30 + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 1.31 + POSSIBILITY OF SUCH DAMAGE. 1.32 +*/ 1.33 + 1.34 +#ifndef OS_SUPPORT_H 1.35 +#define OS_SUPPORT_H 1.36 + 1.37 +#ifdef CUSTOM_SUPPORT 1.38 +# include "custom_support.h" 1.39 +#endif 1.40 + 1.41 +#include "opus_types.h" 1.42 +#include "opus_defines.h" 1.43 + 1.44 +#include <string.h> 1.45 +#include <stdio.h> 1.46 +#include <stdlib.h> 1.47 + 1.48 +/** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */ 1.49 +#ifndef OVERRIDE_OPUS_ALLOC 1.50 +static OPUS_INLINE void *opus_alloc (size_t size) 1.51 +{ 1.52 + return malloc(size); 1.53 +} 1.54 +#endif 1.55 + 1.56 +/** Same as celt_alloc(), except that the area is only needed inside a CELT call (might cause problem with wideband though) */ 1.57 +#ifndef OVERRIDE_OPUS_ALLOC_SCRATCH 1.58 +static OPUS_INLINE void *opus_alloc_scratch (size_t size) 1.59 +{ 1.60 + /* Scratch space doesn't need to be cleared */ 1.61 + return opus_alloc(size); 1.62 +} 1.63 +#endif 1.64 + 1.65 +/** Opus wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and opus_alloc */ 1.66 +#ifndef OVERRIDE_OPUS_FREE 1.67 +static OPUS_INLINE void opus_free (void *ptr) 1.68 +{ 1.69 + free(ptr); 1.70 +} 1.71 +#endif 1.72 + 1.73 +/** Copy n bytes of memory from src to dst. The 0* term provides compile-time type checking */ 1.74 +#ifndef OVERRIDE_OPUS_COPY 1.75 +#define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) 1.76 +#endif 1.77 + 1.78 +/** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0* term 1.79 + provides compile-time type checking */ 1.80 +#ifndef OVERRIDE_OPUS_MOVE 1.81 +#define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) 1.82 +#endif 1.83 + 1.84 +/** Set n elements of dst to zero, starting at address s */ 1.85 +#ifndef OVERRIDE_OPUS_CLEAR 1.86 +#define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) 1.87 +#endif 1.88 + 1.89 +/*#ifdef __GNUC__ 1.90 +#pragma GCC poison printf sprintf 1.91 +#pragma GCC poison malloc free realloc calloc 1.92 +#endif*/ 1.93 + 1.94 +#endif /* OS_SUPPORT_H */ 1.95 +