From 9cf5c4557d570fac79b1fe2c908a81e272fe1102 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 24 Jan 2007 23:31:58 +0000 Subject: [PATCH] Add Linux-compatible rol32/ror32 functions. Amazingly, gcc will optimise these down to the correct single "roll"/"rorl" instruction. --- src/include/gpxe/bitops.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/include/gpxe/bitops.h diff --git a/src/include/gpxe/bitops.h b/src/include/gpxe/bitops.h new file mode 100644 index 00000000..9e2fc7cb --- /dev/null +++ b/src/include/gpxe/bitops.h @@ -0,0 +1,19 @@ +#ifndef _GPXE_BITOPS_H +#define _GPXE_BITOPS_H + +/** @file + * + * Bit operations + */ + +#include + +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 */