bug-gnu-chess
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Building GNU Chess 5.07 on MinGW/gcc


From: Anders Carlsson
Subject: Building GNU Chess 5.07 on MinGW/gcc
Date: 17 Jan 2004 16:52:54 +0100

Simon Waters <address@hidden> writes:

> Send a bug report to bug-gnu-chess, it isn't a target
> platform but if we can fit it in without too much grief.

I have now managed to successfully compile GNU Chess 5.07 on MinGW.
Besides getting bison and flex, the following adaptions were taken:

1. MinGW lacks native threading, but the Win32-port of Pthreads 
   builds on MinGW/GCC (or on MSVC for that matter). This port 
   names its libraries libpthreadGC.a etc. Thus, the user has to 
   symlink libpthreads.a to the suitable library version installed. 
   The runtime is a DLL which obviously has to be in the path. It 
   is possible to build Pthreads-Win32 statically too, although I 
   haven't tried it.

   Also, for some reason I had to move the "-lpthreads" parameter
   from PTHREAD_LIBS to LIBS in the Makefile to get it in the right
   end of the GCC (3.2.3) call and link properly.

2. There is no BSD style gettimeofday() call in MinGW. Inspired
   by this GDB mailing list message, I solved it as follows:

   http://sources.redhat.com/ml/gdb/2001-05/msg00076.html

---- In common.h after #include <sys/time>, I added the following:

   /* These are winbase.h definitions, but to avoid including
      tons of Windows related stuff, it is reprinted here  */
   typedef struct _FILETIME {
        unsigned long dwLowDateTime;
        unsigned long dwHighDateTime;
   } FILETIME;
   void __stdcall GetSystemTimeAsFileTime(FILETIME*);
   
   void gettimeofday(struct timeval* p, void* tz /* IGNORED */);

---- and into main.c, I put the actual gettimeofday function:

   void gettimeofday(struct timeval* p, void* tz /* IGNORED */){
     union {
       long long ns100; /*time since 1 Jan 1601 in 100ns units */
       FILETIME ft;
     } _now;

     GetSystemTimeAsFileTime( &(_now.ft) );
     p->tv_usec=(long)((_now.ns100 / 10LL) % 1000000LL );
     p->tv_sec= (long)((_now.ns100-(116444736000000000LL))/10000000LL);
     return;
   }

----

Now GNU Chess compiles and runs also in Windows/DOS. However, this 
GCC generated binary is 276 kB compiled (excl. pthreads runtime) 
compared to the one on the other webpage which is 57 kB using MVSC.
I would believe it is faster than a Cygwin generated one, but maybe 
slower than the MVSC.

I don't know how to adopt these changes to the build structure, 
but in case anyone of the GNU Chess developers wants to try it for
themselves, they have an idea how to go ahead.

> The main current issue is a bug subsequently found in the thread
> handling,

Would this bug explain the odd thread handling I encountered on 
the outdated AIX 4.2 platform, or are those separate issues?

-- 
Anders Carlsson




reply via email to

[Prev in Thread] Current Thread [Next in Thread]