This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC] powerpc: optimizing random() and POSIX question
- From: Raphael M Zinsly <rzinsly at linux dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Cc: Tulio Magno Quites Machado Filho <tuliom at linux dot ibm dot com>, Paul Clarke <pc at us dot ibm dot com>
- Date: Tue, 11 Feb 2020 11:04:19 -0300
- Subject: [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