comparison runtime/internal/typeinfo/ti_cfloat.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 // cfloat
3
4 module typeinfo.ti_cfloat;
5
6 class TypeInfo_q : TypeInfo
7 {
8 char[] toString() { return "cfloat"; }
9
10 hash_t getHash(void *p)
11 {
12 return (cast(uint *)p)[0] + (cast(uint *)p)[1];
13 }
14
15 static int _equals(cfloat f1, cfloat f2)
16 {
17 return f1 == f2;
18 }
19
20 static int _compare(cfloat f1, cfloat f2)
21 { int result;
22
23 if (f1.re < f2.re)
24 result = -1;
25 else if (f1.re > f2.re)
26 result = 1;
27 else if (f1.im < f2.im)
28 result = -1;
29 else if (f1.im > f2.im)
30 result = 1;
31 else
32 result = 0;
33 return result;
34 }
35
36 int equals(void *p1, void *p2)
37 {
38 return _equals(*cast(cfloat *)p1, *cast(cfloat *)p2);
39 }
40
41 int compare(void *p1, void *p2)
42 {
43 return _compare(*cast(cfloat *)p1, *cast(cfloat *)p2);
44 }
45
46 size_t tsize()
47 {
48 return cfloat.sizeof;
49 }
50
51 void swap(void *p1, void *p2)
52 {
53 cfloat t;
54
55 t = *cast(cfloat *)p1;
56 *cast(cfloat *)p1 = *cast(cfloat *)p2;
57 *cast(cfloat *)p2 = t;
58 }
59
60 void[] init()
61 { static cfloat r;
62
63 return (cast(cfloat *)&r)[0 .. 1];
64 }
65 }