Changeset 853

Show
Ignore:
Timestamp:
10/10/08 20:56:40 (2 months ago)
Author:
sean
Message:

This commit includes all the changes necessary for Phobos to run against druntime. Here is a sucinct list of the changes made:

  • Removed gcstats. Garbage collector statistics will be avaialable in durintime's 'memory' module.
  • Removed object.d. This module is replaced by the object.d provided by druntime.
  • Removed std.array. To trap an array bounds error, import 'exception' from druntime and catch ArrayBoundsException?.
  • Removed std.asserterror. To trap an asertion failure, import 'exception' from druntime and catch AssertException?.
  • Removed std.gc. To interact with the garbage collector, import 'memory' from druntime.
  • Removed std.hiddenfunc. No equivalent exception is currently exposed by druntime, but if one is exposed it will be called HiddenFuncException? and be declared in 'exception'.
  • Removed std.moduleinit. druntime declares ModuleInfo? in object.d, so it is implicitly availble without importing.
  • Removed std.outofmemory. To trap an out of memory error, import 'exception' from druntime and catch OutOfMemoryException?.
  • Removed std.switcherr. To trap a switch error, import 'exception' from druntime and catch SwitchException?.
  • Removed std.synchro. This functionality will exist within druintime.
  • Removed std.thread. A Thread class is available within druntime's 'thread' module. An interface comparison will be provided separately.
  • Removed std.typeinfo. The classes defined in this package are for runtime use and should not be visible to the user.

The prior version of Phobos has been archived in tags/phobos-2.019 if needed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/phobos/etc/gamma.d

    r697 r853  
    184184     * interval (2,3).  Large arguments are handled by Stirling's 
    185185     * formula. Large negative arguments are made positive using 
    186      * a reflection formula.  
    187      */  
     186     * a reflection formula. 
     187     */ 
    188188 
    189189    real q, z; 
     
    197197    if (x == 0) 
    198198    return 1.0 / x; // +- infinity depending on sign of x, create an exception. 
    199      
     199 
    200200    q = fabs(x); 
    201          
     201 
    202202    if ( q > 13.0L ) 
    203203    { 
    204204    // Large arguments are handled by Stirling's 
    205205    // formula. Large negative arguments are made positive using 
    206     // the reflection formula.   
     206    // the reflection formula. 
    207207 
    208208    if ( x < 0.0L ) 
     
    230230        return gammaStirling(x); 
    231231    } 
    232      
     232 
    233233    // Arguments |x| <= 13 are reduced by recurrence and the function 
    234234    // approximated by a rational function of degree 7/8 in the 
     
    241241    z *= x; 
    242242    } 
    243      
     243 
    244244    while ( x < -0.03125L ) 
    245245    { 
     
    247247    x += 1.0L; 
    248248    } 
    249      
     249 
    250250    if ( x <= 0.03125L ) 
    251251    { 
     
    262262    } 
    263263    } 
    264      
     264 
    265265    while ( x < 2.0L ) 
    266266    { 
     
    270270    if ( x == 2.0L ) 
    271271    return z; 
    272      
     272 
    273273    x -= 2.0L; 
    274274    return z * poly( x, GammaNumeratorCoeffs ) / poly( x, GammaDenominatorCoeffs ); 
     
    315315 *  <tr> <td> &plusmn;&infin;  <td> +&infin;      <td> no 
    316316 *  </table> 
    317  *  
     317 * 
    318318 */ 
    319319real lgamma(real x) 
     
    330330     */ 
    331331    real q, w, z, f, nx; 
    332      
     332 
    333333    if (isnan(x)) 
    334334    return x; 
    335335    if (fabs(x) == x.infinity) 
    336336    return x.infinity; 
    337      
     337 
    338338    if ( x < -34.0L ) 
    339339    { 
     
    386386            q = z / (x * poly( x, GammaSmallCoeffs)); 
    387387        return log( fabs(q) ); 
    388         }           
     388        } 
    389389        z /= nx +  f; 
    390390        nx += 1.0L; 
     
    398398    return ( log(z) + p ); 
    399399    } 
    400      
     400 
    401401    //const real MAXLGM = 1.04848146839019521116e+4928L; 
    402402    //if ( x > MAXLGM ) return sgngaml * real.infinity; 
     
    404404    /* log( sqrt( 2*pi ) ) */ 
    405405    const real LOGSQRT2PI  =  0.91893853320467274178L; 
    406      
     406 
    407407    q = ( x - 0.5L ) * log(x) - x + LOGSQRT2PI; 
    408408    if (x > 1.0e10L) return q; 
     
    415415{ 
    416416    // return true if x is +0.0 
    417     bit isPosZero(real x) 
     417    bool isPosZero(real x) 
    418418    { 
    419419       return (x==0) && (signbit(x)==0); 
     
    426426    assert(isPosZero(lgamma(1.0L))); 
    427427    assert(isPosZero(lgamma(2.0L))); 
    428   
     428 
    429429    // x, correct loggamma(x), correct d/dx loggamma(x). 
    430430    static real[] testpoints = 
    431     [  
     431    [ 
    432432     8.0L,                    8.525146484375L      + 1.48766904143001655310E-5,   2.01564147795560999654E0L, 
    433433     8.99993896484375e-1L,    6.6375732421875e-2L  + 5.11505711292524166220E-6L, -7.54938684259372234258E-1, 
     
    481481} 
    482482 
    483    
     483 
  • trunk/phobos/linux.mak

    r829 r853  
    3535      CFLAGS = 
    3636      DFLAGS = 
    37       LDFLAGS =  
     37      LDFLAGS = 
    3838else 
    3939      OBJDIR = obj/linux 
    4040      OBJEXT = o 
    4141      LIBEXT = a 
    42       EXEEXT =  
     42      EXEEXT = 
    4343      CC = gcc 
    4444      DMD = dmd 
     
    9191 
    9292ifneq (none,$(OBJDIR)) 
    93       DUMMY := $(shell mkdir --parents $(OBJDIR) $(OBJDIR)/etc/c/zlib   \ 
    94             $(OBJDIR)/internal $(OBJDIR)/internal/gc) 
     93      DUMMY := $(shell mkdir --parents $(OBJDIR) $(OBJDIR)/etc/c/zlib) 
    9594endif 
    9695 
     
    139138    for m in $(STD_MODULES); do echo public import std.$$m\;; done > $@ 
    140139 
    141 INTERNAL_MODULES = aApply aApplyR aaA adi alloca arraycast arraycat \ 
    142     cast cmath2 deh2 dmain2 invariant llmath memset monitor obj     \ 
    143     object qsort switch trace arrayassign \ 
    144     arrayfloat arraydouble arrayreal \ 
    145     arraybyte arrayshort arrayint 
    146 INTERNAL_CMODULES = complex critical 
    147 INTERNAL_CMODULES_NOTBUILT = deh 
    148 INTERNAL_EXTRAFILES = internal/mars.h internal/minit.asm 
    149  
    150 INTERNAL_GC_MODULES = gc gcold gcx gcbits gclinux 
    151 INTERNAL_GC_EXTRAFILES = \ 
    152     internal/gc/gcstub.d \ 
    153     internal/gc/win32.d \ 
    154     internal/gc/testgc.d \ 
    155     internal/gc/win32.mak \ 
    156     internal/gc/linux.mak 
    157  
    158 STD_MODULES = algorithm array asserterror atomics base64 bigint bind bitarray   \ 
     140STD_MODULES = algorithm atomics base64 bigint bind bitarray         \ 
    159141        bitmanip boxer compiler complex contracts conv cover cpuid  \ 
    160142        cstream ctype date dateparse demangle encoding file format  \ 
    161         functional  getopt hiddenfunc intrinsic iterator loader math   
    162         md5 metastrings mmfile moduleinit numeric openrj outbuffer
    163         outofmemory path perf process random regexp signals socket
    164         socketstream stdint stdio stream string switcherr syserror
    165         synchro system thread traits typecons typetuple uni uri utf     \ 
     143        functional  getopt intrinsic iterator loader math         
     144        md5 metastrings mmfile numeric openrj outbuffer                   
     145        path perf process random regexp signals socket                 
     146        socketstream stdint stdio stream string syserror           
     147        system traits typecons typetuple uni uri utf                    \ 
    166148        variant xml zip zlib 
    167 STD_MODULES_NOTBUILT = stdarg gc 
     149STD_MODULES_NOTBUILT = stdarg 
    168150 
    169151STD_C_MODULES = stdarg stdio 
     
    192174ETC_C_MODULES = zlib 
    193175 
    194 SRC = errno.c object.d unittest.d crc32.d  
     176SRC = errno.c object.d unittest.d crc32.d 
    195177 
    196178SRC_ZLIB = ChangeLog README adler32.c algorithm.txt compress.c crc32.c  \ 
     
    208190 
    209191SRC_RELEASEZIP = linux.mak win32.mak phoboslicense.txt $(SRC)       \ 
    210     $(SRC_ZLIB) $(INTERNAL_EXTRAFILES) $(INTERNAL_GC_EXTRAFILES)    \ 
    211     $(addprefix internal/,$(addsuffix .c,               \ 
    212     $(INTERNAL_CMODULES_NOTBUILT))) $(addprefix internal/,      \ 
    213     $(addsuffix .c, $(INTERNAL_CMODULES))) $(addprefix internal/,   \ 
    214     $(addsuffix .d, $(INTERNAL_MODULES))) $(addprefix       \ 
    215     internal/gc/, $(addsuffix .d, $(INTERNAL_GC_MODULES)))      \ 
    216     $(addprefix std/, $(addsuffix .d, $(STD_MODULES)        \ 
     192    $(SRC_ZLIB) $(addprefix std/, $(addsuffix .d, $(STD_MODULES)    \ 
    217193    $(STD_MODULES_NOTBUILT))) $(addprefix std/c/, $(addsuffix .d,   \ 
    218194    $(STD_C_MODULES) $(STD_C_MODULES_NOTBUILT))) $(addprefix    \ 
     
    220196    $(STD_C_LINUX_MODULES_NOTBUILT))) $(addprefix std/c/windows/,   \ 
    221197    $(addsuffix .d, $(STD_C_WINDOWS_MODULES_NOTBUILT)))     \ 
    222     $(addprefix std/typeinfo/, $(addsuffix .d,          \ 
    223     $(TYPEINFO_MODULES))) $(addprefix std/windows/, $(addsuffix \ 
     198    $(addprefix std/windows/, $(addsuffix                           \ 
    224199    .d, $(STD_WINDOWS_MODULES_NOTBUILT))) $(addprefix etc/,     \ 
    225200    $(addsuffix .d, $(ETC_MODULES_NOTBUILT))) $(addprefix etc/c/,   \ 
    226201    $(addsuffix .d, $(ETC_C_MODULES))) 
    227202 
    228 OBJS = errno $(addprefix internal/, $(INTERNAL_MODULES)     \ 
    229     $(INTERNAL_CMODULES)) $(addprefix internal/gc/,     \ 
    230     $(INTERNAL_GC_MODULES)) $(addprefix etc/c/zlib/,    \ 
    231     $(ZLIB_CMODULES)) 
     203OBJS = errno 
    232204 
    233205OBJS := $(addsuffix .$(OBJEXT),$(addprefix $(OBJDIR)/,$(OBJS))) 
    234206 
    235 SRC2LIB = crc32 gcstats $(addprefix std/, $(STD_MODULES)) $(addprefix   \ 
    236 std/typeinfo/, $(TYPEINFO_MODULES)) $(addprefix std/c/,         \ 
     207SRC2LIB = crc32 $(addprefix std/, $(STD_MODULES)) $(addprefix std/c/,   \ 
    237208$(STD_C_MODULES)) $(addprefix std/c/linux/, $(STD_C_LINUX_MODULES)) \ 
    238209$(addprefix etc/c/, $(ETC_C_MODULES)) 
     
    275246 
    276247HEADERDIR = include 
    277 HEADERS = object.d \ 
    278     $(addprefix std/,$(addsuffix .d,$(STD_MODULES))) \ 
     248HEADERS = $(addprefix std/,$(addsuffix .d,$(STD_MODULES))) \ 
    279249    $(addprefix std/,$(addsuffix .d,$(STD_MODULES_NOTBUILT))) \ 
    280250    $(addprefix std/c/,$(addsuffix .d,$(STD_C_MODULES))) \ 
    281251    $(addprefix std/c/,$(addsuffix .d,$(STD_C_MODULES_NOTBUILT))) \ 
    282252    $(addprefix std/c/linux/,$(addsuffix .d,$(STD_C_LINUX_MODULES))) \ 
    283     $(addprefix std/c/linux/,$(addsuffix .d,$(STD_C_LINUX_MODULES_NOTBUILT)))  
     253    $(addprefix std/c/linux/,$(addsuffix .d,$(STD_C_LINUX_MODULES_NOTBUILT))) 
    284254 
    285255HEADERS := $(addprefix $(HEADERDIR)/,$(HEADERS)) 
  • trunk/phobos/std/c/stdio.d

    r689 r853  
    196196size_t   fread(void *,size_t,size_t,FILE *);    /// 
    197197size_t   fwrite(in void *,size_t,size_t,FILE *);    /// 
    198 //int  printf(in char *,...); /// 
     198int    printf(in char *,...); /// 
    199199int  fprintf(FILE *,in char *,...); /// 
    200200int  vfprintf(FILE *,in char *,va_list);    /// 
  • trunk/phobos/std/encoding.d

    r693 r853  
    20742074    static void register(string className) 
    20752075    { 
    2076         auto scheme = cast(EncodingScheme)Object.factory(className); 
     2076        auto scheme = cast(EncodingScheme)ClassInfo.find(className).create(); 
    20772077        if (scheme is null) 
    20782078            throw new EncodingException("Unable to create class "~className); 
     
    21012101            throw new EncodingException("Unrecognized Encoding: "~encodingName); 
    21022102        string className = *p; 
    2103         auto scheme = cast(EncodingScheme)Object.factory(className); 
     2103        auto scheme = cast(EncodingScheme)ClassInfo.find(className).create(); 
    21042104        if (scheme is null) throw new EncodingException("Unable to create class "~className); 
    21052105        return scheme; 
  • trunk/phobos/std/file.d

    r840 r853  
    3838module std.file; 
    3939 
     40private import memory; 
    4041private import std.c.stdio; 
    4142private import std.c.stdlib; 
     
    4344private import std.string; 
    4445private import std.regexp; 
    45 private import std.gc; 
    4646private import std.c.string; 
    4747private import std.traits; 
     
    132132    goto err2; 
    133133 
    134     auto buf = std.gc.malloc(size); 
    135     if (buf) 
    136     std.gc.hasNoPointers(buf.ptr); 
     134    auto buf = GC.malloc(size, GC.BlkAttr.NO_SCAN)[0 .. size]; 
    137135 
    138136    if (ReadFile(h,buf.ptr,size,&numread,null) != 1) 
     
    955953    invariant size = statbuf.st_size; 
    956954    if (!size) return null; 
    957     auto buf = std.gc.malloc(size); 
     955    auto buf = GC.malloc(size, GC.BlkAttr.NO_SCAN); 
    958956    enforce(buf, "Out of memory"); 
    959957    scope(failure) delete buf; 
    960     std.gc.hasNoPointers(buf.ptr); 
    961958 
    962959    cenforce(std.c.linux.linux.read(fd, buf.ptr, size) == size, name); 
  • trunk/phobos/std/md5.d

    r689 r853  
    8989import std.string; 
    9090import std.contracts; 
     91import std.c.stdio : printf; 
    9192 
    9293/*************************************** 
  • trunk/phobos/std/outbuffer.d

    r689 r853  
    1919private 
    2020{ 
     21    import memory; 
    2122    import std.string; 
    22     import std.gc; 
    2323    import std.c.stdio; 
    2424    import std.c.stdlib; 
     
    8181        { 
    8282        data.length = (offset + nbytes) * 2; 
    83         std.gc.hasPointers(data.ptr); 
     83        GC.clrAttr(data.ptr, GC.BlkAttr.NO_SCAN); 
    8484        } 
    8585    } 
  • trunk/phobos/std/path.d

    r849 r853  
    3535    private import std.c.stdlib; 
    3636    private import std.c.linux.linux; 
    37     private import std.outofmemory
     37    private import exception : onOutOfMemoryError
    3838} 
    3939 
     
    12581258    if (extra_memory) 
    12591259    std.c.stdlib.free(extra_memory); 
    1260     _d_OutOfMemory(); 
     1260    onOutOfMemoryError(); 
    12611261    return null; 
    12621262} 
  • trunk/phobos/std/random.d

    r846 r853  
    2020Random) for whichever generator it finds the most fit for the target 
    2121environment. 
    22     
     22 
    2323Example: 
    2424 
     
    6666// Work derived from: 
    6767 
    68 /*  
     68/* 
    6969   A C-program for MT19937, with initialization improved 2002/1/26. 
    7070   Coded by Takuji Nishimura and Makoto Matsumoto. 
    7171 
    72    Before using, initialize the state by using init_genrand(seed)   
     72   Before using, initialize the state by using init_genrand(seed) 
    7373   or init_by_array(init_key, key_length). 
    7474 
    7575   Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, 
    76    All rights reserved.                           
     76   All rights reserved. 
    7777 
    7878   Redistribution and use in source and binary forms, with or without 
     
    8787        documentation and/or other materials provided with the distribution. 
    8888 
    89      3. The names of its contributors may not be used to endorse or promote  
    90         products derived from this software without specific prior written  
     89     3. The names of its contributors may not be used to endorse or promote 
     90        products derived from this software without specific prior written 
    9191        permission. 
    9292 
     
    146146            modulus = m; 
    147147    } 
    148      
     148 
    149149    static assert(isIntegral!(UIntType)); 
    150150    static assert(m == 0 || a < m); 
     
    181181    UIntType next() 
    182182    { 
    183         static if (m)  
     183        static if (m) 
    184184            _x = cast(UIntType) ((cast(ulong) a * _x + c) % m); 
    185185        else 
     
    203203        return _x == rhs._x; 
    204204    } 
    205      
     205 
    206206    private UIntType _x = 1; 
    207207}; 
     
    318318        return result; 
    319319    } 
    320      
     320 
    321321/** 
    322322   Constructs a MersenneTwisterEngine object 
     
    334334        } 
    335335        for (mti = 1; mti < n; ++mti) { 
    336             mt[mti] =  
     336            mt[mti] = 
    337337                cast(UIntType) 
    338                 (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> (w - 2))) + mti);  
     338                (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> (w - 2))) + mti); 
    339339            /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ 
    340340            /* In the previous versions, MSBs of the seed affect   */ 
     
    364364            if (mti == n + 1)   /* if init_genrand() has not been called, */ 
    365365                seed(5489UL); /* a default initial seed is used */ 
    366              
    367             int kk = 0;             
     366 
     367            int kk = 0; 
    368368            for (; kk < n - m; ++kk) 
    369369            { 
     
    381381            mt[n - 1] = cast(UIntType) (mt[m - 1] ^ (y >> 1) 
    382382                                        ^ mag01[cast(UIntType) y & 0x1U]); 
    383              
     383 
    384384            mti = 0; 
    385385        } 
    386          
     386 
    387387        y = mt[mti++]; 
    388          
     388 
    389389        /* Tempering */ 
    390390        y ^= (y >> temperingU); 
     
    392392        y ^= (y << temperingT) & temperingC; 
    393393        y ^= (y >> temperingL); 
    394          
     394 
    395395        return cast(UIntType) y; 
    396396    } 
     
    459459auto n = rnd.next; 
    460460... 
    461 ----    
     461---- 
    462462*/ 
    463463 
     
    467467    static MinstdRand0 rand; 
    468468    if (!seeded) { 
    469         rand.seed(getpid ^ getUTCtime); 
     469        rand.seed(getpid ^ cast(uint)getUTCtime); 
    470470        seeded = true; 
    471471    } 
     
    503503auto percentages = UniformDistribution!(double, "$(LPAREN)]")(0.0, 100.0); 
    504504// Get a digit in ['0', '9'] 
    505 auto digit = digits.next(gen);  
     505auto digit = digits.next(gen); 
    506506// Get a number in $(LPAREN)0.0, 100.0] 
    507507auto p = percentages.next(gen); 
     
    545545/** 
    546546Returns the the right bound of the random value generated. 
    547 */  
     547*/ 
    548548    ResultType b() { return rightLim == ']' ? _b : nextLarger(_b); } 
    549549 
     
    585585        } 
    586586    } 
    587      
    588 private:     
     587 
     588private: 
    589589    NumberType _a = 0, _b = NumberType.max; 
    590590 
     
    739739Note: This is more random, but slower, than C's $(D rand()) function. 
    740740To use C's $(D rand()) instead, import $(D std.c.stdlib). 
    741   
     741 
    742742BUGS: Shares a global single state, not multithreaded.  SCHEDULED FOR 
    743743DEPRECATION. 
  • trunk/phobos/std/signals.d

    r464 r853  
    5959import std.stdio; 
    6060import std.c.stdlib : calloc, realloc, free; 
    61 import std.outofmemory : _d_OutOfMemory
     61import exception : onOutOfMemoryError
    6262 
    6363// Special function for internal use only. 
     
    6666extern (C) Object _d_toObject(void* p); 
    6767 
     68// Used in place of Object.notifyRegister and Object.notifyUnRegister. 
     69alias void delegate(Object) DisposeEvt; 
     70extern (C) void  rt_attachDisposeEvent( Object obj, DisposeEvt evt ); 
     71extern (C) void  rt_detachDisposeEvent( Object obj, DisposeEvt evt ); 
    6872//debug=signal; 
    6973 
     
    171175        auto p = std.signals.calloc(slot_t.sizeof, len); 
    172176        if (!p) 
    173             std.signals._d_OutOfMemory(); 
     177            onOutOfMemoryError(); 
    174178        slots = (cast(slot_t*)p)[0 .. len]; 
    175179        } 
     
    179183        auto p = std.signals.realloc(slots.ptr, slot_t.sizeof * len); 
    180184        if (!p) 
    181             std.signals._d_OutOfMemory(); 
     185            onOutOfMemoryError(); 
    182186        slots = (cast(slot_t*)p)[0 .. len]; 
    183187        slots[slots_idx + 1 .. length] = null; 
     
    188192     L1: 
    189193    Object o = _d_toObject(slot.ptr); 
    190     o.notifyRegister(&unhook); 
     194    rt_attachDisposeEvent(o, &unhook); 
    191195    } 
    192196 
     
    205209 
    206210        Object o = _d_toObject(slot.ptr); 
    207         o.notifyUnRegister(&unhook); 
     211        rt_detachDisposeEvent(o, &unhook); 
    208212        } 
    209213        else 
     
    248252        if (slot) 
    249253        {   Object o = _d_toObject(slot.ptr); 
    250             o.notifyUnRegister(&unhook); 
     254            rt_detachDisposeEvent(o, &unhook); 
    251255        } 
    252256        } 
  • trunk/phobos/std/socket.d

    r851 r853  
    33/* 
    44    Copyright (C) 2004-2005 Christopher E. Miller 
    5      
     5 
    66    This software is provided 'as-is', without any express or implied 
    77    warranty.  In no event will the authors be held liable for any damages 
    88    arising from the use of this software. 
    9      
     9 
    1010    Permission is granted to anyone to use this software for any purpose, 
    1111    including commercial applications, and to alter it and redistribute it 
    1212    freely, subject to the following restrictions: 
    13      
     13 
    1414    1. The origin of this software must not be misrepresented; you must not 
    1515       claim that you wrote the original software. If you use this software 
     
    2020    3. This notice may not be removed or altered from any source 
    2121       distribution. 
    22      
     22 
    2323    socket.d 1.3 
    2424    Jan 2005 
    25      
     25 
    2626    Thanks to Benjamin Herr for his assistance. 
    2727*/ 
    2828 
    2929/** 
    30  * Notes: For Win32 systems, link with ws2_32.lib.  
     30 * Notes: For Win32 systems, link with ws2_32.lib. 
    3131 * Example: See /dmd/samples/d/listener.d. 
    32  * Authors: Christopher E. Miller  
     32 * Authors: Christopher E. Miller 
    3333 * Macros: 
    3434 *  WIKI=Phobos/StdSocket 
     
    3939private import std.string, std.stdint, std.c.string, std.c.stdlib; 
    4040 
     41version(unittest) 
     42{ 
     43    private import std.c.stdio : printf; 
     44} 
     45 
    4146 
    4247version(linux) 
     
    5358    private import std.c.windows.windows, std.c.windows.winsock; 
    5459    private alias std.c.windows.winsock.timeval _ctimeval; 
    55      
     60 
    5661    typedef SOCKET socket_t = INVALID_SOCKET; 
    5762    private const int _SOCKET_ERROR = SOCKET_ERROR; 
    58      
    59      
     63 
     64 
    6065    private int _lasterr() 
    6166    { 
     
    7075        private alias std.c.linux.linux.timeval _ctimeval; 
    7176    } 
    72      
     77 
    7378    typedef int32_t socket_t = -1; 
    7479    private const int _SOCKET_ERROR = -1; 
    75      
    76      
     80 
     81 
    7782    private int _lasterr() 
    7883    { 
     
    9095{ 
    9196    int errorCode; /// Platform-specific error code. 
    92      
     97 
    9398    this(string msg, int err = 0) 
    9499    { 
    95100        errorCode = err; 
    96          
     101 
    97102        version(linux) 
    98103        { 
     
    102107                auto cs = strerror_r(errorCode, buf.ptr, buf.length); 
    103108                auto len = strlen(cs); 
    104                  
     109 
    105110                if(cs[len - 1] == '\n') 
    106111                    len--; 
     
    110115            } 
    111116        } 
    112          
     117 
    113118        super(msg); 
    114119    } 
     
    121126    { 
    122127        WSADATA wd; 
    123          
     128 
    124129        // Winsock will still load if an older version is present. 
    125130        // The version is just a request. 
     
    192197    string name;        /// ditto 
    193198    string[] aliases;   /// ditto 
    194      
    195      
     199 
     200 
    196201    void populate(protoent* proto) 
    197202    { 
    198203        type = cast(ProtocolType)proto.p_proto; 
    199204        name = std.string.toString(proto.p_name).idup; 
    200          
     205 
    201206        int i; 
    202207        for(i = 0;; i++) 
     
    205210                break; 
    206211        } 
    207          
     212 
    208213        if(i) 
    209214        { 
     
    220225        } 
    221226    } 
    222      
     227 
    223228    /** Returns false on failure */ 
    224229    bool getProtocolByName(string name) 
     
    231236        return true; 
    232237    } 
    233      
    234      
     238 
     239 
    235240    /** Returns false on failure */ 
    236241    // Same as getprotobynumber(). 
     
    269274    ushort port;        /// ditto 
    270275    string protocolName;    /// ditto 
    271      
    272      
     276 
     277 
    273278    void populate(servent* serv) 
    274279    { 
     
    276281        port = ntohs(cast(ushort)serv.s_port); 
    277282        protocolName = std.string.toString(serv.s_proto).idup; 
    278          
     283 
    279284        int i; 
    280285        for(i = 0;; i++) 
     
    283288                break; 
    284289        } 
    285          
     290 
    286291        if(i) 
    287292        { 
     
    298303        } 
    299304    } 
    300      
     305 
    301306    /** 
    302307     * If a protocol name is omitted, any protocol will be matched. 
     
    312317        return true; 
    313318    } 
    314      
    315      
     319 
     320 
    316321    // Any protocol name will be matched. 
    317322    /// ditto 
     
    325330        return true; 
    326331    } 
    327      
    328      
     332 
     333 
    329334    /// ditto 
    330335    bool getServiceByPort(ushort port, string protocolName) 
     
    337342        return true; 
    338343    } 
    339      
    340      
     344 
     345 
    341346    // Any protocol name will be matched. 
    342347    /// ditto 
     
    378383{ 
    379384    int errorCode;  /// Platform-specific error code. 
    380      
    381      
     385 
     386 
    382387    this(string msg, int err = 0) 
    383388    { 
     
    396401    string[] aliases;   /// ditto 
    397402    uint32_t[] addrList;    /// ditto 
    398      
    399      
     403 
     404 
    400405    void validHostent(hostent* he) 
    401406    { 
     
    403408            throw new HostException("Address family mismatch", _lasterr()); 
    404409    } 
    405      
    406      
     410 
     411 
    407412    void populate(hostent* he) 
    408413    { 
    409414        int i; 
    410415        char* p; 
    411          
     416 
    412417        name = std.string.toString(he.h_name).idup; 
    413          
     418 
    414419        for(i = 0;; i++) 
    415420        { 
     
    418423                break; 
    419424        } 
    420          
     425 
    421426        if(i) 
    422427        { 
     
    432437            aliases = null; 
    433438        } 
    434          
     439 
    435440        for(i = 0;; i++) 
    436441        { 
     
    439444                break; 
    440445        } 
    441          
     446 
    442447        if(i) 
    443448        { 
     
    453458        } 
    454459    } 
    455      
     460 
    456461    /** 
    457462     * Resolve host name. Returns false if unable to resolve. 
    458      */     
     463     */ 
    459464    bool getHostByName(string name) 
    460465    { 
     
    467472        return true; 
    468473    } 
    469      
    470      
     474 
     475 
    471476    /** 
    472477     * Resolve IPv4 address number. Returns false if unable to resolve. 
    473      */     
     478     */ 
    474479    bool getHostByAddr(uint addr) 
    475480    { 
     
    483488        return true; 
    484489    } 
    485      
    486      
     490 
     491 
    487492    /** 
    488493     * Same as previous, but addr is an IPv4 address string in the 
    489494     * dotted-decimal form $(I a.b.c.d). 
    490495     * Returns false if unable to resolve. 
    491      */     
     496     */ 
    492497    bool getHostByAddr(string addr) 
    493498    { 
     
    517522        printf("aliases[%d] = %.*s\n", i, s); 
    518523    } 
    519      
     524 
    520525    printf("---\n"); 
    521      
     526 
    522527    assert(ih.getHostByAddr(ih.addrList[0])); 
    523528    printf("name = %.*s\n", ih.name); 
     
    559564    protected: 
    560565    sockaddr sa; 
    561      
    562      
     566 
     567 
    563568    override sockaddr* name() 
    564569    { 
    565570        return &sa; 
    566571    } 
    567      
    568      
     572 
     573 
    569574    override int nameLen() 
    570575    { 
    571576        return sa.sizeof; 
    572577    } 
    573      
    574      
     578 
     579 
    575580    public: 
    576581    override AddressFamily addressFamily() 
     
    578583        return cast(AddressFamily)sa.sa_family; 
    579584    } 
    580      
    581      
     585 
     586 
    582587    override string toString() 
    583588    { 
     
    601606        return cast(sockaddr*)&sin; 
    602607    } 
    603      
    604      
     608 
     609 
    605610    override int nameLen() 
    606611    { 
    607612        return sin.sizeof; 
    608613    } 
    609      
    610      
     614 
     615 
    611616    this() 
    612617    { 
    613618    } 
    614      
    615      
     619 
     620 
    616621    public: 
    617622    const uint ADDR_ANY = INADDR_ANY;   /// Any IPv4 address number. 
    618623    const uint ADDR_NONE = INADDR_NONE; /// An invalid IPv4 address number. 
    619624    const ushort PORT_ANY = 0;      /// Any IPv4 port number. 
    620      
     625 
    621626    /// Overridden to return AddressFamily.INET. 
    622627    override AddressFamily addressFamily() 
     
    624629        return cast(AddressFamily)AddressFamily.INET; 
    625630    } 
    626      
     631 
    627632    /// Returns the IPv4 port number. 
    628633    ushort port() 
     
    630635        return ntohs(sin.sin_port); 
    631636    } 
    632      
     637 
    633638    /// Returns the IPv4 address number. 
    634639    uint addr() 
     
    636641        return ntohl(sin.sin_addr.s_addr); 
    637642    } 
    638      
     643 
    639644    /** 
    640645     * Params: 
     
    659664        sin.sin_port = htons(port); 
    660665    } 
    661      
     666 
    662667    /** 
    663668     * Construct a new Address. addr may be ADDR_ANY (default) and port may 
     
    670675        sin.sin_port = htons(port); 
    671676    } 
    672      
    673     /// ditto   
     677 
     678    /// ditto</