[CLN-list] CLN on MinGW -- patch

Sheplyakov Alexei varg at theor.jinr.ru
Fri Aug 12 16:48:57 CEST 2005


On Fri, Jul 29, 2005 at 04:38:16PM +1000, John Pye wrote:
> Just wanted to ask if anyone's succeeded in building CLN on MinGW / MSYS
> ? Is this something that other people have shown an interest in?
> 
> I get the following error when I try to ./configure && make:
> 
> >  g++ -g -O2 -I../include -I../include -I./base -Ibase -c
> > ./base/random/cl_random_from.cc  -DDLL_EXPORT -DPIC -o
> > .libs/cl_random_from.o
> > ./base/random/cl_random_from.cc: *In constructor
> > `cln::random_state::random_state()':*
> > ./base/random/cl_random_from.cc:68: *error: `::get_seed' has not been
> > declared*
> > make[3]: *** [cl_random_from.lo] Error 1

Try using using attached patch. Note: the code compiles and no test
seems to fail, but I'm not sure if my implementation of get_seed() is
good enough.



Best regards,
  Alexei

-------------- next part --------------
diff -Nru cln-1.1.9-orig/src/base/random/cl_random_from.cc cln-1.1.9/src/base/random/cl_random_from.cc
--- cln-1.1.9-orig/src/base/random/cl_random_from.cc	2004-06-24 01:04:49.000000000 +0400
+++ cln-1.1.9/src/base/random/cl_random_from.cc	2005-08-12 18:23:11.000000000 +0400
@@ -1,5 +1,9 @@
 // random_state constructor.
 
+#if defined(_WIN32) // it _wants_ to be the first header...
+#include <windows.h>
+#endif
+
 // General includes.
 #include "cl_sysdep.h"
 
@@ -11,12 +15,21 @@
 
 #include "cl_base_config.h"
 #include "cl_low.h"
+#include <cstdlib> // declares rand()
+
+#if defined(_WIN32)
+inline uint32 get_seed()
+{
+	LARGE_INTEGER pcnt; // performance counter value
+	QueryPerformanceCounter(&pcnt);
+        pcnt.QuadPart << 16;
+	return (uint32)(pcnt.HighPart | pcnt.LowPart);
+}
 
-#if defined(unix) || defined(__unix) || defined(_AIX) || defined(sinix) || (defined(__MACH__) && defined(__APPLE__)) || (defined(_WIN32) && defined(__GNUC__)) || defined(__BEOS__)
+#elif defined(unix) || defined(__unix) || defined(_AIX) || defined(sinix) || (defined(__MACH__) && defined(__APPLE__)) || (defined(__CYGWIN__) && defined(__GNUC__)) || defined(__BEOS__)
 
 #include <sys/types.h>
 #include <unistd.h> // declares getpid()
-#include <cstdlib>  // declares rand()
 
 #if defined(HAVE_GETTIMEOFDAY)
 
@@ -64,10 +77,13 @@
 {
 	var uint32 seed_hi;
 	var uint32 seed_lo;
-#if defined(unix) || defined(__unix) || defined(_AIX) || defined(sinix) || (defined(__MACH__) && defined(__APPLE__)) || (defined(_WIN32) && defined(__GNUC__)) || defined(__BEOS__)
+#if defined(unix) || defined(__unix) || defined(_AIX) || defined(sinix) || (defined(__MACH__) && defined(__APPLE__)) || (defined(__CYGWIN__) && defined(__GNUC__)) || defined(__BEOS__)
 	seed_lo = ::get_seed();
 	seed_hi = (rand() // zuf?ige 31 Bit (bei UNIX_BSD) bzw. 16 Bit (bei UNIX_SYSV)
                           << 8) ^ (uintL)(getpid()); // ca. 8 Bit von der Process ID
+#elif defined(_WIN32)
+	seed_lo = ::get_seed();
+	seed_hi = (rand() << 8) ^ (uintL)(GetCurrentProcessId());
 #elif defined(__atarist)
 	seed_lo = highlow32(GEMDOS_GetDate(),GEMDOS_GetTime()); // 16+16 zuf?ige Bits
 	seed_hi = XBIOS_Random(); // 24 Bit zuf?ig vom XBIOS, vorne 8 Nullbits
diff -Nru cln-1.1.9-orig/src/Makefile.in cln-1.1.9/src/Makefile.in
--- cln-1.1.9-orig/src/Makefile.in	2004-11-03 23:56:50.000000000 +0300
+++ cln-1.1.9/src/Makefile.in	2005-08-12 18:23:36.000000000 +0400
@@ -203,7 +203,7 @@
 $(ALLOBJECTS_LO) : $(SUBDIRS_TARGET)
 
 libcln.la : $(LIBTOOL) $(ALLOBJECTS_LO)
-	$(LIBTOOL_LINK) $(CC) -o libcln.la -rpath $(libdir) -version-info $(CL_CURRENT):$(CL_REVISION):$(CL_AGE) $(LDFLAGS) $(LIBS) $(ALLOBJECTS_LO)
+	$(LIBTOOL_LINK) $(CXX) -o libcln.la -rpath $(libdir) -version-info $(CL_CURRENT):$(CL_REVISION):$(CL_AGE) $(LDFLAGS) $(LIBS) $(ALLOBJECTS_LO)
 
 install : all force
 	$(MKDIR) $(DESTDIR)$(libdir)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/cln-list/attachments/20050812/845538a6/attachment.pgp


More information about the CLN-list mailing list