]> granicus.if.org Git - imagemagick/blob - MagickCore/nt-base.h
Fixed warnings for 64 bit build.
[imagemagick] / MagickCore / nt-base.h
1 /*
2   Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization
3   dedicated to making software imaging solutions freely available.
4   
5   You may not use this file except in compliance with the License.
6   obtain a copy of the License at
7   
8     http://www.imagemagick.org/script/license.php
9   
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15
16   MagickCore Windows NT utility methods.
17 */
18 #ifndef _MAGICKCORE_NT_BASE_H
19 #define _MAGICKCORE_NT_BASE_H
20
21 #include "MagickCore/exception.h"
22 #include "MagickCore/geometry.h"
23
24 #if defined(__cplusplus) || defined(c_plusplus)
25 extern "C" {
26 #endif
27
28 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
29
30 #define WIN32_LEAN_AND_MEAN
31 #define VC_EXTRALEAN
32 #define _CRT_SECURE_NO_DEPRECATE  1
33 #include <windows.h>
34 #include <wchar.h>
35 #include <winuser.h>
36 #include <wingdi.h>
37 #include <io.h>
38 #include <process.h>
39 #include <errno.h>
40 #include <malloc.h>
41 #if defined(_DEBUG) && !defined(__MINGW32__) && !defined(__MINGW64__)
42 #include <crtdbg.h>
43 #endif
44
45 #define PROT_READ  0x01
46 #define PROT_WRITE  0x02
47 #define MAP_SHARED  0x01
48 #define MAP_PRIVATE  0x02
49 #define MAP_ANONYMOUS  0x20
50 #define F_OK 0
51 #define R_OK 4
52 #define W_OK 2
53 #define RW_OK 6
54 #define _SC_PAGESIZE 1
55 #define _SC_PHYS_PAGES 2
56 #define _SC_OPEN_MAX 3
57 #if !defined(SSIZE_MAX)
58 #define SSIZE_MAX  0x7fffffffL
59 #endif
60
61 /*
62   _MSC_VER values:
63     1100 MSVC 5.0
64     1200 MSVC 6.0
65     1300 MSVC 7.0 Visual C++ .NET 2002
66     1310 Visual c++ .NET 2003
67     1400 Visual C++ 2005
68     1500 Visual C++ 2008
69 */
70
71 #if !defined(chsize)
72 # if defined(__BORLANDC__)
73 #   define chsize(file,length)  chsize(file,length)
74 # else
75 #   define chsize(file,length)  _chsize(file,length)
76 # endif
77 #endif
78
79 #if !defined(access)
80 #if defined(_VISUALC_) && (_MSC_VER >= 1400)
81 #  define access(path,mode)  _access_s(path,mode)
82 #endif
83 #endif
84 #if !defined(chdir)
85 #  define chdir  _chdir
86 #endif
87 #if !defined(close)
88 #  define close  _close
89 #endif
90 #if !defined(closedir)
91 #  define closedir(directory)  NTCloseDirectory(directory)
92 #endif
93 #if !defined(fdopen)
94 #  define fdopen  _fdopen
95 #endif
96 #if !defined(fileno)
97 #  define fileno  _fileno
98 #endif
99 #if !defined(fseek) && !defined(__MINGW32__) && !defined(__MINGW64__)
100 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
101   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
102 #  define fseek  _fseeki64
103 #endif
104 #endif
105 #if !defined(fstat) && !defined(__BORLANDC__)
106 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
107   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
108 #  define fstat  _fstati64
109 #else
110 #  define fstat  _fstat
111 #endif
112 #endif
113 #if !defined(fsync)
114 #  define fsync  _commit
115 #endif
116 #if !defined(ftell) && !defined(__MINGW32__) && !defined(__MINGW64__)
117 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
118   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
119 #  define ftell  _ftelli64
120 #endif
121 #endif
122 #if !defined(ftruncate)
123 #  define ftruncate(file,length)  NTTruncateFile(file,length)
124 #endif
125 #if !defined(getcwd)
126 #  define getcwd  _getcwd
127 #endif
128 #if !defined(getpid)
129 #  define getpid  _getpid
130 #endif
131 #if !defined(hypot)
132 #  define hypot  _hypot
133 #endif
134 #if !defined(inline)
135 #  define inline __inline
136 #endif
137 #if !defined(isatty)
138 #  define isatty  _isatty
139 #endif
140 #if !defined(locale_t)
141 #define locale_t _locale_t
142 #endif
143 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
144   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
145 #if !defined(lseek)
146 #  define lseek  _lseeki64
147 #endif
148 #else
149 #if !defined(lseek)
150 #  define lseek  _lseek
151 #endif
152 #endif
153 #if !defined(MAGICKCORE_LTDL_DELEGATE)
154 #if !defined(lt_dlclose)
155 #  define lt_dlclose(handle)  NTCloseLibrary(handle)
156 #endif
157 #if !defined(lt_dlerror)
158 #  define lt_dlerror()  NTGetLibraryError()
159 #endif
160 #if !defined(lt_dlexit)
161 #  define lt_dlexit()  NTExitLibrary()
162 #endif
163 #if !defined(lt_dlinit)
164 #  define lt_dlinit()  NTInitializeLibrary()
165 #endif
166 #if !defined(lt_dlopen)
167 #  define lt_dlopen(filename)  NTOpenLibrary(filename)
168 #endif
169 #if !defined(lt_dlsetsearchpath)
170 #  define lt_dlsetsearchpath(path)  NTSetSearchPath(path)
171 #endif
172 #if !defined(lt_dlsym)
173 #  define lt_dlsym(handle,name)  NTGetLibrarySymbol(handle,name)
174 #endif
175 #endif
176 #if !defined(mkdir)
177 #  define mkdir  _mkdir
178 #endif
179 #if !defined(mmap)
180 #  define mmap(address,length,protection,access,file,offset) \
181   NTMapMemory(address,length,protection,access,file,offset)
182 #endif
183 #if !defined(msync)
184 #  define msync(address,length,flags)  NTSyncMemory(address,length,flags)
185 #endif
186 #if !defined(munmap)
187 #  define munmap(address,length)  NTUnmapMemory(address,length)
188 #endif
189 #if !defined(opendir)
190 #  define opendir(directory)  NTOpenDirectory(directory)
191 #endif
192 #if !defined(open)
193 #  define open  _open
194 #endif
195 #if !defined(pclose)
196 #  define pclose  _pclose
197 #endif
198 #if !defined(popen)
199 #  define popen  _popen
200 #endif
201 #if !defined(fprintf_l)
202 #define fprintf_l  _fprintf_s_l
203 #endif
204 #if !defined(read)
205 #  define read(fd,buffer,count)  _read(fd,buffer,(unsigned int) count)
206 #endif
207 #if !defined(readdir)
208 #  define readdir(directory)  NTReadDirectory(directory)
209 #endif
210 #if !defined(seekdir)
211 #  define seekdir(directory,offset)  NTSeekDirectory(directory,offset)
212 #endif
213 #if !defined(setmode)
214 #  define setmode  _setmode
215 #endif
216 #if !defined(spawnvp)
217 #  define spawnvp  _spawnvp
218 #endif
219 #if !defined(strtod_l)
220 #define strtod_l  _strtod_l
221 #endif
222 #if !defined(stat) && !defined(__BORLANDC__)
223 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
224   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
225 #  define stat  _stati64
226 #else
227 #  define stat  _stat
228 #endif
229 #endif
230 #if !defined(strcasecmp)
231 #  define strcasecmp  _stricmp
232 #endif
233 #if !defined(strncasecmp)
234 #  define strncasecmp  _strnicmp
235 #endif
236 #if !defined(sysconf)
237 #  define sysconf(name)  NTSystemConfiguration(name)
238 #endif
239 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
240   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
241 #  define tell  _telli64
242 #else
243 #  define tell  _tell
244 #endif
245 #if !defined(telldir)
246 #  define telldir(directory)  NTTellDirectory(directory)
247 #endif
248 #if !defined(tempnam)
249 #  define tempnam  _tempnam_s
250 #endif
251 #if !defined(vfprintf_l)
252 #define vfprintf_l  _vfprintf_l
253 #endif
254 #if !defined(vsnprintf)
255 #if !defined(_MSC_VER) || (defined(_MSC_VER) && _MSC_VER < 1500)
256 #define vsnprintf _vsnprintf 
257 #endif
258 #endif
259 #if !defined(vsnprintf_l)
260 #define vsnprintf_l  _vsnprintf_l
261 #endif
262 #if !defined(write)
263 #  define write(fd,buffer,count)  _write(fd,buffer,(unsigned int) count)
264 #endif
265 #if !defined(wstat) && !defined(__BORLANDC__)
266 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !defined(Windows95) && \
267   !(defined(_MSC_VER) && (_MSC_VER < 1400)) && (__MSVCRT_VERSION__ < 0x800)
268 #  define wstat  _wstati64
269 #else
270 #  define wstat  _wstat
271 #endif
272 #endif
273
274 #if defined(__BORLANDC__)
275 #undef _O_RANDOM
276 #define _O_RANDOM 0
277 #undef _O_SEQUENTIAL
278 #define _O_SEQUENTIAL 0
279 #undef _O_SHORT_LIVED
280 #define _O_SHORT_LIVED 0
281 #undef _O_TEMPORARY
282 #define _O_TEMPORARY 0
283 #endif
284
285 #undef gettimeofday
286
287 typedef struct _GhostInfo
288   GhostInfo_;
289
290 extern MagickExport char
291   **NTArgvToUTF8(const int argc,wchar_t **);
292
293 extern MagickExport const GhostInfo_
294   *NTGhostscriptDLLVectors(void);
295
296 extern MagickExport int
297   NTGhostscriptUnLoadDLL(void);
298
299 extern MagickExport void
300   NTErrorHandler(const ExceptionType,const char *,const char *),
301   NTWarningHandler(const ExceptionType,const char *,const char *);
302 #endif
303
304 #if defined(__cplusplus) || defined(c_plusplus)
305 }
306 #endif
307
308 #endif