config.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #ifndef __LIBXML_WIN32_CONFIG__
  2. #define __LIBXML_WIN32_CONFIG__
  3. #define HAVE_CTYPE_H
  4. #define HAVE_STDARG_H
  5. #define HAVE_MALLOC_H
  6. #define HAVE_ERRNO_H
  7. #define HAVE_STDINT_H
  8. #if defined(_WIN32_WCE)
  9. #undef HAVE_ERRNO_H
  10. #include "wincecompat.h"
  11. #else
  12. #define HAVE_SYS_STAT_H
  13. #define HAVE_STAT
  14. #define HAVE_STDLIB_H
  15. #define HAVE_TIME_H
  16. #define HAVE_FCNTL_H
  17. #include <io.h>
  18. #include <direct.h>
  19. #endif
  20. #include <libxml/xmlversion.h>
  21. #ifndef ICONV_CONST
  22. #define ICONV_CONST const
  23. #endif
  24. /*
  25. * Windows platforms may define except
  26. */
  27. #undef except
  28. #define HAVE_ISINF
  29. #define HAVE_ISNAN
  30. #include <math.h>
  31. #if defined(_MSC_VER) || defined(__BORLANDC__)
  32. /* MS C-runtime has functions which can be used in order to determine if
  33. a given floating-point variable contains NaN, (+-)INF. These are
  34. preferred, because floating-point technology is considered proprietary
  35. by MS and we can assume that their functions know more about their
  36. oddities than we do. */
  37. #include <float.h>
  38. /* Bjorn Reese figured a quite nice construct for isinf() using the _fpclass
  39. function. */
  40. #ifndef isinf
  41. #define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \
  42. : ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
  43. #endif
  44. /* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */
  45. #ifndef isnan
  46. #define isnan(d) (_isnan(d))
  47. #endif
  48. #else /* _MSC_VER */
  49. #ifndef isinf
  50. static int isinf (double d) {
  51. int expon = 0;
  52. double val = frexp (d, &expon);
  53. if (expon == 1025) {
  54. if (val == 0.5) {
  55. return 1;
  56. } else if (val == -0.5) {
  57. return -1;
  58. } else {
  59. return 0;
  60. }
  61. } else {
  62. return 0;
  63. }
  64. }
  65. #endif
  66. #ifndef isnan
  67. static int isnan (double d) {
  68. int expon = 0;
  69. double val = frexp (d, &expon);
  70. if (expon == 1025) {
  71. if (val == 0.5) {
  72. return 0;
  73. } else if (val == -0.5) {
  74. return 0;
  75. } else {
  76. return 1;
  77. }
  78. } else {
  79. return 0;
  80. }
  81. }
  82. #endif
  83. #endif /* _MSC_VER */
  84. #if defined(_MSC_VER)
  85. #define mkdir(p,m) _mkdir(p)
  86. #if _MSC_VER < 1900 // Cannot define this in VS 2015 and above!
  87. #define snprintf _snprintf
  88. #endif
  89. #if _MSC_VER < 1500
  90. #define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
  91. #endif
  92. #elif defined(__MINGW32__)
  93. #define mkdir(p,m) _mkdir(p)
  94. #endif
  95. /* Threading API to use should be specified here for compatibility reasons.
  96. This is however best specified on the compiler's command-line. */
  97. #if defined(LIBXML_THREAD_ENABLED)
  98. #if !defined(HAVE_PTHREAD_H) && !defined(HAVE_WIN32_THREADS) && !defined(_WIN32_WCE)
  99. #define HAVE_WIN32_THREADS
  100. #endif
  101. #endif
  102. /* Some third-party libraries far from our control assume the following
  103. is defined, which it is not if we don't include windows.h. */
  104. #if !defined(FALSE)
  105. #define FALSE 0
  106. #endif
  107. #if !defined(TRUE)
  108. #define TRUE (!(FALSE))
  109. #endif
  110. #endif /* __LIBXML_WIN32_CONFIG__ */