1 /*****************************************************************************/
2 // Copyright 2006-2019 Adobe Systems Incorporated
3 // All Rights Reserved.
4 //
5 // NOTICE:  Adobe permits you to use, modify, and distribute this file in
6 // accordance with the terms of the Adobe license agreement accompanying it.
7 /*****************************************************************************/
8 
9 /** \file
10  * Conditional compilation flags for DNG SDK.
11  *
12  * All conditional compilation macros for the DNG SDK begin with a lowercase 'q'.
13  */
14 
15 /*****************************************************************************/
16 
17 #ifndef __dng_flags__
18 #define __dng_flags__
19 
20 /*****************************************************************************/
21 
22 /// \def qMacOS
23 /// 1 if compiling for Mac OS X.
24 
25 /// \def qWinOS
26 /// 1 if compiling for Windows.
27 
28 // Make sure a platform is defined
29 
30 #if !(defined(qMacOS) || defined(qWinOS) || defined(qAndroid) || defined(qiPhone) || defined(qLinux))
31 #include "RawEnvironment.h"
32 #endif
33 
34 // This requires a force include or compiler define.  These are the unique platforms.
35 
36 #if !(defined(qMacOS) || defined(qWinOS) || defined(qAndroid) || defined(qiPhone) || defined(qLinux))
37 #error Unable to figure out platform
38 #endif
39 
40 /*****************************************************************************/
41 
42 // Platforms.
43 // Zeros out any undefined platforms, so that #if can be used in place of #ifdef.
44 
45 #ifndef qMacOS
46 #define qMacOS 0
47 #endif
48 
49 #ifndef qiPhone
50 #define qiPhone 0
51 #endif
52 
53 #ifndef qiPhoneSimulator
54 #define qiPhoneSimulator 0
55 #endif
56 
57 #ifndef qAndroid
58 #define qAndroid 0
59 #endif
60 
61 #ifndef qWinOS
62 #define qWinOS 0
63 #endif
64 
65 #ifndef qWinRT
66 #define qWinRT 0
67 #endif
68 
69 #ifndef qLinux
70 #define qLinux 0
71 #endif
72 
73 #ifndef qWeb
74 #define qWeb 0
75 #endif
76 
77 /*****************************************************************************/
78 
79 #if qiPhoneSimulator
80 #if !qiPhone
81 #error "qiPhoneSimulator set and not qiPhone"
82 #endif
83 #endif
84 
85 #if qWinRT
86 #if !qWinOS
87 #error "qWinRT set but not qWinOS"
88 #endif
89 #endif
90 
91 /*****************************************************************************/
92 
93 // arm and neon support
94 
95 // arm detect (apple vs. win)
96 #if defined(__arm__) || defined(__arm64__) || defined(_M_ARM)
97 #define qARM 1
98 #endif
99 
100 // arm_neon detect
101 #if defined(__ARM_NEON__) || defined(_M_ARM)
102 #define qARMNeon 1
103 #endif
104 
105 #ifndef qARM
106 #define qARM 0
107 #endif
108 
109 #ifndef qARMNeon
110 #define qARMNeon 0
111 #endif
112 
113 /*****************************************************************************/
114 
115 // Establish WIN32 and WIN64 definitions.
116 
117 #if defined(_WIN32) && !defined(WIN32)
118 #define WIN32 1
119 #endif
120 
121 #if defined(_WIN64) && !defined(WIN64)
122 #define WIN64 1
123 #endif
124 
125 /*****************************************************************************/
126 
127 /// \def qDNGDebug
128 /// 1 if debug code is compiled in, 0 otherwise. Enables assertions and other debug
129 /// checks in exchange for slower processing.
130 
131 // Figure out if debug build or not.
132 
133 #ifndef qDNGDebug
134 
135 #if defined(Debug)
136 #define qDNGDebug Debug
137 
138 #elif defined(_DEBUG)
139 #define qDNGDebug _DEBUG
140 
141 #else
142 #define qDNGDebug 0
143 
144 #endif
145 #endif
146 
147 /*****************************************************************************/
148 // Support Intel Thread Building Blocks (TBB)?
149 //
150 // This flag needs to be configured via the project, because there are sources
151 // outside the cr_sdk (such as the CTJPEG and ACE libs) that need to use the
152 // same flag to determine whether to use TBB or not.
153 //
154 // By default, configure to 0 (disabled).
155 
156 #ifndef qCRSupportTBB
157 #define qCRSupportTBB 0
158 #endif
159 
160 #if qCRSupportTBB
161 #ifndef TBB_DEPRECATED
162 #define TBB_DEPRECATED 0
163 #endif
164 #endif
165 
166 // This is not really a switch, but rather a shorthand for determining whether
167 // or not we're building a particular translation unit (source file) using the
168 // Intel Compiler.
169 
170 #ifndef qDNGIntelCompiler
171 #if defined(__INTEL_COMPILER)
172 #define qDNGIntelCompiler (__INTEL_COMPILER >= 1700)
173 #else
174 #define qDNGIntelCompiler 0
175 #endif
176 #endif
177 
178 /*****************************************************************************/
179 
180 // Figure out byte order.
181 
182 /// \def qDNGBigEndian
183 /// 1 if this target platform is big endian (e.g. PowerPC Macintosh), else 0.
184 ///
185 /// \def qDNGLittleEndian
186 /// 1 if this target platform is little endian (e.g. x86 processors), else 0.
187 
188 #ifndef qDNGBigEndian
189 
190 #if defined(qDNGLittleEndian)
191 #define qDNGBigEndian !qDNGLittleEndian
192 
193 #elif defined(__s390__) || defined(__s390x__)
194 #define qDNGBigEndian 1
195 
196 #elif defined(__POWERPC__)
197 #define qDNGBigEndian 1
198 
199 #elif defined(__INTEL__)
200 #define qDNGBigEndian 0
201 
202 #elif defined(_M_IX86)
203 #define qDNGBigEndian 0
204 
205 #elif defined(_M_X64) || defined(__amd64__)
206 #define qDNGBigEndian 0
207 
208 #elif defined(__LITTLE_ENDIAN__)
209 #define qDNGBigEndian 0
210 
211 #elif defined(__BIG_ENDIAN__)
212 #define qDNGBigEndian 1
213 
214 #elif defined(_ARM_)
215 #define qDNGBigEndian 0
216 
217 #else
218 
219 #ifndef qXCodeRez
220 #error Unable to figure out byte order.
221 #endif
222 
223 #endif
224 #endif
225 
226 #ifndef qXCodeRez
227 
228 #ifndef qDNGLittleEndian
229 #define qDNGLittleEndian !qDNGBigEndian
230 #endif
231 
232 #endif
233 
234 /*****************************************************************************/
235 
236 /// \def qDNG64Bit
237 /// 1 if this target platform uses 64-bit addresses, 0 otherwise.
238 
239 #ifndef qDNG64Bit
240 
241 #if qMacOS
242 
243 #ifdef __LP64__
244 #if    __LP64__
245 #define qDNG64Bit 1
246 #endif
247 #endif
248 
249 #elif qWinOS
250 
251 #ifdef WIN64
252 #if    WIN64
253 #define qDNG64Bit 1
254 #endif
255 #endif
256 
257 #elif qLinux
258 
259 #ifdef __LP64__
260 #if    __LP64__
261 #define qDNG64Bit 1
262 #endif
263 #endif
264 
265 #endif
266 
267 #ifndef qDNG64Bit
268 #define qDNG64Bit 0
269 #endif
270 
271 #endif
272 
273 /*****************************************************************************/
274 
275 /// \def qDNGThreadSafe
276 /// 1 if target platform has thread support and threadsafe libraries, 0 otherwise.
277 
278 #ifndef qDNGThreadSafe
279 #define qDNGThreadSafe (qMacOS || qWinOS)
280 #endif
281 
282 /*****************************************************************************/
283 
284 /// \def qDNGValidateTarget
285 /// 1 if dng_validate command line tool is being built, 0 otherwise.
286 
287 #ifndef qDNGValidateTarget
288 #define qDNGValidateTarget 0
289 #endif
290 
291 /*****************************************************************************/
292 
293 /// \def qDNGValidate
294 /// 1 if DNG validation code is enabled, 0 otherwise.
295 
296 #ifndef qDNGValidate
297 #define qDNGValidate qDNGValidateTarget
298 #endif
299 
300 /*****************************************************************************/
301 
302 /// \def qDNGPrintMessages
303 /// 1 if dng_show_message should use fprintf to stderr. 0 if it should use a platform
304 /// specific interrupt mechanism.
305 
306 #ifndef qDNGPrintMessages
307 #define qDNGPrintMessages qDNGValidate
308 #endif
309 
310 /*****************************************************************************/
311 
312 // Experimental features -- work in progress for Lightroom and Camera Raw
313 // major releases. Turn this off for Lightroom & Camera Raw dot releases.
314 
315 #ifndef qDNGExperimental
316 #define qDNGExperimental 1
317 #endif
318 
319 /*****************************************************************************/
320 
321 /// \def qDNGXMPFiles
322 /// 1 to use XMPFiles.
323 
324 #ifndef qDNGXMPFiles
325 #define qDNGXMPFiles 1
326 #endif
327 
328 /*****************************************************************************/
329 
330 /// \def qDNGXMPDocOps
331 /// 1 to use XMPDocOps.
332 
333 #ifndef qDNGXMPDocOps
334 #define qDNGXMPDocOps (!qDNGValidateTarget)
335 #endif
336 
337 /*****************************************************************************/
338 
339 /// \def qDNGUseLibJPEG
340 /// 1 to use open-source libjpeg for lossy jpeg processing.
341 
342 #ifndef qDNGUseLibJPEG
343 #define qDNGUseLibJPEG qDNGValidateTarget
344 #endif
345 
346 /*****************************************************************************/
347 
348 #ifndef qDNGAVXSupport
349 #define qDNGAVXSupport ((qMacOS || qWinOS) && qDNG64Bit && !qARM && 1)
350 #endif
351 
352 #if qDNGAVXSupport && !(qDNG64Bit && !qARM)
353 #error AVX support is enabled when 64-bit support is not or ARM is
354 #endif
355 
356 /*****************************************************************************/
357 
358 #ifndef qDNGSupportVC5
359 #define qDNGSupportVC5 (1)
360 #endif
361 
362 /*****************************************************************************/
363 
364 /// \def qDNGUsingSanitizer
365 /// Set to 1 when using a Sanitizer tool.
366 
367 #ifndef qDNGUsingSanitizer
368 #define qDNGUsingSanitizer (0)
369 #endif
370 
371 /*****************************************************************************/
372 
373 #ifndef DNG_ATTRIB_NO_SANITIZE
374 #if qDNGUsingSanitizer && defined(__clang__)
375 #define DNG_ATTRIB_NO_SANITIZE(type) __attribute__((no_sanitize(type)))
376 #else
377 #define DNG_ATTRIB_NO_SANITIZE(type)
378 #endif
379 #endif
380 
381 /*****************************************************************************/
382 
383 /// \def qDNGDepthSupport
384 /// 1 to add support for depth maps in DNG format.
385 /// Deprecated 2018-09-19.
386 
387 #ifdef __cplusplus
388 #define qDNGDepthSupport #error
389 #endif
390 
391 /*****************************************************************************/
392 
393 /// \def qDNGPreserveBlackPoint
394 /// 1 to add support for non-zero black point in early raw pipeline.
395 /// Deprecated 2018-09-19.
396 
397 #ifdef __cplusplus
398 #define qDNGPreserveBlackPoint #error
399 #endif
400 
401 /*****************************************************************************/
402 
403 #endif
404 
405 /*****************************************************************************/
406