how 64bit bitfield?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

how 64bit bitfield?

1,379件の閲覧回数
ivanzoli
Contributor I

Hi,

i am porting a library from 32bit ARM to CW for MPC5644A. I have a structure like this that is sent ont a communication line:

struct {
   u64 time : 44; // msec since 1/1/1970
   u64 id : 6; // msg id
} field;

with u64 defined as unisigned long long.

I'd prefer to avoid to break time in L and H part as:

struct {
   u32 pass_time_l; // msec since 1/1/1970
   u32 pass_time_h : 12; // msec since 1/1/1970
   u32 two_way_id : 6; // two_way_id
} field;

beacuse there is a lot of code to change. Is there any solution?

Thank you, regards

Ivan

0 件の賞賛
返信
2 返答(返信)

996件の閲覧回数
martin_kovar
NXP Employee
NXP Employee

Hello Ivan,

you can definitely use the solution you described, but I do not know the use case and I do not know, what should be stored in pass_time_l and pass_time_h variables. But if you need somewhere in your calculation 64-bit integer, you must concatenate pass_time_l and pass_time_h using bit shifting.

Regards,

Martin

0 件の賞賛
返信

996件の閲覧回数
ivanzoli
Contributor I

Thank you :smileyhappy:

0 件の賞賛
返信