tmwtypes.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. /*
  2. * @(#)tmwtypes.h generated by: makeheader 5.1.3 Mon Jan 8 22:14:40 2007
  3. *
  4. * built from: ../../src/include/copyright.h
  5. * ../../src/include/tmwtypes.h
  6. */
  7. #if defined(_MSC_VER) || __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 3)
  8. #pragma once
  9. #endif
  10. #ifndef tmwtypes_h
  11. #define tmwtypes_h
  12. /*
  13. * Copyright 1984-2007 The MathWorks, Inc.
  14. */
  15. /* Copyright 1995-2006 The MathWorks, Inc. */
  16. #ifndef __TMWTYPES__
  17. #define __TMWTYPES__
  18. /*
  19. * File : tmwtypes.h
  20. * Abstract:
  21. * Data types for use with MATLAB/SIMULINK and the Real-Time Workshop.
  22. *
  23. * When compiling stand-alone model code, data types can be overridden
  24. * via compiler switches.
  25. *
  26. * Define NO_FLOATS to eliminate reference to real_T, etc.
  27. */
  28. #include <limits.h>
  29. #ifdef __APPLE_CC__
  30. #include <stdbool.h>
  31. #endif
  32. #define LOGICAL_IS_A_TYPE
  33. #define SPARSE_GENERALIZATION
  34. #ifdef NO_FLOATS
  35. # define double double_not_allowed
  36. # define float float_not_allowed
  37. #endif /*NO_FLOATS*/
  38. #ifndef NO_FLOATS
  39. #ifndef __MWERKS__
  40. # ifdef __STDC__
  41. # include <float.h>
  42. # else
  43. # define FLT_MANT_DIG 24
  44. # define DBL_MANT_DIG 53
  45. # endif
  46. #endif
  47. #endif /*NO_FLOATS*/
  48. /*
  49. * The following data types cannot be overridden when building MEX files.
  50. */
  51. #ifdef MATLAB_MEX_FILE
  52. # undef CHARACTER_T
  53. # undef INTEGER_T
  54. # undef BOOLEAN_T
  55. # undef REAL_T
  56. # undef TIME_T
  57. #endif
  58. /*
  59. * The uchar_T, ushort_T and ulong_T types are needed for compilers which do
  60. * not allow defines to be specified, at the command line, with spaces in them.
  61. */
  62. typedef unsigned char uchar_T;
  63. typedef unsigned short ushort_T;
  64. typedef unsigned long ulong_T;
  65. /*=======================================================================*
  66. * Fixed width word size data types: *
  67. * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
  68. * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
  69. * real32_T, real64_T - 32 and 64 bit floating point numbers *
  70. *=======================================================================*/
  71. /* When used with Real Time Workshop generated code, this
  72. * header file can be used with a variety of compilers.
  73. *
  74. * The compiler could be for an 8 bit embedded processor that
  75. * only had 8 bits per integer and 16 bits per long.
  76. * In that example, a 32 bit integer size is not even available.
  77. * This header file should be robust to that.
  78. *
  79. * For the case of an 8 bit processor, the preprocessor
  80. * may be limited to 16 bit math like its target. That limitation
  81. * would mean that 32 bit comparisons can't be done accurately.
  82. * To increase robustness to this, comparisons are done against
  83. * smaller values first. An inaccurate 32 bit comparison isn't
  84. * attempted if the 16 bit comparison has already succeeded.
  85. *
  86. * Limitations on preprocessor math can also be stricter than
  87. * for the target. There are known cases where a compiler
  88. * targeting processors with 64 bit longs can't do accurate
  89. * preprocessor comparisons on more than 32 bits.
  90. */
  91. /* Determine the number of bits for int, long, short, and char.
  92. * If one fails to be determined, set the number of bits to -1
  93. */
  94. #ifndef TMW_BITS_PER_INT
  95. # if INT_MAX == 0x7FL
  96. # define TMW_BITS_PER_INT 8
  97. # elif INT_MAX == 0x7FFFL
  98. # define TMW_BITS_PER_INT 16
  99. # elif INT_MAX == 0x7FFFFFFFL
  100. # define TMW_BITS_PER_INT 32
  101. # else
  102. # define TMW_BITS_PER_INT -1
  103. # endif
  104. #endif
  105. #ifndef TMW_BITS_PER_LONG
  106. # if LONG_MAX == 0x7FL
  107. # define TMW_BITS_PER_LONG 8
  108. # elif LONG_MAX == 0x7FFFL
  109. # define TMW_BITS_PER_LONG 16
  110. # elif LONG_MAX == 0x7FFFFFFFL
  111. # define TMW_BITS_PER_LONG 32
  112. # else
  113. # define TMW_BITS_PER_LONG -1
  114. # endif
  115. #endif
  116. #ifndef TMW_BITS_PER_SHRT
  117. # if SHRT_MAX == 0x7FL
  118. # define TMW_BITS_PER_SHRT 8
  119. # elif SHRT_MAX == 0x7FFFL
  120. # define TMW_BITS_PER_SHRT 16
  121. # elif SHRT_MAX == 0x7FFFFFFFL
  122. # define TMW_BITS_PER_SHRT 32
  123. # else
  124. # define TMW_BITS_PER_SHRT -1
  125. # endif
  126. #endif
  127. #ifndef TMW_BITS_PER_SCHAR
  128. # if SCHAR_MAX == 0x7FL
  129. # define TMW_BITS_PER_SCHAR 8
  130. # elif SCHAR_MAX == 0x7FFFL
  131. # define TMW_BITS_PER_SCHAR 16
  132. # elif SCHAR_MAX == 0x7FFFFFFFL
  133. # define TMW_BITS_PER_SCHAR 32
  134. # else
  135. # define TMW_BITS_PER_SCHAR -1
  136. # endif
  137. #endif
  138. #ifndef TMW_CHAR_SIGNED
  139. # if SCHAR_MAX == CHAR_MAX
  140. # define TMW_CHAR_SIGNED 1
  141. # else
  142. # define TMW_CHAR_SIGNED 0
  143. # endif
  144. #endif
  145. /* It is common for one or more of the integer types
  146. * to be the same size. For example, on many embedded
  147. * processors, both shorts and ints are 16 bits. On
  148. * processors used for workstations, it is quite common
  149. * for both int and long to be 32 bits.
  150. * When there is more than one choice for typdef'ing
  151. * a portable type like int16_T or uint32_T, in
  152. * concept, it should not matter which choice is made.
  153. * However, some style guides and some code checking
  154. * tools do identify and complain about seemingly
  155. * irrelevant differences. For example, a code
  156. * checking tool may complain about an implicit
  157. * conversion from int to short even though both
  158. * are 16 bits. To reduce these types of
  159. * complaints, it is best to make int the
  160. * preferred choice when more than one is available.
  161. */
  162. #ifndef INT8_T
  163. # if TMW_BITS_PER_INT == 8
  164. # define INT8_T int
  165. # elif TMW_BITS_PER_LONG == 8
  166. # define INT8_T long
  167. # elif TMW_BITS_PER_SCHAR == 8
  168. # if TMW_CHAR_SIGNED
  169. # define INT8_T char
  170. # else
  171. # define INT8_T signed char
  172. # endif
  173. # elif TMW_BITS_PER_SHRT == 8
  174. # define INT8_T short
  175. # endif
  176. #endif
  177. #ifdef INT8_T
  178. typedef INT8_T int8_T;
  179. #endif
  180. #ifndef UINT8_T
  181. # if TMW_BITS_PER_INT == 8
  182. # define UINT8_T unsigned int
  183. # elif TMW_BITS_PER_LONG == 8
  184. # define UINT8_T unsigned long
  185. # elif TMW_BITS_PER_SCHAR == 8
  186. # if TMW_CHAR_SIGNED
  187. # define UINT8_T unsigned char
  188. # else
  189. # define UINT8_T char
  190. # endif
  191. # elif TMW_BITS_PER_SHRT == 8
  192. # define UINT8_T unsigned short
  193. # endif
  194. #endif
  195. #ifdef UINT8_T
  196. typedef UINT8_T uint8_T;
  197. #endif
  198. #ifndef INT16_T
  199. # if TMW_BITS_PER_INT == 16
  200. # define INT16_T int
  201. # elif TMW_BITS_PER_LONG == 16
  202. # define INT16_T long
  203. # elif TMW_BITS_PER_SCHAR == 16
  204. # if TMW_CHAR_SIGNED
  205. # define INT16_T char
  206. # else
  207. # define INT16_T signed char
  208. # endif
  209. # elif TMW_BITS_PER_SHRT == 16
  210. # define INT16_T short
  211. # endif
  212. #endif
  213. #ifdef INT16_T
  214. typedef INT16_T int16_T;
  215. #endif
  216. #ifndef UINT16_T
  217. # if TMW_BITS_PER_INT == 16
  218. # define UINT16_T unsigned int
  219. # elif TMW_BITS_PER_LONG == 16
  220. # define UINT16_T unsigned long
  221. # elif TMW_BITS_PER_SCHAR == 16
  222. # if TMW_CHAR_SIGNED
  223. # define UINT16_T unsigned char
  224. # else
  225. # define UINT16_T char
  226. # endif
  227. # elif TMW_BITS_PER_SHRT == 16
  228. # define UINT16_T unsigned short
  229. # endif
  230. #endif
  231. #ifdef UINT16_T
  232. typedef UINT16_T uint16_T;
  233. #endif
  234. #ifndef INT32_T
  235. # if TMW_BITS_PER_INT == 32
  236. # define INT32_T int
  237. # elif TMW_BITS_PER_LONG == 32
  238. # define INT32_T long
  239. # elif TMW_BITS_PER_SCHAR == 32
  240. # if TMW_CHAR_SIGNED
  241. # define INT32_T char
  242. # else
  243. # define INT32_T signed char
  244. # endif
  245. # elif TMW_BITS_PER_SHRT == 32
  246. # define INT32_T short
  247. # endif
  248. #endif
  249. #ifdef INT32_T
  250. typedef INT32_T int32_T;
  251. #endif
  252. #ifndef UINT32_T
  253. # if TMW_BITS_PER_INT == 32
  254. # define UINT32_T unsigned int
  255. # elif TMW_BITS_PER_LONG == 32
  256. # define UINT32_T unsigned long
  257. # elif TMW_BITS_PER_SCHAR == 32
  258. # if TMW_CHAR_SIGNED
  259. # define UINT32_T unsigned char
  260. # else
  261. # define UINT32_T char
  262. # endif
  263. # elif TMW_BITS_PER_SHRT == 32
  264. # define UINT32_T unsigned short
  265. # endif
  266. #endif
  267. #ifdef UINT32_T
  268. typedef UINT32_T uint32_T;
  269. #endif
  270. /* The following is used to emulate smaller integer types when only
  271. * larger types are available. For example, compilers for TI C3x/C4x DSPs
  272. * define char and short to be 32 bits, so 8 and 16 bits are not directly
  273. * available. This target is commonly used with RTW rapid prototyping.
  274. * Other DSPs define char to be 16 bits, so 8 bits is not directly
  275. * available.
  276. */
  277. #ifndef INT8_T
  278. # ifdef INT16_T
  279. typedef INT16_T int8_T;
  280. # else
  281. # ifdef INT32_T
  282. typedef INT32_T int8_T;
  283. # endif
  284. # endif
  285. #endif
  286. #ifndef UINT8_T
  287. # ifdef UINT16_T
  288. typedef UINT16_T uint8_T;
  289. # else
  290. # ifdef UINT32_T
  291. typedef UINT32_T uint8_T;
  292. # endif
  293. # endif
  294. #endif
  295. #ifndef INT16_T
  296. # ifdef INT32_T
  297. typedef INT32_T int16_T;
  298. # endif
  299. #endif
  300. #ifndef UINT16_T
  301. # ifdef UINT32_T
  302. typedef UINT32_T uint16_T;
  303. # endif
  304. #endif
  305. #ifndef NO_FLOATS
  306. #ifndef REAL32_T
  307. # ifndef __MWERKS__
  308. # if FLT_MANT_DIG >= 23
  309. # define REAL32_T float
  310. # endif
  311. # else
  312. # define REAL32_T float
  313. # endif
  314. #endif
  315. #ifdef REAL32_T
  316. typedef REAL32_T real32_T;
  317. #endif
  318. #ifndef REAL64_T
  319. # ifndef __MWERKS__
  320. # if DBL_MANT_DIG >= 52
  321. # define REAL64_T double
  322. # endif
  323. # else
  324. # define REAL64_T double
  325. # endif
  326. #endif
  327. #ifdef REAL64_T
  328. typedef REAL64_T real64_T;
  329. #endif
  330. #endif /* NO_FLOATS*/
  331. /*=======================================================================*
  332. * Fixed width word size data types: *
  333. * int64_T - signed 64 bit integers *
  334. * uint64_T - unsigned 64 bit integers *
  335. *=======================================================================*/
  336. #ifndef INT64_T
  337. # if defined(__alpha) || defined(__sparcv9) || defined(__ia64) || \
  338. defined(__ia64__) || defined(__x86_64__) || defined(__LP64__)
  339. # define INT64_T long
  340. # define FMT64 "l"
  341. # elif defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \
  342. || (defined(__WATCOMC__) && __WATCOMC__ >= 1100)
  343. # define INT64_T __int64
  344. # define FMT64 "I64"
  345. # elif defined(__GNUC__) || defined(__hpux) || defined(__sun) \
  346. || defined(TMW_ENABLE_INT64)
  347. # define INT64_T long long
  348. # define FMT64 "ll"
  349. # endif
  350. #endif
  351. #if defined(INT64_T)
  352. # if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9))
  353. __extension__
  354. # endif
  355. typedef INT64_T int64_T;
  356. #endif
  357. #ifndef UINT64_T
  358. # if defined(__alpha) || defined(__sparcv9) || defined(__ia64) || \
  359. defined(__ia64__) || defined(__x86_64__) || defined(__LP64__)
  360. # define UINT64_T unsigned long
  361. # define FMT64 "l"
  362. # elif defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \
  363. || (defined(__WATCOMC__) && __WATCOMC__ >= 1100)
  364. # define UINT64_T unsigned __int64
  365. # define FMT64 "I64"
  366. # elif defined(__GNUC__) || defined(__hpux) || defined(__sun) \
  367. || defined(TMW_ENABLE_INT64)
  368. # define UINT64_T unsigned long long
  369. # define FMT64 "ll"
  370. # endif
  371. #endif
  372. #if defined(UINT64_T)
  373. # if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >=9))
  374. __extension__
  375. # endif
  376. typedef UINT64_T uint64_T;
  377. #endif
  378. /*===========================================================================*
  379. * Format string modifiers for using size_t variables in printf statements. *
  380. *===========================================================================*/
  381. #ifndef FMT_SIZE_T
  382. # if defined( __GNUC__ ) || defined(_STDC_C99)
  383. # define FMT_SIZE_T "z"
  384. # elif defined (__WATCOMC__)
  385. # define FMT_SIZE_T "l"
  386. # elif defined (_WIN32 )
  387. # define FMT_SIZE_T "I"
  388. # else
  389. # define FMT_SIZE_T "l"
  390. # endif
  391. #endif
  392. /*===========================================================================*
  393. * General or logical data types where the word size is not guaranteed. *
  394. * real_T - possible settings include real32_T or real64_T *
  395. * time_T - possible settings include real64_T or uint32_T *
  396. * boolean_T *
  397. * char_T *
  398. * int_T *
  399. * uint_T *
  400. * byte_T *
  401. *===========================================================================*/
  402. #ifndef NO_FLOATS
  403. #ifndef REAL_T
  404. # ifdef REAL64_T
  405. # define REAL_T real64_T
  406. # else
  407. # ifdef REAL32_T
  408. # define REAL_T real32_T
  409. # endif
  410. # endif
  411. #endif
  412. #ifdef REAL_T
  413. typedef REAL_T real_T;
  414. #endif
  415. #ifndef TIME_T
  416. # ifdef REAL_T
  417. # define TIME_T real_T
  418. # endif
  419. #endif
  420. #ifdef TIME_T
  421. typedef TIME_T time_T;
  422. #endif
  423. #endif /* NO_FLOATS */
  424. #ifndef BOOLEAN_T
  425. # if defined(UINT8_T)
  426. # define BOOLEAN_T UINT8_T
  427. # else
  428. # define BOOLEAN_T unsigned int
  429. # endif
  430. #endif
  431. typedef BOOLEAN_T boolean_T;
  432. #ifndef CHARACTER_T
  433. # define CHARACTER_T char
  434. #endif
  435. typedef CHARACTER_T char_T;
  436. #ifndef INTEGER_T
  437. # define INTEGER_T int
  438. #endif
  439. typedef INTEGER_T int_T;
  440. #ifndef UINTEGER_T
  441. # define UINTEGER_T unsigned
  442. #endif
  443. typedef UINTEGER_T uint_T;
  444. #ifndef BYTE_T
  445. # define BYTE_T unsigned char
  446. #endif
  447. typedef BYTE_T byte_T;
  448. /*===========================================================================*
  449. * Define Complex Structures *
  450. *===========================================================================*/
  451. #ifndef NO_FLOATS
  452. #ifndef CREAL32_T
  453. # ifdef REAL32_T
  454. typedef struct {
  455. real32_T re, im;
  456. } creal32_T;
  457. # define CREAL32_T creal32_T
  458. # endif
  459. #endif
  460. #ifndef CREAL64_T
  461. # ifdef REAL64_T
  462. typedef struct {
  463. real64_T re, im;
  464. } creal64_T;
  465. # define CREAL64_T creal64_T
  466. # endif
  467. #endif
  468. #ifndef CREAL_T
  469. # ifdef REAL_T
  470. typedef struct {
  471. real_T re, im;
  472. } creal_T;
  473. # define CREAL_T creal_T
  474. # endif
  475. #endif
  476. #endif /* NO_FLOATS */
  477. #ifndef CINT8_T
  478. # ifdef INT8_T
  479. typedef struct {
  480. int8_T re, im;
  481. } cint8_T;
  482. # define CINT8_T cint8_T
  483. # endif
  484. #endif
  485. #ifndef CUINT8_T
  486. # ifdef UINT8_T
  487. typedef struct {
  488. uint8_T re, im;
  489. } cuint8_T;
  490. # define CUINT8_T cuint8_T
  491. # endif
  492. #endif
  493. #ifndef CINT16_T
  494. # ifdef INT16_T
  495. typedef struct {
  496. int16_T re, im;
  497. } cint16_T;
  498. # define CINT16_T cint16_T
  499. # endif
  500. #endif
  501. #ifndef CUINT16_T
  502. # ifdef UINT16_T
  503. typedef struct {
  504. uint16_T re, im;
  505. } cuint16_T;
  506. # define CUINT16_T cuint16_T
  507. # endif
  508. #endif
  509. #ifndef CINT32_T
  510. # ifdef INT32_T
  511. typedef struct {
  512. int32_T re, im;
  513. } cint32_T;
  514. # define CINT32_T cint32_T
  515. # endif
  516. #endif
  517. #ifndef CUINT32_T
  518. # ifdef UINT32_T
  519. typedef struct {
  520. uint32_T re, im;
  521. } cuint32_T;
  522. # define CUINT32_T cuint32_T
  523. # endif
  524. #endif
  525. /*=======================================================================*
  526. * Min and Max: *
  527. * int8_T, int16_T, int32_T - signed 8, 16, or 32 bit integers *
  528. * uint8_T, uint16_T, uint32_T - unsigned 8, 16, or 32 bit integers *
  529. *=======================================================================*/
  530. #define MAX_int8_T ((int8_T)(127)) /* 127 */
  531. #define MIN_int8_T ((int8_T)(-128)) /* -128 */
  532. #define MAX_uint8_T ((uint8_T)(255)) /* 255 */
  533. #define MIN_uint8_T ((uint8_T)(0))
  534. #define MAX_int16_T ((int16_T)(32767)) /* 32767 */
  535. #define MIN_int16_T ((int16_T)(-32768)) /* -32768 */
  536. #define MAX_uint16_T ((uint16_T)(65535)) /* 65535 */
  537. #define MIN_uint16_T ((uint16_T)(0))
  538. #define MAX_int32_T ((int32_T)(2147483647)) /* 2147483647 */
  539. #define MIN_int32_T ((int32_T)(-2147483647-1)) /* -2147483648 */
  540. #define MAX_uint32_T ((uint32_T)(0xFFFFFFFFU)) /* 4294967295 */
  541. #define MIN_uint32_T ((uint32_T)(0))
  542. #if defined(_MSC_VER) || (defined(__BORLANDC__) && __BORLANDC__ >= 0x530) \
  543. || (defined(__WATCOMC__) && __WATCOMC__ >= 1100)
  544. # ifdef INT64_T
  545. # define MAX_int64_T ((int64_T)(9223372036854775807))
  546. # define MIN_int64_T ((int64_T)(-9223372036854775807-1))
  547. # endif
  548. # ifdef UINT64_T
  549. # define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFU))
  550. # define MIN_uint64_T ((uint64_T)(0))
  551. # endif
  552. #else
  553. # ifdef INT64_T
  554. # define MAX_int64_T ((int64_T)(9223372036854775807LL))
  555. # define MIN_int64_T ((int64_T)(-9223372036854775807LL-1LL))
  556. # endif
  557. # ifdef UINT64_T
  558. # define MAX_uint64_T ((uint64_T)(0xFFFFFFFFFFFFFFFFLLU))
  559. # define MIN_uint64_T ((uint64_T)(0))
  560. # endif
  561. #endif
  562. #ifdef _MSC_VER
  563. /* Conversion from unsigned __int64 to double is not implemented in windows
  564. * and results in a compile error, thus the value must first be cast to
  565. * signed __int64, and then to double.
  566. *
  567. * If the 64 bit int value is greater than 2^63-1, which is the signed int64 max,
  568. * the macro below provides a workaround for casting a uint64 value to a double
  569. * in windows.
  570. */
  571. # define uint64_to_double(u) ( ((u) > _I64_MAX) ? \
  572. (double)(__int64)((u) - _I64_MAX - 1) + (double)_I64_MAX + 1: \
  573. (double)(__int64)(u) )
  574. /* The largest double value that can be cast to uint64 in windows is the
  575. * signed int64 max, which is 2^63-1. The macro below provides
  576. * a workaround for casting large double values to uint64 in windows.
  577. */
  578. # define double_to_uint64(d) ( ((d) > 0xffffffffffffffffu) ? \
  579. (unsigned __int64) 0xffffffffffffffffu : \
  580. ((d) < 0) ? (unsigned __int64) 0 : \
  581. ((d) > _I64_MAX) ? \
  582. (unsigned __int64) ((d) - _I64_MAX) - 1 + (unsigned __int64)_I64_MAX + 1: \
  583. (unsigned __int64)(d) )
  584. #else
  585. # define uint64_to_double(u) ((double)(u))
  586. # if defined(__BORLANDC__) || defined(__WATCOMC__) || defined(__TICCSC__)
  587. /* double_to_uint64 defined only for MSVC and UNIX */
  588. # else
  589. # define double_to_uint64(d) ( ((d) > 0xffffffffffffffffLLU) ? \
  590. (unsigned long long) 0xffffffffffffffffLLU : \
  591. ((d) < 0) ? (unsigned long long) 0 : (unsigned long long)(d) )
  592. # endif
  593. #endif
  594. #if !defined(__cplusplus) && !defined(__bool_true_false_are_defined)
  595. #ifndef _bool_T
  596. #define _bool_T
  597. typedef boolean_T bool;
  598. #ifndef false
  599. #define false (0)
  600. #endif
  601. #ifndef true
  602. #define true (1)
  603. #endif
  604. #endif /* _bool_T */
  605. #endif /* !__cplusplus */
  606. /*
  607. * This software assumes that the code is being compiled on a target using a
  608. * 2's complement representation for signed integer values.
  609. */
  610. #if ((SCHAR_MIN + 1) != -SCHAR_MAX)
  611. #error "This code must be compiled using a 2's complement representation for signed integer values"
  612. #endif
  613. /*
  614. * Maximum length of a MATLAB identifier (function/variable/model)
  615. * including the null-termination character.
  616. */
  617. #define TMW_NAME_LENGTH_MAX 64
  618. /*
  619. * Maximum values for indices and dimensions
  620. */
  621. #include <stddef.h>
  622. #ifdef MX_COMPAT_32
  623. typedef int mwSize;
  624. typedef int mwIndex;
  625. typedef int mwSignedIndex;
  626. #else
  627. typedef size_t mwSize; /* unsigned pointer-width integer */
  628. typedef size_t mwIndex; /* unsigned pointer-width integer */
  629. typedef ptrdiff_t mwSignedIndex; /* a signed pointer-width integer */
  630. #endif
  631. #if (defined(_LP64) || defined(_WIN64)) && !defined(MX_COMPAT_32)
  632. /* Currently 2^48 based on hardware limitations */
  633. # define MWSIZE_MAX 281474976710655UL
  634. # define MWINDEX_MAX 281474976710655UL
  635. # define MWSINDEX_MAX 281474976710655L
  636. # define MWSINDEX_MIN -281474976710655L
  637. #else
  638. # define MWSIZE_MAX 2147483647UL
  639. # define MWINDEX_MAX 2147483647UL
  640. # define MWSINDEX_MAX 2147483647L
  641. # define MWSINDEX_MIN -2147483647L
  642. #endif
  643. #define MWSIZE_MIN 0UL
  644. #define MWINDEX_MIN 0UL
  645. #endif /* __TMWTYPES__ */
  646. #endif /* tmwtypes_h */