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
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove IN_GCC code for xopCmp/xopEquals in compiler and library
- Loading branch information
Showing
3 changed files
with
70 additions
and
22 deletions.
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