~ubuntu-branches/debian/squeeze/openttd/squeeze

« back to all changes in this revision

Viewing changes to src/stdafx.h

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Matthijs Kooijman, Jordi Mallach
  • Date: 2009-04-15 18:22:10 UTC
  • mfrom: (1.1.6 upstream) (2.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090415182210-22ktb8kdbp2tf3bm
[ Matthijs Kooijman ]
* New upstream release.
* Remove Debian specific desktop file, upstream provides one now. 
* Add debian/watch file.

[ Jordi Mallach ]
* Bump Standards-Version to 3.8.1, with no changes required.
* Move to debhelper compat 7. Bump Build-Depends accordingly.
* Use dh_prep.
* Add "set -e" to config script.
* Remove a few extra doc files that get installed by upstream Makefile.
* Add more complete copyright information.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: stdafx.h 14429 2008-10-01 16:50:11Z rubidium $ */
 
1
/* $Id: stdafx.h 15710 2009-03-14 15:42:53Z glx $ */
2
2
 
3
 
/** @file stdafx.h */
 
3
/** @file stdafx.h Definition of base types and functions in a cross-platform compatible way. */
4
4
 
5
5
#ifndef STDAFX_H
6
6
#define STDAFX_H
32
32
                #include <stdint.h>
33
33
        #endif
34
34
#else
35
 
        #define INT64_MAX (9223372036854775807LL)
36
 
        #define INT64_MIN (-INT64_MAX - 1)
37
 
        #define INT16_MAX (32767)
38
 
        #define INT16_MIN (-INT16_MAX - 1)
 
35
        #define UINT64_MAX (18446744073709551615ULL)
 
36
        #define INT64_MAX  (9223372036854775807LL)
 
37
        #define INT64_MIN  (-INT64_MAX - 1)
 
38
        #define UINT32_MAX (4294967295U)
 
39
        #define INT32_MAX  (2147483647)
 
40
        #define INT32_MIN  (-INT32_MAX - 1)
 
41
        #define UINT16_MAX (65535U)
 
42
        #define INT16_MAX  (32767)
 
43
        #define INT16_MIN  (-INT16_MAX - 1)
39
44
#endif
40
45
 
41
46
#include <cstdio>
71
76
        #include <SupportDefs.h>
72
77
#endif
73
78
 
74
 
#if defined(SUNOS)
 
79
#if defined(SUNOS) || defined(HPUX)
75
80
        #include <alloca.h>
76
81
#endif
77
82
 
140
145
        #include <malloc.h> // alloca()
141
146
#endif
142
147
 
 
148
#if defined(WIN32)
 
149
        #define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
 
150
#endif
 
151
 
143
152
/* Stuff for MSVC */
144
153
#if defined(_MSC_VER)
145
154
        #pragma once
153
162
        #endif
154
163
        #define _WIN32_IE_ 0x0401         // 4.01 (win98 and NT4SP5+)
155
164
 
156
 
        #define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
157
165
        #pragma warning(disable: 4244)  // 'conversion' conversion from 'type1' to 'type2', possible loss of data
158
166
        #pragma warning(disable: 4761)  // integral size mismatch in argument : conversion supplied
159
167
        #pragma warning(disable: 4200)  // nonstandard extension used : zero-sized array in struct/union
160
168
 
161
169
        #if (_MSC_VER < 1400)                   // MSVC 2005 safety checks
162
 
                #error "Only MSVC 2005 or higher are supported. MSVC 2003 and earlier are not!. Upgrade your compiler."
 
170
                #error "Only MSVC 2005 or higher are supported. MSVC 2003 and earlier are not! Upgrade your compiler."
163
171
        #endif /* (_MSC_VER < 1400) */
164
172
        #pragma warning(disable: 4996)   // 'strdup' was declared deprecated
165
173
        #define _CRT_SECURE_NO_DEPRECATE // all deprecated 'unsafe string functions
180
188
        #endif
181
189
 
182
190
        int CDECL snprintf(char *str, size_t size, const char *format, ...);
183
 
        #if (_MSC_VER < 1400) || defined(WINCE)
 
191
        #if defined(WINCE)
184
192
                int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
185
193
        #endif
186
194
 
193
201
                typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
194
202
        #endif /* WIN32 && !_WIN64 && !WIN64 */
195
203
 
 
204
        #if defined(_WIN64) || defined(WIN64)
 
205
                #define fseek _fseeki64
 
206
        #endif /* _WIN64 || WIN64 */
 
207
 
 
208
 
196
209
        #define GCC_PACK
197
210
 
198
211
        /* This is needed to zlib uses the stdcall calling convention on visual studio */
211
224
                #define strncasecmp strnicmp
212
225
        #endif
213
226
 
214
 
        void SetExceptionString(const char* s, ...);
 
227
        void SetExceptionString(const char *s, ...);
215
228
 
216
229
        #if defined(NDEBUG) && defined(WITH_ASSERT)
217
230
                #undef assert
218
231
                #define assert(expression) if (!(expression)) { SetExceptionString("Assertion failed at %s:%d: %s", __FILE__, __LINE__, #expression); *(byte*)0 = 0; }
219
232
        #endif
 
233
 
 
234
        /* MSVC doesn't have these :( */
 
235
        #define S_ISDIR(mode) (mode & S_IFDIR)
 
236
        #define S_ISREG(mode) (mode & S_IFREG)
 
237
 
220
238
#endif /* defined(_MSC_VER) */
221
239
 
222
240
#if defined(WINCE)
229
247
        #if defined(WIN32) || defined(WIN64)
230
248
                char *getcwd(char *buf, size_t size);
231
249
                #include <tchar.h>
 
250
                #include <io.h>
232
251
 
233
252
                /* XXX - WinCE without MSVCRT doesn't support wfopen, so it seems */
234
253
                #if !defined(WINCE)
235
254
                        #define fopen(file, mode) _tfopen(OTTD2FS(file), _T(mode))
 
255
                        #define unlink(file) _tunlink(OTTD2FS(file))
236
256
                #endif /* WINCE */
237
257
 
238
258
                const char *FS2OTTD(const TCHAR *name);
287
307
assert_compile(sizeof(uint16) == 2);
288
308
assert_compile(sizeof(uint8)  == 1);
289
309
 
290
 
#define lengthof(x) (sizeof(x)/sizeof(x[0]))
 
310
/**
 
311
 * Return the length of an fixed size array.
 
312
 * Unlike sizeof this function returns the number of elements
 
313
 * of the given type.
 
314
 *
 
315
 * @param x The pointer to the first element of the array
 
316
 * @return The number of elements
 
317
 */
 
318
#define lengthof(x) (sizeof(x) / sizeof(x[0]))
 
319
 
 
320
/**
 
321
 * Get the end element of an fixed size array.
 
322
 *
 
323
 * @param x The pointer to the first element of the array
 
324
 * @return The pointer past to the last element of the array
 
325
 */
291
326
#define endof(x) (&x[lengthof(x)])
 
327
 
 
328
/**
 
329
 * Get the last element of an fixed size array.
 
330
 *
 
331
 * @param x The pointer to the first element of the array
 
332
 * @return The pointer to the last element of the array
 
333
 */
292
334
#define lastof(x) (&x[lengthof(x) - 1])
293
335
 
294
 
#define cpp_offsetof(s,m)   (((size_t)&reinterpret_cast<const volatile char&>((((s*)(char*)8)->m))) - 8)
 
336
#define cpp_offsetof(s, m)   (((size_t)&reinterpret_cast<const volatile char&>((((s*)(char*)8)->m))) - 8)
295
337
#if !defined(offsetof)
296
 
        #define offsetof(s,m) cpp_offsetof(s, m)
 
338
        #define offsetof(s, m) cpp_offsetof(s, m)
297
339
#endif /* offsetof */
298
340
 
299
341
 
304
346
        #define CloseConnection OTTD_CloseConnection
305
347
#endif /* __APPLE__ */
306
348
 
307
 
#if !defined(STRGEN)
308
 
        /* In strgen error is not fatal and returns */
309
 
        void NORETURN CDECL error(const char *str, ...);
310
 
#else
311
 
        void CDECL error(const char *str, ...);
312
 
#endif
313
 
 
 
349
void NORETURN CDECL usererror(const char *str, ...);
 
350
void NORETURN CDECL error(const char *str, ...);
314
351
#define NOT_REACHED() error("NOT_REACHED triggered at line %i of %s", __LINE__, __FILE__)
315
352
 
316
 
#if defined(MORPHOS) || defined(__NDS__)
 
353
#if defined(MORPHOS) || defined(__NDS__) || defined(__DJGPP__)
317
354
        /* MorphOS and NDS don't have C++ conformant _stricmp... */
318
355
        #define _stricmp stricmp
319
356
#elif defined(OPENBSD)
321
358
        #define _stricmp strcasecmp
322
359
#endif
323
360
 
324
 
#if !defined(MORPHOS) && !defined(OPENBSD) && !defined(__NDS__)
 
361
#if !defined(MORPHOS) && !defined(OPENBSD) && !defined(__NDS__) && !defined(__DJGPP__)
325
362
        /* NDS, MorphOS & OpenBSD don't know wchars, the rest does :( */
326
363
        #define HAS_WCHAR
327
364
#endif /* !defined(MORPHOS) && !defined(OPENBSD) && !defined(__NDS__) */