1066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#ifndef __LIBXML_WIN32_CONFIG__
2066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define __LIBXML_WIN32_CONFIG__
3066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
4066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_CTYPE_H
5066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_STDARG_H
6066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_MALLOC_H
7066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_ERRNO_H
8066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_STDINT_H
9066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
10066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#if defined(_WIN32_WCE)
11066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#undef HAVE_ERRNO_H
12066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#include <windows.h>
13066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#include "wincecompat.h"
14066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#else
15066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_SYS_STAT_H
16066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE__STAT
17066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_STAT
18066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_STDLIB_H
19066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_TIME_H
20066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_FCNTL_H
21066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#include <io.h>
22066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#include <direct.h>
23066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
24066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
25066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#include <libxml/xmlversion.h>
26066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
27066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#ifndef ICONV_CONST
28066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define ICONV_CONST const
29066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
30066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
31066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#ifdef NEED_SOCKETS
32066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#include <wsockcompat.h>
33066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
34066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
35066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm/*
36066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm * Windows platforms may define except
37066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm */
38066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#undef except
39066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
40066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_ISINF
41066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_ISNAN
42066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#include <math.h>
43066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#if defined(_MSC_VER) || defined(__BORLANDC__)
44066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm/* MS C-runtime has functions which can be used in order to determine if
45066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm   a given floating-point variable contains NaN, (+-)INF. These are
46066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm   preferred, because floating-point technology is considered propriatary
47066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm   by MS and we can assume that their functions know more about their
48066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm   oddities than we do. */
49066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#include <float.h>
50066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm/* Bjorn Reese figured a quite nice construct for isinf() using the _fpclass
51066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm   function. */
52066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#ifndef isinf
53066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define isinf(d) ((_fpclass(d) == _FPCLASS_PINF) ? 1 \
54066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm	: ((_fpclass(d) == _FPCLASS_NINF) ? -1 : 0))
55066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
56066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm/* _isnan(x) returns nonzero if (x == NaN) and zero otherwise. */
57066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#ifndef isnan
58066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define isnan(d) (_isnan(d))
59066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
60066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#else /* _MSC_VER */
61066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#ifndef isinf
62066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemmstatic int isinf (double d) {
63066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm    int expon = 0;
64066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm    double val = frexp (d, &expon);
65066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm    if (expon == 1025) {
66066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm        if (val == 0.5) {
67066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm            return 1;
68066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm        } else if (val == -0.5) {
69066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm            return -1;
70066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm        } else {
71066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm            return 0;
72066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm        }
73066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm    } else {
74066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm        return 0;
75066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm    }
76066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm}
77066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
78066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#ifndef isnan
79066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemmstatic int isnan (double d) {
80066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm    int expon = 0;
81066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm    double val = frexp (d, &expon);
82066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm    if (expon == 1025) {
83066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm        if (val == 0.5) {
84066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm            return 0;
85066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm        } else if (val == -0.5) {
86066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm            return 0;
87066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm        } else {
88066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm            return 1;
89066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm        }
90066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm    } else {
91066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm        return 0;
92066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm    }
93066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm}
94066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
95066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif /* _MSC_VER */
96066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
97066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#if defined(_MSC_VER)
98066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define mkdir(p,m) _mkdir(p)
99dfbacd4f417cb0f4b9bef3ff205bf95cb73c5717Bruce Dawson#if _MSC_VER < 1900 // Cannot define this in VS 2015 and above!
100066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define snprintf _snprintf
101dfbacd4f417cb0f4b9bef3ff205bf95cb73c5717Bruce Dawson#endif
102066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#if _MSC_VER < 1500
103066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define vsnprintf(b,c,f,a) _vsnprintf(b,c,f,a)
104066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
105066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#elif defined(__MINGW32__)
106066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define mkdir(p,m) _mkdir(p)
107066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
108066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
109066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm/* Threading API to use should be specified here for compatibility reasons.
110066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm   This is however best specified on the compiler's command-line. */
111066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#if defined(LIBXML_THREAD_ENABLED)
112066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#if !defined(HAVE_PTHREAD_H) && !defined(HAVE_WIN32_THREADS) && !defined(_WIN32_WCE)
113066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define HAVE_WIN32_THREADS
114066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
115066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
116066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
117066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm/* Some third-party libraries far from our control assume the following
118066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm   is defined, which it is not if we don't include windows.h. */
119066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#if !defined(FALSE)
120066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define FALSE 0
121066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
122066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#if !defined(TRUE)
123066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#define TRUE (!(FALSE))
124066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif
125066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
126066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm#endif /* __LIBXML_WIN32_CONFIG__ */
127066c69777207436e3517d1b930a97f0e0a8aa060Thomas Lemm
128