summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2007-01-25 00:31:58 +0100
committerMichael Brown2007-01-25 00:31:58 +0100
commit9cf5c4557d570fac79b1fe2c908a81e272fe1102 (patch)
tree631eaabc2bc52209206e2c7569328377ef5c7be8
parentUse base "0" in strtoul for consistency with "mem=" (diff)
downloadipxe-9cf5c4557d570fac79b1fe2c908a81e272fe1102.tar.gz
ipxe-9cf5c4557d570fac79b1fe2c908a81e272fe1102.tar.xz
ipxe-9cf5c4557d570fac79b1fe2c908a81e272fe1102.zip
Add Linux-compatible rol32/ror32 functions. Amazingly, gcc will
optimise these down to the correct single "roll"/"rorl" instruction.
-rw-r--r--src/include/gpxe/bitops.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/include/gpxe/bitops.h b/src/include/gpxe/bitops.h
new file mode 100644
index 000000000..9e2fc7cbe
--- /dev/null
+++ b/src/include/gpxe/bitops.h
@@ -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 */