-
-
Notifications
You must be signed in to change notification settings - Fork 711
Concept: druntime getting rid of libc dependency #23498
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
327e916
2cb303c
90237dc
c8e5b4e
f17cea9
6c69083
afb47cc
80eff15
95a13a7
f121ab9
6f8d22b
c2658a3
8ae2a8f
01dc104
417361a
85de307
76191c4
a34c6de
f20ede3
7075d9f
21fb5a1
4b9b386
b426feb
43eb8f8
ec6e2ec
e79d4d2
f82da6f
b8d39b9
c188f6c
3755f54
8298709
5de3953
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /// | ||
| module core.internal.config.memory; | ||
|
|
||
| // libc version | ||
| version (all) | ||
| { | ||
| import core.stdc.stdlib; | ||
|
|
||
| alias allocateOne = malloc; | ||
| alias allocateFew = (size_t num, size_t size) nothrow @nogc => allocateOne(num * size); | ||
| void* allocateOneBlank(size_t size) nothrow @nogc => allocateFewBlank(1, size); | ||
| alias allocateFewBlank = calloc; | ||
| alias reallocate = realloc; | ||
| alias freeMem = core.stdc.stdlib.free; | ||
|
|
||
| alias allocateOnStack = alloca; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| /// | ||
| module core.internal.config.opt; | ||
|
|
||
| struct Opt | ||
| { | ||
| import core.gc.config: ConfigT; | ||
|
|
||
| alias GcConfig = ConfigT!(); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /// | ||
| module core.internal.config; | ||
|
|
||
| struct Sys | ||
| { | ||
| static import core.stdc.stdlib; | ||
| import core.stdc.stdio; | ||
|
|
||
| alias abort = core.stdc.stdlib.abort; | ||
|
|
||
| static void print(scope const char[] str) nothrow @nogc | ||
| { | ||
| // This is a silly approach, but it's a simple way to print non-null-terminated strings | ||
| // TODO: implement using write() or so | ||
| foreach(c; str) | ||
| { | ||
| auto r = fputc(c, stdout); | ||
| if(r == EOF) | ||
| Sys.abort(); | ||
| } | ||
| } | ||
|
|
||
| /// C-formatted print | ||
| static void printf(T...)(scope const char[] fmt, T vals) nothrow @nogc | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this being kept long term (i.e. will freestanding platforms have to write their own
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. I plan to add it to debug builds so that when testing I can make sure it responds similarly as current libc versions |
||
| { | ||
| static assert(T.length > 0); | ||
|
|
||
| int r = core.stdc.stdio.printf(fmt.ptr, vals); | ||
| if(r < fmt.length) | ||
| Sys.abort(); | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.