Sfoglia il codice sorgente

Add Linux-compatible rol32/ror32 functions. Amazingly, gcc will

optimise these down to the correct single "roll"/"rorl" instruction.
tags/v0.9.3
Michael Brown 18 anni fa
parent
commit
9cf5c4557d
1 ha cambiato i file con 19 aggiunte e 0 eliminazioni
  1. 19
    0
      src/include/gpxe/bitops.h

+ 19
- 0
src/include/gpxe/bitops.h Vedi File

@@ -0,0 +1,19 @@
1
+#ifndef _GPXE_BITOPS_H
2
+#define _GPXE_BITOPS_H
3
+
4
+/** @file
5
+ *
6
+ * Bit operations
7
+ */
8
+
9
+#include <stdint.h>
10
+
11
+static inline uint32_t rol32 ( uint32_t data, unsigned int rotation ) {
12
+        return ( ( data << rotation ) | ( data >> ( 32 - rotation ) ) );
13
+}
14
+
15
+static inline uint32_t ror32 ( uint32_t data, unsigned int rotation ) {
16
+        return ( ( data >> rotation ) | ( data << ( 32 - rotation ) ) );
17
+}
18
+
19
+#endif /* _GPXE_BITOPS_H */

Loading…
Annulla
Salva