OLD | NEW |
1 /* Copyright (C) 2007 Jean-Marc Valin | 1 /* Copyright (C) 2007 Jean-Marc Valin |
2 | 2 |
3 File: os_support.h | 3 File: os_support.h |
4 This is the (tiny) OS abstraction layer. Aside from math.h, this is the | 4 This is the (tiny) OS abstraction layer. Aside from math.h, this is the |
5 only place where system headers are allowed. | 5 only place where system headers are allowed. |
6 | 6 |
7 Redistribution and use in source and binary forms, with or without | 7 Redistribution and use in source and binary forms, with or without |
8 modification, are permitted provided that the following conditions are | 8 modification, are permitted provided that the following conditions are |
9 met: | 9 met: |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 POSSIBILITY OF SUCH DAMAGE. | 28 POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef OS_SUPPORT_H | 31 #ifndef OS_SUPPORT_H |
32 #define OS_SUPPORT_H | 32 #define OS_SUPPORT_H |
33 | 33 |
34 #ifdef CUSTOM_SUPPORT | 34 #ifdef CUSTOM_SUPPORT |
35 # include "custom_support.h" | 35 # include "custom_support.h" |
36 #endif | 36 #endif |
37 | 37 |
| 38 #include "opus_types.h" |
| 39 #include "opus_defines.h" |
| 40 |
38 #include <string.h> | 41 #include <string.h> |
39 #include <stdio.h> | 42 #include <stdio.h> |
40 #include <stdlib.h> | 43 #include <stdlib.h> |
41 | 44 |
42 /** Opus wrapper for malloc(). To do your own dynamic allocation, all you need t
o do is replace this function and opus_free */ | 45 /** Opus wrapper for malloc(). To do your own dynamic allocation, all you need t
o do is replace this function and opus_free */ |
43 #ifndef OVERRIDE_OPUS_ALLOC | 46 #ifndef OVERRIDE_OPUS_ALLOC |
44 static inline void *opus_alloc (size_t size) | 47 static OPUS_INLINE void *opus_alloc (size_t size) |
45 { | 48 { |
46 return malloc(size); | 49 return malloc(size); |
47 } | 50 } |
48 #endif | 51 #endif |
49 | 52 |
50 /** Same as celt_alloc(), except that the area is only needed inside a CELT call
(might cause problem with wideband though) */ | 53 /** Same as celt_alloc(), except that the area is only needed inside a CELT call
(might cause problem with wideband though) */ |
51 #ifndef OVERRIDE_OPUS_ALLOC_SCRATCH | 54 #ifndef OVERRIDE_OPUS_ALLOC_SCRATCH |
52 static inline void *opus_alloc_scratch (size_t size) | 55 static OPUS_INLINE void *opus_alloc_scratch (size_t size) |
53 { | 56 { |
54 /* Scratch space doesn't need to be cleared */ | 57 /* Scratch space doesn't need to be cleared */ |
55 return opus_alloc(size); | 58 return opus_alloc(size); |
56 } | 59 } |
57 #endif | 60 #endif |
58 | 61 |
59 /** Opus wrapper for free(). To do your own dynamic allocation, all you need to
do is replace this function and opus_alloc */ | 62 /** Opus wrapper for free(). To do your own dynamic allocation, all you need to
do is replace this function and opus_alloc */ |
60 #ifndef OVERRIDE_OPUS_FREE | 63 #ifndef OVERRIDE_OPUS_FREE |
61 static inline void opus_free (void *ptr) | 64 static OPUS_INLINE void opus_free (void *ptr) |
62 { | 65 { |
63 free(ptr); | 66 free(ptr); |
64 } | 67 } |
65 #endif | 68 #endif |
66 | 69 |
67 /** Copy n bytes of memory from src to dst. The 0* term provides compile-time ty
pe checking */ | 70 /** Copy n bytes of memory from src to dst. The 0* term provides compile-time ty
pe checking */ |
68 #ifndef OVERRIDE_OPUS_COPY | 71 #ifndef OVERRIDE_OPUS_COPY |
69 #define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((ds
t)-(src)) )) | 72 #define OPUS_COPY(dst, src, n) (memcpy((dst), (src), (n)*sizeof(*(dst)) + 0*((ds
t)-(src)) )) |
70 #endif | 73 #endif |
71 | 74 |
72 /** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0*
term | 75 /** Copy n bytes of memory from src to dst, allowing overlapping regions. The 0*
term |
73 provides compile-time type checking */ | 76 provides compile-time type checking */ |
74 #ifndef OVERRIDE_OPUS_MOVE | 77 #ifndef OVERRIDE_OPUS_MOVE |
75 #define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((d
st)-(src)) )) | 78 #define OPUS_MOVE(dst, src, n) (memmove((dst), (src), (n)*sizeof(*(dst)) + 0*((d
st)-(src)) )) |
76 #endif | 79 #endif |
77 | 80 |
78 /** Set n elements of dst to zero, starting at address s */ | 81 /** Set n elements of dst to zero, starting at address s */ |
79 #ifndef OVERRIDE_OPUS_CLEAR | 82 #ifndef OVERRIDE_OPUS_CLEAR |
80 #define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) | 83 #define OPUS_CLEAR(dst, n) (memset((dst), 0, (n)*sizeof(*(dst)))) |
81 #endif | 84 #endif |
82 | 85 |
83 /*#ifdef __GNUC__ | 86 /*#ifdef __GNUC__ |
84 #pragma GCC poison printf sprintf | 87 #pragma GCC poison printf sprintf |
85 #pragma GCC poison malloc free realloc calloc | 88 #pragma GCC poison malloc free realloc calloc |
86 #endif*/ | 89 #endif*/ |
87 | 90 |
88 #endif /* OS_SUPPORT_H */ | 91 #endif /* OS_SUPPORT_H */ |
89 | 92 |
OLD | NEW |