Преглед изворни кода

[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 пре 8 година
родитељ
комит
1fcd4223cc
1 измењених фајлова са 7 додато и 0 уклоњено
  1. 7
    0
      src/include/ipxe/bitops.h

+ 7
- 0
src/include/ipxe/bitops.h Прегледај датотеку

212
 		   BIT_ASSEMBLE_6 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),     \
212
 		   BIT_ASSEMBLE_6 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ),     \
213
 				    _field1, __VA_ARGS__ ) )
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
 /** Extract value of named field */
222
 /** Extract value of named field */
216
 #define BIT_GET64( _ptr, _field )					      \
223
 #define BIT_GET64( _ptr, _field )					      \
217
 	( {								      \
224
 	( {								      \

Loading…
Откажи
Сачувај