Skip Menu |

This queue is for tickets about the Math-Prime-Util CPAN distribution.

Maintainer(s)' notes

The latest version is in https://github.com/danaj/Math-Prime-Util

    git clone --origin upstream git://github.com/danaj/Math-Prime-Util.git Math-Prime-Util

Comments, issues, and patches are welcome at either RT or github, or send me email.

Report information
The Basics
Id: 78455
Status: resolved
Priority: 0/
Queue: Math-Prime-Util

People
Owner: DANAJ [...] cpan.org
Requestors: sisyphus [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.10
Fixed in: 0.11



Subject: Won't build with Microsoft Compilers
Hi, Patch is attached. The 2 Microsoft Compilers that I used were 32-bit 7.0 (_MSC_VER == 1300) with perl-5.10.0 and 64-bit 8.0 (_MSC_VER == 1400) with perl-5.16.0. In both cases I was using the compiler that built perl. Neither of those compilers have stdint.h. I think that 10.0 (_MSC_VER == 1600) does come with such a header file, though I've no idea what it contains. I don't know about 9.0 (_MSC_VER == 1500). With the attached patch applied, Math-Prime-Util-0.10 then built and tested fine with those 2 Microsoft compilers - with no affect on my MinGW (gcc compiler) builds. Cheers, Rob
Subject: M-P-U-diff.txt
--- ptypes.h_orig Wed Jul 18 23:24:11 2012 +++ ptypes.h Wed Jul 18 23:33:30 2012 @@ -2,7 +2,9 @@ #define MPU_PTYPES_H #define __STDC_LIMIT_MACROS +#ifndef _MSC_VER #include <stdint.h> +#endif #include "EXTERN.h" #include "perl.h" --- util.c_orig Thu Jul 19 16:53:04 2012 +++ util.c Thu Jul 19 16:52:52 2012 @@ -8,6 +8,10 @@ #define INFINITY (DBL_MAX + DBL_MAX) #endif +#ifdef _MSC_VER +#define exp2(x) pow(2.0,x) +#endif + #include "ptypes.h" #include "util.h" #include "sieve.h" --- XS.xs_orig Thu Jul 19 16:26:18 2012 +++ XS.xs Thu Jul 19 16:29:29 2012 @@ -274,6 +274,7 @@ } else { /* trial divisions */ if (verbose) printf("doing trial on %"UVuf"\n", n); + { UV f = tlim; UV m = tlim % 30; UV limit = (UV) (sqrt(n)+0.1); @@ -289,6 +290,7 @@ m = nextwheel30[m]; } break; /* We just factored n via trial division. Exit loop. */ + } } } /* n is now prime (or 1), so add to already-factored stack */
On Thu Jul 19 03:18:42 2012, SISYPHUS wrote: Show quoted text
> Hi, > > Patch is attached. > The 2 Microsoft Compilers that I used were 32-bit 7.0 (_MSC_VER ==
1300) Show quoted text
> with perl-5.10.0 and 64-bit 8.0 (_MSC_VER == 1400) with perl-5.16.0. > > In both cases I was using the compiler that built perl. > > Neither of those compilers have stdint.h. > I think that 10.0 (_MSC_VER == 1600) does come with such a header
file, Show quoted text
> though I've no idea what it contains. > I don't know about 9.0 (_MSC_VER == 1500).
Thank you VERY much! I fixed the exp2 issue when I saw NetBSD didn't have it, but the other two I didn't know about. The code-before- declarations probably came in late when I switched those from comments to if (verbose). I need to find a good way to automatically find those. I believe OpenSolaris, which I can run in VirtualBox, will complain about them, and adding -pedantic -ansi to gcc will make it output warnings (though it also outputs pages of other issues in perl.h that I can't control so requires digging). I found a way to accomplish my stdint.h goal with MSC, but for now I'm going with the same solution you did -- just don't include the file. It will mean 32-bit Perl on machines that have a uint64 type will run slower for some operations, so eventually I should work it out. Show quoted text
> With the attached patch applied, Math-Prime-Util-0.10 then built and > tested fine with those 2 Microsoft compilers - with no affect on my > MinGW (gcc compiler) builds.
Wonderful! I'm always worried about the threading tests, partly just because I don't actually use threading but want to make sure nothing breaks if someone does use it. I had to disable them for Cygwin -- one of my Cygwin systems (Win7 64-bit) works just fine with them, while the other (XP 32-bit) gives me random mutex panics. I'm happy to hear it's working on MSC. It was working for me with Strawberry Perl + gcc on Win7. I'll make a new release after I'm back from a conference and can test on other machines. Dana
On Thu Jul 19 13:07:57 2012, DANAJ wrote: Show quoted text
> Thank you VERY much! I fixed the exp2 issue when I saw NetBSD didn't > have it, but the other two I didn't know about. The code-before- > declarations probably came in late when I switched those from comments > to if (verbose).
Actually, that might only be a problem on *older* MS compilers ... I've a notion that more recent MS compilers wouldn't worry about that "code-before-declarations" piece, but I'm not entirely sure about that. Certainly, both of my MS compilers needed the scoping brackets. Cheers, Rob
On Thu Jul 19 22:21:41 2012, SISYPHUS wrote: Show quoted text
> On Thu Jul 19 13:07:57 2012, DANAJ wrote:
> > Thank you VERY much! I fixed the exp2 issue when I saw NetBSD
didn't Show quoted text
> > have it, but the other two I didn't know about. The code-before- > > declarations probably came in late when I switched those from
comments Show quoted text
> > to if (verbose).
> > Actually, that might only be a problem on *older* MS compilers ...
I've Show quoted text
> a notion that more recent MS compilers wouldn't worry about that > "code-before-declarations" piece, but I'm not entirely sure about
that. Show quoted text
> Certainly, both of my MS compilers needed the scoping brackets.
It's something I've been trying to take care with, since it's technically wrong (it isn't C90), does break some compilers (not just MS), and it is pretty readily fixed (in this case I just moved the line down below, instead of adding an inner scope). I need to start adding something like: perl Makefile.PL OPTIMIZE="-O0 -g -Wdeclaration-after-statement" to my prerelease testing so I can immediately see if it happens. Dana
This should be fixed in version 0.11. 1) stdint.h wrapped inside #ifndef _MSC_VER 2) exp2 -> pow in all places (needed for other platforms also) 3) declarations after statement should be fixed.