Re: malloc more than 2 GB? - SGI

This is a discussion on Re: malloc more than 2 GB? - SGI ; If your systune parameters and system resources so permit, then it can be done. $ cc -64 -o t t.c $ ./t 8 $ cat t.c #include #include int main(){printf("%lld\n",sizeof(ssize_t)); return 0;} $ You could write your own malloc to ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Re: malloc more than 2 GB?

  1. Re: malloc more than 2 GB?

    If your systune parameters and system resources so permit, then it can be done.

    $ cc -64 -o t t.c
    $ ./t
    8
    $ cat t.c
    #include
    #include
    int main(){printf("%lld\n",sizeof(ssize_t)); return 0;}
    $

    You could write your own malloc to the malloc API with ssize_t substituted.

    You could use sbrk(2)/brk(2) to do the actual allocation.

    The following header lines retained to effect attribution:
    >Date: Sat, 31 Jan 2004 19:39:36 +0000 (GMT)
    >From: r5
    >Subject: malloc more than 2 GB?
    >To: info-iris-misc@ARL.ARMY.MIL
    >X-UserInfo1:


    >Sorry if this is a FAQ. Is it possible to malloc() more
    >than 2 GB worth of memory in a single call? I see that
    >malloc() accepts a size_t which is an int even on my
    >64-bit SGI. Thanks.


    Randolph J. Herber, herber@fnal.gov, +1 630 840 2966, CD/CDFTF PK-149F,
    Mail Stop 318, Fermilab, Kirk & Pine Rds., PO Box 500, Batavia, IL 60510-0500,
    USA. (Speaking for myself and not for US, US DOE, FNAL nor URA.) (Product,
    trade, or service marks herein belong to their respective owners.)

    $ cc -64 -o t t.c
    $ ./t
    8
    $ cat t.c
    #include
    #include
    int main(){printf("%lld\n",sizeof(ssize_t)); return 0;}
    $

  2. Re: malloc more than 2 GB?

    In article ,
    Randolph J. Herber wrote:
    >If your systune parameters and system resources so permit, then it can be done.

    [nice example showing size_t is 8 removed to save space]

    >
    >The following header lines retained to effect attribution:
    >>Date: Sat, 31 Jan 2004 19:39:36 +0000 (GMT)
    >>From: r5
    >>Subject: malloc more than 2 GB?
    >>To: info-iris-misc@ARL.ARMY.MIL
    >>X-UserInfo1:

    >
    >>Sorry if this is a FAQ. Is it possible to malloc() more
    >>than 2 GB worth of memory in a single call? I see that
    >>malloc() accepts a size_t which is an int even on my
    >>64-bit SGI. Thanks.


    size_t is not 'int' in -64 ABI.
    For -64 it's 'long'-based, which is 64 bits, as -64 is LP64.
    (long and pointer are 64 bits, int is 32 bits)

    As Randolph shows, size_t can be 8.

    6.5.19 shows how it is defined:

    #if !defined(_SIZE_T) && !defined(_SIZE_T_)
    #define _SIZE_T
    #if (_MIPS_SZLONG == 32)
    typedef unsigned int size_t;
    #endif
    #if (_MIPS_SZLONG == 64)
    typedef unsigned long size_t;
    #endif
    #endif /* !_SIZE_T */

    __SGI_LIBC_END_NAMESPACE_STD
    __SGI_LIBC_USING_FROM_STD(size_t)

    #ifndef _SSIZE_T
    #define _SSIZE_T
    #if (_MIPS_SZLONG == 32)
    typedef int ssize_t;
    #endif
    #if (_MIPS_SZLONG == 64)
    typedef long ssize_t;
    #endif
    #endif

    Regards,
    David B. Anderson davea at sgi dot com http://reality.sgiweb.org/davea

+ Reply to Thread