changeset 30787:e10ba171be06

Define HAVE_SETMODE conditionally, and use it in stream/stream_file.c instead of platform specific predefined macros.
author komh
date Thu, 04 Mar 2010 14:46:44 +0000
parents 24c1cedb1de2
children ea3ba0e77acf
files configure stream/stream_file.c
diffstat 2 files changed, 16 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/configure	Thu Mar 04 12:55:30 2010 +0000
+++ b/configure	Thu Mar 04 14:46:44 2010 +0000
@@ -4050,6 +4050,17 @@
 echores "$_setenv"
 
 
+echocheck "setmode()"
+_setmode=no
+def_setmode='#define HAVE_SETMODE 0'
+cat > $TMPC << EOF
+#include <io.h>
+int main(void) { setmode(0, 0); return 0; }
+EOF
+cc_check && _setmode=yes && def_setmode='#define HAVE_SETMODE 1'
+echores "$_setmode"
+
+
 if sunos; then
 echocheck "sysi86()"
 cat > $TMPC << EOF
@@ -8870,6 +8881,7 @@
 $def_posix_select
 $def_select
 $def_setenv
+$def_setmode
 $def_shm
 $def_strsep
 $def_swab
@@ -9225,7 +9237,6 @@
 #define HAVE_LDBRX 0
 #define HAVE_POLL_H 1
 #define HAVE_PPC4XX 0
-#define HAVE_SETMODE 0
 #define HAVE_SYS_SELECT_H 0
 #define HAVE_VFP_ARGS 1
 #define HAVE_VIRTUALALLOC 0
--- a/stream/stream_file.c	Thu Mar 04 12:55:30 2010 +0000
+++ b/stream/stream_file.c	Thu Mar 04 14:46:44 2010 +0000
@@ -145,14 +145,14 @@
       // read from stdin
       mp_msg(MSGT_OPEN,MSGL_INFO,MSGTR_ReadSTDIN);
       f=0; // 0=stdin
-#if defined(__MINGW32__) || defined(__OS2__)
-	  setmode(fileno(stdin),O_BINARY);
+#if HAVE_SETMODE
+      setmode(fileno(stdin),O_BINARY);
 #endif
     } else {
       mp_msg(MSGT_OPEN,MSGL_INFO,"Writing to stdout\n");
       f=1;
-#if defined(__MINGW32__) || defined(__OS2__)
-	  setmode(fileno(stdout),O_BINARY);
+#if HAVE_SETMODE
+      setmode(fileno(stdout),O_BINARY);
 #endif
     }
   } else {