From owner-freebsd-perl@FreeBSD.ORG Thu Jun 3 14:26:32 2004 Return-Path: Delivered-To: freebsd-perl@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 46FF616A4CE for ; Thu, 3 Jun 2004 14:26:32 -0700 (PDT) Received: from mail01.stbernard.com (mail01.stbernard.com [199.245.188.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1D75143D31 for ; Thu, 3 Jun 2004 14:26:32 -0700 (PDT) (envelope-from cjones@stbernard.com) X-MimeOLE: Produced By Microsoft Exchange V6.0.6375.0 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Thu, 3 Jun 2004 14:26:31 -0700 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: RE: Math::TrulyRandom not working in FreeBSD 5.2.1 Thread-Index: AcRJsXCnzwbB7H0KQ8CWkozEjuAL3g== From: "Cory Jones" To: Subject: RE: Math::TrulyRandom not working in FreeBSD 5.2.1 X-BeenThere: freebsd-perl@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: maintainer of a number of perl-related ports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Jun 2004 21:26:32 -0000 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? 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()