Skip to content
  1. Mar 15, 2014
  2. Mar 12, 2014
  3. Feb 27, 2014
  4. Feb 10, 2014
  5. Feb 09, 2014
  6. Jan 28, 2014
  7. Jan 26, 2014
  8. Jul 11, 2013
  9. Jul 05, 2013
  10. Jul 04, 2013
  11. Mar 09, 2013
  12. Mar 05, 2013
  13. Mar 02, 2013
  14. Mar 01, 2013
    • Jason Miller's avatar
      Implement in-process PRNG for mkostemp · 88eb09b2
      Jason Miller authored and Stelian Ionescu's avatar Stelian Ionescu committed
      Instead of using /dev/urandom, use an in-process 32-bit xorshift.
      
      The xorshift is a very fast but not particularly strong PRNG with a
      period of (1- (expt 2 32)).  It has only a single 32-bit word for seed
      data, so that multithreaded code should play very nicely on CPUs that
      can store those atomically.  For CPUs that cannot, it should still be
      safe, since it can recover from any value in the seed.
      
      We reseed from the pid and current time when we hit a collision.  This
      is necessary for code like this to not be slow:
      
          mkstemp(...)
          fork()
          mkstemp(...)
      
      since the child process(es) will inherit the seed of the parent and
      collide a lot otherwise.
      88eb09b2