/*****************************************************************************
 * $Id: gfx_os.hh,v 1.50 2006/08/01 01:36:54 devel Exp $
 * @file
 * @author	Jim E. Brooks  http://www.jimbrooks.org
 * @brief	Operating-system specific header file.
 *//*
 * LEGAL:	COPYRIGHT (C) 2004 JIM E. BROOKS
 *          THIS SOURCE CODE IS RELEASED UNDER THE TERMS
 *          OF THE GNU GENERAL PUBLIC LICENSE (GPL).
 *****************************************************************************/

#ifndef GFX_OS_HH
#define GFX_OS_HH 1

// --- OS-specific ---
#if defined(_WIN32)		// Win32
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <sys/timeb.h>
#include <fcntl.h>
#include <io.h>
#include <direct.h>
#else					// GNU (default)
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/times.h>
#include <fcntl.h>
#endif

// --- ANSI/POSIX/universal header files ---
#include <limits.h>
#include <float.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#if ! defined(_WIN32)
#include <dirent.h>
#endif

// -----------------------------------------------------------------------------
namespace gfx {

#ifndef INT_MAX
#define INT_MAX		(0x7fffffff)
#endif
#ifndef INT_MIN
#define INT_MIN		(-0x80000000)		// minus sign for 64-bit arch
#endif

// Filesystem.
#if defined(_WIN32)
#define DOSFS 1		// use MSDOS directory char
#endif

// Win32 has many POSIX counterparts with '_' prefix.
#if defined(_WIN32)
#	define EXEC_SUFFIX_STR		".exe"
#	define DIRECTORY_CHAR		'\\'
#	define DIRECTORY_CHAR_STR	"\\"
#	define GETCWD				_getcwd		// use higher-level Getcwd() in gfx_file.cc
#else
#	define EXEC_SUFFIX_STR		""
#	define DIRECTORY_CHAR		'/'
#	define DIRECTORY_CHAR_STR	"/"
#	define GETCWD				getcwd
#endif

#if __GNUC__
#define GCC_VERSION (__GNUC__*10000 + __GNUC_MINOR__*100 + __GNUC_PATCHLEVEL__)
#else
#define GCC_VERSION 0 // if nothing will cause error on Visual C++
#endif

// If C++ compiler is old (eg deprecated .h suffix for C++ headers).
#if defined(__GNUC__) && GCC_VERSION < 30000 && ! defined(OLD_CC)
#define OLD_CC	1
#endif

#if defined(__GNUC__) && GCC_VERSION < 30000
#define GCC29 1
#endif

#if 0
#if defined(__GNUC__) && GCC_VERSION >= 30000 && GCC_VERSION < 30100
#error "gcc-3.0.x cannot compile this program correctly"
#error "Compile with 2.9.x or 3.1.x or later."
#endif
#endif

// prototypes

void
Snooze( uint milsec );

#if _WIN32
void
Win32CreateConsole( void );
#endif // _WIN32

} // namespace gfx
// -----------------------------------------------------------------------------

#endif // GFX_OS_HH
