473,569 Members | 3,035 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

About 64-bit portability

Happy new year to everybody...

Just a few questions about porting code to 64-bit environment.

1) Is there a different version of the SDK (i.e., C/C++ compiler) for the
64-bit platform, or does the regular one just automatically know it's
targeting 64-bit?

2) (sort of following on from (1) really, but...) when compiling for the
64-bit platform, does the compilier still treat 'long' as 32-bit?

3) (following on from (1 & 2)...) If I use __int64, LONGLONG, LARGE_INTEGER,
etc. do they automatically know to make use of 64-bit registers?

4) (not following on from any) I've got some asm code that uses MMX
registers, e.g. __asm { ... movq mm0, [esp+4] ... }
Since an AMD64's standard registers (e.g. rax, rbx being double eax,
ebx) are 64-bit, does this mmx code need to be changed/upgraded.....
..............a ) in order to *work* on an AMD64?
..............b ) in order to run *optimally* on an AMD64?

5) Is there a list of types that are different on 64-bit? e.g. I know an
LPVOID is 64-bit on a 64-bit platform, but 32-bit on a 32-bit platform,
whereas some ('long' ?) are 32 bit on both...
Thanks for any insight

Jul 22 '05 #1
7 2790

"Bonj" <sp******@crayn e.org> wrote in message
news:33******** *****@individua l.net...
Happy new year to everybody...

Just a few questions about porting code to 64-bit environment.

1) Is there a different version of the SDK (i.e., C/C++ compiler) for the
64-bit platform, or does the regular one just automatically know it's
targeting 64-bit?

2) (sort of following on from (1) really, but...) when compiling for the
64-bit platform, does the compilier still treat 'long' as 32-bit?

3) (following on from (1 & 2)...) If I use __int64, LONGLONG,
LARGE_INTEGER, etc. do they automatically know to make use of 64-bit
registers?

4) (not following on from any) I've got some asm code that uses MMX
registers, e.g. __asm { ... movq mm0, [esp+4] ... }
Since an AMD64's standard registers (e.g. rax, rbx being double eax,
ebx) are 64-bit, does this mmx code need to be changed/upgraded.....
..............a ) in order to *work* on an AMD64?
..............b ) in order to run *optimally* on an AMD64?

5) Is there a list of types that are different on 64-bit? e.g. I know an
LPVOID is 64-bit on a 64-bit platform, but 32-bit on a 32-bit platform,
whereas some ('long' ?) are 32 bit on both...


Nothing you've mentioned above has anything to do with the C++ language
itself, which is what is discussed here.

You need to ask in a newsgroup devoted to the compiler and/or platform
you're referring to. (Such as on the news.microsoft. com news server?)

-Howard
Jul 22 '05 #2
Bonj wrote:
Happy new year to everybody...

Just a few questions about porting code to 64-bit environment.
Most of the questions you're asking depend on whether you're talking
about Linux or Windows platforms. I assume since you've crossposted to a
Windows newsgroup that you're talking Windows.
1) Is there a different version of the SDK (i.e., C/C++ compiler) for the
64-bit platform, or does the regular one just automatically know it's
targeting 64-bit?
I have no insight about this, again also depends on platform.
2) (sort of following on from (1) really, but...) when compiling for the
64-bit platform, does the compilier still treat 'long' as 32-bit?
From what I've heard, int is still treated as 32-bit, but long is now
64-bit.
4) (not following on from any) I've got some asm code that uses MMX
registers, e.g. __asm { ... movq mm0, [esp+4] ... }
Since an AMD64's standard registers (e.g. rax, rbx being double eax,
ebx) are 64-bit, does this mmx code need to be changed/upgraded.....
..............a ) in order to *work* on an AMD64?
..............b ) in order to run *optimally* on an AMD64?


The answer to this on the Microsoft platform is *no*. Microsoft has
specifically decided to exclude all x87-related functionality. That
means any instruction set generated off of the x87 unit is excluded,
including MMX, 3DNow, and of course x87 floating point itself. Only
SSE1-3 are supported from now on.

On Linux, I don't think there is any such restriction.

Yousuf Khan

Jul 22 '05 #3
"Bonj" <sp******@crayn e.org> wrote in message
news:33******** *****@individua l.net...
Happy new year to everybody...

Just a few questions about porting code to 64-bit environment.
Please don't cross-post to so many groups; your questions aren't relevant to
most.
1) Is there a different version of the SDK (i.e., C/C++ compiler) for the
64-bit platform, or does the regular one just automatically know it's
targeting 64-bit?
Yes, there is a different compiler for x86-64. It has not yet been released,
though last I heard it was going to ship with VS 2005. I believe you can
also get it from the DDK or something along those lines.
2) (sort of following on from (1) really, but...) when compiling for the
64-bit platform, does the compilier still treat 'long' as 32-bit?
Yes. MSDN explicitly says that int and long are 4 bytes, always. Microsoft
decided that it was better to do this so that fewer programs would break. As
a result, it is necessary to use the non-standard __int64 type (since MS
does not currently support long long) or the size_t type.
3) (following on from (1 & 2)...) If I use __int64, LONGLONG,
LARGE_INTEGER, etc. do they automatically know to make use of 64-bit
registers?
The first two definitely will. A LARGE_INTEGER will use 64-bit registers
with limitation. If you access QuadPart then yes, it will use a 64-bit
register. If you access LowPart or HighPart then the compiler will probably
use 32-bit registers. If you access QuadPart *and* you access LowPart or
HighPart, the compiler will probably store QuadPart to memory and then load
LowPart or HighPart from memory. At least, I would expect this from Visual
C++. I don't know how GCC or others fare. I don't have any x86-64 compiler,
so these are just guesses.
4) (not following on from any) I've got some asm code that uses MMX
registers, e.g. __asm { ... movq mm0, [esp+4] ... }
Since an AMD64's standard registers (e.g. rax, rbx being double eax,
ebx) are 64-bit, does this mmx code need to be changed/upgraded.....
..............a ) in order to *work* on an AMD64?
No. As was pointed out, MMX code will not run on AMD64 because the kernel
will not save the state of the x87 registers for 64-bit apps. If any other
program on the system tries to use x87, MMX, or 3DNow!, then it will
overwrite the registers and your results will get trashed.
..............b ) in order to run *optimally* on an AMD64?
Though this is sort've useless given the answer to (a), the answer to (b)
is: probably nothing. If your MMX code is optimal on K7, then it is optimal
on K8. At present, the same is largely true for the entire instruction set.

Code that uses MMX for fast 64-bit ALU ops will heavily favor conversion to
the integer instruction set. Code that uses MMX for packed ALU, swizzle, or
saturated arithmetic operations will be substantially slower if converted to
integer instructions.

You can port MMX code to SSE2 code fairly trivially in most cases. The SSE2
code may be slightly slower, though.
5) Is there a list of types that are different on 64-bit? e.g. I know an
LPVOID is 64-bit on a 64-bit platform, but 32-bit on a 32-bit platform,
whereas some ('long' ?) are 32 bit on both...


Pointers, size_t, and ptrdiff_t will be different. Microsoft has introduced
the various *_PTR types (INT_PTR, LONG_PTR, etc.) which also change. They
are basically the same as size_t. The SIZE_T type is also basically the same
as size_t. All others remain the same because Microsoft has defined them to
be constant sizes on all of their platforms.

-Matt

Jul 22 '05 #4
"Matt" <sp******@crayn e.org> writes:
"Bonj" <sp******@crayn e.org> wrote in message
news:33******** *****@individua l.net...
Happy new year to everybody...

Just a few questions about porting code to 64-bit environment.


Please don't cross-post to so many groups; your questions aren't relevant to
most.
1) Is there a different version of the SDK (i.e., C/C++ compiler) for the
64-bit platform, or does the regular one just automatically know it's
targeting 64-bit?


Yes, there is a different compiler for x86-64. It has not yet been released,
though last I heard it was going to ship with VS 2005. I believe you can
also get it from the DDK or something along those lines.
2) (sort of following on from (1) really, but...) when compiling for the
64-bit platform, does the compilier still treat 'long' as 32-bit?


Yes. MSDN explicitly says that int and long are 4 bytes, always. Microsoft
decided that it was better to do this so that fewer programs would break. As
a result, it is necessary to use the non-standard __int64 type (since MS
does not currently support long long) or the size_t type.


Does that mention of size_t mean that MS have ignored the warning given
in Clive Feather's 1999 cautionary
http://www.open-std.org/jtc1/sc22/wg...ocs/dr_201.htm
(Which while closed with no action the relevant point was reraised
a few months later and acted upon, IIRC.)

Phil
--
The gun is good. The penis is evil... Go forth and kill.

Jul 22 '05 #5
Bonj wrote:
Happy new year to everybody...

Just a few questions about porting code to 64-bit environment.

1) Is there a different version of the SDK (i.e., C/C++ compiler) for the
64-bit platform, or does the regular one just automatically know it's
targeting 64-bit?
This is compiler dependant.

For example, using GCC, the amd64 version of gcc is able to build 32 bit
binaries as well (using the -m32 flag).

On Irix, using the SGI compiler, there are 3 ABI's "o32", "n32" and
"n64", perhaps by now only the n32 and n64 ABI's are supported.

2) (sort of following on from (1) really, but...) when compiling for the
64-bit platform, does the compilier still treat 'long' as 32-bit?
Again, this is compiler dependant. It's best to avoid the issue (it
it's important in your code) by adding compiler dependant defitinions
similar to:

typedef long int_64bit; ... etc

3) (following on from (1 & 2)...) If I use __int64, LONGLONG, LARGE_INTEGER,
etc. do they automatically know to make use of 64-bit registers?
Again, compiler dependant. However, al the compilers I've used end up
using 64 bit registers in a 64 bit capable system (if the OS supports it
as well).

4) (not following on from any) I've got some asm code that uses MMX
registers, e.g. __asm { ... movq mm0, [esp+4] ... }
Since an AMD64's standard registers (e.g. rax, rbx being double eax,
ebx) are 64-bit, does this mmx code need to be changed/upgraded.....
..............a ) in order to *work* on an AMD64?
..............b ) in order to run *optimally* on an AMD64?
Read up on the amd64 architechture docs from AMD.

"optimally" is somthing you need to figure out for your application,
figuring out wether you even need to be optimal is up to you.

5) Is there a list of types that are different on 64-bit? e.g. I know an
LPVOID is 64-bit on a 64-bit platform, but 32-bit on a 32-bit platform,
whereas some ('long' ?) are 32 bit on both...


LPVOID is windows specific, keep away from it. Write wrappers for your
code so that you code can be system independant, then you can write
portable code. Heck, if you're really clever, you can probably figure
out how to make a system independant set of wrappers that auto-configures.

e.g.

typedef FindInt<64>::ty pe Int64;

- you can even make it fail gracefully at compile-time if compile-time
assumptions are incorrect.

Jul 22 '05 #6

"Bonj" <sp******@crayn e.org> wrote in message
news:33******** *****@individua l.net...
Happy new year to everybody...

Just a few questions about porting code to 64-bit environment.

1) Is there a different version of the SDK (i.e., C/C++ compiler) for the
64-bit platform, or does the regular one just automatically know it's
targeting 64-bit? If you stick to standard C, or sane C++, if you accept such a thing, you
should have eliminated such obstacles to portability. It looks like you
haven't bothered to read the advice offered freely by your favorite software
vendor.
2) (sort of following on from (1) really, but...) when compiling for the
64-bit platform, does the compilier still treat 'long' as 32-bit? You didn't specify your idea of "the 64-bit platform," although you gave
hints further down. Not many here will agree with your implied prejudice.
long is not defined as 32-bit, except on certain instances of C. Definitely
not a standard C concept.
3) (following on from (1 & 2)...) If I use __int64, LONGLONG, LARGE_INTEGER, etc. do they automatically know to make use of 64-bit registers? Again, you should restrict your discussion to language standards. Yes, any
reasonable compiler will use 64-bit registers as available, but that's not a
language level concept. Your chances of automatic adaptation may be better
if you avoid platform specificity.
4) (not following on from any) I've got some asm code that uses MMX
registers, e.g. __asm { ... movq mm0, [esp+4] ... }
Since an AMD64's standard registers (e.g. rax, rbx being double eax,
ebx) are 64-bit, does this mmx code need to be changed/upgraded.....
..............a ) in order to *work* on an AMD64?
..............b ) in order to run *optimally* on an AMD64? Normally, asm code would not upgrade itself to use full length 64-bit
registers. Now you know why you should have used standard source code. If
you seriously mean that you're trying to write code which runs well only on
an AMD64, you haven't chosen any suitable NG.
5) Is there a list of types that are different on 64-bit? e.g. I know an
LPVOID is 64-bit on a 64-bit platform, but 32-bit on a 32-bit platform,
whereas some ('long' ?) are 32 bit on both...

If you're interested only in Windows, your web browser could have helped you
more effectively than cross-posting to groups which have no interest in
Windows-only features.

Jul 22 '05 #7

"Phil Carmody" <th************ *****@yahoo.co. uk> wrote in message
news:87******** ****@nonospaz.f atphil.org...
Yes. MSDN explicitly says that int and long are 4 bytes, always. Microsoft decided that it was better to do this so that fewer programs would break. As a result, it is necessary to use the non-standard __int64 type (since MS
does not currently support long long) or the size_t type.

OK, now you make it explicit that the answers depend on which of the many
NGs
Does that mention of size_t mean that MS have ignored the warning given
in Clive Feather's 1999 cautionary
http://www.open-std.org/jtc1/sc22/wg...ocs/dr_201.htm


Presumably, Microsoft studied the situation to a sufficient extent when
making their decision. There must be some applications which make
unwarranted assumptions about sizeof(long), without making similar
assumptions about the relationship between sizeof(long) and size_t.
I myself ran into a situation where a software vendor flat out refused to
support 64-bit Windows on account of size_t not fitting in long. That saved
me from having to sort out other inscrutable practices of theirs, such as
for(int i=0; i<last_outer; ++i){
for(int i=0; i<last_inner; ++i){
.....
if(some_conditi on)break;
}
some_flag = some_variable[i]; // is this the inner or the outer i ?!
...
}

On the basis of admittedly insufficient data, my experience suggests that
people who insist on one non-standard practice will indulge in others.

Jul 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1527
by: Marc Poinot | last post by:
Did anybody use numarray on a 64 bits platform ? (e.g. SGI/Irix) The package works on our 64 bits platforms... using 32 bits mode, but not using 64 mode. Big crash in _ufunc... Is there a flag to set somewhere, trick, hint, noway ? -MP- ----------------------------------------------------------------------- Marc POINOT Alias:...
6
1719
by: administrata | last post by:
Hi! I'm programming maths programs. And I got some questions about mathematical signs. 1. Inputing suqare like a * a, It's too long when I do time-consuming things. Can it be simplified? 2. Inputing fractions like (a / b) + (c / d), It's tiring work too. Can it be simplified? 3. How can i input root?
1
2042
by: Hugo | last post by:
I have a dual boot machine, runs Win XP pro and Win XP Pro 64, XP boots from C and XP 64 boots from D. They both have VS 2005 Beta 2 installed. I have a webapp developed in Win XP (32) which has gone well and runs fine in XP. I Now want to get this same app running under IIS on XP 64.
1
2847
by: war_wheelan | last post by:
I have a TSQL script to add daily tables to replication and then run the snapshot agent to distribute them to two subscribers. The script executes without errors, but when I check the running jobs for each server I see the following: JUST AN EXAMPLE Job1 'Category' REPL-Snapshot Job2 'Category' REPL-Distribution What is the difference...
0
1296
by: Hugo | last post by:
I have a dual boot machine, runs Win XP pro and Win XP Pro 64, Win XP boots from C and Win XP 64 boot from D. They both have VS 2005 Beta 2 installed. I have a webapp developed in Win XP (32) which has gone well and runs fine in XP. I Now want to get this same app running under IIS on XP 64.
1
2154
by: mel_apiso | last post by:
Hi, we have an AIX 5.3 OS, and we purchased DB2 UDB version 8 Workgroup Edition. We want to install 64 bits version, but the source CD's that we have say: WORKGROUP SERVER EDITION Version 8.1 for AIX 5L
68
15650
by: James Dow Allen | last post by:
The gcc compiler treats malloc() specially! I have no particular question, but it might be fun to hear from anyone who knows about gcc's special behavior. Some may find this post interesting; some may find it off-topic or confusing. Disclaimers at end. The code samples are intended to be nearly minimal demonstrations. They are *not*...
10
10673
by: krunalb | last post by:
Hi, I am trying to shift unsigned long long value by 64 bits and this is what i get #include <stdio.h> int main() { unsigned short shiftby= 64;
7
3857
by: SatX | last post by:
Hi to all, I have question about compile with st20cc.exe How can compile one source code with st20cc.exe??? Example: /* Includes --------------------------------------------------------------- */ #include "emu.h" #include "crypto.h" #include <string.h> //---------------------------------------------------------------------------
0
1480
by: shineyang | last post by:
Dear all: Who is kind to help me about the following problem. Why cannot log the remote node by using Net::Telent #################################### The following is normal to the process using "Telnet" #################################### $ telnet 172.30.9.2 Trying 172.30.9.2...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7930
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6290
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5228
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3662
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.