Skip to content
Draft
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
327e916
core.system.Mem.reallocate alias added and used in registerGCFactory()
denizzzka Jul 31, 2026
2cb303c
core.system.Mem: allocate and free aliases added and used in Runtime.…
denizzzka Jul 31, 2026
90237dc
Mem.allocateBlank() added
denizzzka Jul 31, 2026
c8e5b4e
calloc() and free() replaced by Mem in core.internal.gc.os module
denizzzka Jul 31, 2026
f17cea9
Mem.allocateBlank() on Posix uses calloc()
denizzzka Jul 31, 2026
6c69083
module rt.minfo now uses core.system.Mem
denizzzka Jul 31, 2026
afb47cc
core.internal.gc.impl.manual.gc uses core.system.Mem
denizzzka Jul 31, 2026
80eff15
module core.runtime uses core.system.Mem
denizzzka Jul 31, 2026
95a13a7
core.gc.registry uses core.system.Mem
denizzzka Jul 31, 2026
f121ab9
rt.dmain2: core.stdc.stdlib.alloca() replaced by Mem.allocateOnStack
denizzzka Jul 31, 2026
6f8d22b
rt.dmain2: free, malloc, realloc replaced by Mem.* calls
denizzzka Jul 31, 2026
c2658a3
Merge branch 'master' into libc_gone
denizzzka Aug 1, 2026
8ae2a8f
allocateBlank() commented-out code removed
denizzzka Aug 1, 2026
01dc104
Mem.allocate -> Mem.allocateOne
denizzzka Aug 1, 2026
417361a
allocateBlank() -> allocateOneBlank()
denizzzka Aug 1, 2026
85de307
allocateFew() and allocateFewBlank() added
denizzzka Aug 1, 2026
76191c4
GC Config: initialization method does not need access to the outer scope
denizzzka Aug 1, 2026
a34c6de
Merge branch 'gc_cfg_init_changed' into libc_gone
denizzzka Aug 1, 2026
f20ede3
GC Config defined in core.system.Opt
denizzzka Aug 1, 2026
7075d9f
Opt.Config -> Opt.GcConfig
denizzzka Aug 1, 2026
21fb5a1
Attempt to fix build fo Windows by adding module core.system.opt
denizzzka Aug 1, 2026
4b9b386
druntime: -debug=PRINTF compilation fix
denizzzka Aug 2, 2026
b426feb
core.system: Sys.abort() and printf() added
denizzzka Aug 2, 2026
43eb8f8
core.system comment about debugging added, aliases added
denizzzka Aug 2, 2026
ec6e2ec
more correct printf result value check
denizzzka Aug 2, 2026
e79d4d2
Sys.print() added
denizzzka Aug 2, 2026
f82da6f
core.system.Sys.printf() implemented (depends on libc version) and used
denizzzka Aug 2, 2026
b8d39b9
Sys.print() can print non-null-terminated strings
denizzzka Aug 2, 2026
c188f6c
free() -> freeMem()
denizzzka Aug 3, 2026
3755f54
core.system.Mem code moved to new core.system.memory module
denizzzka Aug 3, 2026
8298709
Merge branch 'master' into libc_gone
denizzzka Aug 3, 2026
5de3953
modules renamed: core.system.* -> core.internal.config.*
denizzzka Aug 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions druntime/mak/COPY
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ COPY=\
$(IMPDIR)\core\memory.d \
$(IMPDIR)\core\runtime.d \
$(IMPDIR)\core\simd.d \
$(IMPDIR)\core\system.d \
$(IMPDIR)\core\time.d \
$(IMPDIR)\core\vararg.d \
$(IMPDIR)\core\volatile.d \
Expand Down
1 change: 1 addition & 0 deletions druntime/mak/SRCS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ SRCS=\
src\core\memory.d \
src\core\runtime.d \
src\core\simd.d \
src\core\system.d \
src\core\time.d \
src\core\vararg.d \
src\core\volatile.d \
Expand Down
4 changes: 2 additions & 2 deletions druntime/src/core/gc/registry.d
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ alias GCThreadInitFunction = void function(ThreadBase base) nothrow @nogc;
void registerGCFactory(string name, GCFactory factory,
GCThreadInitFunction threadInit = null) nothrow @nogc
{
import core.stdc.stdlib : realloc;
import core.system : Mem;

auto ptr = cast(Entry*)realloc(entries.ptr, (entries.length + 1) * Entry.sizeof);
auto ptr = cast(Entry*) Mem.reallocate(entries.ptr, (entries.length + 1) * Entry.sizeof);
entries = ptr[0 .. entries.length + 1];
entries[$ - 1] = Entry(name, factory, threadInit);
}
Expand Down
6 changes: 3 additions & 3 deletions druntime/src/core/internal/gc/bits.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import core.internal.gc.os;

import core.bitop;
import core.exception : onOutOfMemoryError;
import core.stdc.stdlib : calloc, free;
import core.system : Mem;
import core.stdc.string : memcpy, memset;

// use version gcbitsSingleBitOperation to disable optimizations that use
Expand All @@ -38,7 +38,7 @@ struct GCBits
if (data)
{
if (!AllocSupportsShared || !share)
free(data);
Mem.free(data);
else static if (AllocSupportsShared)
os_mem_unmap_shared(data, nwords * data[0].sizeof);
else
Expand All @@ -51,7 +51,7 @@ struct GCBits
{
this.nbits = nbits;
if (!AllocSupportsShared || !share)
data = cast(typeof(data[0])*)calloc(nwords, data[0].sizeof);
Comment thread
denizzzka marked this conversation as resolved.
data = cast(typeof(data[0])*) Mem.allocateBlank(nwords * data[0].sizeof);
else static if (AllocSupportsShared)
data = cast(typeof(data[0])*)os_mem_map_shared(nwords * data[0].sizeof); // Allocate as MAP_SHARED
else
Expand Down
10 changes: 5 additions & 5 deletions druntime/src/core/runtime.d
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ struct Runtime
*/
static void* loadLibrary()(const scope char[] name)
{
import core.stdc.stdlib : free, malloc;
import core.system : Mem;
version (Windows)
{
import core.sys.windows.winnls : CP_UTF8, MultiByteToWideChar;
Expand All @@ -222,9 +222,9 @@ struct Runtime
if (len == 0)
return null;

auto buf = cast(WCHAR*)malloc((len+1) * WCHAR.sizeof);
auto buf = cast(WCHAR*) Mem.allocate((len+1) * WCHAR.sizeof);
if (buf is null) return null;
scope (exit) free(buf);
scope (exit) Mem.free(buf);

len = MultiByteToWideChar(
CP_UTF8, 0, name.ptr, cast(int)name.length, buf, len);
Expand All @@ -240,9 +240,9 @@ struct Runtime
/* Need a 0-terminated C string for the dll name
*/
immutable len = name.length;
auto buf = cast(char*)malloc(len + 1);
auto buf = cast(char*) Mem.allocate(len + 1);
if (!buf) return null;
scope (exit) free(buf);
scope (exit) Mem.free(buf);

buf[0 .. len] = name[];
buf[len] = 0;
Expand Down
20 changes: 20 additions & 0 deletions druntime/src/core/system.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
///
module core.system;

package:

struct Mem
{
import core.stdc.stdlib;

alias allocate = malloc;
alias reallocate = realloc;
alias free = core.stdc.stdlib.free;

static void* allocateBlank(size_t size) nothrow @nogc
{
ubyte* p = cast(ubyte*) allocate(size);
p[0 .. size] = 0;
return cast(void*) p;
}
}
Loading