Browse Source

[bitops] Provide BIT_QWORD_PTR()

Provide BIT_QWORD_PTR() to allow for easy extraction of non-endian
fields (e.g. Infiniband GUIDs) without unnecessary byte swapping.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
1fcd4223cc
1 changed files with 7 additions and 0 deletions
  1. 7
    0
      src/include/ipxe/bitops.h

+ 7
- 0
src/include/ipxe/bitops.h View File

@@ -212,6 +212,13 @@ typedef unsigned char pseudo_bit_t;
212 212
 		   BIT_ASSEMBLE_6 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),     \
213 213
 				    _field1, __VA_ARGS__ ) )
214 214
 
215
+#define BIT_QWORD_PTR( _ptr, _field )					      \
216
+	( {								      \
217
+		unsigned int __index = QWORD_OFFSET ( _ptr, _field );	      \
218
+		uint64_t *__ptr = &(_ptr)->u.qwords[__index];		      \
219
+		__ptr;							      \
220
+	} )
221
+
215 222
 /** Extract value of named field */
216 223
 #define BIT_GET64( _ptr, _field )					      \
217 224
 	( {								      \

Loading…
Cancel
Save