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

Changeset 1856

Show
Ignore:
Timestamp:
03/06/07 16:35:32 (5 years ago)
Author:
sean
Message:

Merged in final GDC 0.23 changes. These changes have also been applied to the DMD runtime where applicable. As most of these changes were replacing instances of int/uint with ptrdiff_t/size_t, there should be no noticeable difference in DMD behavior from these changes.

Please note that some changes were necessary to the GC as well, and I am trusting that Dave Friedman got things right. Again, most of these were changes from uint to size_t, but things here seem a bit less clear-cut than most of the changes to the GDC runtime itself.

Finally, it is worth being aware that of the GC code, only gcx.d is really pretty much the same between Tango and Phobos/GPhobos. The remaining files are split among the GC directory (gc/basic), and the files lifetime.d and memory.d in the compiler runtime code. The Tango design is far cleaner, but the structural differences complicate merging changes in this area. I've triple-checked all changes for this merge, but if there are any functional problems, I expect them to concern these GC-related files.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/compiler/dmd/arraycat.d

    r1414 r1856  
    3838extern (C): 
    3939 
    40 byte[] _d_arraycopy(uint size, byte[] from, byte[] to) 
     40byte[] _d_arraycopy(size_t size, byte[] from, byte[] to) 
    4141{ 
    4242    debug printf("f = %p,%d, t = %p,%d, size = %d\n", 
  • trunk/lib/compiler/dmd/cast.d

    r925 r1856  
    8181Object _d_dynamic_cast(Object o, ClassInfo c) 
    8282{   ClassInfo oc; 
    83     uint offset = 0; 
     83    size_t offset = 0; 
    8484 
    8585    //printf("_d_dynamic_cast(o = %p, c = '%.*s')\n", o, c.name); 
     
    100100} 
    101101 
    102 int _d_isbaseof2(ClassInfo oc, ClassInfo c, inout uint offset) 
     102int _d_isbaseof2(ClassInfo oc, ClassInfo c, inout size_t offset) 
    103103{   int i; 
    104104 
  • trunk/lib/compiler/dmd/genobj.d

    r1748 r1856  
    227227    ClassInfo classinfo;        /// .classinfo for this interface (not for containing class) 
    228228    void *[] vtbl; 
    229     int offset;                 /// offset to Interface 'this' from Object 'this' 
     229    ptrdiff_t offset;       /// offset to Interface 'this' from Object 'this' 
    230230} 
    231231 
     
    304304 
    305305    /// Returns a hash of the instance of a type. 
    306     hash_t getHash(void *p) { return cast(uint)p; } 
     306    hash_t getHash(void *p) { return cast(hash_t)p; } 
    307307 
    308308    /// Compares two instances for equality. 
     
    389389    hash_t getHash(void *p) 
    390390    { 
    391         return cast(uint)*cast(void* *)p; 
     391        return cast(hash_t)*cast(void**)p; 
    392392    } 
    393393 
  • trunk/lib/compiler/dmd/lifetime.d

    r1802 r1856  
    809809    uint i; 
    810810    byte[] b; 
    811     auto size = ti.next.tsize();                // array element size 
     811    auto size = ti.next.tsize(); // array element size 
    812812 
    813813    p = cast(byte[]*)(&n + 1); 
     
    837837    } 
    838838 
    839     *cast(int *)&a = length;    // jam length 
     839    *cast(size_t *)&a = length; // jam length 
    840840    //a.length = length; 
    841841    return a; 
  • trunk/lib/compiler/dmd/memset.d

    r454 r1856  
    2626{ 
    2727    // Functions from the C library. 
    28     void *memcpy(void *, void *, uint); 
     28    void *memcpy(void *, void *, size_t); 
    2929} 
    3030 
    3131extern (C): 
    3232 
    33 short *_memset16(short *p, short value, int count) 
     33short *_memset16(short *p, short value, size_t count) 
    3434{ 
    3535    short *pstart = p; 
     
    4141} 
    4242 
    43 int *_memset32(int *p, int value, int count) 
     43int *_memset32(int *p, int value, size_t count) 
    4444{ 
    4545version (X86) 
     
    6767} 
    6868 
    69 long *_memset64(long *p, long value, int count) 
     69long *_memset64(long *p, long value, size_t count) 
    7070{ 
    7171    long *pstart = p; 
     
    7777} 
    7878 
    79 cdouble *_memset128(cdouble *p, cdouble value, int count) 
     79cdouble *_memset128(cdouble *p, cdouble value, size_t count) 
    8080{ 
    8181    cdouble *pstart = p; 
     
    8787} 
    8888 
    89 real *_memset80(real *p, real value, int count) 
     89real *_memset80(real *p, real value, size_t count) 
    9090{ 
    9191    real *pstart = p; 
     
    9797} 
    9898 
    99 creal *_memset160(creal *p, creal value, int count) 
     99creal *_memset160(creal *p, creal value, size_t count) 
    100100{ 
    101101    creal *pstart = p; 
     
    107107} 
    108108 
    109 void *_memsetn(void *p, void *value, int count, int sizelem) 
     109void *_memsetn(void *p, void *value, int count, size_t sizelem) 
    110110{   void *pstart = p; 
    111111    int i; 
  • trunk/lib/compiler/dmd/qsort.d

    r1072 r1856  
    3030struct Array 
    3131{ 
    32     int length; 
    33     void *ptr; 
     32    size_t length; 
     33    voidptr; 
    3434} 
    3535 
  • trunk/lib/compiler/dmd/qsort2.d

    r925 r1856  
    2121{ 
    2222    size_t length; 
    23     void *ptr; 
     23    voidptr; 
    2424} 
    2525 
  • trunk/lib/compiler/dmd/typeinfo/ti_AC.d

    r1414 r1856  
    4343        Object[] s1 = *cast(Object[]*)p1; 
    4444        Object[] s2 = *cast(Object[]*)p2; 
    45         int c; 
     45        ptrdiff_t c; 
    4646 
    47         c = cast(int)s1.length - cast(int)s2.length; 
     47        c = cast(ptrdiff_t)s1.length - cast(ptrdiff_t)s2.length; 
    4848        if (c == 0) 
    4949        { 
     
    7272            } 
    7373        } 
     74        if (c < 0) 
     75            c = -1; 
     76        else if (c > 0) 
     77            c = 1; 
    7478        return c; 
    7579    } 
  • trunk/lib/compiler/dmd/typeinfo/ti_Acdouble.d

    r1414 r1856  
    8383                return c; 
    8484        } 
    85         return cast(int)s1.length - cast(int)s2.length; 
     85        if (s1.length < s2.length) 
     86            return -1; 
     87        else if (s1.length > s2.length) 
     88            return 1; 
     89        return 0; 
    8690    } 
    8791 
  • trunk/lib/compiler/dmd/typeinfo/ti_Acfloat.d

    r1414 r1856  
    8181                return c; 
    8282        } 
    83         return cast(int)s1.length - cast(int)s2.length; 
     83        if (s1.length < s2.length) 
     84            return -1; 
     85        else if (s1.length > s2.length) 
     86            return 1; 
     87        return 0; 
    8488    } 
    8589 
  • trunk/lib/compiler/dmd/typeinfo/ti_Acreal.d

    r1414 r1856  
    8484                return c; 
    8585        } 
    86         return cast(int)s1.length - cast(int)s2.length; 
     86        if (s1.length < s2.length) 
     87            return -1; 
     88        else if (s1.length > s2.length) 
     89            return 1; 
     90        return 0; 
    8791    } 
    8892 
  • trunk/lib/compiler/dmd/typeinfo/ti_Adouble.d

    r1414 r1856  
    8181                return c; 
    8282        } 
    83         return cast(int)s1.length - cast(int)s2.length; 
     83        if (s1.length < s2.length) 
     84            return -1; 
     85        else if (s1.length > s2.length) 
     86            return 1; 
     87        return 0; 
    8488    } 
    8589 
  • trunk/lib/compiler/dmd/typeinfo/ti_Afloat.d

    r1414 r1856  
    8080                return c; 
    8181        } 
    82         return cast(int)s1.length - cast(int)s2.length; 
     82        if (s1.length < s2.length) 
     83            return -1; 
     84        else if (s1.length > s2.length) 
     85            return 1; 
     86        return 0; 
    8387    } 
    8488 
  • trunk/lib/compiler/dmd/typeinfo/ti_Ag.d

    r1414 r1856  
    1212 
    1313    hash_t getHash(void *p) 
    14     {  byte[] s = *cast(byte[]*)p; 
    15    size_t len = s.length; 
    16    byte *str = s.ptr; 
    17    hash_t hash = 0; 
    18  
    19    while (1) 
    20    
    21        switch (len) 
    22        { 
    23        case 0: 
    24            return hash; 
    25  
    26        case 1: 
    27            hash *= 9; 
    28            hash += *cast(ubyte *)str; 
    29            return hash; 
    30  
    31        case 2: 
    32            hash *= 9; 
    33            hash += *cast(ushort *)str; 
    34            return hash; 
    35  
    36        case 3: 
    37            hash *= 9; 
    38            hash += (*cast(ushort *)str << 8) + 
    39                (cast(ubyte *)str)[2]; 
    40            return hash; 
    41  
    42        default: 
    43            hash *= 9; 
    44            hash += *cast(uint *)str; 
    45            str += 4; 
    46            len -= 4; 
    47            break; 
    48        } 
    49    
    50  
    51    return hash; 
     14    {   byte[] s = *cast(byte[]*)p; 
     15        size_t len = s.length; 
     16        byte *str = s.ptr; 
     17        hash_t hash = 0; 
     18 
     19        while (1) 
     20       
     21            switch (len) 
     22            { 
     23                case 0: 
     24                    return hash; 
     25 
     26                case 1: 
     27                    hash *= 9; 
     28                    hash += *cast(ubyte *)str; 
     29                    return hash; 
     30 
     31                case 2: 
     32                    hash *= 9; 
     33                    hash += *cast(ushort *)str; 
     34                    return hash; 
     35 
     36                case 3: 
     37                    hash *= 9; 
     38                    hash += (*cast(ushort *)str << 8) + 
     39                            (cast(ubyte *)str)[2]; 
     40                    return hash; 
     41 
     42                default: 
     43                    hash *= 9; 
     44                    hash += *cast(uint *)str; 
     45                    str += 4; 
     46                    len -= 4; 
     47                    break; 
     48            } 
     49       
     50 
     51        return hash; 
    5252    } 
    5353 
    5454    int equals(void *p1, void *p2) 
    5555    { 
    56    byte[] s1 = *cast(byte[]*)p1; 
    57    byte[] s2 = *cast(byte[]*)p2; 
    58  
    59    return s1.length == s2.length && 
    60           memcmp(cast(byte *)s1, cast(byte *)s2, s1.length) == 0; 
     56        byte[] s1 = *cast(byte[]*)p1; 
     57        byte[] s2 = *cast(byte[]*)p2; 
     58 
     59        return s1.length == s2.length && 
     60               memcmp(cast(byte *)s1, cast(byte *)s2, s1.length) == 0; 
    6161    } 
    6262 
    6363    int compare(void *p1, void *p2) 
    6464    { 
    65     byte[] s1 = *cast(byte[]*)p1; 
    66     byte[] s2 = *cast(byte[]*)p2; 
    67     size_t len = s1.length; 
    68  
    69     if (s2.length < len) 
    70         len = s2.length; 
    71     for (size_t u = 0; u < len; u++) 
    72     { 
    73         int result = s1[u] - s2[u]; 
    74         if (result) 
    75         return result; 
    76     } 
    77     return cast(int)s1.length - cast(int)s2.length; 
     65        byte[] s1 = *cast(byte[]*)p1; 
     66        byte[] s2 = *cast(byte[]*)p2; 
     67        size_t len = s1.length; 
     68 
     69        if (s2.length < len) 
     70            len = s2.length; 
     71        for (size_t u = 0; u < len; u++) 
     72        { 
     73            int result = s1[u] - s2[u]; 
     74            if (result) 
     75                return result; 
     76        } 
     77        if (s1.length < s2.length) 
     78            return -1; 
     79        else if (s1.length > s2.length) 
     80            return 1; 
     81        return 0; 
    7882    } 
    7983 
    8084    size_t tsize() 
    8185    { 
    82    return (byte[]).sizeof; 
     86        return (byte[]).sizeof; 
    8387    } 
    8488 
    8589    uint flags() 
    8690    { 
    87    return 1; 
    88     } 
    89  
    90     TypeInfo next() 
    91     { 
    92    return typeid(byte); 
     91        return 1; 
     92    } 
     93 
     94    TypeInfo next() 
     95    { 
     96        return typeid(byte); 
    9397    } 
    9498} 
     
    103107    int compare(void *p1, void *p2) 
    104108    { 
    105    char[] s1 = *cast(char[]*)p1; 
    106    char[] s2 = *cast(char[]*)p2; 
    107  
    108    return stringCompare(s1, s2); 
    109     } 
    110  
    111     TypeInfo next() 
    112     { 
    113    return typeid(ubyte); 
     109        char[] s1 = *cast(char[]*)p1; 
     110        char[] s2 = *cast(char[]*)p2; 
     111 
     112        return stringCompare(s1, s2); 
     113    } 
     114 
     115    TypeInfo next() 
     116    { 
     117        return typeid(ubyte); 
    114118    } 
    115119} 
     
    123127    TypeInfo next() 
    124128    { 
    125    return typeid(void); 
     129        return typeid(void); 
    126130    } 
    127131} 
     
    135139    TypeInfo next() 
    136140    { 
    137    return typeid(bool); 
     141        return typeid(bool); 
    138142    } 
    139143} 
     
    146150 
    147151    hash_t getHash(void *p) 
    148     {  char[] s = *cast(char[]*)p; 
    149    hash_t hash = 0; 
     152    {   char[] s = *cast(char[]*)p; 
     153        hash_t hash = 0; 
    150154 
    151155version (all) 
    152156{ 
    153    foreach (char c; s) 
    154        hash = hash * 11 + c; 
     157        foreach (char c; s) 
     158            hash = hash * 11 + c; 
    155159} 
    156160else 
    157161{ 
    158    size_t len = s.length; 
    159    char *str = s; 
    160  
    161    while (1) 
    162    
    163        switch (len) 
    164        { 
    165        case 0: 
    166            return hash; 
    167  
    168        case 1: 
    169            hash *= 9; 
    170            hash += *cast(ubyte *)str; 
    171            return hash; 
    172  
    173        case 2: 
    174            hash *= 9; 
    175            hash += *cast(ushort *)str; 
    176            return hash; 
    177  
    178        case 3: 
    179            hash *= 9; 
    180            hash += (*cast(ushort *)str << 8) + 
    181                (cast(ubyte *)str)[2]; 
    182            return hash; 
    183  
    184        default: 
    185            hash *= 9; 
    186            hash += *cast(uint *)str; 
    187            str += 4; 
    188            len -= 4; 
    189            break; 
    190        } 
    191    
    192 } 
    193    return hash; 
    194     } 
    195  
    196     TypeInfo next() 
    197     { 
    198    return typeid(char); 
    199     } 
    200 } 
    201  
    202  
     162        size_t len = s.length; 
     163        char *str = s; 
     164 
     165        while (1) 
     166       
     167            switch (len) 
     168            { 
     169                case 0: 
     170                    return hash; 
     171 
     172                case 1: 
     173                    hash *= 9; 
     174                    hash += *cast(ubyte *)str; 
     175                    return hash; 
     176 
     177                case 2: 
     178                    hash *= 9; 
     179                    hash += *cast(ushort *)str; 
     180                    return hash; 
     181 
     182                case 3: 
     183                    hash *= 9; 
     184                    hash += (*cast(ushort *)str << 8) + 
     185                            (cast(ubyte *)str)[2]; 
     186                    return hash; 
     187 
     188                default: 
     189                    hash *= 9; 
     190                    hash += *cast(uint *)str; 
     191                    str += 4; 
     192                    len -= 4; 
     193                    break; 
     194            } 
     195       
     196} 
     197        return hash; 
     198    } 
     199 
     200    TypeInfo next() 
     201    { 
     202        return typeid(char); 
     203    } 
     204} 
     205 
     206 
  • trunk/lib/compiler/dmd/typeinfo/ti_Aint.d

    r1414 r1856  
    5050                return result; 
    5151        } 
    52         return cast(int)s1.length - cast(int)s2.length; 
     52        if (s1.length < s2.length) 
     53            return -1; 
     54        else if (s1.length > s2.length) 
     55            return 1; 
     56        return 0; 
    5357    } 
    5458 
     
    8993                return result; 
    9094        } 
    91         return cast(int)s1.length - cast(int)s2.length; 
     95        if (s1.length < s2.length) 
     96            return -1; 
     97        else if (s1.length > s2.length) 
     98            return 1; 
     99        return 0; 
    92100    } 
    93101 
  • trunk/lib/compiler/dmd/typeinfo/ti_Along.d

    r1414 r1856  
    5151                return 1; 
    5252        } 
    53         return cast(int)s1.length - cast(int)s2.length; 
     53        if (s1.length < s2.length) 
     54            return -1; 
     55        else if (s1.length > s2.length) 
     56            return 1; 
     57        return 0; 
    5458    } 
    5559 
     
    9296                return 1; 
    9397        } 
    94         return cast(int)s1.length - cast(int)s2.length; 
     98        if (s1.length < s2.length) 
     99            return -1; 
     100        else if (s1.length > s2.length) 
     101            return 1; 
     102        return 0; 
    95103    } 
    96104 
  • trunk/lib/compiler/dmd/typeinfo/ti_Areal.d

    r1414 r1856  
    8282                return c; 
    8383        } 
    84         return cast(int)s1.length - cast(int)s2.length; 
     84        if (s1.length < s2.length) 
     85            return -1; 
     86        else if (s1.length > s2.length) 
     87            return 1; 
     88        return 0; 
    8589    } 
    8690 
  • trunk/lib/compiler/dmd/typeinfo/ti_Ashort.d

    r1414 r1856  
    6363                return result; 
    6464        } 
    65         return cast(int)s1.length - cast(int)s2.length; 
     65        if (s1.length < s2.length) 
     66            return -1; 
     67        else if (s1.length > s2.length) 
     68            return 1; 
     69        return 0; 
    6670    } 
    6771 
     
    103107                return result; 
    104108        } 
    105         return cast(int)s1.length - cast(int)s2.length; 
     109        if (s1.length < s2.length) 
     110            return -1; 
     111        else if (s1.length > s2.length) 
     112            return 1; 
     113        return 0; 
    106114    } 
    107115 
  • trunk/lib/compiler/dmd/typeinfo/ti_ptr.d

    r1414 r1856  
    1818    int compare(void *p1, void *p2) 
    1919    { 
    20         return *cast(void* *)p1 - *cast(void* *)p2; 
     20        auto c = *cast(void* *)p1 - *cast(void* *)p2; 
     21        if (c < 0) 
     22            return -1; 
     23        else if (c > 0) 
     24            return 1; 
     25        return 0; 
    2126    } 
    2227 
  • trunk/lib/compiler/gdc/arraycat.d

    r1617 r1856  
    3838extern (C): 
    3939 
    40 byte[] _d_arraycopy(uint size, byte[] from, byte[] to) 
     40byte[] _d_arraycopy(size_t size, byte[] from, byte[] to) 
    4141{ 
    4242    debug printf("f = %p,%d, t = %p,%d, size = %d\n", 
  • trunk/lib/compiler/gdc/cast.d

    r925 r1856  
    8181Object _d_dynamic_cast(Object o, ClassInfo c) 
    8282{   ClassInfo oc; 
    83     uint offset = 0; 
     83    size_t offset = 0; 
    8484 
    8585    //printf("_d_dynamic_cast(o = %p, c = '%.*s')\n", o, c.name); 
     
    100100} 
    101101 
    102 int _d_isbaseof2(ClassInfo oc, ClassInfo c, inout uint offset) 
     102int _d_isbaseof2(ClassInfo oc, ClassInfo c, inout size_t offset) 
    103103{   int i; 
    104104 
  • trunk/lib/compiler/gdc/config/config-head

    r454 r1856  
    55private import gcc.configext; 
    66 
    7 alias __builtin_abi_int Clong_t; 
    8 alias __builtin_abi_uint Culong_t; 
     7alias __builtin_Clong Clong_t; 
     8alias __builtin_Culong Culong_t; 
  • trunk/lib/compiler/gdc/config/config-mid

    r454 r1856  
    33version (linux) { 
    44    version(X86) 
    5     version = Use_FP_Math; 
     5        version = Use_FP_Math; 
     6    else version(X86_64) 
     7        version = Use_FP_Math; 
    68    else version(PPC) 
    7     version = Use_FP_Math; 
    8     else version(Solaris) 
    9     version = Use_FP_Math; 
     9        version = Use_FP_Math; 
     10    else version(PPC64) 
     11        version = Use_FP_Math; 
     12    else version(SPARC) 
     13        version = Use_FP_Math; 
     14    else version(SPARC64) 
     15        version = Use_FP_Math; 
    1016    // any system using IEEE FP is fine, just not listed 
    1117 
     
    3339      int __signbitl(real); 
    3440  } 
    35    
     41 
    3642  int isnan(real x) { return __isnand(x); } 
    3743  int isfinite(real x) { return __isfinited(x); } 
     
    4450  int isinf(real x) { return __isinfd(x); } 
    4551  int signbit(real x) { return __signbitd(x); } 
    46   int fpclassify(real x) { return __fpclassifyd(x); }     
    47   int fpclassify(double x) { return __fpclassifyd(x); }     
    48   int fpclassify(float x) { return __fpclassifyf(x); }     
     52  int fpclassify(real x) { return __fpclassifyd(x); } 
     53  int fpclassify(double x) { return __fpclassifyd(x); } 
     54  int fpclassify(float x) { return __fpclassifyf(x); } 
    4955} else version (solaris) { 
    5056    // for now this is a copy of the darwin stuff (and doesn't work) 
     
    7076      int __signbitl(real); 
    7177  } 
    72    
     78 
    7379  int isnan(real x) { return __isnand(x); } 
    7480  int isfinite(real x) { return __isfinited(x); } 
     
    8187  int isinf(real x) { return __isinfd(x); } 
    8288  int signbit(real x) { return __signbitd(x); } 
    83   int fpclassify(real x) { return __fpclassifyd(x); }     
    84   int fpclassify(double x) { return __fpclassifyd(x); }     
    85   int fpclassify(float x) { return __fpclassifyf(x); }     
     89  int fpclassify(real x) { return __fpclassifyd(x); } 
     90  int fpclassify(double x) { return __fpclassifyd(x); } 
     91  int fpclassify(float x) { return __fpclassifyf(x); } 
    8692} else { 
    8793    version = Use_FP_Math; 
     
    94100    int isnan(real x) { return fpclassify(x)==FP_NAN; } 
    95101    int isfinite(real x) { 
    96    int r = fpclassify(x); 
    97    return r != FP_NAN && r != FP_INFINITE; 
     102        int r = fpclassify(x); 
     103        return r != FP_NAN && r != FP_INFINITE; 
    98104    } 
    99105    int isnormal(real x) { return fpclassify(x)==FP_NORMAL; } 
  • trunk/lib/compiler/gdc/config/darwin8/frag-gen

    r700 r1856  
    44const size_t dirent_d_name_size = 256; 
    55const size_t dirent_remaining_size = 0; 
     6static if (size_t.sizeof == 4) 
    67const size_t DIR_struct_size = 80; 
     8else 
     9    const size_t DIR_struct_size = 136; 
    710 
    811// from <stdlib.h> 
     
    1013 
    1114// from <stdio.h> 
    12 const size_t FILE_struct_size = 88; 
     15static if (size_t.sizeof == 4) 
     16    const size_t FILE_struct_size = 88; 
     17else 
     18    const size_t FILE_struct_size = 152; 
    1319const int EOF = -1; 
    1420const int FOPEN_MAX = 20; 
     
    2026// from <sys/types.h> 
    2127alias long Coff_t; 
    22 alias uint Csize_t; 
    23 alias int Ctime_t; 
     28alias size_t   Csize_t; 
     29alias Clong_t  Ctime_t; 
     30alias Culong_t Cclock_t; 
    2431 
    2532// from <time.h> 
    2633const uint CLOCKS_PER_SEC = 100; 
     34struct tm { 
     35    int tm_sec; 
     36    int tm_min; 
     37    int tm_hour; 
     38    int tm_mday; 
     39    int tm_mon; 
     40    int tm_year; 
     41    int tm_wday; 
     42    int tm_yday; 
     43    int tm_isdst; 
     44    Clong_t tm_gmtoff; 
     45    char * tm_zone; 
     46} 
     47 
     48static assert(tm.tm_sec.offsetof == 0); 
     49static assert(tm.tm_min.offsetof == 4); 
     50static assert(tm.tm_hour.offsetof == 8); 
     51static assert(tm.tm_mday.offsetof == 12); 
     52static assert(tm.tm_mon.offsetof == 16); 
     53static assert(tm.tm_year.offsetof == 20); 
     54static assert(tm.tm_wday.offsetof == 24); 
     55static assert(tm.tm_yday.offsetof == 28); 
     56static assert(tm.tm_isdst.offsetof == 32); 
     57 
     58 
  • trunk/lib/compiler/gdc/config/darwin8/frag-unix

    r1173 r1856  
    88alias uint uid_t; 
    99alias uint gid_t; 
     10alias Clong_t ssize_t; 
    1011 
    1112enum { 
     
    4748} 
    4849 
    49 alias int time_t; 
     50alias Clong_t time_t; 
    5051struct timespec { 
    51     int tv_sec; 
    52     int tv_nsec; 
    53 
    54  
    55 static assert(timespec.tv_sec.offsetof == 0); 
    56 static assert(timespec.tv_nsec.offsetof == 4); 
    57 static assert(timespec.sizeof == 8); 
    58  
     52    Clong_t tv_sec; 
     53    Clong_t tv_nsec; 
     54
    5955 
    6056struct timeval { 
    61     int tv_sec; 
     57    Clong_t tv_sec; 
    6258    int tv_usec; 
    6359} 
    64  
    65 static assert(timeval.tv_sec.offsetof == 0); 
    66 static assert(timeval.tv_usec.offsetof == 4); 
    67 static assert(timeval.sizeof == 8); 
    68  
    6960 
    7061struct timezone { 
     
    7970 
    8071struct utimbuf { 
    81     int actime; 
    82     int modtime; 
    83 
    84  
    85 static assert(utimbuf.actime.offsetof == 0); 
    86 static assert(utimbuf.modtime.offsetof == 4); 
    87 static assert(utimbuf.sizeof == 8); 
    88  
     72    Clong_t actime; 
     73    Clong_t modtime; 
     74
    8975 
    9076enum { 
     
    118104    uint st_gid; 
    119105    int st_rdev; 
    120     int st_atime; 
    121    ubyte[4] ___pad1; 
    122     int st_mtime; 
    123    ubyte[4] ___pad2; 
    124     int st_ctime; 
    125    ubyte[4] ___pad3; 
    126     long st_size; 
     106    time_t st_atime; 
     107    time_t ___pad1; 
     108    time_t st_mtime; 
     109    time_t ___pad2; 
     110    time_t st_ctime; 
     111    time_t ___pad3; 
     112    off_t st_size; 
    127113    long st_blocks; 
    128114    int st_blksize; 
    129115   ubyte[28] ___pad4; 
    130116} 
    131  
    132 static assert(struct_stat.st_dev.offsetof == 0); 
    133 static assert(struct_stat.st_ino.offsetof == 4); 
    134 static assert(struct_stat.st_mode.offsetof == 8); 
    135 static assert(struct_stat.st_nlink.offsetof == 10); 
    136 static assert(struct_stat.st_uid.offsetof == 12); 
    137 static assert(struct_stat.st_gid.offsetof == 16); 
    138 static assert(struct_stat.st_rdev.offsetof == 20); 
    139 static assert(struct_stat.st_atime.offsetof == 24); 
    140 static assert(struct_stat.st_mtime.offsetof == 32); 
    141 static assert(struct_stat.st_ctime.offsetof == 40); 
    142 static assert(struct_stat.st_size.offsetof == 48); 
    143 static assert(struct_stat.st_blocks.offsetof == 56); 
    144 static assert(struct_stat.st_blksize.offsetof == 64); 
    145 static assert(struct_stat.sizeof == 96); 
    146  
    147117 
    148118// from <sys/signal.h> 
     
    203173    int si_errno; 
    204174    int si_code; 
     175    static if (size_t.sizeof == 4) 
    205176   ubyte[52] ___pad1; 
    206 
    207  
    208 static assert(siginfo_t.si_signo.offsetof == 0); 
    209 static assert(siginfo_t.si_errno.offsetof == 4); 
    210 static assert(siginfo_t.si_code.offsetof == 8); 
    211 static assert(siginfo_t.sizeof == 64); 
    212  
     177    else 
     178       ubyte[92] ___pad1; 
     179
    213180 
    214181struct sigaction_t { 
     
    220187    int sa_flags; 
    221188} 
    222  
    223 static assert(sigaction_t.sa_flags.offsetof == 8); 
    224 static assert(sigaction_t.sizeof == 12); 
    225189 
    226190 
     
    268232} 
    269233 
    270 struct sem_t { ubyte[4] opaque; } 
    271 alias uint pthread_t; 
     234alias int sem_t; 
     235alias Culong_t pthread_t; 
     236static if (size_t.sizeof == 4) 
     237
    272238struct pthread_attr_t { ubyte[40] opaque; } 
    273239struct pthread_cond_t { ubyte[28] opaque; } 
     
    275241struct pthread_mutex_t { ubyte[44] opaque; } 
    276242struct pthread_mutexattr_t { ubyte[12] opaque; } 
     243} 
     244else 
     245{ 
     246    struct pthread_attr_t { ubyte[64] opaque; } 
     247    struct pthread_cond_t { ubyte[48] opaque; } 
     248    struct pthread_condattr_t { ubyte[16] opaque; } 
     249    struct pthread_mutex_t { ubyte[64] opaque; } 
     250    struct pthread_mutexattr_t { ubyte[16] opaque; } 
     251} 
    277252struct sched_param { 
    278253    int sched_priority; 
     
    409384} 
    410385 
    411 static assert(protoent.p_proto.offsetof == 8); 
    412 static assert(protoent.sizeof == 12); 
    413  
    414  
    415386struct servent { 
    416387    char * s_name; 
     
    419390    char * s_proto; 
    420391} 
    421  
    422 static assert(servent.s_port.offsetof == 8); 
    423 static assert(servent.sizeof == 16); 
    424392 
    425393 
     
    432400char* h_addr() 
    433401{ 
    434     return h_addr_list[0]; 
    435 
    436 
    437  
    438 static assert(hostent.h_addrtype.offsetof == 8); 
    439 static assert(hostent.h_length.offsetof == 12); 
    440 static assert(hostent.sizeof == 20); 
    441  
     402        return h_addr_list[0]; 
     403
     404
    442405 
    443406struct addrinfo { } 
     
    447410    uint pw_uid; 
    448411    uint pw_gid; 
    449    ubyte[8] ___pad1; 
     412    time_t pw_change; 
     413    char * pw_class; 
    450414    char * pw_gecos; 
    451415    char * pw_dir; 
    452416    char * pw_shell; 
    453    ubyte[4] ___pad2; 
    454 
    455  
    456 static assert(passwd.pw_uid.offsetof == 8); 
    457 static assert(passwd.pw_gid.offsetof == 12); 
    458 static assert(passwd.sizeof == 40); 
    459  
    460  
    461 
    462  
     417    time_t pw_expire; 
     418
     419 
     420
     421 
  • trunk/lib/compiler/gdc/config/gen_unix.c

    r1173 r1856  
    6464    INT_TYPE(uid_t); 
    6565    INT_TYPE(gid_t); 
     66    INT_TYPE(ssize_t); 
    6667    printf("\n"); 
    6768} 
     
    143144 
    144145    { 
    145    FieldInfo fi[2]; 
    146    struct timespec rec; 
    147    INT_FIELD(fi[0], tv_sec); 
    148    INT_FIELD(fi[1], tv_nsec); 
    149    finish_struct(fi, 2, sizeof(rec), "timespec"); 
    150     } 
    151     { 
    152    FieldInfo fi[2]; 
    153    struct timeval rec; 
    154    INT_FIELD(fi[0], tv_sec); 
    155    INT_FIELD(fi[1], tv_usec); 
    156    finish_struct(fi, 2, sizeof(rec), "timeval"); 
    157     } 
    158     { 
    159    FieldInfo fi[2]; 
    160    struct timezone rec; 
    161    INT_FIELD(fi[0], tz_minuteswest); 
    162    INT_FIELD(fi[1], tz_dsttime); 
    163    finish_struct(fi, 2, sizeof(rec), "timezone"); 
     146        FieldInfo fi[2]; 
     147        struct timespec rec; 
     148        INT_FIELD(fi[0], tv_sec); 
     149        INT_FIELD(fi[1], tv_nsec); 
     150        finish_struct(fi, 2, sizeof(rec), "timespec"); 
     151    } 
     152    { 
     153        FieldInfo fi[2]; 
     154        struct timeval rec; 
     155        INT_FIELD(fi[0], tv_sec); 
     156        INT_FIELD(fi[1], tv_usec); 
     157        finish_struct(fi, 2, sizeof(rec), "timeval"); 
     158    } 
     159    { 
     160        FieldInfo fi[2]; 
     161        struct timezone rec; 
     162        INT_FIELD(fi[0], tz_minuteswest); 
     163        INT_FIELD(fi[1], tz_dsttime); 
     164        finish_struct(fi, 2, sizeof(rec), "timezone"); 
    164165    } 
    165166} 
     
    168169    { 
    169170    { 
    170    FieldInfo fi[2]; 
    171    struct utimbuf rec; 
    172    INT_FIELD(fi[0], actime); 
    173    INT_FIELD(fi[1], modtime); 
    174    finish_struct(fi, 2, sizeof(rec), "utimbuf"); 
     171        FieldInfo fi[2]; 
     172        struct utimbuf rec; 
     173        INT_FIELD(fi[0], actime); 
     174        INT_FIELD(fi[1], modtime); 
     175        finish_struct(fi, 2, sizeof(rec), "utimbuf"); 
    175176    } 
    176177} 
     
    345346#ifdef HAVE_SIGINFO_T 
    346347    { 
    347    siginfo_t rec; 
    348    FieldInfo fi[3]; 
    349    INT_FIELD(fi[0],si_signo); 
    350    INT_FIELD(fi[1],si_errno); 
    351    INT_FIELD(fi[2],si_code); 
    352    printf("/* siginfo_t is not finished... see gen_unix.c */\n"); 
    353    finish_struct(fi, 3, sizeof(rec), "siginfo_t"); 
     348        siginfo_t rec; 
     349        FieldInfo fi[3]; 
     350        INT_FIELD(fi[0],si_signo); 
     351        INT_FIELD(fi[1],si_errno); 
     352        INT_FIELD(fi[2],si_code); 
     353        printf("/* siginfo_t is not finished... see gen_unix.c */\n"); 
     354        finish_struct(fi, 3, sizeof(rec), "siginfo_t"); 
    354355    } 
    355356#else 
     
    358359 
    359360    { 
    360    struct sigaction rec; 
    361    FieldInfo fi[4]; 
    362    int n = 0; 
    363    ADD_FIELD(fi[n], "void function(int)",  sa_handler); 
    364    n++; 
     361        struct sigaction rec; 
     362        FieldInfo fi[4]; 
     363        int n = 0; 
     364        ADD_FIELD(fi[n], "void function(int)",  sa_handler); 
     365        n++; 
    365366#ifdef HAVE_SIGINFO_T 
    366    ADD_FIELD(fi[n], "void function(int, siginfo_t *, void *)", sa_sigaction); 
    367    n++; 
    368 #endif 
    369    ADD_FIELD(fi[n], "sigset_t", sa_mask); 
    370    n++; 
    371    INT_FIELD(fi[n], sa_flags); 
    372    n++; 
    373    //FN_FIELD(fi[4], "void (*sa_restorer)(void)", sa_restorer); 
    374    //ADD_FIELD(fi[4], "void function(void)", sa_restorer); 
    375    finish_struct(fi, n, sizeof(rec), "sigaction_t"); 
     367        ADD_FIELD(fi[n], "void function(int, siginfo_t *, void *)", sa_sigaction); 
     368        n++; 
     369#endif 
     370        ADD_FIELD(fi[n], "sigset_t", sa_mask); 
     371        n++; 
     372        INT_FIELD(fi[n], sa_flags); 
     373        n++; 
     374        //FN_FIELD(fi[4], "void (*sa_restorer)(void)", sa_restorer); 
     375        //ADD_FIELD(fi[4], "void function(void)", sa_restorer); 
     376        finish_struct(fi, n, sizeof(rec), "sigaction_t"); 
    376377    } 
    377378    // not sure about this 
     
    387388#ifdef PROT_NONE 
    388389    printf("enum { PROT_NONE = %d, PROT_READ = %d, PROT_WRITE = %d, PROT_EXEC = %d }\n", 
    389    PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC); 
     390        PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC); 
    390391    // there are more flags, but this is all that is needed for GC and other modules 
    391392#endif 
    392393#ifdef MAP_SHARED 
    393394    printf( 
    394       "enum { MAP_SHARED = 0x%x, MAP_PRIVATE = 0x%x, MAP_ANON = 0x%x," 
    395       "       MAP_ANONYMOUS = 0x%x,", 
    396       MAP_SHARED, MAP_PRIVATE, 
    397       // not sure if these are alway macros, if not, just add an autoconf test 
     395           "enum { MAP_SHARED = 0x%x, MAP_PRIVATE = 0x%x, MAP_ANON = 0x%x," 
     396           "       MAP_ANONYMOUS = 0x%x,", 
     397           MAP_SHARED, MAP_PRIVATE, 
     398           // not sure if these are alway macros, if not, just add an autoconf test 
    398399#ifdef MAP_ANON 
    399       MAP_ANON, MAP_ANON 
    400 #else 
    401       MAP_ANONYMOUS, MAP_ANONYMOUS 
    402 #endif 
    403       ); 
     400           MAP_ANON, MAP_ANON 
     401#else 
     402           MAP_ANONYMOUS, MAP_ANONYMOUS 
     403#endif 
     404           ); 
    404405#ifdef MAP_TYPE 
    405406    CES( MAP_TYPE ); 
     
    548549    OPAQUE_TYPE(pthread_mutexattr_t); 
    549550    { 
    550    struct sched_param rec; 
    551    FieldInfo fi[1]; 
    552    INT_FIELD(fi[0],sched_priority); 
    553    finish_struct(fi, 1, sizeof(rec), "sched_param"); 
     551        struct sched_param rec; 
     552        FieldInfo fi[1]; 
     553        INT_FIELD(fi[0],sched_priority); 
     554        finish_struct(fi, 1, sizeof(rec), "sched_param"); 
    554555    } 
    555556#if HAVE_PTHREAD_BARRIER_T 
     
    640641    printf("\n"); 
    641642    { 
    642    struct linger rec; 
    643    FieldInfo fi[2]; 
    644    INT_FIELD(fi[0],l_onoff); 
    645    INT_FIELD(fi[1],l_linger); 
    646    finish_struct(fi, 2, sizeof(rec), "linger"); 
     643        struct linger rec; 
     644        FieldInfo fi[2]; 
     645        INT_FIELD(fi[0],l_onoff); 
     646        INT_FIELD(fi[1],l_linger); 
     647        finish_struct(fi, 2, sizeof(rec), "linger"); 
    647648    } 
    648649    printf("\n"); 
     
    795796    printf("// from <netdb.h>\n"); 
    796797    { 
    797    FieldInfo fi[3]; 
    798    struct protoent rec; 
    799    ADD_FIELD(fi[0], "char *", p_name); 
    800    ADD_FIELD(fi[1], "char **", p_aliases); 
    801    INT_FIELD(fi[2], p_proto); 
    802    finish_struct(fi, 3, sizeof(rec), "protoent"); 
    803     } 
    804     { 
    805    FieldInfo fi[4]; 
    806    struct servent rec; 
    807    ADD_FIELD(fi[0], "char *", s_name); 
    808    ADD_FIELD(fi[1], "char **", s_aliases); 
    809    INT_FIELD(fi[2], s_port); 
    810    ADD_FIELD(fi[3], "char *", s_proto); 
    811    finish_struct(fi, 4, sizeof(rec), "servent"); 
    812     } 
    813     { 
    814    FieldInfo fi[5]; 
    815    struct hostent rec; 
    816    ADD_FIELD(fi[0], "char *", h_name); 
    817    ADD_FIELD(fi[1], "char **", h_aliases); 
    818    INT_FIELD(fi[2], h_addrtype); 
    819    INT_FIELD(fi[3], h_length); 
    820    ADD_FIELD(fi[4], "char **", h_addr_list); 
    821    finish_struct_ex(fi, 5, sizeof(rec), "hostent", 
    822    "char* h_addr()\n" 
    823    "{\n" 
    824    "   return h_addr_list[0];\n" 
    825    "}"); 
     798        FieldInfo fi[3]; 
     799        struct protoent rec; 
     800        ADD_FIELD(fi[0], "char *", p_name); 
     801        ADD_FIELD(fi[1], "char **", p_aliases); 
     802        INT_FIELD(fi[2], p_proto); 
     803        finish_struct(fi, 3, sizeof(rec), "protoent"); 
     804    } 
     805    { 
     806        FieldInfo fi[4]; 
     807        struct servent rec; 
     808        ADD_FIELD(fi[0], "char *", s_name); 
     809        ADD_FIELD(fi[1], "char **", s_aliases); 
     810        INT_FIELD(fi[2], s_port); 
     811        ADD_FIELD(fi[3], "char *", s_proto); 
     812        finish_struct(fi, 4, sizeof(rec), "servent"); 
     813    } 
     814    { 
     815        FieldInfo fi[5]; 
     816        struct hostent rec; 
     817        ADD_FIELD(fi[0], "char *", h_name); 
     818        ADD_FIELD(fi[1], "char **", h_aliases); 
     819        INT_FIELD(fi[2], h_addrtype); 
     820        INT_FIELD(fi[3], h_length); 
     821        ADD_FIELD(fi[4], "char **", h_addr_list); 
     822        finish_struct_ex(fi, 5, sizeof(rec), "hostent", 
     823        "char* h_addr()\n" 
     824        "{\n" 
     825        "       return h_addr_list[0];\n" 
     826        "}"); 
    826827    } 
    827828    /*//not required for std/socket.d yet 
    828829    { 
    829    FieldInfo fi[8]; 
    830    struct addrinfo rec; 
    831    INT_FIELD(fi[0], ai_flags); 
    832    INT_FIELD(fi[1], ai_family); 
    833    INT_FIELD(fi[2], ai_socktype); 
    834    INT_FIELD(fi[3], ai_protocol); 
    835    INT_FIELD(fi[4], ai_addrlen); 
    836    ADD_FIELD(fi[5], "sockaddr *", ai_addr); 
    837    ADD_FIELD(fi[6], "char *", ai_canonname); 
    838    ADD_FIELD(fi[7], "addrinfo *", ai_next); 
    839    finish_struct(fi, 8, "addrinfo"); 
     830        FieldInfo fi[8]; 
     831        struct addrinfo rec; 
     832        INT_FIELD(fi[0], ai_flags); 
     833        INT_FIELD(fi[1], ai_family); 
     834        INT_FIELD(fi[2], ai_socktype); 
     835        INT_FIELD(fi[3], ai_protocol); 
     836        INT_FIELD(fi[4], ai_addrlen); 
     837        ADD_FIELD(fi[5], "sockaddr *", ai_addr); 
     838        ADD_FIELD(fi[6], "char *", ai_canonname); 
     839        ADD_FIELD(fi[7], "addrinfo *", ai_next); 
     840        finish_struct(fi, 8, "addrinfo"); 
    840841    } 
    841842    */ 
     
    846847{ 
    847848    { 
    848    FieldInfo fi[7]; 
    849    struct passwd rec; 
    850    ADD_FIELD(fi[0], "char *", pw_name); 
    851    ADD_FIELD(fi[1], "char *", pw_passwd); 
    852    INT_FIELD(fi[2], pw_uid); 
    853    INT_FIELD(fi[3], pw_gid); 
    854    ADD_FIELD(fi[4], "char *", pw_gecos); 
    855    ADD_FIELD(fi[5], "char *", pw_dir); 
    856    ADD_FIELD(fi[6], "char *", pw_shell); 
    857    finish_struct(fi, 7, sizeof(rec), "passwd"); 
     849        FieldInfo fi[7]; 
     850        struct passwd rec; 
     851        ADD_FIELD(fi[0], "char *", pw_name); 
     852        ADD_FIELD(fi[1], "char *", pw_passwd); 
     853        INT_FIELD(fi[2], pw_uid); 
     854        INT_FIELD(fi[3], pw_gid); 
     855        ADD_FIELD(fi[4], "char *", pw_gecos); 
     856        ADD_FIELD(fi[5], "char *", pw_dir); 
     857        ADD_FIELD(fi[6], "char *", pw_shell); 
     858        finish_struct(fi, 7, sizeof(rec), "passwd"); 
    858859    } 
    859860} 
  • trunk/lib/compiler/gdc/config/skyos/frag-unix

    r700 r1856  
    88alias ushort uid_t; 
    99alias ushort gid_t; 
     10alias int ssize_t; 
    1011 
    1112enum { 
     
    405406char* h_addr() 
    406407{ 
    407    return h_addr_list[0]; 
     408        return h_addr_list[0]; 
    408409} 
    409410} 
  • trunk/lib/compiler/gdc/config/unix-mid

    r991 r1856  
    22{ 
    33    int open(char*, int, ...); 
    4     int read(int, void*, size_t); 
    5     int write(int, void*, size_t); 
     4    ssize_t read(int, void*, size_t); 
     5    ssize_t write(int, void*, size_t); 
    66    int close(int); 
    77    off_t lseek(int, off_t, int); 
     
    1010    int fstat(int, struct_stat*); 
    1111    int stat(char*, struct_stat*); 
    12     int    lstat(char *, struct_stat *); 
    13     int    chmod(char *, mode_t); 
     12    int lstat(char *, struct_stat *); 
     13    int chmod(char *, mode_t); 
    1414    int chdir(char*); 
    15     int mkdir(char*, int); 
     15    int mkdir(char*, mode_t); 
    1616    int rmdir(char*); 
    17     char* getcwd(char*, int); 
     17    char* getcwd(char*, size_t); 
    1818 
    1919    pid_t fork(); 
     
    5050    int pthread_attr_init(pthread_attr_t *); 
    5151    int pthread_attr_destroy(pthread_attr_t *); 
     52    int pthread_attr_setdetachstate(pthread_attr_t *, int); 
     53    int pthread_attr_getdetachstate(pthread_attr_t *, int *); 
     54    int pthread_attr_setguardsize(pthread_attr_t*, size_t); 
     55    int pthread_attr_getguardsize(pthread_attr_t*, size_t *); 
     56    int pthread_attr_setinheritsched(pthread_attr_t *, int); 
     57    int pthread_attr_getinheritsched(pthread_attr_t *, int *); 
     58    int pthread_attr_setschedparam(pthread_attr_t *, sched_param *); 
     59    int pthread_attr_getschedparam(pthread_attr_t *, sched_param *); 
     60    int pthread_attr_setschedpolicy(pthread_attr_t *, int); 
     61    int pthread_attr_getschedpolicy(pthread_attr_t *, int*); 
     62    int pthread_attr_setscope(pthread_attr_t *, int); 
     63    int pthread_attr_getscope(pthread_attr_t *, int*); 
     64    int pthread_attr_setstack(pthread_attr_t *, void*, size_t); 
     65    int pthread_attr_getstack(pthread_attr_t *, void**, size_t *); 
     66    int pthread_attr_setstackaddr(pthread_attr_t *, void *); 
     67    int pthread_attr_getstackaddr(pthread_attr_t *, void **); 
    5268    int pthread_attr_setstacksize(pthread_attr_t *, size_t); 
    5369    int pthread_attr_getstacksize(pthread_attr_t *, size_t *); 
    54     int pthread_attr_setstackaddr(pthread_attr_t *, void *); 
    55     int pthread_attr_getstackaddr(pthread_attr_t *, void **); 
    5670 
    5771    int pthread_create(pthread_t*, pthread_attr_t*, void* (*)(void*), void*); 
     
    6680    int pthread_setcanceltype(int type, int *oldtype); 
    6781    void pthread_testcancel(); 
     82    int pthread_detach(pthread_t); 
     83    void pthread_exit(void*); 
     84    int pthread_getattr_np(pthread_t, pthread_attr_t*); 
     85    int pthread_getconcurrency(); 
     86    int pthread_getcpuclockid(pthread_t, clockid_t*); 
    6887 
    6988    int pthread_cond_init(pthread_cond_t *, pthread_condattr_t *); 
     
    88107    int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); 
    89108 
     109    int pthread_barrierattr_init(pthread_barrierattr_t*); 
     110    int pthread_barrierattr_getpshared(pthread_barrierattr_t*, int*); 
     111    int pthread_barrierattr_destroy(pthread_barrierattr_t*); 
     112    int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int); 
     113 
     114    int pthread_barrier_init(pthread_barrier_t*, pthread_barrierattr_t*, uint); 
     115    int pthread_barrier_destroy(pthread_barrier_t*); 
     116    int pthread_barrier_wait(pthread_barrier_t*); 
     117 
    90118    // version ( Unix_Sched ) 
    91119    void sched_yield(); 
     
    100128    int mlockall(int); 
    101129    int munlockall(); 
    102     void* mremap(void*, size_t, size_t, Culong_t); 
     130    void* mremap(void*, size_t, size_t, Culong_t); // Linux specific 
    103131    int mincore(void*, size_t, ubyte*); 
    104     int remap_file_pages(void*, size_t, int, size_t, int); 
     132    int remap_file_pages(void*, size_t, int, ssize_t, int); // Linux specific 
    105133    int shm_open(char*, int, mode_t); 
    106134    int shm_unlink(char*); 
     
    113141    // could probably rewrite fd_set stuff in D, but for now... 
    114142    struct fd_set { 
    115    ubyte opaque[__FD_SET_SIZEOF]; 
     143        ubyte opaque[__FD_SET_SIZEOF]; 
    116144    } 
    117145    private void _d_gnu_fd_set(int n, fd_set * p); 
     
    123151    version (none) 
    124152    { 
    125    void FD_SET(int n, inout fd_set p) { return _d_gnu_fd_set(n, & p); } 
    126    void FD_CLR(int n, inout fd_set p) { return _d_gnu_fd_clr(n, & p); } 
    127    int FD_ISSET(int n, inout fd_set p) { return _d_gnu_fd_isset(n, & p); } 
    128    void FD_COPY(inout fd_set f, inout fd_set t) { return _d_gnu_fd_copy(& f, & t); } 
    129    void FD_ZERO(inout fd_set p) { return _d_gnu_fd_zero(& p); } 
     153        void FD_SET(int n, inout fd_set p) { return _d_gnu_fd_set(n, & p); } 
     154        void FD_CLR(int n, inout fd_set p) { return _d_gnu_fd_clr(n, & p); } 
     155        int FD_ISSET(int n, inout fd_set p) { return _d_gnu_fd_isset(n, & p); } 
     156        void FD_COPY(inout fd_set f, inout fd_set t) { return _d_gnu_fd_copy(& f, & t); } 
     157        void FD_ZERO(inout fd_set p) { return _d_gnu_fd_zero(& p); } 
    130158    } 
    131159    void FD_SET(int n,  fd_set * p) { return _d_gnu_fd_set(n, p); } 
     
    147175    struct in_addr 
    148176    { 
    149    uint s_addr; 
     177        uint s_addr; 
    150178    } 
    151179 
    152180    struct sockaddr 
    153181    { 
    154    version(GNU_BsdSockets_salen) { 
    155        ubyte  sa_len; 
    156        ubyte  sa_family; 
    157    } else { 
    158        ushort sa_family; 
    159    
    160    char[14] sa_data = [0]
     182        version(GNU_BsdSockets_salen) { 
     183            ubyte  sa_len; 
     184            ubyte  sa_family; 
     185        } else { 
     186            ushort sa_family; 
     187       
     188        ubyte[14] sa_data
    161189    } 
    162190 
    163191    struct sockaddr_in 
    164192    { 
    165    version( BsdSockets_salen ) { 
    166        ubyte sin_len = sockaddr_in.sizeof; 
    167        ubyte sin_family = AF_INET; 
    168    } else { 
    169        ushort sin_family = AF_INET; 
    170    
    171    ushort sin_port; 
    172    in_addr sin_addr; 
    173    char[8] sin_zero = [0]
     193        version( BsdSockets_salen ) { 
     194            ubyte sin_len = sockaddr_in.sizeof; 
     195            ubyte sin_family = AF_INET; 
     196        } else { 
     197            ushort sin_family = AF_INET; 
     198       
     199        ushort sin_port; 
     200        in_addr sin_addr; 
     201        ubyte[8] sin_zero
    174202    } 
    175203 
     
    177205    enum: int 
    178206    { 
    179    SD_RECEIVE =  0, 
    180    SD_SEND =     1, 
    181    SD_BOTH =     2, 
     207        SD_RECEIVE =  0, 
     208        SD_SEND =     1, 
     209        SD_BOTH =     2, 
    182210    } 
    183211 
     
    190218    int getpeername(int s, sockaddr* name, int* namelen); 
    191219    int getsockname(int s, sockaddr* name, int* namelen); 
    192     int send(int s, void* buf, int len, int flags); 
    193     int sendto(int s, void* buf, int len, int flags, sockaddr* to, int tolen); 
    194     int recv(int s, void* buf, int len, int flags); 
    195     int recvfrom(int s, void* buf, int len, int flags, sockaddr* from, int* fromlen); 
     220    ssize_t send(int s, void* buf, size_t len, int flags); 
     221    ssize_t sendto(int s, void* buf, size_t len, int flags, sockaddr* to, int tolen); 
     222    ssize_t recv(int s, void* buf, size_t len, int flags); 
     223    ssize_t recvfrom(int s, void* buf, size_t len, int flags, sockaddr* from, int* fromlen); 
    196224    int getsockopt(int s, int level, int optname, void* optval, int* optlen); 
    197225    int setsockopt(int s, int level, int optname, void* optval, int optlen); 
     
    199227    char* inet_ntoa(in_addr ina); 
    200228    hostent* gethostbyname(char* name); 
     229    int gethostbyname_r(char* name, hostent* ret, void* buf, size_t buflen, hostent** result, int* h_errnop); 
     230    int gethostbyname2_r(char* name, int af, hostent* ret, void* buf, size_t buflen, hostent** result, int* h_errnop); 
    201231    hostent* gethostbyaddr(void* addr, int len, int type); 
    202232    protoent* getprotobyname(char* name); 
     
    213243    version(BigEndian) 
    214244    { 
    215        uint16_t htons(uint16_t x) 
    216        { 
    217            return x; 
    218        } 
    219  
    220  
    221        uint32_t htonl(uint32_t x) 
    222        { 
    223            return x; 
    224        } 
     245            uint16_t htons(uint16_t x) 
     246            { 
     247                    return x; 
     248            } 
     249 
     250 
     251            uint32_t htonl(uint32_t x) 
     252            { 
     253                    return x; 
     254            } 
    225255    } 
    226256    else version(LittleEndian) 
    227257    { 
    228        private import std.intrinsic; 
    229  
    230  
    231        uint16_t htons(uint16_t x) 
    232        { 
    233            return (x >> 8) | (x << 8); 
    234        } 
    235  
    236  
    237        uint32_t htonl(uint32_t x) 
    238        { 
    239            return bswap(x); 
    240        } 
     258            private import std.intrinsic; 
     259 
     260 
     261            uint16_t htons(uint16_t x) 
     262            { 
     263                    return (x >> 8) | (x << 8); 
     264            } 
     265 
     266 
     267            uint32_t htonl(uint32_t x) 
     268            { 
     269                    return bswap(x); 
     270            } 
    241271    } 
    242272    else 
    243273    { 
    244        static assert(0); 
     274            static assert(0); 
    245275    } 
    246276 
    247277    alias htons ntohs; 
    248278    alias htonl ntohl; 
     279 
     280    // from <time.h> 
     281    char* asctime_r(tm* t, char* buf); 
     282    char* ctime_r(time_t* timep, char* buf); 
     283    tm* gmtime_r(time_t* timep, tm* result); 
     284    tm* localtime_r(time_t* timep, tm* result); 
     285 
     286    // misc. 
     287    uint alarm(uint); 
     288    char* basename(char*); 
     289    //wint_t btowc(int); 
     290    int chown(char*, uid_t, gid_t); 
     291    int chroot(char*); 
     292    size_t confstr(int, char*, size_t); 
     293    int creat(char*, mode_t); 
     294    char* ctermid(char*); 
     295    int dirfd(DIR*); 
     296    char* dirname(char*); 
     297    int fattach(int, char*); 
     298    int fchmod(int, mode_t); 
     299    int fdatasync(int); 
     300    int ffs(int); 
     301    int fmtmsg(int, char*, int, char*, char*, char*); 
     302    int fpathconf(int, int); 
     303    int fseeko(FILE*, off_t, int); 
     304    off_t ftello(FILE*); 
     305 
     306    extern char** environ; 
     307 
    249308} 
  • trunk/lib/compiler/gdc/fpmath.d

    r1173 r1856  
    1919struct Info { 
    2020    static if (real.sizeof == double.sizeof) { 
    21    static const RealFormat realFormat = RealFormat.SameAsDouble; 
     21        static const RealFormat realFormat = RealFormat.SameAsDouble; 
    2222    } else version (PPC) { 
    23     static const RealFormat realFormat = RealFormat.DoubleDouble; 
    24     union real_rec { 
    25         real f; 
    26         struct { double hd, ld; } 
    27     } 
     23        static const RealFormat realFormat = RealFormat.DoubleDouble; 
     24        union real_rec { 
     25            real f; 
     26            struct { double hd, ld; } 
     27        } 
     28    } else version (PPC64) { 
     29        static const RealFormat realFormat = RealFormat.DoubleDouble; 
     30        union real_rec { 
     31            real f; 
     32            struct { double hd, ld; } 
     33        } 
    2834    } else version (X86) { 
    29    static const RealFormat realFormat = RealFormat.Intel80; 
    30    union real_rec { 
    31        real f; 
    32        struct { uint li, mi, hi; } 
    33    
     35        static const RealFormat realFormat = RealFormat.Intel80; 
     36        union real_rec { 
     37            real f; 
     38            struct { uint li, mi, hi; } 
     39       
    3440    } else version (X86_64) { 
    35    static const RealFormat realFormat = RealFormat.Intel80; 
    36    union real_rec { 
    37        real f; 
    38        struct { uint li, mi, hi; } 
    39    
     41        static const RealFormat realFormat = RealFormat.Intel80; 
     42        union real_rec { 
     43            real f; 
     44            struct { uint li, mi, hi; } 
     45       
    4046    } else { 
    41    static assert(0); 
     47        static assert(0); 
    4248    } 
    4349} 
     
    6268 
    6369    if (! i) 
    64    return FP_ZERO; 
     70        return FP_ZERO; 
    6571    else if (i < 0x00800000) 
    66    return FP_SUBNORMAL; 
     72        return FP_SUBNORMAL; 
    6773    else if (i < 0x7f800000) 
    68    return FP_NORMAL; 
     74        return FP_NORMAL; 
    6975    else if (i < 0x7f800001) 
    70    return FP_INFINITE; 
     76        return FP_INFINITE; 
    7177    else 
    72    return FP_NAN; 
     78        return FP_NAN; 
    7379} 
    7480 
     
    7682    double f; 
    7783    struct { 
    78    version (BigEndian) 
    79        uint  hi, li; 
    80    else 
    81        uint  li, hi; 
     84        version (BigEndian) 
     85            uint  hi, li; 
     86        else 
     87            uint  li, hi; 
    8288    } 
    8389} 
     
    97103 
    98104    if (! (i | r.li)) 
    99    return FP_ZERO; 
     105        return FP_ZERO; 
    100106    else if (i <  0x00100000) 
    101    return FP_SUBNORMAL; 
     107        return FP_SUBNORMAL; 
    102108    else if (i <  0x7ff00000) 
    103    return FP_NORMAL; 
     109        return FP_NORMAL; 
    104110    else if (i == 0x7ff00000 && ! r.li) 
    105    return FP_INFINITE; 
     111        return FP_INFINITE; 
    106112    else 
    107    return FP_NAN; 
     113        return FP_NAN; 
    108114} 
    109115 
     
    111117{ 
    112118    static if (Info.realFormat == RealFormat.SameAsDouble) { 
    113    return signbit(cast(double) f); 
     119        return signbit(cast(double) f); 
    114120    } else static if (Info.realFormat == RealFormat.DoubleDouble) { 
    115    Info.real_rec r = void; 
    116    r.f = f; 
    117    return signbit(r.hd); 
     121        Info.real_rec r = void; 
     122        r.f = f; 
     123        return signbit(r.hd); 
    118124    } else static if (Info.realFormat == RealFormat.Intel80) { 
    119    Info.real_rec r = void; 
    120    r.f = f; 
    121    return r.hi & 0x00008000; 
     125        Info.real_rec r = void; 
     126        r.f = f; 
     127        return r.hi & 0x00008000; 
    122128    } 
    123129} 
     
    126132{ 
    127133    static if (Info.realFormat == RealFormat.SameAsDouble) { 
    128    return fpclassify(cast(double) f); 
     134        return fpclassify(cast(double) f); 
    129135    } else static if (Info.realFormat == RealFormat.DoubleDouble) { 
    130    Info.real_rec r = void; 
    131    r.f = f; 
    132    return fpclassify(r.hd); 
     136        Info.real_rec r = void; 
     137        r.f = f; 
     138        return fpclassify(r.hd); 
    133139    } else static if (Info.realFormat == RealFormat.Intel80) { 
    134    Info.real_rec r = void; 
    135    r.f = f; 
    136    uint i = r.hi & 0x00007fff; 
    137    uint li = r.li | (r.mi & 0x7fffffff) ; 
    138    if (! i && ! li) 
    139        return FP_ZERO; 
    140    else if (i <  0x00000001 && (r.mi & 0x80000000) == 0) 
    141        return FP_SUBNORMAL; 
    142    else if (i <  0x00007fff) 
    143        return FP_NORMAL; 
    144    else if (i == 0x00007fff && ! li) 
    145        return FP_INFINITE; 
    146    else 
    147        return FP_NAN; 
     140        Info.real_rec r = void; 
     141        r.f = f; 
     142        uint i = r.hi & 0x00007fff; 
     143        uint li = r.li | (r.mi & 0x7fffffff) ; 
     144        if (! i && ! li) 
     145            return FP_ZERO; 
     146        else if (i <  0x00000001 && (r.mi & 0x80000000) == 0) 
     147            return FP_SUBNORMAL; 
     148        else if (i <  0x00007fff) 
     149            return FP_NORMAL; 
     150        else if (i == 0x00007fff && ! li) 
     151            return FP_INFINITE; 
     152        else 
     153            return FP_NAN; 
    148154    } 
    149155} 
     
    152158{ 
    153159    static if (Info.realFormat == RealFormat.SameAsDouble) { 
    154    const real xrsn = 0x1p-1050; 
     160        const real xrsn = 0x1p-1050; 
    155161    } else static if (Info.realFormat == RealFormat.DoubleDouble) { 
    156    const real xrsn = 0x1p-1050; 
     162        const real xrsn = 0x1p-1050; 
    157163    } else static if (Info.realFormat == RealFormat.Intel80) { 
    158    const real xrsn = 0x1p-16390; 
     164        const real xrsn = 0x1p-16390; 
    159165    } 
    160166 
    161167    static float[]  xfi = [ float.nan, -float.nan, float.infinity, -float.infinity, 
    162    0.0f, -0.0f, 0x1p-135f, -0x1p-135f, 4.2f, -4.2f ]; 
     168        0.0f, -0.0f, 0x1p-135f, -0x1p-135f, 4.2f, -4.2f ]; 
    163169    static double[] xdi = [ double.nan, -double.nan, double.infinity, -double.infinity, 
    164    0.0, -0.0, 0x1p-1050, -0x1p-1050, 4.2, -4.2 ]; 
     170        0.0, -0.0, 0x1p-1050, -0x1p-1050, 4.2, -4.2 ]; 
    165171    static real[]   xri = [ real.nan, -real.nan, real.infinity, -real.infinity, 
    166    0.0L, -0.0L, xrsn, -xrsn, 4.2L, -4.2L ]; 
     172        0.0L, -0.0L, xrsn, -xrsn, 4.2L, -4.2L ]; 
    167173    static int[]     xo = [ FP_NAN, FP_NAN, FP_INFINITE, FP_INFINITE, 
    168    FP_ZERO, FP_ZERO, FP_SUBNORMAL, FP_SUBNORMAL, FP_NORMAL, FP_NORMAL]; 
     174        FP_ZERO, FP_ZERO, FP_SUBNORMAL, FP_SUBNORMAL, FP_NORMAL, FP_NORMAL]; 
    169175 
    170176    foreach (int i, int cls; xo) { 
    171    assert( fpclassify(xfi[i]) == xo[i] ); 
    172    assert( fpclassify(xdi[i]) == xo[i] ); 
    173    assert( fpclassify(xri[i]) == xo[i] ); 
    174    assert( ( signbit(xfi[i]) ?1:0 ) == (i & 1) ); 
    175    assert( ( signbit(xdi[i]) ?1:0 ) == (i & 1) ); 
    176    assert( ( signbit(xri[i]) ?1:0 ) == (i & 1) ); 
     177        assert( fpclassify(xfi[i]) == xo[i] ); 
     178        assert( fpclassify(xdi[i]) == xo[i] ); 
     179        assert( fpclassify(xri[i]) == xo[i] ); 
     180        assert( ( signbit(xfi[i]) ?1:0 ) == (i & 1) ); 
     181        assert( ( signbit(xdi[i]) ?1:0 ) == (i & 1) ); 
     182        assert( ( signbit(xri[i]) ?1:0 ) == (i & 1) ); 
    177183    } 
    178184} 
  • trunk/lib/compiler/gdc/gcc/builtins.d

    r454 r1856  
    11/* GDC -- D front-end for GCC 
    22   Copyright (C) 2004 David Friedman 
    3     
     3 
    44   This program is free software; you can redistribute it and/or modify 
    55   it under the terms of the GNU General Public License as published by 
    66   the Free Software Foundation; either version 2 of the License, or 
    77   (at your option) any later version. 
    8   
     8 
    99   This program is distributed in the hope that it will be useful, 
    1010   but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1111   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1212   GNU General Public License for more details. 
    13   
     13 
    1414   You should have received a copy of the GNU General Public License 
    1515   along with this program; if not, write to the Free Software 
     
    1717*/ 
    1818 
    19 module gcc.builtins; 
    2019 
    21 /* 
     20/** 
    2221  Declarations are automatically created by the compiler.  All 
    23   declarations start with "__builtin_". Refer to builtins.def in the 
     22  declarations start with "__builtin_". Refer to _builtins.def in the 
    2423  GCC source for a list of functions.  Not all of the functions are 
    2524  supported. 
    2625 
    27   In addition to built in functions, the type __builtin_va_list is 
    28   defined. 
     26  In addition to built-in functions, the following types are defined. 
     27 
     28  $(TABLE 
     29  $(TR $(TD ___builtin_va_list)      $(TD The target's va_list type )) 
     30  $(TR $(TD ___builtin_Clong  )      $(TD The D equivalent of the target's 
     31                                           C "long" type )) 
     32  $(TR $(TD ___builtin_Culong )      $(TD The D equivalent of the target's 
     33                                           C "unsigned long" type )) 
     34  $(TR $(TD ___builtin_machine_int ) $(TD Signed word-sized integer )) 
     35  $(TR $(TD ___builtin_machine_uint) $(TD Unsigned word-sized integer )) 
     36  $(TR $(TD ___builtin_pointer_int ) $(TD Signed pointer-sized integer )) 
     37  $(TR $(TD ___builtin_pointer_uint) $(TD Unsigned pointer-sized integer )) 
     38  ) 
    2939*/ 
     40 
     41module gcc.builtins; 
  • trunk/lib/compiler/gdc/gcc/unwind.d

    r465 r1856  
    3636// extra casts now 
    3737 
    38 alias __builtin_abi_uint _Unwind_Word; 
    39 alias __builtin_abi_int  _Unwind_Sword; 
    40  
    41 //typedef void * _Unwind_Internal_Ptr; // this should be an unsigned of pointer size... 
    42  
    43 // D Note: rearranged because we don't have __attribute__((mode())) 
    44  
    45 version (GNU_BitsPerPointer32) { 
    46     alias uint _Unwind_Internal_Ptr; 
    47 
    48 version (GNU_BitsPerPointer64) { 
    49     alias ulong _Unwind_Internal_Ptr; 
    50 
     38alias __builtin_machine_uint _Unwind_Word; 
     39alias __builtin_machine_int  _Unwind_Sword; 
     40alias __builtin_pointer_uint _Unwind_Internal_Ptr; 
    5141 
    5242version (IA64) { 
    5343    version (HPUX) { 
    54    alias _Unwind_Word _Unwind_Ptr; 
     44        alias __builtin_machine_uint _Unwind_Ptr; 
    5545    } else { 
    56    alias _Unwind_Internal_Ptr _Unwind_Ptr; 
     46        alias __builtin_pointer_uint _Unwind_Ptr; 
    5747    } 
    5848} else { 
    59     alias _Unwind_Internal_Ptr _Unwind_Ptr; 
     49    alias __builtin_pointer_uint _Unwind_Ptr; 
    6050} 
    6151 
     
    9181 
    9282extern(C) typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code, 
    93                          _Unwind_Exception *); 
     83                                              _Unwind_Exception *); 
    9484 
    9585align struct _Unwind_Exception // D Note: this may not be "maxium alignment required by any type"? 
     
    112102enum 
    113103{ 
    114     _UA_SEARCH_PHASE  =    1, 
    115     _UA_CLEANUP_PHASE =    2, 
    116     _UA_HANDLER_FRAME =    4, 
    117     _UA_FORCE_UNWIND  =    8, 
    118     _UA_END_OF_STACK  =    16 
     104    _UA_SEARCH_PHASE  = 1, 
     105    _UA_CLEANUP_PHASE = 2, 
     106    _UA_HANDLER_FRAME = 4, 
     107    _UA_FORCE_UNWIND  = 8, 
     108    _UA_END_OF_STACK  = 16 
    119109} 
    120110 
     
    135125 
    136126_Unwind_Reason_Code _Unwind_ForcedUnwind (_Unwind_Exception *, 
    137                         _Unwind_Stop_Fn, 
    138                         void *); 
     127                                                _Unwind_Stop_Fn, 
     128                                                void *); 
    139129 
    140130/* Helper to invoke the exception_cleanup routine.  */ 
     
    281271    { 
    282272      if (encoding == DW_EH_PE_omit) 
    283    return 0; 
     273        return 0; 
    284274 
    285275      switch (encoding & 0x07) 
    286    
    287    case DW_EH_PE_absptr: 
    288      return (void *).sizeof; 
    289    case DW_EH_PE_udata2: 
    290      return 2; 
    291    case DW_EH_PE_udata4: 
    292      return 4; 
    293    case DW_EH_PE_udata8: 
    294      return 8; 
    295    
     276       
     277        case DW_EH_PE_absptr: 
     278          return (void *).sizeof; 
     279        case DW_EH_PE_udata2: 
     280          return 2; 
     281        case DW_EH_PE_udata4: 
     282          return 4; 
     283        case DW_EH_PE_udata8: 
     284          return 8; 
     285       
    296286      abort (); 
    297287    } 
     
    309299    { 
    310300      if (encoding == DW_EH_PE_omit) 
    311    return cast(_Unwind_Ptr) 0; 
     301        return cast(_Unwind_Ptr) 0; 
    312302 
    313303      switch (encoding & 0x70) 
    314    
    315    case DW_EH_PE_absptr: 
    316    case DW_EH_PE_pcrel: 
    317    case DW_EH_PE_aligned: 
    318      return cast(_Unwind_Ptr) 0; 
    319  
    320    case DW_EH_PE_textrel: 
    321      return _Unwind_GetTextRelBase (context); 
    322    case DW_EH_PE_datarel: 
    323      return _Unwind_GetDataRelBase (context); 
    324    case DW_EH_PE_funcrel: 
    325      return _Unwind_GetRegionStart (context); 
    326    
     304       
     305        case DW_EH_PE_absptr: 
     306        case DW_EH_PE_pcrel: 
     307        case DW_EH_PE_aligned: 
     308          return cast(_Unwind_Ptr) 0; 
     309 
     310        case DW_EH_PE_textrel: 
     311          return _Unwind_GetTextRelBase (context); 
     312        case DW_EH_PE_datarel: 
     313          return _Unwind_GetDataRelBase (context); 
     314        case DW_EH_PE_funcrel: 
     315          return _Unwind_GetRegionStart (context); 
     316       
    327317      abort (); 
    328318    } 
     
    387377ubyte * 
    388378read_encoded_value_with_base (ubyte encoding, _Unwind_Ptr base, 
    389                  ubyte *p, _Unwind_Ptr *val) 
     379                              ubyte *p, _Unwind_Ptr *val) 
    390380{ 
    391381    // D Notes: Todo -- packed! 
     
    414404    { 
    415405      switch (encoding & 0x0f) 
    416    
    417    case DW_EH_PE_absptr: 
    418      result = cast(_Unwind_Internal_Ptr) u.ptr; 
    419      p += (void *).sizeof; 
    420      break; 
    421  
    422    case DW_EH_PE_uleb128: 
    423      { 
    424        _Unwind_Word tmp; 
    425        p = read_uleb128 (p, &tmp); 
    426        result = cast(_Unwind_Internal_Ptr) tmp; 
    427      } 
    428      break; 
    429  
    430    case DW_EH_PE_sleb128: 
    431      { 
    432        _Unwind_Sword tmp; 
    433        p = read_sleb128 (p, &tmp); 
    434        result = cast(_Unwind_Internal_Ptr) tmp; 
    435      } 
    436      break; 
    437  
    438    case DW_EH_PE_udata2: 
    439      result = cast(_Unwind_Internal_Ptr) u.u2; 
    440      p += 2; 
    441      break; 
    442    case DW_EH_PE_udata4: 
    443      result = cast(_Unwind_Internal_Ptr) u.u4; 
    444      p += 4; 
    445      break; 
    446    case DW_EH_PE_udata8: 
    447      result = cast(_Unwind_Internal_Ptr) u.u8; 
    448      p += 8; 
    449      break; 
    450  
    451    case DW_EH_PE_sdata2: 
    452      result = cast(_Unwind_Internal_Ptr) u.s2; 
    453      p += 2; 
    454      break; 
    455    case DW_EH_PE_sdata4: 
    456      result = cast(_Unwind_Internal_Ptr) u.s4; 
    457      p += 4; 
    458      break; 
    459    case DW_EH_PE_sdata8: 
    460      result = cast(_Unwind_Internal_Ptr) u.s8; 
    461      p += 8; 
    462      break; 
    463  
    464    default: 
    465      abort (); 
    466    
     406       
     407        case DW_EH_PE_absptr: 
     408          result = cast(_Unwind_Internal_Ptr) u.ptr; 
     409          p += (void *).sizeof; 
     410          break; 
     411 
     412        case DW_EH_PE_uleb128: 
     413          { 
     414            _Unwind_Word tmp; 
     415            p = read_uleb128 (p, &tmp); 
     416            result = cast(_Unwind_Internal_Ptr) tmp; 
     417          } 
     418          break; 
     419 
     420        case DW_EH_PE_sleb128: 
     421          { 
     422            _Unwind_Sword tmp; 
     423            p = read_sleb128 (p, &tmp); 
     424            result = cast(_Unwind_Internal_Ptr) tmp; 
     425          } 
     426          break; 
     427 
     428        case DW_EH_PE_udata2: 
     429          result = cast(_Unwind_Internal_Ptr) u.u2; 
     430          p += 2; 
     431          break; 
     432        case DW_EH_PE_udata4: 
     433          result = cast(_Unwind_Internal_Ptr) u.u4; 
     434          p += 4; 
     435          break; 
     436        case DW_EH_PE_udata8: 
     437          result = cast(_Unwind_Internal_Ptr) u.u8; 
     438          p += 8; 
     439          break; 
     440 
     441        case DW_EH_PE_sdata2: 
     442          result = cast(_Unwind_Internal_Ptr) u.s2; 
     443          p += 2; 
     444          break; 
     445        case DW_EH_PE_sdata4: 
     446          result = cast(_Unwind_Internal_Ptr) u.s4; 
     447          p += 4; 
     448          break; 
     449        case DW_EH_PE_sdata8: 
     450          result = cast(_Unwind_Internal_Ptr) u.s8; 
     451          p += 8; 
     452          break; 
     453 
     454        default: 
     455          abort (); 
     456       
    467457 
    468458      if (result != 0) 
    469    
    470      result += ((encoding & 0x70) == DW_EH_PE_pcrel 
    471             ? cast(_Unwind_Internal_Ptr) u : base); 
    472      if (encoding & DW_EH_PE_indirect) 
    473        result = *cast(_Unwind_Internal_Ptr *) result; 
    474    
     459       
     460          result += ((encoding & 0x70) == DW_EH_PE_pcrel 
     461                     ? cast(_Unwind_Internal_Ptr) u : base); 
     462          if (encoding & DW_EH_PE_indirect) 
     463            result = *cast(_Unwind_Internal_Ptr *) result; 
     464       
    475465    } 
    476466 
     
    486476    ubyte * 
    487477    read_encoded_value (_Unwind_Context *context, ubyte encoding, 
    488            ubyte *p, _Unwind_Ptr *val) 
     478                        ubyte *p, _Unwind_Ptr *val) 
    489479    { 
    490480      return read_encoded_value_with_base (encoding, 
    491            base_of_encoded_value (encoding, context), 
    492            p, val); 
    493     } 
    494 } 
    495  
     481                    base_of_encoded_value (encoding, context), 
     482                    p, val); 
     483    } 
     484} 
     485 
  • trunk/lib/compiler/gdc/genobj.d

    r1748 r1856  
    5151//       in this particular file (and this file only).  It must 
    5252//       be a DMD thing. 
    53 //alias typeof(int.sizeof)                    size_t; 
    54 //alias typeof(cast(void*)0 - cast(void*)0)   ptrdiff_t; 
    55  
     53alias typeof(int.sizeof)                    size_t; 
     54alias typeof(cast(void*)0 - cast(void*)0)   ptrdiff_t; 
     55/+ 
    5656version( X86_64 ) 
    5757{ 
     
    6464    alias int   ptrdiff_t; 
    6565} 
    66  
     66+/ 
    6767alias size_t hash_t; 
    6868 
     
    122122    int opEquals(Object o) 
    123123    { 
    124    return cast(int)(this is o); 
     124    return cast(int)(this is o); 
    125125    } 
    126126 
     
    227227    ClassInfo classinfo;        /// .classinfo for this interface (not for containing class) 
    228228    void *[] vtbl; 
    229     int offset;                 /// offset to Interface 'this' from Object 'this' 
     229    ptrdiff_t offset;       /// offset to Interface 'this' from Object 'this' 
    230230} 
    231231 
     
    304304 
    305305    /// Returns a hash of the instance of a type. 
    306     hash_t getHash(void *p) { return cast(uint)p; } 
     306    hash_t getHash(void *p) { return cast(hash_t)p; } 
    307307 
    308308    /// Compares two instances for equality. 
     
    389389    hash_t getHash(void *p) 
    390390    { 
    391         return cast(uint)*cast(void* *)p; 
     391        return cast(hash_t)*cast(void**)p; 
    392392    } 
    393393 
     
    427427    {   TypeInfo_Array c; 
    428428 
    429    return cast(int) 
    430           (this is o || 
     429    return cast(int) 
     430           (this is o || 
    431431                ((c = cast(TypeInfo_Array)o) !is null && 
    432         this.value == c.value)); 
     432        this.value == c.value)); 
    433433    } 
    434434 
     
    508508    {   TypeInfo_StaticArray c; 
    509509 
    510    return cast(int) 
    511           (this is o || 
     510    return cast(int) 
     511           (this is o || 
    512512                ((c = cast(TypeInfo_StaticArray)o) !is null && 
    513513                 this.len == c.len && 
    514         this.value == c.value)); 
     514        this.value == c.value)); 
    515515    } 
    516516 
  • trunk/lib/compiler/gdc/lifetime.d

    r1806 r1856  
    839839    } 
    840840 
    841     *cast(int *)&a = length; // jam length 
     841    *cast(size_t *)&a = length; // jam length 
    842842    //a.length = length; 
    843843    return a; 
  • trunk/lib/compiler/gdc/mars.h

    r925 r1856  
    1111 
    1212#include <stddef.h> 
     13#include <sys/types.h> 
    1314 
    1415#if __cplusplus 
     
    2930    struct ClassInfo *classinfo; 
    3031    struct Vtbl vtbl; 
    31     int offset; 
     32    ptrdiff_t offset; 
    3233} Interface; 
    3334 
  • trunk/lib/compiler/gdc/memory.d

    r1206 r1856  
    314314void initStaticDataPtrs() 
    315315{ 
     316    const int S = (void*).sizeof; 
     317 
    316318    // Can't assume the input addresses are word-aligned 
    317319    static void* adjust_up( void* p ) 
    318320    { 
    319         const int S = (void*).sizeof; 
    320         return p + ((S - (cast(uint)p & (S-1))) & (S-1)); // cast ok even if 64-bit 
     321        return p + ((S - (cast(size_t)p & (S-1))) & (S-1)); // cast ok even if 64-bit 
    321322    } 
    322323 
    323324    static void * adjust_down( void* p ) 
    324325    { 
    325         const int S = (void*).sizeof; 
    326         return p - (cast(uint) p & (S-1)); 
     326        return p - (cast(size_t) p & (S-1)); 
    327327    } 
    328328 
     
    385385                    { 
    386386                        // parse the entry in [s, p) 
    387                         version( GNU_BitsPerPointer32
     387                        static if( S == 4
    388388                        { 
    389389                            enum Ofs 
     
    395395                            } 
    396396                        } 
    397                         else version( GNU_BitsPerPointer64
     397                        else static if( S == 8
    398398                        { 
    399399                            enum Ofs 
  • trunk/lib/compiler/gdc/memory_dyld.c

    r1200 r1856  
    6969        end = (void*)( start + sec->size ); 
    7070 
    71         _d_gcc_gc_remove_range((void*) start); 
     71        _d_gcc_gc_remove_range(start); 
    7272    } 
    7373} 
  • trunk/lib/compiler/gdc/memset.d

    r454 r1856  
    3131{ 
    3232    // Functions from the C library. 
    33     void *memcpy(void *, void *, uint); 
     33    void *memcpy(void *, void *, size_t); 
    3434} 
    3535 
    3636extern (C): 
    3737 
    38 short *_memset16(short *p, short value, int count) 
     38short *_memset16(short *p, short value, size_t count) 
    3939{ 
    4040    short *pstart = p; 
     
    4242 
    4343    for (ptop = &p[count]; p < ptop; p++) 
    44    *p = value; 
     44        *p = value; 
    4545    return pstart; 
    4646} 
    4747 
    48 int *_memset32(int *p, int value, int count) 
     48int *_memset32(int *p, int value, size_t count) 
    4949{ 
    5050version (Asm86) 
     
    5252    asm 
    5353    { 
    54    mov EDI,p       
    55    mov EAX,value   
    56    mov ECX,count   
    57    mov EDX,EDI     
    58    rep         
    59    stosd           
    60    mov EAX,EDX     
     54        mov     EDI,p           
     55        mov     EAX,value       
     56        mov     ECX,count       
     57        mov     EDX,EDI         
     58        rep                     
     59        stosd                   
     60        mov     EAX,EDX         
    6161    } 
    6262} 
     
    6767 
    6868    for (ptop = &p[count]; p < ptop; p++) 
    69    *p = value; 
     69        *p = value; 
    7070    return pstart; 
    7171} 
    7272} 
    7373 
    74 long *_memset64(long *p, long value, int count) 
     74long *_memset64(long *p, long value, size_t count) 
    7575{ 
    7676    long *pstart = p; 
     
    7878 
    7979    for (ptop = &p[count]; p < ptop; p++) 
    80    *p = value; 
     80        *p = value; 
    8181    return pstart; 
    8282} 
    8383 
    84 cdouble *_memset128(cdouble *p, cdouble value, int count) 
     84cdouble *_memset128(cdouble *p, cdouble value, size_t count) 
    8585{ 
    8686    cdouble *pstart = p; 
     
    8888 
    8989    for (ptop = &p[count]; p < ptop; p++) 
    90    *p = value; 
     90        *p = value; 
    9191    return pstart; 
    9292} 
    9393 
    94 real *_memset80(real *p, real value, int count) 
     94real *_memset80(real *p, real value, size_t count) 
    9595{ 
    9696    real *pstart = p; 
     
    9898 
    9999    for (ptop = &p[count]; p < ptop; p++) 
    100    *p = value; 
     100        *p = value; 
    101101    return pstart; 
    102102} 
    103103 
    104 creal *_memset160(creal *p, creal value, int count) 
     104creal *_memset160(creal *p, creal value, size_t count) 
    105105{ 
    106106    creal *pstart = p; 
     
    108108 
    109109    for (ptop = &p[count]; p < ptop; p++) 
    110    *p = value; 
     110        *p = value; 
    111111    return pstart; 
    112112} 
    113113 
    114 void *_memsetn(void *p, void *value, int count, int sizelem) 
     114void *_memsetn(void *p, void *value, int count, size_t sizelem) 
    115115{   void *pstart = p; 
    116116    int i; 
     
    118118    for (i = 0; i < count; i++) 
    119119    { 
    120    memcpy(p, value, sizelem); 
    121    p = cast(void *)(cast(char *)p + sizelem); 
     120        memcpy(p, value, sizelem); 
     121        p = cast(void *)(cast(char *)p + sizelem); 
    122122    } 
    123123    return pstart; 
  • trunk/lib/compiler/gdc/qsort2.d

    r925 r1856  
    2121{ 
    2222    size_t length; 
    23     void *ptr; 
     23    voidptr; 
    2424} 
    2525 
  • trunk/lib/compiler/gdc/qsortg.d

    r1087 r1856  
    22struct Array 
    33{ 
    4     int length; 
    5     void * ptr; 
     4    size_t length; 
     5    void* ptr; 
    66} 
    77 
     
    1111 
    1212    struct StackEntry { 
    13    byte *l; 
    14    byte *r; 
     13        byte *l; 
     14        byte *r; 
    1515    } 
    1616 
     
    3030    while (1) 
    3131    { 
    32    if (rbound - lbound > qsort_limit) 
    33    
    34        ti.swap(lbound, 
    35        lbound + ( 
    36              ((rbound - lbound) >>> 1) - 
    37              (((rbound - lbound) >>> 1) % elem_size) 
    38              )); 
     32        if (rbound - lbound > qsort_limit) 
     33       
     34            ti.swap(lbound, 
     35                lbound + ( 
     36                          ((rbound - lbound) >>> 1) - 
     37                          (((rbound - lbound) >>> 1) % elem_size) 
     38                          )); 
    3939 
    40        li = lbound + elem_size; 
    41        ri = rbound - elem_size; 
     40            li = lbound + elem_size; 
     41            ri = rbound - elem_size; 
    4242 
    43        if (ti.compare(li, ri) > 0) 
    44        ti.swap(li, ri); 
    45        if (ti.compare(lbound, ri) > 0) 
    46        ti.swap(lbound, ri); 
    47        if (ti.compare(li, lbound) > 0) 
    48        ti.swap(li, lbound); 
     43            if (ti.compare(li, ri) > 0) 
     44                ti.swap(li, ri); 
     45            if (ti.compare(lbound, ri) > 0) 
     46                ti.swap(lbound, ri); 
     47            if (ti.compare(li, lbound) > 0) 
     48                ti.swap(li, lbound); 
    4949 
    50        while (1) 
    51        { 
    52        do 
    53            li += elem_size; 
    54        while (ti.compare(li, lbound) < 0); 
    55        do 
    56            ri -= elem_size; 
    57        while (ti.compare(ri, lbound) > 0); 
    58        if (li > ri) 
    59            break; 
    60        ti.swap(li, ri); 
    61        } 
    62        ti.swap(lbound, ri); 
    63        if (ri - lbound > rbound - li) 
    64        { 
    65        sp.l = lbound; 
    66        sp.r = ri; 
    67        lbound = li; 
    68        } 
    69        else 
    70        { 
    71        sp.l = li; 
    72        sp.r = rbound; 
    73        rbound = ri; 
    74        } 
    75        ++sp; 
    76    } else { 
    77        // Use insertion sort 
    78        for (ri = lbound, li = lbound + elem_size; 
    79         li < rbound; 
    80         ri = li, li += elem_size) 
    81        { 
    82        for ( ; ti.compare(ri, ri + elem_size) > 0; 
    83              ri -= elem_size) 
    84        
    85            ti.swap(ri, ri + elem_size); 
    86            if (ri == lbound) 
    87            break; 
    88        
    89        } 
    90        if (sp != stack.ptr) 
    91        { 
    92        --sp; 
    93        lbound = sp.l; 
    94        rbound = sp.r; 
    95        } 
    96        else 
    97        return a; 
    98    
     50            while (1) 
     51            { 
     52                do 
     53                    li += elem_size; 
     54                while (ti.compare(li, lbound) < 0); 
     55                do 
     56                    ri -= elem_size; 
     57                while (ti.compare(ri, lbound) > 0); 
     58                if (li > ri) 
     59                    break; 
     60                ti.swap(li, ri); 
     61            } 
     62            ti.swap(lbound, ri); 
     63            if (ri - lbound > rbound - li) 
     64            { 
     65                sp.l = lbound; 
     66                sp.r = ri; 
     67                lbound = li; 
     68            } 
     69            else 
     70            { 
     71                sp.l = li; 
     72                sp.r = rbound; 
     73                rbound = ri; 
     74            } 
     75            ++sp; 
     76        } else { 
     77            // Use insertion sort 
     78            for (ri = lbound, li = lbound + elem_size; 
     79                li < rbound; 
     80                ri = li, li += elem_size) 
     81            { 
     82                for ( ; ti.compare(ri, ri + elem_size) > 0; 
     83                      ri -= elem_size) 
     84               
     85                    ti.swap(ri, ri + elem_size); 
     86                    if (ri == lbound) 
     87                        break; 
     88               
     89            } 
     90            if (sp != stack.ptr) 
     91            { 
     92                --sp; 
     93                lbound = sp.l; 
     94                rbound = sp.r; 
     95            } 
     96            else 
     97                return a; 
     98       
    9999    } 
    100100} 
     
    103103{ 
    104104    static void check(int[] a) { 
    105    for (uint i = 1; i < a.length; i++) 
    106        assert(a[i-1] <= a[i]); 
     105        for (uint i = 1; i < a.length; i++) 
     106            assert(a[i-1] <= a[i]); 
    107107    } 
    108108 
  • trunk/lib/compiler/gdc/typeinfo/ti_AC.d

    r1617 r1856  
    4343        Object[] s1 = *cast(Object[]*)p1; 
    4444        Object[] s2 = *cast(Object[]*)p2; 
    45         int c; 
     45        ptrdiff_t c; 
    4646 
    47         c = cast(int)s1.length - cast(int)s2.length; 
     47        c = cast(ptrdiff_t)s1.length - cast(ptrdiff_t)s2.length; 
    4848        if (c == 0) 
    4949        { 
     
    7272            } 
    7373        } 
     74        if (c < 0) 
     75            c = -1; 
     76        else if (c > 0) 
     77            c = 1; 
    7478        return c; 
    7579    } 
  • trunk/lib/compiler/gdc/typeinfo/ti_Acdouble.d

    r1617 r1856  
    8383                return c; 
    8484        } 
    85         return cast(int)s1.length - cast(int)s2.length; 
     85        if (s1.length < s2.length) 
     86            return -1; 
     87        else if (s1.length > s2.length) 
     88            return 1; 
     89        return 0; 
    8690    } 
    8791 
  • trunk/lib/compiler/gdc/typeinfo/ti_Acfloat.d

    r1617 r1856  
    8181                return c; 
    8282        } 
    83         return cast(int)s1.length - cast(int)s2.length; 
     83        if (s1.length < s2.length) 
     84            return -1; 
     85        else if (s1.length > s2.length) 
     86            return 1; 
     87        return 0; 
    8488    } 
    8589 
  • trunk/lib/compiler/gdc/typeinfo/ti_Acreal.d

    r1617 r1856  
    8484                return c; 
    8585        } 
    86         return cast(int)s1.length - cast(int)s2.length; 
     86        if (s1.length < s2.length) 
     87            return -1; 
     88        else if (s1.length > s2.length) 
     89            return 1; 
     90        return 0; 
    8791    } 
    8892 
  • trunk/lib/compiler/gdc/typeinfo/ti_Adouble.d

    r1617 r1856  
    8181                return c; 
    8282        } 
    83         return cast(int)s1.length - cast(int)s2.length; 
     83        if (s1.length < s2.length) 
     84            return -1; 
     85        else if (s1.length > s2.length) 
     86            return 1; 
     87        return 0; 
    8488    } 
    8589 
  • trunk/lib/compiler/gdc/typeinfo/ti_Afloat.d

    r1617 r1856  
    8080                return c; 
    8181        } 
    82         return cast(int)s1.length - cast(int)s2.length; 
     82        if (s1.length < s2.length) 
     83            return -1; 
     84        else if (s1.length > s2.length) 
     85            return 1; 
     86        return 0; 
    8387    } 
    8488 
  • trunk/lib/compiler/gdc/typeinfo/ti_Ag.d

    r1617 r1856  
    1212 
    1313    hash_t getHash(void *p) 
    14     {  byte[] s = *cast(byte[]*)p; 
    15    size_t len = s.length; 
    16    byte *str = s.ptr; 
    17    hash_t hash = 0; 
    18  
    19    while (1) 
    20    
    21        switch (len) 
    22        { 
    23        case 0: 
    24            return hash; 
    25  
    26        case 1: 
    27            hash *= 9; 
    28            hash += *cast(ubyte *)str; 
    29            return hash; 
    30  
    31        case 2: 
    32            hash *= 9; 
    33            hash += *cast(ushort *)str; 
    34            return hash; 
    35  
    36        case 3: 
    37            hash *= 9; 
    38            hash += (*cast(ushort *)str << 8) + 
    39                (cast(ubyte *)str)[2]; 
    40            return hash; 
    41  
    42        default: 
    43            hash *= 9; 
    44            hash += *cast(uint *)str; 
    45            str += 4; 
    46            len -= 4; 
    47            break; 
    48        } 
    49    
    50  
    51    return hash; 
     14    {   byte[] s = *cast(byte[]*)p; 
     15        size_t len = s.length; 
     16        byte *str = s.ptr; 
     17        hash_t hash = 0; 
     18 
     19        while (1) 
     20       
     21            switch (len) 
     22            { 
     23                case 0: 
     24                    return hash; 
     25 
     26                case 1: 
     27                    hash *= 9; 
     28                    hash += *cast(ubyte *)str; 
     29                    return hash; 
     30 
     31                case 2: 
     32                    hash *= 9; 
     33                    hash += *cast(ushort *)str; 
     34                    return hash; 
     35 
     36                case 3: 
     37                    hash *= 9; 
     38                    hash += (*cast(ushort *)str << 8) + 
     39                            (cast(ubyte *)str)[2]; 
     40                    return hash; 
     41 
     42                default: 
     43                    hash *= 9; 
     44                    hash += *cast(uint *)str; 
     45                    str += 4; 
     46                    len -= 4; 
     47                    break; 
     48            } 
     49       
     50 
     51        return hash; 
    5252    } 
    5353 
    5454    int equals(void *p1, void *p2) 
    5555    { 
    56    byte[] s1 = *cast(byte[]*)p1; 
    57    byte[] s2 = *cast(byte[]*)p2; 
    58  
    59    return s1.length == s2.length && 
    60           memcmp(cast(byte *)s1, cast(byte *)s2, s1.length) == 0; 
     56        byte[] s1 = *cast(byte[]*)p1; 
     57        byte[] s2 = *cast(byte[]*)p2; 
     58 
     59        return s1.length == s2.length && 
     60               memcmp(cast(byte *)s1, cast(byte *)s2, s1.length) == 0; 
    6161    } 
    6262 
    6363    int compare(void *p1, void *p2) 
    6464    { 
    65     byte[] s1 = *cast(byte[]*)p1; 
    66     byte[] s2 = *cast(byte[]*)p2; 
    67     size_t len = s1.length; 
    68  
    69     if (s2.length < len) 
    70         len = s2.length; 
    71     for (size_t u = 0; u < len; u++) 
    72     { 
    73         int result = s1[u] - s2[u]; 
    74         if (result) 
    75         return result; 
    76     } 
    77     return cast(int)s1.length - cast(int)s2.length; 
     65        byte[] s1 = *cast(byte[]*)p1; 
     66        byte[] s2 = *cast(byte[]*)p2; 
     67        size_t len = s1.length; 
     68 
     69        if (s2.length < len) 
     70            len = s2.length; 
     71        for (size_t u = 0; u < len; u++) 
     72        { 
     73            int result = s1[u] - s2[u]; 
     74            if (result) 
     75                return result; 
     76        } 
     77        if (s1.length < s2.length) 
     78            return -1; 
     79        else if (s1.length > s2.length) 
     80            return 1; 
     81        return 0; 
    7882    } 
    7983 
    8084    size_t tsize() 
    8185    { 
    82    return (byte[]).sizeof; 
     86        return (byte[]).sizeof; 
    8387    } 
    8488 
    8589    uint flags() 
    8690    { 
    87    return 1; 
    88     } 
    89  
    90     TypeInfo next() 
    91     { 
    92    return typeid(byte); 
     91        return 1; 
     92    } 
     93 
     94    TypeInfo next() 
     95    { 
     96        return typeid(byte); 
    9397    } 
    9498} 
     
    103107    int compare(void *p1, void *p2) 
    104108    { 
    105    char[] s1 = *cast(char[]*)p1; 
    106    char[] s2 = *cast(char[]*)p2; 
    107  
    108    return stringCompare(s1, s2); 
    109     } 
    110  
    111     TypeInfo next() 
    112     { 
    113    return typeid(ubyte); 
     109        char[] s1 = *cast(char[]*)p1; 
     110        char[] s2 = *cast(char[]*)p2; 
     111 
     112        return stringCompare(s1, s2); 
     113    } 
     114 
     115    TypeInfo next() 
     116    { 
     117        return typeid(ubyte); 
    114118    } 
    115119} 
     
    123127    TypeInfo next() 
    124128    { 
    125    return typeid(void); 
     129        return typeid(void); 
    126130    } 
    127131} 
     
    135139    TypeInfo next() 
    136140    { 
    137    return typeid(bool); 
     141        return typeid(bool); 
    138142    } 
    139143} 
     
    146150 
    147151    hash_t getHash(void *p) 
    148     {  char[] s = *cast(char[]*)p; 
    149    hash_t hash = 0; 
     152    {   char[] s = *cast(char[]*)p; 
     153        hash_t hash = 0; 
    150154 
    151155version (all) 
    152156{ 
    153    foreach (char c; s) 
    154        hash = hash * 11 + c; 
     157        foreach (char c; s) 
     158            hash = hash * 11 + c; 
    155159} 
    156160else 
    157161{ 
    158    size_t len = s.length; 
    159    char *str = s; 
    160  
    161    while (1) 
    162    
    163        switch (len) 
    164        { 
    165        case 0: 
    166            return hash; 
    167  
    168        case 1: 
    169            hash *= 9; 
    170            hash += *cast(ubyte *)str; 
    171            return hash; 
    172  
    173        case 2: 
    174            hash *= 9; 
    175            hash += *cast(ushort *)str; 
    176            return hash; 
    177  
    178        case 3: 
    179            hash *= 9; 
    180            hash += (*cast(ushort *)str << 8) + 
    181                (cast(ubyte *)str)[2]; 
    182            return hash; 
    183  
    184        default: 
    185            hash *= 9; 
    186            hash += *cast(uint *)str; 
    187            str += 4; 
    188            len -= 4; 
    189            break; 
    190        } 
    191    
    192 } 
    193    return hash; 
    194     } 
    195  
    196     TypeInfo next() 
    197     { 
    198    return typeid(char); 
    199     } 
    200 } 
    201  
    202  
     162        size_t len = s.length; 
     163        char *str = s; 
     164 
     165        while (1) 
     166       
     167            switch (len) 
     168            { 
     169                case 0: 
     170                    return hash; 
     171 
     172                case 1: 
     173                    hash *= 9; 
     174                    hash += *cast(ubyte *)str; 
     175                    return hash; 
     176 
     177                case 2: 
     178                    hash *= 9; 
     179                    hash += *cast(ushort *)str; 
     180                    return hash; 
     181 
     182                case 3: 
     183                    hash *= 9; 
     184                    hash += (*cast(ushort *)str << 8) + 
     185                            (cast(ubyte *)str)[2]; 
     186                    return hash; 
     187 
     188                default: 
     189                    hash *= 9; 
     190                    hash += *cast(uint *)str; 
     191                    str += 4; 
     192                    len -= 4; 
     193                    break; 
     194            } 
     195       
     196} 
     197        return hash; 
     198    } 
     199 
     200    TypeInfo next() 
     201    { 
     202        return typeid(char); 
     203    } 
     204} 
     205 
     206 
  • trunk/lib/compiler/gdc/typeinfo/ti_Aint.d

    r1617 r1856  
    5050                return result; 
    5151        } 
    52         return cast(int)s1.length - cast(int)s2.length; 
     52        if (s1.length < s2.length) 
     53            return -1; 
     54        else if (s1.length > s2.length) 
     55            return 1; 
     56        return 0; 
    5357    } 
    5458 
     
    8993                return result; 
    9094        } 
    91         return cast(int)s1.length - cast(int)s2.length; 
     95        if (s1.length < s2.length) 
     96            return -1; 
     97        else if (s1.length > s2.length) 
     98            return 1; 
     99        return 0; 
    92100    } 
    93101 
  • trunk/lib/compiler/gdc/typeinfo/ti_Along.d

    r1617 r1856  
    5151                return 1; 
    5252        } 
    53         return cast(int)s1.length - cast(int)s2.length; 
     53        if (s1.length < s2.length) 
     54            return -1; 
     55        else if (s1.length > s2.length) 
     56            return 1; 
     57        return 0; 
    5458    } 
    5559 
     
    9296                return 1; 
    9397        } 
    94         return cast(int)s1.length - cast(int)s2.length; 
     98        if (s1.length < s2.length) 
     99            return -1; 
     100        else if (s1.length > s2.length) 
     101            return 1; 
     102        return 0; 
    95103    } 
    96104 
  • trunk/lib/compiler/gdc/typeinfo/ti_Areal.d

    r1617 r1856  
    8282                return c; 
    8383        } 
    84         return cast(int)s1.length - cast(int)s2.length; 
     84        if (s1.length < s2.length) 
     85            return -1; 
     86        else if (s1.length > s2.length) 
     87            return 1; 
     88        return 0; 
    8589    } 
    8690 
  • trunk/lib/compiler/gdc/typeinfo/ti_Ashort.d

    r1617 r1856  
    6363                return result; 
    6464        } 
    65         return cast(int)s1.length - cast(int)s2.length; 
     65        if (s1.length < s2.length) 
     66            return -1; 
     67        else if (s1.length > s2.length) 
     68            return 1; 
     69        return 0; 
    6670    } 
    6771 
     
    103107                return result; 
    104108        } 
    105         return cast(int)s1.length - cast(int)s2.length; 
     109        if (s1.length < s2.length) 
     110            return -1; 
     111        else if (s1.length > s2.length) 
     112            return 1; 
     113        return 0; 
    106114    } 
    107115 
  • trunk/lib/compiler/gdc/typeinfo/ti_ptr.d

    r1617 r1856  
    1818    int compare(void *p1, void *p2) 
    1919    { 
    20         return *cast(void* *)p1 - *cast(void* *)p2; 
     20        auto c = *cast(void* *)p1 - *cast(void* *)p2; 
     21        if (c < 0) 
     22            return -1; 
     23        else if (c > 0) 
     24            return 1; 
     25        return 0; 
    2126    } 
    2227 
  • trunk/lib/gc/basic/gcalloc.d

    r1748 r1856  
    7070     * Map memory. 
    7171     */ 
    72     void *os_mem_map(uint nbytes) 
     72    void *os_mem_map(size_t nbytes) 
    7373    { 
    7474        return VirtualAlloc(null, nbytes, MEM_RESERVE, PAGE_READWRITE); 
     
    8282     *      !=0     failure 
    8383     */ 
    84     int os_mem_commit(void *base, uint offset, uint nbytes) 
     84    int os_mem_commit(void *base, size_t offset, size_t nbytes) 
    8585    {   void *p; 
    8686 
     
    9696     *      !=0     failure 
    9797     */ 
    98     int os_mem_decommit(void *base, uint offset, uint nbytes) 
     98    int os_mem_decommit(void *base, size_t offset, size_t nbytes) 
    9999    { 
    100100    return cast(int)(VirtualFree(base + offset, nbytes, MEM_DECOMMIT) == 0); 
     
    109109     *      !=0     failure 
    110110     */ 
    111     int os_mem_unmap(void *base, uint nbytes) 
     111    int os_mem_unmap(void *base, size_t nbytes) 
    112112    { 
    113113        return cast(int)(VirtualFree(base, 0, MEM_RELEASE) == 0); 
     
    116116else static if (is(typeof(mmap)))  // else version (GC_Use_Alloc_MMap) 
    117117{ 
    118     void *os_mem_map(uint nbytes) 
     118    void *os_mem_map(size_t nbytes) 
    119119    {   void *p; 
    120120 
     
    124124 
    125125 
    126     int os_mem_commit(void *base, uint offset, uint nbytes) 
    127     { 
    128         return 0; 
    129     } 
    130  
    131  
    132     int os_mem_decommit(void *base, uint offset, uint nbytes) 
    133     { 
    134         return 0; 
    135     } 
    136  
    137  
    138     int os_mem_unmap(void *base, uint nbytes) 
     126    int os_mem_commit(void *base, size_t offset, size_t nbytes) 
     127    { 
     128        return 0; 
     129    } 
     130 
     131 
     132    int os_mem_decommit(void *base, size_t offset, size_t nbytes) 
     133    { 
     134        return 0; 
     135    } 
     136 
     137 
     138    int os_mem_unmap(void *base, size_t nbytes) 
    139139    { 
    140140        return munmap(base, nbytes); 
     
    143143else static if (is(typeof(valloc))) // else version (GC_Use_Alloc_Valloc) 
    144144{ 
    145     void *os_mem_map(uint nbytes) 
     145    void *os_mem_map(size_t nbytes) 
    146146    { 
    147147        return valloc(nbytes); 
     
    149149 
    150150 
    151     int os_mem_commit(void *base, uint offset, uint nbytes) 
    152     { 
    153         return 0; 
    154     } 
    155  
    156  
    157     int os_mem_decommit(void *base, uint offset, uint nbytes) 
    158     { 
    159         return 0; 
    160     } 
    161  
    162  
    163     int os_mem_unmap(void *base, uint nbytes) 
     151    int os_mem_commit(void *base, size_t offset, size_t nbytes) 
     152    { 
     153        return 0; 
     154    } 
     155 
     156 
     157    int os_mem_decommit(void *base, size_t offset, size_t nbytes) 
     158    { 
     159        return 0; 
     160    } 
     161 
     162 
     163    int os_mem_unmap(void *base, size_t nbytes) 
    164164    { 
    165165        free(base); 
     
    178178 
    179179 
    180     const uint PAGE_MASK = PAGESIZE - 1; 
    181  
    182  
    183     void *os_mem_map(uint nbytes) 
     180    const size_t PAGE_MASK = PAGESIZE - 1; 
     181 
     182 
     183    void *os_mem_map(size_t nbytes) 
    184184    {   byte *p, q; 
    185185        p = cast(byte *) malloc(nbytes + PAGESIZE); 
     
    190190 
    191191 
    192     int os_mem_commit(void *base, uint offset, uint nbytes) 
    193     { 
    194         return 0; 
    195     } 
    196  
    197  
    198     int os_mem_decommit(void *base, uint offset, uint nbytes) 
    199     { 
    200         return 0; 
    201     } 
    202  
    203  
    204     int os_mem_unmap(void *base, uint nbytes) 
     192    int os_mem_commit(void *base, size_t offset, size_t nbytes) 
     193    { 
     194        return 0; 
     195    } 
     196 
     197 
     198    int os_mem_decommit(void *base, size_t offset, size_t nbytes) 
     199    { 
     200        return 0; 
     201    } 
     202 
     203 
     204    int os_mem_unmap(void *base, size_t nbytes) 
    205205    { 
    206206        free( *cast(void**)( cast(byte*) base + nbytes ) ); 
  • trunk/lib/gc/basic/gcstats.d

    r830 r1856  
    3131struct GCStats 
    3232{ 
    33     uint poolsize;      /// total size of pool 
    34     uint usedsize;      /// bytes allocated 
    35     uint freeblocks;    /// number of blocks marked FREE 
    36     uint freelistsize;  /// total of memory on free lists 
    37     uint pageblocks;    /// number of blocks marked PAGE 
     33    size_t poolsize;        // total size of pool 
     34    size_t usedsize;        // bytes allocated 
     35    size_t freeblocks;      // number of blocks marked FREE 
     36    size_t freelistsize;    // total of memory on free lists 
     37    size_t pageblocks;      // number of blocks marked PAGE 
    3838} 
  • trunk/lib/gc/basic/gcx.d

    r1748 r1856  
    107107    struct Log 
    108108    { 
    109         void *p; 
    110         uint size; 
    111         uint line; 
    112         char *file; 
    113         void *parent; 
     109        voidp; 
     110        size_t size; 
     111        uint   line; 
     112        charfile; 
     113        voidparent; 
    114114 
    115115        void print() 
     
    127127    struct LogArray 
    128128    { 
    129         uint dim; 
    130         uint allocdim; 
     129        size_t dim; 
     130        size_t allocdim; 
    131131        Log *data; 
    132132 
     
    138138        } 
    139139 
    140         void reserve(uint nentries) 
     140        void reserve(size_t nentries) 
    141141        { 
    142142            assert(dim <= allocdim); 
     
    169169        } 
    170170 
    171  
    172         void remove(uint i) 
     171        void remove(size_t i) 
    173172        { 
    174173            memmove(data + i, data + i + 1, (dim - i) * Log.sizeof); 
     
    177176 
    178177 
    179         uint find(void *p) 
    180         { 
    181             for (uint i = 0; i < dim; i++) 
     178        size_t find(void *p) 
     179        { 
     180            for (size_t i = 0; i < dim; i++) 
    182181            { 
    183182                if (data[i].p == p) 
     
    211210{ 
    212211    // For passing to debug code 
    213     static uint line; 
    214     static char *file; 
     212    static size_t line; 
     213    static charfile; 
    215214 
    216215    uint gcversion = GCVERSION; 
     
    590589        else 
    591590        {   void *p2; 
    592             uint psize; 
     591            size_t psize; 
    593592 
    594593            //debug(PRINTF) printf("GC::realloc(p = %x, size = %u)\n", p, size); 
     
    777776            // 1) size is a power of 2 for less than PAGESIZE values 
    778777            // 2) base of memory pool is aligned on PAGESIZE boundary 
    779             if (cast(uint)p & (size - 1) & (PAGESIZE - 1)) 
     778            if (cast(size_t)p & (size - 1) & (PAGESIZE - 1)) 
    780779                size = 0; 
    781780            return size ? size - SENTINAL_EXTRA : 0; 
     
    792791            // 1) size is a power of 2 for less than PAGESIZE values 
    793792            // 2) base of memory pool is aligned on PAGESIZE boundary 
    794             if (cast(uint)p & (size - 1) & (PAGESIZE - 1)) 
     793            if (cast(size_t)p & (size - 1) & (PAGESIZE - 1)) 
    795794                size = 0; 
    796795            else 
     
    832831        debug (PTRCHECK) 
    833832        { 
    834             Pool *pool; 
    835             uint pagenum; 
    836             Bins bin; 
    837             uint size; 
     833            Poolpool; 
     834            uint   pagenum; 
     835            Bins   bin; 
     836            size_t size; 
    838837 
    839838            p = sentinel_sub(p); 
     
    844843            assert(bin <= B_PAGE); 
    845844            size = binsize[bin]; 
    846             assert((cast(uint)p & (size - 1)) == 0); 
     845            assert((cast(size_t)p & (size - 1)) == 0); 
    847846 
    848847            debug (PTRCHECK2) 
     
    10461045    private void getStatsNoSync(out GCStats stats) 
    10471046    { 
    1048         uint psize = 0; 
    1049         uint usize = 0; 
    1050         uint flsize = 0; 
    1051  
    1052         uint n; 
    1053         uint bsize = 0; 
     1047        size_t psize = 0; 
     1048        size_t usize = 0; 
     1049        size_t flsize = 0; 
     1050 
     1051        size_t n; 
     1052        size_t bsize = 0; 
    10541053 
    10551054        //debug(PRINTF) printf("getStats()\n"); 
     
    11591158 
    11601159    void *p_cache; 
    1161     uint size_cache; 
    1162  
    1163     uint nroots; 
    1164     uint rootdim; 
     1160    size_t size_cache; 
     1161 
     1162    size_t nroots; 
     1163    size_t rootdim; 
    11651164    void **roots; 
    11661165 
    1167     uint nranges; 
    1168     uint rangedim; 
     1166    size_t nranges; 
     1167    size_t rangedim; 
    11691168    Range *ranges; 
    11701169 
     
    12861285        if (nroots == rootdim) 
    12871286        { 
    1288             uint newdim = rootdim * 2 + 16; 
    1289             void **newroots; 
     1287            size_t newdim = rootdim * 2 + 16; 
     1288            void** newroots; 
    12901289 
    12911290            newroots = cast(void **)tango.stdc.stdlib.malloc(newdim * newroots[0].sizeof); 
     
    13081307    void removeRoot(void *p) 
    13091308    { 
    1310         uint i; 
    1311         for (i = nroots; i--;) 
     1309        for (size_t i = nroots; i--;) 
    13121310        { 
    13131311            if (roots[i] == p) 
     
    13311329        if (nranges == rangedim) 
    13321330        { 
    1333             uint newdim = rangedim * 2 + 16; 
     1331            size_t newdim = rangedim * 2 + 16; 
    13341332            Range *newranges; 
    13351333 
     
    13561354        debug(PRINTF) printf("Thread %x ", pthread_self()); 
    13571355        debug(PRINTF) printf("%x.Gcx.removeRange(%x), nranges = %d\n", this, pbot, nranges); 
    1358         for (uint i = nranges; i--;) 
     1356        for (size_t i = nranges; i--;) 
    13591357        { 
    13601358            if (ranges[i].pbot == pbot) 
     
    14071405     * Returns 0 if not a gc'd pointer 
    14081406     */ 
    1409     uint findSize(void *p) 
     1407    size_t findSize(void *p) 
    14101408    { 
    14111409        Pool *pool; 
    1412         uint size = 0; 
     1410        size_t size = 0; 
    14131411 
    14141412        pool = findPool(p); 
     
    14421440     * Compute bin for size. 
    14431441     */ 
    1444     static Bins findBin(uint size) 
     1442    static Bins findBin(size_t size) 
    14451443    {   Bins bin; 
    14461444 
     
    14891487     * Return null if out of memory. 
    14901488     */ 
    1491     void *bigAlloc(uint size) 
     1489    void *bigAlloc(size_t size) 
    14921490    { 
    14931491        Pool *pool; 
     
    16641662 
    16651663        // Convert page to free list 
    1666         uint size = binsize[bin]; 
     1664        size_t size = binsize[bin]; 
    16671665        List **b = &bucket[bin]; 
    16681666 
     
    17001698                if (pool) 
    17011699                { 
    1702                     uint offset = cast(uint)(p - pool.baseAddr); 
     1700                    size_t offset = cast(uint)(p - pool.baseAddr); 
    17031701                    uint biti; 
    17041702                    uint pn = offset / PAGESIZE; 
     
    17481746     * Return number of full pages free'd. 
    17491747     */ 
    1750     uint fullcollectshell() 
     1748    size_t fullcollectshell() 
    17511749    { 
    17521750        // The purpose of the 'shell' is to ensure all the registers 
    17531751        // get put on the stack so they'll be scanned 
    17541752        void *sp; 
    1755         uint result; 
     1753        size_t result; 
    17561754        version (GNU) 
    17571755        { 
     
    17861784     * 
    17871785     */ 
    1788     uint fullcollect(void *stackTop) 
     1786    size_t fullcollect(void *stackTop) 
    17891787    { 
    17901788        uint n; 
     
    19221920        // Free up everything not marked 
    19231921        debug(COLLECT_PRINTF) printf("\tfree'ing\n"); 
    1924         uint freedpages = 0; 
    1925         uint freed = 0; 
     1922        size_t freedpages = 0; 
     1923        size_t freed = 0; 
    19261924        for (n = 0; n < npools; n++) 
    19271925        {   uint pn; 
     
    20302028        // Free complete pages, rebuild free list 
    20312029        debug(COLLECT_PRINTF) printf("\tfree complete pages\n"); 
    2032         uint recoveredpages = 0; 
     2030        size_t recoveredpages = 0; 
    20332031        for (n = 0; n < npools; n++) 
    20342032        {   uint pn; 
     
    21672165 
    21682166 
    2169         void log_malloc(void *p, uint size) 
     2167        void log_malloc(void *p, size_t size) 
    21702168        { 
    21712169            //debug(PRINTF) printf("+log_malloc(p = %x, size = %d)\n", p, size); 
     
    21892187        { 
    21902188            //debug(PRINTF) printf("+log_free(%x)\n", p); 
    2191             uint i; 
     2189            size_t i; 
    21922190 
    21932191            i = current.find(p); 
     
    22082206 
    22092207            debug(PRINTF) printf("New pointers this cycle: --------------------------------\n"); 
    2210             int used = 0; 
    2211             for (uint i = 0; i < current.dim; i++) 
    2212             { 
    2213                 uint j; 
     2208            size_t used = 0; 
     2209            for (size_t i = 0; i < current.dim; i++) 
     2210            { 
     2211                size_t j; 
    22142212 
    22152213                j = prev.find(current.data[i].p); 
     
    22212219 
    22222220            debug(PRINTF) printf("All roots this cycle: --------------------------------\n"); 
    2223             for (uint i = 0; i < current.dim; i++) 
     2221            for (size_t i = 0; i < current.dim; i++) 
    22242222            { 
    22252223                void *p; 
    2226                 uint j; 
     2224                size_t j; 
    22272225 
    22282226                p = current.data[i].p; 
     
    22482246        { 
    22492247            //debug(PRINTF) printf("+log_parent()\n"); 
    2250             uint i; 
     2248            size_t i; 
    22512249 
    22522250            i = current.find(p); 
     
    22572255                pool = findPool(p); 
    22582256                assert(pool); 
    2259                 uint offset = cast(uint)(p - pool.baseAddr); 
     2257                size_t offset = cast(uint)(p - pool.baseAddr); 
    22602258                uint biti; 
    22612259                uint pn = offset / PAGESIZE; 
     
    22752273    { 
    22762274        void log_init() { } 
    2277         void log_malloc(void *p, uint size) { } 
     2275        void log_malloc(void *p, size_t size) { } 
    22782276        void log_free(void *p) { } 
    22792277        void log_collect() { } 
     
    23032301    void initialize(uint npages) 
    23042302    { 
    2305         uint poolsize; 
     2303        size_t poolsize; 
    23062304 
    23072305        //debug(PRINTF) printf("Pool::Pool(%u)\n", npages); 
     
    24652463            return -1; 
    24662464        else 
    2467        return cast(int)(baseAddr > p2.baseAddr); 
     2465        return cast(int)(baseAddr > p2.baseAddr); 
    24682466    } 
    24692467} 
     
    24752473version (SENTINEL) 
    24762474{ 
    2477     const uint SENTINEL_PRE = 0xF4F4F4F4;       // 32 bits 
     2475    const size_t SENTINEL_PRE = cast(size_t) 0xF4F4F4F4F4F4F4F4UL; // 32 or 64 bits 
    24782476    const ubyte SENTINEL_POST = 0xF5;           // 8 bits 
    2479     const uint SENTINEL_EXTRA = 2 * uint.sizeof + 1; 
    2480  
    2481  
    2482     uint* sentinel_size(void *p)  { return &(cast(uint *)p)[-2]; } 
    2483     uint* sentinel_pre(void *p)   { return &(cast(uint *)p)[-1]; } 
     2477    const uint SENTINEL_EXTRA = 2 * size_t.sizeof + 1; 
     2478 
     2479 
     2480    size_t* sentinel_size(void *p)  { return &(cast(size_t *)p)[-2]; } 
     2481    size_t* sentinel_pre(void *p)   { return &(cast(size_t *)p)[-1]; } 
    24842482    ubyte* sentinel_post(void *p) { return &(cast(ubyte *)p)[sentinel_size(p)]; } 
    24852483 
    24862484 
    2487     void sentinel_init(void *p, uint size) 
     2485    void sentinel_init(void *p, size_t size) 
    24882486    { 
    24892487        *sentinel_size(p) = size; 
     
    25022500    void *sentinel_add(void *p) 
    25032501    { 
    2504         return p + 2 * uint.sizeof; 
     2502        return p + 2 * size_t.sizeof; 
    25052503    } 
    25062504 
     
    25082506    void *sentinel_sub(void *p) 
    25092507    { 
    2510         return p - 2 * uint.sizeof; 
     2508        return p - 2 * size_t.sizeof; 
    25112509    } 
    25122510} 
     
    25162514 
    25172515 
    2518     void sentinel_init(void *p, uint size) 
     2516    void sentinel_init(void *p, size_t size) 
    25192517    { 
    25202518    } 
  • trunk/object.di

    r1800 r1856  
    2626    ClassInfo   classinfo; 
    2727    void*[]     vtbl; 
    28     int         offset;     // offset to Interface 'this' from Object 'this' 
     28    ptrdiff_t offset;           // offset to Interface 'this' from Object 'this' 
    2929} 
    3030 
  • trunk/tango/text/Regex.d

    r1748 r1856  
    268268        { 
    269269            debug(Regex) 
    270                 printf("pattern: %.*s, slice: %.*s, replacement: %.*s\n",pattern,result[offset + so .. offset + eo],replacement); 
    271             result = std.string.replace(result,slice,replacement); 
     270            printf("pattern: %.*s, slice: %.*s, replacement: %.*s\n", 
     271                cast(int) pattern.length, pattern.ptr, 
     272                cast(int) (eo-so), result.ptr + offset, 
     273                cast(int) replacement.length, replacement.ptr); 
     274                result = std.string.replace(result,slice,replacement); 
    272275            break; 
    273276        } 
     
    10001003        { 
    10011004            debug(Regex) 
    1002                 printf("pattern: %.*s, slice: %.*s, format: %.*s, replacement: %.*s\n",pattern,result[offset + so .. offset + eo],format,replacement); 
    1003             result = std.string.replace(result,slice,replacement); 
     1005            printf("pattern: %.*s, slice: %.*s, format: %.*s, replacement: %.*s\n", 
     1006                cast(int) pattern.length, pattern.ptr, 
     1007                cast(int) (eo-so), result.ptr + offset, 
     1008                cast(int) format.length, format.ptr, 
     1009                cast(int) replacement.length, replacement.ptr); 
     1010                result = std.string.replace(result,slice,replacement); 
    10041011            break; 
    10051012        } 
     
    10481055public rchar[][] exec(rchar[] string) 
    10491056{ 
    1050     debug(Regex) printf("Regex.exec(string = '%.*s')\n", string); 
     1057    debug(Regex) printf("Regex.exec(string = '%.*s')\n", 
     1058                        cast(int) string.length, string.ptr); 
    10511059    input = string; 
    10521060    pmatch[0].rm_so = 0; 
     
    11941202    ushort *pu; 
    11951203    uint *puint; 
     1204    ubyte[] s; 
    11961205 
    11971206    printf("printProgram()\n"); 
     
    12301239            case REstring: 
    12311240                len = *cast(uint *)&prog[pc + 1]; 
     1241                s = (&prog[pc + 1 + uint.sizeof])[0 .. len]; 
    12321242                printf("\tREstring x%x, '%.*s'\n", len, 
    1233                         (&prog[pc + 1 + uint.sizeof])[0 .. len]); 
     1243            cast(int) s.length, s.ptr); 
    12341244                pc += 1 + uint.sizeof + len * rchar.sizeof; 
    12351245                break; 
     
    12371247            case REistring: 
    12381248                len = *cast(uint *)&prog[pc + 1]; 
     1249                s = (&prog[pc + 1 + uint.sizeof])[0 .. len]; 
    12391250                printf("\tREistring x%x, '%.*s'\n", len, 
    1240                         (&prog[pc + 1 + uint.sizeof])[0 .. len]); 
     1251                    cast(int) s.length, s.ptr); 
    12411252                pc += 1 + uint.sizeof + len * rchar.sizeof; 
    12421253                break; 
     
    13141325                n = puint[1]; 
    13151326                m = puint[2]; 
    1316                 printf("\tREnm%.*s len=%d, n=%u, m=%u, pc=>%d\n", 
    1317                     (prog[pc] == REnmq) ? "q" : " ", 
     1327                printf("\tREnm%s len=%d, n=%u, m=%u, pc=>%d\n", 
     1328                    (prog[pc] == REnmq) ? cast(char*)"q" : cast(char*)" ", 
    13181329                    len, n, m, pc + 1 + uint.sizeof * 3 + len); 
    13191330                pc += 1 + uint.sizeof * 3; 
     
    14081419 
    14091420    debug(Regex) 
     1421    { 
     1422        char[] s = input[src .. input.length]; 
    14101423        printf("Regex.trymatch(pc = %d, src = '%.*s', pcend = %d)\n", 
    1411             pc, input[src .. input.length], pcend); 
     1424               pc, cast(int) s.length, s.ptr, pcend); 
     1425    } 
    14121426    srcsave = src; 
    14131427    psave = null; 
     
    14921506            case REstring: 
    14931507                len = *cast(uint *)&program[pc + 1]; 
    1494                 debug(Regex) printf("\tREstring x%x, '%.*s'\n", len, 
    1495                         (&program[pc + 1 + uint.sizeof])[0 .. len]); 
     1508                debug(Regex) 
     1509                { 
     1510                    char[] s = (&program[pc + 1 + uint.sizeof])[0 .. len]; 
     1511                    printf("\tREstring x%x, '%.*s'\n", len, 
     1512                        cast(int) s.length, s.ptr); 
     1513                } 
    14961514                if (src + len > input.length) 
    14971515                    goto Lnomatch; 
     
    15041522            case REistring: 
    15051523                len = *cast(uint *)&program[pc + 1]; 
    1506                 debug(Regex) printf("\tREistring x%x, '%.*s'\n", len, 
    1507                         (&program[pc + 1 + uint.sizeof])[0 .. len]); 
     1524                debug(Regex) 
     1525                { 
     1526                    char[] s = (&program[pc + 1 + uint.sizeof])[0 .. len]; 
     1527                    printf("\tREistring x%x, '%.*s'\n", len, 
     1528                        cast(int) s.length, s.ptr); 
     1529                } 
    15081530                if (src + len > input.length) 
    15091531                    goto Lnomatch; 
     
    21662188                    case 'u': 
    21672189                    case '0': 
    2168            c = cast(char)escape(); 
     2190                        c = cast(char)escape(); 
    21692191                        goto Lbyte; 
    21702192 
     
    25122534{ 
    25132535    errors++; 
    2514     debug(Regex) printf("error: %.*s\n", msg); 
     2536    debug(Regex) printf("error: %.*s\n", cast(int) msg.length, msg.ptr); 
    25152537//assert(0); 
    25162538//*(char*)0=0; 
     
    29762998                        result ~= '$'; 
    29772999                        result ~= c; 
    2978            c = cast(char)c2; 
     3000            c = cast(char)c2; 
    29793001                        goto L1; 
    29803002                    }