5 #include "athena/Types.hpp" 6 #include "athena/Utility.hpp" 9 #pragma warning(disable : 4996) 13 #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG) 14 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 17 #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR) 18 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 33 #ifndef AT_PRETTY_FUNCTION 34 # if defined(__PRETTY_FUNCTION__) || defined(__GNUC__) 35 # define AT_PRETTY_FUNCTION __PRETTY_FUNCTION__ 36 # elif defined(__FUNCSIG__) 37 # define AT_PRETTY_FUNCTION __FUNCSIG__ 38 # elif defined(__FUNCTION__) 39 # define AT_PRETTY_FUNCTION __FUNCTION__ 40 # elif defined(__FUNC__) 41 # define AT_PRETTY_FUNCTION __FUNC__ 42 # elif defined(__func__) 43 # define AT_PRETTY_FUNCTION __func__ 45 # define AT_PRETTY_FUNCTION "<unknown>" 51 #include "gekko_support.h" 52 typedef struct stat stat64_t;
55 typedef struct _stat64 stat64_t;
57 typedef struct stat stat64_t;
59 #define fseeko64 fseeko 60 #define ftello64 ftello 62 typedef struct stat64 stat64_t;
69 #define ROUND_UP_256(val) (((val) + 255) & ~255) 70 #define ROUND_UP_64(val) (((val) + 63) & ~63) 71 #define ROUND_UP_32(val) (((val) + 31) & ~31) 72 #define ROUND_UP_16(val) (((val) + 15) & ~15) 73 #define ROUND_UP_4(val) (((val) + 3) & ~3) 75 #define _XSTR(s) _STR(s) 78 #ifndef ENABLE_BITWISE_ENUM 79 #define ENABLE_BITWISE_ENUM(type)\ 80 constexpr type operator|(type a, type b)\ 82 using T = std::underlying_type_t<type>;\ 83 return type(static_cast<T>(a) | static_cast<T>(b));\ 85 constexpr type operator&(type a, type b)\ 87 using T = std::underlying_type_t<type>;\ 88 return type(static_cast<T>(a) & static_cast<T>(b));\ 90 inline type& operator|=(type& a, const type& b)\ 92 using T = std::underlying_type_t<type>;\ 93 a = type(static_cast<T>(a) | static_cast<T>(b));\ 96 inline type& operator&=(type& a, const type& b)\ 98 using T = std::underlying_type_t<type>;\ 99 a = type(static_cast<T>(a) & static_cast<T>(b));\ 102 inline type operator~(const type& key)\ 104 using T = std::underlying_type_t<type>;\ 105 return type(~static_cast<T>(key));\ 135 typedef void (*atEXCEPTION_HANDLER)(athena::error::Level level,
const char* file,
const char*
function,
int line,
const char* fmt, ...);
137 atEXCEPTION_HANDLER atGetExceptionHandler();
142 void atSetExceptionHandler(atEXCEPTION_HANDLER func);
144 std::ostream& operator<<(std::ostream& os,
const athena::SeekOrigin& origin);
145 std::ostream& operator<<(std::ostream& os,
const athena::Endian& endian);
149 #define atDebug(fmt, ...) \ 150 do { atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \ 152 __handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, ##__VA_ARGS__); \ 155 #define atDebug(fmt, ...) 158 #define atMessage(fmt, ...) \ 159 do { atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \ 161 __handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, ##__VA_ARGS__); \ 164 #define atWarning(fmt, ...) \ 165 do { atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \ 167 __handler(athena::error::Level::Warning, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, ##__VA_ARGS__); \ 170 #define atError(fmt, ...) \ 171 do { atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \ 173 __handler(athena::error::Level::Error, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, ##__VA_ARGS__); \ 176 #define atFatal(fmt, ...) \ 177 do { atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \ 179 __handler(athena::error::Level::Fatal, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt, ##__VA_ARGS__); \ 181 #elif defined(__GNUC__) 184 #define atDebug(fmt...) \ 185 do { atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \ 187 __handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt); \ 190 #define atDebug(fmt, ...) 193 #define atMessage(fmt...) \ 194 do { atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \ 196 __handler(athena::error::Level::Message, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt); \ 199 #define atWarning(fmt...) \ 200 do { atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \ 202 __handler(athena::error::Level::Warning, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt); \ 205 #define atError(fmt...) \ 206 do { atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \ 208 __handler(athena::error::Level::Error, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt); \ 211 #define atFatal(fmt...) \ 212 do { atEXCEPTION_HANDLER __handler = atGetExceptionHandler(); \ 214 __handler(athena::error::Level::Fatal, __FILE__, AT_PRETTY_FUNCTION, __LINE__, fmt); \ 216 #endif // defined(__GNUC__)