Openholo  v2.1
Open Source Digital Holographic Library
tmwtypes.h
Go to the documentation of this file.
1 /*
2  * Copyright 1984-2018 The MathWorks, Inc.
3  */
4 
5 #if defined(_MSC_VER)
6 # pragma once
7 #endif
8 #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3))
9 # pragma once
10 #endif
11 
12 #ifndef tmwtypes_h
13 #define tmwtypes_h
14 
15 #ifndef __TMWTYPES__
16 #define __TMWTYPES__
17 /*
18  * File : tmwtypes.h
19  * Abstract:
20  * Data types for use with MATLAB/SIMULINK and the Real-Time Workshop.
21  *
22  * When compiling stand-alone model code, data types can be overridden
23  * via compiler switches.
24  *
25  * Define NO_FLOATS to eliminate reference to real_T, etc.
26  */
27 
28 #ifdef MW_LIBTOOLING
29 #include "mwstdint.h"
30 #endif
31 
32 #include <limits.h>
33 
34 /* __STDC_VERSION__ version check below means "check for a C99 compiler".
35 
36  Visual Studio (checked on versions 2015 and 2017) does
37  not define __STDC_VERSION__, however it has stdbool.h available,
38  thus a separate check for _MSC_VER below.
39  */
40 #if defined(__APPLE_CC__) \
41  || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) \
42  || (defined(_MSC_VER) && (_MSC_VER >= 1900))
43 #ifndef tmwtypes_do_not_include_stdbool
44 #include <stdbool.h>
45 #endif
46 #endif
47 
48 #define LOGICAL_IS_A_TYPE
49 #define SPARSE_GENERALIZATION
50 
51 #ifdef NO_FLOATS
52 # define double double_not_allowed
53 # define float float_not_allowed
54 #endif /*NO_FLOATS*/
55 
56 #ifndef NO_FLOATS
57 
58 #ifndef __MWERKS__
59 # ifdef __STDC__
60 # include <float.h>
61 # else
62 # ifndef FLT_MANT_DIG
63 # define FLT_MANT_DIG 24
64 # endif
65 # ifndef DBL_MANT_DIG
66 # define DBL_MANT_DIG 53
67 # endif
68 # endif
69 #endif
70 
71 #endif /*NO_FLOATS*/
72 
73 /*
74  * The following data types cannot be overridden when building MEX files.
75  */
76 #ifdef MATLAB_MEX_FILE
77 # undef CHARACTER_T
78 # undef INTEGER_T
79 # undef BOOLEAN_T
80 # undef REAL_T
81 # undef TIME_T
82 #endif
83 
84 /*
85  * The uchar_T, ushort_T and ulong_T types are needed for compilers which do
86  * not allow defines to be specified, at the command line, with spaces in them.
87  */
88 
89 typedef unsigned char uchar_T;
90 typedef unsigned short ushort_T;
91 typedef unsigned long ulong_T;
92 
93 #if (defined(_MSC_VER) && _MSC_VER >= 1500) \
94  || defined(__x86_64__) || defined(__LP64__) \
95  || defined(__LCC64__)
96 
97 typedef unsigned long long ulonglong_T;
98 #endif
99 
100 
101 
102 /*=======================================================================*
103  * Fixed width word size data types: *
104  * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
105  * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
106  * real32_T, real64_T - 32 and 64 bit floating point numbers *
107  *=======================================================================*/
108 
109 /* When used with Real Time Workshop generated code, this
110  * header file can be used with a variety of compilers.
111  *
112  * The compiler could be for an 8 bit embedded processor that
113  * only had 8 bits per integer and 16 bits per long.
114  * In that example, a 32 bit integer size is not even available.
115  * This header file should be robust to that.
116  *
117  * For the case of an 8 bit processor, the preprocessor
118  * may be limited to 16 bit math like its target. That limitation
119  * would mean that 32 bit comparisons can't be done accurately.
120  * To increase robustness to this, comparisons are done against
121  * smaller values first. An inaccurate 32 bit comparison isn't
122  * attempted if the 16 bit comparison has already succeeded.
123  *
124  * Limitations on preprocessor math can also be stricter than
125  * for the target. There are known cases where a compiler
126  * targeting processors with 64 bit longs can't do accurate
127  * preprocessor comparisons on more than 32 bits.
128  */
129 
130 /* Determine the number of bits for int, long, short, and char.
131  * If one fails to be determined, set the number of bits to -1
132  */
133 
134 #ifndef TMW_BITS_PER_INT
135 # if INT_MAX == 0x7FL
136 # define TMW_BITS_PER_INT 8
137 # elif INT_MAX == 0x7FFFL
138 # define TMW_BITS_PER_INT 16
139 # elif INT_MAX == 0x7FFFFFFFL
140 # define TMW_BITS_PER_INT 32
141 # else
142 # define TMW_BITS_PER_INT -1
143 # endif
144 #endif
145 
146 #ifndef TMW_BITS_PER_LONG
147 # if LONG_MAX == 0x7FL
148 # define TMW_BITS_PER_LONG 8
149 # elif LONG_MAX == 0x7FFFL
150 # define TMW_BITS_PER_LONG 16
151 # elif LONG_MAX == 0x7FFFFFFFL
152 # define TMW_BITS_PER_LONG 32
153 # else
154 # define TMW_BITS_PER_LONG -1
155 # endif
156 #endif
157 
158 #ifndef TMW_BITS_PER_SHRT
159 # if SHRT_MAX == 0x7FL
160 # define TMW_BITS_PER_SHRT 8
161 # elif SHRT_MAX == 0x7FFFL
162 # define TMW_BITS_PER_SHRT 16
163 # elif SHRT_MAX == 0x7FFFFFFFL
164 # define TMW_BITS_PER_SHRT 32
165 # else
166 # define TMW_BITS_PER_SHRT -1
167 # endif
168 #endif
169 
170 #ifndef TMW_BITS_PER_SCHAR
171 # if SCHAR_MAX == 0x7FL
172 # define TMW_BITS_PER_SCHAR 8
173 # elif SCHAR_MAX == 0x7FFFL
174 # define TMW_BITS_PER_SCHAR 16
175 # elif SCHAR_MAX == 0x7FFFFFFFL
176 # define TMW_BITS_PER_SCHAR 32
177 # else
178 # define TMW_BITS_PER_SCHAR -1
179 # endif
180 #endif
181 
182 #ifndef TMW_CHAR_SIGNED
183 # if SCHAR_MAX == CHAR_MAX
184 # define TMW_CHAR_SIGNED 1
185 # else
186 # define TMW_CHAR_SIGNED 0
187 # endif
188 #endif
189 
190 /* It is common for one or more of the integer types
191  * to be the same size. For example, on many embedded
192  * processors, both shorts and ints are 16 bits. On
193  * processors used for workstations, it is quite common
194  * for both int and long to be 32 bits.
195  * When there is more than one choice for typdef'ing
196  * a portable type like int16_T or uint32_T, in
197  * concept, it should not matter which choice is made.
198  * However, some style guides and some code checking
199  * tools do identify and complain about seemingly
200  * irrelevant differences. For example, a code
201  * checking tool may complain about an implicit
202  * conversion from int to short even though both
203  * are 16 bits. To reduce these types of
204  * complaints, it is best to make int the
205  * preferred choice when more than one is available.
206  */
207 
208 #ifndef INT8_T
209 # if defined(MW_LIBTOOLING)
210 # define INT8_T int8_t
211 # elif TMW_BITS_PER_INT == 8
212 # define INT8_T int
213 # elif TMW_BITS_PER_LONG == 8
214 # define INT8_T long
215 # elif TMW_BITS_PER_SCHAR == 8
216 # define INT8_T signed char
217 # elif TMW_BITS_PER_SHRT == 8
218 # define INT8_T short
219 # endif
220 #endif
221 #ifdef INT8_T
222  typedef INT8_T int8_T;
223 #endif
224 
225 #ifndef UINT8_T
226 # if defined(MW_LIBTOOLING)
227 # define UINT8_T uint8_t
228 # elif TMW_BITS_PER_INT == 8
229 # define UINT8_T unsigned int
230 # elif TMW_BITS_PER_LONG == 8
231 # define UINT8_T unsigned long
232 # elif TMW_BITS_PER_SCHAR == 8
233 # define UINT8_T unsigned char
234 # elif TMW_BITS_PER_SHRT == 8
235 # define UINT8_T unsigned short
236 # endif
237 #endif
238 #ifdef UINT8_T
239  typedef UINT8_T uint8_T;
240 #endif
241 
242 
243 #ifndef INT16_T
244 # if defined(MW_LIBTOOLING)
245 # define INT16_T int16_t
246 # elif TMW_BITS_PER_INT == 16
247 # define INT16_T int
248 # elif TMW_BITS_PER_LONG == 16
249 # define INT16_T long
250 # elif TMW_BITS_PER_SCHAR == 16
251 # define INT16_T signed char
252 # elif TMW_BITS_PER_SHRT == 16
253 # define INT16_T short
254 # endif
255 #endif
256 #ifdef INT16_T
257  typedef INT16_T int16_T;
258 #endif
259 
260 
261 #ifndef UINT16_T
262 # if defined(MW_LIBTOOLING)
263 # define UINT16_T uint16_t
264 # elif TMW_BITS_PER_INT == 16
265 # define UINT16_T unsigned int
266 # elif TMW_BITS_PER_LONG == 16
267 # define UINT16_T unsigned long
268 # elif TMW_BITS_PER_SCHAR == 16
269 # define UINT16_T unsigned char
270 # elif TMW_BITS_PER_SHRT == 16
271 # define UINT16_T unsigned short
272 # endif
273 #endif
274 #ifdef UINT16_T
275  typedef UINT16_T uint16_T;
276 #endif
277 
278 
279 #ifndef INT32_T
280 # if defined(MW_LIBTOOLING)
281 # define INT32_T int32_t
282 # elif TMW_BITS_PER_INT == 32
283 # define INT32_T int
284 # elif TMW_BITS_PER_LONG == 32
285 # define INT32_T long
286 # elif TMW_BITS_PER_SCHAR == 32
287 # define INT32_T signed char
288 # elif TMW_BITS_PER_SHRT == 32
289 # define INT32_T short
290 # endif
291 #endif
292 #ifdef INT32_T
293  typedef INT32_T int32_T;
294 #endif
295 
296 
297 #ifndef UINT32_T
298 # if defined(MW_LIBTOOLING)
299 # define UINT32_T uint32_t
300 # elif TMW_BITS_PER_INT == 32
301 # define UINT32_T unsigned int
302 # elif TMW_BITS_PER_LONG == 32
303 # define UINT32_T unsigned long
304 # elif TMW_BITS_PER_SCHAR == 32
305 # define UINT32_T unsigned char
306 # elif TMW_BITS_PER_SHRT == 32
307 # define UINT32_T unsigned short
308 # endif
309 #endif
310 #ifdef UINT32_T
311  typedef UINT32_T uint32_T;
312 #endif
313 
314 /* The following is used to emulate smaller integer types when only
315  * larger types are available. For example, compilers for TI C3x/C4x DSPs
316  * define char and short to be 32 bits, so 8 and 16 bits are not directly
317  * available. This target is commonly used with RTW rapid prototyping.
318  * Other DSPs define char to be 16 bits, so 8 bits is not directly
319  * available.
320  */
321 #ifndef INT8_T
322 # ifdef INT16_T
323 # define INT8_T INT16_T
324  typedef INT8_T int8_T;
325 # else
326 # ifdef INT32_T
327 # define INT8_T INT32_T
328  typedef INT8_T int8_T;
329 # endif
330 # endif
331 #endif
332 
333 #ifndef UINT8_T
334 # ifdef UINT16_T
335 # define UINT8_T UINT16_T
336  typedef UINT8_T uint8_T;
337 # else
338 # ifdef UINT32_T
339 # define UINT8_T UINT32_T
340  typedef UINT8_T uint8_T;
341 # endif
342 # endif
343 #endif
344 
345 #ifndef INT16_T
346 # ifdef INT32_T
347 # define INT16_T INT32_T
348  typedef INT16_T int16_T;
349 # endif
350 #endif
351 
352 #ifndef UINT16_T
353 # ifdef UINT32_T
354 # define UINT16_T UINT32_T
355  typedef UINT16_T uint16_T;
356 # endif
357 #endif
358 
359 
360 #ifndef NO_FLOATS
361 
362 #ifndef REAL32_T
363 # ifndef __MWERKS__
364 # if FLT_MANT_DIG >= 23
365 # define REAL32_T float
366 # endif
367 # else
368 # define REAL32_T float
369 # endif
370 #endif
371 #ifdef REAL32_T
373 #endif
374 
375 
376 #ifndef REAL64_T
377 # ifndef __MWERKS__
378 # if DBL_MANT_DIG >= 52
379 # define REAL64_T double
380 # endif
381 # else
382 # define REAL64_T double
383 # endif
384 #endif
385 #ifdef REAL64_T
387 #endif
388 
389 #endif /* NO_FLOATS*/
390 
391 /*=======================================================================*
392  * Fixed width word size data types: *
393  * int64_T - signed 64 bit integers *
394  * uint64_T - unsigned 64 bit integers *
395  *=======================================================================*/
396 
397 # if defined(MW_LIBTOOLING)
398 # ifdef INT64_T
399 # undef INT64_T
400 # endif
401 # define INT64_T int64_t
402 # ifdef UINT64_T
403 # undef UINT64_T
404 # endif
405 # define UINT64_T uint64_t
406 # endif
407 #if !defined(INT64_T) || !defined(UINT64_T) || !defined(FMT64)
408 # if defined(__APPLE__) || defined(__clang__)
409 # ifndef INT64_T
410 # define INT64_T long long
411 # endif
412 # ifndef UINT64_T
413 # define UINT64_T unsigned long long
414 # endif
415 # ifndef FMT64
416 # define FMT64 "ll"
417 # endif
418 # if defined(__LP64__) && !defined(INT_TYPE_64_IS_LONG)
419 # define INT_TYPE_64_IS_LONG
420 # endif
421 # elif (defined(__x86_64__) || defined(__LP64__))&& !defined(__MINGW64__)
422 # ifndef INT64_T
423 # define INT64_T long
424 # endif
425 # ifndef UINT64_T
426 # define UINT64_T unsigned long
427 # endif
428 # ifndef FMT64
429 # define FMT64 "l"
430 # endif
431 # if !defined(INT_TYPE_64_IS_LONG)
432 # define INT_TYPE_64_IS_LONG
433 # endif
434 # elif defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \
435  || (defined(__WATCOMC__) && __WATCOMC__ >= 1100)
436 # ifndef INT64_T
437 # define INT64_T __int64
438 # endif
439 # ifndef UINT64_T
440 # define UINT64_T unsigned __int64
441 # endif
442 # ifndef FMT64
443 # define FMT64 "I64"
444 # endif
445 # elif defined(__GNUC__) || defined(TMW_ENABLE_INT64) \
446  || defined(__LCC64__)
447 # ifndef INT64_T
448 # define INT64_T long long
449 # endif
450 # ifndef UINT64_T
451 # define UINT64_T unsigned long long
452 # endif
453 # ifndef FMT64
454 # define FMT64 "ll"
455 # endif
456 # endif
457 
458 #endif
459 
460 #if defined(INT64_T)
461 # if defined(__GNUC__) && \
462  ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9)))
463  __extension__
464 # endif
465  typedef INT64_T int64_T;
466 #endif
467 
468 #if defined(_WIN64) || (defined(__APPLE__) && defined(__LP64__)) \
469  || defined(__x86_64__) \
470  || defined(__LP64__)
471 # define INT_TYPE_64_IS_SUPPORTED
472 #endif
473 
474 #if defined(UINT64_T)
475 # if defined(__GNUC__) && \
476  ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9)))
477  __extension__
478 # endif
479  typedef UINT64_T uint64_T;
480 #endif
481 
482 /*===========================================================================*
483  * Format string modifiers for using size_t variables in printf statements. *
484  *===========================================================================*/
485 
486 #ifndef FMT_SIZE_T
487 # if (defined( __GNUC__ ) || defined(_STDC_C99))&& !defined(__MINGW64__)
488 # define FMT_SIZE_T "z"
489 # elif defined (__WATCOMC__)
490 # define FMT_SIZE_T "l"
491 # elif defined (_WIN32 )
492 # define FMT_SIZE_T "I"
493 # else
494 # define FMT_SIZE_T "l"
495 # endif
496 #endif
497 
498 #ifndef FMT_PTRDIFF_T
499 # if defined(__APPLE__)
500 # define FMT_PTRDIFF_T "l"
501 # elif defined( __GNUC__ ) || defined(_STDC_C99)
502 # define FMT_PTRDIFF_T "t"
503 # elif defined (__WATCOMC__)
504 # define FMT_PTRDIFF_T "l"
505 # elif defined (_WIN32 )
506 # define FMT_PTRDIFF_T "I"
507 # else
508 # define FMT_PTRDIFF_T "l"
509 # endif
510 #endif
511 
512 /*===========================================================================*
513  * General or logical data types where the word size is not guaranteed. *
514  * real_T - possible settings include real32_T or real64_T *
515  * time_T - possible settings include real32_T or real64_T *
516  * boolean_T *
517  * char_T *
518  * int_T *
519  * uint_T *
520  * byte_T *
521  *===========================================================================*/
522 
523 #ifndef NO_FLOATS
524 
525 #ifndef REAL_T
526 # ifdef REAL64_T
527 # define REAL_T real64_T
528 # else
529 # ifdef REAL32_T
530 # define REAL_T real32_T
531 # endif
532 # endif
533 #endif
534 #ifdef REAL_T
535  typedef REAL_T real_T;
536 #endif
537 
538 #ifndef TIME_T
539 # ifdef REAL_T
540 # define TIME_T real_T
541 # endif
542 #endif
543 #ifdef TIME_T
544  typedef TIME_T time_T;
545 #endif
546 
547 #endif /* NO_FLOATS */
548 
549 #ifndef BOOLEAN_T
550 # if defined(UINT8_T)
551 # define BOOLEAN_T UINT8_T
552 # else
553 # define BOOLEAN_T unsigned int
554 # endif
555 #endif
557 
558 
559 #ifndef CHARACTER_T
560 # define CHARACTER_T char
561 #endif
563 
564 
565 #ifndef INTEGER_T
566 # define INTEGER_T int
567 #endif
568 typedef INTEGER_T int_T;
569 
570 
571 #ifndef UINTEGER_T
572 # define UINTEGER_T unsigned
573 #endif
575 
576 
577 #ifndef BYTE_T
578 # define BYTE_T unsigned char
579 #endif
580 typedef BYTE_T byte_T;
581 
582 
583 /*===========================================================================*
584  * Define Complex Structures *
585  *===========================================================================*/
586 #ifndef NO_FLOATS
587 
588 #ifndef CREAL32_T
589 # ifdef REAL32_T
590  typedef struct {
592  } creal32_T;
593 # define CREAL32_T creal32_T
594 # endif
595 #endif
596 
597 #ifndef CREAL64_T
598 # ifdef REAL64_T
599  typedef struct {
601  } creal64_T;
602 # define CREAL64_T creal64_T
603 # endif
604 #endif
605 
606 #ifndef CREAL_T
607 # ifdef REAL_T
608  typedef struct {
609  real_T re, im;
610  } creal_T;
611 # define CREAL_T creal_T
612 # endif
613 #endif
614 
615 #endif /* NO_FLOATS */
616 
617 #ifndef CINT8_T
618 # ifdef INT8_T
619  typedef struct {
620  int8_T re, im;
621  } cint8_T;
622 # define CINT8_T cint8_T
623 # endif
624 #endif
625 
626 #ifndef CUINT8_T
627 # ifdef UINT8_T
628  typedef struct {
629  uint8_T re, im;
630  } cuint8_T;
631 # define CUINT8_T cuint8_T
632 # endif
633 #endif
634 
635 #ifndef CINT16_T
636 # ifdef INT16_T
637  typedef struct {
638  int16_T re, im;
639  } cint16_T;
640 # define CINT16_T cint16_T
641 # endif
642 #endif
643 
644 #ifndef CUINT16_T
645 # ifdef UINT16_T
646  typedef struct {
647  uint16_T re, im;
648  } cuint16_T;
649 # define CUINT16_T cuint16_T
650 # endif
651 #endif
652 
653 #ifndef CINT32_T
654 # ifdef INT32_T
655  typedef struct {
656  int32_T re, im;
657  } cint32_T;
658 # define CINT32_T cint32_T
659 # endif
660 #endif
661 
662 #ifndef CUINT32_T
663 # ifdef UINT32_T
664  typedef struct {
665  uint32_T re, im;
666  } cuint32_T;
667 # define CUINT32_T cuint32_T
668 # endif
669 #endif
670 
671 #ifndef CINT64_T
672 # ifdef INT64_T
673  typedef struct {
674  int64_T re, im;
675  } cint64_T;
676 # define CINT64_T cint64_T
677 # endif
678 #endif
679 
680 #ifndef CUINT64_T
681 # ifdef UINT64_T
682  typedef struct {
683  uint64_T re, im;
684  } cuint64_T;
685 # define CUINT64_T cuint64_T
686 # endif
687 #endif
688 
689 /*=======================================================================*
690  * Min and Max: *
691  * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
692  * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
693  *=======================================================================*/
694 
695 #define MAX_int8_T ((int8_T)(127)) /* 127 */
696 #define MIN_int8_T ((int8_T)(-128)) /* -128 */
697 #define MAX_uint8_T ((uint8_T)(255)) /* 255 */
698 #define MIN_uint8_T ((uint8_T)(0))
699 
700 #define MAX_int16_T ((int16_T)(32767)) /* 32767 */
701 #define MIN_int16_T ((int16_T)(-32768)) /* -32768 */
702 #define MAX_uint16_T ((uint16_T)(65535)) /* 65535 */
703 #define MIN_uint16_T ((uint16_T)(0))
704 
705 #define MAX_int32_T ((int32_T)(2147483647)) /* 2147483647 */
706 #define MIN_int32_T ((int32_T)(-2147483647-1)) /* -2147483648 */
707 #define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU)) /* 4294967295 */
708 #define MIN_uint32_T ((uint32_T)(0))
709 
710 #if defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \
711  || (defined(__WATCOMC__) && __WATCOMC__ >= 1100) \
712  || defined(__LCC64__)
713 # ifdef INT64_T
714 # define MAX_int64_T ((int64_T)(9223372036854775807LL))
715 # define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL))
716 # endif
717 # ifdef UINT64_T
718 # define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL))
719 # define MIN_uint64_T ((uint64_T)(0))
720 # endif
721 #else
722 # ifdef INT64_T
723 # ifdef INT_TYPE_64_IS_LONG
724 # define MAX_int64_T ((int64_T)(9223372036854775807L))
725 # define MIN_int64_T ((int64_T)(-9223372036854775807L-1L))
726 # else
727 # define MAX_int64_T ((int64_T)(9223372036854775807LL))
728 # define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL))
729 # endif
730 # endif
731 # ifdef UINT64_T
732 # ifdef INT_TYPE_64_IS_LONG
733 # define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFUL))
734 # define MIN_uint64_T ((uint64_T)(0))
735 # else
736 # define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFULL))
737 # define MIN_uint64_T ((uint64_T)(0))
738 # endif
739 # endif
740 #endif
741 
742 #if (defined(_MSC_VER) && !defined(__clang__))
743 
744 /* Conversion from unsigned __int64 to double is not implemented in Visual Studio
745  * and results in a compile error, thus the value must first be cast to
746  * signed __int64, and then to double.
747  *
748  * If the 64 bit int value is greater than 2^63-1, which is the signed int64 max,
749  * the macro below provides a workaround for casting a uint64 value to a double
750  * in windows.
751  */
752 # define uint64_to_double(u) ( ((u) > _I64_MAX) ? \
753  (double)(__int64)((u) - _I64_MAX - 1) + (double)_I64_MAX + 1: \
754  (double)(__int64)(u) )
755 
756 /* The following inline function should only be used in the macro double_to_uint64,
757  * as it only handles the specfic range of double between 2^63 and 2^64-1 */
758 __forceinline
759 uint64_T double_to_uint64_helper(double d) {
760  union double_to_uint64_union_type {
761  double dd;
762  uint64_T i64;
763  } di;
764  di.dd = d;
765  return (((di.i64 & 0x000fffffffffffff) | 0x0010000000000000) << 11);
766 }
767 
768 /* The largest double value that can be cast to uint64 in windows is the
769  * signed int64 max, which is 2^63-1. The macro below provides
770  * a workaround for casting large double values to uint64 in windows.
771  */
772 /* The magic number 18446744073709551616.0 is 2^64 */
773 /* The magic number 9223372036854775808.0 is 2^63 */
774 # define double_to_uint64(d) ( ((d) >= 18446744073709551616.0) ? \
775  0xffffffffffffffffULL : \
776  ((d) >= 0.0) ? \
777  ((d) >= 9223372036854775808.0) ? \
778  double_to_uint64_helper(d) : \
779  (unsigned __int64)(d) : \
780  0ULL )
781 #else
782 # define uint64_to_double(u) ((double)(u))
783 # if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__TICCSC__)
784 /* double_to_uint64 defined only for MSVC and UNIX */
785 # else
786 # define double_to_uint64(d) ( ((d) >= 18446744073709551616.0) ? \
787  (unsigned long long) 0xffffffffffffffffULL : \
788  ((d) >= 0) ? (unsigned long long)(d) : (unsigned long long) 0 )
789 # endif
790 #endif
791 
792 #if !defined(__cplusplus) && !defined(__bool_true_false_are_defined)
793 
794 #ifndef _bool_T
795 #define _bool_T
796 
797 typedef boolean_T bool;
798 
799 #ifndef false
800 #define false (0)
801 #endif
802 #ifndef true
803 #define true (1)
804 #endif
805 
806 #endif /* _bool_T */
807 
808 #endif /* !__cplusplus */
809 
810 /*
811  * This software assumes that the code is being compiled on a target using a
812  * 2's complement representation for signed integer values.
813  */
814 #if ((SCHAR_MIN + 1) != -SCHAR_MAX)
815 #error "This code must be compiled using a 2's complement representation for signed integer values"
816 #endif
817 
818 /*
819  * Maximum length of a MATLAB identifier (function/variable/model)
820  * including the null-termination character.
821  */
822 #define TMW_NAME_LENGTH_MAX 64
823 
824 /*
825  * Maximum values for indices and dimensions
826  */
827 #include <stddef.h>
828 
829 #ifdef MX_COMPAT_32
830 typedef int mwSize;
831 typedef int mwIndex;
832 typedef int mwSignedIndex;
833 #else
834 typedef size_t mwSize; /* unsigned pointer-width integer */
835 typedef size_t mwIndex; /* unsigned pointer-width integer */
836 typedef ptrdiff_t mwSignedIndex; /* a signed pointer-width integer */
837 #endif
838 
839  /* for the individual dim */
840 #ifndef SLSIZE_SLINDEX
841  #define SLSIZE_SLINDEX
842  #ifdef INT_TYPE_64_IS_SUPPORTED
843  typedef int64_T SLIndex;
844  typedef int64_T SLSize;
845  #else
846  typedef int SLIndex;
847  typedef int SLSize;
848  #endif
849 #endif
850 
851 /* for the total size */
852 #define SLIndexType size_t
853 #define INVALID_SIZET_VALUE (std::numeric_limits<SLIndexType>::max())
854 #define MAX_VALID_SIZET_VALUE (std::numeric_limits<SLIndexType>::max() -1)
855 
856 
857 #if (defined(_LP64) || defined(_WIN64)) && !defined(MX_COMPAT_32)
858 /* Currently 2^48 based on hardware limitations */
859 # define MWSIZE_MAX 281474976710655UL
860 # define MWINDEX_MAX 281474976710655UL
861 # define MWSINDEX_MAX 281474976710655L
862 # define MWSINDEX_MIN -281474976710655L
863 #else
864 # define MWSIZE_MAX 2147483647UL
865 # define MWINDEX_MAX 2147483647UL
866 # define MWSINDEX_MAX 2147483647L
867 # define MWSINDEX_MIN -2147483647L
868 #endif
869 #define MWSIZE_MIN 0UL
870 #define MWINDEX_MIN 0UL
871 
874 #if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT)
875 typedef char16_t CHAR16_T;
876 #define U16_STRING_LITERAL_PREFIX u
877 #elif defined(_MSC_VER)
878 typedef wchar_t CHAR16_T;
879 #define U16_STRING_LITERAL_PREFIX L
880 #else
881 typedef UINT16_T CHAR16_T;
882 #endif
883 
884 #endif /* __TMWTYPES__ */
885 
886 #endif /* tmwtypes_h */
REAL32_T real32_T
Definition: tmwtypes.h:372
unsigned short ushort_T
Definition: tmwtypes.h:90
#define REAL_T
Definition: tmwtypes.h:527
INTEGER_T int_T
Definition: tmwtypes.h:568
size_t mwIndex
Definition: tmwtypes.h:835
ptrdiff_t mwSignedIndex
Definition: tmwtypes.h:836
#define REAL64_T
Definition: tmwtypes.h:379
#define UINTEGER_T
Definition: tmwtypes.h:572
BOOLEAN_T boolean_T
Definition: tmwtypes.h:556
UINTEGER_T uint_T
Definition: tmwtypes.h:574
BYTE_T byte_T
Definition: tmwtypes.h:580
unsigned char uchar_T
Definition: tmwtypes.h:89
boolean_T bool
Definition: tmwtypes.h:797
REAL_T real_T
Definition: tmwtypes.h:535
REAL64_T real64_T
Definition: tmwtypes.h:386
int SLIndex
Definition: tmwtypes.h:846
real_T re
Definition: tmwtypes.h:609
CHARACTER_T char_T
Definition: tmwtypes.h:562
#define INTEGER_T
Definition: tmwtypes.h:566
#define CHARACTER_T
Definition: tmwtypes.h:560
UINT16_T CHAR16_T
Definition: tmwtypes.h:881
int SLSize
Definition: tmwtypes.h:847
real32_T re
Definition: tmwtypes.h:591
size_t mwSize
Definition: tmwtypes.h:834
#define TIME_T
Definition: tmwtypes.h:540
#define BYTE_T
Definition: tmwtypes.h:578
#define REAL32_T
Definition: tmwtypes.h:365
TIME_T time_T
Definition: tmwtypes.h:544
#define BOOLEAN_T
Definition: tmwtypes.h:553
real64_T re
Definition: tmwtypes.h:600
unsigned long ulong_T
Definition: tmwtypes.h:91