Math::TrulyRandom not working in FreeBSD 5.2.1

Cory Jones cjones at stbernard.com
Thu Jun 3 14:26:32 PDT 2004


Kelly Hall wrote:

>>The module Math::TrulyRandom is not working in FreeBSD 5.2.1.  I installed perl 5.6.1 via ports, and installed >>>>>>Math::TrulyRandom via CPAN.
>>
>>"make test" hangs forever.
>>
>>A solution is to add the statement:
>>return 0;
>>as the last line of the function tick() in the file truerand.c.
>>
>>I can only guess that GCC is having issues?
<snip>

I found that making env, count, ocount, and buffer in truerand.c volatile (atomic) fixes the problem. It appears (from my very limited understanding :-) since it is possible that an interrupt may occur during the middle of some operation for example an assignment operation it can cause trouble. Using volatile on these data objects ensures they are atomic or uninterruptible. Anyways here a diff of the changes I made to truerand.c:
~Cory

$ diff -r -u truerand.orignal truerand.c
--- truerand.orignal     Thu Jun  3 13:55:39 2004
+++ truerand.c     Thu Jun  3 13:56:06 2004
@@ -46,10 +46,10 @@

 #include "truerand.h"

-static jmp_buf env;
-static unsigned count;
-static unsigned ocount;
-static unsigned buffer;
+static volatile jmp_buf env;
+static volatile unsigned count;
+static volatile unsigned ocount;
+static volatile unsigned buffer;

 static int
 tick()


More information about the freebsd-perl mailing list