core.runtime

The runtime module exposes information specific to the D runtime code.

Module Initializers 1

shared static this()

Types 8

This type is returned by the module unit test handler to indicate testing results.

Fields
size_t executedNumber of modules which were tested
size_t passedNumber of modules passed the unittests
bool runMainShould the main function be run or not? This is ignored if any tests failed.
bool summarizeShould we print a summary of the results?
UnitTestResult passSimple return code that says unit tests pass, and main should be run
UnitTestResult failSimple return code that says unit tests failed.
Methods
bool opCast(T : bool)() constSimple check for whether execution should continue after unit tests have been run. Works with legacy code that expected a bool return.
aliasModuleUnitTester = bool function()

Legacy module unit test handler

Module unit test handler

aliasCollectHandler = bool function(Object)
aliasTraceHandler = Throwable.TraceInfo function(void * ptr)
aliasExceptionHandler = void delegate(Throwable)
structCArgs

Stores the unprocessed arguments supplied when the process was started.

Fields
int argc
char * * argv
structRuntime

This struct encapsulates all functionality related to the underlying runtime module for the calling context.

Fields
ExtendedModuleUnitTester sm_extModuleUnitTester
ModuleUnitTester sm_moduleUnitTester
Methods
bool initialize()Initializes the runtime. This call is to be used in instances where the standard program initialization process is not executed. This is most often in shared libraries or in libraries linked to a...
bool terminate()Terminates the runtime. This call is to be used in instances where the standard program termination process will not be not executed. This is most often in shared libraries or in libraries linked...
string[] args() @propertyReturns the arguments supplied when the process was started.
CArgs cArgs() @property @nogcReturns the unprocessed C arguments supplied when the process was started. Use this when you need to supply argc and argv to C libraries.
void * loadLibrary()(const scope char[] name)Locates a dynamic library with the supplied library name and dynamically loads it into the caller's address space. If the library contains a D runtime it will be integrated with the current runtime.
bool unloadLibrary()(void * p)Unloads the dynamic library referenced by p. If this library contains a D runtime then any necessary finalization or cleanup of that runtime will be performed.
void traceHandler(TraceHandler h, Throwable.TraceDeallocator d = null) @propertyOverrides the default trace mechanism with a user-supplied version. A trace represents the context from which an exception was thrown, and the trace handler will be called when this occurs. The p...
TraceHandler traceHandler() @propertyGets the current trace handler.
Throwable.TraceDeallocator traceDeallocator() @propertyGets the current trace deallocator.
void collectHandler( CollectHandler h ) @propertyOverrides the default collect hander with a user-supplied version. This routine will be called for each resource object that is finalized in a non-deterministic manner--typically during a garbage ...
CollectHandler collectHandler() @propertyGets the current collect handler.
void extendedModuleUnitTester( ExtendedModuleUnitTester h ) @propertyOverrides the default module unit tester with a user-supplied version. This routine will be called once on program initialization. The return value of this routine indicates to the runtime whether...
void moduleUnitTester( ModuleUnitTester h ) @propertyDitto
ModuleUnitTester moduleUnitTester() @propertyGets the current legacy module unit tester.
ExtendedModuleUnitTester extendedModuleUnitTester() @propertyGets the current module unit tester.

Functions 15

fnvoid * rt_loadLibrary(const char * name)C interface for Runtime.loadLibrary
fnint rt_unloadLibrary(void * ptr)C interface for Runtime.unloadLibrary, returns 1/0 instead of bool
fnint rt_init()C interface for Runtime.initialize, returns 1/0 instead of bool
fnint rt_term()C interface for Runtime.terminate, returns 1/0 instead of bool
fnvoid _d_print_throwable(Throwable t)
fnvoid * thread_stackBottom() nothrow @nogc
fnvoid dmd_coverSourcePath(string path)Set source file path for coverage reports.
fnvoid dmd_coverDestPath(string path)Set output path for coverage reports.
fnvoid dmd_coverSetMerge(bool flag)Enable merging of coverage reports with existing data.
fnvoid trace_setlogfilename(string name)Set the output file name for profile reports (-profile switch). An empty name will set the output to stdout.
fnvoid trace_setdeffilename(string name)Set the output file name for the optimized profile linker DEF file (-profile switch). An empty name will set the output to stdout.
fnvoid profilegc_setlogfilename(string name)Set the output file name for memory profile reports (-profile=gc switch). An empty name will set the output to stdout.
fnUnitTestResult runModuleUnitTests() This routine is called by the runtime to run module unit tests on startup. The user-supplied unit tester will be called if one has been set, otherwise all unit tests will be run in sequence. I...
fnThrowable.TraceInfo defaultTraceHandler( void * ptr = null )Get the default `Throwable.TraceInfo` implementation for the platform
fnvoid defaultTraceDeallocator(Throwable.TraceInfo info) nothrowDeallocate a traceinfo generated by deaultTraceHander.