crypto_int32.h 621 B

12345678910111213141516171819202122232425
  1. /* Added for Tor. */
  2. #ifndef CRYPTO_INT32_H
  3. #define CRYPTO_INT32_H
  4. #include "common/torint.h"
  5. #define crypto_int32 int32_t
  6. #define crypto_uint32 uint32_t
  7. /*
  8. Stop signed left shifts overflowing
  9. by using unsigned types for bitwise operations
  10. */
  11. #ifndef OVERFLOW_SAFE_SIGNED_LSHIFT
  12. #define OVERFLOW_SAFE_SIGNED_LSHIFT(s, lshift, utype, stype) \
  13. ((stype)((utype)(s) << (utype)(lshift)))
  14. #endif
  15. #define SHL32(s, lshift) \
  16. OVERFLOW_SAFE_SIGNED_LSHIFT(s, lshift, crypto_uint32, crypto_int32)
  17. #define SHL8(s, lshift) \
  18. OVERFLOW_SAFE_SIGNED_LSHIFT(s, lshift, unsigned char, signed char)
  19. #endif /* CRYPTO_INT32_H */