Copy from druntime available module buth with modifications allowing it's usage in @nogc.
Undocumented in source.