Advertisement
Guest User

Outlined thread locals.

a guest
May 13th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. static thread_local uint64_t RandomStateA =
  2. static_cast<uint64_t>(time(nullptr));
  3. static thread_local uint64_t RandomStateB = xorShiftStar64();
  4.  
  5. uint64_t getRandomUnsigned64() {
  6. uint64_t A = RandomStateA;
  7. const uint64_t B = RandomStateB;
  8. RandomStateA = B;
  9.  
  10. A ^= A << 23;
  11. A ^= A >> 17;
  12. A ^= B ^ (B >> 26);
  13.  
  14. RandomStateB = A;
  15. return A + B;
  16. }
  17.  
  18. ==========================================================================
  19. 0000000000400780 <gwp_asan::random::getRandomUnsigned64()>:
  20. 400780: 41 57 push %r15
  21. 400782: 41 56 push %r14
  22. 400784: 41 55 push %r13
  23. 400786: 41 54 push %r12
  24. 400788: 53 push %rbx
  25. 400789: 66 66 66 64 48 8b 04 data16 data16 data16 mov %fs:0x0,%rax
  26. 400790: 25 00 00 00 00
  27. 400795: 49 89 c6 mov %rax,%r14
  28. 400798: 8a 88 f8 ff ff ff mov -0x8(%rax),%cl
  29. 40079e: 84 c9 test %cl,%cl
  30. 4007a0: 74 55 je 4007f7 <gwp_asan::random::getRandomUnsigned64()+0x77>
  31. 4007a2: 4d 8b a6 e8 ff ff ff mov -0x18(%r14),%r12
  32. 4007a9: 4d 8b ae f0 ff ff ff mov -0x10(%r14),%r13
  33. 4007b0: 4c 89 f0 mov %r14,%rax
  34. 4007b3: 4d 89 ae e8 ff ff ff mov %r13,-0x18(%r14)
  35. 4007ba: 4c 89 e3 mov %r12,%rbx
  36. 4007bd: 48 c1 e3 17 shl $0x17,%rbx
  37. 4007c1: 4c 31 e3 xor %r12,%rbx
  38. 4007c4: 4c 89 e8 mov %r13,%rax
  39. 4007c7: 48 c1 e8 1a shr $0x1a,%rax
  40. 4007cb: 4c 31 e8 xor %r13,%rax
  41. 4007ce: 48 31 d8 xor %rbx,%rax
  42. 4007d1: 48 c1 eb 11 shr $0x11,%rbx
  43. 4007d5: 48 31 c3 xor %rax,%rbx
  44. 4007d8: 84 c9 test %cl,%cl
  45. 4007da: 0f 84 d6 00 00 00 je 4008b6 <gwp_asan::random::getRandomUnsigned64()+0x136>
  46. 4007e0: 49 89 9e f0 ff ff ff mov %rbx,-0x10(%r14)
  47. 4007e7: 49 01 dd add %rbx,%r13
  48. 4007ea: 4c 89 e8 mov %r13,%rax
  49. 4007ed: 5b pop %rbx
  50. 4007ee: 41 5c pop %r12
  51. 4007f0: 41 5d pop %r13
  52. 4007f2: 41 5e pop %r14
  53. 4007f4: 41 5f pop %r15
  54. 4007f6: c3 retq
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement