athena/include/Athena/Global.hpp

129 lines
2.5 KiB
C++
Raw Normal View History

2014-04-20 09:14:15 +00:00
#ifndef GLOBAL_HPP
#define GLOBAL_HPP
#include <iostream>
2014-04-20 09:14:15 +00:00
#include "Athena/Types.hpp"
#include "Athena/Utility.hpp"
#ifdef _MSC_VER
#pragma warning(disable : 4996)
2015-06-20 04:40:15 +00:00
#include <sys/stat.h>
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
#endif
#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
#if !defined(S_ISLNK)
#define S_ISLNK(m) 0
#endif
#endif
#ifndef AT_PRETTY_FUNCTION
2015-05-04 03:57:00 +00:00
# if defined(__PRETTY_FUNCTION__) || defined(__GNUC__)
# define AT_PRETTY_FUNCTION __PRETTY_FUNCTION__
# elif defined(__FUNCSIG__)
# define AT_PRETTY_FUNCTION __FUNCSIG__
2014-06-03 03:09:40 +00:00
# elif defined(__FUNCTION__)
# define AT_PRETTY_FUNCTION __FUNCTION__
2014-06-03 03:09:40 +00:00
# elif defined(__FUNC__)
# define AT_PRETTY_FUNCTION __FUNC__
2014-06-03 03:09:40 +00:00
# elif defined(__func__)
# define AT_PRETTY_FUNCTION __func__
2014-06-03 03:09:40 +00:00
# else
# define AT_PRETTY_FUNCTION "<unknown>"
2014-06-03 03:09:40 +00:00
# endif
2014-05-15 05:42:20 +00:00
#endif
#ifdef GEKKO
#include "gekko_support.h"
typedef struct stat stat64_t;
#define stat64 stat
2015-06-20 04:40:15 +00:00
#elif _WIN32
typedef struct _stat64 stat64_t;
#else
typedef struct stat64 stat64_t;
#endif
2014-04-20 09:14:15 +00:00
#ifndef aDebug
#define aDebug() \
std::cout << __FILE__ << "(" << __LINE__ << ") " << AT_PRETTY_FUNCTION << ": "
2014-04-20 09:14:15 +00:00
#endif
#ifndef aError
#define aError() \
std::cerr << __FILE__ << "(" << __LINE__ << ") " << AT_PRETTY_FUNCTION << ": "
2014-04-20 09:14:15 +00:00
#endif
2014-04-29 02:31:32 +00:00
#ifndef aPrint
#define aPrint() std::cout
#endif
#define aEnd() '\n'
2014-04-20 09:14:15 +00:00
#ifndef BLOCKSZ
#define BLOCKSZ 512
#endif
#define ROUND_UP_32(val) (((val) + 31) & ~31)
#define ROUND_UP_16(val) (((val) + 15) & ~15)
2014-04-20 09:14:15 +00:00
namespace Athena
{
2015-06-16 02:29:53 +00:00
enum SeekOrigin
2014-04-20 09:14:15 +00:00
{
Begin,
Current,
End
};
2015-06-16 02:29:53 +00:00
enum Endian
2014-04-20 09:14:15 +00:00
{
LittleEndian,
BigEndian
};
#ifndef ATHENA_NO_SAKURA
2014-04-20 09:14:15 +00:00
namespace Sakura
{
template <typename T>
class Vector2D
2014-05-15 07:41:54 +00:00
{
2014-04-20 09:14:15 +00:00
public:
T x;
T y;
Vector2D()
: x(0),
y(0)
{
}
Vector2D(T x, T y)
: x(x),
y(y)
{
}
};
typedef Vector2D<int> Vector2Di;
typedef Vector2D<float> Vector2Df;
} // Sakura
#endif // ATHENA_NO_SAKURA
2014-04-20 09:14:15 +00:00
} // Athena
2015-05-18 23:28:17 +00:00
typedef void (*atEXCEPTION_HANDLER)(const std::string& file, const std::string& function, int line, const std::string&, ...);
atEXCEPTION_HANDLER atGetExceptionHandler();
void atSetExceptionHandler(atEXCEPTION_HANDLER func);
2014-04-20 09:14:15 +00:00
std::ostream& operator<<(std::ostream& os, const Athena::SeekOrigin& origin);
std::ostream& operator<<(std::ostream& os, const Athena::Endian& endian);
#endif // GLOBAL_HPP