Date: Thu, 3 Jun 2004 14:26:31 -0700 From: "Cory Jones" <cjones@stbernard.com> To: <freebsd-perl@freebsd.org> Subject: RE: Math::TrulyRandom not working in FreeBSD 5.2.1 Message-ID: <E7E213858379814A9AE48CA6754F5ECB02FD9F31@mail01.stbernard.com>
next in thread | raw e-mail | index | archive | help
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()
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E7E213858379814A9AE48CA6754F5ECB02FD9F31>