media/libopus/celt/os_support.h

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

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

mercurial