This repository has been archived by the owner on Jun 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Remove IN_GCC code for xopCmp/xopEquals in compiler and library #465
Open
ibuclaw
wants to merge
1
commit into
D-Programming-GDC:master
Choose a base branch
from
ibuclaw:rm-xopcmp-bug
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
struct S1 | ||
{ | ||
long x1, x2; | ||
|
||
int opCmp(ref const S1 s) const | ||
{ | ||
if (x2 - s.x2 != 0) | ||
return x2 < s.x2 ? -1 : 1; | ||
|
||
return x1 < s.x1 ? -1 : x1 == s.x1 ? 0 : 1; | ||
} | ||
} | ||
|
||
struct S2 | ||
{ | ||
long x1, x2; | ||
|
||
int opCmp(in S2 s) const | ||
{ | ||
if (x2 - s.x2 != 0) | ||
return x2 < s.x2 ? -1 : 1; | ||
|
||
return x1 < s.x1 ? -1 : x1 == s.x1 ? 0 : 1; | ||
} | ||
} | ||
|
||
extern (C) int structcmp(T)(scope T a, scope T b) | ||
{ | ||
extern (C) int cmp(scope const void* p1, scope const void* p2, scope void* ti) | ||
{ | ||
return (cast(TypeInfo)ti).compare(p1, p2); | ||
} | ||
return cmp(&a, &b, cast(void*)typeid(T)); | ||
} | ||
|
||
void test5854() | ||
{ | ||
alias Tuple(T...) = T; | ||
|
||
foreach (T; Tuple!(S1, S2)) | ||
{ | ||
assert(T(1, 3).structcmp(T(4, 4)) == -1); | ||
assert(T(1, 3).structcmp(T(4, 3)) == -1); | ||
assert(T(4, 3).structcmp(T(4, 3)) == 0); | ||
assert(T(5, 3).structcmp(T(4, 3)) == 1); | ||
assert(T(5, 4).structcmp(T(4, 3)) == 1); | ||
} | ||
} | ||
|
||
void main() | ||
{ | ||
test5854(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
xopEquals
is now in the global namespace. I wonder whether we should prefix all (new)extern(C)
druntime functions with something?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.
I don't think the frontend cares about that. As it makes the call through a function pointer, so this only changes ABI of how parameters are expected to be passed.
I didn't check the code in clone.d, but when I spoke to Daniel about it, I recall him saying that it's just an abi hack. The compiler sees xopCmp as a C function internally, but reverses the arguments as its really calling a D method.
This reversing of arguments never worked for gdc.
...
However I should check something about this, as it appears that the test for xopCmp parameter order was removed or no longer uses the generated xopCmp call.
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.
Oh, you're right, I totally forgot that this is just a pointer to a generated function (which then obviously has a unique name) 👍
Does the frontend emit these
xopCmp
functions asextern(C)
orextern(D)
?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.
That is just what I've pushed a test for. The
__xopCmp
function is marked as LINKd at least.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.
Although, now I think about it, it doesn't really matter for us as LINKd and LINKc are the same...