svn commit: r230230 - head/sys/dev/random
John Baldwin
jhb at freebsd.org
Thu Jan 26 13:44:25 UTC 2012
On Wednesday, January 25, 2012 10:39:50 pm Andrey Chernov wrote:
> On Thu, Jan 26, 2012 at 07:03:05AM +0400, Andrey Chernov wrote:
> > On Wed, Jan 25, 2012 at 07:16:41PM +0000, Mark Murray wrote:
> > > I thought you were going to do this as a function? It would be
> > > slightly neater to do it that way.
> > >
> > > Looks good! Are you sure this needs no locking or volatile
> > > variables?
> >
> > Now with function, volatile, atomic and even enum:
>
> Sorry. Reading of state variable should be atomical too. Fixed version:
What is the purpose of the atomics? Doing atomic_load/atomic_store
is just as racy as if you had not used atomics at all. Should you be
using atomic_cmpset instead, e.g.:
case ARC4_ENTER_HAVE:
/* XXX: What does it mean for this to fail? */
atomic_cmpset_int(&iniseed_state, ARC4_ENTER_NONE, ARC4_ENTER_HAVE);
break;
--
John Baldwin
More information about the svn-src-head
mailing list