2010-08-08 01:06:34 -07:00
|
|
|
/*
|
2015-01-30 22:10:29 +01:00
|
|
|
Copyright (c) 1998-2015, Enno Rehling <enno@eressea.de>
|
2010-08-08 01:06:34 -07:00
|
|
|
Katja Zedel <katze@felidae.kn-bremen.de
|
|
|
|
Christian Schlittchen <corwin@amber.kn-bremen.de>
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
**/
|
|
|
|
|
2016-11-26 16:21:41 +01:00
|
|
|
#ifndef PLATFORM_H
|
|
|
|
#define PLATFORM_H
|
2010-08-08 01:06:34 -07:00
|
|
|
|
2014-06-26 22:05:17 -07:00
|
|
|
#ifdef NDEBUG
|
|
|
|
#define LOMEM
|
|
|
|
#endif
|
|
|
|
|
2016-11-26 16:21:41 +01:00
|
|
|
// enable X/Open 7 extensions (like strdup):
|
|
|
|
#ifndef _XOPEN_SOURCE
|
|
|
|
#define _XOPEN_SOURCE 700
|
|
|
|
#endif
|
|
|
|
|
2016-11-26 16:54:19 +01:00
|
|
|
// enable bsd string extensions, since glibc 2.12 (_BSD_SOURCE is dead):
|
2016-11-26 16:21:41 +01:00
|
|
|
#ifndef _POSIX_C_SOURCE
|
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef USE_AUTOCONF
|
2016-11-25 21:57:35 +01:00
|
|
|
#define USE_AUTOCONF
|
|
|
|
|
2010-08-08 01:06:34 -07:00
|
|
|
#ifdef _MSC_VER
|
2016-11-26 16:21:41 +01:00
|
|
|
#undef USE_AUTOCONF
|
|
|
|
#define HAVE_STDBOOL_H
|
|
|
|
#define HAVE_DIRECT__MKDIR
|
|
|
|
#define HAVE__ACCESS
|
|
|
|
|
|
|
|
#define VC_EXTRALEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2015-01-12 22:53:21 +01:00
|
|
|
#pragma warning(push)
|
|
|
|
#pragma warning(disable:4820 4255 4668)
|
2012-05-15 15:04:23 -07:00
|
|
|
# include <windows.h>
|
2015-01-12 22:53:21 +01:00
|
|
|
# include <io.h>
|
|
|
|
#pragma warning(pop)
|
2010-08-08 01:06:34 -07:00
|
|
|
# undef MOUSE_MOVED
|
2011-03-07 08:02:35 +01:00
|
|
|
# define STDIO_CP 1252 /* log.c, convert to console character set */
|
2010-08-08 01:06:34 -07:00
|
|
|
# pragma warning (disable: 4201 4214 4514 4115 4711)
|
2015-09-27 09:33:56 +02:00
|
|
|
#if _MSC_VER >= 1900
|
2015-09-26 14:01:01 +02:00
|
|
|
# pragma warning(disable: 4710)
|
|
|
|
/* warning C4710: function not inlined */
|
|
|
|
# pragma warning(disable: 4456)
|
|
|
|
/* warning C4456 : declaration of <name> hides previous local declaration */
|
|
|
|
# pragma warning(disable: 4457)
|
|
|
|
/* warning C4457: declaration of <name> hides function parameter */
|
|
|
|
# pragma warning(disable: 4459)
|
|
|
|
/* warning C4459: declaration of <name> hides global declaration */
|
2015-09-27 09:33:56 +02:00
|
|
|
#endif
|
2010-08-08 01:06:34 -07:00
|
|
|
# pragma warning(disable: 4056)
|
|
|
|
/* warning C4056: overflow in floating point constant arithmetic */
|
|
|
|
# pragma warning(disable: 4201)
|
|
|
|
/* warning C4201: nonstandard extension used : nameless struct/union */
|
|
|
|
# pragma warning(disable: 4214)
|
|
|
|
/* warning C4214: nonstandard extension used : bit field types other than int */
|
|
|
|
# pragma warning(disable: 4100)
|
|
|
|
/* warning C4100: <name> : unreferenced formal parameter */
|
|
|
|
# pragma warning(disable: 4996)
|
2012-05-15 15:04:23 -07:00
|
|
|
/* <name> is not defined as a preprocessor macro, replacing with '0' for '#if/#elif' */
|
|
|
|
# pragma warning(disable: 4668)
|
2015-01-12 22:53:21 +01:00
|
|
|
/* <type>: <num> bytes padding after data member <member> */
|
|
|
|
# pragma warning(disable: 4820)
|
2010-08-08 01:06:34 -07:00
|
|
|
|
|
|
|
/* warning C4100: <name> was declared deprecated */
|
|
|
|
#ifndef _CRT_SECURE_NO_DEPRECATE
|
2016-11-26 16:21:41 +01:00
|
|
|
#define _CRT_SECURE_NO_DEPRECATE
|
2010-08-08 01:06:34 -07:00
|
|
|
#endif
|
|
|
|
|
2013-12-31 01:06:28 -08:00
|
|
|
/*
|
|
|
|
* http://msdn2.microsoft.com/en-us/library/ms235505(VS.80).aspx
|
|
|
|
* Defining _CRT_DISABLE_PERFCRIT_LOCKS forces all I/O operations to assume a
|
|
|
|
* single-threaded I/O model and use the _nolock forms of the functions.
|
|
|
|
*/
|
2010-08-08 01:06:34 -07:00
|
|
|
#ifndef _CRT_DISABLE_PERFCRIT_LOCKS
|
2016-11-26 16:21:41 +01:00
|
|
|
#define _CRT_DISABLE_PERFCRIT_LOCKS
|
2010-08-08 01:06:34 -07:00
|
|
|
#endif
|
|
|
|
|
2016-11-25 21:57:35 +01:00
|
|
|
#elif __GNUC__
|
2016-11-26 16:21:41 +01:00
|
|
|
#undef USE_AUTOCONF
|
|
|
|
#define HAVE_SNPRINTF
|
|
|
|
#define HAVE_SYS_STAT_MKDIR
|
|
|
|
#define HAVE_STRDUP
|
|
|
|
#define HAVE_UNISTD_H
|
|
|
|
#endif
|
2016-11-25 21:57:35 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef USE_AUTOCONF
|
2016-11-26 16:21:41 +01:00
|
|
|
// unknown toolchain, using autoconf
|
2016-11-25 21:12:14 +01:00
|
|
|
#include <autoconf.h>
|
2010-08-08 01:06:34 -07:00
|
|
|
#endif
|
|
|
|
|
2014-04-11 19:20:20 -07:00
|
|
|
#define unused_arg (void)
|
2010-08-08 01:06:34 -07:00
|
|
|
|
|
|
|
#define iswxspace(c) (c==160 || iswspace(c))
|
|
|
|
#define isxspace(c) (c==160 || isspace(c))
|
|
|
|
|
|
|
|
#define TOLUA_CAST (char*)
|
2013-12-29 09:31:49 +01:00
|
|
|
|
2014-03-15 19:29:11 +01:00
|
|
|
#if !defined(MAX_PATH)
|
|
|
|
#if defined(PATH_MAX)
|
|
|
|
# define MAX_PATH PATH_MAX
|
2013-12-31 10:25:25 +01:00
|
|
|
#else
|
2014-03-15 19:29:11 +01:00
|
|
|
# define MAX_PATH 256
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
2016-11-25 20:15:11 +01:00
|
|
|
#if defined(HAVE_STDBOOL_H)
|
|
|
|
# include <stdbool.h>
|
|
|
|
#else
|
2016-11-26 07:04:18 +01:00
|
|
|
# ifndef HAVE__BOOL
|
2016-11-25 20:15:11 +01:00
|
|
|
# ifdef __cplusplus
|
|
|
|
typedef bool _Bool;
|
|
|
|
# else
|
|
|
|
typedef unsigned char _Bool;
|
|
|
|
# endif
|
|
|
|
# endif
|
|
|
|
# define bool _Bool
|
|
|
|
# define false 0
|
|
|
|
# define true 1
|
|
|
|
# define __bool_true_false_are_defined 1
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef HAVE__ACCESS
|
|
|
|
#ifdef HAVE_ACCESS
|
|
|
|
#define _access(path, mode) access(path, mode)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_DIRECT__MKDIR)
|
|
|
|
#include <direct.h>
|
|
|
|
#elif defined(HAVE_DIRECT_MKDIR)
|
|
|
|
#include <direct.h>
|
|
|
|
#define _mkdir(a) mkdir(a)
|
|
|
|
#elif defined(HAVE_SYS_STAT_MKDIR)
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#define _mkdir(a) mkdir(a, 0777)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _min
|
|
|
|
#define _min(a,b) ((a) < (b) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
#ifndef _max
|
|
|
|
#define _max(a,b) ((a) > (b) ? (a) : (b))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(HAVE__STRDUP)
|
|
|
|
#if defined(HAVE_STRDUP)
|
2016-11-25 21:57:35 +01:00
|
|
|
#undef _strdup
|
2016-11-26 16:21:41 +01:00
|
|
|
#define _strdup strdup
|
2016-11-25 20:15:11 +01:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if !defined(HAVE__SNPRINTF)
|
|
|
|
#if defined(HAVE_SNPRINTF)
|
|
|
|
#define _snprintf snprintf
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2010-08-08 01:06:34 -07:00
|
|
|
#endif
|
2014-06-09 09:54:48 -07:00
|
|
|
|