Fix R_PACKED() macro usage (#16571)

This commit is contained in:
Anton Kochkov 2020-04-14 01:55:00 +08:00 committed by GitHub
parent 09cc1b670a
commit 69ad1aeffe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 2 deletions

View File

@ -331,6 +331,26 @@ You may use directory-local variables by putting
into `.dir-locals.el`.
## Packed structures
Due to the various differences between platforms and compilers radare2
has a special helper macro - `R_PACKED()`. Instead of non-portable
`#pragma pack` or `__attribute__((packed))` it is advised to use this macro
instead. To wrap the code inside of it you just need to write:
```c
R_PACKED (union mystruct {
int a;
char b;
})
```
or in case of typedef:
```c
R_PACKED (typedef structmystruct {
int a;
char b;
})
```
## Modules
The radare2 code base is modularized into different libraries that are

View File

@ -47,7 +47,7 @@ typedef struct LE_entry_bundle_header_s {
#define ENTRY_EXPORTED 0x01
#define ENTRY_PARAM_COUNT_MASK 0xF8
typedef R_PACKED (union LE_entry_bundle_entry_u {
R_PACKED (typedef union LE_entry_bundle_entry_u {
R_PACKED (struct {
ut8 flags; // First bit set if exported, mask with 0xF8 to get parameters count
ut16 offset; // This is the offset in the object for the entry point defined at this ordinal number.

View File

@ -13,7 +13,7 @@ typedef double ft64;
#define WIRE_END_GRP 4 // groups (deprecated)
#define WIRE_32_BIT 5 // fixed32, sfixed32, float
typedef R_PACKED (struct _proto_head {
R_PACKED (typedef struct _proto_head {
ut8 wire : 3;
ut8 number : 5;
}) proto_head_t;