This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [AVR][PATCH] Add linker relaxation support / Fix 64 bit bug ingas rev. 3
Hi Björn,
You should only use this header if HAVE_INTTYPES_H is defined. If it is
not defined you should provide an alternative definition of the types
that you are using.
Basically the only thing I need for fixing the problem is an expression for
"integer type that is large enough to hold a pointer". <inttypes.h> provides
intptr_t that does the job. I thought this to be the cleaner way than simply
using "(unsigned long long int)" for all of the targets. But if one could not
assume that <inttypes.h> is present, I might as well use casts to long
longs.? The difficulty shows up only at two places and is not performance
relevant. However, I assume that a similar issue certainly shows up also
elsewere in binutils, so that I think that there should be a standard method
for this problem.?
Well the cleanest way to resolve this problem is to use a union. ie:
typedef union { int mod; void * ptr; } avr_mod_hash_value;
...
for (i = 0; i < ARRAY_SIZE (exp_mod); ++i)
{
avr_mod_hash_value v;
v.mod = i + 10;
hash_insert (avr_mod_hash, EXP_MOD_NAME (i), v.ptr);
}
...
if (op[0])
{
avr_mod_hash_value v;
v.ptr = hash_find (avr_mod_hash, op);
mod = v.mod;
Cheers
Nick