win32config.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * Summary: Windows configuration header
  3. * Description: Windows configuration header
  4. *
  5. * Copy: See Copyright for the status of this software.
  6. *
  7. * Author: Igor Zlatkovic
  8. */
  9. #ifndef __LIBXSLT_WIN32_CONFIG__
  10. #define __LIBXSLT_WIN32_CONFIG__
  11. #define HAVE_CTYPE_H 1
  12. #define HAVE_STDLIB_H 1
  13. #define HAVE_STDARG_H 1
  14. #define HAVE_MALLOC_H 1
  15. #define HAVE_TIME_H 1
  16. #define HAVE_LOCALTIME 1
  17. #define HAVE_GMTIME 1
  18. #define HAVE_TIME 1
  19. #define HAVE_MATH_H 1
  20. #define HAVE_FCNTL_H 1
  21. #include <io.h>
  22. #define HAVE_ISINF
  23. #define HAVE_ISNAN
  24. #include <math.h>
  25. #ifdef _WIN32
  26. /* MS C-runtime has functions which can be used in order to determine if
  27. a given floating-point variable contains NaN, (+-)INF. These are
  28. preferred, because floating-point technology is considered propriatary
  29. by MS and we can assume that their functions know more about their
  30. oddities than we do. */
  31. #include <float.h>
  32. /* Bjorn Reese figured a quite nice construct for isinf() using the
  33. _fpclass() function. */
  34. #ifndef isinf
  35. #define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \
  36. : ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
  37. #endif
  38. /* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */
  39. #ifndef isnan
  40. #define isnan(d) (_isnan(d))
  41. #endif
  42. #else /* _MSC_VER */
  43. static int isinf (double d) {
  44. int expon = 0;
  45. double val = frexp (d, &expon);
  46. if (expon == 1025) {
  47. if (val == 0.5) {
  48. return 1;
  49. } else if (val == -0.5) {
  50. return -1;
  51. } else {
  52. return 0;
  53. }
  54. } else {
  55. return 0;
  56. }
  57. }
  58. static int isnan (double d) {
  59. int expon = 0;
  60. double val = frexp (d, &expon);
  61. if (expon == 1025) {
  62. if (val == 0.5) {
  63. return 0;
  64. } else if (val == -0.5) {
  65. return 0;
  66. } else {
  67. return 1;
  68. }
  69. } else {
  70. return 0;
  71. }
  72. }
  73. #endif /* _MSC_VER */
  74. #include <direct.h>
  75. /* snprintf emulation taken from http://stackoverflow.com/a/8712996/1956010 */
  76. #if defined(_MSC_VER) && _MSC_VER < 1900
  77. #include <stdarg.h>
  78. #include <stdio.h>
  79. #define snprintf c99_snprintf
  80. #define vsnprintf c99_vsnprintf
  81. __inline int c99_vsnprintf(char *outBuf, size_t size, const char *format, va_list ap)
  82. {
  83. int count = -1;
  84. if (size != 0)
  85. count = _vsnprintf_s(outBuf, size, _TRUNCATE, format, ap);
  86. if (count == -1)
  87. count = _vscprintf(format, ap);
  88. return count;
  89. }
  90. __inline int c99_snprintf(char *outBuf, size_t size, const char *format, ...)
  91. {
  92. int count;
  93. va_list ap;
  94. va_start(ap, format);
  95. count = c99_vsnprintf(outBuf, size, format, ap);
  96. va_end(ap);
  97. return count;
  98. }
  99. #endif /* defined(_MSC_VER) && _MSC_VER < 1900 */
  100. #define HAVE_SYS_STAT_H
  101. #define HAVE_STAT
  102. #define HAVE_STRING_H
  103. #include <libxml/xmlversion.h>
  104. #ifndef ATTRIBUTE_UNUSED
  105. #define ATTRIBUTE_UNUSED
  106. #endif
  107. #define _WINSOCKAPI_
  108. #endif /* __LIBXSLT_WIN32_CONFIG__ */