2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program 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.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #ifndef _MACCOMPATIBLITY_H_
23 #define _MACCOMPATIBLITY_H_
31 // stuff to make Mac code compatable with Windows/Linux/etc
33 #if defined(WIN32) && !defined(strcasecmp)
34 #define strcasecmp(a,b) stricmp(a,b)
38 // disable warnings about double to float conversions
39 #pragma warning(disable:4305)
40 #pragma warning(disable:4244)
42 // disable warnings about boolean to int conversions
43 #pragma warning(disable:4800)
45 // disable warning about unreferenced local variables
46 #pragma warning(disable:4101)
51 # define __forceinline inline __attribute__((always_inline))
63 typedef signed char SInt8;
64 typedef unsigned int UInt32;
70 void CopyCStringToPascal( const char* src, unsigned char dst[256]);
71 void CopyPascalStringToC( const unsigned char* src, char* dst);
74 typedef struct AbsoluteTime {
79 AbsoluteTime UpTime(); // NOTE: returns time since app started, not system start
81 typedef long Duration;
84 durationMicrosecond = -1,
85 durationMillisecond = 1,
86 durationSecond = 1000,
87 durationMinute = 1000 * 60,
88 durationHour = 1000 * 60 * 60,
89 durationDay = 1000 * 60 * 60 * 24,
90 durationForever = 0x7FFFFFFF,
91 durationImmediate = 0,
94 Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
97 inline bool isnormal( double x)
99 int ret = _fpclass( x);
100 return (ret == _FPCLASS_NN || ret == _FPCLASS_PN);
107 // fix file names to use '/' instead of ':'
108 char* ConvertFileName( const char* orgfilename, const char *mode = "rb" );
110 #define fopen( a, b) fopen(ConvertFileName(a, b), b)