Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 4 Oct 2010 22:41:50 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        spellberg_robert <emailrob@emailrob.com>
Cc:        fbsd_questions <freebsd-questions@freebsd.org>
Subject:   Re: [fbsd_questions] i386 vs amd64, on intel_64
Message-ID:  <20101005034150.GL40148@dan.emsphone.com>
In-Reply-To: <4CAA654B.7040409@emailrob.com>
References:  <4CAA3030.3090001@emailrob.com> <AANLkTintm_XubwCCRNJci99Y4M6nwbFr=oiKqBw2%2Ba9M@mail.gmail.com> <4CAA3CFE.1060609@emailrob.com> <AANLkTi=e8cBqd6Z=zxOxpMZm_RD=-RODupzprK843=qF@mail.gmail.com> <20101004225757.GK40148@dan.emsphone.com> <4CAA654B.7040409@emailrob.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Oct 05), spellberg_robert said:
> well, i looked at questions back to the beginning of august.
> 
> on aug_09 i found a thread that suggests the following questions.

You might want to just use "i386" and "amd64" instead of making up your own
terminology ("i_386", "intel_64", "amd_64", etc).  Note that Intel has chips
that support two competing 64-bit instruction sets: ia64, which is used by
their Itanium line, and amd64, which originated on AMD chips but Intel
adopted for their 64-bit-capable x86 chips (Xeon, Core etc).  I'll assume
that any time you say "intel_64" or "amd_64" you really mean amd64, since
nobody uses Itaniums :)
 
> for a given release of freebsd,
> 
>    q:    is it that the version labeled "i386" contains only 32_bit
>            headers and source, which creates the 32_bit version of
>            freebsd, as well as 32_bit versions of what i write, which will
>            run as 32_bit code on either i_386, intel_64 or amd_64 ?

Yes, assuming you have COMPAT_FREEBSD32 in your kernel config (which GENERIC
has, so most people have it).
 
>    q:    is it that the version labeled "amd64" contains only 64_bit headers and source,
>            which creates the 64_bit version of freebsd, as well as 64_bit
>            versions of what i write, which will run as 64_bit code on the
>            intel_64 and the amd_64, but, not the i_386 ?

Yes.
 
>    q:    if a "i386" version is installed on an intel_64 platform, then
>            the pointers are 32_bits_wide, no matter what ?

Yes.  FreeBSD's models are ILP32 (int, long, pointer are all 32-bit) or LP64
(int is 32-bit, long and pointer are 64-bit).
 
>    q:    if i want to produce both 32_bit and 64_bit versions of my
>            "killer_app", then i need two machines,
>              one       a 32_bit or          a 64_bit running "i386",
>              the other             --only-- a 64_bit running "amd64" ?

Or an amd64 machine with a 32-bit world installed in a subdirectory that you
can chroot to to do your 32-bit compiles, or a virtual machine running a
32-bit world.

>    q:    given that i have intel_64 hardware,
>            do i need to start acquiring the "amd64" versions of the
>            releases, rather_than / in_addition_to the "i386" versions ?

If you have more than 4GB of ram, it would be a good idea.  If you have 4GB
or less, then 64-bit mode doesn't buy you much, and may cost you performance
since all your pointers take up twice the space, filling up your L1/L2
caches twice as fast.

>    q:    given that --i-- am committed to 64_bit hardware, perhaps, i
>            should give up on the "i386" versions of the releases and
>            require my users to spend us$_300 on 64_bit hardware [ it would
>            save a large number of conditional_compilation directives;
>                nudge_nudge, wink_wink, say no more
>            ] ?

Or provide source and let the users compile what they need on their own
machines.  Assuming you code using the appropriate types (size_t, intptr_t,
etc, or int32_t and int64_t for when you know you need a particular word
size) instead of assuming that a pointer will fit in an int, your code
should compile on either 32- or 64-bit machines with no conditional code.

http://www.opengroup.org/onlinepubs/9699919799/basedefs/stdint.h.html
 
-- 
	Dan Nelson
	dnelson@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101005034150.GL40148>