#include <stdint.h>
#include <byteswap.h>
Go to the source code of this file.
Defines | |
| #define | PSEUDO_BIT_STRUCT(_structure) |
| Wrapper structure for pseudo_bit_t structures. | |
| #define | PSEUDO_BIT_STRUCT_TYPE(_ptr) typeof ( *((_ptr)->u.dummy[0]) ) |
| Get pseudo_bit_t structure type from wrapper structure pointer. | |
| #define | BIT_OFFSET(_ptr, _field) offsetof ( PSEUDO_BIT_STRUCT_TYPE ( _ptr ), _field ) |
| Bit offset of a field within a pseudo_bit_t structure. | |
| #define | BIT_WIDTH(_ptr, _field) sizeof ( ( ( PSEUDO_BIT_STRUCT_TYPE ( _ptr ) * ) NULL )->_field ) |
| Bit width of a field within a pseudo_bit_t structure. | |
| #define | QWORD_OFFSET(_ptr, _field) ( BIT_OFFSET ( _ptr, _field ) / 64 ) |
| Qword offset of a field within a pseudo_bit_t structure. | |
| #define | QWORD_BIT_OFFSET(_ptr, _index, _field) ( BIT_OFFSET ( _ptr, _field ) - ( 64 * (_index) ) ) |
| Qword bit offset of a field within a pseudo_bit_t structure. | |
| #define | BIT_MASK(_ptr, _field) |
| Bit mask for a field within a pseudo_bit_t structure. | |
| #define | BIT_ASSEMBLE_1(_ptr, _index, _field, _value) |
| #define | BIT_ASSEMBLE_2(_ptr, _index, _field, _value,...) |
| #define | BIT_ASSEMBLE_3(_ptr, _index, _field, _value,...) |
| #define | BIT_ASSEMBLE_4(_ptr, _index, _field, _value,...) |
| #define | BIT_ASSEMBLE_5(_ptr, _index, _field, _value,...) |
| #define | BIT_ASSEMBLE_6(_ptr, _index, _field, _value,...) |
| #define | BIT_ASSEMBLE_7(_ptr, _index, _field, _value,...) |
| #define | BIT_MASK_1(_ptr, _index, _field) |
| #define | BIT_MASK_2(_ptr, _index, _field,...) |
| #define | BIT_MASK_3(_ptr, _index, _field,...) |
| #define | BIT_MASK_4(_ptr, _index, _field,...) |
| #define | BIT_MASK_5(_ptr, _index, _field,...) |
| #define | BIT_MASK_6(_ptr, _index, _field,...) |
| #define | BIT_MASK_7(_ptr, _index, _field,...) |
| #define | BIT_FILL(_ptr, _index, _assembled) |
| #define | BIT_FILL_1(_ptr, _field1,...) |
| #define | BIT_FILL_2(_ptr, _field1,...) |
| #define | BIT_FILL_3(_ptr, _field1,...) |
| #define | BIT_FILL_4(_ptr, _field1,...) |
| #define | BIT_FILL_5(_ptr, _field1,...) |
| #define | BIT_FILL_6(_ptr, _field1,...) |
| #define | BIT_GET64(_ptr, _field) |
| Extract value of named field. | |
| #define | BIT_GET(_ptr, _field) ( ( unsigned long ) BIT_GET64 ( _ptr, _field ) ) |
| Extract value of named field (for fields up to the size of a long). | |
| #define | BIT_SET(_ptr, _field, _value) |
Typedefs | |
| typedef unsigned char | pseudo_bit_t |
| Datatype used to represent a bit in the pseudo-structures. | |
Functions | |
| FILE_LICENCE (GPL2_OR_LATER) | |
Definition in file bitops.h.
| #define PSEUDO_BIT_STRUCT | ( | _structure | ) |
Value:
union { \ uint8_t bytes[ sizeof ( _structure ) / 8 ]; \ uint32_t dwords[ sizeof ( _structure ) / 32 ]; \ uint64_t qwords[ sizeof ( _structure ) / 64 ]; \ _structure *dummy[0]; \ } u
This structure provides a wrapper around pseudo_bit_t structures. It has the correct size, and also encapsulates type information about the underlying pseudo_bit_t-based structure, which allows the BIT_FILL() etc. macros to work without requiring explicit type information.
| #define PSEUDO_BIT_STRUCT_TYPE | ( | _ptr | ) | typeof ( *((_ptr)->u.dummy[0]) ) |
| #define BIT_OFFSET | ( | _ptr, | |||
| _field | ) | offsetof ( PSEUDO_BIT_STRUCT_TYPE ( _ptr ), _field ) |
| #define BIT_WIDTH | ( | _ptr, | |||
| _field | ) | sizeof ( ( ( PSEUDO_BIT_STRUCT_TYPE ( _ptr ) * ) NULL )->_field ) |
| #define QWORD_OFFSET | ( | _ptr, | |||
| _field | ) | ( BIT_OFFSET ( _ptr, _field ) / 64 ) |
| #define QWORD_BIT_OFFSET | ( | _ptr, | |||
| _index, | |||||
| _field | ) | ( BIT_OFFSET ( _ptr, _field ) - ( 64 * (_index) ) ) |
| #define BIT_MASK | ( | _ptr, | |||
| _field | ) |
| #define BIT_ASSEMBLE_1 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| _value | ) |
Value:
( ( ( uint64_t) (_value) ) << \ QWORD_BIT_OFFSET ( _ptr, _index, _field ) )
| #define BIT_ASSEMBLE_2 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| _value, | |||||
| ... | ) |
Value:
( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \ BIT_ASSEMBLE_1 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_ASSEMBLE_3 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| _value, | |||||
| ... | ) |
Value:
( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \ BIT_ASSEMBLE_2 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_ASSEMBLE_4 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| _value, | |||||
| ... | ) |
Value:
( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \ BIT_ASSEMBLE_3 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_ASSEMBLE_5 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| _value, | |||||
| ... | ) |
Value:
( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \ BIT_ASSEMBLE_4 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_ASSEMBLE_6 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| _value, | |||||
| ... | ) |
Value:
( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \ BIT_ASSEMBLE_5 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_ASSEMBLE_7 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| _value, | |||||
| ... | ) |
Value:
( BIT_ASSEMBLE_1 ( _ptr, _index, _field, _value ) | \ BIT_ASSEMBLE_6 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_MASK_1 | ( | _ptr, | |||
| _index, | |||||
| _field | ) |
Value:
( BIT_MASK ( _ptr, _field ) << \ QWORD_BIT_OFFSET ( _ptr, _index, _field ) )
| #define BIT_MASK_2 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| ... | ) |
Value:
( BIT_MASK_1 ( _ptr, _index, _field ) | \ BIT_MASK_1 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_MASK_3 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| ... | ) |
Value:
( BIT_MASK_1 ( _ptr, _index, _field ) | \ BIT_MASK_2 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_MASK_4 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| ... | ) |
Value:
( BIT_MASK_1 ( _ptr, _index, _field ) | \ BIT_MASK_3 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_MASK_5 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| ... | ) |
Value:
( BIT_MASK_1 ( _ptr, _index, _field ) | \ BIT_MASK_4 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_MASK_6 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| ... | ) |
Value:
( BIT_MASK_1 ( _ptr, _index, _field ) | \ BIT_MASK_5 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_MASK_7 | ( | _ptr, | |||
| _index, | |||||
| _field, | |||||
| ... | ) |
Value:
( BIT_MASK_1 ( _ptr, _index, _field ) | \ BIT_MASK_6 ( _ptr, _index, __VA_ARGS__ ) )
| #define BIT_FILL | ( | _ptr, | |||
| _index, | |||||
| _assembled | ) |
| #define BIT_FILL_1 | ( | _ptr, | |||
| _field1, | |||||
| ... | ) |
Value:
BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ BIT_ASSEMBLE_1 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ _field1, __VA_ARGS__ ) )
Definition at line 173 of file bitops.h.
Referenced by linda_create_recv_wq(), linda_ib_epb_release(), linda_ib_epb_request(), linda_init_recv(), linda_init_send(), linda_poll_eq(), and linda_post_recv().
| #define BIT_FILL_2 | ( | _ptr, | |||
| _field1, | |||||
| ... | ) |
Value:
BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ BIT_ASSEMBLE_2 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ _field1, __VA_ARGS__ ) )
Definition at line 178 of file bitops.h.
Referenced by linda_init_send(), linda_poll_recv_wq(), linda_post_recv(), and linda_post_send().
| #define BIT_FILL_3 | ( | _ptr, | |||
| _field1, | |||||
| ... | ) |
Value:
BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ BIT_ASSEMBLE_3 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ _field1, __VA_ARGS__ ) )
Definition at line 183 of file bitops.h.
Referenced by linda_ib_epb_read(), and linda_init_recv().
| #define BIT_FILL_4 | ( | _ptr, | |||
| _field1, | |||||
| ... | ) |
Value:
BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ BIT_ASSEMBLE_4 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ _field1, __VA_ARGS__ ) )
Definition at line 188 of file bitops.h.
Referenced by linda_ib_epb_write().
| #define BIT_FILL_5 | ( | _ptr, | |||
| _field1, | |||||
| ... | ) |
Value:
BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ BIT_ASSEMBLE_5 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ _field1, __VA_ARGS__ ) )
| #define BIT_FILL_6 | ( | _ptr, | |||
| _field1, | |||||
| ... | ) |
Value:
BIT_FILL ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ BIT_ASSEMBLE_6 ( _ptr, QWORD_OFFSET ( _ptr, _field1 ), \ _field1, __VA_ARGS__ ) )
Definition at line 198 of file bitops.h.
Referenced by linda_init_ib_serdes().
| #define BIT_GET64 | ( | _ptr, | |||
| _field | ) |
Value:
( { \
unsigned int __index = QWORD_OFFSET ( _ptr, _field ); \
uint64_t *__ptr = &(_ptr)->u.qwords[__index]; \
uint64_t __value = BIT64_to_cpu ( *__ptr ); \
__value >>= \
QWORD_BIT_OFFSET ( _ptr, __index, _field ); \
__value &= BIT_MASK ( _ptr, _field ); \
__value; \
} )
| #define BIT_GET | ( | _ptr, | |||
| _field | ) | ( ( unsigned long ) BIT_GET64 ( _ptr, _field ) ) |
Extract value of named field (for fields up to the size of a long).
Definition at line 216 of file bitops.h.
Referenced by linda_complete_recv(), linda_i2c_read_bit(), linda_i2c_write_bit(), linda_ib_epb_read(), linda_ib_epb_request(), linda_ib_epb_wait(), linda_init_recv(), linda_init_send(), linda_link_state_changed(), linda_link_state_check(), linda_poll_eq(), linda_poll_recv_wq(), linda_probe(), linda_send_buf_in_use(), and linda_trim_ib().
| #define BIT_SET | ( | _ptr, | |||
| _field, | |||||
| _value | ) |
Value:
do { \ unsigned int __index = QWORD_OFFSET ( _ptr, _field ); \ uint64_t *__ptr = &(_ptr)->u.qwords[__index]; \ unsigned int __shift = \ QWORD_BIT_OFFSET ( _ptr, __index, _field ); \ uint64_t __value = (_value); \ *__ptr &= cpu_to_BIT64 ( ~( BIT_MASK ( _ptr, _field ) << \ __shift ) ); \ *__ptr |= cpu_to_BIT64 ( __value << __shift ); \ } while ( 0 )
Definition at line 219 of file bitops.h.
Referenced by linda_close(), linda_create_recv_wq(), linda_destroy_recv_wq(), linda_i2c_write_bit(), linda_init_ib_serdes(), linda_link_state_changed(), linda_open(), linda_set_port_info(), and linda_trim_ib().
| typedef unsigned char pseudo_bit_t |
| FILE_LICENCE | ( | GPL2_OR_LATER | ) |
1.5.7.1