Mailinglist Archive: opensuse-programming (118 mails)

< Previous Next >
Re: [suse-programming-e] Programming standards!
  • From: Jerry Feldman <gaf@xxxxxxx>
  • Date: Tue, 19 Apr 2005 10:30:32 -0400
  • Message-id: <200504191030.32595.gaf@xxxxxxx>
On Tuesday 19 April 2005 10:09 am, Colin Carter wrote:
> Jerry also mentioned the correct use of multiples of "natural" units.
> I think I will use 64 bit integers (on my AMD64) because I think it ought
> to be faster than 32 bit, and memory is 'cheaper' than cpu speed, and one
> pays for memory once, but for cpu time every time you run the code.
64-bit systems generally use the LP64 method, which means that both pointers
and long integers are 64-bits while int remains at 32-bits. Most Unix and
Linux systems use this. You will not pay a penalty for using a 32-bit int.
C and C++ will automatically align your data for you:
struct {
char a; /* aligned on at least a 64-bit boundary probably 128 */
long b; /* aligned on a 64-bit boundary */
};
The above structure is 16 bytes long with 7 bytes inserted as a filler
between a and b. (on a 32-bit system, the filler would be 3 bytes).
--
Jerry Feldman <gaf@xxxxxxx>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9

< Previous Next >