Skip to content

Commit 1922a57

Browse files
committed
[runtime/stdio] fix win32 defs (#26)
* [runtime/stdio] fix win32 defs * [runtime/util] remove duplicate functions
1 parent 1e54c29 commit 1922a57

File tree

2 files changed

+7
-32
lines changed

2 files changed

+7
-32
lines changed

runtime/flang/utils.c

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -604,38 +604,6 @@ __fortio_trunc(FIO_FCB *p, seekoffx_t length)
604604
}
605605

606606
#ifdef _WIN32
607-
int
608-
__fortio_binary_mode(void *fp)
609-
{
610-
#if defined(WINNT)
611-
#include <fcntl.h>
612-
613-
#if defined(WIN64) || defined(WIN32)
614-
#define O_BINARY _O_BINARY
615-
#endif
616-
617-
int mode;
618-
619-
mode = setmode(fileno((FILE *)fp), O_BINARY);
620-
if (mode == -1) {
621-
/* The mode argument is clearly legal, so this should not
622-
* happen. But, in a console app, setmode will fail on
623-
* the fd representing stdout.
624-
*/
625-
return 0;
626-
}
627-
(void)setmode(fileno((FILE *)fp), mode);
628-
return (mode & O_BINARY);
629-
#else
630-
return 1;
631-
#endif
632-
}
633-
634-
void
635-
__fortio_setmode_binary(FILE *f) {
636-
_setmode(_fileno(f), _O_BINARY);
637-
}
638-
639607
void
640608
sincos(double x, double *sine, double *cosine) {
641609
*sine = sin(x);

runtime/include/stdioInterf.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@
2424
#endif
2525
#include <stdlib.h>
2626

27+
/* for some reason these are not correctly defined on WIN32 */
28+
#ifdef _WIN32
29+
#define __fortio_setmode_binary __io_setmode_binary
30+
#define __fortio_binary_mode __io_binary_mode
31+
32+
#endif
33+
2734
/* defines to use real host stdio routines */
2835

2936
#define __io_fclose(fp) fclose(fp)

0 commit comments

Comments
 (0)