global.h
Go to the documentation of this file.00001
#if !defined(SM_PCH) || SM_PCH == FALSE
00002
00003
#ifndef GLOBAL_H
00004
#define GLOBAL_H
00005
00006
#ifdef HAVE_CONFIG_H
00007
#include "config.h"
00008
#endif
00009
00010
#if _MSC_VER >= 1000
00011
#pragma once
00012
#endif // _MSC_VER >= 1000
00013
00014
00015
#if defined(WIN32)
00016
#include "archutils/Win32/arch_setup.h"
00017
#elif defined(PBBUILD)
00018
#include "archutils/Darwin/arch_setup.h"
00019
#elif defined(UNIX)
00020
#include "archutils/Unix/arch_setup.h"
00021
#endif
00022
00023
00024
00025
#if !defined(ENDIAN_LITTLE) && !defined(ENDIAN_BIG)
00026
#error Neither ENDIAN_LITTLE nor ENDIAN_BIG defined
00027
#endif
00028
00029
00030
#if defined(HAVE_ENDIAN_H)
00031
#include <endian.h>
00032
#else
00033 #define LITTLE_ENDIAN 1234
00034 #define BIG_ENDIAN 4321
00035
#if defined(ENDIAN_LITTLE)
00036
#define BYTE_ORDER LITTLE_ENDIAN
00037
#elif defined(ENDIAN_BIG)
00038
#define BYTE_ORDER BIG_ENDIAN
00039
#endif
00040
00041
#endif
00042
00043
00044
#include <algorithm>
00045
00046
00047
#include <string>
00048
00049
00050
#include <vector>
00051
00052
#if !defined(MISSING_STDINT_H)
00053
#include <stdint.h>
00054
#endif
00055
00056
#if defined(NEED_CSTDLIB_WORKAROUND)
00057
#define llabs ::llabs
00058
#endif
00059
00060
#if defined(NEED_MINMAX_TEMPLATES)
00061
00062
template<
class T>
00063
inline const T&
max(
const T &a,
const T &b) {
return a < b? b:a; }
00064
template<
class T,
class P>
00065
inline const T&
max(
const T &a,
const T &b, P Pr) {
return Pr(a, b)? b:a; }
00066
template<
class T>
00067
inline const T&
min(
const T &a,
const T &b) {
return b < a? b:a; }
00068
template<
class T,
class P>
00069
inline const T&
min(
const T &a,
const T &b, P Pr) {
return Pr(b, a)? b:a; }
00070
#endif
00071
00072
using namespace std;
00073
00074
#ifdef ASSERT
00075
#undef ASSERT
00076
#endif
00077
00078
00079 namespace Checkpoints
00080 {
00081
void SetCheckpoint(
const char *file,
int line,
const char *message );
00082 };
00083 #define CHECKPOINT (Checkpoints::SetCheckpoint(__FILE__, __LINE__, NULL))
00084 #define CHECKPOINT_M(m) (Checkpoints::SetCheckpoint(__FILE__, __LINE__, m))
00085
00086
00087
00088
00089
00090
00091
#if defined(_MSC_VER)
00092
#define NORETURN __declspec(noreturn)
00093
#elif defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5))
00094
#define NORETURN __attribute__ ((__noreturn__))
00095
#else
00096 #define NORETURN
00097
#endif
00098
00099
void NORETURN sm_crash(
const char *reason =
"Internal error" );
00100
00101
00102
00103
00104
00105 #define FAIL_M(MESSAGE) { CHECKPOINT_M(MESSAGE); sm_crash(MESSAGE); }
00106 #define ASSERT_M(COND, MESSAGE) { if(!(COND)) { FAIL_M(MESSAGE); } }
00107 #define ASSERT(COND) ASSERT_M((COND), "Assertion '" #COND "' failed")
00108
00109
#ifdef DEBUG
00110
#define DEBUG_ASSERT(x) ASSERT(x)
00111
#else
00112 #define DEBUG_ASSERT(x)
00113
#endif
00114
00115
00116
00117
#if defined(__GNUC__)
00118
#define PRINTF(a,b) __attribute__((format(__printf__,a,b)))
00119
#else
00120 #define PRINTF(a,b)
00121
#endif
00122
00123
#if !defined(ALIGN)
00124
#if defined(__GNUC__)
00125
#define ALIGN(n) __attribute__((aligned(n)))
00126
#else
00127 #define ALIGN(n)
00128
#endif
00129
#endif
00130
00131
00132
#include "StdString.h"
00133
00134 typedef const CString&
CCStringRef;
00135
00136
00137
00138
00139
#include "RageException.h"
00140
00141
#if !defined(WIN32)
00142 #define stricmp strcasecmp
00143 #define strnicmp strncasecmp
00144
#endif
00145
00146
00147
#include <cmath>
00148
#ifdef NEED_POWF
00149
inline float powf (
float x,
float y) {
return float(pow(
double(x),
double(y))); }
00150
#endif
00151
00152
#ifdef NEED_SQRTF
00153
inline float sqrtf(
float x) {
return float(sqrt(
double(x))); }
00154
#endif
00155
00156
#ifdef NEED_SINF
00157
inline float sinf(
float x) {
return float(sin(
double(x))); }
00158
#endif
00159
00160
#ifdef NEED_TANF
00161
inline float tanf(
float x) {
return float(tan(
double(x))); }
00162
#endif
00163
00164
#ifdef NEED_COSF
00165
inline float cosf(
float x) {
return float(cos(
double(x))); }
00166
#endif
00167
00168
#ifdef NEED_ACOSF
00169
inline float acosf(
float x) {
return float(acos(
double(x))); }
00170
#endif
00171
00172
#ifdef NEED_TRUNCF
00173
inline float truncf(
float f ) {
return float(
int(f)); };
00174
#endif
00175
00176
#ifdef NEED_ROUNDF
00177
inline float roundf(
float f ) {
if(
f < 0)
return truncf(f-0.5f);
return truncf(f+0.5f); };
00178
#endif
00179
00180
#ifdef NEED_STRTOF
00181
inline float strtof(
const char *s,
char **se ) {
return (
float) strtod( s, se ); }
00182
#endif
00183
00184
00185
00186
#endif
00187
00188
#endif
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
Generated on Thu Jan 27 20:57:21 2005 for StepMania by
1.3.7