Hi,
https://winlibs.com is a good source of mingw-w64 toolchains.
Currently, their compilers provide threading via pthreads, but they are planning to move to mcf threads.
That shouldn't be a big issue - the experimental 64-bit mcf toolchain that they've just provided builds perl straight out of the box, with all tests passing. (Not so with the 32-bit mcf compiler, but I would think that can be fixed inside the perl source.)
However, I was puzzled by a change in behaviour of the following script and, being a complete idiot wrt threading, I'm keen to hear thoughts from those who know about threads.
(FAIK, my script might be rubbish that is triggering undefined or implementation-dependent behaviour).
Here is the script:
use warnings;
use strict;
use threads;
use Math::MPFR qw(:mpfr);
die "threads version is too old"
if $threads::VERSION < 1.71;
die "mpfr library was built without TLS support"
unless Rmpfr_buildopt_tls_p();
# Default precision is 53.
# First, change it to 101
# Then change it to 201 (inside a separate thread)
Rmpfr_set_default_prec(101);
my $thr1 = threads->create(
sub {
Rmpfr_set_default_prec(201);
return Rmpfr_get_default_prec();
} );
my $res = $thr1->join();
if($res == 201) { print "ok 1\n" }
else { print "\$res: $res (expected 201) not ok 1\n" }
if(Rmpfr_get_default_prec() == 101) { print "ok 2\n" }
else { print "\$res: $res\nprec: ", Rmpfr_get_default_prec(), "\nNOT o
+k 2\n"}
When perl is built with the mcf toolchain I get:
>perl tls.pl
$res: 53 (expected 201) not ok 1
ok 2
When perl is built with the pthreads toolchain (or built on Linux) I get:
>perl tls.pl
ok 1
ok 2
The only difference lies in the compiler that built perl.
Other than that, it's the same perl source, same Math::MPFR source and the same static mpfr and gmp libraries.
The Rmpfr_set_default_prec() function is a wrapper around the mpfr function that sets the default precision (in bits) in the mpfr library. Initial (default) precision is 53.
And the Rmpfr_get_default_prec() function is a wrapper around the mpfr function that returns that default precision.
Thoughts ?
It seems odd that, having passed the plethora of "threads" tests in perl's test suite, the "mcf" build should stumble on such a basic script.
Cheers,
Rob
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.