-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from Srekel/srekel-bitfields-deluxe
Added better support for bitfields.
- Loading branch information
Showing
7 changed files
with
219 additions
and
33 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// auto generated by c2z | ||
const std = @import("std"); | ||
//const cpp = @import("cpp"); | ||
|
||
pub const Bitfields = extern struct { | ||
bitfield_1: packed struct(u64) { | ||
bitfield1: u10, // 10 bits | ||
bitfield2: u10, // 20 bits | ||
/// C2Z WARNING: This perhaps shouldn't be padded in this way! | ||
/// Padding added by c2z | ||
_dummy_padding: u44, | ||
}, | ||
bitfield_2: packed struct(u32) { | ||
bitfield3: u5, // 5 bits | ||
bitfield4: i5, // 10 bits | ||
/// C2Z WARNING: This perhaps shouldn't be padded in this way! | ||
/// Padding added by c2z | ||
_dummy_padding: u22, | ||
}, | ||
bitfield_3: packed struct(u8) { | ||
bitfield5: u2, // 2 bits | ||
bitfield6: u2, // 4 bits | ||
bitfield7: u2, // 6 bits | ||
/// C2Z WARNING: This perhaps shouldn't be padded in this way! | ||
/// Padding added by c2z | ||
_dummy_padding: u2, | ||
}, | ||
bitfield_4: packed struct(u32) { | ||
bitfield8: i31, // 31 bits | ||
/// C2Z WARNING: This perhaps shouldn't be padded in this way! | ||
/// Padding added by c2z | ||
_dummy_padding: u1, | ||
}, | ||
bitfield_5: packed struct(u64) { | ||
bitfield9: i30, // 30 bits | ||
/// TODO: Add test of 0-length bitfield here | ||
/// long long : 0; | ||
bitfield11: i30, // 60 bits | ||
/// Padding added by c2z | ||
_dummy_padding: u4, | ||
}, | ||
}; | ||
|
||
extern fn _1_size_of_Bitfields_() c_int; | ||
pub const size_of_Bitfields = _1_size_of_Bitfields_; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// auto generated by c2z | ||
#include <new> | ||
#include "c024_cpp_bitfields.h" | ||
|
||
extern "C" int _1_size_of_Bitfields_() { return ::size_of_Bitfields(); } |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#include "c024_cpp_bitfields.h" | ||
|
||
int size_of_Bitfields(){ | ||
return sizeof(Bitfields); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
typedef struct Bitfields | ||
{ | ||
unsigned long long bitfield1 : 10; | ||
unsigned long long bitfield2 : 10; | ||
unsigned long bitfield3 : 5; | ||
signed long bitfield4 : 5; | ||
bool bitfield5 : 2; | ||
char bitfield6 : 2; | ||
unsigned char bitfield7 : 2; | ||
int bitfield8 : 31; | ||
long long bitfield9 : 30; | ||
// TODO: Add test of 0-length bitfield here | ||
// long long : 0; | ||
long long bitfield11 : 30; | ||
} Bitfields; | ||
|
||
int size_of_Bitfields(); |
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