typedefs.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. ********************************************************************************
  3. *
  4. * GSM AMR-NB speech codec R98 Version 7.6.0 December 12, 2001
  5. * R99 Version 3.3.0
  6. * REL-4 Version 4.1.0
  7. *
  8. ********************************************************************************
  9. *
  10. * File : typedefs.h
  11. * Description : Definition of platform independent data
  12. * types and constants
  13. *
  14. *
  15. * The following platform independent data types and corresponding
  16. * preprocessor (#define) constants are defined:
  17. *
  18. * defined type meaning corresponding constants
  19. * ----------------------------------------------------------
  20. * Char character (none)
  21. * Bool boolean true, false
  22. * Word8 8-bit signed minWord8, maxWord8
  23. * UWord8 8-bit unsigned minUWord8, maxUWord8
  24. * Word16 16-bit signed minWord16, maxWord16
  25. * UWord16 16-bit unsigned minUWord16, maxUWord16
  26. * Word32 32-bit signed minWord32, maxWord32
  27. * UWord32 32-bit unsigned minUWord32, maxUWord32
  28. * Float floating point minFloat, maxFloat
  29. *
  30. *
  31. * The following compile switches are #defined:
  32. *
  33. * PLATFORM string indicating platform progam is compiled on
  34. * possible values: "OSF", "PC", "SUN"
  35. *
  36. * OSF only defined if the current platform is an Alpha
  37. * PC only defined if the current platform is a PC
  38. * SUN only defined if the current platform is a Sun
  39. *
  40. * LSBFIRST is defined if the byte order on this platform is
  41. * "least significant byte first" -> defined on DEC Alpha
  42. * and PC, undefined on Sun
  43. *
  44. ********************************************************************************
  45. */
  46. #ifndef typedefs_h
  47. #define typedefs_h "$Id $"
  48. /*
  49. ********************************************************************************
  50. * INCLUDE FILES
  51. ********************************************************************************
  52. */
  53. #include <float.h>
  54. #include <limits.h>
  55. /*
  56. ********************************************************************************
  57. * DEFINITION OF CONSTANTS
  58. ********************************************************************************
  59. */
  60. /*
  61. ********* define char type
  62. */
  63. typedef char Char;
  64. /*
  65. ********* define 8 bit signed/unsigned types & constants
  66. */
  67. #if SCHAR_MAX == 127
  68. typedef signed char Word8;
  69. #define minWord8 SCHAR_MIN
  70. #define maxWord8 SCHAR_MAX
  71. typedef unsigned char UWord8;
  72. #define minUWord8 0
  73. #define maxUWord8 UCHAR_MAX
  74. #else
  75. #error cannot find 8-bit type
  76. #endif
  77. /*
  78. ********* define 16 bit signed/unsigned types & constants
  79. */
  80. #if INT_MAX == 32767
  81. typedef int Word16;
  82. #define minWord16 INT_MIN
  83. #define maxWord16 INT_MAX
  84. typedef unsigned int UWord16;
  85. #define minUWord16 0
  86. #define maxUWord16 UINT_MAX
  87. #elif SHRT_MAX == 32767
  88. typedef short Word16;
  89. #define minWord16 SHRT_MIN
  90. #define maxWord16 SHRT_MAX
  91. typedef unsigned short UWord16;
  92. #define minUWord16 0
  93. #define maxUWord16 USHRT_MAX
  94. #else
  95. #error cannot find 16-bit type
  96. #endif
  97. /*
  98. ********* define 32 bit signed/unsigned types & constants
  99. */
  100. #if INT_MAX == 2147483647
  101. typedef int Word32;
  102. #define minWord32 INT_MIN
  103. #define maxWord32 INT_MAX
  104. typedef unsigned int UWord32;
  105. #define minUWord32 0
  106. #define maxUWord32 UINT_MAX
  107. #elif LONG_MAX == 2147483647
  108. typedef long Word32;
  109. #define minWord32 LONG_MIN
  110. #define maxWord32 LONG_MAX
  111. typedef unsigned long UWord32;
  112. #define minUWord32 0
  113. #define maxUWord32 ULONG_MAX
  114. #else
  115. #error cannot find 32-bit type
  116. #endif
  117. /*
  118. ********* define floating point type & constants
  119. */
  120. /* use "#if 0" below if Float should be double;
  121. use "#if 1" below if Float should be float
  122. */
  123. #if 0
  124. typedef float Float;
  125. #define maxFloat FLT_MAX
  126. #define minFloat FLT_MIN
  127. #else
  128. typedef double Float;
  129. #define maxFloat DBL_MAX
  130. #define minFloat DBL_MIN
  131. #endif
  132. /*
  133. ********* define complex type
  134. */
  135. typedef struct {
  136. Float r; /* real part */
  137. Float i; /* imaginary part */
  138. } CPX;
  139. /*
  140. ********* define boolean type
  141. */
  142. typedef int Bool;
  143. #define false 0
  144. #define true 1
  145. /*
  146. ********* Check current platform
  147. */
  148. #define i386
  149. #define MMS_IO
  150. #if defined(__MSDOS__)
  151. #define PC
  152. #define PLATFORM "PC"
  153. #define LSBFIRST
  154. #elif defined(__osf__)
  155. #define OSF
  156. #define PLATFORM "OSF"
  157. #define LSBFIRST
  158. #elif defined(__sun__) || defined(__sun)
  159. #define SUN
  160. #define PLATFORM "SUN"
  161. #undef LSBFIRST
  162. #elif defined(linux) && defined(i386)
  163. #define PC
  164. #define PLATFORM "PC"
  165. #define LSBFIRST
  166. #else
  167. #error "can't determine architecture; adapt typedefs.h to your platform"
  168. #endif
  169. #endif