]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[bitops] Provide BIT_QWORD_PTR()
authorMichael Brown <mcb30@ipxe.org>
Tue, 24 Nov 2015 17:28:23 +0000 (17:28 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 1 Dec 2015 23:56:27 +0000 (23:56 +0000)
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>
src/include/ipxe/bitops.h

index 2e22c1dbc464ed7348dcfe2fed2d0aeaf22618e7..93eb663e24957c39dba5be90f2d0e70c525f8e44 100644 (file)
@@ -212,6 +212,13 @@ typedef unsigned char pseudo_bit_t;
                   BIT_ASSEMBLE_6 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),     \
                                    _field1, __VA_ARGS__ ) )
 
+#define BIT_QWORD_PTR( _ptr, _field )                                        \
+       ( {                                                                   \
+               unsigned int __index = QWORD_OFFSET ( _ptr, _field );         \
+               uint64_t *__ptr = &(_ptr)->u.qwords[__index];                 \
+               __ptr;                                                        \
+       } )
+
 /** Extract value of named field */
 #define BIT_GET64( _ptr, _field )                                            \
        ( {                                                                   \