mirror of
https://github.com/xcat2/xNBA.git
synced 2024-12-15 07:41:45 +00:00
Add Linux-compatible rol32/ror32 functions. Amazingly, gcc will
optimise these down to the correct single "roll"/"rorl" instruction.
This commit is contained in:
parent
6a765fdc15
commit
9cf5c4557d
19
src/include/gpxe/bitops.h
Normal file
19
src/include/gpxe/bitops.h
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef _GPXE_BITOPS_H
|
||||
#define _GPXE_BITOPS_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* Bit operations
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
static inline uint32_t rol32 ( uint32_t data, unsigned int rotation ) {
|
||||
return ( ( data << rotation ) | ( data >> ( 32 - rotation ) ) );
|
||||
}
|
||||
|
||||
static inline uint32_t ror32 ( uint32_t data, unsigned int rotation ) {
|
||||
return ( ( data >> rotation ) | ( data << ( 32 - rotation ) ) );
|
||||
}
|
||||
|
||||
#endif /* _GPXE_BITOPS_H */
|
Loading…
Reference in New Issue
Block a user