Home | History | Annotate | Download | only in gpxe
      1 #ifndef _GPXE_ROTATE_H
      2 #define _GPXE_ROTATE_H
      3 
      4 /** @file
      5  *
      6  * Bit operations
      7  */
      8 
      9 FILE_LICENCE ( GPL2_OR_LATER );
     10 
     11 #include <stdint.h>
     12 
     13 static inline uint32_t rol32 ( uint32_t data, unsigned int rotation ) {
     14         return ( ( data << rotation ) | ( data >> ( 32 - rotation ) ) );
     15 }
     16 
     17 static inline uint32_t ror32 ( uint32_t data, unsigned int rotation ) {
     18         return ( ( data >> rotation ) | ( data << ( 32 - rotation ) ) );
     19 }
     20 
     21 static inline uint64_t rol64 ( uint64_t data, unsigned int rotation ) {
     22         return ( ( data << rotation ) | ( data >> ( 64 - rotation ) ) );
     23 }
     24 
     25 static inline uint64_t ror64 ( uint64_t data, unsigned int rotation ) {
     26         return ( ( data >> rotation ) | ( data << ( 64 - rotation ) ) );
     27 }
     28 
     29 #endif /* _GPXE_ROTATE_H */
     30