]> git.jsancho.org Git - lugaru.git/blob - Source/MacCompatibility.h
Removed obsolete PLATFORM_MACOSX code
[lugaru.git] / Source / MacCompatibility.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3
4 This file is part of Lugaru.
5
6 Lugaru is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 Lugaru is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _MACCOMPATIBLITY_H_
21 #define _MACCOMPATIBLITY_H_
22
23 #include <stdio.h>
24 #include <float.h>
25 #include <math.h>
26
27 // stuff to make Mac code compatable with Windows/Linux/etc
28
29 #if defined(WIN32) && !defined(strcasecmp)
30 #define strcasecmp(a,b) stricmp(a,b)
31 #endif
32
33 #ifdef _MSC_VER
34 // disable warnings about double to float conversions
35 #pragma warning(disable:4305)
36 #pragma warning(disable:4244)
37
38 // disable warnings about boolean to int conversions
39 #pragma warning(disable:4800)
40
41 // disable warning about unreferenced local variables
42 #pragma warning(disable:4101)
43 #endif
44
45 #ifndef __forceinline
46 #  ifdef __GNUC__
47 #    define __forceinline inline __attribute__((always_inline))
48 #  endif
49 #endif
50
51 typedef bool Boolean;
52
53
54 struct Point {
55     short v;
56     short h;
57 };
58
59 typedef signed char SInt8;
60 typedef unsigned int UInt32;
61
62
63 #include "Random.h"
64
65
66 void CopyCStringToPascal( const char* src, unsigned char dst[256]);
67 void CopyPascalStringToC( const unsigned char* src, char* dst);
68
69
70 typedef struct AbsoluteTime {
71     unsigned long   hi;
72     unsigned long   lo;
73 } AbsoluteTime;
74
75 AbsoluteTime UpTime(); // NOTE: returns time since app started, not system start
76
77 typedef long Duration;
78
79 enum {
80     durationMicrosecond             = -1,
81     durationMillisecond             = 1,
82     durationSecond                  = 1000,
83     durationMinute                  = 1000 * 60,
84     durationHour                    = 1000 * 60 * 60,
85     durationDay                     = 1000 * 60 * 60 * 24,
86     durationForever                 = 0x7FFFFFFF,
87     durationImmediate               = 0,
88 };
89
90 Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
91
92 #ifdef _MSC_VER
93 inline bool isnormal( double x)
94 {
95     int ret = _fpclass( x);
96     return (ret == _FPCLASS_NN || ret == _FPCLASS_PN);
97 }
98 #else
99 #include <stdint.h>
100 #endif
101
102
103 // fix file names to use '/' instead of ':'
104 char* ConvertFileName( const char* orgfilename, const char *mode = "rb" );
105
106 #define fopen( a, b) fopen(ConvertFileName(a, b), b)
107
108 #endif
109
110