[fbsd_questions] i386 vs amd64, on intel_64

2010-10-04 Thread spellberg_robert

howdy, y'all ---

these may be stupid questions and, if so, i am prepared to slap my forehead 
with the palm of my hand.



i recently acquired my first batch of intel cpus with 64_bit integer registers 
[ celeron 440 ],
  specifically for the 16 registers and the potential for a truly_gargantuan 
datasize.
intel has called this many things, currently intel 64 architecture.

to me, this is just a bigger, faster 386,
  just like my 486 and several flavors of pentium [ now, all retired ].
i have never owned an amd cpu.
this may be the source of my confusion.

what prompted my recent searches was the observation, while working on my 
killer_app,
  in machine/types.h, as i recall, that the size of an intptr is 32_bits.
[ i am aware of the gcc double_integer implementation of 64_bit 
data_integers.
  that is not the issue; i want big memory.
]
i want my app to exist in two sizes, small [ 8_, 16_ and 32_bit integers and 
32_bit pointers ] and
  large [ 8_, 16_, 32_ and 64_bit integers and 48_bit pointers ],
  the choice between the two being made by my users, according to their needs.
my objective is to produce both versions, simultaneously.

so, i have been looking at many pages, mostly at freebsd.org [ http and ftp ] 
and gcc.gnu.org,
  as well as some others [ release notes, in particular ].
the last question is the big one.



consider a dvd_image [ to pick an approach ] of a release to be found on 
ftp.freebsd.org.

  q:if the release_name includes the string i386,
  am i restricted to 8 32_bit registers and 32_bit pointers,
  notwithstanding its installation on an intel_64 platform ?



next, from what i have been reading,
  those releases whose names contain amd64 not only are for amd cpus, but, 
also,
  are for the intel_64 variant [ no doubt, probing the cpu for its feature_set 
].

  q:if i install an amd64 version on an intel_64 platform,
  am i restricted to 16 64_bit registers and 48_bit pointers or
  can i compile for both cpu_models
  [ perhaps, with nothing more complicated than a compiler option ] ?



please cc.
in advance, thanks big_time.

rob

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: [fbsd_questions] i386 vs amd64, on intel_64

2010-10-04 Thread David Brodbeck
On Mon, Oct 4, 2010 at 12:51 PM, spellberg_robert email...@emailrob.com wrote:
  q:    if i install an amd64 version on an intel_64 platform,
          am i restricted to 16 64_bit registers and 48_bit pointers or
          can i compile for both cpu_models
          [ perhaps, with nothing more complicated than a compiler option ] ?

Take a look at gcc's -m32 and -m64 options.
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: [fbsd_questions] i386 vs amd64, on intel_64

2010-10-04 Thread spellberg_robert

hmmm ..., you did not answer the question that i asked.

per your statement, on i386, amd64 or both ?



David Brodbeck wrote:

On Mon, Oct 4, 2010 at 12:51 PM, spellberg_robert email...@emailrob.com wrote:


q:if i install an amd64 version on an intel_64 platform,
am i restricted to 16 64_bit registers and 48_bit pointers or
can i compile for both cpu_models
[ perhaps, with nothing more complicated than a compiler option ] ?



Take a look at gcc's -m32 and -m64 options.




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: [fbsd_questions] i386 vs amd64, on intel_64

2010-10-04 Thread David Brodbeck
On a 64-bit system, if you build a binary with the -m32 flag, it
should run on both i386 and x86-64 systems.  A binary built with -m64
will only run on x86-64.  Does that help?

On Mon, Oct 4, 2010 at 1:45 PM, spellberg_robert email...@emailrob.com wrote:
 hmmm ..., you did not answer the question that i asked.

 per your statement, on i386, amd64 or both ?



 David Brodbeck wrote:

 On Mon, Oct 4, 2010 at 12:51 PM, spellberg_robert email...@emailrob.com
 wrote:

 q:    if i install an amd64 version on an intel_64 platform,
        am i restricted to 16 64_bit registers and 48_bit pointers or
        can i compile for both cpu_models
        [ perhaps, with nothing more complicated than a compiler option ]
 ?


 Take a look at gcc's -m32 and -m64 options.




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: [fbsd_questions] i386 vs amd64, on intel_64

2010-10-04 Thread Michael Powell
spellberg_robert wrote:

[snip] 
 consider a dvd_image [ to pick an approach ] of a release to be found on
 ftp.freebsd.org.
 
q:if the release_name includes the string i386,
am i restricted to 8 32_bit registers and 32_bit pointers,
notwithstanding its installation on an intel_64 platform ?

I am certainly not an expert, and if I am interpreting the question 
correctly I believe the answer here would be yes. x86 processors of today 
can run either 32 bit or 64 bit OS. For example, you could install a 32 bit 
Windows XP and it would run as 32 bit even thought the processor has 64 bit 
capability. The restriction you are asking about here would be as a result 
of using a 32 bit OS and not because of processor capabilities.

 
 next, from what i have been reading,
those releases whose names contain amd64 not only are for amd cpus,
but, also, are for the intel_64 variant [ no doubt, probing the cpu for
its feature_set ].
 
q:if i install an amd64 version on an intel_64 platform,
am i restricted to 16 64_bit registers and 48_bit pointers or
can i compile for both cpu_models
[ perhaps, with nothing more complicated than a compiler option
[ ] ?
 

The amd64 stuck primarily because the 64 bit extensions were initially 
pioneered by AMD, and subsequently copied by Intel. Generally speaking, for 
the most part it is possible to run 32 bit binaries on a 64 bit OS installed 
to 64 bit x86 CPU hardware. Another Windows example: Let's say you have 64 
bit version of Windows installed. It can run 32 bit apps using WoW, or 
Windows on Windows. amd64 processor can execute either 32 bit or 64 bit 
simultaneously providing there are libraries contained within the OS to 
facilitate this. You just wouldn't really want to do this because it is 
slow.

I do not know enough about this as I have never had a need, but I think 
similar facilities exist in FreeBSD. You can install amd64 to a 64 bit CPU 
and still execute 32 bit software using a 32 compatibility library set. Look 
at the GENERIC kernel config file for amd64 and you will see a line like 
this:

options COMPAT_FREEBSD32# Compatible with i386 binaries 

You need to have the 32 bit library set built and installed. Investigate 
this particular subject for further (and better) explanation. It isn't so 
much a matter of compiling an app for both models as it is where they will 
run. You cannot compile an app as 64 bit and run it on an i386 OS install, 
whether or not the CPU is 64 bit. But with the help of 32 bit compatibility 
libs you _can_ run a 32 bit binary on a 64 bit OS installed to a 64 bit 
processor.

-Mike



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: [fbsd_questions] i386 vs amd64, on intel_64

2010-10-04 Thread Dan Nelson
In the last episode (Oct 04), David Brodbeck said:
 On a 64-bit system, if you build a binary with the -m32 flag, it
 should run on both i386 and x86-64 systems.  A binary built with -m64
 will only run on x86-64.  Does that help?

Actually, -m32 on amd64 won't generate usable binaries, since
/usr/include/machine/* are all amd64 headers and you end up with things like
struct FILE with wrong-size elements.  There was a thread a few weeks ago
discussing this.  If you need to generate 32-bit executables, you'll need to
do it inside an all-32-bit chroot or a virtual machine.

-- 
Dan Nelson
dnel...@allantgroup.com
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: [fbsd_questions] i386 vs amd64, on intel_64

2010-10-04 Thread spellberg_robert

aha !

this relates to what i found in machine/types.h,
  on my existing i386 version of freebsd on my intel_64 hardware platform.

i will look into the questions archive.

meanwhile, back at the ranch,
  does this mean that i need the amd64 version of freebsd to get the right 
headers ?



Dan Nelson wrote:

In the last episode (Oct 04), David Brodbeck said:


On a 64-bit system, if you build a binary with the -m32 flag, it
should run on both i386 and x86-64 systems.  A binary built with -m64
will only run on x86-64.  Does that help?



Actually, -m32 on amd64 won't generate usable binaries, since
/usr/include/machine/* are all amd64 headers and you end up with things like
struct FILE with wrong-size elements.  There was a thread a few weeks ago
discussing this.  If you need to generate 32-bit executables, you'll need to
do it inside an all-32-bit chroot or a virtual machine.




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: [fbsd_questions] i386 vs amd64, on intel_64

2010-10-04 Thread spellberg_robert

well, i looked at questions back to the beginning of august.

on aug_09 i found a thread that suggests the following questions.



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 ?

  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 ?

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

  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 ?



  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 ?



  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
  ] ?



again, i thank you for your assistance.

rob







Dan Nelson wrote:

In the last episode (Oct 04), David Brodbeck said:


On a 64-bit system, if you build a binary with the -m32 flag, it
should run on both i386 and x86-64 systems.  A binary built with -m64
will only run on x86-64.  Does that help?



Actually, -m32 on amd64 won't generate usable binaries, since
/usr/include/machine/* are all amd64 headers and you end up with things like
struct FILE with wrong-size elements.  There was a thread a few weeks ago
discussing this.  If you need to generate 32-bit executables, you'll need to
do it inside an all-32-bit chroot or a virtual machine.




___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org


Re: [fbsd_questions] i386 vs amd64, on intel_64

2010-10-04 Thread Dan Nelson
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
dnel...@allantgroup.com
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to freebsd-questions-unsubscr...@freebsd.org