2012-11-01 15:19:01 +00:00
|
|
|
// Copyright (C) 2003 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2012-11-04 22:01:49 +00:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2013-01-12 10:31:32 +00:00
|
|
|
#pragma once
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2022-06-19 14:31:07 +00:00
|
|
|
#include "ppsspp_config.h"
|
|
|
|
|
2014-12-06 11:19:23 +00:00
|
|
|
#include "CommonTypes.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2017-08-30 23:14:51 +00:00
|
|
|
#ifndef ARRAY_SIZE
|
|
|
|
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
|
|
|
#endif
|
|
|
|
|
2016-05-08 20:27:20 +00:00
|
|
|
#if !defined(_WIN32)
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2013-09-29 02:15:02 +00:00
|
|
|
#include <unistd.h>
|
2012-11-01 15:19:01 +00:00
|
|
|
#include <errno.h>
|
|
|
|
|
2023-08-12 19:38:35 +00:00
|
|
|
#if (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)) && !defined(__EMSCRIPTEN__)
|
2016-05-08 20:27:20 +00:00
|
|
|
#define Crash() {asm ("int $3");}
|
2023-06-27 11:42:54 +00:00
|
|
|
#elif PPSSPP_PLATFORM(SWITCH)
|
|
|
|
// TODO: Implement Crash() for Switch, lets not use breakpoint for the time being
|
|
|
|
#define Crash() {*((volatile u32 *)0x0) = 0xDEADC0DE;}
|
2022-06-19 14:31:07 +00:00
|
|
|
#elif PPSSPP_ARCH(ARM)
|
|
|
|
#define Crash() {asm ("bkpt #0");}
|
|
|
|
#elif PPSSPP_ARCH(ARM64)
|
|
|
|
#define Crash() {asm ("brk #0");}
|
2023-02-12 20:10:29 +00:00
|
|
|
#elif PPSSPP_ARCH(RISCV64)
|
|
|
|
#define Crash() {asm ("ebreak");}
|
2022-06-19 14:46:55 +00:00
|
|
|
#else
|
|
|
|
#include <signal.h>
|
|
|
|
#define Crash() {kill(getpid(), SIGINT);}
|
2012-11-01 15:19:01 +00:00
|
|
|
#endif
|
2014-09-06 08:47:25 +00:00
|
|
|
|
2013-04-04 17:16:15 +00:00
|
|
|
inline u32 __rotl(u32 x, int shift) {
|
2016-05-08 20:27:20 +00:00
|
|
|
shift &= 31;
|
|
|
|
if (!shift) return x;
|
|
|
|
return (x << shift) | (x >> (32 - shift));
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|
|
|
|
|
2013-04-04 17:16:15 +00:00
|
|
|
inline u64 __rotl64(u64 x, unsigned int shift){
|
2012-11-01 15:19:01 +00:00
|
|
|
unsigned int n = shift % 64;
|
|
|
|
return (x << n) | (x >> (64 - n));
|
|
|
|
}
|
|
|
|
|
2013-04-04 17:16:15 +00:00
|
|
|
inline u32 __rotr(u32 x, int shift) {
|
2012-11-01 15:19:01 +00:00
|
|
|
shift &= 31;
|
|
|
|
if (!shift) return x;
|
|
|
|
return (x >> shift) | (x << (32 - shift));
|
|
|
|
}
|
|
|
|
|
2013-04-04 17:16:15 +00:00
|
|
|
inline u64 __rotr64(u64 x, unsigned int shift){
|
2012-11-01 15:19:01 +00:00
|
|
|
unsigned int n = shift % 64;
|
|
|
|
return (x >> n) | (x << (64 - n));
|
|
|
|
}
|
|
|
|
|
|
|
|
#else // WIN32
|
2014-09-06 08:47:25 +00:00
|
|
|
|
2012-11-01 15:19:01 +00:00
|
|
|
// Function Cross-Compatibility
|
2018-03-23 02:18:13 +00:00
|
|
|
#ifndef __MINGW32__
|
2012-11-01 15:19:01 +00:00
|
|
|
#define strcasecmp _stricmp
|
|
|
|
#define strncasecmp _strnicmp
|
2018-03-23 02:18:13 +00:00
|
|
|
#endif
|
2022-06-19 14:31:07 +00:00
|
|
|
|
|
|
|
#define unlink _unlink
|
|
|
|
#define __rotl _rotl
|
|
|
|
#define __rotl64 _rotl64
|
|
|
|
#define __rotr _rotr
|
|
|
|
#define __rotr64 _rotr64
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// 64 bit offsets for windows
|
2017-08-31 20:15:05 +00:00
|
|
|
#ifndef __MINGW32__
|
2012-11-01 15:19:01 +00:00
|
|
|
#define fseeko _fseeki64
|
|
|
|
#define ftello _ftelli64
|
|
|
|
#define atoll _atoi64
|
2017-08-31 20:15:05 +00:00
|
|
|
#endif
|
2020-05-18 22:10:39 +00:00
|
|
|
#define Crash() {__debugbreak();}
|
2012-11-01 15:19:01 +00:00
|
|
|
#endif // WIN32 ndef
|