1
0
Fork 0
mirror of https://github.com/Atmosphere-NX/Atmosphere.git synced 2024-11-24 04:42:11 +00:00
Atmosphere/libraries/libvapours/include/vapours/svc/svc_common.hpp

91 lines
2.6 KiB
C++
Raw Normal View History

2020-01-18 04:11:03 +00:00
/*
* Copyright (c) 2018-2020 Atmosphère-NX
2020-01-18 04:11:03 +00:00
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope 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 for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
2020-02-23 07:05:14 +00:00
#include <vapours/common.hpp>
#include <vapours/assert.hpp>
#include <vapours/results.hpp>
2020-01-18 04:11:03 +00:00
namespace ams::svc {
/* TODO: C++ style handle? */
#ifdef ATMOSPHERE_IS_STRATOSPHERE
using Handle = ::Handle;
#else
2020-02-23 14:51:32 +00:00
using Handle = u32;
2020-01-18 04:11:03 +00:00
#endif
constexpr inline size_t MaxWaitSynchronizationHandleCount = 0x40;
2020-01-31 08:07:06 +00:00
enum PseudoHandle : Handle {
CurrentThread = 0xFFFF8000,
CurrentProcess = 0xFFFF8001,
};
constexpr inline Handle InvalidHandle = Handle(0);
constexpr ALWAYS_INLINE bool operator==(const Handle &lhs, const PseudoHandle &rhs) {
return static_cast<Handle>(lhs) == static_cast<Handle>(rhs);
}
constexpr ALWAYS_INLINE bool operator==(const PseudoHandle &lhs, const Handle &rhs) {
return static_cast<Handle>(lhs) == static_cast<Handle>(rhs);
}
constexpr ALWAYS_INLINE bool operator!=(const Handle &lhs, const PseudoHandle &rhs) {
return !(lhs == rhs);
}
constexpr ALWAYS_INLINE bool operator!=(const PseudoHandle &lhs, const Handle &rhs) {
return !(lhs == rhs);
}
constexpr ALWAYS_INLINE bool IsPseudoHandle(const Handle &handle) {
return handle == PseudoHandle::CurrentProcess || handle == PseudoHandle::CurrentThread;
}
2020-03-15 06:13:40 +00:00
#if defined(ATMOSPHERE_ARCH_ARM64)
2020-01-18 04:11:03 +00:00
namespace lp64 { /* ... */ }
namespace aarch64 { /* ... */ }
using namespace ::ams::svc::lp64;
using namespace ::ams::svc::aarch64;
/* TODO: ifdef ATMOSPHERE_ABI_LP64 */
#if 1
namespace aarch64::lp64 { /* ... */ }
using namespace ::ams::svc::aarch64::lp64;
#else
namespace aarch64::ilp32 { /* ... */ }
using namespace ::ams::svc::aarch64::ilp32;
#endif
2020-03-15 06:13:40 +00:00
#elif defined(ATMOSPHERE_ARCH_ARM)
2020-01-18 04:11:03 +00:00
namespace ilp32 { /* ... */ }
namespace aarch32 { /* ... */ }
using namespace ::ams::svc::ilp32;
using namespace ::ams::svc::aarch32;
#else
#error "Unknown Architecture"
#endif
}