/src/opus/celt/os_support.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2007 Jean-Marc Valin |
2 | | |
3 | | File: os_support.h |
4 | | This is the (tiny) OS abstraction layer. Aside from math.h, this is the |
5 | | only place where system headers are allowed. |
6 | | |
7 | | Redistribution and use in source and binary forms, with or without |
8 | | modification, are permitted provided that the following conditions are |
9 | | met: |
10 | | |
11 | | 1. Redistributions of source code must retain the above copyright notice, |
12 | | this list of conditions and the following disclaimer. |
13 | | |
14 | | 2. Redistributions in binary form must reproduce the above copyright |
15 | | notice, this list of conditions and the following disclaimer in the |
16 | | documentation and/or other materials provided with the distribution. |
17 | | |
18 | | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
19 | | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
21 | | DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
22 | | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
23 | | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
24 | | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 | | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
26 | | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
27 | | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | | POSSIBILITY OF SUCH DAMAGE. |
29 | | */ |
30 | | |
31 | | #ifndef OS_SUPPORT_H |
32 | | #define OS_SUPPORT_H |
33 | | |
34 | | #ifdef CUSTOM_SUPPORT |
35 | | # include "custom_support.h" |
36 | | #endif |
37 | | |
38 | | #include "opus_types.h" |
39 | | #include "opus_defines.h" |
40 | | |
41 | | #include <string.h> |
42 | | #include <stdlib.h> |
43 | | |
44 | | /** Opus wrapper for malloc(). To do your own dynamic allocation replace this function, opus_realloc, and opus_free */ |
45 | | #ifndef OVERRIDE_OPUS_ALLOC |
46 | | static OPUS_INLINE void *opus_alloc (size_t size) |
47 | 0 | { |
48 | 0 | return malloc(size); |
49 | 0 | } Unexecuted instantiation: celt.c:opus_alloc Unexecuted instantiation: pitch_sse.c:opus_alloc Unexecuted instantiation: opus_multistream_encoder.c:opus_alloc Unexecuted instantiation: repacketizer.c:opus_alloc Unexecuted instantiation: bands.c:opus_alloc Unexecuted instantiation: celt_encoder.c:opus_alloc Unexecuted instantiation: entdec.c:opus_alloc Unexecuted instantiation: entenc.c:opus_alloc Unexecuted instantiation: mathops.c:opus_alloc Unexecuted instantiation: mdct.c:opus_alloc Unexecuted instantiation: modes.c:opus_alloc Unexecuted instantiation: pitch.c:opus_alloc Unexecuted instantiation: celt_lpc.c:opus_alloc Unexecuted instantiation: quant_bands.c:opus_alloc Unexecuted instantiation: rate.c:opus_alloc Unexecuted instantiation: vq.c:opus_alloc Unexecuted instantiation: vq_sse2.c:opus_alloc Unexecuted instantiation: opus_decoder.c:opus_alloc Unexecuted instantiation: opus_encoder.c:opus_alloc Unexecuted instantiation: extensions.c:opus_alloc Unexecuted instantiation: opus_multistream.c:opus_alloc Unexecuted instantiation: analysis.c:opus_alloc Unexecuted instantiation: celt_decoder.c:opus_alloc Unexecuted instantiation: cwrs.c:opus_alloc Unexecuted instantiation: kiss_fft.c:opus_alloc Unexecuted instantiation: laplace.c:opus_alloc Unexecuted instantiation: dec_API.c:opus_alloc |
50 | | #endif |
51 | | |
52 | | #ifndef OVERRIDE_OPUS_REALLOC |
53 | | static OPUS_INLINE void *opus_realloc (void *ptr, size_t size) |
54 | 0 | { |
55 | 0 | return realloc(ptr, size); |
56 | 0 | } Unexecuted instantiation: celt.c:opus_realloc Unexecuted instantiation: pitch_sse.c:opus_realloc Unexecuted instantiation: opus_multistream_encoder.c:opus_realloc Unexecuted instantiation: repacketizer.c:opus_realloc Unexecuted instantiation: bands.c:opus_realloc Unexecuted instantiation: celt_encoder.c:opus_realloc Unexecuted instantiation: entdec.c:opus_realloc Unexecuted instantiation: entenc.c:opus_realloc Unexecuted instantiation: mathops.c:opus_realloc Unexecuted instantiation: mdct.c:opus_realloc Unexecuted instantiation: modes.c:opus_realloc Unexecuted instantiation: pitch.c:opus_realloc Unexecuted instantiation: celt_lpc.c:opus_realloc Unexecuted instantiation: quant_bands.c:opus_realloc Unexecuted instantiation: rate.c:opus_realloc Unexecuted instantiation: vq.c:opus_realloc Unexecuted instantiation: vq_sse2.c:opus_realloc Unexecuted instantiation: opus_decoder.c:opus_realloc Unexecuted instantiation: opus_encoder.c:opus_realloc Unexecuted instantiation: extensions.c:opus_realloc Unexecuted instantiation: opus_multistream.c:opus_realloc Unexecuted instantiation: analysis.c:opus_realloc Unexecuted instantiation: celt_decoder.c:opus_realloc Unexecuted instantiation: cwrs.c:opus_realloc Unexecuted instantiation: kiss_fft.c:opus_realloc Unexecuted instantiation: laplace.c:opus_realloc Unexecuted instantiation: dec_API.c:opus_realloc |
57 | | #endif |
58 | | |
59 | | /** Used only for non-threadsafe pseudostack. |
60 | | If desired, this can always return the same area of memory rather than allocating a new one every time. */ |
61 | | #ifndef OVERRIDE_OPUS_ALLOC_SCRATCH |
62 | | static OPUS_INLINE void *opus_alloc_scratch (size_t size) |
63 | 0 | { |
64 | 0 | /* Scratch space doesn't need to be cleared */ |
65 | 0 | return opus_alloc(size); |
66 | 0 | } Unexecuted instantiation: celt.c:opus_alloc_scratch Unexecuted instantiation: pitch_sse.c:opus_alloc_scratch Unexecuted instantiation: opus_multistream_encoder.c:opus_alloc_scratch Unexecuted instantiation: repacketizer.c:opus_alloc_scratch Unexecuted instantiation: bands.c:opus_alloc_scratch Unexecuted instantiation: celt_encoder.c:opus_alloc_scratch Unexecuted instantiation: entdec.c:opus_alloc_scratch Unexecuted instantiation: entenc.c:opus_alloc_scratch Unexecuted instantiation: mathops.c:opus_alloc_scratch Unexecuted instantiation: mdct.c:opus_alloc_scratch Unexecuted instantiation: modes.c:opus_alloc_scratch Unexecuted instantiation: pitch.c:opus_alloc_scratch Unexecuted instantiation: celt_lpc.c:opus_alloc_scratch Unexecuted instantiation: quant_bands.c:opus_alloc_scratch Unexecuted instantiation: rate.c:opus_alloc_scratch Unexecuted instantiation: vq.c:opus_alloc_scratch Unexecuted instantiation: vq_sse2.c:opus_alloc_scratch Unexecuted instantiation: opus_decoder.c:opus_alloc_scratch Unexecuted instantiation: opus_encoder.c:opus_alloc_scratch Unexecuted instantiation: extensions.c:opus_alloc_scratch Unexecuted instantiation: opus_multistream.c:opus_alloc_scratch Unexecuted instantiation: analysis.c:opus_alloc_scratch Unexecuted instantiation: celt_decoder.c:opus_alloc_scratch Unexecuted instantiation: cwrs.c:opus_alloc_scratch Unexecuted instantiation: kiss_fft.c:opus_alloc_scratch Unexecuted instantiation: laplace.c:opus_alloc_scratch Unexecuted instantiation: dec_API.c:opus_alloc_scratch |
67 | | #endif |
68 | | |
69 | | /** Opus wrapper for free(). To do your own dynamic allocation replace this function, opus_realloc, and opus_free */ |
70 | | #ifndef OVERRIDE_OPUS_FREE |
71 | | static OPUS_INLINE void opus_free (void *ptr) |
72 | 0 | { |
73 | 0 | free(ptr); |
74 | 0 | } Unexecuted instantiation: celt.c:opus_free Unexecuted instantiation: pitch_sse.c:opus_free Unexecuted instantiation: opus_multistream_encoder.c:opus_free Unexecuted instantiation: repacketizer.c:opus_free Unexecuted instantiation: bands.c:opus_free Unexecuted instantiation: celt_encoder.c:opus_free Unexecuted instantiation: entdec.c:opus_free Unexecuted instantiation: entenc.c:opus_free Unexecuted instantiation: mathops.c:opus_free Unexecuted instantiation: mdct.c:opus_free Unexecuted instantiation: modes.c:opus_free Unexecuted instantiation: pitch.c:opus_free Unexecuted instantiation: celt_lpc.c:opus_free Unexecuted instantiation: quant_bands.c:opus_free Unexecuted instantiation: rate.c:opus_free Unexecuted instantiation: vq.c:opus_free Unexecuted instantiation: vq_sse2.c:opus_free Unexecuted instantiation: opus_decoder.c:opus_free Unexecuted instantiation: opus_encoder.c:opus_free Unexecuted instantiation: extensions.c:opus_free Unexecuted instantiation: opus_multistream.c:opus_free Unexecuted instantiation: analysis.c:opus_free Unexecuted instantiation: celt_decoder.c:opus_free Unexecuted instantiation: cwrs.c:opus_free Unexecuted instantiation: kiss_fft.c:opus_free Unexecuted instantiation: laplace.c:opus_free Unexecuted instantiation: dec_API.c:opus_free |
75 | | #endif |
76 | | |
77 | | /** Copy n elements from src to dst. The 0* term provides compile-time type checking */ |
78 | | #ifndef OVERRIDE_OPUS_COPY |
79 | 0 | #define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) |
80 | | #endif |
81 | | |
82 | | /** Copy n elements from src to dst, allowing overlapping regions. The 0* term |
83 | | provides compile-time type checking */ |
84 | | #ifndef OVERRIDE_OPUS_MOVE |
85 | 0 | #define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((dst)-(src)) )) |
86 | | #endif |
87 | | |
88 | | /** Set n elements of dst to zero */ |
89 | | #ifndef OVERRIDE_OPUS_CLEAR |
90 | 0 | #define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) |
91 | | #endif |
92 | | |
93 | | /*#ifdef __GNUC__ |
94 | | #pragma GCC poison printf sprintf |
95 | | #pragma GCC poison malloc free realloc calloc |
96 | | #endif*/ |
97 | | |
98 | | #endif /* OS_SUPPORT_H */ |
99 | | |