annotate src/opus-1.3/celt/os_support.h @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents 7aeed7906520
children
rev   line source
Chris@69 1 /* Copyright (C) 2007 Jean-Marc Valin
Chris@69 2
Chris@69 3 File: os_support.h
Chris@69 4 This is the (tiny) OS abstraction layer. Aside from math.h, this is the
Chris@69 5 only place where system headers are allowed.
Chris@69 6
Chris@69 7 Redistribution and use in source and binary forms, with or without
Chris@69 8 modification, are permitted provided that the following conditions are
Chris@69 9 met:
Chris@69 10
Chris@69 11 1. Redistributions of source code must retain the above copyright notice,
Chris@69 12 this list of conditions and the following disclaimer.
Chris@69 13
Chris@69 14 2. Redistributions in binary form must reproduce the above copyright
Chris@69 15 notice, this list of conditions and the following disclaimer in the
Chris@69 16 documentation and/or other materials provided with the distribution.
Chris@69 17
Chris@69 18 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
Chris@69 19 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
Chris@69 20 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Chris@69 21 DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
Chris@69 22 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
Chris@69 23 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Chris@69 24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Chris@69 25 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
Chris@69 26 STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
Chris@69 27 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Chris@69 28 POSSIBILITY OF SUCH DAMAGE.
Chris@69 29 */
Chris@69 30
Chris@69 31 #ifndef OS_SUPPORT_H
Chris@69 32 #define OS_SUPPORT_H
Chris@69 33
Chris@69 34 #ifdef CUSTOM_SUPPORT
Chris@69 35 # include "custom_support.h"
Chris@69 36 #endif
Chris@69 37
Chris@69 38 #include "opus_types.h"
Chris@69 39 #include "opus_defines.h"
Chris@69 40
Chris@69 41 #include <string.h>
Chris@69 42 #include <stdio.h>
Chris@69 43 #include <stdlib.h>
Chris@69 44
Chris@69 45 /** Opus wrapper for malloc(). To do your own dynamic allocation, all you need to do is replace this function and opus_free */
Chris@69 46 #ifndef OVERRIDE_OPUS_ALLOC
Chris@69 47 static OPUS_INLINE void *opus_alloc (size_t size)
Chris@69 48 {
Chris@69 49 return malloc(size);
Chris@69 50 }
Chris@69 51 #endif
Chris@69 52
Chris@69 53 /** Same as celt_alloc(), except that the area is only needed inside a CELT call (might cause problem with wideband though) */
Chris@69 54 #ifndef OVERRIDE_OPUS_ALLOC_SCRATCH
Chris@69 55 static OPUS_INLINE void *opus_alloc_scratch (size_t size)
Chris@69 56 {
Chris@69 57 /* Scratch space doesn't need to be cleared */
Chris@69 58 return opus_alloc(size);
Chris@69 59 }
Chris@69 60 #endif
Chris@69 61
Chris@69 62 /** Opus wrapper for free(). To do your own dynamic allocation, all you need to do is replace this function and opus_alloc */
Chris@69 63 #ifndef OVERRIDE_OPUS_FREE
Chris@69 64 static OPUS_INLINE void opus_free (void *ptr)
Chris@69 65 {
Chris@69 66 free(ptr);
Chris@69 67 }
Chris@69 68 #endif
Chris@69 69
Chris@69 70 /** Copy n elements from src to dst. The 0* term provides compile-time type checking */
Chris@69 71 #ifndef OVERRIDE_OPUS_COPY
Chris@69 72 #define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
Chris@69 73 #endif
Chris@69 74
Chris@69 75 /** Copy n elements from src to dst, allowing overlapping regions. The 0* term
Chris@69 76 provides compile-time type checking */
Chris@69 77 #ifndef OVERRIDE_OPUS_MOVE
Chris@69 78 #define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) ))
Chris@69 79 #endif
Chris@69 80
Chris@69 81 /** Set n elements of dst to zero */
Chris@69 82 #ifndef OVERRIDE_OPUS_CLEAR
Chris@69 83 #define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst))))
Chris@69 84 #endif
Chris@69 85
Chris@69 86 /*#ifdef __GNUC__
Chris@69 87 #pragma GCC poison printf sprintf
Chris@69 88 #pragma GCC poison malloc free realloc calloc
Chris@69 89 #endif*/
Chris@69 90
Chris@69 91 #endif /* OS_SUPPORT_H */
Chris@69 92