You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rotate.h 757B

1234567891011121314151617181920212223242526272829
  1. #ifndef _GPXE_ROTATE_H
  2. #define _GPXE_ROTATE_H
  3. /** @file
  4. *
  5. * Bit operations
  6. */
  7. FILE_LICENCE ( GPL2_OR_LATER );
  8. #include <stdint.h>
  9. static inline uint32_t rol32 ( uint32_t data, unsigned int rotation ) {
  10. return ( ( data << rotation ) | ( data >> ( 32 - rotation ) ) );
  11. }
  12. static inline uint32_t ror32 ( uint32_t data, unsigned int rotation ) {
  13. return ( ( data >> rotation ) | ( data << ( 32 - rotation ) ) );
  14. }
  15. static inline uint64_t rol64 ( uint64_t data, unsigned int rotation ) {
  16. return ( ( data << rotation ) | ( data >> ( 64 - rotation ) ) );
  17. }
  18. static inline uint64_t ror64 ( uint64_t data, unsigned int rotation ) {
  19. return ( ( data >> rotation ) | ( data << ( 64 - rotation ) ) );
  20. }
  21. #endif /* _GPXE_ROTATE_H */