This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFC] powerpc: optimizing random() and POSIX question


Hi,

I’m investigating ways to optimize random() for powerpc and got some questions regarding POSIX.
The current code on stdlib/random.c does:

long int
__random (void)
{
  int32_t retval;

  __libc_lock_lock (lock);

  (void) __random_r (&unsafe_state, &retval);

  __libc_lock_unlock (lock);

  return retval;
}

If I remove the lock in order to use lqarx/stqcx to access fptr and rptr (that are adjacents), then compute the result as is done in random_r, will this still be compliant with POSIX? As the data is accessed atomically, only one thread access the critical section at a time. Am I missing something?


Thanks,
--
Raphael Moreira Zinsly
IBM
Linux on Power Toolchain


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]