Re: malloc on 64 AMD64
On Thu, Apr 15, 2004 at 11:24:52AM -0700, Sebastian Haase wrote:
> Hi,
> We are planning to by an Athlon64 (or Opteron) system and since I like debian
> I am posting this "request":
> What output can I expect from this c program:
> <code>
> #include <stdio.h>
> int main() { size_t n; void *p; double gb;
> for(gb=10;gb>.3;gb-=.5) {
> n= 1024L * 1024L * 1024L * gb;
> p = malloc( n );
> printf("%12lu %4.1lfGb %p\n",n,n/1024./1024./1024.,p);
> free(p); } return 0; }
> </code>
>
> BTW: I get this on my Pentium 4
> <terminal>
> haase@baboon:~: make test64 && ./test64
> cc test64.c -o test64
> test64.c: In function `main':
> test64.c:5: warning: assignment makes pointer from integer without a cast
Note that you have to include stdlib.h to get the proper
prototype of malloc else you'll corrupt the pointer you get back
and get a segmentation fault in free().
I get:
10737418240 10.000Gb 0x2a958a5010
10200547328 9.500Gb 0x2a958a5010
9663676416 9.000Gb 0x2a958a5010
9126805504 8.500Gb 0x2a958a5010
8589934592 8.000Gb 0x2a958a5010
8053063680 7.500Gb 0x2a958a5010
7516192768 7.000Gb 0x2a958a5010
6979321856 6.500Gb 0x2a958a5010
6442450944 6.000Gb 0x2a958a5010
5905580032 5.500Gb 0x2a958a5010
5368709120 5.000Gb 0x2a958a5010
4831838208 4.500Gb 0x2a958a5010
4294967296 4.000Gb 0x2a958a5010
3758096384 3.500Gb 0x2a958a5010
3221225472 3.000Gb 0x2a958a5010
2684354560 2.500Gb 0x2a958a5010
2147483648 2.000Gb 0x2a958a5010
1610612736 1.500Gb 0x2a958a5010
1073741824 1.000Gb 0x2a958a5010
536870912 0.500Gb 0x2a958a5010
Note that that pointer is more than 32 bit.
Kurt
Reply to: