/*****************************************************************************
 * $Id: gfx_os.hh,v 1.56 2006/11/12 20:01:21 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 ---

#include <stdlib.h>       // GNU (default)
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/times.h>
#include <fcntl.h>

// --- ANSI/POSIX/universal header files (gfx_cc.hh includes C++ standard headers) ---

#include <limits.h>
#include <float.h>
//#include <math.h>  // gfx_cc.hh includes C++ <cmath>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <dirent.h>

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

// GFX_LITTLE_ENDIAN or GFX_BIG_ENDIAN abstracts compiler differences.
#if BYTE_ORDER == LITTLE_ENDIAN  // gcc
#   define GFX_LITTLE_ENDIAN 1
#elif BYTE_ORDER == BIG_ENDIAN  // gcc
#   define GFX_BIG_ENDIAN 1
#else
#   error "Need to define GFX_LITTLE/BIG_ENDIAN in gfx_os.hh"
#endif

// Limited use (may cause non-portable code).
// You might assume AMD64 has a 64-bit int.
// But in fact int is 32-bits on Linux x86-64 (its long is 64-bits).
#define GFX_INT_BITS  (sizeof(int)*8)
#define GFX_LONG_BITS  (sizeof(long)*8)

// Filesystem specific.
#define EXEC_SUFFIX_STR		""
#define DIRECTORY_CHAR		'/'
#define DIRECTORY_CHAR_STR	"/"
#define GETCWD				getcwd

#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 );

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

#endif // GFX_OS_HH
