-
-
Notifications
You must be signed in to change notification settings - Fork 423
Conversation
Thanks for your pull request and interest in making D better, @denizzzka! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + druntime#3241" |
{ | ||
free( m_pmem ); | ||
} | ||
} | ||
else | ||
static assert(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static assert(false); | |
static assert(false, "`Fiber` support is not available on this platform, please raise an issue"); |
Or something similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed for now - there are no easy ways to get to the versions other than windows or posix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not rare to have people stepping in and trying to port D to an architecture / OS we currently do not support.
Also, some people do funky stuff with druntime, building their own.
Those errors message ensure that they get some kind of clue of what is failing at a minimum cost to us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If everything was as you say, then malloc already would work. :-)
Proposed text is a comment, and I consider what obvious comments like this are bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the contrary, the next poor schmuck that tries to build for a micro controller, e.g. this guy https://forum.dlang.org/thread/erwfgtigvcciohllvaos@forum.dlang.org , is going to hit that error and get
src/core/thread/fiber.d(1018): Error: static assert: *false* is false.
Rather than
src/core/thread/fiber.d(1018): Error: static assert: "*Fiber* support is not available on this platform, please raise an issue"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
She uses Posix, as I understand. Both cases will force to look into code.
I think the main focus should be on the fundamental removal of such branching code, and not commenting on it with pretty messages.
be5f636
to
aef8851
Compare
Good! If not removing valloc perhaps also import core.sys.posix.stdlib.
Why? In |
It is already imported above. I added redundand to clear things.
My target (outside of ~master druntime) is to adding support for any platforms, including which not providing C API.
Here is many similar places where similar assertion will be triggered (or also must be added):
|
ac2ba2e
to
3bd6e15
Compare
{ | ||
version (Posix) import core.sys.posix.sys.mman; // mmap, MAP_ANON | ||
import core.sys.posix.sys.mman; // mmap, MAP_ANON |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This imported module will always define mmap
or else compilation will fail with static assert(false, "Unsupported platform")
. So there seems to be no way the malloc
branch can ever be reached.
druntime/src/core/sys/posix/sys/mman.d
Lines 261 to 326 in 31c9e38
version (CRuntime_Glibc) | |
{ | |
static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off_t); | |
static if (__USE_FILE_OFFSET64) | |
alias mmap = mmap64; | |
else | |
void* mmap(void*, size_t, int, int, int, off_t); | |
int munmap(void*, size_t); | |
} | |
else version (Darwin) | |
{ | |
void* mmap(void*, size_t, int, int, int, off_t); | |
int munmap(void*, size_t); | |
} | |
else version (FreeBSD) | |
{ | |
void* mmap(void*, size_t, int, int, int, off_t); | |
int munmap(void*, size_t); | |
} | |
else version (NetBSD) | |
{ | |
void* mmap(void*, size_t, int, int, int, off_t); | |
int munmap(void*, size_t); | |
} | |
else version (OpenBSD) | |
{ | |
void* mmap(void*, size_t, int, int, int, off_t); | |
int munmap(void*, size_t); | |
} | |
else version (DragonFlyBSD) | |
{ | |
void* mmap(void*, size_t, int, int, int, off_t); | |
int munmap(void*, size_t); | |
} | |
else version (Solaris) | |
{ | |
void* mmap(void*, size_t, int, int, int, off_t); | |
int munmap(void*, size_t); | |
} | |
else version (CRuntime_Bionic) | |
{ | |
void* mmap(void*, size_t, int, int, int, off_t); | |
int munmap(void*, size_t); | |
} | |
else version (CRuntime_Musl) | |
{ | |
static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off_t); | |
static if (__USE_FILE_OFFSET64) | |
alias mmap = mmap64; | |
else | |
void* mmap(void*, size_t, int, int, int, off_t); | |
int munmap(void*, size_t); | |
} | |
else version (CRuntime_UClibc) | |
{ | |
static if (__USE_LARGEFILE64) void* mmap64(void*, size_t, int, int, int, off64_t); | |
static if (__USE_FILE_OFFSET64) | |
alias mmap = mmap64; | |
else | |
void* mmap(void*, size_t, int, int, int, off_t); | |
int munmap(void*, size_t); | |
} | |
else | |
{ | |
static assert(false, "Unsupported platform"); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I brought this fix by accident and did git push -f
. :-(
I think we just need to get rid of these __traits( compiles, mmap )
at whole file replacing them by version(POSIX_MMAP)
, etc.
This bug is still here, but I don't have time at the moment to deal with it. It will be great if someone fixes it. :-) |
Current code silently ignores malloc call even if it available - import is forgotten.
This PR fixes it and adds assert checks to avoid this for other whan Windows or Posix platforms.