/src/opencv/3rdparty/openexr/IlmImf/ImfSystemSpecific.h
Line | Count | Source (jump to first uncovered line) |
1 | | /////////////////////////////////////////////////////////////////////////// |
2 | | // |
3 | | // Copyright (c) 2012, Industrial Light & Magic, a division of Lucas |
4 | | // Digital Ltd. LLC |
5 | | // |
6 | | // All rights reserved. |
7 | | // |
8 | | // Redistribution and use in source and binary forms, with or without |
9 | | // modification, are permitted provided that the following conditions are |
10 | | // met: |
11 | | // * Redistributions of source code must retain the above copyright |
12 | | // notice, this list of conditions and the following disclaimer. |
13 | | // * Redistributions in binary form must reproduce the above |
14 | | // copyright notice, this list of conditions and the following disclaimer |
15 | | // in the documentation and/or other materials provided with the |
16 | | // distribution. |
17 | | // * Neither the name of Industrial Light & Magic nor the names of |
18 | | // its contributors may be used to endorse or promote products derived |
19 | | // from this software without specific prior written permission. |
20 | | // |
21 | | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
22 | | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
23 | | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
24 | | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
25 | | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
26 | | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
27 | | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
28 | | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
29 | | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
30 | | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
31 | | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
32 | | // |
33 | | /////////////////////////////////////////////////////////////////////////// |
34 | | |
35 | | #ifndef INCLUDED_IMF_COMPILER_SPECIFIC_H |
36 | | #define INCLUDED_IMF_COMPILER_SPECIFIC_H |
37 | | |
38 | | #include "ImfNamespace.h" |
39 | | #include "ImfSimd.h" |
40 | | #include <stdlib.h> |
41 | | #include "ImfExport.h" |
42 | | |
43 | | OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_ENTER |
44 | | |
45 | | |
46 | | static unsigned long systemEndianCheckValue = 0x12345678; |
47 | | static unsigned long* systemEndianCheckPointer = &systemEndianCheckValue; |
48 | | |
49 | | // EXR files are little endian - check processor architecture is too |
50 | | // (optimisation currently not supported for big endian machines) |
51 | | static bool GLOBAL_SYSTEM_LITTLE_ENDIAN = |
52 | | (*(unsigned char*)systemEndianCheckPointer == 0x78 ? true : false); |
53 | | |
54 | | |
55 | | #ifdef IMF_HAVE_SSE2 |
56 | | |
57 | | #if defined(__GNUC__) |
58 | | // Causes issues on certain gcc versions |
59 | | //#define EXR_FORCEINLINE inline __attribute__((always_inline)) |
60 | | #define EXR_FORCEINLINE inline |
61 | | #define EXR_RESTRICT __restrict |
62 | | |
63 | | static void* EXRAllocAligned(size_t size, size_t alignment) |
64 | 0 | { |
65 | | // GNUC is used for things like mingw to (cross-)compile for windows |
66 | | #ifdef _WIN32 |
67 | | return _aligned_malloc(size, alignment); |
68 | | #elif defined(__ANDROID__) |
69 | | return memalign(alignment, size); |
70 | | #else |
71 | 0 | void* ptr = 0; |
72 | 0 | posix_memalign(&ptr, alignment, size); |
73 | 0 | return ptr; |
74 | 0 | #endif |
75 | 0 | } Unexecuted instantiation: ImfScanLineInputFile.cpp:Imf_opencv::EXRAllocAligned(unsigned long, unsigned long) Unexecuted instantiation: ImfDwaCompressor.cpp:Imf_opencv::EXRAllocAligned(unsigned long, unsigned long) Unexecuted instantiation: ImfSystemSpecific.cpp:Imf_opencv::EXRAllocAligned(unsigned long, unsigned long) |
76 | | |
77 | | |
78 | | static void EXRFreeAligned(void* ptr) |
79 | 0 | { |
80 | | #ifdef _WIN32 |
81 | | _aligned_free(ptr); |
82 | | #else |
83 | 0 | free(ptr); |
84 | 0 | #endif |
85 | 0 | } Unexecuted instantiation: ImfScanLineInputFile.cpp:Imf_opencv::EXRFreeAligned(void*) Unexecuted instantiation: ImfDwaCompressor.cpp:Imf_opencv::EXRFreeAligned(void*) Unexecuted instantiation: ImfSystemSpecific.cpp:Imf_opencv::EXRFreeAligned(void*) |
86 | | |
87 | | #elif defined _MSC_VER |
88 | | |
89 | | #define EXR_FORCEINLINE __forceinline |
90 | | #define EXR_RESTRICT __restrict |
91 | | |
92 | | static void* EXRAllocAligned(size_t size, size_t alignment) |
93 | | { |
94 | | return _aligned_malloc(size, alignment); |
95 | | } |
96 | | |
97 | | |
98 | | static void EXRFreeAligned(void* ptr) |
99 | | { |
100 | | _aligned_free(ptr); |
101 | | } |
102 | | |
103 | | #elif defined (__INTEL_COMPILER) || \ |
104 | | defined(__ICL) || \ |
105 | | defined(__ICC) || \ |
106 | | defined(__ECC) |
107 | | |
108 | | #define EXR_FORCEINLINE inline |
109 | | #define EXR_RESTRICT restrict |
110 | | |
111 | | static void* EXRAllocAligned(size_t size, size_t alignment) |
112 | | { |
113 | | return _mm_malloc(size, alignment); |
114 | | } |
115 | | |
116 | | |
117 | | static void EXRFreeAligned(void* ptr) |
118 | | { |
119 | | _mm_free(ptr); |
120 | | } |
121 | | |
122 | | #else |
123 | | |
124 | | // generic compiler |
125 | | #define EXR_FORCEINLINE inline |
126 | | #define EXR_RESTRICT |
127 | | |
128 | | static void* EXRAllocAligned(size_t size, size_t alignment) |
129 | | { |
130 | | return malloc(size); |
131 | | } |
132 | | |
133 | | |
134 | | static void EXRFreeAligned(void* ptr) |
135 | | { |
136 | | free(ptr); |
137 | | } |
138 | | |
139 | | #endif // compiler switch |
140 | | |
141 | | |
142 | | #else // IMF_HAVE_SSE2 |
143 | | |
144 | | |
145 | | #define EXR_FORCEINLINE inline |
146 | | #define EXR_RESTRICT |
147 | | |
148 | | static void* EXRAllocAligned(size_t size, size_t alignment) |
149 | | { |
150 | | return malloc(size); |
151 | | } |
152 | | |
153 | | |
154 | | static void EXRFreeAligned(void* ptr) |
155 | | { |
156 | | free(ptr); |
157 | | } |
158 | | |
159 | | |
160 | | #endif // IMF_HAVE_SSE2 |
161 | | |
162 | | // |
163 | | // Simple CPUID based runtime detection of various capabilities |
164 | | // |
165 | | class IMF_EXPORT CpuId |
166 | | { |
167 | | public: |
168 | | CpuId(); |
169 | | |
170 | | bool sse2; |
171 | | bool sse3; |
172 | | bool ssse3; |
173 | | bool sse4_1; |
174 | | bool sse4_2; |
175 | | bool avx; |
176 | | bool f16c; |
177 | | }; |
178 | | |
179 | | |
180 | | OPENEXR_IMF_INTERNAL_NAMESPACE_HEADER_EXIT |
181 | | |
182 | | |
183 | | #endif //include guard |