Problem with sizeof?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines
I am not sure, but can this be memory allignment problem ?
you can check this by adding one more (dummy ) element of__u32length (MIPS should print 40 insted of 44 and pc shuld print 40 as expected )
You are right. when I add a __u32 dummy to the tc_stats then it still prints the size as 40. Is it get padded at the end? My main concern is, is this a normal behavior or do I need to upgrade my MIPS build environment?
Thanks a lot,
Muthu.
Quoted 51 lines
if it works then you can get rid of the above problem by changing the compilar settings.
Regards,
venkatesh M RQuoted 38 lines · Muthukumar Ratty
Hi,
In my MIPS systemsizeof(struct tc_stats)returns 40 but it returns 36 in i386 PC.
tc_statsis defined ininclude/linux/pkt_sched.cas structtc_stats
{__u64 bytes; /* NUmber of enqueues bytes */ __u32 packets; /* Number of enqueued packets */ __u32 drops; /* Packets dropped because of lackof resources */
__u32overlimits; /* Number of throttle events when
this
* flow goes out of allocated
bandwidth*/__u32 bps; /* Current flow byte rate */ __u32 pps; /* Current flow packet rate */ __u32 qlen; __u32 backlog; #ifdef __KERNEL__ spinlock_t *lock;#endif
};
I printed the offsets of individual fields and they are same in i386 and MIPS. If the "spinlock_t" is defined then this may be the case but I am compiling an application, so it shouldnt be there? Right now I think the problem could be with the "sizeof" operator.
Could someone please let me know if this is the case or I am doing something wrong. Also any solution.The versions are
kernel : 2.4.3
gcc : gcc version 3.1
binutils : 2.11.93
glibc : 2.2.5Thanks,
Muthu.
Quoted 8 lines · Muthukumar Ratty
Quoted 3 lines
I am not sure, but can this be memory allignment problem ?
you can check this by adding one more (dummy ) element of__u32length (MIPS should print 40 insted of 44 and pc shuld print 40 as expected )You are right. when I add a
__u32dummy to thetc_statsthen it still prints the size as 40. Is it get padded at the end? My main concern is, is this a normal behavior or do I need to upgrade my MIPS build environment?
The alignment rule for 64-bit value is 8 bytes on MIPS, and only 4 bytes on ia32.
Since sizeof(struct ...) must return a value that's a multiple of the alignment rule for the largest element in the struct, it returns 40 on MIPS.
Quoted 44 lines
Thanks a lot,
Muthu.Quoted 41 lines
if it works then you can get rid of the above problem by changing the compilar settings.
Regards,
venkatesh M RQuoted 29 lines · Muthukumar Ratty
Hi,
In my MIPS systemsizeof(struct tc_stats)returns 40 but it returns 36 in i386 PC.
tc_statsis defined ininclude/linux/pkt_sched.cas structtc_stats
{__u64 bytes; /* NUmber of enqueues bytes */ __u32 packets; /* Number of enqueued packets */ __u32 drops; /* Packets dropped because of lackof resources */
__u32overlimits; /* Number of throttle events when
this
* flow goes out of allocated
bandwidth*/__u32 bps; /* Current flow byte rate */ __u32 pps; /* Current flow packet rate */ __u32 qlen; __u32 backlog; #ifdef __KERNEL__ spinlock_t *lock;#endif
};
I printed the offsets of individual fields and they are same in i386 and MIPS. If the "spinlock_t" is defined then this may be the case but I am compiling an application, so it shouldnt be there? Right now I think the problem could be with the "sizeof" operator.
Could someone please let me know if this is the case or I am doing something wrong. Also any solution.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Hi Geert,
The main reason I thought my environment could be broken is because I got the problem with iproute2 by Alexey!! Anyway I sent a mail to Alexey to check with him.
Thanks,
Muthu
Quoted 72 lines · Geert Uytterhoeven
Quoted 8 lines · Muthukumar Ratty
Quoted 3 lines
I am not sure, but can this be memory allignment problem ?
you can check this by adding one more (dummy ) element of__u32length (MIPS should print 40 insted of 44 and pc shuld print 40 as expected )You are right. when I add a
__u32dummy to thetc_statsthen it still prints the size as 40. Is it get padded at the end? My main concern is, is this a normal behavior or do I need to upgrade my MIPS build environment?The alignment rule for 64-bit value is 8 bytes on MIPS, and only 4 bytes on ia32.
Since sizeof(struct ...) must return a value that's a multiple of the alignment rule for the largest element in the struct, it returns 40 on MIPS.
Quoted 44 lines
Thanks a lot,
Muthu.Quoted 41 lines
if it works then you can get rid of the above problem by changing the compilar settings.
Regards,
venkatesh M RQuoted 29 lines · Muthukumar Ratty
Hi,
In my MIPS systemsizeof(struct tc_stats)returns 40 but it returns 36 in i386 PC.
tc_statsis defined ininclude/linux/pkt_sched.cas structtc_stats
{__u64 bytes; /* NUmber of enqueues bytes */ __u32 packets; /* Number of enqueued packets */ __u32 drops; /* Packets dropped because of lackof resources */
__u32overlimits; /* Number of throttle events when
this
* flow goes out of allocated
bandwidth*/__u32 bps; /* Current flow byte rate */ __u32 pps; /* Current flow packet rate */ __u32 qlen; __u32 backlog; #ifdef __KERNEL__ spinlock_t *lock;#endif
};
I printed the offsets of individual fields and they are same in i386 and MIPS. If the "spinlock_t" is defined then this may be the case but I am compiling an application, so it shouldnt be there? Right now I think the problem could be with the "sizeof" operator.
Could someone please let me know if this is the case or I am doing something wrong. Also any solution.Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds