diff -ur druntime/src/core/stdc/errno.d druntime/import/core/stdc/errno.d
--- druntime/src/core/stdc/errno.d	2010-08-05 03:11:28.000000000 +0100
+++ druntime/import/core/stdc/errno.d	2009-11-30 07:05:20.000000000 +0000
@@ -281,7 +281,7 @@
     enum ETIME              = 101;      // STREAM ioctl timeout
     enum ELAST              = 101;      // Must be equal largest errno
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum EPERM              = 1;        // Operation not permitted
     enum ENOENT             = 2;        // No such file or directory
diff -ur druntime/src/core/stdc/fenv.d druntime/import/core/stdc/fenv.d
--- druntime/src/core/stdc/fenv.d	2010-08-05 04:38:04.000000000 +0100
+++ druntime/import/core/stdc/fenv.d	2009-09-25 21:07:38.000000000 +0100
@@ -67,7 +67,7 @@
         alias ushort fexcept_t;
     }
 }
-else version ( FreeBSD )
+else version ( freebsd )
 {
     struct fenv_t
     {
@@ -115,10 +115,10 @@
     private extern fenv_t _FE_DFL_ENV;
     fenv_t* FE_DFL_ENV = &_FE_DFL_ENV;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
-    private extern const fenv_t __fe_dfl_env;
-    const fenv_t* FE_DFL_ENV = &__fe_dfl_env;
+    private extern fenv_t __fe_dfl_env;
+    fenv_t* FE_DFL_ENV = &__fe_dfl_env;
 }
 else
 {
diff -ur druntime/src/core/stdc/math.d druntime/import/core/stdc/math.d
--- druntime/src/core/stdc/math.d	2010-09-03 09:28:52.000000000 +0100
+++ druntime/import/core/stdc/math.d	2009-11-30 07:04:54.000000000 +0000
@@ -367,7 +367,7 @@
     }
   }
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum
     {
@@ -468,123 +468,37 @@
     int isunordered(real x, real y)        { return (x !<>= y); }
 }
 
-/* NOTE: freebsd < 8-CURRENT doesn't appear to support *l, but we can
- *       approximate.
- * A lot of them were added in 8.0-RELEASE, and so a lot of these workarounds
- * should then be removed.
- */
-// NOTE: FreeBSD 8.0-RELEASE doesn't support log2* nor these *l functions:
-//         acoshl, asinhl, atanhl, coshl, sinhl, tanhl, cbrtl, powl, expl,
-//         expm1l, logl, log1pl, log10l, erfcl, erfl, lgammal, tgammal;
-//       but we can approximate.
-version( FreeBSD )
+// NOTE: freebsd < 8-CURRENT doesn't appear to support *l, but we can
+//       approximate.
+version( freebsd )
 {
-  version (all) // < 8-CURRENT
-  {
-    real    acosl(real x) { return acos(x); }
-    real    asinl(real x) { return asin(x); }
-    real    atanl(real x) { return atan(x); }
-    real    atan2l(real y, real x) { return atan2(y, x); }
-    real    cosl(real x) { return cos(x); }
-    real    sinl(real x) { return sin(x); }
-    real    tanl(real x) { return tan(x); }
-    real    exp2l(real x) { return exp2(x); }
-    real    frexpl(real value, int* exp) { return frexp(value, exp); }
-    int     ilogbl(real x) { return ilogb(x); }
-    real    ldexpl(real x, int exp) { return ldexp(x, exp); }
-    real    logbl(real x) { return logb(x); }
-    //real    modfl(real value, real *iptr); // nontrivial conversion
-    real    scalbnl(real x, int n) { return scalbn(x, n); }
-    real    scalblnl(real x, c_long n) { return scalbln(x, n); }
-    real    fabsl(real x) { return fabs(x); }
-    real    hypotl(real x, real y) { return hypot(x, y); }
-    real    sqrtl(real x) { return sqrt(x); }
-    real    ceill(real x) { return ceil(x); }
-    real    floorl(real x) { return floor(x); }
-    real    nearbyintl(real x) { return nearbyint(x); }
-    real    rintl(real x) { return rint(x); }
-    c_long  lrintl(real x) { return lrint(x); }
-    real    roundl(real x) { return round(x); }
-    c_long  lroundl(real x) { return lround(x); }
-    long    llroundl(real x) { return llround(x); }
-    real    truncl(real x) { return trunc(x); }
-    real    fmodl(real x, real y) { return fmod(x, y); }
-    real    remainderl(real x, real y) { return remainder(x, y); }
-    real    remquol(real x, real y, int* quo) { return remquo(x, y, quo); }
-    real    copysignl(real x, real y) { return copysign(x, y); }
-//  double  nan(char* tagp);
-//  float   nanf(char* tagp);
-//  real    nanl(char* tagp);
-    real    nextafterl(real x, real y) { return nextafter(x, y); }
-    real    nexttowardl(real x, real y) { return nexttoward(x, y); }
-    real    fdiml(real x, real y) { return fdim(x, y); }
-    real    fmaxl(real x, real y) { return fmax(x, y); }
-    real    fminl(real x, real y) { return fmin(x, y); }
-    real    fmal(real x, real y, real z) { return fma(x, y, z); }
-  }
-  else
-  {
-    real    acosl(real x);
-    real    asinl(real x);
-    real    atanl(real x);
-    real    atan2l(real y, real x);
-    real    cosl(real x);
-    real    sinl(real x);
-    real    tanl(real x);
-    real    exp2l(real x);
-    real    frexpl(real value, int* exp);
-    int     ilogbl(real x);
-    real    ldexpl(real x, int exp);
-    real    logbl(real x);
-    real    modfl(real value, real *iptr);
-    real    scalbnl(real x, int n);
-    real    scalblnl(real x, c_long n);
-    real    fabsl(real x);
-    real    hypotl(real x, real y);
-    real    sqrtl(real x);
-    real    ceill(real x);
-    real    floorl(real x);
-    real    nearbyintl(real x);
-    real    rintl(real x);
-    c_long  lrintl(real x);
-    real    roundl(real x);
-    c_long  lroundl(real x);
-    long    llroundl(real x);
-    real    truncl(real x);
-    real    fmodl(real x, real y);
-    real    remainderl(real x, real y);
-    real    remquol(real x, real y, int* quo);
-    real    copysignl(real x, real y);
-    double  nan(char* tagp);
-    float   nanf(char* tagp);
-    real    nanl(char* tagp);
-    real    nextafterl(real x, real y);
-    real    nexttowardl(real x, real y);
-    real    fdiml(real x, real y);
-    real    fmaxl(real x, real y);
-    real    fminl(real x, real y);
-    real    fmal(real x, real y, real z);
-  }
     double  acos(double x);
     float   acosf(float x);
+    real    acosl(real x) { return acos(x); }
 
     double  asin(double x);
     float   asinf(float x);
+    real    asinl(real x) { return asin(x); }
 
     double  atan(double x);
     float   atanf(float x);
+    real    atanl(real x) { return atan(x); }
 
     double  atan2(double y, double x);
     float   atan2f(float y, float x);
+    real    atan2l(real y, real x) { return atan2(y, x); }
 
     double  cos(double x);
     float   cosf(float x);
+    real    cosl(real x) { return cos(x); }
 
     double  sin(double x);
     float   sinf(float x);
+    real    sinl(real x) { return sin(x); }
 
     double  tan(double x);
     float   tanf(float x);
+    real    tanl(real x) { return tan(x); }
 
     double  acosh(double x);
     float   acoshf(float x);
@@ -616,6 +530,7 @@
 
     double  exp2(double x);
     float   exp2f(float x);
+    real    exp2l(real x) { return exp2(x); }
 
     double  expm1(double x);
     float   expm1f(float x);
@@ -623,12 +538,15 @@
 
     double  frexp(double value, int* exp);
     float   frexpf(float value, int* exp);
+    real    frexpl(real value, int* exp) { return frexp(value, exp); }
 
     int     ilogb(double x);
     int     ilogbf(float x);
+    int     ilogbl(real x) { return ilogb(x); }
 
     double  ldexp(double x, int exp);
     float   ldexpf(float x, int exp);
+    real    ldexpl(real x, int exp) { return ldexp(x, exp); }
 
     double  log(double x);
     float   logf(float x);
@@ -649,15 +567,20 @@
 
     double  logb(double x);
     float   logbf(float x);
+    real    logbl(real x) { return logb(x); }
 
     double  modf(double value, double* iptr);
     float   modff(float value, float* iptr);
+    //real    modfl(real value, real *iptr); // nontrivial conversion
 
     double  scalbn(double x, int n);
     float   scalbnf(float x, int n);
+    real    scalbnl(real x, int n) { return scalbn(x, n); }
 
     double  scalbln(double x, c_long n);
     float   scalblnf(float x, c_long n);
+    real    scalblnl(real x, c_long n) { return scalbln(x, n); }
+
 
     double  cbrt(double x);
     float   cbrtf(float x);
@@ -665,9 +588,11 @@
 
     double  fabs(double x);
     float   fabsf(float x);
+    real    fabsl(real x) { return fabs(x); }
 
     double  hypot(double x, double y);
     float   hypotf(float x, float y);
+    real    hypotl(real x, real y) { return hypot(x, y); }
 
     double  pow(double x, double y);
     float   powf(float x, float y);
@@ -675,6 +600,7 @@
 
     double  sqrt(double x);
     float   sqrtf(float x);
+    real    sqrtl(real x) { return sqrt(x); }
 
     double  erf(double x);
     float   erff(float x);
@@ -694,18 +620,23 @@
 
     double  ceil(double x);
     float   ceilf(float x);
+    real    ceill(real x) { return ceil(x); }
 
     double  floor(double x);
     float   floorf(float x);
+    real    floorl(real x) { return floor(x); }
 
     double  nearbyint(double x);
     float   nearbyintf(float x);
+    real    nearbyintl(real x) { return nearbyint(x); }
 
     double  rint(double x);
     float   rintf(float x);
+    real    rintl(real x) { return rint(x); }
 
     c_long  lrint(double x);
     c_long  lrintf(float x);
+    c_long  lrintl(real x) { return lrint(x); }
 
     long    llrint(double x);
     long    llrintf(float x);
@@ -713,45 +644,63 @@
 
     double  round(double x);
     float   roundf(float x);
+    real    roundl(real x) { return round(x); }
 
     c_long  lround(double x);
     c_long  lroundf(float x);
+    c_long  lroundl(real x) { return lround(x); }
 
     long    llround(double x);
     long    llroundf(float x);
+    long    llroundl(real x) { return llround(x); }
 
     double  trunc(double x);
     float   truncf(float x);
+    real    truncl(real x) { return trunc(x); }
 
     double  fmod(double x, double y);
     float   fmodf(float x, float y);
+    real    fmodl(real x, real y) { return fmod(x, y); }
 
     double  remainder(double x, double y);
     float   remainderf(float x, float y);
+    real    remainderl(real x, real y) { return remainder(x, y); }
 
     double  remquo(double x, double y, int* quo);
     float   remquof(float x, float y, int* quo);
+    real    remquol(real x, real y, int* quo) { return remquo(x, y, quo); }
 
     double  copysign(double x, double y);
     float   copysignf(float x, float y);
+    real    copysignl(real x, real y) { return copysign(x, y); }
+
+//  double  nan(char* tagp);
+//  float   nanf(char* tagp);
+//  real    nanl(char* tagp);
 
     double  nextafter(double x, double y);
     float   nextafterf(float x, float y);
+    real    nextafterl(real x, real y) { return nextafter(x, y); }
 
     double  nexttoward(double x, real y);
     float   nexttowardf(float x, real y);
+    real    nexttowardl(real x, real y) { return nexttoward(x, y); }
 
     double  fdim(double x, double y);
     float   fdimf(float x, float y);
+    real    fdiml(real x, real y) { return fdim(x, y); }
 
     double  fmax(double x, double y);
     float   fmaxf(float x, float y);
+    real    fmaxl(real x, real y) { return fmax(x, y); }
 
     double  fmin(double x, double y);
     float   fminf(float x, float y);
+    real    fminl(real x, real y) { return fmin(x, y); }
 
     double  fma(double x, double y, double z);
     float   fmaf(float x, float y, float z);
+    real    fmal(real x, real y, real z) { return fma(x, y, z); }
 }
 else
 {
diff -ur druntime/src/core/stdc/stdio.d druntime/import/core/stdc/stdio.d
--- druntime/src/core/stdc/stdio.d	2010-09-14 04:17:34.000000000 +0100
+++ druntime/import/core/stdc/stdio.d	2009-11-30 07:02:54.000000000 +0000
@@ -18,11 +18,6 @@
     import core.stdc.config;
     import core.stdc.stddef; // for size_t
     import core.stdc.stdarg; // for va_list
-
-  version (FreeBSD)
-  {
-    import core.sys.posix.sys.types;
-  }
 }
 
 extern (C):
@@ -94,17 +89,17 @@
         L_tmpnam     = 1024
     }
 
-    struct __sbuf
+    private
     {
-        ubyte *_base;
-        int _size;
-    }
-    alias _iobuf __sFILE;
+        struct __sbuf
+        {
+            ubyte *_base;
+            int _size;
+        }
+        struct __sFILEX
+        {
 
-    union __mbstate_t // <sys/_types.h>
-    {
-        char[128]   _mbstate8;
-        long        _mbstateL;
+        }
     }
 }
 else
@@ -135,7 +130,6 @@
     }
     else version( linux )
     {
-        int     _flags;
         char*   _read_ptr;
         char*   _read_end;
         char*   _read_base;
@@ -186,37 +180,31 @@
     }
     else version( FreeBSD )
     {
-	ubyte*          _p;
-	int             _r;
-	int             _w;
-	short           _flags;
-	short           _file;
-	__sbuf          _bf;
-	int             _lbfsize;
-
-	void*           _cookie;
-	int     function(void*)                 _close;
-	int     function(void*, char*, int)     _read;
-	fpos_t  function(void*, fpos_t, int)    _seek;
-	int     function(void*, in char*, int)  _write;
-
-	__sbuf          _ub;
-	ubyte*          _up;
-	int             _ur;
-
-	ubyte[3]        _ubuf;
-	ubyte[1]        _nbuf;
-
-	__sbuf          _lb;
-
-	int             _blksize;
-	fpos_t          _offset;
-
-	pthread_mutex_t _fl_mutex;
-	pthread_t       _fl_owner;
-	int             _fl_count;
-	int             _orientation;
-	__mbstate_t     _mbstate;
+        ubyte*    _p;
+        int       _r;
+        int       _w;
+        short     _flags;
+        short     _file;
+        __sbuf    _bf;
+        int       _lbfsize;
+
+        void* function()                        _cookie;
+        int* function(void*)                    _close;
+        int* function(void*, char*, int)        _read;
+        fpos_t* function(void*, fpos_t, int)    _seek;
+        int* function(void*, char *, int)       _write;
+
+        __sbuf    _ub;
+        __sFILEX* _extra;
+        int       _ur;
+
+        ubyte[3]  _ubuf;
+        ubyte[1]  _nbuf;
+
+        __sbuf    _lb;
+
+        int       _blksize;
+        fpos_t    _offset;
     }
     else
     {
@@ -250,7 +238,7 @@
         _IONBF   = 4,
         _IOREAD  = 1,     // non-standard
         _IOWRT   = 2,     // non-standard
-        _IOMYBUF = 8,     // non-standard
+        _IOMYBUF = 8,     // non-standard       
         _IOEOF   = 0x10,  // non-standard
         _IOERR   = 0x20,  // non-standard
         _IOSTRG  = 0x40,  // non-standard
@@ -301,20 +289,11 @@
 }
 else version( FreeBSD )
 {
-    enum
-    {
-        _IOFBF = 0,
-        _IOLBF = 1,
-        _IONBF = 2,
-    }
+    private extern shared FILE[3] __sF;
 
-    private extern shared FILE* __stdinp;
-    private extern shared FILE* __stdoutp;
-    private extern shared FILE* __stderrp;
-
-    alias __stdinp  stdin;
-    alias __stdoutp stdout;
-    alias __stderrp stderr;
+    shared stdin  = &__sF[0];
+    shared stdout = &__sF[1];
+    shared stderr = &__sF[2];
 }
 else
 {
diff -ur druntime/src/core/stdc/tgmath.d druntime/import/core/stdc/tgmath.d
--- druntime/src/core/stdc/tgmath.d	2010-08-05 03:11:28.000000000 +0100
+++ druntime/import/core/stdc/tgmath.d	2009-09-25 21:07:38.000000000 +0100
@@ -19,7 +19,7 @@
 
 extern (C):
 
-version( FreeBSD )
+version( freebsd )
 {
     alias core.stdc.math.acos          acos;
     alias core.stdc.math.acosf         acos;
diff -ur druntime/src/core/stdc/time.d druntime/import/core/stdc/time.d
--- druntime/src/core/stdc/time.d	2010-08-05 03:11:28.000000000 +0100
+++ druntime/import/core/stdc/time.d	2009-11-30 06:59:02.000000000 +0000
@@ -64,7 +64,7 @@
 {
     enum clock_t CLOCKS_PER_SEC = 100;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum clock_t CLOCKS_PER_SEC = 128;
 }
@@ -94,7 +94,7 @@
 {
     void tzset(); // non-standard
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     void tzset(); // non-standard
 }
diff -ur druntime/src/core/sys/posix/arpa/inet.d druntime/import/core/sys/posix/arpa/inet.d
--- druntime/src/core/sys/posix/arpa/inet.d	2010-08-05 05:06:04.000000000 +0100
+++ druntime/import/core/sys/posix/arpa/inet.d	2009-09-25 21:07:38.000000000 +0100
@@ -88,10 +88,10 @@
     char*     inet_ntop(int, in void*, char*, socklen_t);
     int       inet_pton(int, in char*, void*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
-    alias uint16_t in_port_t;
-    alias uint32_t in_addr_t;
+    alias uint16_t in_port_t; // TODO: verify
+    alias uint32_t in_addr_t; // TODO: verify
 
     struct in_addr
     {
@@ -105,10 +105,10 @@
     uint32_t ntohl(uint32_t);
     uint16_t ntohs(uint16_t);
 
-    in_addr_t       inet_addr(in char*);
-    char*           inet_ntoa(in_addr);
-    const(char)*    inet_ntop(int, in void*, char*, socklen_t);
-    int             inet_pton(int, in char*, void*);
+    in_addr_t inet_addr(in char*);
+    char*     inet_ntoa(in_addr);
+    char*     inet_ntop(int, in void*, char*, socklen_t);
+    int       inet_pton(int, in char*, void*);
 }
 
 //
@@ -126,7 +126,7 @@
 {
     enum INET6_ADDRSTRLEN = 46;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum INET6_ADDRSTRLEN = 46;
 }
diff -ur druntime/src/core/sys/posix/config.d druntime/import/core/sys/posix/config.d
--- druntime/src/core/sys/posix/config.d	2010-08-26 22:23:26.000000000 +0100
+++ druntime/import/core/sys/posix/config.d	2009-09-25 21:07:38.000000000 +0100
@@ -19,7 +19,14 @@
 
 version( linux )
 {
+  version( X86_64 )
+  {
     enum bool  __USE_LARGEFILE64    = true;
+  }
+  else
+  {
+    enum bool  __USE_LARGEFILE64    = false;
+  }
     enum bool  __USE_FILE_OFFSET64  = __USE_LARGEFILE64;
     enum bool  __REDIRECT           = false;
 }
diff -ur druntime/src/core/sys/posix/dirent.d druntime/import/core/sys/posix/dirent.d
--- druntime/src/core/sys/posix/dirent.d	2010-08-05 05:54:34.000000000 +0100
+++ druntime/import/core/sys/posix/dirent.d	2009-09-25 21:07:38.000000000 +0100
@@ -108,7 +108,7 @@
 
     dirent* readdir(DIR*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum
     {
@@ -129,26 +129,36 @@
         uint      d_fileno;
         ushort    d_reclen;
         ubyte     d_type;
-        ubyte     d_namlen;
+        ubyte     d_namelen;
         char[256] d_name;
     }
 
-    typedef void* DIR;
+    struct _telldir;
+    struct DIR
+    {
+        int       dd_fd;
+        c_long    dd_loc;
+        c_long    dd_size;
+        char*     dd_buf;
+        int       dd_len;
+        c_long    dd_seek;
+        c_long    dd_rewind;
+        int       dd_flags;
+        void*     dd_lock;
+        _telldir* dd_td;
+    }
 
     dirent* readdir(DIR*);
 }
-else version( Posix )
+else
 {
     dirent* readdir(DIR*);
 }
 
-version( Posix )
-{
-    int     closedir(DIR*);
-    DIR*    opendir(in char*);
-    //dirent* readdir(DIR*);
-    void    rewinddir(DIR*);
-}
+int     closedir(DIR*);
+DIR*    opendir(in char*);
+//dirent* readdir(DIR*);
+void    rewinddir(DIR*);
 
 //
 // Thread-Safe Functions (TSF)
@@ -173,7 +183,7 @@
 {
     int readdir_r(DIR*, dirent*, dirent**);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     int readdir_r(DIR*, dirent*, dirent**);
 }
@@ -191,9 +201,3 @@
     void   seekdir(DIR*, c_long);
     c_long telldir(DIR*);
 }
-else version( FreeBSD )
-{
-    void   seekdir(DIR*, c_long);
-    c_long telldir(DIR*);
-}
-
diff -ur druntime/src/core/sys/posix/dlfcn.d druntime/import/core/sys/posix/dlfcn.d
--- druntime/src/core/sys/posix/dlfcn.d	2010-08-05 03:11:28.000000000 +0100
+++ druntime/import/core/sys/posix/dlfcn.d	2009-09-25 21:07:38.000000000 +0100
@@ -56,7 +56,7 @@
     void* dlopen(in char*, int);
     void* dlsym(void*, in char*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum RTLD_LAZY      = 1;
     enum RTLD_NOW       = 2;
diff -ur druntime/src/core/sys/posix/fcntl.d druntime/import/core/sys/posix/fcntl.d
--- druntime/src/core/sys/posix/fcntl.d	2010-08-05 06:15:56.000000000 +0100
+++ druntime/import/core/sys/posix/fcntl.d	2009-09-25 21:07:38.000000000 +0100
@@ -185,7 +185,7 @@
     int creat(in char*, mode_t);
     int open(in char*, int, ...);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum F_DUPFD        = 0;
     enum F_GETFD        = 1;
@@ -194,13 +194,9 @@
     enum F_SETFL        = 4;
     enum F_GETOWN       = 5;
     enum F_SETOWN       = 6;
-    enum F_GETLK        = 11;
-    enum F_SETLK        = 12;
-    enum F_SETLKW       = 13;
-    enum F_OGETLK       = 7;
-    enum F_OSETLK       = 8;
-    enum F_OSETLKW      = 9;
-    enum F_DUP2FD       = 10;
+    enum F_GETLK        = 7;
+    enum F_SETLK        = 8;
+    enum F_SETLKW       = 9;
 
     enum FD_CLOEXEC     = 1;
 
@@ -210,7 +206,7 @@
 
     enum O_CREAT        = 0x0200;
     enum O_EXCL         = 0x0800;
-    enum O_NOCTTY       = 0x8000;
+    enum O_NOCTTY       = 0;
     enum O_TRUNC        = 0x0400;
 
     enum O_RDONLY       = 0x0000;
@@ -231,28 +227,15 @@
         pid_t   l_pid;
         short   l_type;
         short   l_whence;
-        int     l_sysid;
-    }
-
-    struct oflock
-    {
-        off_t   l_start;
-        off_t   l_len;
-        pid_t   l_pid;
-        short   l_type;
-        short   l_whence;
     }
 
     int creat(in char*, mode_t);
     int open(in char*, int, ...);
 }
 
-version( Posix )
-{
-    //int creat(in char*, mode_t);
-    int fcntl(int, int, ...);
-    //int open(in char*, int, ...);
-}
+//int creat(in char*, mode_t);
+int fcntl(int, int, ...);
+//int open(in char*, int, ...);
 
 //
 // Advisory Information (ADV)
diff -ur druntime/src/core/sys/posix/inttypes.d druntime/import/core/sys/posix/inttypes.d
--- druntime/src/core/sys/posix/inttypes.d	2010-08-05 02:39:08.000000000 +0100
+++ druntime/import/core/sys/posix/inttypes.d	2009-09-25 21:07:38.000000000 +0100
@@ -27,13 +27,9 @@
 intmax_t  wcstoimax(in wchar_t*, wchar_t**, int);
 uintmax_t wcstoumax(in wchar_t*, wchar_t**, int);
 */
-
-version( Posix )
-{
-    intmax_t  imaxabs(intmax_t);
-    imaxdiv_t imaxdiv(intmax_t, intmax_t);
-    intmax_t  strtoimax(in char*, char**, int);
-    uintmax_t strtoumax(in char *, char**, int);
-    intmax_t  wcstoimax(in wchar_t*, wchar_t**, int);
-    uintmax_t wcstoumax(in wchar_t*, wchar_t**, int);
-}
+intmax_t  imaxabs(intmax_t);
+imaxdiv_t imaxdiv(intmax_t, intmax_t);
+intmax_t  strtoimax(in char*, char**, int);
+uintmax_t strtoumax(in char *, char**, int);
+intmax_t  wcstoimax(in wchar_t*, wchar_t**, int);
+uintmax_t wcstoumax(in wchar_t*, wchar_t**, int);
diff -ur druntime/src/core/sys/posix/net/if_.d druntime/import/core/sys/posix/net/if_.d
--- druntime/src/core/sys/posix/net/if_.d	2010-08-05 03:11:28.000000000 +0100
+++ druntime/import/core/sys/posix/net/if_.d	2009-09-25 21:07:38.000000000 +0100
@@ -65,7 +65,7 @@
     if_nameindex_t* if_nameindex();
     void            if_freenameindex(if_nameindex_t*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     struct if_nameindex_t
     {
diff -ur druntime/src/core/sys/posix/netinet/in_.d druntime/import/core/sys/posix/netinet/in_.d
--- druntime/src/core/sys/posix/netinet/in_.d	2010-10-10 21:37:54.000000000 +0100
+++ druntime/import/core/sys/posix/netinet/in_.d	2009-09-25 21:07:38.000000000 +0100
@@ -116,8 +116,10 @@
     
     enum INET_ADDRSTRLEN       = 16;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
+    private enum __SOCK_SIZE__ = 16;
+
     struct sockaddr_in
     {
         ubyte       sin_len;
@@ -218,8 +220,8 @@
         uint32_t    sin6_scope_id;
     }
 
-    extern __gshared immutable in6_addr in6addr_any;
-    extern __gshared immutable in6_addr in6addr_loopback;
+    extern in6_addr in6addr_any;
+    extern in6_addr in6addr_loopback;
 
     struct ipv6_mreq
     {
@@ -341,8 +343,8 @@
         uint32_t    sin6_scope_id;
     }
 
-    extern __gshared immutable in6_addr in6addr_any;
-    extern __gshared immutable in6_addr in6addr_loopback;
+    extern in6_addr in6addr_any;
+    extern in6_addr in6addr_loopback;
 
     struct ipv6_mreq
     {
@@ -443,148 +445,6 @@
                ((cast(uint8_t*) addr)[1] & 0xf) == 0xe;
     }
 }
-else version( FreeBSD )
-{
-    struct in6_addr
-    {
-        union
-        {
-            uint8_t[16] s6_addr;
-            uint16_t[8] s6_addr16;
-            uint32_t[4] s6_addr32;
-        }
-    }
-
-    struct sockaddr_in6
-    {
-        uint8_t     sin6_len;
-        sa_family_t sin6_family;
-        in_port_t   sin6_port;
-        uint32_t    sin6_flowinfo;
-        in6_addr    sin6_addr;
-        uint32_t    sin6_scope_id;
-    }
-
-    extern __gshared immutable in6_addr in6addr_any;
-    extern __gshared immutable in6_addr in6addr_loopback;
-
-    struct ipv6_mreq
-    {
-        in6_addr    ipv6mr_multiaddr;
-        uint        ipv6mr_interface;
-    }
-
-    enum INET6_ADDRSTRLEN    = 46;
-    enum IPPROTO_IPV6        = 41; // <netinet/in.h>
-
-    enum
-    {
-        IPV6_SOCKOPT_RESERVED1  = 3,
-        IPV6_UNICAST_HOPS       = 4,
-        IPV6_MULTICAST_IF       = 9,
-        IPV6_MULTICAST_HOPS     = 10,
-        IPV6_MULTICAST_LOOP     = 11,
-        IPV6_JOIN_GROUP         = 12,
-        IPV6_LEAVE_GROUP        = 13,
-        IPV6_PORTRANGE          = 14,
-        ICMP6_FILTER            = 18,
-        IPV6_CHECKSUM           = 26,
-        IPV6_V6ONLY             = 27,
-    }
-
-    private enum
-    {
-        __IPV6_ADDR_SCOPE_NODELOCAL     = 0x01,
-        __IPV6_ADDR_SCOPE_INTFACELOCAL  = 0x01,
-        __IPV6_ADDR_SCOPE_LINKLOCAL     = 0x02,
-        __IPV6_ADDR_SCOPE_SITELOCAL     = 0x05,
-        __IPV6_ADDR_SCOPE_ORGLOCAL      = 0x08,
-        __IPV6_ADDR_SCOPE_GLOBAL        = 0x0e,
-    }
-
-    // macros
-    extern (D) int IN6_IS_ADDR_UNSPECIFIED( in in6_addr* a )
-    {
-        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == 0);
-    }
-
-    extern (D) int IN6_IS_ADDR_LOOPBACK( in in6_addr* a )
-    {
-        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) == ntohl(1));
-    }
-
-    extern (D) int IN6_IS_ADDR_V4COMPAT( in in6_addr* a )
-    {
-        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[12]) != ntohl(1));
-    }
-
-    extern (D) int IN6_IS_ADDR_V4MAPPED( in in6_addr* a )
-    {
-        return (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[0]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[4]) == 0) &&
-               (*cast(const uint32_t*) cast(const void*) (&a.s6_addr[8]) == ntohl(0x0000ffff));
-    }
-
-    extern (D) int IN6_IS_ADDR_LINKLOCAL( in in6_addr* a )
-    {
-        return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0x80;
-    }
-
-    extern (D) int IN6_IS_ADDR_SITELOCAL( in in6_addr* a )
-    {
-        return a.s6_addr[0] == 0xfe && (a.s6_addr[1] & 0xc0) == 0xc0;
-    }
-
-    extern (D) int IN6_IS_ADDR_MULTICAST( in in6_addr* a )
-    {
-        return a.s6_addr[0] == 0xff;
-    }
-
-    extern (D) uint8_t __IPV6_ADDR_MC_SCOPE( in in6_addr* a )
-    {
-        return a.s6_addr[1] & 0x0f;
-    }
-
-    extern (D) int IN6_IS_ADDR_MC_NODELOCAL( in in6_addr* a )
-    {
-        return IN6_IS_ADDR_MULTICAST(a) &&
-               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_NODELOCAL;
-    }
-
-    extern (D) int IN6_IS_ADDR_MC_LINKLOCAL( in in6_addr* a )
-    {
-        return IN6_IS_ADDR_MULTICAST(a) &&
-               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_LINKLOCAL;
-    }
-
-    extern (D) int IN6_IS_ADDR_MC_SITELOCAL( in in6_addr* a )
-    {
-        return IN6_IS_ADDR_MULTICAST(a) &&
-               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL;
-    }
-
-    extern (D) int IN6_IS_ADDR_MC_ORGLOCAL( in in6_addr* a )
-    {
-        return IN6_IS_ADDR_MULTICAST(a) &&
-               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL;
-    }
-
-    extern (D) int IN6_IS_ADDR_MC_GLOBAL( in in6_addr* a )
-    {
-        return IN6_IS_ADDR_MULTICAST(a) &&
-               __IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_GLOBAL;
-    }
-}
 
 
 //
@@ -594,7 +454,7 @@
 IPPROTO_RAW
 */
 
-version( linux )
+version (linux )
 {
     enum uint IPPROTO_RAW = 255;
 }
@@ -602,8 +462,3 @@
 {
     enum uint IPPROTO_RAW = 255;
 }
-else version( FreeBSD )
-{
-    enum uint IPPROTO_RAW = 255;
-}
-
diff -ur druntime/src/core/sys/posix/netinet/tcp.d druntime/import/core/sys/posix/netinet/tcp.d
--- druntime/src/core/sys/posix/netinet/tcp.d	2010-08-05 03:11:28.000000000 +0100
+++ druntime/import/core/sys/posix/netinet/tcp.d	2009-09-25 21:07:38.000000000 +0100
@@ -32,7 +32,7 @@
 {
     enum TCP_NODELAY = 1;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum TCP_NODELAY = 1;
 }
diff -ur druntime/src/core/sys/posix/poll.d druntime/import/core/sys/posix/poll.d
--- druntime/src/core/sys/posix/poll.d	2010-08-05 06:20:20.000000000 +0100
+++ druntime/import/core/sys/posix/poll.d	2009-09-25 21:07:38.000000000 +0100
@@ -105,10 +105,8 @@
 
     int poll(pollfd*, nfds_t, int);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
-    alias uint nfds_t;
-
     struct pollfd
     {
         int     fd;
@@ -116,6 +114,8 @@
         short   revents;
     };
 
+    alias uint nfds_t;
+
     enum
     {
         POLLIN      = 0x0001,
diff -ur druntime/src/core/sys/posix/pthread.d druntime/import/core/sys/posix/pthread.d
--- druntime/src/core/sys/posix/pthread.d	2010-08-05 06:25:46.000000000 +0100
+++ druntime/import/core/sys/posix/pthread.d	2009-09-25 21:07:38.000000000 +0100
@@ -18,8 +18,6 @@
 public import core.sys.posix.sched;
 public import core.sys.posix.time;
 
-import core.stdc.stdint;
-
 extern (C):
 
 //
@@ -170,57 +168,15 @@
         PTHREAD_PROCESS_SHARED  = 1
     }
 }
-else version( FreeBSD )
-{
-    enum
-    {
-        PTHREAD_DETACHED            = 0x1,
-        PTHREAD_INHERIT_SCHED       = 0x4,
-        PTHREAD_NOFLOAT             = 0x8,
 
-        PTHREAD_CREATE_DETACHED     = PTHREAD_DETACHED,
-        PTHREAD_CREATE_JOINABLE     = 0,
-        PTHREAD_EXPLICIT_SCHED      = 0,
-    }
-
-    enum
-    {
-        PTHREAD_PROCESS_PRIVATE     = 0,
-        PTHREAD_PROCESS_SHARED      = 1,
-    }
-
-    enum
-    {
-        PTHREAD_CANCEL_ENABLE       = 0,
-        PTHREAD_CANCEL_DISABLE      = 1,
-        PTHREAD_CANCEL_DEFERRED     = 0,
-        PTHREAD_CANCEL_ASYNCHRONOUS = 2,
-    }
-
-    enum PTHREAD_CANCELED = cast(void*) -1;
-
-    enum PTHREAD_NEEDS_INIT = 0;
-    enum PTHREAD_DONE_INIT  = 1;
-
-    //enum PTHREAD_ONCE_INIT = { PTHREAD_NEEDS_INIT, null };
-
-    enum PTHREAD_MUTEX_INITIALIZER              = null;
-    enum PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP  = null;
-    enum PTHREAD_COND_INITIALIZER               = null;
-    enum PTHREAD_RWLOCK_INITIALIZER             = null;
-}
-
-version( Posix )
-{
-    int pthread_atfork(void function(), void function(), void function());
-    int pthread_attr_destroy(pthread_attr_t*);
-    int pthread_attr_getdetachstate(in pthread_attr_t*, int*);
-    int pthread_attr_getschedparam(in pthread_attr_t*, sched_param*);
-    int pthread_attr_init(pthread_attr_t*);
-    int pthread_attr_setdetachstate(pthread_attr_t*, int);
-    int pthread_attr_setschedparam(in pthread_attr_t*, sched_param*);
-    int pthread_cancel(pthread_t);
-}
+int pthread_atfork(void function(), void function(), void function());
+int pthread_attr_destroy(pthread_attr_t*);
+int pthread_attr_getdetachstate(in pthread_attr_t*, int*);
+int pthread_attr_getschedparam(in pthread_attr_t*, sched_param*);
+int pthread_attr_init(pthread_attr_t*);
+int pthread_attr_setdetachstate(pthread_attr_t*, int);
+int pthread_attr_setschedparam(in pthread_attr_t*, sched_param*);
+int pthread_cancel(pthread_t);
 
 version( linux )
 {
@@ -287,80 +243,50 @@
         }
     }
 }
-else version( FreeBSD )
-{
-    alias void function(void*) _pthread_cleanup_routine;
-
-    struct _pthread_cleanup_info
-    {
-        uintptr_t[8]    pthread_cleanup_pad;
-    }
-
-    struct pthread_cleanup
-    {
-        _pthread_cleanup_info __cleanup_info__ = void;
-
-        void push()( _pthread_cleanup_routine cleanup_routine, void* cleanup_arg )
-        {
-            __pthread_cleanup_push_imp( cleanup_routine, cleanup_arg, &__cleanup_info__ );
-        }
-
-        void pop()( int execute )
-        {
-            __pthread_cleanup_pop_imp( execute );
-        }
-    }
-
-    void __pthread_cleanup_push_imp(_pthread_cleanup_routine, void*, _pthread_cleanup_info*);
-    void __pthread_cleanup_pop_imp(int);
-}
-else version( Posix )
+else
 {
     void pthread_cleanup_push(void function(void*), void*);
     void pthread_cleanup_pop(int);
 }
 
-version( Posix )
-{
-    int pthread_cond_broadcast(pthread_cond_t*);
-    int pthread_cond_destroy(pthread_cond_t*);
-    int pthread_cond_init(in pthread_cond_t*, pthread_condattr_t*);
-    int pthread_cond_signal(pthread_cond_t*);
-    int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, in timespec*);
-    int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
-    int pthread_condattr_destroy(pthread_condattr_t*);
-    int pthread_condattr_init(pthread_condattr_t*);
-    int pthread_create(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
-    int pthread_detach(pthread_t);
-    int pthread_equal(pthread_t, pthread_t);
-    void pthread_exit(void*);
-    void* pthread_getspecific(pthread_key_t);
-    int pthread_join(pthread_t, void**);
-    int pthread_key_create(pthread_key_t*, void function(void*));
-    int pthread_key_delete(pthread_key_t);
-    int pthread_mutex_destroy(pthread_mutex_t*);
-    int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*);
-    int pthread_mutex_lock(pthread_mutex_t*);
-    int pthread_mutex_trylock(pthread_mutex_t*);
-    int pthread_mutex_unlock(pthread_mutex_t*);
-    int pthread_mutexattr_destroy(pthread_mutexattr_t*);
-    int pthread_mutexattr_init(pthread_mutexattr_t*);
-    int pthread_once(pthread_once_t*, void function());
-    int pthread_rwlock_destroy(pthread_rwlock_t*);
-    int pthread_rwlock_init(in pthread_rwlock_t*, pthread_rwlockattr_t*);
-    int pthread_rwlock_rdlock(pthread_rwlock_t*);
-    int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
-    int pthread_rwlock_trywrlock(pthread_rwlock_t*);
-    int pthread_rwlock_unlock(pthread_rwlock_t*);
-    int pthread_rwlock_wrlock(pthread_rwlock_t*);
-    int pthread_rwlockattr_destroy(pthread_rwlockattr_t*);
-    int pthread_rwlockattr_init(pthread_rwlockattr_t*);
-    pthread_t pthread_self();
-    int pthread_setcancelstate(int, int*);
-    int pthread_setcanceltype(int, int*);
-    int pthread_setspecific(pthread_key_t, in void*);
-    void pthread_testcancel();
-}
+int pthread_cond_broadcast(pthread_cond_t*);
+int pthread_cond_destroy(pthread_cond_t*);
+int pthread_cond_init(in pthread_cond_t*, pthread_condattr_t*);
+int pthread_cond_signal(pthread_cond_t*);
+int pthread_cond_timedwait(pthread_cond_t*, pthread_mutex_t*, in timespec*);
+int pthread_cond_wait(pthread_cond_t*, pthread_mutex_t*);
+int pthread_condattr_destroy(pthread_condattr_t*);
+int pthread_condattr_init(pthread_condattr_t*);
+int pthread_create(pthread_t*, in pthread_attr_t*, void* function(void*), void*);
+int pthread_detach(pthread_t);
+int pthread_equal(pthread_t, pthread_t);
+void pthread_exit(void*);
+void* pthread_getspecific(pthread_key_t);
+int pthread_join(pthread_t, void**);
+int pthread_key_create(pthread_key_t*, void function(void*));
+int pthread_key_delete(pthread_key_t);
+int pthread_mutex_destroy(pthread_mutex_t*);
+int pthread_mutex_init(pthread_mutex_t*, pthread_mutexattr_t*);
+int pthread_mutex_lock(pthread_mutex_t*);
+int pthread_mutex_trylock(pthread_mutex_t*);
+int pthread_mutex_unlock(pthread_mutex_t*);
+int pthread_mutexattr_destroy(pthread_mutexattr_t*);
+int pthread_mutexattr_init(pthread_mutexattr_t*);
+int pthread_once(pthread_once_t*, void function());
+int pthread_rwlock_destroy(pthread_rwlock_t*);
+int pthread_rwlock_init(in pthread_rwlock_t*, pthread_rwlockattr_t*);
+int pthread_rwlock_rdlock(pthread_rwlock_t*);
+int pthread_rwlock_tryrdlock(pthread_rwlock_t*);
+int pthread_rwlock_trywrlock(pthread_rwlock_t*);
+int pthread_rwlock_unlock(pthread_rwlock_t*);
+int pthread_rwlock_wrlock(pthread_rwlock_t*);
+int pthread_rwlockattr_destroy(pthread_rwlockattr_t*);
+int pthread_rwlockattr_init(pthread_rwlockattr_t*);
+pthread_t pthread_self();
+int pthread_setcancelstate(int, int*);
+int pthread_setcanceltype(int, int*);
+int pthread_setspecific(pthread_key_t, in void*);
+void pthread_testcancel();
 
 //
 // Barrier (BAR)
@@ -389,18 +315,6 @@
     int pthread_barrierattr_init(pthread_barrierattr_t*);
     int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
 }
-else version( FreeBSD )
-{
-    enum PTHREAD_BARRIER_SERIAL_THREAD = -1;
-
-    int pthread_barrier_destroy(pthread_barrier_t*);
-    int pthread_barrier_init(pthread_barrier_t*, in pthread_barrierattr_t*, uint);
-    int pthread_barrier_wait(pthread_barrier_t*);
-    int pthread_barrierattr_destroy(pthread_barrierattr_t*);
-    int pthread_barrierattr_getpshared(in pthread_barrierattr_t*, int*);
-    int pthread_barrierattr_init(pthread_barrierattr_t*);
-    int pthread_barrierattr_setpshared(pthread_barrierattr_t*, int);
-}
 
 //
 // Clock (CS)
@@ -429,14 +343,6 @@
     int pthread_spin_trylock(pthread_spinlock_t*);
     int pthread_spin_unlock(pthread_spinlock_t*);
 }
-else version( FreeBSD )
-{
-    int pthread_spin_init(pthread_spinlock_t*, int);
-    int pthread_spin_destroy(pthread_spinlock_t*);
-    int pthread_spin_lock(pthread_spinlock_t*);
-    int pthread_spin_trylock(pthread_spinlock_t*);
-    int pthread_spin_unlock(pthread_spinlock_t*);
-}
 
 //
 // XOpen (XSI)
@@ -483,7 +389,7 @@
     int pthread_mutexattr_settype(pthread_mutexattr_t*, int);
     int pthread_setconcurrency(int);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum
     {
@@ -514,10 +420,6 @@
 {
     int pthread_getcpuclockid(pthread_t, clockid_t*);
 }
-else version( FreeBSD )
-{
-    int pthread_getcpuclockid(pthread_t, clockid_t*);
-}
 
 //
 // Timeouts (TMO)
@@ -540,12 +442,6 @@
     int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
     int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
 }
-else version( FreeBSD )
-{
-    int pthread_mutex_timedlock(pthread_mutex_t*, timespec*);
-    int pthread_rwlock_timedrdlock(pthread_rwlock_t*, in timespec*);
-    int pthread_rwlock_timedwrlock(pthread_rwlock_t*, in timespec*);
-}
 
 //
 // Priority (TPI|TPP)
@@ -617,7 +513,7 @@
     int pthread_setschedparam(pthread_t, int, in sched_param*);
     //int pthread_setschedprio(pthread_t, int);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum
     {
@@ -666,7 +562,7 @@
     int pthread_attr_setstackaddr(pthread_attr_t*, void*);
     int pthread_attr_setstacksize(pthread_attr_t*, size_t);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     int pthread_attr_getstack(in pthread_attr_t*, void**, size_t*);
     int pthread_attr_getstackaddr(in pthread_attr_t*, void**);
@@ -687,13 +583,3 @@
 int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
 int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
 */
-version( FreeBSD )
-{
-    int pthread_condattr_getpshared(in pthread_condattr_t*, int*);
-    int pthread_condattr_setpshared(pthread_condattr_t*, int);
-    int pthread_mutexattr_getpshared(in pthread_mutexattr_t*, int*);
-    int pthread_mutexattr_setpshared(pthread_mutexattr_t*, int);
-    int pthread_rwlockattr_getpshared(in pthread_rwlockattr_t*, int*);
-    int pthread_rwlockattr_setpshared(pthread_rwlockattr_t*, int);
-}
-
diff -ur druntime/src/core/sys/posix/pwd.d druntime/import/core/sys/posix/pwd.d
--- druntime/src/core/sys/posix/pwd.d	2010-08-05 03:11:28.000000000 +0100
+++ druntime/import/core/sys/posix/pwd.d	2009-09-25 21:07:38.000000000 +0100
@@ -64,7 +64,7 @@
         time_t  pw_expire;
     }
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     struct passwd
     {
@@ -82,11 +82,8 @@
     }
 }
 
-version( Posix )
-{
-    passwd* getpwnam(in char*);
-    passwd* getpwuid(uid_t);
-}
+passwd* getpwnam(in char*);
+passwd* getpwuid(uid_t);
 
 //
 // Thread-Safe Functions (TSF)
@@ -106,7 +103,7 @@
     int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
     int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     int getpwnam_r(in char*, passwd*, char*, size_t, passwd**);
     int getpwuid_r(uid_t, passwd*, char*, size_t, passwd**);
@@ -132,7 +129,7 @@
     passwd* getpwent();
     void    setpwent();
 }
-else version ( FreeBSD )
+else version ( freebsd )
 {
     void    endpwent();
     passwd* getpwent();
diff -ur druntime/src/core/sys/posix/sched.d druntime/import/core/sys/posix/sched.d
--- druntime/src/core/sys/posix/sched.d	2010-08-05 06:26:40.000000000 +0100
+++ druntime/import/core/sys/posix/sched.d	2009-09-25 21:07:38.000000000 +0100
@@ -70,7 +70,7 @@
         byte[__PTHREAD_MUTEX_SIZE__]    __opaque;
     }
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     struct sched_param
     {
@@ -80,15 +80,13 @@
     enum SCHED_FIFO     = 1;
     enum SCHED_OTHER    = 2;
     enum SCHED_RR       = 3;
+    //SCHED_SPORADIC (SS|TSP)
 }
 
-version( Posix )
-{
-    int sched_getparam(pid_t, sched_param*);
-    int sched_getscheduler(pid_t);
-    int sched_setparam(pid_t, in sched_param*);
-    int sched_setscheduler(pid_t, int, in sched_param*);
-}
+int sched_getparam(pid_t, sched_param*);
+int sched_getscheduler(pid_t);
+int sched_setparam(pid_t, in sched_param*);
+int sched_setscheduler(pid_t, int, in sched_param*);
 
 //
 // Thread (THR)
@@ -105,7 +103,7 @@
 {
     int sched_yield();
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     int sched_yield();
 }
@@ -131,7 +129,7 @@
     int sched_get_priority_max(int);
     //int sched_rr_get_interval(pid_t, timespec*); // FIXME: unavailable?
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     int sched_get_priority_min(int);
     int sched_get_priority_max(int);
diff -ur druntime/src/core/sys/posix/semaphore.d druntime/import/core/sys/posix/semaphore.d
--- druntime/src/core/sys/posix/semaphore.d	2010-08-05 06:27:28.000000000 +0100
+++ druntime/import/core/sys/posix/semaphore.d	2009-09-25 21:07:38.000000000 +0100
@@ -61,25 +61,25 @@
 
     enum SEM_FAILED = cast(sem_t*) null;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
+    enum SEM_MAGIC  = 0x09fa4012;
+    enum SEM_USER   = 0;
+
     alias void* sem_t;
 
     enum SEM_FAILED = cast(sem_t*) null;
 }
 
-version( Posix )
-{
-    int sem_close(sem_t*);
-    int sem_destroy(sem_t*);
-    int sem_getvalue(sem_t*, int*);
-    int sem_init(sem_t*, int, uint);
-    sem_t* sem_open(in char*, int, ...);
-    int sem_post(sem_t*);
-    int sem_trywait(sem_t*);
-    int sem_unlink(in char*);
-    int sem_wait(sem_t*);
-}
+int sem_close(sem_t*);
+int sem_destroy(sem_t*);
+int sem_getvalue(sem_t*, int*);
+int sem_init(sem_t*, int, uint);
+sem_t* sem_open(in char*, int, ...);
+int sem_post(sem_t*);
+int sem_trywait(sem_t*);
+int sem_unlink(in char*);
+int sem_wait(sem_t*);
 
 //
 // Timeouts (TMO)
@@ -96,7 +96,7 @@
 {
     int sem_timedwait(sem_t*, in timespec*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     int sem_timedwait(sem_t*, in timespec*);
 }
diff -ur druntime/src/core/sys/posix/setjmp.d druntime/import/core/sys/posix/setjmp.d
--- druntime/src/core/sys/posix/setjmp.d	2010-08-05 06:30:16.000000000 +0100
+++ druntime/import/core/sys/posix/setjmp.d	2009-09-25 21:07:38.000000000 +0100
@@ -24,8 +24,8 @@
 /*
 jmp_buf
 
-int  setjmp(ref jmp_buf);
-void longjmp(ref jmp_buf, int);
+int  setjmp(jmp_buf);
+void longjmp(jmp_buf, int);
 */
 
 version( linux )
@@ -71,32 +71,7 @@
     alias __jmp_buf_tag[1] jmp_buf;
 
     alias _setjmp setjmp; // see XOpen block
-    void longjmp(ref jmp_buf, int);
-}
-else version( FreeBSD )
-{
-    // <machine/setjmp.h>
-    version( X86 )
-    {
-        enum _JBLEN = 11;
-        struct _jmp_buf { int[_JBLEN + 1] _jb; }
-    }
-    else version( X86_64)
-    {
-        enum _JBLEN = 12;
-        struct _jmp_buf { c_long[_JBLEN] _jb; }
-    }
-    else version( SPARC )
-    {
-        enum _JBLEN = 5;
-        struct _jmp_buf { c_long[_JBLEN + 1] _jb; }
-    }
-    else
-        static assert(0);
-    alias _jmp_buf[1] jmp_buf;
-
-    int  setjmp(ref jmp_buf);
-    void longjmp(ref jmp_buf, int);
+    void longjmp(jmp_buf, int);
 }
 
 //
@@ -117,34 +92,6 @@
     alias __sigsetjmp sigsetjmp;
     void siglongjmp(sigjmp_buf, int);
 }
-else version( FreeBSD )
-{
-    // <machine/setjmp.h>
-    version( X86 )
-    {
-        struct _sigjmp_buf { int[_JBLEN + 1] _ssjb; }
-    }
-    else version( X86_64)
-    {
-        struct _sigjmp_buf { c_long[_JBLEN] _sjb; }
-    }
-    else version( SPARC )
-    {
-        enum _JBLEN         = 5;
-        enum _JB_FP         = 0;
-        enum _JB_PC         = 1;
-        enum _JB_SP         = 2;
-        enum _JB_SIGMASK    = 3;
-        enum _JB_SIGFLAG    = 5;
-        struct _sigjmp_buf { c_long[_JBLEN + 1] _sjb; }
-    }
-    else
-        static assert(0);
-    alias _sigjmp_buf[1] sigjmp_buf;
-
-    int  sigsetjmp(ref sigjmp_buf);
-    void siglongjmp(ref sigjmp_buf, int);
-}
 
 //
 // XOpen (XSI)
@@ -156,11 +103,6 @@
 
 version( linux )
 {
-    int  _setjmp(ref jmp_buf);
-    void _longjmp(ref jmp_buf, int);
-}
-else version( FreeBSD )
-{
-    int  _setjmp(ref jmp_buf);
-    void _longjmp(ref jmp_buf, int);
+    int  _setjmp(jmp_buf);
+    void _longjmp(jmp_buf, int);
 }
diff -ur druntime/src/core/sys/posix/signal.d druntime/import/core/sys/posix/signal.d
--- druntime/src/core/sys/posix/signal.d	2010-08-05 06:32:46.000000000 +0100
+++ druntime/import/core/sys/posix/signal.d	2010-05-05 23:20:22.000000000 +0100
@@ -21,6 +21,9 @@
 
 extern (C):
 
+private alias void function(int) sigfn_t;
+private alias void function(int, siginfo_t*, void*) sigactfn_t;
+
 //
 // Required
 //
@@ -83,30 +86,24 @@
 
 //sig_atomic_t (defined in core.stdc.signal)
 
-version( Posix )
+enum
 {
-    private alias void function(int) sigfn_t;
-    private alias void function(int, siginfo_t*, void*) sigactfn_t;
-    
-    enum
-    {
-      SIGEV_SIGNAL,
-      SIGEV_NONE,
-      SIGEV_THREAD
-    }
+  SIGEV_SIGNAL,
+  SIGEV_NONE,
+  SIGEV_THREAD
+}
 
-    union sigval
-    {
-        int     sival_int;
-        void*   sival_ptr;
-    }
+union sigval
+{
+    int     sival_int;
+    void*   sival_ptr;
+}
 
-    private extern (C) int __libc_current_sigrtmin();
-    private extern (C) int __libc_current_sigrtmax();
+private extern (C) int __libc_current_sigrtmin();
+private extern (C) int __libc_current_sigrtmax();
 
-    alias __libc_current_sigrtmin SIGRTMIN;
-    alias __libc_current_sigrtmax SIGRTMAX;
-}
+alias __libc_current_sigrtmin SIGRTMIN;
+alias __libc_current_sigrtmax SIGRTMAX;
 
 version( linux )
 {
@@ -156,7 +153,7 @@
     enum SIGUSR2    = 31;
     enum SIGURG     = 16;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     //SIGABRT (defined in core.stdc.signal)
     enum SIGALRM    = 14;
@@ -181,42 +178,25 @@
     enum SIGURG     = 16;
 }
 
-version( FreeBSD )
+struct sigaction_t
 {
-    struct sigaction_t
+    static if( true /* __USE_POSIX199309 */ )
     {
         union
         {
             sigfn_t     sa_handler;
             sigactfn_t  sa_sigaction;
         }
-        int      sa_flags;
-        sigset_t sa_mask;
     }
-}
-else
-version( Posix )
-{
-    struct sigaction_t
+    else
     {
-        static if( true /* __USE_POSIX199309 */ )
-        {
-            union
-            {
-                sigfn_t     sa_handler;
-                sigactfn_t  sa_sigaction;
-            }
-        }
-        else
-        {
-            sigfn_t     sa_handler;
-        }
-        sigset_t        sa_mask;
-        int             sa_flags;
+        sigfn_t     sa_handler;
+    }
+    sigset_t        sa_mask;
+    int             sa_flags;
 
-        version( OSX ) {} else {
-        void function() sa_restorer;
-        }
+    version( OSX ) {} else {
+    void function() sa_restorer;
     }
 }
 
@@ -453,7 +433,7 @@
     int sigsuspend(in sigset_t*);
     int sigwait(in sigset_t*, int*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     struct sigset_t
     {
@@ -504,7 +484,7 @@
     }
 
     int kill(pid_t, int);
-    int sigaction(int, in sigaction_t*, sigaction_t*);
+    int sigaction(int, in sigaction_t*, sigaction_t);
     int sigaddset(sigset_t*, int);
     int sigdelset(sigset_t*, int);
     int sigemptyset(sigset_t *);
@@ -826,125 +806,6 @@
     int sigpause(int);
     int sigrelse(int);
 }
-else version( FreeBSD )
-{
-    // No SIGPOLL on *BSD
-    enum SIGPROF        = 27;
-    enum SIGSYS         = 12;
-    enum SIGTRAP        = 5;
-    enum SIGVTALRM      = 26;
-    enum SIGXCPU        = 24;
-    enum SIGXFSZ        = 25;
-
-    enum
-    {
-        SA_ONSTACK      = 0x0001,
-        SA_RESTART      = 0x0002,
-        SA_RESETHAND    = 0x0004,
-        SA_NODEFER      = 0x0010,
-        SA_NOCLDWAIT    = 0x0020,
-        SA_SIGINFO      = 0x0040,
-    }
-
-    enum
-    {
-        SS_ONSTACK = 0x0001,
-        SS_DISABLE = 0x0004,
-    }
-
-    enum MINSIGSTKSZ = 512 * 4;
-    enum SIGSTKSZ    = (MINSIGSTKSZ + 32768);
-;
-    //ucontext_t (defined in core.sys.posix.ucontext)
-    //mcontext_t (defined in core.sys.posix.ucontext)
-
-    struct stack_t
-    {
-        void*   ss_sp;
-        size_t  ss_size;
-        int     ss_flags;
-    }
-
-    struct sigstack
-    {
-        void*   ss_sp;
-        int     ss_onstack;
-    }
-
-    enum
-    {
-        ILL_ILLOPC = 1,
-        ILL_ILLOPN,
-        ILL_ILLADR,
-        ILL_ILLTRP,
-        ILL_PRVOPC,
-        ILL_PRVREG,
-        ILL_COPROC,
-        ILL_BADSTK,
-    }
-
-    enum
-    {
-        BUS_ADRALN = 1,
-        BUS_ADRERR,
-        BUS_OBJERR,
-    }
-
-    enum
-    {
-        SEGV_MAPERR = 1,
-        SEGV_ACCERR,
-    }
-
-    enum
-    {
-        FPE_INTOVF = 1,
-        FPE_INTDIV,
-        FPE_FLTDIV,
-        FPE_FLTOVF,
-        FPE_FLTUND,
-        FPE_FLTRES,
-        FPE_FLTINV,
-        FPE_FLTSUB,
-    }
-
-    enum
-    {
-        TRAP_BRKPT = 1,
-        TRAP_TRACE,
-    }
-
-    enum
-    {
-        CLD_EXITED = 1,
-        CLD_KILLED,
-        CLD_DUMPED,
-        CLD_TRAPPED,
-        CLD_STOPPED,
-        CLD_CONTINUED,
-    }
-
-    enum
-    {
-        POLL_IN = 1,
-        POLL_OUT,
-        POLL_MSG,
-        POLL_ERR,
-        POLL_PRI,
-        POLL_HUP,
-    }
-
-    //sigfn_t bsd_signal(int sig, sigfn_t func);
-    sigfn_t sigset(int sig, sigfn_t func);
-
-    int killpg(pid_t, int);
-    int sigaltstack(in stack_t*, stack_t*);
-    int sighold(int);
-    int sigignore(int);
-    int siginterrupt(int, int);
-    int sigpause(int);
-    int sigrelse(int);
-}
 
 //
 // Timer (TMR)
@@ -976,7 +837,7 @@
         c_long  tv_nsec;
     }
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     struct timespec
     {
@@ -1039,7 +900,7 @@
     int sigtimedwait(in sigset_t*, siginfo_t*, in timespec*);
     int sigwaitinfo(in sigset_t*, siginfo_t*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     struct sigevent
     {
@@ -1080,7 +941,7 @@
     int pthread_kill(pthread_t, int);
     int pthread_sigmask(int, in sigset_t*, sigset_t*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     int pthread_kill(pthread_t, int);
     int pthread_sigmask(int, in sigset_t*, sigset_t*);
diff -ur druntime/src/core/sys/posix/stdio.d druntime/import/core/sys/posix/stdio.d
--- druntime/src/core/sys/posix/stdio.d	2010-08-05 02:39:08.000000000 +0100
+++ druntime/import/core/sys/posix/stdio.d	2009-09-25 21:07:38.000000000 +0100
@@ -136,7 +136,6 @@
 int    fseeko(FILE*, off_t, int);
 off_t  ftello(FILE*);
 char*  gets(char*);
-int    pclose(FILE*);
 FILE*  popen(in char*, in char*);
 */
 
@@ -164,23 +163,19 @@
     off_t ftello(FILE*);
   }
 }
-else version( Posix )
+else
 {
     int   fseeko(FILE*, off_t, int);
     off_t ftello(FILE*);
 }
 
-version( Posix )
-{
-    char*  ctermid(char*);
-    FILE*  fdopen(int, in char*);
-    int    fileno(FILE*);
-    //int    fseeko(FILE*, off_t, int);
-    //off_t  ftello(FILE*);
-    char*  gets(char*);
-    int    pclose(FILE*);
-    FILE*  popen(in char*, in char*);
-}
+char*  ctermid(char*);
+FILE*  fdopen(int, in char*);
+int    fileno(FILE*);
+//int    fseeko(FILE*, off_t, int);
+//off_t  ftello(FILE*);
+char*  gets(char*);
+FILE*  popen(in char*, in char*);
 
 //
 // Thread-Safe Functions (TSF)
diff -ur druntime/src/core/sys/posix/stdlib.d druntime/import/core/sys/posix/stdlib.d
--- druntime/src/core/sys/posix/stdlib.d	2010-08-05 06:33:28.000000000 +0100
+++ druntime/import/core/sys/posix/stdlib.d	2009-09-25 21:07:38.000000000 +0100
@@ -83,10 +83,6 @@
 {
     int posix_memalign(void**, size_t, size_t);
 }
-else version( FreeBSD )
-{
-    int posix_memalign(void**, size_t, size_t);
-}
 
 //
 // C Extension (CX)
@@ -110,7 +106,7 @@
 
     void* valloc(size_t); // LEGACY non-standard
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     int setenv(in char*, in char*, int);
     int unsetenv(in char*);
@@ -133,7 +129,7 @@
 {
     int rand_r(uint*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     int rand_r(uint*);
 }
@@ -154,27 +150,27 @@
 c_long a64l(in char*);
 double drand48();
 char*  ecvt(double, int, int *, int *); // LEGACY
-double erand48(ref ushort[3]);
+double erand48(ushort[3]);
 char*  fcvt(double, int, int *, int *); // LEGACY
 char*  gcvt(double, int, char*); // LEGACY
 // per spec: int getsubopt(char** char* const*, char**);
 int    getsubopt(char**, in char**, char**);
 int    grantpt(int);
 char*  initstate(uint, char*, size_t);
-c_long jrand48(ref ushort[3]);
+c_long jrand48(ushort[3]);
 char*  l64a(c_long);
-void   lcong48(ref ushort[7]);
+void   lcong48(ushort[7]);
 c_long lrand48();
 char*  mktemp(char*); // LEGACY
 int    mkstemp(char*);
 c_long mrand48();
-c_long nrand48(ref ushort[3]);
+c_long nrand48(ushort[3]);
 int    posix_openpt(int);
 char*  ptsname(int);
 int    putenv(char*);
 c_long random();
 char*  realpath(in char*, char*);
-ushort seed48(ref ushort[3]);
+ushort seed48(ushort[3]);
 void   setkey(in char*);
 char*  setstate(in char*);
 void   srand48(c_long);
@@ -196,26 +192,26 @@
     c_long a64l(in char*);
     double drand48();
     char*  ecvt(double, int, int *, int *); // LEGACY
-    double erand48(ref ushort[3]);
+    double erand48(ushort[3]);
     char*  fcvt(double, int, int *, int *); // LEGACY
     char*  gcvt(double, int, char*); // LEGACY
     int    getsubopt(char**, in char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
-    c_long jrand48(ref ushort[3]);
+    c_long jrand48(ushort[3]);
     char*  l64a(c_long);
-    void   lcong48(ref ushort[7]);
+    void   lcong48(ushort[7]);
     c_long lrand48();
     char*  mktemp(char*); // LEGACY
     //int    mkstemp(char*);
     c_long mrand48();
-    c_long nrand48(ref ushort[3]);
+    c_long nrand48(ushort[3]);
     int    posix_openpt(int);
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
     char*  realpath(in char*, char*);
-    ushort seed48(ref ushort[3]);
+    ushort seed48(ushort[3]);
     void   setkey(in char*);
     char*  setstate(in char*);
     void   srand48(c_long);
@@ -246,33 +242,33 @@
     c_long a64l(in char*);
     double drand48();
     char*  ecvt(double, int, int *, int *); // LEGACY
-    double erand48(ref ushort[3]);
+    double erand48(ushort[3]);
     char*  fcvt(double, int, int *, int *); // LEGACY
     char*  gcvt(double, int, char*); // LEGACY
     int    getsubopt(char**, in char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
-    c_long jrand48(ref ushort[3]);
+    c_long jrand48(ushort[3]);
     char*  l64a(c_long);
-    void   lcong48(ref ushort[7]);
+    void   lcong48(ushort[7]);
     c_long lrand48();
     char*  mktemp(char*); // LEGACY
     int    mkstemp(char*);
     c_long mrand48();
-    c_long nrand48(ref ushort[3]);
+    c_long nrand48(ushort[3]);
     int    posix_openpt(int);
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
     char*  realpath(in char*, char*);
-    ushort seed48(ref ushort[3]);
+    ushort seed48(ushort[3]);
     void   setkey(in char*);
     char*  setstate(in char*);
     void   srand48(c_long);
     void   srandom(uint);
     int    unlockpt(int);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     //WNOHANG     (defined in core.sys.posix.sys.wait)
     //WUNTRACED   (defined in core.sys.posix.sys.wait)
@@ -286,26 +282,26 @@
     c_long a64l(in char*);
     double drand48();
     //char*  ecvt(double, int, int *, int *); // LEGACY
-    double erand48(ref ushort[3]);
+    double erand48(ushort[3]);
     //char*  fcvt(double, int, int *, int *); // LEGACY
     //char*  gcvt(double, int, char*); // LEGACY
     int    getsubopt(char**, in char**, char**);
     int    grantpt(int);
     char*  initstate(uint, char*, size_t);
-    c_long jrand48(ref ushort[3]);
+    c_long jrand48(ushort[3]);
     char*  l64a(c_long);
-    void   lcong48(ref ushort[7]);
+    void   lcong48(ushort[7]);
     c_long lrand48();
     char*  mktemp(char*); // LEGACY
     int    mkstemp(char*);
     c_long mrand48();
-    c_long nrand48(ref ushort[3]);
+    c_long nrand48(ushort[3]);
     int    posix_openpt(int);
     char*  ptsname(int);
     int    putenv(char*);
     c_long random();
     char*  realpath(in char*, char*);
-    ushort seed48(ref ushort[3]);
+    ushort seed48(ushort[3]);
     void   setkey(in char*);
     char*  setstate(in char*);
     void   srand48(c_long);
diff -ur druntime/src/core/sys/posix/sys/ipc.d druntime/import/core/sys/posix/sys/ipc.d
--- druntime/src/core/sys/posix/sys/ipc.d	2010-08-05 06:35:42.000000000 +0100
+++ druntime/import/core/sys/posix/sys/ipc.d	2009-09-25 21:07:38.000000000 +0100
@@ -77,9 +77,9 @@
 {
 
 }
-else version( FreeBSD )
+else version( freebsd )
 {
-    struct ipc_perm_old // <= FreeBSD7
+    struct ipc_perm
     {
         ushort cuid;
         ushort cguid;
@@ -90,17 +90,6 @@
         key_t key;
     }
 
-    struct ipc_perm
-    {
-        uid_t   cuid;
-        gid_t   cgid;
-        uid_t   uid;
-        gid_t   gid;
-        mode_t  mode;
-        ushort  seq;
-        key_t   key;
-    }
-
     enum IPC_CREAT      = 01000;
     enum IPC_EXCL       = 02000;
     enum IPC_NOWAIT     = 04000;
diff -ur druntime/src/core/sys/posix/sys/select.d druntime/import/core/sys/posix/sys/select.d
--- druntime/src/core/sys/posix/sys/select.d	2010-08-08 01:10:24.000000000 +0100
+++ druntime/import/core/sys/posix/sys/select.d	2009-09-25 21:07:38.000000000 +0100
@@ -48,14 +48,14 @@
     private
     {
         alias c_long __fd_mask;
-        enum uint __NFDBITS = 8 * __fd_mask.sizeof;
+        enum __NFDBITS = 8 * __fd_mask.sizeof;
 
-        extern (D) auto __FDELT( int d )
+        extern (D) int __FDELT( int d )
         {
             return d / __NFDBITS;
         }
 
-        extern (D) auto __FDMASK( int d )
+        extern (D) int __FDMASK( int d )
         {
             return cast(__fd_mask) 1 << ( d % __NFDBITS );
         }
@@ -73,7 +73,7 @@
         fdset.fds_bits[__FDELT( fd )] &= ~__FDMASK( fd );
     }
 
-    extern (D) int FD_ISSET( int fd, fd_set* fdset )
+    extern (D) int  FD_ISSET( int fd, fd_set* fdset )
     {
         return fdset.fds_bits[__FDELT( fd )] & __FDMASK( fd );
     }
@@ -164,52 +164,17 @@
     int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
     int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     private
     {
-        alias c_ulong __fd_mask;
-        enum _NFDBITS = __fd_mask.sizeof * 8;
+        enum uint _NFDBITS   = c_ulong.sizeof * 8;
     }
 
     enum uint FD_SETSIZE = 1024;
 
     struct fd_set
     {
-        __fd_mask __fds_bits[(FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS];
-    }
-
-    extern (D) __fd_mask __fdset_mask(uint n)
-    {
-        return cast(__fd_mask) 1 << (n % _NFDBITS);
-    }
-
-    extern (D) void FD_CLR( int n, fd_set* p )
-    {
-        p.__fds_bits[n / _NFDBITS] &= ~__fdset_mask(n);
-    }
-
-    extern (D) bool FD_ISSET( int n, fd_set* p )
-    {
-        return (p.__fds_bits[n / _NFDBITS] & __fdset_mask(n)) != 0;
+        c_ulong fds_bits[(FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS];
     }
-
-    extern (D) void FD_SET( int n, fd_set* p )
-    {
-        p.__fds_bits[n / _NFDBITS] |= __fdset_mask(n);
-    }
-
-    extern (D) void FD_ZERO( fd_set* p )
-    {
-        fd_set *_p;
-        size_t _n;
-
-        _p = p;
-        _n = (FD_SETSIZE + (_NFDBITS - 1)) / _NFDBITS;
-        while (_n > 0)
-            _p.__fds_bits[--_n] = 0;
-    }
-
-    int pselect(int, fd_set*, fd_set*, fd_set*, in timespec*, in sigset_t*);
-    int select(int, fd_set*, fd_set*, fd_set*, timeval*);
 }
diff -ur druntime/src/core/sys/posix/sys/shm.d druntime/import/core/sys/posix/sys/shm.d
--- druntime/src/core/sys/posix/sys/shm.d	2010-08-05 06:38:52.000000000 +0100
+++ druntime/import/core/sys/posix/sys/shm.d	2009-09-25 21:07:38.000000000 +0100
@@ -80,7 +80,7 @@
     int   shmdt(in void*);
     int   shmget(key_t, size_t, int);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum SHM_RDONLY     = 010000;
     enum SHM_RND        = 020000;
@@ -88,29 +88,21 @@
 
     alias c_ulong   shmatt_t;
 
-    struct shmid_ds_old // <= FreeBSD7
-    {
-        ipc_perm_old    shm_perm;
-        int             shm_segsz;
-        pid_t           shm_lpid;
-        pid_t           shm_cpid;
-        short           shm_nattch;
-        time_t          shm_atime;
-        time_t          shm_dtime;
-        time_t          shm_ctime;
-        void*           shm_internal;
-    }
-
     struct shmid_ds
     {
-         ipc_perm    shm_perm;
-         int         shm_segsz;
-         pid_t       shm_lpid;
-         pid_t       shm_cpid;
-         short       shm_nattch;
-         time_t      shm_atime;
-         time_t      shm_dtime;
-         time_t      shm_ctime;
+        ipc_perm    shm_perm;
+        size_t      shm_segsz;
+        time_t      shm_atime;
+        c_ulong     __unused1;
+        time_t      shm_dtime;
+        c_ulong     __unused2;
+        time_t      shm_ctime;
+        c_ulong     __unused3;
+        pid_t       shm_cpid;
+        pid_t       shm_lpid;
+        shmatt_t    shm_nattch;
+        c_ulong     __unused4;
+        c_ulong     __unused5;
     }
 
     void* shmat(int, in void*, int);
diff -ur druntime/src/core/sys/posix/sys/socket.d druntime/import/core/sys/posix/sys/socket.d
--- druntime/src/core/sys/posix/sys/socket.d	2010-08-05 06:40:14.000000000 +0100
+++ druntime/import/core/sys/posix/sys/socket.d	2009-09-25 21:07:38.000000000 +0100
@@ -127,7 +127,7 @@
 int     shutdown(int, int);
 int     socket(int, int, int);
 int     sockatmark(int);
-int     socketpair(int, int, int, ref int[2]);
+int     socketpair(int, int, int, int[2]);
 */
 
 version( linux )
@@ -285,7 +285,7 @@
     int     shutdown(int, int);
     int     socket(int, int, int);
     int     sockatmark(int);
-    int     socketpair(int, int, int, ref int[2]);
+    int     socketpair(int, int, int, int[2]);
 }
 else version( OSX )
 {
@@ -434,9 +434,9 @@
     int     shutdown(int, int);
     int     socket(int, int, int);
     int     sockatmark(int);
-    int     socketpair(int, int, int, ref int[2]);
+    int     socketpair(int, int, int, int[2]);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     alias uint   socklen_t;
     alias ubyte  sa_family_t;
@@ -488,37 +488,17 @@
         SCM_RIGHTS = 0x01
     }
 
-    private // <machine/param.h>
-    {
-        enum _ALIGNBYTES = /+c_int+/ int.sizeof - 1;
-        extern (D) size_t _ALIGN( size_t p ) { return (p + _ALIGNBYTES) & ~_ALIGNBYTES; }
-    }
-
-    extern (D) ubyte* CMSG_DATA( cmsghdr* cmsg )
-    {
-        return cast(ubyte*) cmsg + _ALIGN( cmsghdr.sizeof );
-    }
-
-    extern (D) cmsghdr* CMSG_NXTHDR( msghdr* mhdr, cmsghdr* cmsg )
-    {
-        if( cmsg == null )
-        {
-           return CMSG_FIRSTHDR( mhdr );
-        }
-        else
-        {
-            if( cast(ubyte*) cmsg + _ALIGN( cmsg.cmsg_len ) + _ALIGN( cmsghdr.sizeof ) > 
-                    cast(ubyte*) mhdr.msg_control + mhdr.msg_controllen )
-                return null;
-            else
-                return cast(cmsghdr*) (cast(ubyte*) cmsg + _ALIGN( cmsg.cmsg_len ));
-        }
-    }
-
-    extern (D) cmsghdr* CMSG_FIRSTHDR( msghdr* mhdr )
-    {
-        return mhdr.msg_controllen >= cmsghdr.sizeof ? cast(cmsghdr*) mhdr.msg_control : null;
-    }
+    /+
+    CMSG_DATA(cmsg)     ((unsigned char *)(cmsg) + \
+                         ALIGN(sizeof(struct cmsghdr)))
+    CMSG_NXTHDR(mhdr, cmsg) \
+                        (((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len) + \
+                         ALIGN(sizeof(struct cmsghdr)) > \
+                         (unsigned char *)(mhdr)->msg_control +(mhdr)->msg_controllen) ? \
+                         (struct cmsghdr *)0 /* NULL */ : \
+                         (struct cmsghdr *)((unsigned char *)(cmsg) + ALIGN((cmsg)->cmsg_len)))
+    CMSG_FIRSTHDR(mhdr) ((struct cmsghdr *)(mhdr)->msg_control)
+    +/
 
     struct linger
     {
@@ -546,7 +526,7 @@
         SO_DONTROUTE    = 0x0010,
         SO_ERROR        = 0x1007,
         SO_KEEPALIVE    = 0x0008,
-        SO_LINGER       = 0x0080,
+        SO_LINGER       = 0x1080,
         SO_OOBINLINE    = 0x0100,
         SO_RCVBUF       = 0x1002,
         SO_RCVLOWAT     = 0x1004,
@@ -605,7 +585,7 @@
     int     shutdown(int, int);
     int     socket(int, int, int);
     int     sockatmark(int);
-    int     socketpair(int, int, int, ref int[2]);
+    int     socketpair(int, int, int, int[2]);
 }
 
 //
@@ -629,7 +609,7 @@
         AF_INET6    = 30
     }
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum
     {
@@ -658,7 +638,7 @@
         SOCK_RAW    = 3
     }
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum
     {
diff -ur druntime/src/core/sys/posix/sys/stat.d druntime/import/core/sys/posix/sys/stat.d
--- druntime/src/core/sys/posix/sys/stat.d	2010-08-05 06:42:10.000000000 +0100
+++ druntime/import/core/sys/posix/sys/stat.d	2009-09-25 21:07:38.000000000 +0100
@@ -250,24 +250,33 @@
     extern (D) bool S_ISLNK( mode_t mode )  { return S_ISTYPE( mode, S_IFLNK );  }
     extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     struct stat_t
     {
-        dev_t       st_dev;
-        ino_t       st_ino;
-        mode_t      st_mode;
-        nlink_t     st_nlink;
-        uid_t       st_uid;
-        gid_t       st_gid;
-        dev_t       st_rdev;
-
-        time_t      st_atime;
-        c_long      __st_atimensec;
-        time_t      st_mtime;
-        c_long      __st_mtimensec;
-        time_t      st_ctime;
-        c_long      __st_ctimensec;
+        dev_t   st_dev;
+        ino_t   st_ino;
+        mode_t  st_mode;
+        nlink_t st_nlink;
+        uid_t   st_uid;
+        gid_t   st_gid;
+        dev_t   st_rdev;
+
+        timespec st_atimespec;
+        timespec st_mtimespec;
+        timespec st_ctimespec;
+        time_t st_atime()
+        {
+            return st_atimespec.tv_sec;
+        }
+        time_t st_mtime()
+        {
+            return st_mtimespec.tv_sec;
+        }
+        time_t st_ctime()
+        {
+            return st_ctimespec.tv_sec;
+        }
 
         off_t       st_size;
         blkcnt_t    st_blocks;
@@ -275,11 +284,9 @@
         fflags_t    st_flags;
         uint        st_gen;
         int         st_lspare;
+        timespec    st_birthtimespec;
 
-        time_t      st_birthtime;
-        c_long      st_birthtimensec;
-
-        ubyte[16 - timespec.sizeof] padding;
+        byte[16 - timespec.sizeof] padding;
     }
 
     enum S_IRUSR    = 0000400;
@@ -318,17 +325,14 @@
     extern (D) bool S_ISSOCK( mode_t mode ) { return S_ISTYPE( mode, S_IFSOCK ); }
 }
 
-version( Posix )
-{
-    int    chmod(in char*, mode_t);
-    int    fchmod(int, mode_t);
-    //int    fstat(int, stat_t*);
-    //int    lstat(in char*, stat_t*);
-    int    mkdir(in char*, mode_t);
-    int    mkfifo(in char*, mode_t);
-    //int    stat(in char*, stat_t*);
-    mode_t umask(mode_t);
-}
+int    chmod(in char*, mode_t);
+int    fchmod(int, mode_t);
+//int    fstat(int, stat_t*);
+//int    lstat(in char*, stat_t*);
+int    mkdir(in char*, mode_t);
+int    mkfifo(in char*, mode_t);
+//int    stat(in char*, stat_t*);
+mode_t umask(mode_t);
 
 version( linux )
 {
@@ -350,7 +354,7 @@
     int   stat(in char*, stat_t*);
   }
 }
-else version( Posix )
+else
 {
     int   fstat(int, stat_t*);
     int   lstat(in char*, stat_t*);
@@ -406,7 +410,7 @@
 
     int mknod(in char*, mode_t, dev_t);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum S_IFMT     = 0170000;
     enum S_IFBLK    = 0060000;
diff -ur druntime/src/core/sys/posix/sys/time.d druntime/import/core/sys/posix/sys/time.d
--- druntime/src/core/sys/posix/sys/time.d	2010-08-05 03:11:28.000000000 +0100
+++ druntime/import/core/sys/posix/sys/time.d	2009-09-25 21:07:38.000000000 +0100
@@ -43,7 +43,7 @@
 int gettimeofday(timeval*, void*);
 int select(int, fd_set*, fd_set*, fd_set*, timeval*); (defined in core.sys.posix.sys.signal)
 int setitimer(int, in itimerval*, itimerval*);
-int utimes(in char*, ref const(timeval)[2]); // LEGACY
+int utimes(in char*, in timeval[2]); // LEGACY
 */
 
 version( linux )
@@ -67,7 +67,7 @@
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, void*);
     int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]); // LEGACY
+    int utimes(in char*, in timeval[2]); // LEGACY
 }
 else version( OSX )
 {
@@ -93,9 +93,9 @@
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void*
     int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int utimes(in char*, in timeval[2]);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     struct timeval
     {
@@ -119,5 +119,5 @@
     int getitimer(int, itimerval*);
     int gettimeofday(timeval*, timezone_t*); // timezone_t* is normally void*
     int setitimer(int, in itimerval*, itimerval*);
-    int utimes(in char*, ref const(timeval)[2]);
+    int utimes(in char*, in timeval[2]);
 }
diff -ur druntime/src/core/sys/posix/sys/types.d druntime/import/core/sys/posix/sys/types.d
--- druntime/src/core/sys/posix/sys/types.d	2010-09-03 09:28:52.000000000 +0100
+++ druntime/import/core/sys/posix/sys/types.d	2009-09-25 21:07:38.000000000 +0100
@@ -76,11 +76,11 @@
     alias long      off_t;
     alias int       pid_t;
     //size_t (defined in core.stdc.stddef)
-    alias c_long    ssize_t;
+    alias size_t    ssize_t;
     //time_t (defined in core.stdc.time)
     alias uint      uid_t;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     alias long      blkcnt_t;
     alias uint      blksize_t;
@@ -92,7 +92,7 @@
     alias long      off_t;
     alias int       pid_t;
     //size_t (defined in core.stdc.stddef)
-    alias c_long    ssize_t;
+    alias size_t    ssize_t;
     //time_t (defined in core.stdc.time)
     alias uint      uid_t;
     alias uint      fflags_t;
@@ -139,9 +139,9 @@
     alias int   suseconds_t;
     alias uint  useconds_t;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
-    // clock_t (defined in core.stdc.time)
+    //clock_t
     alias ulong     fsblkcnt_t;
     alias ulong     fsfilcnt_t;
     alias long      id_t;
@@ -345,7 +345,7 @@
 
     alias _opaque_pthread_t* pthread_t;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     alias int lwpid_t;
 
@@ -384,7 +384,7 @@
         int __pshared;
     }
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     alias void* pthread_barrier_t;
     alias void* pthread_barrierattr_t;
@@ -405,7 +405,7 @@
 {
     //struct pthread_spinlock_t;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     alias void* pthread_spinlock_t;
 }
diff -ur druntime/src/core/sys/posix/sys/uio.d druntime/import/core/sys/posix/sys/uio.d
--- druntime/src/core/sys/posix/sys/uio.d	2010-08-05 03:11:28.000000000 +0100
+++ druntime/import/core/sys/posix/sys/uio.d	2009-09-25 21:07:38.000000000 +0100
@@ -57,7 +57,7 @@
     ssize_t readv(int, in iovec*, int);
     ssize_t writev(int, in iovec*, int);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     struct iovec
     {
diff -ur druntime/src/core/sys/posix/sys/wait.d druntime/import/core/sys/posix/sys/wait.d
--- druntime/src/core/sys/posix/sys/wait.d	2010-08-05 06:43:54.000000000 +0100
+++ druntime/import/core/sys/posix/sys/wait.d	2010-05-05 23:20:22.000000000 +0100
@@ -89,10 +89,11 @@
     extern (D) int  WSTOPSIG( int status )     { return status >> 8;                     }
     extern (D) int  WTERMSIG( int status )     { return _WSTATUS( status );              }
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum WNOHANG        = 1;
     enum WUNTRACED      = 2;
+    enum WCONTINUED     = 4;
 
     private
     {
@@ -111,13 +112,14 @@
     extern (D) int  WSTOPSIG( int status )     { return status >> 8;                     }
     extern (D) int  WTERMSIG( int status )     { return _WSTATUS( status );              }
 }
-
-version( Posix )
+else
 {
-    pid_t wait(int*);
-    pid_t waitpid(pid_t, int*, int);
+    static assert( false );
 }
 
+pid_t wait(int*);
+pid_t waitpid(pid_t, int*, int);
+
 //
 // XOpen (XSI)
 //
@@ -169,12 +171,3 @@
 
     int waitid(idtype_t, id_t, siginfo_t*, int);    
 }
-else version (FreeBSD)
-{
-    enum WSTOPPED       = WUNTRACED;
-    enum WCONTINUED     = 4;
-    enum WNOWAIT        = 8;
-
-    // http://www.freebsd.org/projects/c99/
-}
-
diff -ur druntime/src/core/sys/posix/termios.d druntime/import/core/sys/posix/termios.d
--- druntime/src/core/sys/posix/termios.d	2010-08-05 06:44:46.000000000 +0100
+++ druntime/import/core/sys/posix/termios.d	2009-09-25 21:07:38.000000000 +0100
@@ -127,116 +127,7 @@
 int     tcsetattr(int, int, in termios*);
 */
 
-version( linux )
-{
-    alias ubyte cc_t;
-    alias uint  speed_t;
-    alias uint  tcflag_t;
-
-    enum NCCS   = 32;
-
-    struct termios
-    {
-        tcflag_t   c_iflag;
-        tcflag_t   c_oflag;
-        tcflag_t   c_cflag;
-        tcflag_t   c_lflag;
-        cc_t       c_line;
-        cc_t[NCCS] c_cc;
-        speed_t    c_ispeed;
-        speed_t    c_ospeed;
-    }
-
-    enum VEOF       = 4;
-    enum VEOL       = 11;
-    enum VERASE     = 2;
-    enum VINTR      = 0;
-    enum VKILL      = 3;
-    enum VMIN       = 6;
-    enum VQUIT      = 1;
-    enum VSTART     = 8;
-    enum VSTOP      = 9;
-    enum VSUSP      = 10;
-    enum VTIME      = 5;
-
-    enum BRKINT     = 0000002;
-    enum ICRNL      = 0000400;
-    enum IGNBRK     = 0000001;
-    enum IGNCR      = 0000200;
-    enum IGNPAR     = 0000004;
-    enum INLCR      = 0000100;
-    enum INPCK      = 0000020;
-    enum ISTRIP     = 0000040;
-    enum IXOFF      = 0010000;
-    enum IXON       = 0002000;
-    enum PARMRK     = 0000010;
-
-    enum OPOST      = 0000001;
-
-    enum B0         = 0000000;
-    enum B50        = 0000001;
-    enum B75        = 0000002;
-    enum B110       = 0000003;
-    enum B134       = 0000004;
-    enum B150       = 0000005;
-    enum B200       = 0000006;
-    enum B300       = 0000007;
-    enum B600       = 0000010;
-    enum B1200      = 0000011;
-    enum B1800      = 0000012;
-    enum B2400      = 0000013;
-    enum B4800      = 0000014;
-    enum B9600      = 0000015;
-    enum B19200     = 0000016;
-    enum B38400     = 0000017;
-
-    enum CSIZE      = 0000060;
-    enum   CS5      = 0000000;
-    enum   CS6      = 0000020;
-    enum   CS7      = 0000040;
-    enum   CS8      = 0000060;
-    enum CSTOPB     = 0000100;
-    enum CREAD      = 0000200;
-    enum PARENB     = 0000400;
-    enum PARODD     = 0001000;
-    enum HUPCL      = 0002000;
-    enum CLOCAL     = 0004000;
-
-    enum ECHO       = 0000010;
-    enum ECHOE      = 0000020;
-    enum ECHOK      = 0000040;
-    enum ECHONL     = 0000100;
-    enum ICANON     = 0000002;
-    enum IEXTEN     = 0100000;
-    enum ISIG       = 0000001;
-    enum NOFLSH     = 0000200;
-    enum TOSTOP     = 0000400;
-
-    enum TCSANOW    = 0;
-    enum TCSADRAIN  = 1;
-    enum TCSAFLUSH  = 2;
-
-    enum TCIFLUSH   = 0;
-    enum TCOFLUSH   = 1;
-    enum TCIOFLUSH  = 2;
-
-    enum TCIOFF     = 2;
-    enum TCION      = 3;
-    enum TCOOFF     = 0;
-    enum TCOON      = 1;
-
-    speed_t cfgetispeed(in termios*);
-    speed_t cfgetospeed(in termios*);
-    int     cfsetispeed(termios*, speed_t);
-    int     cfsetospeed(termios*, speed_t);
-    int     tcdrain(int);
-    int     tcflow(int, int);
-    int     tcflush(int, int);
-    int     tcgetattr(int, termios*);
-    int     tcsendbreak(int, int);
-    int     tcsetattr(int, int, in termios*);
-}
-else version( OSX )
+version( OSX )
 {
     alias ubyte cc_t;
     alias uint  speed_t;
@@ -345,7 +236,116 @@
     int     tcsetattr(int, int, in termios*);
 
 }
-else version ( FreeBSD )
+else version( linux )
+{
+    alias ubyte cc_t;
+    alias uint  speed_t;
+    alias uint  tcflag_t;
+
+    enum NCCS   = 32;
+
+    struct termios
+    {
+        tcflag_t   c_iflag;
+        tcflag_t   c_oflag;
+        tcflag_t   c_cflag;
+        tcflag_t   c_lflag;
+        cc_t       c_line;
+        cc_t[NCCS] c_cc;
+        speed_t    c_ispeed;
+        speed_t    c_ospeed;
+    }
+
+    enum VEOF       = 4;
+    enum VEOL       = 11;
+    enum VERASE     = 2;
+    enum VINTR      = 0;
+    enum VKILL      = 3;
+    enum VMIN       = 6;
+    enum VQUIT      = 1;
+    enum VSTART     = 8;
+    enum VSTOP      = 9;
+    enum VSUSP      = 10;
+    enum VTIME      = 5;
+
+    enum BRKINT     = 0000002;
+    enum ICRNL      = 0000400;
+    enum IGNBRK     = 0000001;
+    enum IGNCR      = 0000200;
+    enum IGNPAR     = 0000004;
+    enum INLCR      = 0000100;
+    enum INPCK      = 0000020;
+    enum ISTRIP     = 0000040;
+    enum IXOFF      = 0010000;
+    enum IXON       = 0002000;
+    enum PARMRK     = 0000010;
+
+    enum OPOST      = 0000001;
+
+    enum B0         = 0000000;
+    enum B50        = 0000001;
+    enum B75        = 0000002;
+    enum B110       = 0000003;
+    enum B134       = 0000004;
+    enum B150       = 0000005;
+    enum B200       = 0000006;
+    enum B300       = 0000007;
+    enum B600       = 0000010;
+    enum B1200      = 0000011;
+    enum B1800      = 0000012;
+    enum B2400      = 0000013;
+    enum B4800      = 0000014;
+    enum B9600      = 0000015;
+    enum B19200     = 0000016;
+    enum B38400     = 0000017;
+
+    enum CSIZE      = 0000060;
+    enum   CS5      = 0000000;
+    enum   CS6      = 0000020;
+    enum   CS7      = 0000040;
+    enum   CS8      = 0000060;
+    enum CSTOPB     = 0000100;
+    enum CREAD      = 0000200;
+    enum PARENB     = 0000400;
+    enum PARODD     = 0001000;
+    enum HUPCL      = 0002000;
+    enum CLOCAL     = 0004000;
+
+    enum ECHO       = 0000010;
+    enum ECHOE      = 0000020;
+    enum ECHOK      = 0000040;
+    enum ECHONL     = 0000100;
+    enum ICANON     = 0000002;
+    enum IEXTEN     = 0100000;
+    enum ISIG       = 0000001;
+    enum NOFLSH     = 0000200;
+    enum TOSTOP     = 0000400;
+
+    enum TCSANOW    = 0;
+    enum TCSADRAIN  = 1;
+    enum TCSAFLUSH  = 2;
+
+    enum TCIFLUSH   = 0;
+    enum TCOFLUSH   = 1;
+    enum TCIOFLUSH  = 2;
+
+    enum TCIOFF     = 2;
+    enum TCION      = 3;
+    enum TCOOFF     = 0;
+    enum TCOON      = 1;
+
+    speed_t cfgetispeed(in termios*);
+    speed_t cfgetospeed(in termios*);
+    int     cfsetispeed(termios*, speed_t);
+    int     cfsetospeed(termios*, speed_t);
+    int     tcdrain(int);
+    int     tcflow(int, int);
+    int     tcflush(int, int);
+    int     tcgetattr(int, termios*);
+    int     tcsendbreak(int, int);
+    int     tcsetattr(int, int, in termios*);
+}
+else version ( freebsd )
 {
     alias ubyte cc_t;
     alias uint  speed_t;
@@ -526,38 +526,3 @@
 
     pid_t   tcgetsid(int);
 }
-else version( FreeBSD )
-{
-    enum IXANY      = 0x00000800;
-
-    enum ONLCR      = 0x00000002;
-    enum OCRNL      = 0x00000010;
-    enum ONOCR      = 0x00000020;
-    enum ONLRET     = 0x00000040;
-    //enum OFILL
-    //enum NLDLY
-    //enum     NL0
-    //enum     NL1
-    //enum CRDLY
-    //enum     CR0
-    //enum     CR1
-    //enum     CR2
-    //enum     CR3
-    enum TABDLY     = 0x00000004;
-    enum     TAB0   = 0x00000000;
-    //enum     TAB1
-    //enum     TAB2
-    enum     TAB3   = 0x00000004;
-    //enum BSDLY
-    //enum     BS0
-    //enum     BS1
-    //enum VTDLY
-    //enum     VT0
-    //enum     VT1
-    //enum FFDLY
-    //enum     FF0
-    //enum     FF1
-
-    pid_t   tcgetsid(int);
-}
-
diff -ur druntime/src/core/sys/posix/time.d druntime/import/core/sys/posix/time.d
--- druntime/src/core/sys/posix/time.d	2010-08-05 06:47:04.000000000 +0100
+++ druntime/import/core/sys/posix/time.d	2009-09-25 21:07:38.000000000 +0100
@@ -43,7 +43,7 @@
 {
     time_t timegm(tm*); // non-standard
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     time_t timegm(tm*); // non-standard
 }
@@ -156,9 +156,10 @@
 {
     int nanosleep(in timespec*, timespec*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
-    enum CLOCK_THREAD_CPUTIME_ID    = 15;
+    enum CLOCK_PROCESS_CPUTIME_ID   = 2; // (TMR|CPT)
+    enum CLOCK_THREAD_CPUTIME_ID    = 3; // (TMR|TCT)
 
     // NOTE: See above for why this is commented out.
     //
@@ -177,7 +178,7 @@
     enum CLOCK_REALTIME     = 0;
     enum TIMER_ABSTIME      = 0x01;
 
-    alias int clockid_t; // <sys/_types.h>
+    //alias int clockid_t;
     alias int timer_t;
 
     int clock_getres(clockid_t, timespec*);
@@ -216,7 +217,7 @@
     tm*   gmtime_r(in time_t*, tm*);
     tm*   localtime_r(in time_t*, tm*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     char* asctime_r(in tm*, char*);
     char* ctime_r(in time_t*, char*);
@@ -254,6 +255,8 @@
 }
 else version( FreeBSD )
 {
+    extern __gshared c_long timezone;
+
     //tm*   getdate(in char*);
     char* strptime(in char*, in char*, tm*);
 }
diff -ur druntime/src/core/sys/posix/ucontext.d druntime/import/core/sys/posix/ucontext.d
--- druntime/src/core/sys/posix/ucontext.d	2010-08-05 06:48:14.000000000 +0100
+++ druntime/import/core/sys/posix/ucontext.d	2009-09-25 21:07:38.000000000 +0100
@@ -140,65 +140,6 @@
         }
     }
 }
-else version( FreeBSD )
-{
-    // <machine/ucontext.h>
-    version( X86 )
-    {
-        alias int __register_t;
-
-        struct mcontext_t
-        {
-            __register_t    mc_onstack;
-            __register_t    mc_gs;
-            __register_t    mc_fs;
-            __register_t    mc_es;
-            __register_t    mc_ds;
-            __register_t    mc_edi;
-            __register_t    mc_esi;
-            __register_t    mc_ebp;
-            __register_t    mc_isp;
-            __register_t    mc_ebx;
-            __register_t    mc_edx;
-            __register_t    mc_ecx;
-            __register_t    mc_eax;
-            __register_t    mc_trapno;
-            __register_t    mc_err;
-            __register_t    mc_eip;
-            __register_t    mc_cs;
-            __register_t    mc_eflags;
-            __register_t    mc_esp;
-            __register_t    mc_ss;
-
-            int             mc_len;
-            int             mc_fpformat;
-            int             mc_ownedfp;
-            int[1]          mc_spare1;
-
-            align(16)
-            int[128]        mc_fpstate;
-
-            __register_t    mc_fsbase;
-            __register_t    mc_gsbase;
-
-            int[6]          mc_spare2;
-        }
-    }
-
-    // <ucontext.h>
-    enum UCF_SWAPPED = 0x00000001;
-
-    struct ucontext_t
-    {
-        sigset_t        uc_sigmask;
-        mcontext_t      uc_mcontext;
-
-        ucontext_t*     uc_link;
-        stack_t         uc_stack;
-        int             uc_flags;
-        int[4]          __spare__;
-    }
-}
 
 //
 // Obsolescent (OB)
diff -ur druntime/src/core/sys/posix/unistd.d druntime/import/core/sys/posix/unistd.d
--- druntime/src/core/sys/posix/unistd.d	2010-09-03 09:28:52.000000000 +0100
+++ druntime/import/core/sys/posix/unistd.d	2009-12-06 19:51:36.000000000 +0000
@@ -20,74 +20,71 @@
 
 extern (C):
 
-version( Posix )
-{
-    enum STDIN_FILENO  = 0;
-    enum STDOUT_FILENO = 1;
-    enum STDERR_FILENO = 2;
-
-    char*   optarg;
-    int     optind;
-    int     opterr;
-    int     optopt;
-
-    int     access(in char*, int);
-    uint    alarm(uint);
-    int     chdir(in char*);
-    int     chown(in char*, uid_t, gid_t);
-    int     close(int);
-    size_t  confstr(int, char*, size_t);
-    int     dup(int);
-    int     dup2(int, int);
-    int     execl(in char*, in char*, ...);
-    int     execle(in char*, in char*, ...);
-    int     execlp(in char*, in char*, ...);
-    int     execv(in char*, in char**);
-    int     execve(in char*, in char**, in char**);
-    int     execvp(in char*, in char**);
-    void    _exit(int);
-    int     fchown(int, uid_t, gid_t);
-    pid_t   fork();
-    c_long  fpathconf(int, int);
-    //int     ftruncate(int, off_t);
-    char*   getcwd(char*, size_t);
-    gid_t   getegid();
-    uid_t   geteuid();
-    gid_t   getgid();
-    int     getgroups(int, gid_t *);
-    int     gethostname(char*, size_t);
-    char*   getlogin();
-    int     getlogin_r(char*, size_t);
-    int     getopt(int, in char**, in char*);
-    pid_t   getpgrp();
-    pid_t   getpid();
-    pid_t   getppid();
-    uid_t   getuid();
-    int     isatty(int);
-    int     link(in char*, in char*);
-    //off_t   lseek(int, off_t, int);
-    c_long  pathconf(in char*, int);
-    int     pause();
-    int     pipe(ref int[2]);
-    ssize_t read(int, void*, size_t);
-    ssize_t readlink(in char*, char*, size_t);
-    int     rmdir(in char*);
-    int     setegid(gid_t);
-    int     seteuid(uid_t);
-    int     setgid(gid_t);
-    int     setpgid(pid_t, pid_t);
-    pid_t   setsid();
-    int     setuid(uid_t);
-    uint    sleep(uint);
-    int     symlink(in char*, in char*);
-    c_long  sysconf(int);
-    pid_t   tcgetpgrp(int);
-    int     tcsetpgrp(int, pid_t);
-    char*   ttyname(int);
-    int     ttyname_r(int, char*, size_t);
-    int     unlink(in char*);
-    ssize_t write(int, in void*, size_t);
-}
+enum STDIN_FILENO  = 0;
+enum STDOUT_FILENO = 1;
+enum STDERR_FILENO = 2;
+
+char*   optarg;
+int     optind;
+int     opterr;
+int     optopt;
+
+int     access(in char*, int);
+uint    alarm(uint);
+int     chdir(in char*);
+int     chown(in char*, uid_t, gid_t);
+int     close(int);
+size_t  confstr(int, char*, size_t);
+int     dup(int);
+int     dup2(int, int);
+int     execl(in char*, in char*, ...);
+int     execle(in char*, in char*, ...);
+int     execlp(in char*, in char*, ...);
+int     execv(in char*, in char**);
+int     execve(in char*, in char**, in char**);
+int     execvp(in char*, in char**);
+void    _exit(int);
+int     fchown(int, uid_t, gid_t);
+pid_t   fork();
+c_long  fpathconf(int, int);
+//int     ftruncate(int, off_t);
+char*   getcwd(char*, size_t);
+gid_t   getegid();
+uid_t   geteuid();
+gid_t   getgid();
+int     getgroups(int, gid_t *);
+int     gethostname(char*, size_t);
+char*   getlogin();
+int     getlogin_r(char*, size_t);
+int     getopt(int, in char**, in char*);
+pid_t   getpgrp();
+pid_t   getpid();
+pid_t   getppid();
+uid_t   getuid();
+int     isatty(int);
+int     link(in char*, in char*);
+//off_t   lseek(int, off_t, int);
+c_long  pathconf(in char*, int);
+int     pause();
+int     pipe(int[2]);
+ssize_t read(int, void*, size_t);
+ssize_t readlink(in char*, char*, size_t);
+int     rmdir(in char*);
+int     setegid(gid_t);
+int     seteuid(uid_t);
+int     setgid(gid_t);
+int     setpgid(pid_t, pid_t);
+pid_t   setsid();
+int     setuid(uid_t);
+uint    sleep(uint);
+int     symlink(in char*, in char*);
+c_long  sysconf(int);
+pid_t   tcgetpgrp(int);
+int     tcsetpgrp(int, pid_t);
+char*   ttyname(int);
+int     ttyname_r(int, char*, size_t);
+int     unlink(in char*);
+ssize_t write(int, in void*, size_t);
 
 version( linux )
 {
@@ -110,12 +107,12 @@
     int   ftruncate(int, off_t);
   }
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     off_t lseek(int, off_t, int);
     int   ftruncate(int, off_t);
 }
-else version( Posix )
+else
 {
     off_t lseek(int, off_t, int);
     int   ftruncate(int, off_t);
@@ -448,7 +445,7 @@
     enum F_TLOCK    = 2;
     enum F_TEST     = 3;
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     enum F_OK       = 0;
     enum R_OK       = 0x04;
@@ -476,10 +473,6 @@
 {
     int fsync(int);
 }
-else version( FreeBSD )
-{
-    int fsync(int);
-}
 
 //
 // Synchronized I/O (SIO)
@@ -499,7 +492,7 @@
 /*
 char*      crypt(in char*, in char*);
 char*      ctermid(char*);
-void       encrypt(ref char[64], int);
+void       encrypt(char[64], int);
 int        fchdir(int);
 c_long     gethostid();
 pid_t      getpgid(pid_t);
@@ -525,7 +518,7 @@
 {
     char*      crypt(in char*, in char*);
     char*      ctermid(char*);
-    void       encrypt(ref char[64], int);
+    void       encrypt(char[64], int);
     int        fchdir(int);
     c_long     gethostid();
     pid_t      getpgid(pid_t);
@@ -572,7 +565,7 @@
 {
     char*      crypt(in char*, in char*);
     char*      ctermid(char*);
-    void       encrypt(ref char[64], int);
+    void       encrypt(char[64], int);
     int        fchdir(int);
     c_long     gethostid();
     pid_t      getpgid(pid_t);
@@ -593,11 +586,11 @@
     int        usleep(useconds_t);
     pid_t      vfork();
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     char*      crypt(in char*, in char*);
     //char*      ctermid(char*);
-    void       encrypt(ref char[64], int);
+    void       encrypt(char*, int);
     int        fchdir(int);
     c_long     gethostid();
     int        getpgid(pid_t);
diff -ur druntime/src/core/sys/posix/utime.d druntime/import/core/sys/posix/utime.d
--- druntime/src/core/sys/posix/utime.d	2010-08-05 03:11:28.000000000 +0100
+++ druntime/import/core/sys/posix/utime.d	2009-09-25 21:07:38.000000000 +0100
@@ -51,7 +51,7 @@
 
     int utime(in char*, in utimbuf*);
 }
-else version( FreeBSD )
+else version( freebsd )
 {
     struct utimbuf
     {
diff -ur druntime/src/core/sys/windows/windows.d druntime/import/core/sys/windows/windows.d
--- druntime/src/core/sys/windows/windows.d	2010-10-10 21:37:54.000000000 +0100
+++ druntime/import/core/sys/windows/windows.d	2009-12-02 00:51:12.000000000 +0000
@@ -13,6 +13,13 @@
  */
 module core.sys.windows.windows;
 
+version (Windows)
+{
+}
+else
+{
+    static assert(0);       // Windows only
+}
 
 extern (Windows)
 {
@@ -44,7 +51,6 @@
     alias const(WCHAR)* LPCWSTR, PCWSTR;
 
     alias uint DWORD;
-    alias ulong DWORD64;
     alias int BOOL;
     alias ubyte BYTE;
     alias ushort WORD;
@@ -69,7 +75,7 @@
     alias uint *PUINT;
 
 // ULONG_PTR must be able to store a pointer as an integral type
-version (Win64)
+version(Win64)
 {
     alias  long INT_PTR;
     alias ulong UINT_PTR;
@@ -80,7 +86,7 @@
     alias  long * PLONG_PTR;
     alias ulong * PULONG_PTR;
 }
-else // Win32
+version(Win32)
 {
     alias  int INT_PTR;
     alias uint UINT_PTR;
@@ -131,7 +137,7 @@
     alias ACCESS_MASK *PACCESS_MASK;
     alias ACCESS_MASK REGSAM;
 
-    alias int function() FARPROC;
+    alias int (*FARPROC)();
 
     alias UINT WPARAM;
     alias LONG LPARAM;
@@ -1169,90 +1175,6 @@
     DWORD   SegSs;
 }
 
-enum ADDRESS_MODE
-{
-    AddrMode1616,
-    AddrMode1632,
-    AddrModeReal,
-    AddrModeFlat
-}
-
-struct ADDRESS
-{
-    DWORD         Offset;
-    WORD          Segment;
-    ADDRESS_MODE  Mode;
-}
-
-struct ADDRESS64
-{
-    DWORD64       Offset;
-    WORD          Segment;
-    ADDRESS_MODE  Mode;
-}
-
-struct KDHELP
-{
-    DWORD       Thread;
-    DWORD       ThCallbackStack;
-    DWORD       NextCallback;
-    DWORD       FramePointer;
-    DWORD       KiCallUserMode;
-    DWORD       KeUserCallbackDispatcher;
-    DWORD       SystemRangeStart;
-    DWORD       ThCallbackBStore;
-    DWORD       KiUserExceptionDispatcher;
-    DWORD       StackBase;
-    DWORD       StackLimit;
-    DWORD[5]    Reserved;
-}
-
-struct KDHELP64
-{
-    DWORD64     Thread;
-    DWORD       ThCallbackStack;
-    DWORD       ThCallbackBStore;
-    DWORD       NextCallback;
-    DWORD       FramePointer;
-    DWORD64     KiCallUserMode;
-    DWORD64     KeUserCallbackDispatcher;
-    DWORD64     SystemRangeStart;
-    DWORD64     KiUserExceptionDispatcher;
-    DWORD64     StackBase;
-    DWORD64     StackLimit;
-    DWORD64[5]  Reserved;
-}
-
-struct STACKFRAME
-{
-    ADDRESS     AddrPC;
-    ADDRESS     AddrReturn;
-    ADDRESS     AddrFrame;
-    ADDRESS     AddrStack;
-    PVOID       FuncTableEntry;
-    DWORD[4]    Params;
-    BOOL        Far;
-    BOOL        Virtual;
-    DWORD[3]    Reserved;
-    KDHELP      KdHelp;
-    ADDRESS     AddrBStore;
-}
-
-struct STACKFRAME64
-{
-    ADDRESS64   AddrPC;
-    ADDRESS64   AddrReturn;
-    ADDRESS64   AddrFrame;
-    ADDRESS64   AddrStack;
-    ADDRESS64   AddrBStore;
-    PVOID       FuncTableEntry;
-    DWORD64[4]  Params;
-    BOOL        Far;
-    BOOL        Virtual;
-    DWORD64[3]  Reserved;
-    KDHELP64    KdHelp;
-}
-
 enum
 {
     THREAD_BASE_PRIORITY_LOWRT =  15,  // value that gets a thread to LowRealtime-1
@@ -2114,7 +2036,7 @@
 export LRESULT DefWindowProcA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
 export HMODULE GetModuleHandleA(LPCSTR lpModuleName);
 
-alias LRESULT function (HWND, UINT, WPARAM, LPARAM) WNDPROC;
+alias LRESULT (* WNDPROC)(HWND, UINT, WPARAM, LPARAM);
 
 struct WNDCLASSEXA {
     UINT        cbSize;
@@ -2613,7 +2535,7 @@
 
 export LRESULT SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
 
-alias UINT function (HWND, UINT, WPARAM, LPARAM) LPOFNHOOKPROC;
+alias UINT (*LPOFNHOOKPROC) (HWND, UINT, WPARAM, LPARAM);
 
 struct OPENFILENAMEA {
    DWORD        lStructSize;
@@ -3136,7 +3058,7 @@
 BOOL ScrollConsoleScreenBufferW(HANDLE hConsoleOutput, in SMALL_RECT *lpScrollRectangle, in SMALL_RECT *lpClipRectangle, COORD dwDestinationOrigin, in CHAR_INFO *lpFill);
 BOOL SetConsoleWindowInfo(HANDLE hConsoleOutput, BOOL bAbsolute, in SMALL_RECT *lpConsoleWindow);
 BOOL SetConsoleTextAttribute(HANDLE hConsoleOutput, WORD wAttributes);
-alias BOOL function(DWORD CtrlType) PHANDLER_ROUTINE;
+alias BOOL(*PHANDLER_ROUTINE)(DWORD CtrlType);
 BOOL SetConsoleCtrlHandler(PHANDLER_ROUTINE HandlerRoutine, BOOL Add);
 BOOL GenerateConsoleCtrlEvent( DWORD dwCtrlEvent, DWORD dwProcessGroupId);
 BOOL AllocConsole();
