-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcmtk-2-mingw-w64.patch
161 lines (147 loc) · 4.48 KB
/
dcmtk-2-mingw-w64.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
This file is part of MXE. See LICENSE.md for licensing information.
From 2d08af9a15089c354b436282e4d23f462a81ce8f Mon Sep 17 00:00:00 2001
From: MXE <[email protected]>
Date: Tue, 7 Oct 2014 21:50:59 -0700
Subject: [PATCH] Fix i686-w64-mingw32
Cherry-picked from
https://git.dcmtk.org/?p=dcmtk.git;a=commitdiff;h=b8a53c5f7fd12e9479f830680ef84f93805fd004
diff --git a/config/configure.in b/config/configure.in
index e343ce1..a305114 100644
--- a/config/configure.in
+++ b/config/configure.in
@@ -199,6 +199,10 @@ AC_CHECK_TYPES(longlong)
AC_CHECK_TYPES(ulonglong)
CHECK_VLA
+dnl File access stuff
+AC_CHECK_TYPES(fpos64_t)
+AC_CHECK_TYPES(off64_t)
+
dnl stdbool.h and stdint.h are only defined in ANSI C, not in C++
AC_CHECK_HEADERS(stdbool.h)
AC_CHECK_HEADERS(stdint.h)
@@ -232,6 +236,7 @@ AC_CHECK_FUNCS(sleep fork)
AC_CHECK_FUNCS(_findfirst)
AC_CHECK_FUNCS(strlcpy strlcat)
AC_CHECK_FUNCS(vsnprintf)
+AC_CHECK_FUNCS(popen pclose)
AC_FUNC_FSEEKO
diff --git a/config/include/dcmtk/config/cfunix.h.in b/config/include/dcmtk/config/cfunix.h.in
index 3a6cd69..ed211ca 100644
--- a/config/include/dcmtk/config/cfunix.h.in
+++ b/config/include/dcmtk/config/cfunix.h.in
@@ -157,6 +157,9 @@
/* Define to 1 if you have the `fork' function. */
#undef HAVE_FORK
+/* Define to 1 if the system has the type `fpos64_t'. */
+#undef HAVE_FPOS64_T
+
/* Define to 1 if fseeko (and presumably ftello) exists and is declared. */
#undef HAVE_FSEEKO
@@ -424,14 +427,23 @@ typedef unsigned short ushort;
/* Define to 1 if you have the `ntohs' function. */
#undef HAVE_NTOHS
+/* Define to 1 if the system has the type `off64_t'. */
+#undef HAVE_OFF64_T
+
/* Define if your system supports readdir_r with the obsolete Posix 1.c draft
6 declaration (2 arguments) instead of the Posix 1.c declaration with 3
arguments. */
#undef HAVE_OLD_READDIR_R
+/* Define to 1 if you have the `pclose' function. */
+#undef HAVE_PCLOSE
+
/* Define if pthread_t is a pointer type on your system */
#undef HAVE_POINTER_TYPE_PTHREAD_T
+/* Define to 1 if you have the `popen' function. */
+#undef HAVE_POPEN
+
/* Define if your system has a prototype for accept in sys/types.h
sys/socket.h */
#undef HAVE_PROTOTYPE_ACCEPT
diff --git a/ofstd/include/dcmtk/ofstd/offile.h b/ofstd/include/dcmtk/ofstd/offile.h
index 0f5d454..3f5a677 100644
--- a/ofstd/include/dcmtk/ofstd/offile.h
+++ b/ofstd/include/dcmtk/ofstd/offile.h
@@ -75,26 +75,36 @@ END_EXTERN_C
#endif
#endif
-#if defined(_WIN32) && !defined(__MINGW32__)
- // On Win32 systems except MinGW (where Posix definitions are available)
- // we use Win32 specific definitions
- typedef __int64 offile_off_t;
- typedef fpos_t offile_fpos_t;
+// Explicit LFS (LFS64) and Windows need 64 bit types
+#if defined(EXPLICIT_LFS_64) || defined(_WIN32)
+
+// Use POSIX 64 bit file position type when available
+#ifdef HAVE_FPOS64_T
+typedef fpos64_t offile_fpos_t;
+#else // Otherwise this should be sufficient
+typedef fpos_t offile_fpos_t;
+#endif
+
+// Use POSIX 64 bit file offset type when available
+#ifdef HAVE_OFF64_T
+typedef off64_t offile_off_t;
+#elif !defined(OF_NO_SINT64) // Otherwise use a 64 bit integer
+typedef Sint64 offile_off_t;
+#else // Cry when 64 LFS is required but no 64 bit integer exists
+#error \
+ Could not find a suitable offset-type for LFS64 support.
+#endif
+
+#else // Implicit LFS or no LFS
+
+#ifdef HAVE_FSEEKO
+typedef off_t offile_off_t;
#else
- #ifdef EXPLICIT_LFS_64
- // Explicit LFS (LFS64)
- typedef fpos64_t offile_fpos_t;
- typedef off64_t offile_off_t;
- #else
- // Implicit LFS or no LFS
- #ifdef HAVE_FSEEKO
- typedef off_t offile_off_t;
- #else
- typedef long offile_off_t;
- #endif
- typedef fpos_t offile_fpos_t;
- #endif
+typedef long offile_off_t;
#endif
+typedef fpos_t offile_fpos_t;
+
+#endif // basic type definitions
// the type we use to store the last error.
typedef int offile_errno_t;
@@ -196,10 +206,10 @@ public:
OFBool popen(const char *command, const char *modes)
{
if (file_) fclose();
-#ifdef _WIN32
- file_ = _popen(command, modes);
-#else
+#ifdef HAVE_POPEN
file_ = :: popen(command, modes);
+#else
+ file_ = _popen(command, modes);
#endif
if (file_) popened_ = OFTrue; else storeLastError();
return (file_ != NULL);
@@ -258,10 +268,10 @@ public:
{
if (popened_)
{
-#ifdef _WIN32
- result = _pclose(file_);
-#else
+#ifdef HAVE_PCLOSE
result = :: pclose(file_);
+#else
+ result = _pclose(file_);
#endif
}
else
--
1.8.3.2