Mercurial > projects > ldc
comparison runtime/internal/typeinfo/ti_creal.d @ 443:44f08170f4ef
Removed tango from the repository and instead added a runtime dir with the files needed to patch and build tango from svn.
Reworked the LLVMDC specific pragmas.
author | Tomas Lindquist Olsen <tomas.l.olsen@gmail.com> |
---|---|
date | Fri, 01 Aug 2008 00:32:06 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
442:76078c8ab5b9 | 443:44f08170f4ef |
---|---|
1 | |
2 // creal | |
3 | |
4 module typeinfo.ti_creal; | |
5 | |
6 class TypeInfo_c : TypeInfo | |
7 { | |
8 char[] toString() { return "creal"; } | |
9 | |
10 hash_t getHash(void *p) | |
11 { | |
12 return (cast(uint *)p)[0] + (cast(uint *)p)[1] + | |
13 (cast(uint *)p)[2] + (cast(uint *)p)[3] + | |
14 (cast(uint *)p)[4]; | |
15 } | |
16 | |
17 static int _equals(creal f1, creal f2) | |
18 { | |
19 return f1 == f2; | |
20 } | |
21 | |
22 static int _compare(creal f1, creal f2) | |
23 { int result; | |
24 | |
25 if (f1.re < f2.re) | |
26 result = -1; | |
27 else if (f1.re > f2.re) | |
28 result = 1; | |
29 else if (f1.im < f2.im) | |
30 result = -1; | |
31 else if (f1.im > f2.im) | |
32 result = 1; | |
33 else | |
34 result = 0; | |
35 return result; | |
36 } | |
37 | |
38 int equals(void *p1, void *p2) | |
39 { | |
40 return _equals(*cast(creal *)p1, *cast(creal *)p2); | |
41 } | |
42 | |
43 int compare(void *p1, void *p2) | |
44 { | |
45 return _compare(*cast(creal *)p1, *cast(creal *)p2); | |
46 } | |
47 | |
48 size_t tsize() | |
49 { | |
50 return creal.sizeof; | |
51 } | |
52 | |
53 void swap(void *p1, void *p2) | |
54 { | |
55 creal t; | |
56 | |
57 t = *cast(creal *)p1; | |
58 *cast(creal *)p1 = *cast(creal *)p2; | |
59 *cast(creal *)p2 = t; | |
60 } | |
61 | |
62 void[] init() | |
63 { static creal r; | |
64 | |
65 return (cast(creal *)&r)[0 .. 1]; | |
66 } | |
67 } |