aboutsummaryrefslogtreecommitdiff
path: root/libphobos/src
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2022-06-22 17:03:33 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2022-06-22 17:57:56 +0200
commit445d8deffb6c9bc1f4a5ed0a8e02d7f31d3caec7 (patch)
tree4b9aa4224d827abfe081adf2289af34436d3e552 /libphobos/src
parentd844478ab47a16c8ae65f253fd1cdc685c7951fc (diff)
downloadgcc-445d8deffb6c9bc1f4a5ed0a8e02d7f31d3caec7.zip
gcc-445d8deffb6c9bc1f4a5ed0a8e02d7f31d3caec7.tar.gz
gcc-445d8deffb6c9bc1f4a5ed0a8e02d7f31d3caec7.tar.bz2
d: Merge upstream dmd 6203135dc, druntime e150cca1, phobos a4a18d21c.
D front-end changes: - Input parameters can now be applied on extern(C++) functions to bind to `const &' when the `-fpreview=in' flag is in effect. D runtime changes: - Run-time flag `--DRT-oncycle=deprecate' has been removed. Phobos changes: - Removed std.experimental.logger's capability to set the minimal LogLevel at compile time. gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 6203135dc. * typeinfo.cc (TypeInfoVisitor::visit (TypeInfoStructDeclaration *)): Update for new front-end interface. (SpeculativeTypeVisitor::visit (TypeStruct *)): Likewise. libphobos/ChangeLog: * libdruntime/MERGE: Merge upstream druntime e150cca1. * src/MERGE: Merge upstream phobos a4a18d21c. * testsuite/libphobos.cycles/cycles.exp (cycle_test_list): Update expected result of deprecate test.
Diffstat (limited to 'libphobos/src')
-rw-r--r--libphobos/src/MERGE2
-rw-r--r--libphobos/src/std/complex.d2
-rw-r--r--libphobos/src/std/experimental/logger/core.d329
-rw-r--r--libphobos/src/std/experimental/logger/package.d20
-rw-r--r--libphobos/src/std/file.d30
-rw-r--r--libphobos/src/std/math/algebraic.d6
-rw-r--r--libphobos/src/std/math/hardware.d6
-rw-r--r--libphobos/src/std/math/trigonometry.d46
-rw-r--r--libphobos/src/std/numeric.d44
-rw-r--r--libphobos/src/std/stdio.d12
-rw-r--r--libphobos/src/std/sumtype.d50
11 files changed, 195 insertions, 352 deletions
diff --git a/libphobos/src/MERGE b/libphobos/src/MERGE
index 30e9e80..a4daa84 100644
--- a/libphobos/src/MERGE
+++ b/libphobos/src/MERGE
@@ -1,4 +1,4 @@
-1206fc94f967b0183667a109049cbf596deaa696
+a4a18d21c4ea7930f80309f85e38c571c5f6d4b8
The first line of this file holds the git revision number of the last
merge done from the dlang/phobos repository.
diff --git a/libphobos/src/std/complex.d b/libphobos/src/std/complex.d
index 485b548..6b1541a 100644
--- a/libphobos/src/std/complex.d
+++ b/libphobos/src/std/complex.d
@@ -935,7 +935,7 @@ Complex!(CommonType!(T, U)) fromPolar(T, U)(const T modulus, const U argument)
import std.math.operations : isClose;
import std.math.algebraic : sqrt;
import std.math.constants : PI_4;
- auto z = fromPolar(core.math.sqrt(2.0), PI_4);
+ auto z = fromPolar(core.math.sqrt(2.0L), PI_4);
assert(isClose(z.re, 1.0L));
assert(isClose(z.im, 1.0L));
}
diff --git a/libphobos/src/std/experimental/logger/core.d b/libphobos/src/std/experimental/logger/core.d
index efc4ef7..d899db7 100644
--- a/libphobos/src/std/experimental/logger/core.d
+++ b/libphobos/src/std/experimental/logger/core.d
@@ -12,56 +12,6 @@ import std.traits;
import std.experimental.logger.filelogger;
-/** This template evaluates if the passed `LogLevel` is active.
-The previously described version statements are used to decide if the
-`LogLevel` is active. The version statements only influence the compile
-unit they are used with, therefore this function can only disable logging this
-specific compile unit.
-*/
-template isLoggingActiveAt(LogLevel ll)
-{
- version (StdLoggerDisableLogging)
- {
- enum isLoggingActiveAt = false;
- }
- else
- {
- static if (ll == LogLevel.trace)
- {
- version (StdLoggerDisableTrace) enum isLoggingActiveAt = false;
- }
- else static if (ll == LogLevel.info)
- {
- version (StdLoggerDisableInfo) enum isLoggingActiveAt = false;
- }
- else static if (ll == LogLevel.warning)
- {
- version (StdLoggerDisableWarning) enum isLoggingActiveAt = false;
- }
- else static if (ll == LogLevel.error)
- {
- version (StdLoggerDisableError) enum isLoggingActiveAt = false;
- }
- else static if (ll == LogLevel.critical)
- {
- version (StdLoggerDisableCritical) enum isLoggingActiveAt = false;
- }
- else static if (ll == LogLevel.fatal)
- {
- version (StdLoggerDisableFatal) enum isLoggingActiveAt = false;
- }
- // If `isLoggingActiveAt` didn't get defined above to false,
- // we default it to true.
- static if (!is(typeof(isLoggingActiveAt) == bool))
- {
- enum isLoggingActiveAt = true;
- }
- }
-}
-
-/// This compile-time flag is `true` if logging is not statically disabled.
-enum isLoggingActive = isLoggingActiveAt!(LogLevel.all);
-
/** This functions is used at runtime to determine if a `LogLevel` is
active. The same previously defined version statements are used to disable
certain levels. Again the version statements are associated with a compile
@@ -71,26 +21,6 @@ pure bool isLoggingEnabled()(LogLevel ll) @safe nothrow @nogc
bool isLoggingEnabled()(LogLevel ll, LogLevel loggerLL,
LogLevel globalLL, lazy bool condition = true) @safe
{
- switch (ll)
- {
- case LogLevel.trace:
- version (StdLoggerDisableTrace) return false;
- else break;
- case LogLevel.info:
- version (StdLoggerDisableInfo) return false;
- else break;
- case LogLevel.warning:
- version (StdLoggerDisableWarning) return false;
- else break;
- case LogLevel.critical:
- version (StdLoggerDisableCritical) return false;
- else break;
- case LogLevel.fatal:
- version (StdLoggerDisableFatal) return false;
- else break;
- default: break;
- }
-
return ll >= globalLL
&& ll >= loggerLL
&& ll != LogLevel.off
@@ -99,66 +29,6 @@ bool isLoggingEnabled()(LogLevel ll, LogLevel loggerLL,
&& condition;
}
-/** This template returns the `LogLevel` named "logLevel" of type $(D
-LogLevel) defined in a user defined module where the filename has the
-suffix "_loggerconfig.d". This `LogLevel` sets the minimal `LogLevel`
-of the module.
-
-A minimal `LogLevel` can be defined on a per module basis.
-In order to define a module `LogLevel` a file with a modulename
-"MODULENAME_loggerconfig" must be found. If no such module exists and the
-module is a nested module, it is checked if there exists a
-"PARENT_MODULE_loggerconfig" module with such a symbol.
-If this module exists and it contains a `LogLevel` called logLevel this $(D
-LogLevel) will be used. This parent lookup is continued until there is no
-parent module. Then the moduleLogLevel is `LogLevel.all`.
-*/
-template moduleLogLevel(string moduleName)
-if (!moduleName.length)
-{
- // default
- enum moduleLogLevel = LogLevel.all;
-}
-
-///
-@system unittest
-{
- static assert(moduleLogLevel!"" == LogLevel.all);
-}
-
-/// ditto
-template moduleLogLevel(string moduleName)
-if (moduleName.length)
-{
- import std.string : format;
- mixin(q{
- static if (__traits(compiles, {import %1$s : logLevel;}))
- {
- import %1$s : logLevel;
- static assert(is(typeof(logLevel) : LogLevel),
- "Expect 'logLevel' to be of Type 'LogLevel'.");
- // don't enforce enum here
- alias moduleLogLevel = logLevel;
- }
- else
- // use logLevel of package or default
- alias moduleLogLevel = moduleLogLevel!(parentOf(moduleName));
- }.format(moduleName ~ "_loggerconfig"));
-}
-
-///
-@system unittest
-{
- static assert(moduleLogLevel!"not.amodule.path" == LogLevel.all);
-}
-
-private string parentOf(string mod)
-{
- foreach_reverse (i, c; mod)
- if (c == '.') return mod[0 .. i];
- return null;
-}
-
/* This function formates a `SysTime` into an `OutputRange`.
The `SysTime` is formatted similar to
@@ -200,14 +70,8 @@ void log(int line = __LINE__, string file = __FILE__,
lazy bool condition, lazy A args)
if (args.length != 1)
{
- static if (isLoggingActive)
- {
- if (ll >= moduleLogLevel!moduleName)
- {
- stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName)
- (ll, condition, args);
- }
- }
+ stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName)
+ (ll, condition, args);
}
/// Ditto
@@ -215,14 +79,8 @@ void log(T, string moduleName = __MODULE__)(const LogLevel ll,
lazy bool condition, lazy T arg, int line = __LINE__, string file = __FILE__,
string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__)
{
- static if (isLoggingActive)
- {
- if (ll >= moduleLogLevel!moduleName)
- {
- stdThreadLocalLog.log!(T,moduleName)(ll, condition, arg, line, file, funcName,
- prettyFuncName);
- }
- }
+ stdThreadLocalLog.log!(T,moduleName)(ll, condition, arg, line, file, funcName,
+ prettyFuncName);
}
/** This function logs data.
@@ -244,14 +102,8 @@ void log(int line = __LINE__, string file = __FILE__,
string moduleName = __MODULE__, A...)(const LogLevel ll, lazy A args)
if (args.length > 1 && !is(Unqual!(A[0]) : bool))
{
- static if (isLoggingActive)
- {
- if (ll >= moduleLogLevel!moduleName)
- {
- stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName)
- (ll, args);
- }
- }
+ stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName)
+ (ll, args);
}
/// Ditto
@@ -259,14 +111,8 @@ void log(T, string moduleName = __MODULE__)(const LogLevel ll, lazy T arg,
int line = __LINE__, string file = __FILE__, string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__)
{
- static if (isLoggingActive)
- {
- if (ll >= moduleLogLevel!moduleName)
- {
- stdThreadLocalLog.log!T(ll, arg, line, file, funcName, prettyFuncName,
- moduleName);
- }
- }
+ stdThreadLocalLog.log!T(ll, arg, line, file, funcName, prettyFuncName,
+ moduleName);
}
/** This function logs data.
@@ -289,11 +135,8 @@ void log(int line = __LINE__, string file = __FILE__,
string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args)
if (args.length != 1)
{
- static if (isLoggingActive)
- {
- stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName)
- (stdThreadLocalLog.logLevel, condition, args);
- }
+ stdThreadLocalLog.log!(line, file, funcName, prettyFuncName, moduleName)
+ (stdThreadLocalLog.logLevel, condition, args);
}
/// Ditto
@@ -301,11 +144,8 @@ void log(T, string moduleName = __MODULE__)(lazy bool condition, lazy T arg,
int line = __LINE__, string file = __FILE__, string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__)
{
- static if (isLoggingActive)
- {
- stdThreadLocalLog.log!(T,moduleName)(stdThreadLocalLog.logLevel,
- condition, arg, line, file, funcName, prettyFuncName);
- }
+ stdThreadLocalLog.log!(T,moduleName)(stdThreadLocalLog.logLevel,
+ condition, arg, line, file, funcName, prettyFuncName);
}
/** This function logs data.
@@ -328,22 +168,16 @@ if ((args.length > 1 && !is(Unqual!(A[0]) : bool)
&& !is(Unqual!(A[0]) == LogLevel))
|| args.length == 0)
{
- static if (isLoggingActive)
- {
- stdThreadLocalLog.log!(line, file, funcName,
- prettyFuncName, moduleName)(stdThreadLocalLog.logLevel, args);
- }
+ stdThreadLocalLog.log!(line, file, funcName,
+ prettyFuncName, moduleName)(stdThreadLocalLog.logLevel, args);
}
void log(T)(lazy T arg, int line = __LINE__, string file = __FILE__,
string funcName = __FUNCTION__, string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__)
{
- static if (isLoggingActive)
- {
- stdThreadLocalLog.log!T(stdThreadLocalLog.logLevel, arg, line, file,
- funcName, prettyFuncName, moduleName);
- }
+ stdThreadLocalLog.log!T(stdThreadLocalLog.logLevel, arg, line, file,
+ funcName, prettyFuncName, moduleName);
}
/** This function logs data in a `printf`-style manner.
@@ -369,14 +203,8 @@ void logf(int line = __LINE__, string file = __FILE__,
string moduleName = __MODULE__, A...)(const LogLevel ll,
lazy bool condition, lazy string msg, lazy A args)
{
- static if (isLoggingActive)
- {
- if (ll >= moduleLogLevel!moduleName)
- {
- stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName)
- (ll, condition, msg, args);
- }
- }
+ stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName)
+ (ll, condition, msg, args);
}
/** This function logs data in a `printf`-style manner.
@@ -400,14 +228,8 @@ void logf(int line = __LINE__, string file = __FILE__,
string moduleName = __MODULE__, A...)(const LogLevel ll, lazy string msg,
lazy A args)
{
- static if (isLoggingActive)
- {
- if (ll >= moduleLogLevel!moduleName)
- {
- stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName)
- (ll, msg, args);
- }
- }
+ stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName)
+ (ll, msg, args);
}
/** This function logs data in a `printf`-style manner.
@@ -431,11 +253,8 @@ void logf(int line = __LINE__, string file = __FILE__,
string moduleName = __MODULE__, A...)(lazy bool condition,
lazy string msg, lazy A args)
{
- static if (isLoggingActive)
- {
- stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName)
- (stdThreadLocalLog.logLevel, condition, msg, args);
- }
+ stdThreadLocalLog.logf!(line, file, funcName, prettyFuncName, moduleName)
+ (stdThreadLocalLog.logLevel, condition, msg, args);
}
/** This function logs data in a `printf`-style manner.
@@ -457,11 +276,8 @@ void logf(int line = __LINE__, string file = __FILE__,
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
{
- static if (isLoggingActive)
- {
- stdThreadLocalLog.logf!(line, file, funcName,prettyFuncName, moduleName)
- (stdThreadLocalLog.logLevel, msg, args);
- }
+ stdThreadLocalLog.logf!(line, file, funcName,prettyFuncName, moduleName)
+ (stdThreadLocalLog.logLevel, msg, args);
}
/** This template provides the global log functions with the `LogLevel`
@@ -478,11 +294,8 @@ template defaultLogFunction(LogLevel ll)
string moduleName = __MODULE__, A...)(lazy A args)
if ((args.length > 0 && !is(Unqual!(A[0]) : bool)) || args.length == 0)
{
- static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
- {
stdThreadLocalLog.memLogFunctions!(ll).logImpl!(line, file, funcName,
prettyFuncName, moduleName)(args);
- }
}
void defaultLogFunction(int line = __LINE__, string file = __FILE__,
@@ -490,11 +303,8 @@ template defaultLogFunction(LogLevel ll)
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args)
{
- static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
- {
- stdThreadLocalLog.memLogFunctions!(ll).logImpl!(line, file, funcName,
- prettyFuncName, moduleName)(condition, args);
- }
+ stdThreadLocalLog.memLogFunctions!(ll).logImpl!(line, file, funcName,
+ prettyFuncName, moduleName)(condition, args);
}
}
@@ -551,11 +361,8 @@ template defaultLogFunctionf(LogLevel ll)
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
{
- static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
- {
- stdThreadLocalLog.memLogFunctions!(ll).logImplf!(line, file, funcName,
- prettyFuncName, moduleName)(msg, args);
- }
+ stdThreadLocalLog.memLogFunctions!(ll).logImplf!(line, file, funcName,
+ prettyFuncName, moduleName)(msg, args);
}
void defaultLogFunctionf(int line = __LINE__, string file = __FILE__,
@@ -564,11 +371,8 @@ template defaultLogFunctionf(LogLevel ll)
string moduleName = __MODULE__, A...)(lazy bool condition,
lazy string msg, lazy A args)
{
- static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
- {
- stdThreadLocalLog.memLogFunctions!(ll).logImplf!(line, file, funcName,
- prettyFuncName, moduleName)(condition, msg, args);
- }
+ stdThreadLocalLog.memLogFunctions!(ll).logImplf!(line, file, funcName,
+ prettyFuncName, moduleName)(condition, msg, args);
}
}
@@ -816,32 +620,23 @@ abstract class Logger
Tid threadId, SysTime timestamp, Logger logger)
@safe
{
- static if (isLoggingActive)
- {
- msgAppender = appender!string();
- header = LogEntry(file, line, funcName, prettyFuncName,
- moduleName, logLevel, threadId, timestamp, null, logger);
- }
+ msgAppender = appender!string();
+ header = LogEntry(file, line, funcName, prettyFuncName,
+ moduleName, logLevel, threadId, timestamp, null, logger);
}
/** Logs a part of the log message. */
protected void logMsgPart(scope const(char)[] msg) @safe
{
- static if (isLoggingActive)
- {
- msgAppender.put(msg);
- }
+ msgAppender.put(msg);
}
/** Signals that the message has been written and no more calls to
`logMsgPart` follow. */
protected void finishLogMsg() @safe
{
- static if (isLoggingActive)
- {
- header.msg = msgAppender.data;
- this.writeLogMsg(header);
- }
+ header.msg = msgAppender.data;
+ this.writeLogMsg(header);
}
/** The `LogLevel` determines if the log call are processed or dropped
@@ -895,16 +690,13 @@ abstract class Logger
*/
void forwardMsg(ref LogEntry payload) @trusted
{
- static if (isLoggingActive) synchronized (mutex)
+ if (isLoggingEnabled(payload.logLevel, this.logLevel_,
+ globalLogLevel))
{
- if (isLoggingEnabled(payload.logLevel, this.logLevel_,
- globalLogLevel))
- {
- this.writeLogMsg(payload);
+ this.writeLogMsg(payload);
- if (payload.logLevel == LogLevel.fatal)
- this.fatalHandler_();
- }
+ if (payload.logLevel == LogLevel.fatal)
+ this.fatalHandler_();
}
}
@@ -944,8 +736,7 @@ abstract class Logger
string moduleName = __MODULE__, A...)(lazy A args)
if (args.length == 0 || (args.length > 0 && !is(A[0] : bool)))
{
- static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
- synchronized (mutex)
+ synchronized (mutex)
{
if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel))
{
@@ -991,8 +782,7 @@ abstract class Logger
string moduleName = __MODULE__, A...)(lazy bool condition,
lazy A args)
{
- static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
- synchronized (mutex)
+ synchronized (mutex)
{
if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel,
condition))
@@ -1040,8 +830,7 @@ abstract class Logger
string moduleName = __MODULE__, A...)(lazy bool condition,
lazy string msg, lazy A args)
{
- static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
- synchronized (mutex)
+ synchronized (mutex)
{
import std.format.write : formattedWrite;
@@ -1088,8 +877,7 @@ abstract class Logger
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
{
- static if (isLoggingActiveAt!ll && ll >= moduleLogLevel!moduleName)
- synchronized (mutex)
+ synchronized (mutex)
{
import std.format.write : formattedWrite;
@@ -1161,7 +949,7 @@ abstract class Logger
lazy bool condition, lazy A args)
if (args.length != 1)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel, condition))
{
@@ -1185,10 +973,9 @@ abstract class Logger
string file = __FILE__, string funcName = __FUNCTION__,
string prettyFuncName = __PRETTY_FUNCTION__)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
- if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel,
- condition) && ll >= moduleLogLevel!moduleName)
+ if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel, condition))
{
this.beginLogMsg(file, line, funcName, prettyFuncName,
moduleName, ll, thisTid, Clock.currTime, this);
@@ -1230,7 +1017,7 @@ abstract class Logger
string moduleName = __MODULE__, A...)(const LogLevel ll, lazy A args)
if ((args.length > 1 && !is(Unqual!(A[0]) : bool)) || args.length == 0)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel))
{
@@ -1254,7 +1041,7 @@ abstract class Logger
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
if (isLoggingEnabled(ll, this.logLevel_, globalLogLevel))
{
@@ -1299,7 +1086,7 @@ abstract class Logger
string moduleName = __MODULE__, A...)(lazy bool condition, lazy A args)
if (args.length != 1)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
if (isLoggingEnabled(this.logLevel_, this.logLevel_,
globalLogLevel, condition))
@@ -1324,7 +1111,7 @@ abstract class Logger
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
if (isLoggingEnabled(this.logLevel_, this.logLevel_, globalLogLevel,
condition))
@@ -1371,7 +1158,7 @@ abstract class Logger
&& !is(immutable A[0] == immutable LogLevel))
|| args.length == 0)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
if (isLoggingEnabled(this.logLevel_, this.logLevel_,
globalLogLevel))
@@ -1395,7 +1182,7 @@ abstract class Logger
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
if (isLoggingEnabled(this.logLevel_, this.logLevel_, globalLogLevel))
{
@@ -1442,7 +1229,7 @@ abstract class Logger
string moduleName = __MODULE__, A...)(const LogLevel ll,
lazy bool condition, lazy string msg, lazy A args)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
import std.format.write : formattedWrite;
@@ -1490,7 +1277,7 @@ abstract class Logger
string moduleName = __MODULE__, A...)(const LogLevel ll,
lazy string msg, lazy A args)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
import std.format.write : formattedWrite;
@@ -1539,7 +1326,7 @@ abstract class Logger
string moduleName = __MODULE__, A...)(lazy bool condition,
lazy string msg, lazy A args)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
import std.format.write : formattedWrite;
@@ -1585,7 +1372,7 @@ abstract class Logger
string prettyFuncName = __PRETTY_FUNCTION__,
string moduleName = __MODULE__, A...)(lazy string msg, lazy A args)
{
- static if (isLoggingActive) synchronized (mutex)
+ synchronized (mutex)
{
import std.format.write : formattedWrite;
diff --git a/libphobos/src/std/experimental/logger/package.d b/libphobos/src/std/experimental/logger/package.d
index 79245ec..89dc713 100644
--- a/libphobos/src/std/experimental/logger/package.d
+++ b/libphobos/src/std/experimental/logger/package.d
@@ -146,26 +146,6 @@ To gain more precise control over the logging process, additionally to
overriding the `writeLogMsg` method the methods `beginLogMsg`,
`logMsgPart` and `finishLogMsg` can be overridden.
-$(H3 Compile Time Disabling of `Logger`)
-In order to disable logging at compile time, pass `StdLoggerDisableLogging` as a
-version argument to the `D` compiler when compiling your program code.
-This will disable all logging functionality.
-Specific `LogLevel` can be disabled at compile time as well.
-In order to disable logging with the `trace` `LogLevel` pass
-`StdLoggerDisableTrace` as a version.
-The following table shows which version statement disables which
-`LogLevel`.
-$(TABLE
- $(TR $(TD `LogLevel.trace` ) $(TD StdLoggerDisableTrace))
- $(TR $(TD `LogLevel.info` ) $(TD StdLoggerDisableInfo))
- $(TR $(TD `LogLevel.warning` ) $(TD StdLoggerDisableWarning))
- $(TR $(TD `LogLevel.error` ) $(TD StdLoggerDisableError))
- $(TR $(TD `LogLevel.critical` ) $(TD StdLoggerDisableCritical))
- $(TR $(TD `LogLevel.fatal` ) $(TD StdLoggerDisableFatal))
-)
-Such a version statement will only disable logging in the associated compile
-unit.
-
$(H3 Provided Logger)
By default four `Logger` implementations are given. The `FileLogger`
logs data to files. It can also be used to log to `stdout` and `stderr`
diff --git a/libphobos/src/std/file.d b/libphobos/src/std/file.d
index 6bc7d4d..05fad67 100644
--- a/libphobos/src/std/file.d
+++ b/libphobos/src/std/file.d
@@ -3610,7 +3610,7 @@ version (StdDdoc)
Throws:
$(LREF FileException) if the file does not exist.
+/
- this(string path);
+ this(return scope string path);
version (Windows)
{
@@ -3772,7 +3772,7 @@ else version (Windows)
public:
alias name this;
- this(string path)
+ this(return scope string path)
{
import std.datetime.systime : FILETIMEToSysTime;
@@ -3881,7 +3881,7 @@ else version (Posix)
public:
alias name this;
- this(string path)
+ this(return scope string path)
{
if (!path.exists)
throw new FileException(path, "File does not exist");
@@ -4424,7 +4424,7 @@ void rmdirRecurse(scope const(char)[] pathname) @safe
}
/// ditto
-void rmdirRecurse(ref DirEntry de) @safe
+void rmdirRecurse(ref scope DirEntry de) @safe
{
if (!de.isDir)
throw new FileException(de.name, "Not a directory");
@@ -4459,7 +4459,7 @@ void rmdirRecurse(ref DirEntry de) @safe
//"rmdirRecurse(in char[] pathname)" implementation. That is needlessly
//expensive.
//A DirEntry is a bit big (72B), so keeping the "by ref" signature is desirable.
-void rmdirRecurse(DirEntry de) @safe
+void rmdirRecurse(scope DirEntry de) @safe
{
rmdirRecurse(de);
}
@@ -4511,22 +4511,20 @@ version (Posix) @system unittest
enforce(!exists(deleteme));
}
-@system unittest
+@safe unittest
{
- void[] buf;
-
- buf = new void[10];
- (cast(byte[]) buf)[] = 3;
+ ubyte[] buf = new ubyte[10];
+ buf[] = 3;
string unit_file = deleteme ~ "-unittest_write.tmp";
if (exists(unit_file)) remove(unit_file);
- write(unit_file, buf);
+ write(unit_file, cast(void[]) buf);
void[] buf2 = read(unit_file);
- assert(buf == buf2);
+ assert(cast(void[]) buf == buf2);
string unit2_file = deleteme ~ "-unittest_write2.tmp";
copy(unit_file, unit2_file);
buf2 = read(unit2_file);
- assert(buf == buf2);
+ assert(cast(void[]) buf == buf2);
remove(unit_file);
assert(!exists(unit_file));
@@ -5042,7 +5040,7 @@ auto dirEntries(string path, string pattern, SpanMode mode,
return filter!f(DirIterator(path, mode, followSymlink));
}
-@system unittest
+@safe unittest
{
import std.stdio : writefln;
immutable dpath = deleteme ~ "_dir";
@@ -5059,11 +5057,11 @@ auto dirEntries(string path, string pattern, SpanMode mode,
mkdir(dpath);
write(fpath, "hello world");
- version (Posix)
+ version (Posix) () @trusted
{
core.sys.posix.unistd.symlink((dpath ~ '\0').ptr, (sdpath ~ '\0').ptr);
core.sys.posix.unistd.symlink((fpath ~ '\0').ptr, (sfpath ~ '\0').ptr);
- }
+ } ();
static struct Flags { bool dir, file, link; }
auto tests = [dpath : Flags(true), fpath : Flags(false, true)];
diff --git a/libphobos/src/std/math/algebraic.d b/libphobos/src/std/math/algebraic.d
index db70b7a..4791766 100644
--- a/libphobos/src/std/math/algebraic.d
+++ b/libphobos/src/std/math/algebraic.d
@@ -496,9 +496,9 @@ if (isFloatingPoint!T)
[ 1.0L, 4.0L, 8.0L, 9.0L ],
[ 4.0L, 4.0L, 7.0L, 9.0L ],
[ 12.0L, 16.0L, 21.0L, 29.0L ],
- [ 1e+8L, 1.0L, 1e-8L, 1e+8L ],
- [ 1.0L, 1e+8L, 1e-8L, 1e+8L ],
- [ 1e-8L, 1.0L, 1e+8L, 1e+8L ],
+ [ 1e+8L, 1.0L, 1e-8L, 1e+8L+5e-9L ],
+ [ 1.0L, 1e+8L, 1e-8L, 1e+8L+5e-9L ],
+ [ 1e-8L, 1.0L, 1e+8L, 1e+8L+5e-9L ],
[ 1e-2L, 1e-4L, 1e-4L, 0.010000999950004999375L ],
[ 2147483647.0L, 2147483647.0L, 2147483647.0L, 3719550785.027307813987L ]
];
diff --git a/libphobos/src/std/math/hardware.d b/libphobos/src/std/math/hardware.d
index 7bff07e..40e42da 100644
--- a/libphobos/src/std/math/hardware.d
+++ b/libphobos/src/std/math/hardware.d
@@ -674,9 +674,9 @@ nothrow @nogc:
enum : ExceptionMask
{
inexactException = 0x01,
- divByZeroException = 0x02,
- underflowException = 0x04,
- overflowException = 0x08,
+ divByZeroException = 0x08,
+ underflowException = 0x02,
+ overflowException = 0x04,
invalidException = 0x10,
severeExceptions = overflowException | divByZeroException
| invalidException,
diff --git a/libphobos/src/std/math/trigonometry.d b/libphobos/src/std/math/trigonometry.d
index 06a7cb1..a3d04c6 100644
--- a/libphobos/src/std/math/trigonometry.d
+++ b/libphobos/src/std/math/trigonometry.d
@@ -467,20 +467,20 @@ private T tanImpl(T)(T x) @safe pure nothrow @nogc
static immutable T[2][] vals =
[
// angle, tan
- [ .5, .54630248984],
- [ 1, 1.5574077247],
- [ 1.5, 14.101419947],
- [ 2, -2.1850398633],
- [ 2.5,-.74702229724],
- [ 3, -.14254654307],
- [ 3.5, .37458564016],
- [ 4, 1.1578212823],
- [ 4.5, 4.6373320546],
- [ 5, -3.3805150062],
- [ 5.5,-.99558405221],
- [ 6, -.29100619138],
- [ 6.5, .22027720035],
- [ 10, .64836082746],
+ [ .5, .546302489843790513255L],
+ [ 1, 1.55740772465490223050L],
+ [ 1.5, 14.1014199471717193876L],
+ [ 2, -2.18503986326151899164L],
+ [ 2.5,-.747022297238660279355L],
+ [ 3, -.142546543074277805295L],
+ [ 3.5, .374585640158594666330L],
+ [ 4, 1.15782128234957758313L],
+ [ 4.5, 4.63733205455118446831L],
+ [ 5, -3.38051500624658563698L],
+ [ 5.5,-.995584052213885017701L],
+ [ 6, -.291006191384749157053L],
+ [ 6.5, .220277200345896811825L],
+ [ 10, .648360827459086671259L],
// special angles
[ PI_4, 1],
@@ -857,11 +857,11 @@ private T atanImpl(T)(T x) @safe pure nothrow @nogc
static immutable T[2][] vals =
[
// x, atan(x)
- [ 0.25, 0.24497866313 ],
- [ 0.5, 0.46364760900 ],
- [ 1, PI_4 ],
- [ 1.5, 0.98279372325 ],
- [ 10, 1.47112767430 ],
+ [ 0.25, 0.244978663126864154172L ],
+ [ 0.5, 0.463647609000806116214L ],
+ [ 1, PI_4 ],
+ [ 1.5, 0.982793723247329067985L ],
+ [ 10, 1.471127674303734591852L ],
];
foreach (ref val; vals)
@@ -1075,10 +1075,10 @@ private T atan2Impl(T)(T y, T x) @safe pure nothrow @nogc
[ 3.0, -3.0, 3 * PI_4 ],
[ -4.0, -4.0, -3 * PI_4 ],
- [ 0.75, 0.25, 1.249045772398 ],
- [ -0.5, 0.375, -0.927295218002 ],
- [ 0.5, -0.125, 1.815774989922 ],
- [ -0.75, -0.5, -2.158798930342 ],
+ [ 0.75, 0.25, 1.2490457723982544258299L ],
+ [ -0.5, 0.375, -0.9272952180016122324285L ],
+ [ 0.5, -0.125, 1.8157749899217607734034L ],
+ [ -0.75, -0.5, -2.1587989303424641704769L ],
];
foreach (ref val; vals)
diff --git a/libphobos/src/std/numeric.d b/libphobos/src/std/numeric.d
index fd532b2..96d20c2 100644
--- a/libphobos/src/std/numeric.d
+++ b/libphobos/src/std/numeric.d
@@ -79,10 +79,12 @@ public enum CustomFloatFlags
none = 0
}
+private enum isIEEEQuadruple = floatTraits!real.realFormat == RealFormat.ieeeQuadruple;
+
private template CustomFloatParams(uint bits)
{
enum CustomFloatFlags flags = CustomFloatFlags.ieee
- ^ ((bits == 80) ? CustomFloatFlags.storeNormalized : CustomFloatFlags.none);
+ ^ ((bits == 80 && !isIEEEQuadruple) ? CustomFloatFlags.storeNormalized : CustomFloatFlags.none);
static if (bits == 8) alias CustomFloatParams = CustomFloatParams!( 4, 3, flags);
static if (bits == 16) alias CustomFloatParams = CustomFloatParams!(10, 5, flags);
static if (bits == 32) alias CustomFloatParams = CustomFloatParams!(23, 8, flags);
@@ -367,11 +369,36 @@ private:
public:
static if (precision == 64) // CustomFloat!80 support hack
{
- ulong significand;
- enum ulong significand_max = ulong.max;
- mixin(bitfields!(
- T_exp , "exponent", exponentWidth,
- bool , "sign" , flags & flags.signed ));
+ static if (isIEEEQuadruple)
+ {
+ // Only use highest 64 significand bits from 112 explicitly stored
+ align (1):
+ enum ulong significand_max = ulong.max;
+ version (LittleEndian)
+ {
+ private ubyte[6] _padding; // 48-bit of padding
+ ulong significand;
+ mixin(bitfields!(
+ T_exp , "exponent", exponentWidth,
+ bool , "sign" , flags & flags.signed ));
+ }
+ else
+ {
+ mixin(bitfields!(
+ T_exp , "exponent", exponentWidth,
+ bool , "sign" , flags & flags.signed ));
+ ulong significand;
+ private ubyte[6] _padding; // 48-bit of padding
+ }
+ }
+ else
+ {
+ ulong significand;
+ enum ulong significand_max = ulong.max;
+ mixin(bitfields!(
+ T_exp , "exponent", exponentWidth,
+ bool , "sign" , flags & flags.signed ));
+ }
}
else
{
@@ -631,23 +658,28 @@ public:
auto x = F(0.125);
assert(x.get!float == 0.125F);
assert(x.get!double == 0.125);
+ assert(x.get!real == 0.125L);
x -= 0.0625;
assert(x.get!float == 0.0625F);
assert(x.get!double == 0.0625);
+ assert(x.get!real == 0.0625L);
x *= 2;
assert(x.get!float == 0.125F);
assert(x.get!double == 0.125);
+ assert(x.get!real == 0.125L);
x /= 4;
assert(x.get!float == 0.03125);
assert(x.get!double == 0.03125);
+ assert(x.get!real == 0.03125L);
x = 0.5;
x ^^= 4;
assert(x.get!float == 1 / 16.0F);
assert(x.get!double == 1 / 16.0);
+ assert(x.get!real == 1 / 16.0L);
}
}
diff --git a/libphobos/src/std/stdio.d b/libphobos/src/std/stdio.d
index 1bde73d..8614dc9 100644
--- a/libphobos/src/std/stdio.d
+++ b/libphobos/src/std/stdio.d
@@ -498,17 +498,21 @@ struct File
private Impl* _p;
private string _name;
- package this(FILE* handle, string name, uint refs = 1, bool isPopened = false) @trusted
+ package this(FILE* handle, string name, uint refs = 1, bool isPopened = false) @trusted @nogc nothrow
{
import core.stdc.stdlib : malloc;
- import std.exception : enforce;
assert(!_p);
- _p = cast(Impl*) enforce(malloc(Impl.sizeof), "Out of memory");
+ _p = cast(Impl*) malloc(Impl.sizeof);
+ if (!_p)
+ {
+ import core.exception : onOutOfMemoryError;
+ onOutOfMemoryError();
+ }
initImpl(handle, name, refs, isPopened);
}
- private void initImpl(FILE* handle, string name, uint refs = 1, bool isPopened = false)
+ private void initImpl(FILE* handle, string name, uint refs = 1, bool isPopened = false) @nogc nothrow pure @safe
{
assert(_p);
_p.handle = handle;
diff --git a/libphobos/src/std/sumtype.d b/libphobos/src/std/sumtype.d
index f3d3152..1d375ef 100644
--- a/libphobos/src/std/sumtype.d
+++ b/libphobos/src/std/sumtype.d
@@ -635,9 +635,19 @@ public:
this.match!destroyIfOwner;
- mixin("Storage newStorage = { ",
- Storage.memberName!T, ": forward!rhs",
- " };");
+ static if (isCopyable!T)
+ {
+ // Workaround for https://issues.dlang.org/show_bug.cgi?id=21542
+ mixin("Storage newStorage = { ",
+ Storage.memberName!T, ": __ctfe ? rhs : forward!rhs",
+ " };");
+ }
+ else
+ {
+ mixin("Storage newStorage = { ",
+ Storage.memberName!T, ": forward!rhs",
+ " };");
+ }
storage = newStorage;
tag = tid;
@@ -678,7 +688,17 @@ public:
{
import core.lifetime : move;
- rhs.match!((ref value) { this = move(value); });
+ rhs.match!((ref value) {
+ static if (isCopyable!(typeof(value)))
+ {
+ // Workaround for https://issues.dlang.org/show_bug.cgi?id=21542
+ this = __ctfe ? value : move(value);
+ }
+ else
+ {
+ this = move(value);
+ }
+ });
return this;
}
}
@@ -1569,6 +1589,28 @@ version (D_BetterC) {} else
}
}
+// Assignment of struct with overloaded opAssign in CTFE
+// https://issues.dlang.org/show_bug.cgi?id=23182
+@safe unittest
+{
+ static struct HasOpAssign
+ {
+ void opAssign(HasOpAssign rhs) {}
+ }
+
+ static SumType!HasOpAssign test()
+ {
+ SumType!HasOpAssign s;
+ // Test both overloads
+ s = HasOpAssign();
+ s = SumType!HasOpAssign();
+ return s;
+ }
+
+ // Force CTFE
+ enum result = test();
+}
+
/// True if `T` is an instance of the `SumType` template, otherwise false.
private enum bool isSumTypeInstance(T) = is(T == SumType!Args, Args...);