xref: /potrace-1.14/src/platform.h (revision b3fce824)
1 /* Copyright (C) 2001-2017 Peter Selinger.
2    This file is part of Potrace. It is free software and it is covered
3    by the GNU General Public License. See the file COPYING for details. */
4 
5 /* this header file contains some platform dependent stuff */
6 
7 #ifndef PLATFORM_H
8 #define PLATFORM_H
9 
10 #ifdef HAVE_CONFIG_H
11 #include <config.h>
12 #endif
13 
14 /* in Windows, set all file i/o to binary */
15 #ifdef __MINGW32__
16 #include <fcntl.h>
17 unsigned int _CRT_fmode = _O_BINARY;
platform_init(void)18 static inline void platform_init(void) {
19   _setmode(_fileno(stdin), _O_BINARY);
20   _setmode(_fileno(stdout), _O_BINARY);
21 }
22 #else
23 
24 #ifdef __CYGWIN__
25 #include <fcntl.h>
26 #include <io.h>
platform_init(void)27 static inline void platform_init(void) {
28   setmode(0,O_BINARY);
29   setmode(1,O_BINARY);
30 }
31 #else
platform_init(void)32 static inline void platform_init(void) {
33   /* NOP */
34 }
35 #endif
36 #endif
37 
38 #endif /* PLATFORM_H */
39