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 #define ROLx( data, rotation ) \
14  ( ( (data) << (rotation) ) | \
15  ( (data) >> ( ( 8 * sizeof (data) ) - (rotation) ) ) );
16 
17 #define RORx( data, rotation ) \
18  ( ( (data) >> (rotation) ) | \
19  ( (data) << ( ( 8 * sizeof (data) ) - (rotation) ) ) );
20 
21 static inline __attribute__ (( always_inline )) uint8_t
22 rol8 ( uint8_t data, unsigned int rotation ) {
23  return ROLx ( data, rotation );
24 }
25 
26 static inline __attribute__ (( always_inline )) uint8_t
27 ror8 ( uint8_t data, unsigned int rotation ) {
28  return RORx ( data, rotation );
29 }
30 
31 static inline __attribute__ (( always_inline )) uint16_t
32 rol16 ( uint16_t data, unsigned int rotation ) {
33  return ROLx ( data, rotation );
34 }
35 
36 static inline __attribute__ (( always_inline )) uint16_t
37 ror16 ( uint16_t data, unsigned int rotation ) {
38  return RORx ( data, rotation );
39 }
40 
41 static inline __attribute__ (( always_inline )) uint32_t
42 rol32 ( uint32_t data, unsigned int rotation ) {
43  return ROLx ( data, rotation );
44 }
45 
46 static inline __attribute__ (( always_inline )) uint32_t
47 ror32 ( uint32_t data, unsigned int rotation ) {
48  return RORx ( data, rotation );
49 }
50 
51 static inline __attribute__ (( always_inline )) uint64_t
52 rol64 ( uint64_t data, unsigned int rotation ) {
53  return ROLx ( data, rotation );
54 }
55 
56 static inline __attribute__ (( always_inline )) uint64_t
57 ror64 ( uint64_t data, unsigned int rotation ) {
58  return RORx ( data, rotation );
59 }
60 
61 static inline __attribute__ (( always_inline )) unsigned long
62 roll ( unsigned long data, unsigned int rotation ) {
63  return ROLx ( data, rotation );
64 }
65 
66 static inline __attribute__ (( always_inline )) unsigned long
67 rorl ( unsigned long data, unsigned int rotation ) {
68  return RORx ( data, rotation );
69 }
70 
71 #endif /* _IPXE_ROTATE_H */
unsigned short uint16_t
Definition: stdint.h:11
#define ROLx(data, rotation)
Definition: rotate.h:13
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:22
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
#define RORx(data, rotation)
Definition: rotate.h:17