Bill Allombert on Sun, 28 Jun 2009 22:24:42 +0200


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

Re: Pari svn on MSVC


On Sat, Jun 27, 2009 at 04:43:05PM +0200, Bill Allombert wrote:
> On Sat, Jun 27, 2009 at 01:37:55AM +0100, Jason Moxham wrote:
> > By the way , pari svn works under MSVC now with and without MPIR/GMP
> > I'm just going thru the hacks I did.
> >
> > In the file
> > src/gp/gp.c
> >
> > there is use of the function
> > alarm(int)
> >
> > This function does not exist for MSVC or MinGW , for the moment I have 
> > just commented it out to get it to compile and run. I imagine there is a 
> > suitible substitute for it under windows.
> 
> At worse, we can disable alamr in Configure, bug I used alarm instead of
> setitimer/getitimer because alarm is available in UNIX v7...

I attach a patch that check for alamr in Configure and set HAS_ALARM
accoridingly. I suppose it address your issue since since HAS_ALARM is not
defined in Odos/paricfg.h. However it would be better to add an alternative
implementation for MSVC.

Are you running the Configure script ?

I really wonder if there are system where Configure is used and alarm
does not exist. If not, the Configure part of the patch is useless.

Cheers,
Bill.
diff --git a/config/get_libc b/config/get_libc
index 545580c..6c2679c 100644
--- a/config/get_libc
+++ b/config/get_libc
@@ -24,6 +24,7 @@ list=waitpid; . ./look
 list=setsid; . ./look
 list=getenv; . ./look
 list=isatty; . ./look
+list=alarm; . ./look
 
 # For install(). Do we need libdl.so?
 # on irix and osf1 -ldl not needed
diff --git a/config/has_alarm.c b/config/has_alarm.c
new file mode 100644
index 0000000..bd9387e
--- /dev/null
+++ b/config/has_alarm.c
@@ -0,0 +1,4 @@
+#include <unistd.h>
+
+char (*f)() = alarm;
+int main(){ return f != alarm; }
diff --git a/config/paricfg.h.SH b/config/paricfg.h.SH
index 40ae950..2805038 100644
--- a/config/paricfg.h.SH
+++ b/config/paricfg.h.SH
@@ -141,6 +141,10 @@ esac
 case "$has_isatty" in
 yes) echo '#define HAS_ISATTY' >> $file;;
 esac
+case "$has_alarm" in
+yes) echo '#define HAS_ALARM' >> $file;;
+esac
+
 
 case "$has_getrusage" in
 yes) echo '#define USE_GETRUSAGE 1' >> $file;;
diff --git a/src/gp/gp.c b/src/gp/gp.c
index b2a1ebd..833076c 100644
--- a/src/gp/gp.c
+++ b/src/gp/gp.c
@@ -1722,7 +1722,9 @@ void
 alarm0(long s)
 {
   if (s < 0) pari_err(talker,"delay must be non-negative");
+#ifdef HAS_ALARM
   alarm(s);
+#endif
 }
 
 /*******************************************************************/