Created
February 7, 2022 19:16
-
-
Save lucasdemarchi/e0b32dce41815ef8b8f46f574aa8d699 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* iosys_map_rd_field - Read a member from a struct in the iosys_map | |
* | |
* @map__: The iosys_map structure | |
* @struct_offset__: Offset from the beggining of the map, where the struct | |
* is located | |
* @struct_type__: The struct describing the layout of the mapping | |
* @field__: Member of the struct to read | |
* | |
* Read a value from iosys_map assuming its layout is described by a struct, | |
* starting on ``struct_offset__``. The offset and size to the struct member is | |
* calculated and possible un-aligned accesses to the mapping handled. This is | |
* the expected memory layout:: | |
* | |
* Mapped buffer <- iosys_map points here | |
* | |
* struct foo { <- struct offset to what is being read | |
* ... | |
* ... | |
* field; <- field to read and return the value | |
* ... | |
* ... | |
* } | |
* | |
* Returns: | |
* The value read from the mapping. | |
*/ | |
#define iosys_map_rd_field(map__, struct_offset__, struct_type__, field__) ({ \ | |
struct_type__ *s; \ | |
iosys_map_rd(map__, struct_offset__ + offsetof(struct_type__, field__), \ | |
typeof(s->field__)); \ | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment