iPXE
rotate.h
Go to the documentation of this file.
1 #ifndef _IPXE_ROTATE_H
2 #define _IPXE_ROTATE_H
3 
4 /** @file
5  *
6  * Bit operations
7  */
8 
9 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
10 
11 #include <stdint.h>
12 
13 static inline __attribute__ (( always_inline )) uint8_t
14 rol8 ( uint8_t data, unsigned int rotation ) {
15  return ( ( data << rotation ) | ( data >> ( 8 - rotation ) ) );
16 }
17 
18 static inline __attribute__ (( always_inline )) uint8_t
19 ror8 ( uint8_t data, unsigned int rotation ) {
20  return ( ( data >> rotation ) | ( data << ( 8 - rotation ) ) );
21 }
22 
23 static inline __attribute__ (( always_inline )) uint16_t
24 rol16 ( uint16_t data, unsigned int rotation ) {
25  return ( ( data << rotation ) | ( data >> ( 16 - rotation ) ) );
26 }
27 
28 static inline __attribute__ (( always_inline )) uint16_t
29 ror16 ( uint16_t data, unsigned int rotation ) {
30  return ( ( data >> rotation ) | ( data << ( 16 - rotation ) ) );
31 }
32 
33 static inline __attribute__ (( always_inline )) uint32_t
34 rol32 ( uint32_t data, unsigned int rotation ) {
35  return ( ( data << rotation ) | ( data >> ( 32 - rotation ) ) );
36 }
37 
38 static inline __attribute__ (( always_inline )) uint32_t
39 ror32 ( uint32_t data, unsigned int rotation ) {
40  return ( ( data >> rotation ) | ( data << ( 32 - rotation ) ) );
41 }
42 
43 static inline __attribute__ (( always_inline )) uint64_t
44 rol64 ( uint64_t data, unsigned int rotation ) {
45  return ( ( data << rotation ) | ( data >> ( 64 - rotation ) ) );
46 }
47 
48 static inline __attribute__ (( always_inline )) uint64_t
49 ror64 ( uint64_t data, unsigned int rotation ) {
50  return ( ( data >> rotation ) | ( data << ( 64 - rotation ) ) );
51 }
52 
53 #endif /* _IPXE_ROTATE_H */
unsigned short uint16_t
Definition: stdint.h:11
static u32 rol32(u32 v, int bits)
Rotate 32-bit value left.
Definition: wpa_tkip.c:173
unsigned long long uint64_t
Definition: stdint.h:13
static u32 ror32(u32 v, int bits)
Rotate 32-bit value right.
Definition: wpa_tkip.c:161
static __attribute__((always_inline)) uint8_t rol8(uint8_t data
unsigned char uint8_t
Definition: stdint.h:10
static unsigned int rotation
Definition: rotate.h:14
unsigned int uint32_t
Definition: stdint.h:12
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
static u16 ror16(u16 v, int bits)
Rotate 16-bit value right.
Definition: wpa_tkip.c:149
struct arbelprm_port_state_change_st data
Message.
Definition: arbel.h:12