[GiNaC-list] about CLN versus win32 patch

Sheplyakov Alexei varg at theor.jinr.ru
Wed Aug 2 10:12:44 CEST 2006


On Mon, Jul 31, 2006 at 11:34:59PM +0200, Richard B. Kreckel wrote:
> >In order to build from CVS I had to modify configure.ac and different
> >m4 macros, see the second attached file.
> > 
> 
> Okay, but these are new compared to 
> <http://www.ginac.de/pipermail/ginac-list/2006-July/000863>.  :-)

As you have noticed, that patch was not for CVS version. I couldn't use
it because of numerious auto* tools errors:

$ autoreconf -iv
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: configure.ac: tracing
autoreconf: running: libtoolize --copy
Using `AC_PROG_RANLIB' is rendered obsolete by `AC_PROG_LIBTOOL'
Putting files in AC_CONFIG_AUX_DIR, `autoconf'.
libtoolize: `config.guess' exists: use `--force' to overwrite
libtoolize: `config.sub' exists: use `--force' to overwrite
libtoolize: `ltmain.sh' exists: use `--force' to overwrite
autoreconf: running: /usr/bin/autoconf
autoreconf: running: /usr/bin/autoheader
autoheader: warning: missing template: CL_USE_GMP
autoheader: Use AC_DEFINE([CL_USE_GMP], [], [Description])
autoheader: warning: missing template: CL_VERSION
autoheader: warning: missing template: CL_VERSION_MAJOR
autoheader: warning: missing template: CL_VERSION_MINOR
autoheader: warning: missing template: CL_VERSION_PATCHLEVEL
autoreconf: /usr/bin/autoheader failed with exit status: 1

 
> >------------------------------------------------------------------------
> >
> >diff --git a/src/base/random/cl_random_from.cc 
> >b/src/base/random/cl_random_from.cc
> >index 0470a4e..e858473 100644
> >--- a/src/base/random/cl_random_from.cc
> >+++ b/src/base/random/cl_random_from.cc
> >@@ -1,4 +1,7 @@
> >// random_state constructor.
> >+#if defined(_WIN32)
> >+#include <windows.h> // for GetCurrentProcessId()
> >+#endif
> >
> >// General includes.
> >#include "cl_sysdep.h"
> >@@ -9,10 +12,6 @@ #include "cln/random.h"
> >
> >// Implementation.
> >
> >-#if defined(_WIN32)
> >-#include <windows.h> // for GetCurrentProcessId()
> >-#endif
> >-
> >#include "cl_base_config.h"
> >#include "cl_low.h"
> >#include <cstdlib>  // declares rand()
> >@@ -47,14 +46,12 @@ #endif
> >#include <sys/times.h>
> >extern "C" clock_t times (struct tms * buffer);
> >
> >-namespace cln {
> >inline uint32 get_seed (void)
> >{
> >	var struct tms tmsbuf;
> >	var uint32 seed_lo = times(&tmsbuf);
> >	return seed_lo + tmsbuf.tms_utime + tmsbuf.tms_stime;
> >}
> >-}  // namespace cln
> >
> >#endif
> >
> >@@ -62,14 +59,12 @@ #elif defined(_WIN32)
> >#include <sys/time.h>
> >#include <sys/timeb.h>
> >
> >-namespace cln {
> >inline uint32 get_seed (void)
> >{
> >	struct timeb timebuf;
> >	ftime(&timebuf);
> >	return cln::highlow32(timebuf.time, (long)(timebuf.millitm)*1000);
> >}
> >-}  // namespace cln
> >
> >#endif
> > 
> >
> 
> I assume these are not the reason for it failing.

No, this is exactly the reason of compilation errors. First of all,
<windows.h> *must* be the very first of the included files.

> I've deliberately put get_seed into namespace cln.
Then you should have done s/::get_seed/get_seed/g
I've attached yet another variant of patch, it puts *all* definitions 
of get_seed into namespace cln.

 
> >------------------------------------------------------------------------
> >
> >diff --git a/configure.ac b/configure.ac
> >index a47ef2e..c2e0f7c 100644
> >--- a/configure.ac
> >+++ b/configure.ac
> >@@ -69,6 +69,14 @@ dnl           check for build configurat
> >dnl
> >PACKAGE=cln
> >                      dnl libtool wants PACKAGE
> >+case $host_os in
> >+	*mingw32*)
> >+	AC_LIBTOOL_WIN32_DLL
> >+	;;
> >+	*)
> >+	;;
> >+esac          
> >+                      dnl convince libtool to build win32 dll
> > 
> >
> 
> Is this really the right place? 

 From the libtool manual:
\begin{quote}
 -- Macro: AC_LIBTOOL_WIN32_DLL
     This macro should be used if the package has been ported to build
     clean dlls on win32 platforms.  Usually this means that any
     library data items are exported with `__declspec(dllexport)' and
     imported with `__declspec(dllimport)'.  If this macro is not used,
     libtool will assume that the package libraries are not dll clean
     and will build only static libraries on win32 hosts.

     This macro must be called *before* `AC_PROG_LIBTOOL', and
     provision must be made to pass `-no-undefined' to `libtool' in
     link mode from the package `Makefile'.  Naturally, if you pass
     `-no-undefined', you must ensure that all the library symbols
     *really are* defined at link time!
\end{quote}

Note that CLN is *not* clean win32 dll [yet]...

> Maybe updating libtool would be more appropiate?
Updating libtool won't hurt. BTW, private copy of libtool.m4 is *evil*,
isn't it?

> >AC_PROG_LIBTOOL
> >                      dnl sets variable LIBTOOL
> >
> >@@ -94,12 +102,12 @@ CL_VERSION_MAJOR=1
> >CL_VERSION_MINOR=1
> >CL_VERSION_PATCHLEVEL=12
> >dnl release version for cln/config.h, so it can be tested by the 
> >preprocessor
> >-AC_DEFINE_UNQUOTED(CL_VERSION_MAJOR, $CL_VERSION_MAJOR)
> >-AC_DEFINE_UNQUOTED(CL_VERSION_MINOR, $CL_VERSION_MINOR)
> >-AC_DEFINE_UNQUOTED(CL_VERSION_PATCHLEVEL, $CL_VERSION_PATCHLEVEL)
> >+AC_DEFINE_UNQUOTED(CL_VERSION_MAJOR, $CL_VERSION_MAJOR, [CLN major 
> >version])
> >+AC_DEFINE_UNQUOTED(CL_VERSION_MINOR, $CL_VERSION_MINOR, [CLN minor 
> >version])
> >+AC_DEFINE_UNQUOTED(CL_VERSION_PATCHLEVEL, $CL_VERSION_PATCHLEVEL, [CLN 
> >patchlevel version])
> >dnl concatenated release version
> >CL_VERSION=$CL_VERSION_MAJOR.$CL_VERSION_MINOR.$CL_VERSION_PATCHLEVEL
> >-AC_DEFINE_UNQUOTED(CL_VERSION, $CL_VERSION)
> >+AC_DEFINE_UNQUOTED(CL_VERSION, $CL_VERSION, [CLN version])
> >AC_SUBST(CL_VERSION)
> >
> >dnl
> >@@ -151,8 +159,10 @@ CL_MACHINE([floating-point types and beh
> >dnl
> >dnl           interfacing to GNU gmp (must be at least version 3)
> >dnl
> >-AC_ARG_WITH(gmp, [  --with-gmp              use external fast low-level 
> >functions from GNU MP 3.
> >-                          [default=yes]], ,with_gmp="yes")
> >+AC_ARG_WITH(gmp, AS_HELP_STRING([--with-gmp], 
> >+	[use external fast low-level functions from GNU MP 3 (default: 
> >yes).]),
> >+	with_gmp="$withval",
> >+	with_gmp="yes")
> >if test "$with_gmp" = yes; then
> >  CL_GMP_H_VERSION
> >  if test "$cl_cv_new_gmp_h" = no; then with_gmp="no"; fi
> >@@ -163,7 +173,7 @@ if test "$with_gmp" = yes; then
> >fi
> >if test "$with_gmp" = yes; then
> >  CL_GMP_SET_UINTD
> >-  AC_DEFINE(CL_USE_GMP)
> >+  AC_DEFINE(CL_USE_GMP, ,[Define if GNU MP library is available])
> >else
> >  AC_MSG_WARN([disabling external GNU MP library])
> >fi
> >diff --git a/m4/c++-constructors.m4 b/m4/c++-constructors.m4
> >index 2eb9889..48df183 100644
> >--- a/m4/c++-constructors.m4
> >+++ b/m4/c++-constructors.m4
> >@@ -37,7 +37,7 @@ rm -f conftest*
> >])
> >if test "$cl_cv_cplusplus_ctorprefix" '!=' unknown; then
> >  ac_value='"'"$cl_cv_cplusplus_ctorprefix"'"'
> >-  AC_DEFINE_UNQUOTED(CL_GLOBAL_CONSTRUCTOR_PREFIX,$ac_value)
> >+  AC_DEFINE_UNQUOTED(CL_GLOBAL_CONSTRUCTOR_PREFIX,$ac_value, [Global ctor 
> >prefix])
> >AC_CACHE_CHECK(for the global destructors function prefix,
> >cl_cv_cplusplus_dtorprefix, [
> >cat > conftest.cc << EOF
> >@@ -63,7 +63,7 @@ rm -f conftest*
> >])
> >  if test "$cl_cv_cplusplus_dtorprefix" '!=' none; then
> >    ac_value='"'"$cl_cv_cplusplus_ctorprefix"'"'
> >-    AC_DEFINE_UNQUOTED(CL_GLOBAL_DESTRUCTOR_PREFIX,$ac_value)
> >+    AC_DEFINE_UNQUOTED(CL_GLOBAL_DESTRUCTOR_PREFIX,$ac_value, [Global 
> >dtor prefix])
> >  fi
> >dnl Check whether the global constructors/destructors functions are 
> >file-scope
> >dnl only by default. This is the case in egcs-1.1.2 or newer.
> >@@ -93,7 +93,7 @@ fi
> >rm -f conftest*
> >])
> >if test "$cl_cv_cplusplus_ctorexport" = yes; then
> >-  AC_DEFINE(CL_NEED_GLOBALIZE_CTORDTOR)
> >+  AC_DEFINE(CL_NEED_GLOBALIZE_CTORDTOR, ,[Define if global ctor/dtors are 
> >file-scope by default])
> >fi
> >fi
> >fi
> >diff --git a/m4/general.m4 b/m4/general.m4
> >index 0c550af..3a0b403 100644
> >--- a/m4/general.m4
> >+++ b/m4/general.m4
> >@@ -129,6 +129,64 @@ AC_CANONICAL_HOST
> >
> >AC_DEFUN([CL_CANONICAL_HOST_CPU],
> >[AC_REQUIRE([CL_CANONICAL_HOST])AC_REQUIRE([AC_PROG_CC])
> >+AH_TOP([
> >+#ifndef _CL_CONFIG_H
> >+#define _CL_CONFIG_H
> >+/* CLN's idea about CPU model */
> >+#ifndef __i386__
> >+#undef __i386__
> >+#endif
> >+#ifndef __m68k__
> >+#undef __m68k__
> >+#endif
> >+/* NB: GCC def's __mips__ both on big-endian and little-endian systems. */
> >+#ifndef __mips__
> >+#undef __mips__
> >+#endif
> >+#ifndef __mipsel__
> >+#undef __mipsel__
> >+#endif
> >+#ifndef __mips64__
> >+#undef __mips64__
> >+#endif
> >+#ifndef __sparc__
> >+#undef __sparc__
> >+#endif
> >+#ifndef __sparc64__
> >+#undef __sparc64__
> >+#endif
> >+#ifndef __alpha__
> >+#undef __alpha__
> >+#endif
> >+#ifndef __hppa__
> >+#undef __hppa__
> >+#endif
> >+#ifndef __arm__
> >+#undef __arm__
> >+#endif
> >+#ifndef __rs6000__
> >+#undef __rs6000__
> >+#endif
> >+#ifndef __m88k__
> >+#undef __m88k__
> >+#endif
> >+#ifndef __convex__
> >+#undef __convex__
> >+#endif
> >+#ifndef __ia64__
> >+#undef __ia64__
> >+#endif
> >+#ifndef __x86_64__
> >+#undef __x86_64__
> >+#endif
> >+#ifndef __s390__
> >+#undef __s390__
> >+#endif
> >+])
> >+AH_BOTTOM([
> >+#endif /* _CL_CONFIG_H */
> >+])
> >+
> >case "$host_cpu" in
> >changequote(,)dnl
> >  i[4567]86 )
> >@@ -182,6 +240,7 @@ else
> >fi
> >    ;;
> >esac
> >+
> >dnl was AC_DEFINE_UNQUOTED(__${host_cpu}__) but KAI C++ 3.2d doesn't like 
> >this
> >cat >> confdefs.h <<EOF
> >#ifndef __${host_cpu}__
> >diff --git a/m4/gmp.m4 b/m4/gmp.m4
> >index 93bdc5d..5fc110b 100644
> >--- a/m4/gmp.m4
> >+++ b/m4/gmp.m4
> >@@ -62,5 +62,5 @@ #endif
> >    AC_MSG_ERROR([Don't know which C-type has sizeof $gmp_retval.]),
> >    AC_MSG_ERROR([cross-compiling - cannot determine]))
> >])
> >-AC_DEFINE_UNQUOTED($cl_gmp_demands)
> >+AC_DEFINE_UNQUOTED($cl_gmp_demands, ,[sizeof(uintD) == sizeof(mp_limb_t)])
> >])
> >diff --git a/m4/longdouble.m4 b/m4/longdouble.m4
> >index 069de22..72cecce 100644
> >--- a/m4/longdouble.m4
> >+++ b/m4/longdouble.m4
> >@@ -23,6 +23,6 @@ AC_TRY_COMPILE([
> >  ], , cl_cv_c_longdouble=yes, cl_cv_c_longdouble=no)])
> >])
> >if test $cl_cv_c_longdouble = yes; then
> >-  AC_DEFINE(HAVE_LONGDOUBLE)
> >+  AC_DEFINE(HAVE_LONGDOUBLE, ,[Define if compiler support long double 
> >type])
> >fi
> >])
> >diff --git a/m4/param.m4 b/m4/param.m4
> >index 2a6b07d..21a7b84 100644
> >--- a/m4/param.m4
> >+++ b/m4/param.m4
> >@@ -31,9 +31,9 @@ CC=`echo "$CC " | sed -e 's/-O //g'`
> >fi
> >AC_TRY_EVAL(ac_link)
> >CC="$ORIGCC"
> >-if test -s conftest; then
> >+if test -s conftest${ac_exeext}; then
> >  echo "creating $cl_machine_file_h"
> >-  ./conftest > conftest.h
> >+  ./conftest${ac_exeext} > conftest.h
> >  if cmp -s "$cl_machine_file_h" conftest.h 2>/dev/null; then
> >    # The file exists and we would not be changing it
> >    rm -f conftest.h
> > 
> >
 
> Am I right assuming that the last hunk is the only non-cosmetic one?
No. All of hunks (except the last one) are necessary to make auto* tools
happy. The last hunk is the only win32-specific.


Best regards,
 Alexei.

-- 
All science is either physics or stamp collecting.

-------------- next part --------------
diff --git a/src/base/random/cl_random_from.cc b/src/base/random/cl_random_from.cc
index 0470a4e..2ea2481 100644
--- a/src/base/random/cl_random_from.cc
+++ b/src/base/random/cl_random_from.cc
@@ -1,4 +1,7 @@
 // random_state constructor.
+#if defined(_WIN32)
+#include <windows.h> // for GetCurrentProcessId()
+#endif
 
 // General includes.
 #include "cl_sysdep.h"
@@ -9,10 +12,6 @@ #include "cln/random.h"
 
 // Implementation.
 
-#if defined(_WIN32)
-#include <windows.h> // for GetCurrentProcessId()
-#endif
-
 #include "cl_base_config.h"
 #include "cl_low.h"
 #include <cstdlib>  // declares rand()
@@ -31,12 +30,14 @@ #else
   extern "C" int gettimeofday (struct timeval * tp, GETTIMEOFDAY_TZP_T tzp);
 #endif
 
+namespace cln {
 inline uint32 get_seed (void)
 {
 	var struct timeval tv;
 	gettimeofday(&tv,0);
-	return cln::highlow32(tv.tv_sec,tv.tv_usec); // 16+16 zuf?ige Bits
+	return ::cln::highlow32(tv.tv_sec,tv.tv_usec); // 16+16 zuf?ige Bits
 }
+}  // namespace cln
 
 #elif defined(HAVE_TIMES_CLOCK)
 
@@ -67,7 +68,7 @@ inline uint32 get_seed (void)
 {
 	struct timeb timebuf;
 	ftime(&timebuf);
-	return cln::highlow32(timebuf.time, (long)(timebuf.millitm)*1000);
+	return highlow32(timebuf.time, (long)(timebuf.millitm)*1000);
 }
 }  // namespace cln
 
@@ -84,14 +85,14 @@ random_state::random_state ()
 	var uint32 seed_hi;
 	var uint32 seed_lo;
 #if defined(unix) || defined(__unix) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(_AIX) || defined(sinix) || (defined(__MACH__) && defined(__APPLE__)) || (defined(__CYGWIN__) && defined(__GNUC__)) || defined(__BEOS__)
-	seed_lo = ::get_seed();
+	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(__OpenBSD__)
 	seed_lo = arc4random();
 	seed_hi = arc4random();
 #elif defined(_WIN32)
-	seed_lo = ::get_seed();
+	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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
Url : http://www.cebix.net/pipermail/ginac-list/attachments/20060802/b39716c5/attachment.pgp


More information about the GiNaC-list mailing list