public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Iain Buclaw <ibuclaw@gdcproject.org>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH, libphobos] Committed merge with upstream druntime 109f0f2e
Date: Mon, 22 Apr 2019 13:56:00 -0000	[thread overview]
Message-ID: <CABOHX+eqRWL8=2NUw5JeK773xN6b72=fM9ozj+Gy7NKb4C_Fdw@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 503 bytes --]

Hi,

This patch merges the libdruntime sub-directory with upstream druntime 109f0f2e.

Includes more backports for extern(C) bindings, notably for DragonFly
and FreeBSD platforms.  After adding the relevant compiler parts, it
should now be possible to turn on libphobos for x86_64 and i?38
dragronfly and freebsd configurations.

Bootstrapped and regression tested on x86_64-linux-gnu, with build
testing done on x86_64-freebsd11.2 and x86_64-dragonfly5.4.

Committed to trunk as r270490.

-- 
Iain
---

[-- Attachment #2: druntime109f0f2e.patch --]
[-- Type: text/x-patch, Size: 40741 bytes --]

diff --git a/libphobos/libdruntime/MERGE b/libphobos/libdruntime/MERGE
index 405be921eb3..8a3790142cf 100644
--- a/libphobos/libdruntime/MERGE
+++ b/libphobos/libdruntime/MERGE
@@ -1,4 +1,4 @@
-4b2674b36b1f6aac75db2a5aa38d67d4be55a987
+109f0f2e11aaaddd2b158117928e10c3c4688870
 
 The first line of this file holds the git revision number of the last
 merge done from the dlang/druntime repository.
diff --git a/libphobos/libdruntime/core/runtime.d b/libphobos/libdruntime/core/runtime.d
index 1fd54407aa5..848b607ae69 100644
--- a/libphobos/libdruntime/core/runtime.d
+++ b/libphobos/libdruntime/core/runtime.d
@@ -464,10 +464,14 @@ extern (C) bool runModuleUnitTests()
         import core.sys.freebsd.execinfo;
     else version (NetBSD)
         import core.sys.netbsd.execinfo;
+    else version (DragonFlyBSD)
+        import core.sys.dragonflybsd.execinfo;
     else version (Windows)
         import core.sys.windows.stacktrace;
     else version (Solaris)
         import core.sys.solaris.execinfo;
+    else version (CRuntime_UClibc)
+        import core.sys.linux.execinfo;
 
     static if ( __traits( compiles, new LibBacktrace(0) ) )
     {
@@ -591,10 +595,14 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
         import core.sys.freebsd.execinfo;
     else version (NetBSD)
         import core.sys.netbsd.execinfo;
+    else version (DragonFlyBSD)
+        import core.sys.dragonflybsd.execinfo;
     else version (Windows)
         import core.sys.windows.stacktrace;
     else version (Solaris)
         import core.sys.solaris.execinfo;
+    else version (CRuntime_UClibc)
+        import core.sys.linux.execinfo;
 
     // avoid recursive GC calls in finalizer, trace handlers should be made @nogc instead
     import core.memory : gc_inFinalizer;
@@ -709,6 +717,8 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
 
                 version (linux) enum enableDwarf = true;
                 else version (FreeBSD) enum enableDwarf = true;
+                else version (DragonFlyBSD) enum enableDwarf = true;
+                else version (Darwin) enum enableDwarf = true;
                 else enum enableDwarf = false;
 
                 static if (enableDwarf)
@@ -832,6 +842,18 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
                         symEnd = eptr - buf.ptr;
                     }
                 }
+                else version (DragonFlyBSD)
+                {
+                    // format is: 0x00000000 <_D6module4funcAFZv+0x78> at module
+                    auto bptr = cast(char*) memchr( buf.ptr, '<', buf.length );
+                    auto eptr = cast(char*) memchr( buf.ptr, '+', buf.length );
+
+                    if ( bptr++ && eptr )
+                    {
+                        symBeg = bptr - buf.ptr;
+                        symEnd = eptr - buf.ptr;
+                    }
+                }
                 else version (Solaris)
                 {
                     // format is object'symbol+offset [pc]
@@ -896,7 +918,7 @@ Throwable.TraceInfo defaultTraceHandler( void* ptr = null )
         {
             static enum FIRSTFRAME = 0;
         }
-        import core.sys.windows.windows : CONTEXT;
+        import core.sys.windows.winnt : CONTEXT;
         auto s = new StackTrace(FIRSTFRAME, cast(CONTEXT*)ptr);
         return s;
     }
diff --git a/libphobos/libdruntime/core/stdc/math.d b/libphobos/libdruntime/core/stdc/math.d
index e93f8533342..9b190048934 100644
--- a/libphobos/libdruntime/core/stdc/math.d
+++ b/libphobos/libdruntime/core/stdc/math.d
@@ -2041,46 +2041,49 @@ else version (FreeBSD)
 {
   version (none) // < 8-CURRENT
   {
-    real    acosl(real x) { return acos(x); }
-    real    asinl(real x) { return asin(x); }
-    pure real    atanl(real x) { return atan(x); }
-    real    atan2l(real y, real x) { return atan2(y, x); }
-    pure real    cosl(real x) { return cos(x); }
-    pure real    sinl(real x) { return sin(x); }
-    pure real    tanl(real x) { return tan(x); }
-    real    exp2l(real x) { return exp2(x); }
-    pure 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); }
-    pure real    fabsl(real x) { return fabs(x); }
-    real    hypotl(real x, real y) { return hypot(x, y); }
-    real    sqrtl(real x) { return sqrt(x); }
-    pure real    ceill(real x) { return ceil(x); }
-    pure real    floorl(real x) { return floor(x); }
-    pure real    nearbyintl(real x) { return nearbyint(x); }
-    pure real    rintl(real x) { return rint(x); }
-    c_long  lrintl(real x) { return lrint(x); }
-    pure real    roundl(real x) { return round(x); }
-    c_long  lroundl(real x) { return lround(x); }
-    long    llroundl(real x) { return llround(x); }
-    pure 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); }
-    pure real    copysignl(real x, real y) { return copysign(x, y); }
-//  pure double  nan(char* tagp);
-//  pure float   nanf(char* tagp);
-//  pure 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); }
-    pure real    fmaxl(real x, real y) { return fmax(x, y); }
-    pure real    fminl(real x, real y) { return fmin(x, y); }
-    pure real    fmal(real x, real y, real z) { return fma(x, y, z); }
+    extern (D)
+    {
+        real    acosl(real x) { return acos(x); }
+        real    asinl(real x) { return asin(x); }
+        pure real    atanl(real x) { return atan(x); }
+        real    atan2l(real y, real x) { return atan2(y, x); }
+        pure real    cosl(real x) { return cos(x); }
+        pure real    sinl(real x) { return sin(x); }
+        pure real    tanl(real x) { return tan(x); }
+        real    exp2l(real x) { return exp2(x); }
+        pure 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); }
+        pure real    fabsl(real x) { return fabs(x); }
+        real    hypotl(real x, real y) { return hypot(x, y); }
+        real    sqrtl(real x) { return sqrt(x); }
+        pure real    ceill(real x) { return ceil(x); }
+        pure real    floorl(real x) { return floor(x); }
+        pure real    nearbyintl(real x) { return nearbyint(x); }
+        pure real    rintl(real x) { return rint(x); }
+        c_long  lrintl(real x) { return lrint(x); }
+        pure real    roundl(real x) { return round(x); }
+        c_long  lroundl(real x) { return lround(x); }
+        long    llroundl(real x) { return llround(x); }
+        pure 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); }
+        pure real    copysignl(real x, real y) { return copysign(x, y); }
+        //pure double  nan(char* tagp);
+        //pure float   nanf(char* tagp);
+        //pure 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); }
+        pure real    fmaxl(real x, real y) { return fmax(x, y); }
+        pure real    fminl(real x, real y) { return fmin(x, y); }
+        pure real    fmal(real x, real y, real z) { return fma(x, y, z); }
+    }
   }
   else
   {
@@ -2205,49 +2208,49 @@ else version (FreeBSD)
     ///
     float   acoshf(float x);
     ///
-    real    acoshl(real x) { return acosh(x); }
+    extern(D) real acoshl(real x) { return acosh(x); }
 
     ///
     pure double  asinh(double x);
     ///
     pure float   asinhf(float x);
     ///
-    pure real    asinhl(real x) { return asinh(x); }
+    extern(D) pure real asinhl(real x) { return asinh(x); }
 
     ///
     double  atanh(double x);
     ///
     float   atanhf(float x);
     ///
-    real    atanhl(real x) { return atanh(x); }
+    extern(D) real atanhl(real x) { return atanh(x); }
 
     ///
     double  cosh(double x);
     ///
     float   coshf(float x);
     ///
-    real    coshl(real x) { return cosh(x); }
+    extern(D) real coshl(real x) { return cosh(x); }
 
     ///
     double  sinh(double x);
     ///
     float   sinhf(float x);
     ///
-    real    sinhl(real x) { return sinh(x); }
+    extern(D) real sinhl(real x) { return sinh(x); }
 
     ///
     pure double  tanh(double x);
     ///
     pure float   tanhf(float x);
     ///
-    pure real    tanhl(real x) { return tanh(x); }
+    extern(D) pure real tanhl(real x) { return tanh(x); }
 
     ///
     double  exp(double x);
     ///
     float   expf(float x);
     ///
-    real    expl(real x) { return exp(x); }
+    extern(D) real expl(real x) { return exp(x); }
 
     ///
     double  exp2(double x);
@@ -2259,7 +2262,7 @@ else version (FreeBSD)
     ///
     float   expm1f(float x);
     ///
-    real    expm1l(real x) { return expm1(x); }
+    extern(D) real expm1l(real x) { return expm1(x); }
 
     ///
     pure double  frexp(double value, int* exp);
@@ -2281,29 +2284,29 @@ else version (FreeBSD)
     ///
     float   logf(float x);
     ///
-    real    logl(real x) { return log(x); }
+    extern(D) real logl(real x) { return log(x); }
 
     ///
     double  log10(double x);
     ///
     float   log10f(float x);
     ///
-    real    log10l(real x) { return log10(x); }
+    extern(D) real log10l(real x) { return log10(x); }
 
     ///
     double  log1p(double x);
     ///
     float   log1pf(float x);
     ///
-    real    log1pl(real x) { return log1p(x); }
+    extern(D) real log1pl(real x) { return log1p(x); }
 
     private enum real ONE_LN2 = 1 / 0x1.62e42fefa39ef358p-1L;
     ///
-    double  log2(double x) { return log(x) * ONE_LN2; }
+    extern(D) double log2(double x) { return log(x) * ONE_LN2; }
     ///
-    float   log2f(float x) { return logf(x) * ONE_LN2; }
+    extern(D) float  log2f(float x) { return logf(x) * ONE_LN2; }
     ///
-    real    log2l(real x)  { return logl(x) * ONE_LN2; }
+    extern(D) real   log2l(real x)  { return logl(x) * ONE_LN2; }
 
     ///
     double  logb(double x);
@@ -2330,7 +2333,7 @@ else version (FreeBSD)
     ///
     pure float   cbrtf(float x);
     ///
-    pure real    cbrtl(real x) { return cbrt(x); }
+    extern(D) pure real cbrtl(real x) { return cbrt(x); }
 
     ///
     pure double  fabs(double x);
@@ -2347,7 +2350,7 @@ else version (FreeBSD)
     ///
     float   powf(float x, float y);
     ///
-    real    powl(real x, real y) { return pow(x, y); }
+    extern(D) real powl(real x, real y) { return pow(x, y); }
 
     ///
     double  sqrt(double x);
@@ -2359,28 +2362,28 @@ else version (FreeBSD)
     ///
     pure float   erff(float x);
     ///
-    pure real    erfl(real x) { return erf(x); }
+    extern(D) pure real erfl(real x) { return erf(x); }
 
     ///
     double  erfc(double x);
     ///
     float   erfcf(float x);
     ///
-    real    erfcl(real x) { return erfc(x); }
+    extern(D) real erfcl(real x) { return erfc(x); }
 
     ///
     double  lgamma(double x);
     ///
     float   lgammaf(float x);
     ///
-    real    lgammal(real x) { return lgamma(x); }
+    extern(D) real lgammal(real x) { return lgamma(x); }
 
     ///
     double  tgamma(double x);
     ///
     float   tgammaf(float x);
     ///
-    real    tgammal(real x) { return tgamma(x); }
+    extern(D) real tgammal(real x) { return tgamma(x); }
 
     ///
     pure double  ceil(double x);
@@ -2412,7 +2415,7 @@ else version (FreeBSD)
     ///
     long    llrintf(float x);
     ///
-    long    llrintl(real x) { return llrint(x); }
+    extern(D) long llrintl(real x) { return llrint(x); }
 
     ///
     pure double  round(double x);
@@ -2532,13 +2535,13 @@ else version (NetBSD)
     ///
     pure real    rintl(real x);
     ///
-    c_long  lrintl(real x) { return cast(c_long)rintl(x); }
+    extern(D) c_long lrintl(real x) { return cast(c_long)rintl(x); }
     ///
     pure real    roundl(real x);
     ///
-    c_long  lroundl(real x) { return cast(c_long)roundl(x);}
+    extern(D) c_long lroundl(real x) { return cast(c_long)roundl(x);}
     ///
-    long    llroundl(real x) { return cast(long)roundl(x);}
+    extern(D) long llroundl(real x) { return cast(long)roundl(x);}
     ///
     pure real    truncl(real x);
     ///
@@ -2558,7 +2561,7 @@ else version (NetBSD)
     ///
     real    nextafterl(real x, real y);
     ///
-    real    nexttowardl(real x, real y) { return nexttoward(cast(double) x, cast(double) y); }
+    extern(D) real nexttowardl(real x, real y) { return nexttoward(cast(double) x, cast(double) y); }
     ///
     real    fdiml(real x, real y);
     ///
@@ -2740,13 +2743,13 @@ else version (NetBSD)
     ///
     float   log1pf(float x);
     ///
-    real    log1pl(real x) { return log1p(cast(double) x); }
+    extern(D) real log1pl(real x) { return log1p(cast(double) x); }
 
     private enum real ONE_LN2 = 1 / 0x1.62e42fefa39ef358p-1L;
     ///
-    double  log2(double x) { return log(x) * ONE_LN2; }
+    extern(D) double log2(double x) { return log(x) * ONE_LN2; }
     ///
-    float   log2f(float x) { return logf(x) * ONE_LN2; }
+    extern(D) float log2f(float x) { return logf(x) * ONE_LN2; }
     ///
     real    log2l(real x)  { return logl(x) * ONE_LN2; }
 
@@ -2804,7 +2807,7 @@ else version (NetBSD)
     ///
     pure float   erff(float x);
     ///
-    pure real    erfl(real x) { return erf(cast(double) x); }
+    extern(D) pure real erfl(real x) { return erf(cast(double) x); }
 
     ///
     double  erfc(double x);
@@ -2857,7 +2860,7 @@ else version (NetBSD)
     ///
     long    llrintf(float x);
     ///
-    long    llrintl(real x) { return cast(long)rintl(x); }
+    extern(D) long llrintl(real x) { return cast(long)rintl(x); }
 
     ///
     pure double  round(double x);
@@ -3988,399 +3991,399 @@ else version (CRuntime_UClibc)
     ///
     float   acosf(float x);
     ///
-    real    acosl(real x) { return acos(cast(double) x); }
+    extern(D) real acosl(real x) { return acos(cast(double) x); }
 
     ///
     double  asin(double x);
     ///
     float   asinf(float x);
     ///
-    real    asinl(real x) { return asin(cast(double) x); }
+    extern(D) real asinl(real x) { return asin(cast(double) x); }
 
     ///
     pure double  atan(double x);
     ///
     pure float   atanf(float x);
     ///
-    pure real    atanl(real x) { return atan(cast(double) x); }
+    extern(D) pure real atanl(real x) { return atan(cast(double) x); }
 
     ///
     double  atan2(double y, double x);
     ///
     float   atan2f(float y, float x);
     ///
-    real    atan2l(real y, real x) { return atan2(cast(double) x, cast(double) y); }
+    extern(D) real atan2l(real y, real x) { return atan2(cast(double) x, cast(double) y); }
 
     ///
     pure double  cos(double x);
     ///
     pure float   cosf(float x);
     ///
-    pure real    cosl(real x) { return cos(cast(double) x); }
+    extern(D) pure real cosl(real x) { return cos(cast(double) x); }
 
     ///
     pure double  sin(double x);
     ///
     pure float   sinf(float x);
     ///
-    pure real    sinl(real x) { return sin(cast(double) x); }
+    extern(D) pure real sinl(real x) { return sin(cast(double) x); }
 
     ///
     pure double  tan(double x);
     ///
     pure float   tanf(float x);
     ///
-    pure real    tanl(real x) { return tan(cast(double) x); }
+    extern(D) pure real tanl(real x) { return tan(cast(double) x); }
 
     ///
     double  acosh(double x);
     ///
     float   acoshf(float x);
     ///
-    real    acoshl(real x) { return acosh(cast(double) x); }
+    extern(D) real acoshl(real x) { return acosh(cast(double) x); }
 
     ///
     pure double  asinh(double x);
     ///
     pure float   asinhf(float x);
     ///
-    pure real    asinhl(real x) { return asinh(cast(double) x); }
+    extern(D) pure real asinhl(real x) { return asinh(cast(double) x); }
 
     ///
     double  atanh(double x);
     ///
     float   atanhf(float x);
     ///
-    real    atanhl(real x) { return atanh(cast(double) x); }
+    extern(D) real atanhl(real x) { return atanh(cast(double) x); }
 
     ///
     double  cosh(double x);
     ///
     float   coshf(float x);
     ///
-    real    coshl(real x) { return cosh(cast(double) x); }
+    extern(D) real coshl(real x) { return cosh(cast(double) x); }
 
     ///
     double  sinh(double x);
     ///
     float   sinhf(float x);
     ///
-    real    sinhl(real x) { return sinh(cast(double) x); }
+    extern(D) real sinhl(real x) { return sinh(cast(double) x); }
 
     ///
     double  tanh(double x);
     ///
     float   tanhf(float x);
     ///
-    real    tanhl(real x) { return tanh(cast(double) x); }
+    extern(D) real tanhl(real x) { return tanh(cast(double) x); }
 
     ///
     double  exp(double x);
     ///
     float   expf(float x);
     ///
-    real    expl(real x) { return exp(cast(double) x); }
+    extern(D) real expl(real x) { return exp(cast(double) x); }
 
     ///
     double  exp2(double x);
     ///
     float   exp2f(float x);
     ///
-    real    exp2l(real x) { return exp2(cast(double) x); }
+    extern(D) real exp2l(real x) { return exp2(cast(double) x); }
 
     ///
     double  expm1(double x);
     ///
     float   expm1f(float x);
     ///
-    real    expm1l(real x) { return expm1(cast(double) x); }
+    extern(D) real expm1l(real x) { return expm1(cast(double) x); }
 
     ///
     pure double  frexp(double value, int* exp);
     ///
     pure float   frexpf(float value, int* exp);
     ///
-    pure real    frexpl(real value, int* exp) { return frexp(cast(double) value, exp); }
+    extern(D) pure real frexpl(real value, int* exp) { return frexp(cast(double) value, exp); }
 
     ///
     int     ilogb(double x);
     ///
     int     ilogbf(float x);
     ///
-    int     ilogbl(real x) { return ilogb(cast(double) x); }
+    extern(D) int ilogbl(real x) { return ilogb(cast(double) x); }
 
     ///
     double  ldexp(double x, int exp);
     ///
     float   ldexpf(float x, int exp);
     ///
-    real    ldexpl(real x, int exp) { return ldexp(cast(double) x, exp); }
+    extern(D) real ldexpl(real x, int exp) { return ldexp(cast(double) x, exp); }
 
     ///
     double  log(double x);
     ///
     float   logf(float x);
     ///
-    real    logl(real x) { return log(cast(double) x); }
+    extern(D) real logl(real x) { return log(cast(double) x); }
 
     ///
     double  log10(double x);
     ///
     float   log10f(float x);
     ///
-    real    log10l(real x) { return log10(cast(double) x); }
+    extern(D) real log10l(real x) { return log10(cast(double) x); }
 
     ///
     double  log1p(double x);
     ///
     float   log1pf(float x);
     ///
-    real    log1pl(real x) { return log1p(cast(double) x); }
+    extern(D) real log1pl(real x) { return log1p(cast(double) x); }
 
     ///
     double  log2(double x);
     ///
     float   log2f(float x);
     ///
-    real    log2l(real x) { return log2(cast(double) x); }
+    extern(D) real log2l(real x) { return log2(cast(double) x); }
 
     ///
     double  logb(double x);
     ///
     float   logbf(float x);
     ///
-    real    logbl(real x) { return logb(cast(double) x); }
+    extern(D) real logbl(real x) { return logb(cast(double) x); }
 
     ///
     pure double  modf(double value, double* iptr);
     ///
     pure float   modff(float value, float* iptr);
     ///
-    pure real    modfl(real value, real *iptr) { return modf(cast(double) value, cast(double*) iptr); }
+    extern(D) pure real modfl(real value, real *iptr) { return modf(cast(double) value, cast(double*) iptr); }
 
     ///
     double  scalbn(double x, int n);
     ///
     float   scalbnf(float x, int n);
     ///
-    real    scalbnl(real x, int n) { return scalbln(cast(double) x, n); }
+    extern(D) real scalbnl(real x, int n) { return scalbln(cast(double) 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(cast(double) x, n); }
+    extern(D) real scalblnl(real x, c_long n) { return scalbln(cast(double) x, n); }
 
     ///
     pure double  cbrt(double x);
     ///
     pure float   cbrtf(float x);
     ///
-    pure real    cbrtl(real x) { return cbrt(cast(double) x); }
+    extern(D) pure real cbrtl(real x) { return cbrt(cast(double) x); }
 
     ///
     pure double  fabs(double x);
     ///
     pure float   fabsf(float x);
     ///
-    pure real    fabsl(real x) { return fabs(cast(double) x); }
+    extern(D) pure real fabsl(real x) { return fabs(cast(double) x); }
 
     ///
     double  hypot(double x, double y);
     ///
     float   hypotf(float x, float y);
     ///
-    real    hypotl(real x, real y) { return hypot(cast(double) x, cast(double) y); }
+    extern(D) real hypotl(real x, real y) { return hypot(cast(double) x, cast(double) y); }
 
     ///
     double  pow(double x, double y);
     ///
     float   powf(float x, float y);
     ///
-    real    powl(real x, real y) { return pow(cast(double) x, cast(double) y); }
+    extern(D) real powl(real x, real y) { return pow(cast(double) x, cast(double) y); }
 
     ///
     double  sqrt(double x);
     ///
     float   sqrtf(float x);
     ///
-    real    sqrtl(real x) { return sqrt(cast(double) x); }
+    extern(D) real sqrtl(real x) { return sqrt(cast(double) x); }
 
     ///
     pure double  erf(double x);
     ///
     pure float   erff(float x);
     ///
-    pure real    erfl(real x) { return erf(cast(double) x); }
+    extern(D) pure real erfl(real x) { return erf(cast(double) x); }
 
     ///
     double  erfc(double x);
     ///
     float   erfcf(float x);
     ///
-    real    erfcl(real x) { return erfc(cast(double) x); }
+    extern(D) real erfcl(real x) { return erfc(cast(double) x); }
 
     ///
     double  lgamma(double x);
     ///
     float   lgammaf(float x);
     ///
-    real    lgammal(real x) { return lgamma(cast(double) x); }
+    extern(D) real lgammal(real x) { return lgamma(cast(double) x); }
 
     ///
     double  tgamma(double x);
     ///
     float   tgammaf(float x);
     ///
-    real    tgammal(real x) { return tgamma(cast(double) x); }
+    extern(D) real tgammal(real x) { return tgamma(cast(double) x); }
 
     ///
     pure double  ceil(double x);
     ///
     pure float   ceilf(float x);
     ///
-    pure real    ceill(real x) { return ceil(cast(double) x); }
+    extern(D) pure real ceill(real x) { return ceil(cast(double) x); }
 
     ///
     pure double  floor(double x);
     ///
     pure float   floorf(float x);
     ///
-    pure real    floorl(real x) { return floor(cast(double) x); }
+    extern(D) pure real floorl(real x) { return floor(cast(double) x); }
 
     ///
     pure double  nearbyint(double x);
     ///
     pure float   nearbyintf(float x);
     ///
-    pure real    nearbyintl(real x) { return nearbyint(cast(double) x); }
+    extern(D) pure real nearbyintl(real x) { return nearbyint(cast(double) x); }
 
     ///
     pure double  rint(double x);
     ///
     pure float   rintf(float x);
     ///
-    pure real    rintl(real x) { return rint(cast(double) x); }
+    extern(D) pure real rintl(real x) { return rint(cast(double) x); }
 
     ///
     c_long  lrint(double x);
     ///
     c_long  lrintf(float x);
     ///
-    c_long  lrintl(real x) { return lrint(cast(double) x); }
+    extern(D) c_long lrintl(real x) { return lrint(cast(double) x); }
 
     ///
     long    llrint(double x);
     ///
     long    llrintf(float x);
     ///
-    long    llrintl(real x) { return llrint(cast(double) x); }
+    extern(D) long llrintl(real x) { return llrint(cast(double) x); }
 
     ///
     pure double  round(double x);
     ///
     pure float   roundf(float x);
     ///
-    pure real    roundl(real x) { return round(cast(double) x); }
+    extern(D) pure real roundl(real x) { return round(cast(double) x); }
 
     ///
     c_long  lround(double x);
     ///
     c_long  lroundf(float x);
     ///
-    c_long  lroundl(real x) { return lround(cast(double) x); }
+    extern(D) c_long lroundl(real x) { return lround(cast(double) x); }
 
     ///
     long    llround(double x);
     ///
     long    llroundf(float x);
     ///
-    long    llroundl(real x) { return llround(cast(double) x); }
+    extern(D) long llroundl(real x) { return llround(cast(double) x); }
 
     ///
     pure double  trunc(double x);
     ///
     pure float   truncf(float x);
     ///
-    pure real    truncl(real x) { return trunc(cast(double) x); }
+    extern(D) pure real truncl(real x) { return trunc(cast(double) x); }
 
     ///
     double  fmod(double x, double y);
     ///
     float   fmodf(float x, float y);
     ///
-    real    fmodl(real x, real y) { return fmod(cast(double) x, cast(double) y); }
+    extern(D) real fmodl(real x, real y) { return fmod(cast(double) x, cast(double) y); }
 
     ///
     double  remainder(double x, double y);
     ///
     float   remainderf(float x, float y);
     ///
-    real    remainderl(real x, real y) { return remainder(cast(double) x, cast(double) y); }
+    extern(D) real remainderl(real x, real y) { return remainder(cast(double) x, cast(double) 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(cast(double) x, cast(double) y, quo); }
+    extern(D) real remquol(real x, real y, int* quo) { return remquo(cast(double) x, cast(double) y, quo); }
 
     ///
     pure double  copysign(double x, double y);
     ///
     pure float   copysignf(float x, float y);
     ///
-    pure real    copysignl(real x, real y) { return copysign(cast(double) x, cast(double) y); }
+    extern(D) pure real copysignl(real x, real y) { return copysign(cast(double) x, cast(double) y); }
 
     ///
     pure double  nan(char* tagp);
     ///
     pure float   nanf(char* tagp);
     ///
-    pure real    nanl(char* tagp) { return nan(tagp); }
+    extern(D) pure real nanl(char* tagp) { return nan(tagp); }
 
     ///
     double  nextafter(double x, double y);
     ///
     float   nextafterf(float x, float y);
     ///
-    real    nextafterl(real x, real y) { return nextafter(cast(double) x, cast(double) y); }
+    extern(D) real nextafterl(real x, real y) { return nextafter(cast(double) x, cast(double) y); }
 
     ///
     double  nexttoward(double x, real y);
     ///
     float   nexttowardf(float x, real y);
     ///
-    real    nexttowardl(real x, real y) { return nexttoward(cast(double) x, cast(double) y); }
+    extern(D) real nexttowardl(real x, real y) { return nexttoward(cast(double) x, cast(double) y); }
 
     ///
     double  fdim(double x, double y);
     ///
     float   fdimf(float x, float y);
     ///
-    real    fdiml(real x, real y) { return fdim(cast(double) x, cast(double) y); }
+    extern(D) real fdiml(real x, real y) { return fdim(cast(double) x, cast(double) y); }
 
     ///
     pure double  fmax(double x, double y);
     ///
     pure float   fmaxf(float x, float y);
     ///
-    pure real    fmaxl(real x, real y) { return fmax(cast(double) x, cast(double) y); }
+    extern(D) pure real fmaxl(real x, real y) { return fmax(cast(double) x, cast(double) y); }
 
     ///
     pure double  fmin(double x, double y);
     ///
     pure float   fminf(float x, float y);
     ///
-    pure real    fminl(real x, real y) { return fmin(cast(double) x, cast(double) y); }
+    extern(D) pure real fminl(real x, real y) { return fmin(cast(double) x, cast(double) y); }
 
     ///
     pure double  fma(double x, double y, double z);
     ///
     pure float   fmaf(float x, float y, float z);
     ///
-    pure real    fmal(real x, real y, real z) { return fma(cast(double) x, cast(double) y, cast(double) z); }
+    extern(D) pure real fmal(real x, real y, real z) { return fma(cast(double) x, cast(double) y, cast(double) z); }
 }
 else
 {
diff --git a/libphobos/libdruntime/core/sys/posix/fcntl.d b/libphobos/libdruntime/core/sys/posix/fcntl.d
index 2f1daf6ebc9..867356c67e6 100644
--- a/libphobos/libdruntime/core/sys/posix/fcntl.d
+++ b/libphobos/libdruntime/core/sys/posix/fcntl.d
@@ -120,6 +120,13 @@ version (CRuntime_Glibc)
     enum F_SETLK        = 6;
     enum F_SETLKW       = 7;
   }
+  else version (SystemZ)
+  {
+    static assert(off_t.sizeof == 8);
+    enum F_GETLK        = 5;
+    enum F_SETLK        = 6;
+    enum F_SETLKW       = 7;
+  }
   else
   static if ( __USE_FILE_OFFSET64 )
   {
diff --git a/libphobos/libdruntime/core/sys/posix/spawn.d b/libphobos/libdruntime/core/sys/posix/spawn.d
index f5e6c6dbe71..aa59c2f0bf0 100644
--- a/libphobos/libdruntime/core/sys/posix/spawn.d
+++ b/libphobos/libdruntime/core/sys/posix/spawn.d
@@ -239,7 +239,8 @@ else version (Darwin)
         // POSIX_SPAWN_SETSCHEDPARAM = 0x10,  // not supported
         // POSIX_SPAWN_SETSCHEDULER = 0x20,   // ditto
         POSIX_SPAWN_SETEXEC = 0x40,
-        POSIX_SPAWN_START_SUSPENDED = 0x80
+        POSIX_SPAWN_START_SUSPENDED = 0x80,
+        POSIX_SPAWN_CLOEXEC_DEFAULT = 0x4000
     }
     alias posix_spawnattr_t = void*;
     alias posix_spawn_file_actions_t = void*;
@@ -288,6 +289,8 @@ else version (NetBSD)
         uint len;
         posix_spawn_file_actions_entry_t* fae;
     }
+    alias posix_spawnattr_t = posix_spawnattr;
+    alias posix_spawn_file_actions_t = posix_spawn_file_actions;
 }
 else version (OpenBSD)
 {
diff --git a/libphobos/libdruntime/core/sys/posix/sys/stat.d b/libphobos/libdruntime/core/sys/posix/sys/stat.d
index 53858e713bb..ab1fcd7b164 100644
--- a/libphobos/libdruntime/core/sys/posix/sys/stat.d
+++ b/libphobos/libdruntime/core/sys/posix/sys/stat.d
@@ -799,12 +799,12 @@ version (CRuntime_Glibc)
             alias __ino_t = c_ulong;
             alias __ino64_t = ulong;
             alias __mode_t = uint;
-            alias __nlink_t = uint;
+            alias __nlink_t = ulong;
             alias __uid_t = uint;
             alias __gid_t = uint;
             alias __off_t = c_long;
             alias __off64_t = long;
-            alias __blksize_t = int;
+            alias __blksize_t = c_long;
             alias __blkcnt_t = c_long;
             alias __blkcnt64_t = long;
             alias __timespec = timespec;
diff --git a/libphobos/libdruntime/core/thread.d b/libphobos/libdruntime/core/thread.d
index 0466e7ae631..3d2cd287a2e 100644
--- a/libphobos/libdruntime/core/thread.d
+++ b/libphobos/libdruntime/core/thread.d
@@ -1187,7 +1187,7 @@ class Thread
             }
             else
             {
-                // NOTE: pthread_setschedprio is not implemented on Darwin or FreeBSD, so use
+                // NOTE: pthread_setschedprio is not implemented on Darwin, FreeBSD or DragonFlyBSD, so use
                 //       the more complicated get/set sequence below.
                 int         policy;
                 sched_param param;
@@ -3202,8 +3202,11 @@ extern (C) @nogc nothrow
     version (CRuntime_Glibc) int pthread_getattr_np(pthread_t thread, pthread_attr_t* attr);
     version (FreeBSD) int pthread_attr_get_np(pthread_t thread, pthread_attr_t* attr);
     version (NetBSD) int pthread_attr_get_np(pthread_t thread, pthread_attr_t* attr);
+    version (DragonFlyBSD) int pthread_attr_get_np(pthread_t thread, pthread_attr_t* attr);
     version (Solaris) int thr_stksegment(stack_t* stk);
     version (CRuntime_Bionic) int pthread_getattr_np(pthread_t thid, pthread_attr_t* attr);
+    version (CRuntime_Musl) int pthread_getattr_np(pthread_t, pthread_attr_t*);
+    version (CRuntime_UClibc) int pthread_getattr_np(pthread_t thread, pthread_attr_t* attr);
 }
 
 
@@ -3292,6 +3295,19 @@ private void* getStackBottom() nothrow @nogc
             addr += size;
         return addr;
     }
+    else version (DragonFlyBSD)
+    {
+        pthread_attr_t attr;
+        void* addr; size_t size;
+
+        pthread_attr_init(&attr);
+        pthread_attr_get_np(pthread_self(), &attr);
+        pthread_attr_getstack(&attr, &addr, &size);
+        pthread_attr_destroy(&attr);
+        version (StackGrowsDown)
+            addr += size;
+        return addr;
+    }
     else version (Solaris)
     {
         stack_t stk;
@@ -3311,6 +3327,30 @@ private void* getStackBottom() nothrow @nogc
             addr += size;
         return addr;
     }
+    else version (CRuntime_Musl)
+    {
+        pthread_attr_t attr;
+        void* addr; size_t size;
+
+        pthread_getattr_np(pthread_self(), &attr);
+        pthread_attr_getstack(&attr, &addr, &size);
+        pthread_attr_destroy(&attr);
+        version (StackGrowsDown)
+            addr += size;
+        return addr;
+    }
+    else version (CRuntime_UClibc)
+    {
+        pthread_attr_t attr;
+        void* addr; size_t size;
+
+        pthread_getattr_np(pthread_self(), &attr);
+        pthread_attr_getstack(&attr, &addr, &size);
+        pthread_attr_destroy(&attr);
+        version (StackGrowsDown)
+            addr += size;
+        return addr;
+    }
     else
         static assert(false, "Platform not supported.");
 }
@@ -4569,8 +4609,10 @@ private:
             version (Posix) import core.sys.posix.sys.mman; // mmap
             version (FreeBSD) import core.sys.freebsd.sys.mman : MAP_ANON;
             version (NetBSD) import core.sys.netbsd.sys.mman : MAP_ANON;
+            version (DragonFlyBSD) import core.sys.dragonflybsd.sys.mman : MAP_ANON;
             version (CRuntime_Glibc) import core.sys.linux.sys.mman : MAP_ANON;
             version (Darwin) import core.sys.darwin.sys.mman : MAP_ANON;
+            version (CRuntime_UClibc) import core.sys.linux.sys.mman : MAP_ANON;
 
             static if ( __traits( compiles, mmap ) )
             {
@@ -5612,6 +5654,27 @@ version (FreeBSD) unittest
     thr.join();
 }
 
+version (DragonFlyBSD) unittest
+{
+    static void loop()
+    {
+        pthread_attr_t attr;
+        pthread_attr_init(&attr);
+        auto thr = pthread_self();
+        foreach (i; 0 .. 50)
+            pthread_attr_get_np(thr, &attr);
+        pthread_attr_destroy(&attr);
+    }
+
+    auto thr = new Thread(&loop).start();
+    foreach (i; 0 .. 50)
+    {
+        thread_suspendAll();
+        thread_resumeAll();
+    }
+    thr.join();
+}
+
 unittest
 {
     // use >PAGESIZE to avoid stack overflow (e.g. in an syscall)
diff --git a/libphobos/libdruntime/rt/aApplyR.d b/libphobos/libdruntime/rt/aApplyR.d
index 4b39f7093f3..b29d3706af7 100644
--- a/libphobos/libdruntime/rt/aApplyR.d
+++ b/libphobos/libdruntime/rt/aApplyR.d
@@ -272,7 +272,7 @@ extern (C) int _aApplyRwc1(in wchar[] aa, dg_t dg)
 
         if (d & ~0x7F)
         {
-            char[4] buf;
+            char[4] buf = void;
 
             auto b = toUTF8(buf, d);
             foreach (char c2; b)
@@ -348,7 +348,7 @@ extern (C) int _aApplyRdc1(in dchar[] aa, dg_t dg)
 
         if (d & ~0x7F)
         {
-            char[4] buf;
+            char[4] buf = void;
 
             auto b = toUTF8(buf, d);
             foreach (char c2; b)
@@ -741,7 +741,7 @@ extern (C) int _aApplyRwc2(in wchar[] aa, dg2_t dg)
 
         if (d & ~0x7F)
         {
-            char[4] buf;
+            char[4] buf = void;
 
             auto b = toUTF8(buf, d);
             foreach (char c2; b)
@@ -819,7 +819,7 @@ extern (C) int _aApplyRdc2(in dchar[] aa, dg2_t dg)
 
         if (d & ~0x7F)
         {
-            char[4] buf;
+            char[4] buf = void;
 
             auto b = toUTF8(buf, d);
             foreach (char c2; b)
diff --git a/libphobos/libdruntime/rt/config.d b/libphobos/libdruntime/rt/config.d
index fb791eac8d4..904f7219240 100644
--- a/libphobos/libdruntime/rt/config.d
+++ b/libphobos/libdruntime/rt/config.d
@@ -115,7 +115,7 @@ string rt_envvarsOption(string opt, scope rt_configCallBack dg) @nogc nothrow
         if (opt.length >= 32)
             assert(0);
 
-        char[40] var;
+        char[40] var = void;
         var[0 .. 4] = "DRT_";
         foreach (i, c; opt)
             var[4 + i] = cast(char) toupper(c);
diff --git a/libphobos/libdruntime/rt/dmain2.d b/libphobos/libdruntime/rt/dmain2.d
index d9376892769..f45565c971a 100644
--- a/libphobos/libdruntime/rt/dmain2.d
+++ b/libphobos/libdruntime/rt/dmain2.d
@@ -42,6 +42,10 @@ version (NetBSD)
 {
     import core.stdc.fenv;
 }
+version (DragonFlyBSD)
+{
+    import core.stdc.fenv;
+}
 
 extern (C) void _d_monitor_staticctor();
 extern (C) void _d_monitor_staticdtor();
diff --git a/libphobos/libdruntime/rt/monitor_.d b/libphobos/libdruntime/rt/monitor_.d
index 8d301ad763a..e38b015f01e 100644
--- a/libphobos/libdruntime/rt/monitor_.d
+++ b/libphobos/libdruntime/rt/monitor_.d
@@ -193,7 +193,8 @@ else version (Windows)
     {
         pragma(lib, "snn.lib");
     }
-    import core.sys.windows.windows;
+    import core.sys.windows.winbase /+: CRITICAL_SECTION, DeleteCriticalSection,
+        EnterCriticalSection, InitializeCriticalSection, LeaveCriticalSection+/;
 
     alias Mutex = CRITICAL_SECTION;
 
@@ -206,6 +207,7 @@ else version (Posix)
 {
     import core.sys.posix.pthread;
 
+@nogc:
     alias Mutex = pthread_mutex_t;
     __gshared pthread_mutexattr_t gattr;
 
@@ -244,17 +246,17 @@ struct Monitor
 
 private:
 
-@property ref shared(Monitor*) monitor(Object h) pure nothrow
+@property ref shared(Monitor*) monitor(Object h) pure nothrow @nogc
 {
     return *cast(shared Monitor**)&h.__monitor;
 }
 
-private shared(Monitor)* getMonitor(Object h) pure
+private shared(Monitor)* getMonitor(Object h) pure @nogc
 {
     return atomicLoad!(MemoryOrder.acq)(h.monitor);
 }
 
-void setMonitor(Object h, shared(Monitor)* m) pure
+void setMonitor(Object h, shared(Monitor)* m) pure @nogc
 {
     atomicStore!(MemoryOrder.rel)(h.monitor, m);
 }
@@ -296,7 +298,7 @@ shared(Monitor)* ensureMonitor(Object h)
     }
 }
 
-void deleteMonitor(Monitor* m)
+void deleteMonitor(Monitor* m) @nogc
 {
     destroyMutex(&m.mtx);
     free(m);
diff --git a/libphobos/libdruntime/rt/qsort.d b/libphobos/libdruntime/rt/qsort.d
index af0c1eb704a..079a0f574b9 100644
--- a/libphobos/libdruntime/rt/qsort.d
+++ b/libphobos/libdruntime/rt/qsort.d
@@ -75,6 +75,21 @@ else version (FreeBSD)
         return a;
     }
 }
+else version (DragonFlyBSD)
+{
+    alias extern (C) int function(scope void *, scope const void *, scope const void *) Cmp;
+    extern (C) void qsort_r(scope void *base, size_t nmemb, size_t size, scope void *thunk, Cmp cmp);
+
+    extern (C) void[] _adSort(return scope void[] a, TypeInfo ti)
+    {
+        extern (C) int cmp(scope void* ti, scope const void* p1, scope const void* p2)
+        {
+            return (cast(TypeInfo)ti).compare(p1, p2);
+        }
+        qsort_r(a.ptr, a.length, ti.tsize, cast(void*)ti, &cmp);
+        return a;
+    }
+}
 else version (Darwin)
 {
     alias extern (C) int function(scope void *, scope const void *, scope const void *) Cmp;
@@ -90,6 +105,21 @@ else version (Darwin)
         return a;
     }
 }
+else version (CRuntime_UClibc)
+{
+    alias extern (C) int function(scope const void *, scope const void *, scope void *) __compar_d_fn_t;
+    extern (C) void qsort_r(scope void *base, size_t nmemb, size_t size, __compar_d_fn_t cmp, scope void *arg);
+
+    extern (C) void[] _adSort(return scope void[] a, TypeInfo ti)
+    {
+        extern (C) int cmp(scope const void* p1, scope const void* p2, scope void* ti)
+        {
+            return (cast(TypeInfo)ti).compare(p1, p2);
+        }
+        qsort_r(a.ptr, a.length, ti.tsize, &cmp, cast(void*)ti);
+        return a;
+    }
+}
 else
 {
     private TypeInfo tiglobal;

                 reply	other threads:[~2019-04-22 13:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CABOHX+eqRWL8=2NUw5JeK773xN6b72=fM9ozj+Gy7NKb4C_Fdw@mail.gmail.com' \
    --to=ibuclaw@gdcproject.org \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).