typedef.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /***********************************************************************
  2. Copyright (c) 2006-2012 IETF Trust and Skype Limited. All rights reserved.
  3. This file is extracted from RFC6716. Please see that RFC for additional
  4. information.
  5. Redistribution and use in source and binary forms, with or without
  6. modification, are permitted provided that the following conditions
  7. are met:
  8. - Redistributions of source code must retain the above copyright notice,
  9. this list of conditions and the following disclaimer.
  10. - Redistributions in binary form must reproduce the above copyright
  11. notice, this list of conditions and the following disclaimer in the
  12. documentation and/or other materials provided with the distribution.
  13. - Neither the name of Internet Society, IETF or IETF Trust, nor the
  14. names of specific contributors, may be used to endorse or promote
  15. products derived from this software without specific prior written
  16. permission.
  17. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
  18. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19. IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
  21. LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  22. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  23. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  24. INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  25. CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  27. POSSIBILITY OF SUCH DAMAGE.
  28. ***********************************************************************/
  29. #ifndef SILK_TYPEDEF_H
  30. #define SILK_TYPEDEF_H
  31. #include "opus_types.h"
  32. #ifndef silk_USE_DOUBLE_PRECISION_FLOATS
  33. #define silk_USE_DOUBLE_PRECISION_FLOATS 0
  34. #endif
  35. #include <float.h>
  36. #if defined( __GNUC__ )
  37. #include <stdint.h>
  38. #endif
  39. #define silk_int_ptr_size intptr_t
  40. #if silk_USE_DOUBLE_PRECISION_FLOATS
  41. # define silk_float double
  42. # define silk_float_MAX DBL_MAX
  43. #else
  44. # define silk_float float
  45. # define silk_float_MAX FLT_MAX
  46. #endif
  47. #ifdef _WIN32
  48. # define silk_STR_CASEINSENSITIVE_COMPARE(x, y) _stricmp(x, y)
  49. #else
  50. # define silk_STR_CASEINSENSITIVE_COMPARE(x, y) strcasecmp(x, y)
  51. #endif
  52. #define silk_int64_MAX ((opus_int64)0x7FFFFFFFFFFFFFFFLL) /* 2^63 - 1 */
  53. #define silk_int64_MIN ((opus_int64)0x8000000000000000LL) /* -2^63 */
  54. #define silk_int32_MAX 0x7FFFFFFF /* 2^31 - 1 = 2147483647 */
  55. #define silk_int32_MIN ((opus_int32)0x80000000) /* -2^31 = -2147483648 */
  56. #define silk_int16_MAX 0x7FFF /* 2^15 - 1 = 32767 */
  57. #define silk_int16_MIN ((opus_int16)0x8000) /* -2^15 = -32768 */
  58. #define silk_int8_MAX 0x7F /* 2^7 - 1 = 127 */
  59. #define silk_int8_MIN ((opus_int8)0x80) /* -2^7 = -128 */
  60. #define silk_uint32_MAX 0xFFFFFFFF /* 2^32 - 1 = 4294967295 */
  61. #define silk_uint32_MIN 0x00000000
  62. #define silk_uint16_MAX 0xFFFF /* 2^16 - 1 = 65535 */
  63. #define silk_uint16_MIN 0x0000
  64. #define silk_uint8_MAX 0xFF /* 2^8 - 1 = 255 */
  65. #define silk_uint8_MIN 0x00
  66. #define silk_TRUE 1
  67. #define silk_FALSE 0
  68. /* assertions */
  69. #if (defined _WIN32 && !defined _WINCE && !defined(__GNUC__) && !defined(NO_ASSERTS))
  70. # ifndef silk_assert
  71. # include <crtdbg.h> /* ASSERTE() */
  72. # define silk_assert(COND) _ASSERTE(COND)
  73. # endif
  74. #else
  75. # ifdef ENABLE_ASSERTIONS
  76. # include <stdio.h>
  77. # include <stdlib.h>
  78. #define silk_fatal(str) _silk_fatal(str, __FILE__, __LINE__);
  79. #ifdef __GNUC__
  80. __attribute__((noreturn))
  81. #endif
  82. static inline void _silk_fatal(const char *str, const char *file, int line)
  83. {
  84. fprintf (stderr, "Fatal (internal) error in %s, line %d: %s\n", file, line, str);
  85. abort();
  86. }
  87. # define silk_assert(COND) {if (!(COND)) {silk_fatal("assertion failed: " #COND);}}
  88. # else
  89. # define silk_assert(COND)
  90. # endif
  91. #endif
  92. #endif /* SILK_TYPEDEF_H */