]> git.jsancho.org Git - lugaru.git/blob - Source/MacCompatibility.h
License: Update GPLv2+ header to match current FSF recommendation
[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 #if !PLATFORM_MACOSX
24
25 #include <stdio.h>
26 #include <float.h>
27 #include <math.h>
28
29 // stuff to make Mac code compatable with Windows/Linux/etc
30
31 #if defined(WIN32) && !defined(strcasecmp)
32 #define strcasecmp(a,b) stricmp(a,b)
33 #endif
34
35 #ifdef _MSC_VER
36 // disable warnings about double to float conversions
37 #pragma warning(disable:4305)
38 #pragma warning(disable:4244)
39
40 // disable warnings about boolean to int conversions
41 #pragma warning(disable:4800)
42
43 // disable warning about unreferenced local variables
44 #pragma warning(disable:4101)
45 #endif
46
47 #ifndef __forceinline
48 #  ifdef __GNUC__
49 #    define __forceinline inline __attribute__((always_inline))
50 #  endif
51 #endif
52
53 typedef bool Boolean;
54
55
56 struct Point {
57     short v;
58     short h;
59 };
60
61 typedef signed char SInt8;
62 typedef unsigned int UInt32;
63
64
65 #include "Random.h"
66
67
68 void CopyCStringToPascal( const char* src, unsigned char dst[256]);
69 void CopyPascalStringToC( const unsigned char* src, char* dst);
70
71
72 typedef struct AbsoluteTime {
73     unsigned long   hi;
74     unsigned long   lo;
75 } AbsoluteTime;
76
77 AbsoluteTime UpTime(); // NOTE: returns time since app started, not system start
78
79 typedef long Duration;
80
81 enum {
82     durationMicrosecond             = -1,
83     durationMillisecond             = 1,
84     durationSecond                  = 1000,
85     durationMinute                  = 1000 * 60,
86     durationHour                    = 1000 * 60 * 60,
87     durationDay                     = 1000 * 60 * 60 * 24,
88     durationForever                 = 0x7FFFFFFF,
89     durationImmediate               = 0,
90 };
91
92 Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
93
94 #ifdef _MSC_VER
95 inline bool isnormal( double x)
96 {
97     int ret = _fpclass( x);
98     return (ret == _FPCLASS_NN || ret == _FPCLASS_PN);
99 }
100 #else
101 #include <stdint.h>
102 #endif
103
104
105 // fix file names to use '/' instead of ':'
106 char* ConvertFileName( const char* orgfilename, const char *mode = "rb" );
107
108 #define fopen( a, b) fopen(ConvertFileName(a, b), b)
109
110 #endif
111 #endif
112
113