#define small_ushort unsigned char
-typedef small_short BYTE;
typedef small_ushort UBYTE;
typedef short SHORT;
typedef unsigned short USHORT;
#include <sys/param.h>
#include <sys/types.h>
-#include <sys/times.h>
-#include <sys/ioctl.h>
-
+#ifdef WIN32
+# include <windows.h>
+#else
+ typedef small_short BYTE;
+# include <sys/times.h>
+# include <sys/ioctl.h>
+#endif
#if TIME_WITH_SYS_TIME
# include <sys/time.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/file.h>
+#ifndef WIN32
#include <poll.h>
#include <unistd.h>
+#endif
#include "gnushogi.h"
#include "rawdsp.h"
if (XSHOGI)
{
+#ifdef WIN32
+ /* needed because of inconsistency between MSVC run-time system and gcc includes */
+ setbuf(stdout, NULL);
+#else
#ifdef HAVE_SETLINEBUF
setlinebuf(stdout);
#else
# error "Need setlinebuf() or setvbuf() to compile gnushogi!"
# endif
#endif
+#endif
printf("GNU Shogi %s\n", PACKAGE_VERSION);
}
void
Raw_PollForInput(void)
{
+#ifdef WIN32
+ DWORD cnt;
+ if (!PeekNamedPipe(GetStdHandle(STD_INPUT_HANDLE), NULL, 0, NULL, &cnt, NULL))
+ cnt = 1;
+#else
static struct pollfd pollfds[1] = { /* [0] = */ { /* .fd = */ STDIN_FILENO,
/* .events = */ POLLIN } };
int cnt = poll(pollfds, sizeof(pollfds)/sizeof(pollfds[0]), 0);
perror("polling standard input");
ExitShogi();
}
+#endif
if (cnt) { /* if anything to read, or error occured */
if (!flag.timeout)
flag.back = true; /* previous: flag.timeout = true; */