B
Balban
Hello,
I wrote some piece of software that mostly assumes 32 bit systems. I
defined types such as u32, u64. The general convention I use has been
always to use int or unsigned int, and when I use a pointer for
arithmetic I use unsigned long (I never target 16 bit and this is
mostly safe on 32bit/64bit systems), and I use u32, u64 only when I am
sure that the type has to be that size.
Now, If I move to a 64 bit system, what precautions should I consider
to support my software?
One issue is the API that I provide. Consider this function prototype:
int my_api_call(unsigned int type, unsigned int flags);
There are API functions like this and most of them take flags in an
unsigned int. If I passed arguments in u64 today, it would mean
passing too much data in 32 bit sysems. If I continue to pass unsigned
int, the flags provided in 0-31 would be fine on both systems, but I
won't be able to pass anything on 32 onwards in a 32 bit system. Is
there good way to design this right from the start?
Thanks,
Bahadir
I wrote some piece of software that mostly assumes 32 bit systems. I
defined types such as u32, u64. The general convention I use has been
always to use int or unsigned int, and when I use a pointer for
arithmetic I use unsigned long (I never target 16 bit and this is
mostly safe on 32bit/64bit systems), and I use u32, u64 only when I am
sure that the type has to be that size.
Now, If I move to a 64 bit system, what precautions should I consider
to support my software?
One issue is the API that I provide. Consider this function prototype:
int my_api_call(unsigned int type, unsigned int flags);
There are API functions like this and most of them take flags in an
unsigned int. If I passed arguments in u64 today, it would mean
passing too much data in 32 bit sysems. If I continue to pass unsigned
int, the flags provided in 0-31 would be fine on both systems, but I
won't be able to pass anything on 32 onwards in a 32 bit system. Is
there good way to design this right from the start?
Thanks,
Bahadir