• Uros Bizjak's avatar
    random: use try_cmpxchg in _credit_init_bits · b7a68f67
    Uros Bizjak authored
    Use `!try_cmpxchg(ptr, &orig, new)` instead of `cmpxchg(ptr, orig, new)
    != orig` in _credit_init_bits. This has two benefits:
    
    - The x86 cmpxchg instruction returns success in the ZF flag, so this
      change saves a compare after cmpxchg, as well as a related move
      instruction in front of cmpxchg.
    
    - try_cmpxchg implicitly assigns the *ptr value to &orig when cmpxchg
      fails, enabling further code simplifications.
    
    This patch has no functional change.
    Signed-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
    Signed-off-by: default avatarJason A. Donenfeld <Jason@zx2c4.com>
    b7a68f67
random.c 47.2 KB