00001
00002
00003
00004
00005
00006
00007
00008 #if defined(_MSC_VER) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)
00009 #pragma once
00010 #endif
00011
00012 #ifndef tmwtypes_h
00013 #define tmwtypes_h
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef __TMWTYPES__
00026 #define __TMWTYPES__
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040 #include <limits.h>
00041
00042 #ifdef __APPLE_CC__
00043 #include <stdbool.h>
00044 #endif
00045
00046 #define LOGICAL_IS_A_TYPE
00047 #define SPARSE_GENERALIZATION
00048
00049 #ifdef NO_FLOATS
00050 # define double double_not_allowed
00051 # define float float_not_allowed
00052 #endif
00053
00054 #ifndef NO_FLOATS
00055
00056 #ifndef __MWERKS__
00057 # ifdef __STDC__
00058 # include <float.h>
00059 # else
00060 # define FLT_MANT_DIG 24
00061 # define DBL_MANT_DIG 53
00062 # endif
00063 #endif
00064
00065 #endif
00066
00067
00068
00069
00070 #ifdef MATLAB_MEX_FILE
00071 # undef CHARACTER_T
00072 # undef INTEGER_T
00073 # undef BOOLEAN_T
00074 # undef REAL_T
00075 # undef TIME_T
00076 #endif
00077
00078
00079
00080
00081
00082
00083 typedef unsigned char uchar_T;
00084 typedef unsigned short ushort_T;
00085 typedef unsigned long ulong_T;
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 #ifndef TMW_BITS_PER_INT
00122 # if INT_MAX == 0x7FL
00123 # define TMW_BITS_PER_INT 8
00124 # elif INT_MAX == 0x7FFFL
00125 # define TMW_BITS_PER_INT 16
00126 # elif INT_MAX == 0x7FFFFFFFL
00127 # define TMW_BITS_PER_INT 32
00128 # else
00129 # define TMW_BITS_PER_INT -1
00130 # endif
00131 #endif
00132
00133 #ifndef TMW_BITS_PER_LONG
00134 # if LONG_MAX == 0x7FL
00135 # define TMW_BITS_PER_LONG 8
00136 # elif LONG_MAX == 0x7FFFL
00137 # define TMW_BITS_PER_LONG 16
00138 # elif LONG_MAX == 0x7FFFFFFFL
00139 # define TMW_BITS_PER_LONG 32
00140 # else
00141 # define TMW_BITS_PER_LONG -1
00142 # endif
00143 #endif
00144
00145 #ifndef TMW_BITS_PER_SHRT
00146 # if SHRT_MAX == 0x7FL
00147 # define TMW_BITS_PER_SHRT 8
00148 # elif SHRT_MAX == 0x7FFFL
00149 # define TMW_BITS_PER_SHRT 16
00150 # elif SHRT_MAX == 0x7FFFFFFFL
00151 # define TMW_BITS_PER_SHRT 32
00152 # else
00153 # define TMW_BITS_PER_SHRT -1
00154 # endif
00155 #endif
00156
00157 #ifndef TMW_BITS_PER_SCHAR
00158 # if SCHAR_MAX == 0x7FL
00159 # define TMW_BITS_PER_SCHAR 8
00160 # elif SCHAR_MAX == 0x7FFFL
00161 # define TMW_BITS_PER_SCHAR 16
00162 # elif SCHAR_MAX == 0x7FFFFFFFL
00163 # define TMW_BITS_PER_SCHAR 32
00164 # else
00165 # define TMW_BITS_PER_SCHAR -1
00166 # endif
00167 #endif
00168
00169 #ifndef TMW_CHAR_SIGNED
00170 # if SCHAR_MAX == CHAR_MAX
00171 # define TMW_CHAR_SIGNED 1
00172 # else
00173 # define TMW_CHAR_SIGNED 0
00174 # endif
00175 #endif
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195 #ifndef INT8_T
00196 # if TMW_BITS_PER_INT == 8
00197 # define INT8_T int
00198 # elif TMW_BITS_PER_LONG == 8
00199 # define INT8_T long
00200 # elif TMW_BITS_PER_SCHAR == 8
00201 # if TMW_CHAR_SIGNED
00202 # define INT8_T char
00203 # else
00204 # define INT8_T signed char
00205 # endif
00206 # elif TMW_BITS_PER_SHRT == 8
00207 # define INT8_T short
00208 # endif
00209 #endif
00210 #ifdef INT8_T
00211 typedef INT8_T int8_T;
00212 #endif
00213
00214 #ifndef UINT8_T
00215 # if TMW_BITS_PER_INT == 8
00216 # define UINT8_T unsigned int
00217 # elif TMW_BITS_PER_LONG == 8
00218 # define UINT8_T unsigned long
00219 # elif TMW_BITS_PER_SCHAR == 8
00220 # if TMW_CHAR_SIGNED
00221 # define UINT8_T unsigned char
00222 # else
00223 # define UINT8_T char
00224 # endif
00225 # elif TMW_BITS_PER_SHRT == 8
00226 # define UINT8_T unsigned short
00227 # endif
00228 #endif
00229 #ifdef UINT8_T
00230 typedef UINT8_T uint8_T;
00231 #endif
00232
00233
00234 #ifndef INT16_T
00235 # if TMW_BITS_PER_INT == 16
00236 # define INT16_T int
00237 # elif TMW_BITS_PER_LONG == 16
00238 # define INT16_T long
00239 # elif TMW_BITS_PER_SCHAR == 16
00240 # if TMW_CHAR_SIGNED
00241 # define INT16_T char
00242 # else
00243 # define INT16_T signed char
00244 # endif
00245 # elif TMW_BITS_PER_SHRT == 16
00246 # define INT16_T short
00247 # endif
00248 #endif
00249 #ifdef INT16_T
00250 typedef INT16_T int16_T;
00251 #endif
00252
00253
00254 #ifndef UINT16_T
00255 # if TMW_BITS_PER_INT == 16
00256 # define UINT16_T unsigned int
00257 # elif TMW_BITS_PER_LONG == 16
00258 # define UINT16_T unsigned long
00259 # elif TMW_BITS_PER_SCHAR == 16
00260 # if TMW_CHAR_SIGNED
00261 # define UINT16_T unsigned char
00262 # else
00263 # define UINT16_T char
00264 # endif
00265 # elif TMW_BITS_PER_SHRT == 16
00266 # define UINT16_T unsigned short
00267 # endif
00268 #endif
00269 #ifdef UINT16_T
00270 typedef UINT16_T uint16_T;
00271 #endif
00272
00273
00274 #ifndef INT32_T
00275 # if TMW_BITS_PER_INT == 32
00276 # define INT32_T int
00277 # elif TMW_BITS_PER_LONG == 32
00278 # define INT32_T long
00279 # elif TMW_BITS_PER_SCHAR == 32
00280 # if TMW_CHAR_SIGNED
00281 # define INT32_T char
00282 # else
00283 # define INT32_T signed char
00284 # endif
00285 # elif TMW_BITS_PER_SHRT == 32
00286 # define INT32_T short
00287 # endif
00288 #endif
00289 #ifdef INT32_T
00290 typedef INT32_T int32_T;
00291 #endif
00292
00293
00294 #ifndef UINT32_T
00295 # if TMW_BITS_PER_INT == 32
00296 # define UINT32_T unsigned int
00297 # elif TMW_BITS_PER_LONG == 32
00298 # define UINT32_T unsigned long
00299 # elif TMW_BITS_PER_SCHAR == 32
00300 # if TMW_CHAR_SIGNED
00301 # define UINT32_T unsigned char
00302 # else
00303 # define UINT32_T char
00304 # endif
00305 # elif TMW_BITS_PER_SHRT == 32
00306 # define UINT32_T unsigned short
00307 # endif
00308 #endif
00309 #ifdef UINT32_T
00310 typedef UINT32_T uint32_T;
00311 #endif
00312
00313
00314
00315
00316
00317
00318
00319
00320 #ifndef INT8_T
00321 # ifdef INT16_T
00322 typedef INT16_T int8_T;
00323 # else
00324 # ifdef INT32_T
00325 typedef INT32_T int8_T;
00326 # endif
00327 # endif
00328 #endif
00329
00330 #ifndef UINT8_T
00331 # ifdef UINT16_T
00332 typedef UINT16_T uint8_T;
00333 # else
00334 # ifdef UINT32_T
00335 typedef UINT32_T uint8_T;
00336 # endif
00337 # endif
00338 #endif
00339
00340 #ifndef INT16_T
00341 # ifdef INT32_T
00342 typedef INT32_T int16_T;
00343 # endif
00344 #endif
00345
00346 #ifndef UINT16_T
00347 # ifdef UINT32_T
00348 typedef UINT32_T uint16_T;
00349 # endif
00350 #endif
00351
00352
00353 #ifndef NO_FLOATS
00354
00355 #ifndef REAL32_T
00356 # ifndef __MWERKS__
00357 # if FLT_MANT_DIG >= 23
00358 # define REAL32_T float
00359 # endif
00360 # else
00361 # define REAL32_T float
00362 # endif
00363 #endif
00364 #ifdef REAL32_T
00365 typedef REAL32_T real32_T;
00366 #endif
00367
00368
00369 #ifndef REAL64_T
00370 # ifndef __MWERKS__
00371 # if DBL_MANT_DIG >= 52
00372 # define REAL64_T double
00373 # endif
00374 # else
00375 # define REAL64_T double
00376 # endif
00377 #endif
00378 #ifdef REAL64_T
00379 typedef REAL64_T real64_T;
00380 #endif
00381
00382 #endif
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392 #ifndef INT64_T
00393 # if defined(__alpha) || defined(__sparcv9) || defined(__ia64) || \
00394 defined(__ia64__) || defined(__x86_64__) || defined(__LP64__)
00395 # define INT64_T long
00396 # define FMT64 "l"
00397 # elif defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \
00398 || (defined(__WATCOMC__) && __WATCOMC__ >= 1100) \
00399 || (defined(__LCC__))
00400 # define INT64_T __int64
00401 # define FMT64 "I64"
00402 # elif defined(__GNUC__) || defined(__hpux) || defined(__sun) \
00403 || defined(TMW_ENABLE_INT64)
00404 # define INT64_T long long
00405 # define FMT64 "ll"
00406 # endif
00407 #endif
00408
00409
00410
00411 #if defined(INT64_T)
00412 # if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9))
00413 __extension__
00414 # endif
00415 typedef INT64_T int64_T;
00416 #endif
00417
00418
00419
00420 #ifndef UINT64_T
00421 # if defined(__alpha) || defined(__sparcv9) || defined(__ia64) || \
00422 defined(__ia64__) || defined(__x86_64__) || defined(__LP64__)
00423 # define UINT64_T unsigned long
00424 # define FMT64 "l"
00425 # elif defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \
00426 || (defined(__WATCOMC__) && __WATCOMC__ >= 1100) \
00427 || (defined(__LCC__))
00428 # define UINT64_T unsigned __int64
00429 # define FMT64 "I64"
00430 # elif defined(__GNUC__) || defined(__hpux) || defined(__sun) \
00431 || defined(TMW_ENABLE_INT64)
00432 # define UINT64_T unsigned long long
00433 # define FMT64 "ll"
00434 # endif
00435 #endif
00436
00437
00438
00439 #if defined(UINT64_T)
00440 # if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9))
00441 __extension__
00442 # endif
00443 typedef UINT64_T uint64_T;
00444 #endif
00445
00446
00447
00448
00449
00450 #ifndef FMT_SIZE_T
00451 # if defined(__sparcv9)
00452 # define FMT_SIZE_T "l"
00453 # elif defined( __GNUC__ ) || defined(_STDC_C99)
00454 # define FMT_SIZE_T "z"
00455 # elif defined (__WATCOMC__)
00456 # define FMT_SIZE_T "l"
00457 # elif defined (_WIN32 )
00458 # define FMT_SIZE_T "I"
00459 # else
00460 # define FMT_SIZE_T "l"
00461 # endif
00462 #endif
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475 #ifndef NO_FLOATS
00476
00477 #ifndef REAL_T
00478 # ifdef REAL64_T
00479 # define REAL_T real64_T
00480 # else
00481 # ifdef REAL32_T
00482 # define REAL_T real32_T
00483 # endif
00484 # endif
00485 #endif
00486 #ifdef REAL_T
00487 typedef REAL_T real_T;
00488 #endif
00489
00490 #ifndef TIME_T
00491 # ifdef REAL_T
00492 # define TIME_T real_T
00493 # endif
00494 #endif
00495 #ifdef TIME_T
00496 typedef TIME_T time_T;
00497 #endif
00498
00499 #endif
00500
00501 #ifndef BOOLEAN_T
00502 # if defined(UINT8_T)
00503 # define BOOLEAN_T UINT8_T
00504 # else
00505 # define BOOLEAN_T unsigned int
00506 # endif
00507 #endif
00508 typedef BOOLEAN_T boolean_T;
00509
00510
00511 #ifndef CHARACTER_T
00512 # define CHARACTER_T char
00513 #endif
00514 typedef CHARACTER_T char_T;
00515
00516
00517 #ifndef INTEGER_T
00518 # define INTEGER_T int
00519 #endif
00520 typedef INTEGER_T int_T;
00521
00522
00523 #ifndef UINTEGER_T
00524 # define UINTEGER_T unsigned
00525 #endif
00526 typedef UINTEGER_T uint_T;
00527
00528
00529 #ifndef BYTE_T
00530 # define BYTE_T unsigned char
00531 #endif
00532 typedef BYTE_T byte_T;
00533
00534
00535
00536
00537
00538 #ifndef NO_FLOATS
00539
00540 #ifndef CREAL32_T
00541 # ifdef REAL32_T
00542 typedef struct {
00543 real32_T re, im;
00544 } creal32_T;
00545 # define CREAL32_T creal32_T
00546 # endif
00547 #endif
00548
00549 #ifndef CREAL64_T
00550 # ifdef REAL64_T
00551 typedef struct {
00552 real64_T re, im;
00553 } creal64_T;
00554 # define CREAL64_T creal64_T
00555 # endif
00556 #endif
00557
00558 #ifndef CREAL_T
00559 # ifdef REAL_T
00560 typedef struct {
00561 real_T re, im;
00562 } creal_T;
00563 # define CREAL_T creal_T
00564 # endif
00565 #endif
00566
00567 #endif
00568
00569 #ifndef CINT8_T
00570 # ifdef INT8_T
00571 typedef struct {
00572 int8_T re, im;
00573 } cint8_T;
00574 # define CINT8_T cint8_T
00575 # endif
00576 #endif
00577
00578 #ifndef CUINT8_T
00579 # ifdef UINT8_T
00580 typedef struct {
00581 uint8_T re, im;
00582 } cuint8_T;
00583 # define CUINT8_T cuint8_T
00584 # endif
00585 #endif
00586
00587 #ifndef CINT16_T
00588 # ifdef INT16_T
00589 typedef struct {
00590 int16_T re, im;
00591 } cint16_T;
00592 # define CINT16_T cint16_T
00593 # endif
00594 #endif
00595
00596 #ifndef CUINT16_T
00597 # ifdef UINT16_T
00598 typedef struct {
00599 uint16_T re, im;
00600 } cuint16_T;
00601 # define CUINT16_T cuint16_T
00602 # endif
00603 #endif
00604
00605 #ifndef CINT32_T
00606 # ifdef INT32_T
00607 typedef struct {
00608 int32_T re, im;
00609 } cint32_T;
00610 # define CINT32_T cint32_T
00611 # endif
00612 #endif
00613
00614 #ifndef CUINT32_T
00615 # ifdef UINT32_T
00616 typedef struct {
00617 uint32_T re, im;
00618 } cuint32_T;
00619 # define CUINT32_T cuint32_T
00620 # endif
00621 #endif
00622
00623
00624
00625
00626
00627
00628
00629 #define MAX_int8_T ((int8_T)(127))
00630 #define MIN_int8_T ((int8_T)(-128))
00631 #define MAX_uint8_T ((uint8_T)(255))
00632 #define MIN_uint8_T ((uint8_T)(0))
00633
00634 #define MAX_int16_T ((int16_T)(32767))
00635 #define MIN_int16_T ((int16_T)(-32768))
00636 #define MAX_uint16_T ((uint16_T)(65535))
00637 #define MIN_uint16_T ((uint16_T)(0))
00638
00639 #define MAX_int32_T ((int32_T)(2147483647))
00640 #define MIN_int32_T ((int32_T)(-2147483647-1))
00641 #define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU))
00642 #define MIN_uint32_T ((uint32_T)(0))
00643
00644 #if defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \
00645 || (defined(__WATCOMC__) && __WATCOMC__ >= 1100)
00646 # ifdef INT64_T
00647 # define MAX_int64_T ((int64_T)(9223372036854775807))
00648 # define MIN_int64_T ((int64_T)(-9223372036854775807-1))
00649 # endif
00650 # ifdef UINT64_T
00651 # define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFU))
00652 # define MIN_uint64_T ((uint64_T)(0))
00653 # endif
00654 #else
00655 # ifdef INT64_T
00656 # define MAX_int64_T ((int64_T)(9223372036854775807LL))
00657 # define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL))
00658 # endif
00659 # ifdef UINT64_T
00660 # define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFLLU))
00661 # define MIN_uint64_T ((uint64_T)(0))
00662 # endif
00663 #endif
00664
00665 #ifdef _MSC_VER
00666
00667
00668
00669
00670
00671
00672
00673
00674 # define uint64_to_double(u) ( ((u) > _I64_MAX) ? \
00675 (double)(__int64)((u) - _I64_MAX - 1) + (double)_I64_MAX + 1: \
00676 (double)(__int64)(u) )
00677
00678
00679
00680
00681
00682 # define double_to_uint64(d) ( ((d) > 0xffffffffffffffffu) ? \
00683 (unsigned __int64) 0xffffffffffffffffu : \
00684 ((d) < 0) ? (unsigned __int64) 0 : \
00685 ((d) > _I64_MAX) ? \
00686 (unsigned __int64) ((d) - _I64_MAX) - 1 + (unsigned __int64)_I64_MAX + 1: \
00687 (unsigned __int64)(d) )
00688 #else
00689 # define uint64_to_double(u) ((double)(u))
00690 # if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__TICCSC__)
00691
00692 # else
00693 # define double_to_uint64(d) ( ((d) > 0xffffffffffffffffLLU) ? \
00694 (unsigned long long) 0xffffffffffffffffLLU : \
00695 ((d) < 0) ? (unsigned long long) 0 : (unsigned long long)(d) )
00696 # endif
00697 #endif
00698
00699 #if !defined(__cplusplus) && !defined(__bool_true_false_are_defined)
00700
00701 #ifndef _bool_T
00702 #define _bool_T
00703
00704 typedef boolean_T bool;
00705
00706 #ifndef false
00707 #define false (0)
00708 #endif
00709 #ifndef true
00710 #define true (1)
00711 #endif
00712
00713 #endif
00714
00715 #endif
00716
00717
00718
00719
00720
00721 #if ((SCHAR_MIN + 1) != -SCHAR_MAX)
00722 #error "This code must be compiled using a 2's complement representation for signed integer values"
00723 #endif
00724
00725
00726
00727
00728
00729 #define TMW_NAME_LENGTH_MAX 64
00730
00731
00732
00733
00734 #include <stddef.h>
00735
00736 #ifdef MX_COMPAT_32
00737 typedef int mwSize;
00738 typedef int mwIndex;
00739 typedef int mwSignedIndex;
00740 #else
00741 typedef size_t mwSize;
00742 typedef size_t mwIndex;
00743 typedef ptrdiff_t mwSignedIndex;
00744 #endif
00745
00746 #if (defined(_LP64) || defined(_WIN64)) && !defined(MX_COMPAT_32)
00747
00748 # define MWSIZE_MAX 281474976710655UL
00749 # define MWINDEX_MAX 281474976710655UL
00750 # define MWSINDEX_MAX 281474976710655L
00751 # define MWSINDEX_MIN -281474976710655L
00752 #else
00753 # define MWSIZE_MAX 2147483647UL
00754 # define MWINDEX_MAX 2147483647UL
00755 # define MWSINDEX_MAX 2147483647L
00756 # define MWSINDEX_MIN -2147483647L
00757 #endif
00758 #define MWSIZE_MIN 0UL
00759 #define MWINDEX_MIN 0UL
00760
00761 #endif
00762
00763 #endif