Chris@69: /* Copyright (C) 2007 Jean-Marc Valin Chris@69: Chris@69: File: os_support.h Chris@69: This is the (tiny) OS abstraction layer. Aside from math.h, this is the Chris@69: only place where system headers are allowed. Chris@69: Chris@69: Redistribution and use in source and binary forms, with or without Chris@69: modification, are permitted provided that the following conditions are Chris@69: met: Chris@69: Chris@69: 1. Redistributions of source code must retain the above copyright notice, Chris@69: this list of conditions and the following disclaimer. Chris@69: Chris@69: 2. Redistributions in binary form must reproduce the above copyright Chris@69: notice, this list of conditions and the following disclaimer in the Chris@69: documentation and/or other materials provided with the distribution. Chris@69: Chris@69: THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR Chris@69: IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES Chris@69: OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE Chris@69: DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, Chris@69: INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES Chris@69: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR Chris@69: SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) Chris@69: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, Chris@69: STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN Chris@69: ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE Chris@69: POSSIBILITY OF SUCH DAMAGE. Chris@69: */ Chris@69: Chris@69: #ifndef OS_SUPPORT_H Chris@69: #define OS_SUPPORT_H Chris@69: Chris@69: #ifdef CUSTOM_SUPPORT Chris@69: # include "custom_support.h" Chris@69: #endif Chris@69: Chris@69: #include "opus_types.h" Chris@69: #include "opus_defines.h" Chris@69: Chris@69: #include Chris@69: #include Chris@69: #include Chris@69: Chris@69: /** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */ Chris@69: #ifndef OVERRIDE_OPUS_ALLOC Chris@69: static OPUS_INLINE void *opus_alloc (size_t size) Chris@69: { Chris@69: return malloc(size); Chris@69: } Chris@69: #endif Chris@69: Chris@69: /** Same as celt_alloc(), except that the area is only needed inside a CELT call (might cause problem with wideband though) */ Chris@69: #ifndef OVERRIDE_OPUS_ALLOC_SCRATCH Chris@69: static OPUS_INLINE void *opus_alloc_scratch (size_t size) Chris@69: { Chris@69: /* Scratch space doesn't need to be cleared */ Chris@69: return opus_alloc(size); Chris@69: } Chris@69: #endif Chris@69: Chris@69: /** Opus wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and opus_alloc */ Chris@69: #ifndef OVERRIDE_OPUS_FREE Chris@69: static OPUS_INLINE void opus_free (void *ptr) Chris@69: { Chris@69: free(ptr); Chris@69: } Chris@69: #endif Chris@69: Chris@69: /** Copy n elements from src to dst. The 0* term provides compile-time type checking */ Chris@69: #ifndef OVERRIDE_OPUS_COPY Chris@69: #define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) Chris@69: #endif Chris@69: Chris@69: /** Copy n elements from src to dst, allowing overlapping regions. The 0* term Chris@69: provides compile-time type checking */ Chris@69: #ifndef OVERRIDE_OPUS_MOVE Chris@69: #define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) Chris@69: #endif Chris@69: Chris@69: /** Set n elements of dst to zero */ Chris@69: #ifndef OVERRIDE_OPUS_CLEAR Chris@69: #define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) Chris@69: #endif Chris@69: Chris@69: /*#ifdef __GNUC__ Chris@69: #pragma GCC poison printf sprintf Chris@69: #pragma GCC poison malloc free realloc calloc Chris@69: #endif*/ Chris@69: Chris@69: #endif /* OS_SUPPORT_H */ Chris@69: