- 论坛徽章:
- 2
|
昨天抽空找了套环境来试。
结果还是有不同的
1. 在application层面, 以32位/64位模式编译的任何结果,都显示pid_t宽度为4(即32位)。
2. 64位宽度只存在于kernel extension里面,
也就是说
1. 即使在目前的AIXos上面, 各种app 还是都被解释成 sizeof(pid_t)=4
pid_t惟一可能出现为64位和程序,是在64bit的 kernel extension里面。
2. 64-bit kernel 来解析这些app的时候, 会做扩展, 用的是long32tolong64 宏来做扩展, 这跟内核实际pid位数64没多少关系。。。。会做casting。。。
所谓扩展也是纯为了兼容新的64bit mode
http://pic.dhe.ibm.com/infocenter/aix/v7r1/index.jsp?topic=%2Fcom.ibm.aix.kernelext%2Fdoc%2Fkernextc%2Fapp32signedlong.htm
Signed long Parameter
To convert a 32-bit signed long parameter to a 64-bit value, the 32-bit value must be sign extended.
The LONG32TOLONG64 macro is provided for this operation. It converts a 32-bit signed value into a 64-bit signed value, as shown in this example:
syscall1(long incr)
{
/* If the caller is a 32-bit process, convert
* 'incr' to a signed, 64-bit value.
*/
if (!IS64U)
incr = LONG32TOLONG64(incr);
.
.
.
}
3. 这个转换问题的发生 跟用户层无关。。。。 也就是上面的第1点。
另外至于说资源浪费。。。。我表示也不知道IBM怎么想的。。。不过浪费一点也不是IBM买单。。。是customer买单么反正。。。。
帖个实验数据
- #oslevel
- 6.1.0.0
- #bootinfo -K
- 64
- > cat sizeof_test.c
- #include <stdio.h>
- #include <unistd.h>
- int main(int argc, const char *argv[])
- {
- printf("long size:%d\n", sizeof(long));
- printf("signed long size:%d\n", sizeof(signed long));
- printf("int size:%d\n", sizeof(int));
- printf("signed int size:%d\n", sizeof(signed int));
- printf("double size:%d\n", sizeof(double));
- printf("float size:%d\n", sizeof(float));
- printf("short size:%d\n", sizeof(short));
- printf("pid_t size:%d\n", sizeof(pid_t));
- return 0;
- }
复制代码- gcc sizeof_test.c -maix64 -o sizeof_gcc_64
- gcc sizeof_test.c -maix32 -o sizeof_gcc_32
- xlc sizeof_test.c -q64 -o sizeof_xlc_64
- xlc sizeof_test.c -q32 -o sizeof_xlc_32
- > ./sizeof_gcc_32
- long size:4
- signed long size:4
- int size:4
- signed int size:4
- double size:8
- float size:4
- short size:2
- pid_t size:4
- > ./sizeof_gcc_64
- long size:8
- signed long size:8
- int size:4
- signed int size:4
- double size:8
- float size:4
- short size:2
- pid_t size:4
复制代码 xlc和gcc编译的结果都是一致的。
这里很明显的32位和64位比如long的长度是不一致的
pid_t都是一致的。
在操作系统层面有64位进程id的存在 并不影响application的互通,因为任何app的pid_t都会取成32(只要不去随便enable这两个宏就ok)
|
|