Skip to content

Commit

Permalink
[runtime/stdio] fix win32 defs (#26)
Browse files Browse the repository at this point in the history
* [runtime/stdio] fix win32 defs

* [runtime/util] remove duplicate functions
  • Loading branch information
xoviat committed Dec 23, 2017
1 parent 1e54c29 commit 1922a57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 32 deletions.
32 changes: 0 additions & 32 deletions runtime/flang/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,38 +604,6 @@ __fortio_trunc(FIO_FCB *p, seekoffx_t length)
}

#ifdef _WIN32
int
__fortio_binary_mode(void *fp)
{
#if defined(WINNT)
#include <fcntl.h>

#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);
Expand Down
7 changes: 7 additions & 0 deletions runtime/include/stdioInterf.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
#endif
#include <stdlib.h>

/* 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)
Expand Down

0 comments on commit 1922a57

Please sign in to comment.