CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Common/CommonFuncs.h
Views: 1401
// Copyright (C) 2003 Dolphin Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official SVN repository and contact information can be found at15// http://code.google.com/p/dolphin-emu/1617#pragma once1819#include "ppsspp_config.h"2021#include "CommonTypes.h"2223#ifndef ARRAY_SIZE24#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))25#endif2627#if !defined(_WIN32)2829#include <unistd.h>30#include <errno.h>3132#if (PPSSPP_ARCH(X86) || PPSSPP_ARCH(AMD64)) && !defined(__EMSCRIPTEN__)33#define Crash() {asm ("int $3");}34#elif PPSSPP_PLATFORM(SWITCH)35// TODO: Implement Crash() for Switch, lets not use breakpoint for the time being36#define Crash() {*((volatile u32 *)0x0) = 0xDEADC0DE;}37#elif PPSSPP_ARCH(ARM)38#define Crash() {asm ("bkpt #0");}39#elif PPSSPP_ARCH(ARM64)40#define Crash() {asm ("brk #0");}41#elif PPSSPP_ARCH(RISCV64)42#define Crash() {asm ("ebreak");}43#else44#include <signal.h>45#define Crash() {kill(getpid(), SIGINT);}46#endif4748inline u32 __rotl(u32 x, int shift) {49shift &= 31;50if (!shift) return x;51return (x << shift) | (x >> (32 - shift));52}5354inline u64 __rotl64(u64 x, unsigned int shift){55unsigned int n = shift % 64;56return (x << n) | (x >> (64 - n));57}5859inline u32 __rotr(u32 x, int shift) {60shift &= 31;61if (!shift) return x;62return (x >> shift) | (x << (32 - shift));63}6465inline u64 __rotr64(u64 x, unsigned int shift){66unsigned int n = shift % 64;67return (x >> n) | (x << (64 - n));68}6970#else // WIN327172// Function Cross-Compatibility73#ifndef __MINGW32__74#define strcasecmp _stricmp75#define strncasecmp _strnicmp76#endif7778#define unlink _unlink79#define __rotl _rotl80#define __rotl64 _rotl6481#define __rotr _rotr82#define __rotr64 _rotr648384// 64 bit offsets for windows85#ifndef __MINGW32__86#define fseeko _fseeki6487#define ftello _ftelli6488#define atoll _atoi6489#endif90#define Crash() {__debugbreak();}91#endif // WIN32 ndef929394