English 中文(简体)
64 bit v. 32bit C Code on Solaris 10
原标题:64 bit vs 32 bit C code on Solaris 10
  • 时间:2010-10-09 03:16:57
  •  标签:
  • c
  • solaris

我的Solais 10更新了9个指挥系统:

#isainfo -b
64 

但是,如果我在C建立有限度的以下方案,那么,我可以:

#include <stdio.h>
#include <limits.h>

int main(void)
{ 
     printf("Maximum integer value on this system is = %d
", INT_MAX);
}
gcc on64.c -o on64
./on64

Maximum integer value on this system is = 2147483647

我预计会取得更大成果,因为该系统在64个轨道上运行。 这似乎有32点结果。 这是一个汇编者的问题吗?

问题回答

http://www.unix.org/version2/whatsnew/lp64_wp.html” http://www.unix.org/version2/whatsnew/lp64_wp.html,包括:

  • ILP64 (where int, long, and pointers are 64-bit)
  • LP64 (where int is 32-bit, while long and pointers are 64-bit)

64-bit Solaris 10 use the LP64 model ( http://www.sun.com/software/solaris/faqs/64bit.xml#q4:

Q: What is the data model used for the Solaris Operating System?

A: LP64 is the de facto industry standard. The L represents long and the P represents pointer. Both are 64-bit, whereas int is 32-bit.

除了上文提到的“64-Bit Program Models: Why LP64?”纸面外,您不妨看一下Raymond Chen关于为何温64选择LP64模式的解释,因为它可能有助于支持unix.org文件中的各种理由和论点:newthing/archive/2005/01/31/363790.aspx” rel=“nofollow noretinger”http://blogs.msdn.com/b/newthing/archive/310137/

不管平台如何,“int”型号为32倍。 “长期”型号为32个轨道平台上的32个轨道,64个轨道平台上的64个轨道。

为了减少模棱两可之处,你可以使用99类:

#include <stdint.h>

int32_t i32;
int64_t i64;

http://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/i386-and-x86_002d64-Options.html

The 64-bit environment sets int to 32 bits and long and pointer to 64 bits and generates code for AMD s x86-64 architecture.

您可以编制有关太阳系10的方案,范围为32或64。 否则,将编成32项。

利用海合会和最近的太阳编纂者,选择-m32-m64决定采用何种选择。 因此,尝试:

$ gcc -m64 -o on64-64 on64.c
$ gcc -m32 -o on64-32 on64.c

接着:

$ file on64 on64-32 on64-64
...take a look see...
$ ./on64-64
...take a look see...
$ ./on64-32
...as you originally found...
$

如果您想要达到最大的整体类型,则intmax_t:

#include <stdio.h>
#include <stdint.h>

int main(void)
{ 
     printf("Maximum integer value on this system is = %jd
", INTMAX_MAX);
}

至少2^63 - 1.

首先,你们必须确保你以64个轨道的方式管理你的编辑。 一些汇编者不采用32个目标平台模式,即使他们能够制定64个轨道代码。

其次,一些汇编者倾向于采用64类模型,即<代码>int的类型仍为32比值。 海湾合作委员会实际上就是其中之一。 因此,您对<代码>int的类型在64轨道模式中成为64个轨道类型的期望完全没有根据。

同样,一切都取决于汇编者,而只取决于汇编者(以及汇编者的环境)。 你对你的顾问所做的事完全无关紧要。 你可以更新太阳系,使其达到237-比值或1001-比值,但海合会将继续产生32-比值代码,直到海合会的违约情况发生变化或直到你明确要求有一个不同的目标平台为止。

如果你想看到“长期”类型(即32个轨道结构,64个轨道结构,而不是总是32个轨道的“int”,那么你本可以印制:

printf("max long = %ld", LONG_MAX);

在编成册时,我会这样做。

Max long on this system is: 9223372036854775807

页: 1

Max long on this system is: 2147483647




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签