Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Ticket #2038: 64Bit.7.patch

File 64Bit.7.patch, 104.2 kB (added by Marenz, 13 years ago)

forgot a change

  • build/script/unittest.sh

    old new  
    99EXE=runUnittests_$DC 
    1010DL="-L-ldl" 
    1111UNAME=`uname` 
    12 OPTIONS="-debug -debug=UnitTest" 
     12OPTIONS="-debug -debug=UnitTest" # -debug=deh -debug=PRINTF" 
    1313 
    1414error () { 
    1515    echo "Example : DC=dmd PLATFORM=linux ARCH=32 build/script/unittest.sh" 
     
    3333    OPTIONS="-oq -d-debug -d-debug=UnitTest" 
    3434fi 
    3535 
    36 build/bin/$PLATFORM$ARCH/bob -v -r=$DC -c=$DC -p=$PLATFORM -l=libtango-$DC-tst -o="-g -unittest $OPTIONS" .  
     36build/bin/${PLATFORM}32/bob -v -r=$DC -c=$DC -p=$PLATFORM -l=libtango-$DC-tst -o="-m64 -gc -unittest $OPTIONS" .  
    3737 
    3838if ! which $DC >& /dev/null 
    3939then 
     
    9999    DL="" 
    100100fi 
    101101 
    102 echo "$DC $EXE.d $DFILES -g $OPTIONS -unittest -L-L. -L-ltango-$DC-tst  $DL -L-lz -L-lbz2" 
    103 $DC $EXE.d $DFILES -g $OPTIONS -unittest -L-L. -L-ltango-$DC-tst  $DL -L-lz -L-lbz2  && rm $EXE.d && rm libtango-$DC-tst.a 
     102echo "$DC $EXE.d $DFILES -gc $OPTIONS -m$ARCH -unittest -L-L. -L-ltango-$DC-tst  $DL -L-lz -L-lbz2" 
     103$DC $EXE.d $DFILES -gc $OPTIONS -m$ARCH -unittest -L-L. -L-ltango-$DC-tst  $DL -L-lz -L-lbz2  && rm $EXE.d && rm libtango-$DC-tst.a 
    104104 
    105105./runUnittests_$DC 
    106106 
  • build/src/bob.d

    old new  
    3838           new FreeBSD (args); 
    3939           new Solaris (args); 
    4040           new Windows (args); 
    41            stdout.formatln ("{} files", FileFilter.builder(args.os, args.compiler)()); 
     41           Stdout.formatln ("{} files", FileFilter.builder(args.os, args.compiler)()); 
    4242           } 
    4343} 
    4444 
     
    170170 
    171171                if (args.core) { 
    172172                    foreach (file; scan(".c")) { 
    173                              auto obj = compile (file, gcc32); 
     173                             auto obj = compile (file, gcc); 
    174174                             addToLib(obj); 
    175175                    } 
    176176 
    177177                    foreach (file; scan(".S")) { 
    178                             auto obj = compile (file, gcc32); 
     178                            auto obj = compile (file, gcc); 
    179179                            addToLib(obj); 
    180180                    } 
    181181                } 
     
    780780                if (args.verbose) 
    781781                   { 
    782782                   foreach (str; cmd) 
    783                             stdout (str)(' '); 
    784                    stdout.newline; 
     783                            Stdout (str)(' '); 
     784                   Stdout.newline; 
    785785                   }   
    786786                          
    787787                if (! args.inhibit) 
     
    794794                       proc.copyEnv (true); 
    795795 
    796796                   proc.execute(); 
    797                    stdout.stream.copy (proc.stderr); 
    798                    stdout.stream.copy (proc.stdout); 
     797                   Stdout.stream.copy (proc.stderr); 
     798                   Stdout.stream.copy (proc.stdout); 
    799799                   auto result = proc.wait; 
    800800                   if (result.reason != Process.Result.Exit) 
    801801                       throw new Exception (result.toString); 
  • object.di

    old new  
    119119    equals_t      equals(void *p1, void *p2); 
    120120    /// compares the types of this TypeInfo stored at p1 and p2 
    121121    int      compare(void *p1, void *p2); 
     122     /// Return alignment of type 
     123    size_t   talign() { return tsize(); } 
    122124    /// returns the size of a type with the current TypeInfo 
    123125    size_t   tsize(); 
    124126    /// swaps the two types stored at p1 and p2 
     
    131133    PointerMap pointermap(); 
    132134    /// offsets of the various elements 
    133135    OffsetTypeInfo[] offTi(); 
     136 
     137    /** Return internal info on arguments fitting into 8byte. 
     138       * See X86-64 ABI 3.2.3 
     139     */ 
     140    version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2); 
    134141} 
    135142 
    136143class TypeInfo_Typedef : TypeInfo 
  • tango/text/convert/Layout.d

    old new  
    6666        alias void* Arg; 
    6767        alias va_list ArgList; 
    6868        } 
     69else version(DigitalMars) 
     70        { 
     71        private import tango.core.Vararg; 
     72        alias void* Arg; 
     73        alias va_list ArgList; 
     74        } 
    6975     else 
    7076        { 
    7177        alias void* Arg; 
  • tango/text/Text.d

    old new  
    213213 
    214214private import tango.stdc.string : memmove; 
    215215 
     216version(DigitalMars) 
     217{ 
     218    private import tango.core.Vararg; 
     219} 
    216220 
    217221/******************************************************************************* 
    218222 
  • tango/io/stream/Snoop.d

    old new  
    1717 
    1818private import  tango.text.convert.Format; 
    1919 
     20version(DigitalMars) 
     21{ 
     22    private import tango.core.Vararg; 
     23} 
     24 
    2025private alias void delegate(char[]) Snoop; 
    2126 
    2227/******************************************************************************* 
  • tango/io/stream/Format.d

    old new  
    1616 
    1717private import tango.text.convert.Layout; 
    1818 
     19version(DigitalMars) 
     20{ 
     21    private import tango.core.Vararg; 
     22} 
     23 
    1924/******************************************************************************* 
    2025 
    2126        A bridge between a Layout instance and a stream. This is used for 
  • tango/core/rt/gc/basic/gcx.d

    old new  
    16661666     */ 
    16671667    void addRange(void *pbot, void *ptop) 
    16681668    { 
    1669         debug(PRINTF) printf("Thread %x ", pthread_self()); 
     1669        debug(PRINTF) debug(THREADINVARIANT) printf("Thread %x ", pthread_self()); 
    16701670        debug(PRINTF) printf("%x.Gcx::addRange(%x, %x), nranges = %d\n", this, pbot, ptop, nranges); 
    16711671        if (nranges == rangedim) 
    16721672        { 
     
    16941694     */ 
    16951695    void removeRange(void *pbot) 
    16961696    { 
    1697         debug(PRINTF) printf("Thread %x ", pthread_self()); 
     1697        debug(PRINTF) debug(THREADINVARIANT) printf("Thread %x ", pthread_self()); 
    16981698        debug(PRINTF) printf("%x.Gcx.removeRange(%x), nranges = %d\n", this, pbot, nranges); 
    16991699        for (size_t i = nranges; i--;) 
    17001700        { 
     
    23442344        } 
    23452345        else 
    23462346        { 
     2347        version (D_InlineAsm_X86) 
     2348        { 
    23472349        asm 
    23482350        { 
    23492351            pushad              ; 
    23502352            mov sp[EBP],ESP     ; 
    23512353        } 
    23522354        } 
     2355        else version (D_InlineAsm_X86_64) 
     2356        { 
     2357            asm 
     2358            { 
     2359                push RAX ; 
     2360                push RBX ; 
     2361                push RCX ; 
     2362                push RDX ; 
     2363                push RSI ; 
     2364                push RDI ; 
     2365                push RBP ; 
     2366                push R8  ; 
     2367                push R9  ; 
     2368                push R10  ; 
     2369                push R11  ; 
     2370                push R12  ; 
     2371                push R13  ; 
     2372                push R14  ; 
     2373                push R15  ; 
     2374                push EAX ;   // 16 byte align the stack 
     2375            } 
     2376        } 
     2377        else 
     2378        { 
     2379            static assert( false, "Architecture not supported." ); 
     2380        } 
     2381        } 
    23532382        result = fullcollect(sp); 
    23542383        version (GNU) 
    23552384        { 
     
    23592388        { 
    23602389            // nothing to do 
    23612390        } 
    2362         else 
     2391        else version (D_InlineAsm_X86) 
    23632392        { 
    23642393        asm 
    23652394        { 
    23662395            popad               ; 
    23672396        } 
    23682397        } 
     2398        else version (D_InlineAsm_X86_64) 
     2399        { 
     2400            asm 
     2401            { 
     2402                pop EAX ;   // 16 byte align the stack 
     2403                pop R15  ; 
     2404                pop R14  ; 
     2405                pop R13  ; 
     2406                pop R12  ; 
     2407                pop R11  ; 
     2408                pop R10  ; 
     2409                pop R9  ; 
     2410                pop R8  ; 
     2411                pop RBP ; 
     2412                pop RDI ; 
     2413                pop RSI ; 
     2414                pop RDX ; 
     2415                pop RCX ; 
     2416                pop RBX ; 
     2417                pop RAX ; 
     2418            } 
     2419        } 
     2420        else 
     2421        { 
     2422            static assert( false, "Architecture not supported." ); 
     2423        } 
    23692424        return result; 
    23702425    } 
    23712426 
     
    25192574        for (n = 0; n < npools; n++) 
    25202575        {   size_t pn; 
    25212576            size_t ncommitted; 
    2522             uint*  bbase; 
    25232577 
    25242578            pool = pooltable[n]; 
    2525             bbase = pool.mark.base(); 
     2579            auto bbase = pool.mark.base(); 
    25262580            ncommitted = pool.ncommitted; 
    25272581            for (pn = 0; pn < ncommitted; pn++, bbase += PAGESIZE / (32 * 16)) 
    25282582            { 
  • tango/core/rt/gc/basic/gcbits.d

    old new  
    5050 
    5151struct GCBits 
    5252{ 
    53     const int BITS_PER_WORD = 32; 
    54     const int BITS_SHIFT = 5; 
    55     const int BITS_MASK = 31; 
     53    alias size_t wordtype; 
    5654 
    57     uint*  data = null; 
     55    const BITS_PER_WORD = (wordtype.sizeof * 8); 
     56    const BITS_SHIFT = (wordtype.sizeof == 8 ? 6 : 5); 
     57    const BITS_MASK = (BITS_PER_WORD - 1); 
     58    const BITS_1 = cast(wordtype)1; 
     59 
     60    wordtype*  data = null; 
    5861    size_t nwords = 0;    // allocated words in data[] excluding sentinals 
    5962    size_t nbits = 0;     // number of bits in data[] excluding sentinals 
    6063 
     
    7982    { 
    8083        this.nbits = nbits; 
    8184        nwords = (nbits + (BITS_PER_WORD - 1)) >> BITS_SHIFT; 
    82         data = cast(uint*)calloc(nwords + 2, uint.sizeof); 
     85        data = cast(wordtype*)calloc(nwords + 2, wordtype.sizeof); 
    8386        if (!data) 
    8487            onOutOfMemoryError(); 
    8588    } 
    8689 
    87     uint test(size_t i) 
     90    wordtype test(size_t i) 
    8891    in 
    8992    { 
    9093        assert(i < nbits); 
     
    9295    body 
    9396    { 
    9497        //return (cast(bit *)(data + 1))[i]; 
    95         return data[1 + (i >> BITS_SHIFT)] & (1 << (i & BITS_MASK)); 
     98        return data[1 + (i >> BITS_SHIFT)] & (BITS_1 << (i & BITS_MASK)); 
    9699    } 
    97100 
    98101    void set(size_t i) 
     
    103106    body 
    104107    { 
    105108        //(cast(bit *)(data + 1))[i] = 1; 
    106         data[1 + (i >> BITS_SHIFT)] |= (1 << (i & BITS_MASK)); 
     109        data[1 + (i >> BITS_SHIFT)] |= (BITS_1 << (i & BITS_MASK)); 
    107110    } 
    108111 
    109112    void clear(size_t i) 
     
    114117    body 
    115118    { 
    116119        //(cast(bit *)(data + 1))[i] = 0; 
    117         data[1 + (i >> BITS_SHIFT)] &= ~(1 << (i & BITS_MASK)); 
     120        data[1 + (i >> BITS_SHIFT)] &= ~(BITS_1 << (i & BITS_MASK)); 
    118121    } 
    119122 
    120     uint testClear(size_t i) 
     123    wordtype testClear(size_t i) 
    121124    { 
    122125        version (bitops) 
    123126        { 
     
    136139            } 
    137140        } 
    138141        else 
    139         {   uint result; 
     142        {   wordtype result; 
    140143 
    141144            //result = (cast(bit *)(data + 1))[i]; 
    142145            //(cast(bit *)(data + 1))[i] = 0; 
    143146 
    144             uint* p = &data[1 + (i >> BITS_SHIFT)]; 
    145             uint  mask = (1 << (i & BITS_MASK)); 
     147            wordtype* p = &data[1 + (i >> BITS_SHIFT)]; 
     148            wordtype  mask = (BITS_1 << (i & BITS_MASK)); 
    146149            result = *p & mask; 
    147150            *p &= ~mask; 
    148151            return result; 
     
    188191            for (;d1!=dEnd;++d1) 
    189192                *d1=0u; 
    190193        } else { 
    191             memset(data + 1, 0, nwords * uint.sizeof); 
     194            memset(data + 1, 0, nwords * wordtype.sizeof); 
    192195        } 
    193196    } 
    194197 
     
    200203    body 
    201204    { 
    202205        version(MEMCPY_NON_SIG_SAFE) { 
    203             uint * d1=data+1,d2=f.data+1,dEnd=d1+nwords; 
     206            wordtype * d1=data+1,d2=f.data+1,dEnd=d1+nwords; 
    204207            for (;d1!=dEnd;++d1,++d2) 
    205208                *d1=*d2; 
    206209        } else { 
    207             memcpy(data + 1, f.data + 1, nwords * uint.sizeof); 
     210            memcpy(data + 1, f.data + 1, nwords * wordtype.sizeof); 
    208211        } 
    209212    } 
    210213 
    211     uint* base() 
     214    wordtype* base() 
    212215    in 
    213216    { 
    214217        assert(data); 
  • tango/core/rt/compiler/ldc/object_.d

    old new  
    412412    /// Compares two instances for &lt;, ==, or &gt;. 
    413413    int compare(in void* p1, in void* p2) { return 0; } //throw new Exception("non comparable",__FILE__,__LINE__);  
    414414 
     415     /// Return alignment of type 
     416    size_t   talign() { return tsize(); } 
     417 
    415418    /// Returns size of the type. 
    416419    size_t tsize() { return 0; } 
    417420 
  • tango/core/rt/compiler/ldc/typeinfo/ti_void.d

    old new  
    2222        return *cast(byte *)p1 - *cast(byte *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return void.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return void.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_wchar.d

    old new  
    2121        return *cast(wchar *)p1 - *cast(wchar *)p2; 
    2222    } 
    2323 
     24    override size_t talign() 
     25    { 
     26        return wchar.alignof; 
     27    } 
     28 
    2429    override size_t tsize() 
    2530    { 
    2631        return wchar.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_ptr.d

    old new  
    2525        return 0; 
    2626    } 
    2727 
     28    override size_t talign() 
     29    { 
     30        return (void*).alignof; 
     31    } 
     32 
    2833    override size_t tsize() 
    2934    { 
    3035        return (void*).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_Afloat.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (float[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (float[]).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_double.d

    old new  
    4343        return _compare(*cast(double *)p1, *cast(double *)p2); 
    4444    } 
    4545 
     46    override size_t talign() 
     47    { 
     48        return double.alignof; 
     49    } 
     50 
    4651    override size_t tsize() 
    4752    { 
    4853        return double.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_delegate.d

    old new  
    1818        return *cast(dg *)p1 == *cast(dg *)p2; 
    1919    } 
    2020 
     21    override size_t talign() 
     22    { 
     23        return dg.alignof; 
     24    } 
     25 
    2126    override size_t tsize() 
    2227    { 
    2328        return dg.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_Adouble.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (double[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (double[]).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_char.d

    old new  
    2020        return *cast(char *)p1 - *cast(char *)p2; 
    2121    } 
    2222 
     23    override size_t talign() 
     24    { 
     25        return char.alignof; 
     26    } 
     27 
    2328    override size_t tsize() 
    2429    { 
    2530        return char.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_Acdouble.d

    old new  
    7575        return 0; 
    7676    } 
    7777 
     78    override size_t talign() 
     79    { 
     80        return (cdouble[]).alignof; 
     81    } 
     82 
    7883    override size_t tsize() 
    7984    { 
    8085        return (cdouble[]).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_uint.d

    old new  
    2626        return 0; 
    2727    } 
    2828 
     29    override size_t talign() 
     30    { 
     31        return uint.alignof; 
     32    } 
     33 
    2934    override size_t tsize() 
    3035    { 
    3136        return uint.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_AC.d

    old new  
    8282        return 0; 
    8383    } 
    8484 
     85    override size_t talign() 
     86    { 
     87        return (Object[]).alignof; 
     88    } 
     89 
    8590    override size_t tsize() 
    8691    { 
    8792        return (Object[]).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_ulong.d

    old new  
    3131        return 0; 
    3232    } 
    3333 
     34    override size_t talign() 
     35    { 
     36        return ulong.alignof; 
     37    } 
     38 
    3439    override size_t tsize() 
    3540    { 
    3641        return ulong.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_creal.d

    old new  
    4444        return _compare(*cast(creal *)p1, *cast(creal *)p2); 
    4545    } 
    4646 
     47    override size_t talign() 
     48    { 
     49        return creal.alignof; 
     50    } 
     51 
    4752    override size_t tsize() 
    4853    { 
    4954        return creal.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_ubyte.d

    old new  
    2222        return *cast(ubyte *)p1 - *cast(ubyte *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return ubyte.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return ubyte.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_Aint.d

    old new  
    4747        return 0; 
    4848    } 
    4949 
     50    override size_t talign() 
     51    { 
     52        return (int[]).alignof; 
     53    } 
     54 
    5055    override size_t tsize() 
    5156    { 
    5257        return (int[]).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_long.d

    old new  
    3131        return 0; 
    3232    } 
    3333 
     34    override size_t talign() 
     35    { 
     36        return long.alignof; 
     37    } 
     38 
    3439    override size_t tsize() 
    3540    { 
    3641        return long.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_short.d

    old new  
    2222        return *cast(short *)p1 - *cast(short *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return short.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return short.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_Along.d

    old new  
    4848        return 0; 
    4949    } 
    5050 
     51    override size_t talign() 
     52    { 
     53        return (long[]).alignof; 
     54    } 
     55 
    5156    override size_t tsize() 
    5257    { 
    5358        return (long[]).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_byte.d

    old new  
    2222        return *cast(byte *)p1 - *cast(byte *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return byte.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return byte.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_float.d

    old new  
    4242        return _compare(*cast(float *)p1, *cast(float *)p2); 
    4343    } 
    4444 
     45    override size_t talign() 
     46    { 
     47        return float.alignof; 
     48    } 
     49 
    4550    override size_t tsize() 
    4651    { 
    4752        return float.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_cfloat.d

    old new  
    4444        return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); 
    4545    } 
    4646 
     47    override size_t talign() 
     48    { 
     49        return cfloat.alignof; 
     50    } 
     51 
    4752    override size_t tsize() 
    4853    { 
    4954        return cfloat.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_Acfloat.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (cfloat[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (cfloat[]).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_cdouble.d

    old new  
    4444        return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2); 
    4545    } 
    4646 
     47    override size_t talign() 
     48    { 
     49        return cdouble.alignof; 
     50    } 
     51 
    4752    override size_t tsize() 
    4853    { 
    4954        return cdouble.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_dchar.d

    old new  
    2222        return *cast(dchar *)p1 - *cast(dchar *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return dchar.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return dchar.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_C.d

    old new  
    6262        return c; 
    6363    } 
    6464 
     65    override size_t talign() 
     66    { 
     67        return Object.alignof; 
     68    } 
     69 
    6570    override size_t tsize() 
    6671    { 
    6772        return Object.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_real.d

    old new  
    4343        return _compare(*cast(real *)p1, *cast(real *)p2); 
    4444    } 
    4545 
     46    override size_t talign() 
     47    { 
     48        return real.alignof; 
     49    } 
     50 
    4651    override size_t tsize() 
    4752    { 
    4853        return real.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_ushort.d

    old new  
    2222        return *cast(ushort *)p1 - *cast(ushort *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return ushort.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return ushort.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_Areal.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (real[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (real[]).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_Acreal.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (creal[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (creal[]).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_Ag.d

    old new  
    4848        return 0; 
    4949    } 
    5050 
     51    override size_t talign() 
     52    { 
     53        return (byte[]).alignof; 
     54    } 
     55 
    5156    override size_t tsize() 
    5257    { 
    5358        return (byte[]).sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_int.d

    old new  
    2626        return 0; 
    2727    } 
    2828 
     29    override size_t talign() 
     30    { 
     31        return int.alignof; 
     32    } 
     33 
    2934    override size_t tsize() 
    3035    { 
    3136        return int.sizeof; 
  • tango/core/rt/compiler/ldc/typeinfo/ti_Ashort.d

    old new  
    4747        return 0; 
    4848    } 
    4949 
     50    override size_t talign() 
     51    { 
     52        return (short[]).alignof; 
     53    } 
     54 
    5055    override size_t tsize() 
    5156    { 
    5257        return (short[]).sizeof; 
  • tango/core/rt/compiler/dmd/rt/lifetime.d

    old new  
    3333    import tango.stdc.string : memcpy, memset, memcmp; 
    3434    import tango.stdc.stdarg; 
    3535    debug(PRINTF) import tango.stdc.stdio : printf; 
     36 
     37    alias void[] array_t; 
    3638} 
    3739 
    3840 
     
    192194 * ti is the type of the resulting array, or pointer to element. 
    193195 * (For when the array is initialized to 0) 
    194196 */ 
    195 extern (C) ulong _d_newarrayT(TypeInfo ti, size_t length) 
     197extern(C) array_t _d_newarrayT(TypeInfo ti, size_t length) 
    196198{ 
    197199    void* p; 
    198     ulong result; 
     200    array_t result; 
    199201    auto size = ti.next.tsize();                // array element size 
    200202 
    201203    debug(PRINTF) printf("_d_newarrayT(length = x%x, size = %d)\n", length, size); 
    202204    if (length == 0 || size == 0) 
    203         result = 0
     205        result = array_t.init
    204206    else 
    205207    { 
    206208        version (D_InlineAsm_X86) 
     
    213215                jc      Loverflow       ; 
    214216            } 
    215217        } 
     218        else version (D_InlineAsm_X86_64) 
     219            asm 
     220            { 
     221                mov     RAX,size        ; 
     222                mul     RAX,length      ; 
     223                mov     size,RAX        ; 
     224                jc      Loverflow       ; 
     225            } 
    216226        else 
    217227            size *= length; 
     228 
    218229        PointerMap pm; 
    219         version (D_HavePointerMap) { 
    220             pm = ti.next.pointermap(); 
    221         } 
     230        version (D_HavePointerMap)  pm = ti.next.pointermap(); 
     231 
    222232        p = gc_malloc(size + 1, !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0, pm); 
    223233        debug(PRINTF) printf(" p = %p\n", p); 
    224234        memset(p, 0, size); 
    225         result = cast(ulong)length + (cast(ulong)cast(uint)p << 32)
     235        result = cast(array_t)p[0..length]
    226236    } 
    227237    return result; 
    228238 
     
    233243/** 
    234244 * For when the array has a non-zero initializer. 
    235245 */ 
    236 extern (C) ulong _d_newarrayiT(TypeInfo ti, size_t length) 
     246extern(C) array_t _d_newarrayiT(TypeInfo ti, size_t length) 
    237247{ 
    238     ulong result; 
     248    array_t result; 
    239249    auto size = ti.next.tsize();                // array element size 
    240250 
    241251    debug(PRINTF) printf("_d_newarrayiT(length = %d, size = %d)\n", length, size); 
    242252 
    243253    if (length == 0 || size == 0) 
    244         result = 0
     254        result = array_t.init
    245255    else 
    246256    { 
    247257        auto initializer = ti.next.init(); 
     
    257267                jc      Loverflow       ; 
    258268            } 
    259269        } 
     270        else version (D_InlineAsm_X86_64) 
     271            asm 
     272            { 
     273                mov     RAX,size        ; 
     274                mul     RAX,length      ; 
     275                mov     size,RAX        ; 
     276                jc      Loverflow       ; 
     277            } 
    260278        else 
    261279            size *= length; 
     280 
    262281        PointerMap pm; 
    263282        version (D_HavePointerMap) { 
    264283            pm = ti.next.pointermap(); 
     
    284303            } 
    285304        } 
    286305        va_end(q); 
    287         result = cast(ulong)length + (cast(ulong)cast(uint)p << 32)
     306        result = cast(array_t)p[0..length]
    288307    } 
    289308    return result; 
    290309 
     
    295314/** 
    296315 * 
    297316 */ 
    298 extern (C) ulong _d_newarraymT(TypeInfo ti, int ndims, ...) 
     317extern(C) array_t _d_newarraymT(TypeInfo ti, int ndims, ...) 
    299318{ 
    300     ulong result; 
     319    array_t result; 
    301320 
    302321    debug(PRINTF) printf("_d_newarraymT(ndims = %d)\n", ndims); 
    303322    if (ndims == 0) 
    304         result = 0
     323        result = array_t.init
    305324    else 
    306     {   va_list q; 
    307         va_start!(int)(q, ndims)
     325    { 
     326        va_list q
    308327 
    309         void[] foo(TypeInfo ti, size_t* pdim, int ndims) 
     328        version(X86) 
     329            va_start(q, ndims); 
     330        else version(X86_64) 
     331            va_start(q, __va_argsave); 
     332        else 
     333            static assert(false, "platform not supported"); 
     334 
     335        void[] foo(TypeInfo ti, va_list ap, int ndims) 
    310336        { 
    311             size_t dim = *pdim; 
     337            size_t dim; 
     338            va_arg(ap, dim); 
    312339            void[] p; 
    313340 
    314341            debug(PRINTF) printf("foo(ti = %p, ti.next = %p, dim = %d, ndims = %d\n", ti, ti.next, dim, ndims); 
     
    320347            else 
    321348            { 
    322349                p = gc_malloc(dim * (void[]).sizeof + 1)[0 .. dim]; 
    323                 for (int i = 0; i < dim; i++) 
     350 
     351                version (X86) 
    324352                { 
    325                     (cast(void[]*)p.ptr)[i] = foo(ti.next, pdim + 1, ndims - 1); 
     353                    va_list ap2; 
     354                    va_copy(ap2, ap); 
    326355                } 
     356 
     357                for (size_t i = 0; i < dim; i++) 
     358                { 
     359                    version (X86_64) 
     360                    { 
     361                        __va_list argsave = *cast(__va_list*)ap; 
     362                        va_list ap2 = &argsave; 
    327363            } 
     364                    (cast(void[]*)p.ptr)[i] = foo(ti.next, ap2, ndims - 1); 
     365                } 
     366            } 
    328367            return p; 
    329368        } 
    330369 
    331         size_t* pdim = cast(size_t *)q; 
    332         result = cast(ulong)foo(ti, pdim, ndims); 
     370        result = cast(typeof(result))foo(ti, q, ndims); 
    333371        debug(PRINTF) printf("result = %llx\n", result); 
    334372 
    335373        version (none) 
     
    348386/** 
    349387 * 
    350388 */ 
    351 extern (C) ulong _d_newarraymiT(TypeInfo ti, int ndims, ...) 
     389extern(C) array_t _d_newarraymiT(TypeInfo ti, size_t ndims, ...) 
    352390{ 
    353     ulong result; 
     391    array_t result; 
    354392 
    355393    debug(PRINTF) printf("_d_newarraymiT(ndims = %d)\n", ndims); 
    356394    if (ndims == 0) 
    357         result = 0
     395        result = array_t.init
    358396    else 
    359397    { 
    360398        va_list q; 
    361         va_start!(int)(q, ndims); 
    362399 
    363         void[] foo(TypeInfo ti, size_t* pdim, int ndims) 
     400        version(X86) 
     401            va_start(q, ndims); 
     402        else version(X86_64) 
     403            va_start(q, __va_argsave); 
     404        else 
     405            static assert(false, "platform not supported"); 
     406 
     407        void[] foo(TypeInfo ti, va_list ap, size_t ndims) 
    364408        { 
    365             size_t dim = *pdim; 
     409            size_t dim; 
     410            va_arg(ap, dim); 
    366411            void[] p; 
    367412 
    368413            if (ndims == 1) 
     
    373418            else 
    374419            { 
    375420                p = gc_malloc(dim * (void[]).sizeof + 1)[0 .. dim]; 
    376                 for (int i = 0; i < dim; i++) 
     421 
     422                version (X86) 
    377423                { 
    378                     (cast(void[]*)p.ptr)[i] = foo(ti.next, pdim + 1, ndims - 1); 
     424                    va_list ap2; 
     425                    va_copy(ap2, ap); 
    379426                } 
     427 
     428                for (size_t i = 0; i < dim; i++) 
     429                { 
     430                    version (X86_64) 
     431                    { 
     432                        __va_list argsave = *cast(__va_list*)ap; 
     433                        va_list ap2 = &argsave; 
    380434            } 
     435                    (cast(void[]*)p.ptr)[i] = foo(ti.next, ap2, ndims - 1); 
     436                } 
     437            } 
     438 
    381439            return p; 
    382440        } 
    383441 
    384         size_t* pdim = cast(size_t *)q; 
    385         result = cast(ulong)foo(ti, pdim, ndims); 
     442        result = cast(typeof(result))foo(ti, q, ndims); 
    386443        debug(PRINTF) printf("result = %llx\n", result); 
    387444 
    388445        version (none) 
     
    753810    onOutOfMemoryError(); 
    754811} 
    755812 
     813/************************************** 
     814 * Extend an array by n elements. 
     815 * Caller must initialize that element. 
     816 */ 
     817version(X86_64) extern (C) byte[] _d_arrayappendcTX(TypeInfo ti, inout byte[] x, size_t n) 
     818{ 
     819    auto sizeelem = ti.next.tsize();            // array element size 
     820    auto info = gc_query(x.ptr); 
     821    auto length = x.length; 
     822    auto newlength = length + n; 
     823    auto newsize = newlength * sizeelem; 
    756824 
     825    assert(info.size == 0 || length * sizeelem <= info.size); 
     826 
     827    //printf("_d_arrayappendcTX(sizeelem = %d, ptr = %p, length = %d, cap = %d)\n", sizeelem, x.ptr, x.length, cap); 
     828 
     829    if (newsize >= info.size) 
     830    {   byte* newdata; 
     831 
     832        if (info.size >= PAGESIZE) 
     833        {   // Try to extend in-place 
     834            auto u = gc_extend(x.ptr, (newsize + 1) - info.size, (newsize + 1) - info.size); 
     835            if (u) 
     836            { 
     837                goto L1; 
     838            } 
     839        } 
     840 
     841        PointerMap pm; 
     842        version (D_HavePointerMap) { 
     843            pm = ti.next.pointermap(); 
     844        } 
     845 
     846        uint attr = !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0; 
     847        newdata = cast(byte *) gc_malloc(newCapacity(newlength, sizeelem) + 1, attr, pm); 
     848 
     849        memcpy(newdata, x.ptr, length * sizeelem); 
     850 
     851        (cast(void **)(&x))[1] = newdata; 
     852    } 
     853 
     854  L1: 
     855    *cast(size_t *)&x = newlength; 
     856    assert((cast(size_t)x.ptr & 15) == 0); 
     857    assert(gc_query(x.ptr).size > x.length * sizeelem); 
     858    return x; 
     859} 
     860 
     861 
    757862/** 
    758863 * Append y[] to array x[]. 
    759864 * size is size of each array element. 
     
    11471252    return result; 
    11481253} 
    11491254 
     1255extern (C) void* _d_arrayliteralTX(TypeInfo ti, size_t length) 
     1256{ 
     1257    auto sizeelem = ti.next.tsize();            // array element size 
     1258    void* result; 
    11501259 
     1260    //printf("_d_arrayliteralTX(sizeelem = %d, length = %d)\n", sizeelem, length); 
     1261    if (length == 0 || sizeelem == 0) 
     1262        result = null; 
     1263    else 
     1264    { 
     1265        PointerMap pm; 
     1266        version (D_HavePointerMap) { 
     1267            pm = ti.next.pointermap(); 
     1268        } 
     1269        result = gc_malloc(length * sizeelem, !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0, pm); 
     1270    } 
     1271    return result; 
     1272} 
     1273 
    11511274/** 
    11521275 * 
    11531276 */ 
    1154 extern (C) void* _d_arrayliteralT(TypeInfo ti, size_t length, ...) 
     1277version (X86) extern (C) void* _d_arrayliteralT(TypeInfo ti, size_t length, ...) 
    11551278{ 
    11561279    auto sizeelem = ti.next.tsize();            // array element size 
    11571280    void* result; 
     
    11671290        } 
    11681291        result = gc_malloc(length * sizeelem, !(ti.next.flags() & 1) ? BlkAttr.NO_SCAN : 0, pm); 
    11691292 
     1293        version(X86) 
     1294        { 
    11701295        va_list q; 
    11711296        va_start!(size_t)(q, length); 
    11721297 
     
    11871312 
    11881313        va_end(q); 
    11891314    } 
     1315        else version(X86_64) 
     1316        { 
     1317            va_list q; 
     1318            va_start(q, __va_argsave); 
     1319            for (size_t i = 0; i < length; i++) 
     1320            { 
     1321                va_arg(q, ti.next, result + i * sizeelem); 
     1322            } 
     1323            va_end(q); 
     1324        } 
     1325    } 
    11901326    return result; 
    11911327} 
    11921328 
     
    12041340/** 
    12051341 * 
    12061342 */ 
    1207 extern (C) long _adDupT(TypeInfo ti, Array2 a) 
     1343extern (C) array_t _adDupT(TypeInfo ti, Array2 a) 
    12081344out (result) 
    12091345{ 
    12101346    auto sizeelem = ti.next.tsize();            // array element size 
     
    12261362        r.length = a.length; 
    12271363        memcpy(r.ptr, a.ptr, size); 
    12281364    } 
    1229     return *cast(long*)(&r); 
     1365    return *cast(array_t*)(&r); 
    12301366} 
    12311367 
    12321368 
  • tango/core/rt/compiler/dmd/rt/trace.d

    old new  
    906906        } 
    907907    } 
    908908} 
     909else version (D_InlineAsm_X86_64) 
     910{ 
     911    extern (D) 
     912    { 
     913        void QueryPerformanceCounter(timer_t* ctr) 
     914        { 
     915            asm 
     916            { 
     917                naked                   ; 
     918                rdtsc                   ; 
     919                mov   [RDI],EAX         ; 
     920                mov   4[RDI],EDX        ; 
     921                ret                     ; 
     922            } 
     923        } 
     924 
     925        void QueryPerformanceFrequency(timer_t* freq) 
     926        { 
     927            *freq = 3579545; 
     928        } 
     929    } 
     930} 
    909931else 
    910932{ 
    911933    static assert(0); 
  • tango/core/rt/compiler/dmd/rt/memory.d

    old new  
    109109            ret; 
    110110        } 
    111111    } 
     112    else version( D_InlineAsm_X86_64 ) 
     113    { 
     114        asm 
     115        { 
     116            naked; 
     117            mov RAX, RSP; 
     118            ret; 
     119        } 
     120    } 
    112121    else 
    113122    { 
    114123            static assert( false, "Architecture not supported." ); 
  • tango/core/rt/compiler/dmd/rt/cover.d

    old new  
    3434    struct BitArray 
    3535    { 
    3636        size_t  len; 
    37         uint*  ptr; 
     37        size_t* ptr; 
    3838 
    3939        bool opIndex( size_t i ) 
    4040        in 
  • tango/core/rt/compiler/dmd/rt/aaA.d

    old new  
    110110 
    111111size_t aligntsize(size_t tsize) 
    112112{ 
    113     // Is pointer alignment on the x64 4 bytes or 8? 
     113    version (X86_64) 
     114        // Size of key needed to align value on 16 bytes 
     115        return (tsize + 15) & ~(15); 
     116    else 
    114117    return (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 
    115118} 
    116119 
     
    238241 */ 
    239242 
    240243void* _aaGet(AA* aa, TypeInfo keyti, size_t valuesize, ...) 
     244{ 
     245    return _aaGetX(aa, keyti, valuesize, cast(void *)(&valuesize + 1)); 
     246} 
     247 
     248void* _aaGetX(AA* aa, TypeInfo keyti, size_t valuesize, void* pkey) 
    241249in 
    242250{ 
    243251    assert(aa); 
     
    251259} 
    252260body 
    253261{ 
    254     auto pkey = cast(void *)(&valuesize + 1); 
    255262    size_t i; 
    256263    aaA *e; 
    257264    auto keysize = aligntsize(keyti.tsize()); 
    258265 
    259266    if (!aa.a) 
    260267        aa.a = new BB(); 
     268 
    261269    aa.a.keyti = keyti; 
    262270 
    263271    if (!aa.a.b.length) 
     
    269277    } 
    270278 
    271279    auto key_hash = keyti.getHash(pkey); 
     280 
    272281    //printf("hash = %d\n", key_hash); 
     282 
    273283    i = key_hash % aa.a.b.length; 
    274284    auto pe = &aa.a.b[i]; 
     285 
    275286    while ((e = *pe) !is null) 
    276287    { 
    277288        if (key_hash == e.hash) 
     
    312323 
    313324void* _aaGetRvalue(AA aa, TypeInfo keyti, size_t valuesize, ...) 
    314325{ 
     326    return _aaGetRvalueX(aa, keyti, valuesize, cast(void *)(&valuesize + 1)); 
     327} 
     328 
     329void* _aaGetRvalueX(AA aa, TypeInfo keyti, size_t valuesize, void* pkey) 
     330{ 
    315331    //printf("_aaGetRvalue(valuesize = %u)\n", valuesize); 
    316332    if (!aa.a) 
    317333        return null; 
    318334 
    319     auto pkey = cast(void *)(&valuesize + 1); 
    320335    auto keysize = aligntsize(keyti.tsize()); 
    321336    auto len = aa.a.b.length; 
    322337 
     
    351366 */ 
    352367 
    353368void* _aaIn(AA aa, TypeInfo keyti, ...) 
     369{ 
     370    return _aaInX(aa, keyti, cast(void *)(&keyti + 1)); 
     371} 
     372 
     373void* _aaInX(AA aa, TypeInfo keyti, void* pkey) 
    354374in 
    355375{ 
    356376} 
     
    362382{ 
    363383    if (aa.a) 
    364384    { 
    365         auto pkey = cast(void *)(&keyti + 1); 
    366  
    367385        //printf("_aaIn(), .length = %d, .ptr = %x\n", aa.a.length, cast(uint)aa.a.ptr); 
    368386        auto len = aa.a.b.length; 
    369387 
     
    399417 
    400418void _aaDel(AA aa, TypeInfo keyti, ...) 
    401419{ 
    402     auto pkey = cast(void *)(&keyti + 1); 
     420    return _aaDelX(aa, keyti, cast(void *)(&keyti + 1)); 
     421
     422 
     423void _aaDelX(AA aa, TypeInfo keyti, void* pkey) 
     424
    403425    aaA *e; 
    404426 
    405427    if (aa.a && aa.a.b.length) 
     
    801823    return result; 
    802824} 
    803825 
     826extern (C) BB* _d_assocarrayliteralTX(TypeInfo_AssociativeArray ti, void[] keys, void[] values) 
     827{ 
     828    auto valueti = ti.next; 
     829    auto valuesize = valueti.tsize();           // value size 
     830    auto keyti = ti.key; 
     831    auto keysize = keyti.tsize();               // key size 
     832    auto length = keys.length; 
     833    BB* result; 
    804834 
     835    //printf("_d_assocarrayliteralT(keysize = %d, valuesize = %d, length = %d)\n", keysize, valuesize, length); 
     836    //printf("tivalue = %.*s\n", ti.next.classinfo.name); 
     837    assert(length == values.length); 
     838    if (length == 0 || valuesize == 0 || keysize == 0) 
     839    { 
     840        ; 
     841    } 
     842    else 
     843    { 
     844        result = new BB(); 
     845 
     846        size_t i; 
     847        for (i = 0; i < prime_list.length - 1; i++) 
     848        { 
     849            if (length <= prime_list[i]) 
     850                break; 
     851        } 
     852        auto len = prime_list[i]; 
     853        result.b = new aaA*[len]; 
     854 
     855        size_t keytsize = aligntsize(keysize); 
     856 
     857        for (size_t j = 0; j < length; j++) 
     858        {   auto pkey = keys.ptr + j * keysize; 
     859            auto pvalue = values.ptr + j * valuesize; 
     860            aaA* e; 
     861 
     862            auto key_hash = keyti.getHash(pkey); 
     863            //printf("hash = %d\n", key_hash); 
     864            i = key_hash % len; 
     865            auto pe = &result.b[i]; 
     866            while (1) 
     867            { 
     868                e = *pe; 
     869                if (!e) 
     870                { 
     871                    // Not found, create new elem 
     872                    //printf("create new one\n"); 
     873                    e = cast(aaA *) cast(void*) new void[aaA.sizeof + keytsize + valuesize]; 
     874                    memcpy(e + 1, pkey, keysize); 
     875                    e.hash = key_hash; 
     876                    *pe = e; 
     877                    result.nodes++; 
     878                    break; 
     879                } 
     880                if (key_hash == e.hash) 
     881                { 
     882                    auto c = keyti.compare(pkey, e + 1); 
     883                    if (c == 0) 
     884                        break; 
     885                    pe = (c < 0) ? &e.left : &e.right; 
     886                } 
     887                else 
     888                    pe = (key_hash < e.hash) ? &e.left : &e.right; 
     889            } 
     890            memcpy(cast(void *)(e + 1) + keytsize, pvalue, valuesize); 
     891        } 
     892    } 
     893    return result; 
     894} 
     895 
    805896/*********************************** 
    806897 * Construct an associative array of type ti from 
    807898 * length pairs of key/value pairs. 
    808899 */ 
    809900 
    810 extern (C) 
    811 BB* _d_assocarrayliteralT(TypeInfo_AssociativeArray ti, size_t length, ...) 
     901extern (C) BB* _d_assocarrayliteralT(TypeInfo_AssociativeArray ti, size_t length, ...) 
    812902{ 
    813903    auto valuesize = ti.next.tsize();           // value size 
    814904    auto keyti = ti.key; 
     
    824914    else 
    825915    { 
    826916        va_list q; 
    827         va_start!(size_t)(q, length); 
     917        version(X86_64) va_start(q, __va_argsave); else va_start!(size_t)(q, length); 
    828918 
    829919        result = new BB(); 
    830920        result.keyti = keyti; 
  • tango/core/rt/compiler/dmd/rt/memset.d

    old new  
    4141    return pstart; 
    4242} 
    4343 
     44 
    4445int *_memset32(int *p, int value, size_t count) 
    4546{ 
    46 version (X86) 
     47version (D_InlineAsm_X86) 
    4748{ 
    4849    asm 
    4950    { 
     
    118119    } 
    119120    return pstart; 
    120121} 
     122 
     123float *_memsetFloat(float *p, float value, size_t count) 
     124{ 
     125    float *pstart = p; 
     126    float *ptop; 
     127 
     128    for (ptop = &p[count]; p < ptop; p++) 
     129        *p = value; 
     130    return pstart; 
     131} 
     132 
     133double *_memsetDouble(double *p, double value, size_t count) 
     134{ 
     135    double *pstart = p; 
     136    double *ptop; 
     137 
     138    for (ptop = &p[count]; p < ptop; p++) 
     139        *p = value; 
     140    return pstart; 
     141} 
  • tango/core/rt/compiler/dmd/object_.d

    old new  
    416416 
    417417    /// Compares two instances for &lt;, ==, or &gt;. 
    418418    int compare(in void* p1, in void* p2) { return 0; } // throw new Exception("non comparable",__FILE__,__LINE__); 
    419  
     419    /// Return alignment of type 
     420    size_t talign() { return tsize(); } 
    420421    /// Returns size of the type. 
    421422    size_t tsize() { return 0; } 
    422423 
     
    473474 
    474475    /// Get type information on the contents of the type; null if not available 
    475476    OffsetTypeInfo[] offTi() { return null; } 
     477 
     478 
     479     /** Return internal info on arguments fitting into 8byte. 
     480       * See X86-64 ABI 3.2.3 
     481     */ 
     482    version (X86_64) int argTypes(out TypeInfo arg1, out TypeInfo arg2) 
     483    {   arg1 = this; 
     484        return 0; 
    476485} 
     486} 
    477487 
    478488class TypeInfo_Typedef : TypeInfo 
    479489{ 
  • tango/core/rt/compiler/dmd/typeinfo/ti_void.d

    old new  
    2222        return *cast(byte *)p1 - *cast(byte *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return void.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return void.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_wchar.d

    old new  
    2121        return *cast(wchar *)p1 - *cast(wchar *)p2; 
    2222    } 
    2323 
     24    override size_t talign() 
     25    { 
     26        return wchar.alignof; 
     27    } 
     28 
    2429    override size_t tsize() 
    2530    { 
    2631        return wchar.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_ptr.d

    old new  
    2525        return 0; 
    2626    } 
    2727 
     28    override size_t talign() 
     29    { 
     30        return (void*).alignof; 
     31    } 
     32 
    2833    override size_t tsize() 
    2934    { 
    3035        return (void*).sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_Afloat.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (float[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (float[]).sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_double.d

    old new  
    4343        return _compare(*cast(double *)p1, *cast(double *)p2); 
    4444    } 
    4545 
     46    override size_t talign() 
     47    { 
     48        return double.alignof; 
     49    } 
     50 
    4651    override size_t tsize() 
    4752    { 
    4853        return double.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_delegate.d

    old new  
    1818        return *cast(dg *)p1 == *cast(dg *)p2; 
    1919    } 
    2020 
     21    override size_t talign() 
     22    { 
     23        return dg.alignof; 
     24    } 
     25 
    2126    override size_t tsize() 
    2227    { 
    2328        return dg.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_Adouble.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (double[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (double[]).sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_char.d

    old new  
    2020        return *cast(char *)p1 - *cast(char *)p2; 
    2121    } 
    2222 
     23    override size_t talign() 
     24    { 
     25        return char.alignof; 
     26    } 
     27 
    2328    override size_t tsize() 
    2429    { 
    2530        return char.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_Acdouble.d

    old new  
    7575        return 0; 
    7676    } 
    7777 
     78    override size_t talign() 
     79    { 
     80        return (cdouble[]).alignof; 
     81    } 
     82 
    7883    override size_t tsize() 
    7984    { 
    8085        return (cdouble[]).sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_uint.d

    old new  
    2626        return 0; 
    2727    } 
    2828 
     29    override size_t talign() 
     30    { 
     31        return uint.alignof; 
     32    } 
     33 
    2934    override size_t tsize() 
    3035    { 
    3136        return uint.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_AC.d

    old new  
    8282        return 0; 
    8383    } 
    8484 
     85    override size_t talign() 
     86    { 
     87        return (Object[]).alignof; 
     88    } 
     89 
    8590    override size_t tsize() 
    8691    { 
    8792        return (Object[]).sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_ulong.d

    old new  
    3131        return 0; 
    3232    } 
    3333 
     34    override size_t talign() 
     35    { 
     36        return ulong.alignof; 
     37    } 
     38 
    3439    override size_t tsize() 
    3540    { 
    3641        return ulong.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_creal.d

    old new  
    4444        return _compare(*cast(creal *)p1, *cast(creal *)p2); 
    4545    } 
    4646 
     47    override size_t talign() 
     48    { 
     49        return creal.alignof; 
     50    } 
     51 
    4752    override size_t tsize() 
    4853    { 
    4954        return creal.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_ubyte.d

    old new  
    2222        return *cast(ubyte *)p1 - *cast(ubyte *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return ubyte.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return ubyte.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_Aint.d

    old new  
    4747        return 0; 
    4848    } 
    4949 
     50    override size_t talign() 
     51    { 
     52        return (int[]).alignof; 
     53    } 
     54 
    5055    override size_t tsize() 
    5156    { 
    5257        return (int[]).sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_long.d

    old new  
    3131        return 0; 
    3232    } 
    3333 
     34    override size_t talign() 
     35    { 
     36        return long.alignof; 
     37    } 
     38 
    3439    override size_t tsize() 
    3540    { 
    3641        return long.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_short.d

    old new  
    2222        return *cast(short *)p1 - *cast(short *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return short.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return short.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_Along.d

    old new  
    4848        return 0; 
    4949    } 
    5050 
     51    override size_t talign() 
     52    { 
     53        return (long[]).alignof; 
     54    } 
     55 
    5156    override size_t tsize() 
    5257    { 
    5358        return (long[]).sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_byte.d

    old new  
    2222        return *cast(byte *)p1 - *cast(byte *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return byte.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return byte.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_float.d

    old new  
    4242        return _compare(*cast(float *)p1, *cast(float *)p2); 
    4343    } 
    4444 
     45    override size_t talign() 
     46    { 
     47        return float.alignof; 
     48    } 
     49 
    4550    override size_t tsize() 
    4651    { 
    4752        return float.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_cfloat.d

    old new  
    4444        return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); 
    4545    } 
    4646 
     47    override size_t talign() 
     48    { 
     49        return cfloat.alignof; 
     50    } 
     51 
    4752    override size_t tsize() 
    4853    { 
    4954        return cfloat.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_Acfloat.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (cfloat[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (cfloat[]).sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_cdouble.d

    old new  
    4444        return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2); 
    4545    } 
    4646 
     47    override size_t talign() 
     48    { 
     49        return cdouble.alignof; 
     50    } 
     51 
    4752    override size_t tsize() 
    4853    { 
    4954        return cdouble.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_dchar.d

    old new  
    2222        return *cast(dchar *)p1 - *cast(dchar *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return dchar.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return dchar.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_C.d

    old new  
    6262        return c; 
    6363    } 
    6464 
     65    override size_t talign() 
     66    { 
     67        return Object.alignof; 
     68    } 
     69 
    6570    override size_t tsize() 
    6671    { 
    6772        return Object.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_real.d

    old new  
    4343        return _compare(*cast(real *)p1, *cast(real *)p2); 
    4444    } 
    4545 
     46    override size_t talign() 
     47    { 
     48        return real.alignof; 
     49    } 
     50 
    4651    override size_t tsize() 
    4752    { 
    4853        return real.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_ushort.d

    old new  
    2222        return *cast(ushort *)p1 - *cast(ushort *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return ushort.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return ushort.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_Areal.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (real[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (real[]).sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_Acreal.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (creal[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (creal[]).sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_Ag.d

    old new  
    4848        return 0; 
    4949    } 
    5050 
     51    override size_t talign() 
     52    { 
     53        return (byte[]).alignof; 
     54    } 
     55 
    5156    override size_t tsize() 
    5257    { 
    5358        return (byte[]).sizeof; 
     
    117122 
    118123    override hash_t getHash(in void* p){ 
    119124        char[] s = *cast(char[]*)p; 
     125 
    120126        version (OldHash) 
    121127        { 
    122128            hash_t hash = 0; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_int.d

    old new  
    2626        return 0; 
    2727    } 
    2828 
     29    override size_t talign() 
     30    { 
     31        return int.alignof; 
     32    } 
     33 
    2934    override size_t tsize() 
    3035    { 
    3136        return int.sizeof; 
  • tango/core/rt/compiler/dmd/typeinfo/ti_Ashort.d

    old new  
    4747        return 0; 
    4848    } 
    4949 
     50    override size_t talign() 
     51    { 
     52        return (short[]).alignof; 
     53    } 
     54 
    5055    override size_t tsize() 
    5156    { 
    5257        return (short[]).sizeof; 
  • tango/core/rt/compiler/dmd/posix/deh.d

    old new  
    6464    void *fptr;                 // pointer to start of function 
    6565    uint espoffset;             // offset of ESP from EBP 
    6666    uint retoffset;             // offset from start of function to return code 
    67     uint nhandlers;             // dimension of handler_info[] 
     67    size_t nhandlers;             // dimension of handler_info[] 
    6868    DHandlerInfo handler_info[1]; 
    6969} 
    7070 
    7171struct DCatchBlock 
    7272{ 
    7373    ClassInfo type;             // catch type 
    74     uint bpoffset;              // EBP offset of catch var 
     74    size_t bpoffset;              // EBP offset of catch var 
    7575    void *code;                 // catch handler code 
    7676} 
    7777 
    7878// Create one of these for each try-catch 
    7979struct DCatchInfo 
    8080{ 
    81     uint ncatches;                      // number of catch blocks 
     81    size_t ncatches;                      // number of catch blocks 
    8282    DCatchBlock catch_block[1];         // data for each catch block 
    8383} 
    8484 
     
    164164 *   caller's EBP 
    165165 */ 
    166166 
    167 uint __eh_find_caller(uint regbp, uint *pretaddr) 
     167size_t __eh_find_caller(size_t regbp, size_t *pretaddr) 
    168168{ 
    169     uint bp = *cast(uint *)regbp; 
     169    size_t bp = *cast(size_t *)regbp; 
    170170 
    171171    if (bp)         // if not end of call chain 
    172172    { 
     
    176176            // stack should grow to smaller values 
    177177            terminate(); 
    178178 
    179         *pretaddr = *cast(uint *)(regbp + int.sizeof); 
     179        *pretaddr = *cast(size_t *)(regbp + size_t.sizeof); 
    180180    } 
    181181    return bp; 
    182182} 
     
    195195* Throw a D object. 
    196196*/ 
    197197 
    198 extern(C) void _d_throwc(Object *h){ 
    199     uint regebp; 
     198extern(C) void _d_throwc(Object *h) 
     199
     200    size_t regebp; 
    200201 
    201202    debug(deh) 
    202203    { 
     
    204205        printf("\tvptr = %p\n", *cast(void **)h); 
    205206    } 
    206207 
     208    version (D_InlineAsm_X86) 
    207209    asm 
    208210    { 
    209211        mov regebp,EBP  ; 
    210212    } 
     213    else version (D_InlineAsm_X86_64) 
     214        asm 
     215        { 
     216            mov regebp,RBP  ; 
     217        } 
     218    else 
     219        static assert(0); 
    211220 
    212221//static uint abc; 
    213222//if (++abc == 2) *(char *)0=0; 
     
    218227        DHandlerTable *handler_table; 
    219228        FuncTable *pfunc; 
    220229        DHandlerInfo *phi; 
    221         uint retaddr; 
    222         uint funcoffset; 
     230        size_t retaddr; 
     231        size_t funcoffset; 
    223232        uint spoff; 
    224233        uint retoffset; 
    225234        int index; 
    226         int dim; 
     235        size_t dim; 
    227236        int ndx; 
    228237        int prev_ndx; 
    229238 
     
    244253            debug(deh) printf("no handler table\n"); 
    245254            continue; 
    246255        } 
    247         funcoffset = cast(uint)handler_table.fptr; 
     256        funcoffset = cast(size_t)handler_table.fptr; 
    248257        spoff = handler_table.espoffset; 
    249258        retoffset = handler_table.retoffset; 
    250259 
     
    261270        debug(deh) 
    262271        { 
    263272            printf("handler_info[]:\n"); 
    264             for (int i = 0; i < dim; i++) 
     273            for (size_t i = 0; i < dim; i++) 
    265274            { 
    266275                phi = handler_table.handler_info.ptr + i; 
    267276                printf("\t[%d]: offset = x%04x, endoffset = x%04x, prev_index = %d, cioffset = x%04x, finally_code = %x\n", 
     
    270279        } 
    271280 
    272281        index = -1; 
    273         for (int i = 0; i < dim; i++) 
     282        for (size_t i = 0; i < dim; i++) 
    274283        { 
    275284            phi = handler_table.handler_info.ptr + i; 
    276285 
    277286            debug(deh) printf("i = %d, phi.offset = %04x\n", i, funcoffset + phi.offset); 
    278             if (cast(uint)retaddr > funcoffset + phi.offset && 
    279                 cast(uint)retaddr <= funcoffset + phi.endoffset) 
     287            if (retaddr > funcoffset + phi.offset && 
     288                retaddr <= funcoffset + phi.endoffset) 
    280289                index = i; 
    281290        } 
    282291        debug(deh) printf("index = %d\n", index); 
     
    287296        { 
    288297            phi = handler_table.handler_info.ptr + ndx; 
    289298            prev_ndx = phi.prev_index; 
     299 
    290300            if (phi.cioffset) 
    291301            { 
    292302                // this is a catch handler (no finally) 
    293303                DCatchInfo *pci; 
    294                 int ncatches; 
    295                 int i; 
     304                size_t ncatches; 
     305                size_t i; 
    296306 
    297307                pci = cast(DCatchInfo *)(cast(char *)handler_table + phi.cioffset); 
    298308                ncatches = pci.ncatches; 
     309 
    299310                for (i = 0; i < ncatches; i++) 
    300311                { 
    301312                    DCatchBlock *pcb; 
     
    311322 
    312323                        // Jump to catch block. Does not return. 
    313324                        { 
    314                             uint catch_esp; 
     325                            size_t catch_esp; 
    315326                            fp_t catch_addr; 
    316327 
    317328                            catch_addr = cast(fp_t)(pcb.code); 
    318329                            catch_esp = regebp - handler_table.espoffset - fp_t.sizeof; 
     330 
     331                            version (D_InlineAsm_X86) 
    319332                            asm 
    320333                            { 
    321334                                mov     EAX,catch_esp   ; 
     
    325338                                mov     ESP,EAX         ; // reset stack 
    326339                                ret                     ; // jump to catch block 
    327340                            } 
     341                            else version (D_InlineAsm_X86_64) 
     342                                asm 
     343                                { 
     344                                    mov     RAX,catch_esp   ; 
     345                                    mov     RCX,catch_esp   ; 
     346                                    mov     RCX,catch_addr  ; 
     347                                    mov     [RAX],RCX       ; 
     348                                    mov     RBP,regebp      ; 
     349                                    mov     RSP,RAX         ; // reset stack 
     350                                    ret                     ; // jump to catch block 
    328351                        } 
     352                            else 
     353                                static assert(0); 
     354 
    329355                    } 
    330356                } 
    331357            } 
     358            } 
    332359            else if (phi.finally_code) 
    333360            {   // Call finally block 
    334361                // Note that it is unnecessary to adjust the ESP, as the finally block 
     
    338365 
    339366                version (OSX) 
    340367                { 
    341                     asm { 
     368                    version (D_InlineAsm_X86) 
     369                        asm 
     370                        { 
    342371                        sub ESP,4       ; 
    343372                        push    EBX     ; 
    344373                        mov EBX,blockaddr   ; 
     
    349378                        pop EBX     ; 
    350379                        add ESP,4       ; 
    351380                    } 
    352                 } else { 
    353                     asm { 
     381                    else version (D_InlineAsm_X86_64) 
     382                        asm 
     383                        { 
     384                            sub     RSP,8           ; 
     385                            push    RBX             ; 
     386                            mov     RBX,blockaddr   ; 
     387                            push    RBP             ; 
     388                            mov     RBP,regebp      ; 
     389                            call    RBX             ; 
     390                            pop     RBP             ; 
     391                            pop     RBX             ; 
     392                            add     RSP,8           ; 
     393                        } 
     394                    else 
     395                        static assert(0); 
     396                } 
     397                else 
     398                { 
     399                    version (D_InlineAsm_X86) 
     400                        asm 
     401                        { 
    354402                        push        EBX             ; 
    355403                        mov         EBX,blockaddr   ; 
    356404                        push        EBP             ; 
     
    359407                        pop         EBP             ; 
    360408                        pop         EBX             ; 
    361409                    } 
     410                    else version (D_InlineAsm_X86_64) 
     411                        asm 
     412                        { 
     413                            sub     RSP,8           ; 
     414                            push    RBX             ; 
     415                            mov     RBX,blockaddr   ; 
     416                            push    RBP             ; 
     417                            mov     RBP,regebp      ; 
     418                            call    RBX             ; 
     419                            pop     RBP             ; 
     420                            pop     RBX             ; 
     421                            add     RSP,8           ; 
    362422                } 
     423                    else 
     424                        static assert(0); 
    363425            } 
    364426        } 
    365427    } 
    366428} 
     429} 
  • tango/core/rt/compiler/gdc/object_.d

    old new  
    413413    /// Compares two instances for &lt;, ==, or &gt;. 
    414414    int compare(in void* p1, in void* p2) { return 0; } // throw new Exception("non comparable",__FILE__,__LINE__); 
    415415 
     416     /// Return alignment of type 
     417    size_t   talign() { return tsize(); } 
     418 
    416419    /// Returns size of the type. 
    417420    size_t tsize() { return 0; } 
    418421 
  • tango/core/rt/compiler/gdc/typeinfo/ti_void.d

    old new  
    2222        return *cast(byte *)p1 - *cast(byte *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return void.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return void.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_wchar.d

    old new  
    2121        return *cast(wchar *)p1 - *cast(wchar *)p2; 
    2222    } 
    2323 
     24    override size_t talign() 
     25    { 
     26        return wchar.alignof; 
     27    } 
     28 
    2429    override size_t tsize() 
    2530    { 
    2631        return wchar.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_ptr.d

    old new  
    2525        return 0; 
    2626    } 
    2727 
     28    override size_t talign() 
     29    { 
     30        return (void*).alignof; 
     31    } 
     32 
    2833    override size_t tsize() 
    2934    { 
    3035        return (void*).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_Afloat.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (float[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (float[]).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_double.d

    old new  
    4343        return _compare(*cast(double *)p1, *cast(double *)p2); 
    4444    } 
    4545 
     46    override size_t talign() 
     47    { 
     48        return double.alignof; 
     49    } 
     50 
    4651    override size_t tsize() 
    4752    { 
    4853        return double.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_delegate.d

    old new  
    1818        return *cast(dg *)p1 == *cast(dg *)p2; 
    1919    } 
    2020 
     21    override size_t talign() 
     22    { 
     23        return dg.alignof; 
     24    } 
     25 
    2126    override size_t tsize() 
    2227    { 
    2328        return dg.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_Adouble.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (double[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (double[]).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_char.d

    old new  
    2020        return *cast(char *)p1 - *cast(char *)p2; 
    2121    } 
    2222 
     23    override size_t talign() 
     24    { 
     25        return char.alignof; 
     26    } 
     27 
    2328    override size_t tsize() 
    2429    { 
    2530        return char.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_Acdouble.d

    old new  
    7575        return 0; 
    7676    } 
    7777 
     78    override size_t talign() 
     79    { 
     80        return (cdouble[]).alignof; 
     81    } 
     82 
    7883    override size_t tsize() 
    7984    { 
    8085        return (cdouble[]).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_uint.d

    old new  
    2626        return 0; 
    2727    } 
    2828 
     29    override size_t talign() 
     30    { 
     31        return uint.alignof; 
     32    } 
     33 
    2934    override size_t tsize() 
    3035    { 
    3136        return uint.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_AC.d

    old new  
    8282        return 0; 
    8383    } 
    8484 
     85    override size_t talign() 
     86    { 
     87        return (Object[]).alignof; 
     88    } 
     89 
    8590    override size_t tsize() 
    8691    { 
    8792        return (Object[]).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_ulong.d

    old new  
    3131        return 0; 
    3232    } 
    3333 
     34    override size_t talign() 
     35    { 
     36        return ulong.alignof; 
     37    } 
     38 
    3439    override size_t tsize() 
    3540    { 
    3641        return ulong.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_creal.d

    old new  
    4444        return _compare(*cast(creal *)p1, *cast(creal *)p2); 
    4545    } 
    4646 
     47    override size_t talign() 
     48    { 
     49        return creal.alignof; 
     50    } 
     51 
    4752    override size_t tsize() 
    4853    { 
    4954        return creal.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_ubyte.d

    old new  
    2222        return *cast(ubyte *)p1 - *cast(ubyte *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return ubyte.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return ubyte.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_Aint.d

    old new  
    4747        return 0; 
    4848    } 
    4949 
     50    override size_t talign() 
     51    { 
     52        return (int[]).alignof; 
     53    } 
     54 
    5055    override size_t tsize() 
    5156    { 
    5257        return (int[]).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_long.d

    old new  
    3131        return 0; 
    3232    } 
    3333 
     34    override size_t talign() 
     35    { 
     36        return long.alignof; 
     37    } 
     38 
    3439    override size_t tsize() 
    3540    { 
    3641        return long.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_short.d

    old new  
    2222        return *cast(short *)p1 - *cast(short *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return short.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return short.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_Along.d

    old new  
    4848        return 0; 
    4949    } 
    5050 
     51    override size_t talign() 
     52    { 
     53        return (long[]).alignof; 
     54    } 
     55 
    5156    override size_t tsize() 
    5257    { 
    5358        return (long[]).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_byte.d

    old new  
    2222        return *cast(byte *)p1 - *cast(byte *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return byte.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return byte.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_float.d

    old new  
    4242        return _compare(*cast(float *)p1, *cast(float *)p2); 
    4343    } 
    4444 
     45    override size_t talign() 
     46    { 
     47        return float.alignof; 
     48    } 
     49 
    4550    override size_t tsize() 
    4651    { 
    4752        return float.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_cfloat.d

    old new  
    4444        return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2); 
    4545    } 
    4646 
     47    override size_t talign() 
     48    { 
     49        return cfloat.alignof; 
     50    } 
     51 
    4752    override size_t tsize() 
    4853    { 
    4954        return cfloat.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_Acfloat.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (cfloat[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (cfloat[]).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_cdouble.d

    old new  
    4444        return _compare(*cast(cdouble *)p1, *cast(cdouble *)p2); 
    4545    } 
    4646 
     47    override size_t talign() 
     48    { 
     49        return cdouble.alignof; 
     50    } 
     51 
    4752    override size_t tsize() 
    4853    { 
    4954        return cdouble.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_dchar.d

    old new  
    2222        return *cast(dchar *)p1 - *cast(dchar *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return dchar.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return dchar.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_C.d

    old new  
    6262        return c; 
    6363    } 
    6464 
     65    override size_t talign() 
     66    { 
     67        return Object.alignof; 
     68    } 
     69 
    6570    override size_t tsize() 
    6671    { 
    6772        return Object.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_real.d

    old new  
    4343        return _compare(*cast(real *)p1, *cast(real *)p2); 
    4444    } 
    4545 
     46    override size_t talign() 
     47    { 
     48        return real.alignof; 
     49    } 
     50 
    4651    override size_t tsize() 
    4752    { 
    4853        return real.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_ushort.d

    old new  
    2222        return *cast(ushort *)p1 - *cast(ushort *)p2; 
    2323    } 
    2424 
     25    override size_t talign() 
     26    { 
     27        return ushort.alignof; 
     28    } 
     29 
    2530    override size_t tsize() 
    2631    { 
    2732        return ushort.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_Areal.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (real[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (real[]).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_Acreal.d

    old new  
    7676        return 0; 
    7777    } 
    7878 
     79    override size_t talign() 
     80    { 
     81        return (creal[]).alignof; 
     82    } 
     83 
    7984    override size_t tsize() 
    8085    { 
    8186        return (creal[]).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_Ag.d

    old new  
    4848        return 0; 
    4949    } 
    5050 
     51    override size_t talign() 
     52    { 
     53        return (byte[]).alignof; 
     54    } 
     55 
    5156    override size_t tsize() 
    5257    { 
    5358        return (byte[]).sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_int.d

    old new  
    2626        return 0; 
    2727    } 
    2828 
     29    override size_t talign() 
     30    { 
     31        return int.alignof; 
     32    } 
     33 
    2934    override size_t tsize() 
    3035    { 
    3136        return int.sizeof; 
  • tango/core/rt/compiler/gdc/typeinfo/ti_Ashort.d

    old new  
    4747        return 0; 
    4848    } 
    4949 
     50    override size_t talign() 
     51    { 
     52        return (short[]).alignof; 
     53    } 
     54 
    5055    override size_t tsize() 
    5156    { 
    5257        return (short[]).sizeof; 
  • tango/core/Variant.d

    old new  
    88module tango.core.Variant; 
    99 
    1010private import tango.core.Memory : GC; 
    11 private import tango.core.Vararg : va_list
     11private import tango.core.Vararg
    1212private import tango.core.Traits; 
    1313private import tango.core.Tuple; 
    1414 
     
    3737            version=EnableVararg; 
    3838        } 
    3939    } 
     40    version( X86_64 ) 
     41    { 
     42        version( Windows ) 
     43        { 
     44            version=EnableVararg; 
    4045} 
     46        else version( Posix ) 
     47        { 
     48            version=EnableVararg; 
     49        } 
     50    } 
     51} 
    4152else version( LDC ) 
    4253{ 
    4354    version( X86 ) 
  • tango/core/Thread.d

    old new  
    348348            { 
    349349                __builtin_unwind_init(); 
    350350            } 
     351            else version ( D_InlineAsm_X86_64 ) 
     352            { 
     353                asm 
     354                { 
     355                    // Not sure what goes here, pushad is invalid in 64 bit code 
     356                    push RAX ; 
     357                    push RBX ; 
     358                    push RCX ; 
     359                    push RDX ; 
     360                    push RSI ; 
     361                    push RDI ; 
     362                    push RBP ; 
     363                    push R8  ; 
     364                    push R9  ; 
     365                    push R10 ; 
     366                    push R11 ; 
     367                    push R12 ; 
     368                    push R13 ; 
     369                    push R14 ; 
     370                    push R15 ; 
     371                    push EAX ;   // 16 byte align the stack 
     372                } 
     373            } 
    351374            else 
    352375            { 
    353376                static assert( false, "Architecture not supported." ); 
     
    411434            { 
    412435                // registers will be popped automatically 
    413436            } 
     437            else version ( D_InlineAsm_X86_64 ) 
     438            { 
     439                asm 
     440                { 
     441                    // Not sure what goes here, popad is invalid in 64 bit code 
     442                    pop EAX ;   // 16 byte align the stack 
     443                    pop R15 ; 
     444                    pop R14 ; 
     445                    pop R13 ; 
     446                    pop R12 ; 
     447                    pop R11 ; 
     448                    pop R10 ; 
     449                    pop R9  ; 
     450                    pop R8  ; 
     451                    pop RBP ; 
     452                    pop RDI ; 
     453                    pop RSI ; 
     454                    pop RDX ; 
     455                    pop RCX ; 
     456                    pop RBX ; 
     457                    pop RAX ; 
     458                } 
     459            } 
    414460            else 
    415461            { 
    416462                static assert( false, "Architecture not supported." ); 
     
    26702716        } 
    26712717        else version( AsmX86_64_Posix ) 
    26722718        { 
    2673             asm 
     2719            version( DigitalMars ) asm 
    26742720            { 
    26752721                naked; 
    26762722 
    26772723                // save current stack state 
     2724                push RBP; 
     2725                mov RBP, RSP; 
     2726                push RBX; 
     2727                push R12; 
     2728                push R13; 
     2729                push R14; 
     2730                push R15; 
     2731                sub RSP, 4; 
     2732                stmxcsr [RSP]; 
     2733                sub RSP, 4; 
     2734                //version(SynchroFloatExcept){ 
     2735                    fstcw [RSP]; 
     2736                    fwait; 
     2737                //} else { 
     2738                //    fnstcw [RSP]; 
     2739                //    fnclex; 
     2740                //} 
     2741 
     2742                // store oldp again with more accurate address 
     2743                mov [RDI], RSP; 
     2744                // load newp to begin context switch 
     2745                mov RSP, RSI; 
     2746 
     2747                // load saved state from new stack 
     2748                fldcw [RSP]; 
     2749                add RSP, 4; 
     2750                ldmxcsr [RSP]; 
     2751                add RSP, 4; 
     2752                pop R15; 
     2753                pop R14; 
     2754                pop R13; 
     2755                pop R12; 
     2756 
     2757                pop RBX; 
     2758                pop RBP; 
     2759 
     2760                // 'return' to complete switch 
     2761                ret; 
     2762 
     2763            } 
     2764            else asm 
     2765            { 
     2766                naked; 
     2767 
     2768                // save current stack state 
    26782769                pushq RBP; 
    26792770                mov RBP, RSP; 
    26802771                pushq RBX; 
  • tango/core/Vararg.d

    old new  
    2121} 
    2222else 
    2323{ 
    24     /** 
    25      * The base vararg list type. 
    26      */ 
     24    version (X86) 
     25    { 
    2726    alias void* va_list; 
    2827 
    29  
    30     /** 
    31      * This function initializes the supplied argument pointer for subsequent 
    32      * use by va_arg and va_end. 
    33      * 
    34      * Params: 
    35      *  ap      = The argument pointer to initialize. 
    36      *  paramn  = The identifier of the rightmost parameter in the function 
    37      *            parameter list. 
    38      */ 
    39     void va_start(T) ( out va_list ap, ref T parmn ) 
     28        template va_arg(T) 
    4029    { 
    41         ap = cast(va_list) ( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); 
    42     } 
    43  
    44     /** 
    45      * This function returns the next argument in the sequence referenced by 
    46      * the supplied argument pointer.  The argument pointer will be adjusted 
    47      * to point to the next arggument in the sequence. 
    48      * 
    49      * Params: 
    50      *  ap  = The argument pointer. 
    51      * 
    52      * Returns: 
    53      *  The next argument in the sequence.  The result is undefined if ap 
    54      *  does not point to a valid argument. 
    55      */ 
    56     T va_arg(T) ( ref va_list ap ) 
     30            T va_arg(ref va_list _argptr) 
    5731    { 
    58         T arg = *cast(T*) ap
    59         ap = cast(va_list) ( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); 
     32                T arg = *cast(T*)_argptr
     33                _argptr = _argptr + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1)); 
    6034        return arg; 
    6135    } 
    62  
    63     /** 
    64      * This function cleans up any resources allocated by va_start.  It is 
    65      * currently a no-op and exists mostly for syntax compatibility with 
    66      * the variadric argument functions for C. 
    67      * 
    68      * Params: 
    69      *  ap  = The argument pointer. 
    70      */ 
    71     void va_end( va_list ap ) 
    72     { 
    73  
    7436    } 
    75  
    76  
    77     /** 
    78      * This function copied the argument pointer src to dst. 
    79      * 
    80      * Params: 
    81      *  src = The source pointer. 
    82      *  dst = The destination pointer. 
    83      */ 
    84     void va_copy( out va_list dst, va_list src ) 
     37    } 
     38    else 
    8539    { 
    86         dst = src
     40        public import tango.stdc.stdarg
    8741    } 
    8842} 
  • tango/core/sync/Atomic.d

    old new  
    245245        return oldval; 
    246246    } 
    247247} else version(D_InlineAsm_X86) { 
    248     T atomicSwap( T )( inout T val, T newval ) 
     248    T atomicSwap( T )( ref T val, T newval ) 
    249249    in { 
    250250        // NOTE: 32 bit x86 systems support 8 byte CAS, which only requires 
    251251        //       4 byte alignment, so use size_t as the align type here. 
     
    289289        } 
    290290    } 
    291291} else version (D_InlineAsm_X86_64){ 
    292     T atomicSwap( T )( inout T val, T newval ) 
     292    T atomicSwap( T )( ref T val, T newval ) 
    293293    in { 
    294294        assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); 
    295295    } body { 
     
    332332        } 
    333333    } 
    334334} else { 
    335     T atomicSwap( T )( inout T val, T newval ) 
     335    T atomicSwap( T )( ref T val, T newval ) 
    336336    in { 
    337337        assert( atomicValueIsProperlyAligned!(T)( cast(size_t) &val ) ); 
    338338    } body { 
  • tango/stdc/stdarg.d

    old new  
    88 */ 
    99module tango.stdc.stdarg; 
    1010 
    11  
    1211version( GNU ) 
    1312{ 
    1413    public import std.c.stdarg; 
     
    1918} 
    2019else 
    2120{ 
     21version (X86) 
     22{ 
     23    /********************* 
     24     * The argument pointer type. 
     25     */ 
    2226    alias void* va_list; 
    2327 
    24     template va_start( T ) 
     28    /********** 
     29     * Initialize ap. 
     30     * For 32 bit code, parmn should be the last named parameter. 
     31     * For 64 bit code, parmn should be __va_argsave. 
     32     */ 
     33    void va_start(T)(out va_list ap, ref T parmn) 
    2534    { 
    26         void va_start( out va_list ap, ref T parmn ) 
    27         { 
    2835            ap = cast(va_list) ( cast(void*) &parmn + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); 
    2936        } 
    30     } 
    3137 
    32     template va_arg( T ) 
     38    /************ 
     39     * Retrieve and return the next value that is type T. 
     40     * Should use the other va_arg instead, as this won't work for 64 bit code. 
     41     */ 
     42    T va_arg(T)(ref va_list ap) 
    3343    { 
    34         T va_arg( ref va_list ap ) 
    35         { 
    3644            T arg = *cast(T*) ap; 
    3745            ap = cast(va_list) ( cast(void*) ap + ( ( T.sizeof + int.sizeof - 1 ) & ~( int.sizeof - 1 ) ) ); 
    3846            return arg; 
    3947        } 
     48 
     49    /************ 
     50     * Retrieve and return the next value that is type T. 
     51     * This is the preferred version. 
     52     */ 
     53    void va_arg(T)(ref va_list ap, ref T parmn) 
     54    { 
     55        parmn = *cast(T*)ap; 
     56        ap = cast(va_list)(cast(void*)ap + ((T.sizeof + int.sizeof - 1) & ~(int.sizeof - 1))); 
    4057    } 
    4158 
     59    /************* 
     60     * Retrieve and store through parmn the next value that is of TypeInfo ti. 
     61     * Used when the static type is not known. 
     62     */ 
     63    void va_arg()(ref va_list ap, TypeInfo ti, void* parmn) 
     64    { 
     65        // Wait until everyone updates to get TypeInfo.talign() 
     66        //auto talign = ti.talign(); 
     67        //auto p = cast(void*)(cast(size_t)ap + talign - 1) & ~(talign - 1); 
     68        auto p = ap; 
     69        auto tsize = ti.tsize(); 
     70        ap = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1))); 
     71        parmn[0..tsize] = p[0..tsize]; 
     72    } 
     73 
     74    /*********************** 
     75     * End use of ap. 
     76     */ 
    4277    void va_end( va_list ap ) 
    4378    { 
     79    } 
    4480 
     81    void va_copy(out va_list dest, va_list src) 
     82    { 
     83        dest = src; 
    4584    } 
     85} 
     86else version (X86_64) 
     87{ 
     88    // Layout of this struct must match __gnuc_va_list for C ABI compatibility 
     89    struct __va_list 
     90    { 
     91        uint offset_regs = 6 * 8;            // no regs 
     92        uint offset_fpregs = 6 * 8 + 8 * 16; // no fp regs 
     93        void* stack_args; 
     94        void* reg_args; 
     95    } 
    4696 
     97    struct __va_argsave_t 
     98    { 
     99        size_t[6] regs;   // RDI,RSI,RDX,RCX,R8,R9 
     100        real[8] fpregs;   // XMM0..XMM7 
     101        __va_list va; 
     102    } 
     103 
     104    /* 
     105     * Making it an array of 1 causes va_list to be passed as a pointer in 
     106     * function argument lists 
     107     */ 
     108    alias void* va_list; 
     109 
     110    void va_start(T)(out va_list ap, ref T parmn) 
     111    { 
     112        ap = &parmn.va; 
     113    } 
     114 
     115    T va_arg(T)(va_list ap) 
     116    {   T a; 
     117        va_arg(ap, a); 
     118        return a; 
     119    } 
     120 
     121    void va_arg(T)(va_list apx, ref T parmn) 
     122    { 
     123        __va_list* ap = cast(__va_list*)apx; 
     124        static if (is(T U == __argTypes)) 
     125        { 
     126            static if (U.length == 0 || T.sizeof > 16 || U[0].sizeof > 8) 
     127            {   // Always passed in memory 
     128                // The arg may have more strict alignment than the stack 
     129                auto p = (cast(size_t)ap.stack_args + T.alignof - 1) & ~(T.alignof - 1); 
     130                ap.stack_args = cast(void*)(p + ((T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1))); 
     131                parmn = *cast(T*)p; 
     132            } 
     133            else static if (U.length == 1) 
     134            {   // Arg is passed in one register 
     135                alias U[0] T1; 
     136                static if (is(T1 == double) || is(T1 == float)) 
     137                {   // Passed in XMM register 
     138                    if (ap.offset_fpregs < (6 * 8 + 16 * 8)) 
     139                    { 
     140                        parmn = *cast(T*)(ap.reg_args + ap.offset_fpregs); 
     141                        ap.offset_fpregs += 16; 
     142                    } 
     143                    else 
     144                    { 
     145                        parmn = *cast(T*)ap.stack_args; 
     146                        ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 
     147                    } 
     148                } 
     149                else 
     150                {   // Passed in regular register 
     151                    if (ap.offset_regs < 6 * 8 && T.sizeof <= 8) 
     152                    { 
     153                        parmn = *cast(T*)(ap.reg_args + ap.offset_regs); 
     154                        ap.offset_regs += 8; 
     155                    } 
     156                    else 
     157                    { 
     158                        auto p = (cast(size_t)ap.stack_args + T.alignof - 1) & ~(T.alignof - 1); 
     159                        ap.stack_args = cast(void*)(p + ((T.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1))); 
     160                        parmn = *cast(T*)p; 
     161                    } 
     162                } 
     163            } 
     164            else static if (U.length == 2) 
     165            {   // Arg is passed in two registers 
     166                alias U[0] T1; 
     167                alias U[1] T2; 
     168 
     169                static if (is(T1 == double) || is(T1 == float)) 
     170                { 
     171                    if (ap.offset_fpregs < (6 * 8 + 16 * 8)) 
     172                    { 
     173                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_fpregs); 
     174                        ap.offset_fpregs += 16; 
     175                    } 
     176                    else 
     177                    { 
     178                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args; 
     179                        ap.stack_args += (T1.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 
     180                    } 
     181                } 
     182                else 
     183                { 
     184                    if (ap.offset_regs < 6 * 8 && T1.sizeof <= 8) 
     185                    { 
     186                        *cast(T1*)&parmn = *cast(T1*)(ap.reg_args + ap.offset_regs); 
     187                        ap.offset_regs += 8; 
     188                    } 
     189                    else 
     190                    { 
     191                        *cast(T1*)&parmn = *cast(T1*)ap.stack_args; 
     192                        ap.stack_args += 8; 
     193                    } 
     194                } 
     195 
     196                auto p = cast(void*)&parmn + 8; 
     197                static if (is(T2 == double) || is(T2 == float)) 
     198                { 
     199                    if (ap.offset_fpregs < (6 * 8 + 16 * 8)) 
     200                    { 
     201                        *cast(T2*)p = *cast(T2*)(ap.reg_args + ap.offset_fpregs); 
     202                        ap.offset_fpregs += 16; 
     203                    } 
     204                    else 
     205                    { 
     206                        *cast(T2*)p = *cast(T2*)ap.stack_args; 
     207                        ap.stack_args += (T2.sizeof + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 
     208                    } 
     209                } 
     210                else 
     211                { 
     212                    void* a = void; 
     213                    if (ap.offset_regs < 6 * 8 && T2.sizeof <= 8) 
     214                    { 
     215                        a = ap.reg_args + ap.offset_regs; 
     216                        ap.offset_regs += 8; 
     217                    } 
     218                    else 
     219                    { 
     220                        a = ap.stack_args; 
     221                        ap.stack_args += 8; 
     222                    } 
     223                    // Be careful not to go past the size of the actual argument 
     224                    const sz2 = T.sizeof - 8; 
     225                    p[0..sz2] = a[0..sz2]; 
     226                } 
     227            } 
     228            else 
     229            { 
     230                static assert(0); 
     231            } 
     232        } 
     233        else 
     234        { 
     235            static assert(0, "not a valid argument type for va_arg"); 
     236        } 
     237    } 
     238 
     239    void va_arg()(va_list apx, TypeInfo ti, void* parmn) 
     240    { 
     241        __va_list* ap = cast(__va_list*)apx; 
     242        TypeInfo arg1, arg2; 
     243        if (!ti.argTypes(arg1, arg2)) 
     244        { 
     245            if (arg1 && arg1.tsize() <= 8) 
     246            {   // Arg is passed in one register 
     247                auto tsize = arg1.tsize(); 
     248                void* p; 
     249                auto s = arg1.toString(); 
     250                if (s == "double" || s == "float") 
     251                {   // Passed in XMM register 
     252                    if (ap.offset_fpregs < (6 * 8 + 16 * 8)) 
     253                    { 
     254                        p = ap.reg_args + ap.offset_fpregs; 
     255                        ap.offset_fpregs += 16; 
     256                    } 
     257                    else 
     258                    { 
     259                        p = ap.stack_args; 
     260                        ap.stack_args += (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 
     261                    } 
     262                } 
     263                else 
     264                {   // Passed in regular register 
     265                    if (ap.offset_regs < 6 * 8) 
     266                    { 
     267                        p = ap.reg_args + ap.offset_regs; 
     268                        ap.offset_regs += 8; 
     269                    } 
     270                    else 
     271                    { 
     272                        p = ap.stack_args; 
     273                        ap.stack_args += 8; 
     274                    } 
     275                } 
     276                parmn[0..tsize] = p[0..tsize]; 
     277 
     278                if (arg2) 
     279                { 
     280                    parmn += 8; 
     281                    tsize = arg2.tsize(); 
     282                    s = arg2.toString(); 
     283                    if (s == "double" || s == "float") 
     284                    {   // Passed in XMM register 
     285                        if (ap.offset_fpregs < (6 * 8 + 16 * 8)) 
     286                        { 
     287                            p = ap.reg_args + ap.offset_fpregs; 
     288                            ap.offset_fpregs += 16; 
     289                        } 
     290                        else 
     291                        { 
     292                            p = ap.stack_args; 
     293                            ap.stack_args += (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1); 
     294                        } 
     295                    } 
     296                    else 
     297                    {   // Passed in regular register 
     298                        if (ap.offset_regs < 6 * 8) 
     299                        { 
     300                            p = ap.reg_args + ap.offset_regs; 
     301                            ap.offset_regs += 8; 
     302                        } 
     303                        else 
     304                        { 
     305                            p = ap.stack_args; 
     306                            ap.stack_args += 8; 
     307                        } 
     308                    } 
     309                    tsize = ti.tsize() - 8; 
     310                    parmn[0..tsize] = p[0..tsize]; 
     311                } 
     312            } 
     313            else 
     314            {   // Always passed in memory 
     315                // The arg may have more strict alignment than the stack 
     316                auto talign = ti.talign(); 
     317                auto tsize = ti.tsize(); 
     318                auto p = cast(void*)((cast(size_t)ap.stack_args + talign - 1) & ~(talign - 1)); 
     319                ap.stack_args = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1))); 
     320                parmn[0..tsize] = p[0..tsize]; 
     321            } 
     322        } 
     323        else 
     324        { 
     325            assert(0, "not a valid argument type for va_arg"); 
     326        } 
     327    } 
     328 
     329    void va_end(va_list ap) 
     330    { 
     331    } 
     332 
    47333    void va_copy( out va_list dest, va_list src ) 
    48334    { 
    49335        dest = src; 
    50336    } 
    51337} 
     338else 
     339{ 
     340    static assert(0); 
     341} 
     342} 
  • tango/util/log/Log.d

    old new  
    103103        alias void* Arg; 
    104104        alias va_list ArgList; 
    105105        } 
     106version (DigitalMars) 
     107        { 
     108        private import tango.core.Vararg; 
     109        alias void* Arg; 
     110        alias va_list ArgList; 
     111        } 
    106112     else 
    107113        { 
    108114        alias void* Arg;