diff --git a/runtime/flang/utils.c b/runtime/flang/utils.c index 6cae64eca21..d57167ce8e0 100644 --- a/runtime/flang/utils.c +++ b/runtime/flang/utils.c @@ -604,38 +604,6 @@ __fortio_trunc(FIO_FCB *p, seekoffx_t length) } #ifdef _WIN32 -int -__fortio_binary_mode(void *fp) -{ -#if defined(WINNT) -#include - -#if defined(WIN64) || defined(WIN32) -#define O_BINARY _O_BINARY -#endif - - int mode; - - mode = setmode(fileno((FILE *)fp), O_BINARY); - if (mode == -1) { - /* The mode argument is clearly legal, so this should not - * happen. But, in a console app, setmode will fail on - * the fd representing stdout. - */ - return 0; - } - (void)setmode(fileno((FILE *)fp), mode); - return (mode & O_BINARY); -#else - return 1; -#endif -} - -void -__fortio_setmode_binary(FILE *f) { - _setmode(_fileno(f), _O_BINARY); -} - void sincos(double x, double *sine, double *cosine) { *sine = sin(x); diff --git a/runtime/include/stdioInterf.h b/runtime/include/stdioInterf.h index 4391ec8668f..ab7226ad6ae 100644 --- a/runtime/include/stdioInterf.h +++ b/runtime/include/stdioInterf.h @@ -24,6 +24,13 @@ #endif #include +/* for some reason these are not correctly defined on WIN32 */ +#ifdef _WIN32 +#define __fortio_setmode_binary __io_setmode_binary +#define __fortio_binary_mode __io_binary_mode + +#endif + /* defines to use real host stdio routines */ #define __io_fclose(fp) fclose(fp)