]> git.jsancho.org Git - lugaru.git/blob - Source/WinDefs.h
Initial import.
[lugaru.git] / Source / WinDefs.h
1 #ifndef _WINDEFS_H_
2 #define _WINDEFS_H_
3 #ifdef WIN32
4
5
6 #include <stdio.h>
7 #include <float.h>
8
9 // stuff to make Mac code compatable with Windows
10
11
12 // disable warnings about double to float conversions
13 #pragma warning(disable:4305)
14 #pragma warning(disable:4244)
15
16 // disable warnings about boolean to int conversions
17 #pragma warning(disable:4800)
18
19 // disable warning about unreferenced local variables
20 #pragma warning(disable:4101)
21
22 typedef bool Boolean;
23
24
25 struct Point
26 {
27         short v;
28         short h;
29 };
30
31 typedef signed char SInt8;
32 typedef unsigned int UInt32;
33
34
35 #include "Random.h"
36
37
38 void CopyCStringToPascal( const char* src, unsigned char dst[256]);
39 void CopyPascalStringToC( const unsigned char* src, char* dst);
40
41
42 typedef struct AbsoluteTime
43 {
44         unsigned long   hi;
45         unsigned long   lo;
46 } AbsoluteTime; 
47
48 AbsoluteTime UpTime();          // NOTE: returns time since app started, not system start
49
50 typedef long Duration; 
51
52 enum
53 {
54         durationMicrosecond             = -1,
55         durationMillisecond             = 1,
56         durationSecond                  = 1000,
57         durationMinute                  = 1000 * 60,
58         durationHour                    = 1000 * 60 * 60,
59         durationDay                     = 1000 * 60 * 60 * 24,
60         durationForever                 = 0x7FFFFFFF,
61         durationImmediate               = 0,
62 }; 
63
64 Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
65
66
67 inline bool isnormal( double x)
68 {
69         int ret = _fpclass( x);
70         return (ret == _FPCLASS_NN || ret == _FPCLASS_PN);
71 }
72
73 typedef unsigned int uintptr_t;
74
75
76 // fix file names to use '/' instead of ':'
77 char* ConvertFileName( const char* orgfilename);
78
79 #define fopen( a, b) fopen( ConvertFileName( a), b);
80 /*
81 inline float abs( float f)
82 {
83 if (f < 0)
84 return -f;
85 return f;
86 }
87
88 inline double abs( double f)
89 {
90 if (f < 0)
91 return -f;
92 return f;
93 }
94 */
95 inline long long abs( long long f)
96 {
97         if (f < 0)
98                 return -f;
99         return f;
100 }
101 #endif
102 #endif