Silly macro removed

This commit is contained in:
Nekotekina 2016-08-12 19:24:29 +03:00
parent f0459e3891
commit 7a2802a5e0
12 changed files with 35 additions and 40 deletions

View File

@ -17,9 +17,6 @@
// Return 32 bit custom offsetof() // Return 32 bit custom offsetof()
#define OFFSET_32(type, x) static_cast<std::uint32_t>(reinterpret_cast<std::uintptr_t>(&reinterpret_cast<const volatile char&>(reinterpret_cast<type*>(0ull)->x))) #define OFFSET_32(type, x) static_cast<std::uint32_t>(reinterpret_cast<std::uintptr_t>(&reinterpret_cast<const volatile char&>(reinterpret_cast<type*>(0ull)->x)))
// Sometimes to avoid writing std::remove_cv_t<>, example: std::is_same<CV T1, CV T2>
#define CV const volatile
#define CONCATENATE_DETAIL(x, y) x ## y #define CONCATENATE_DETAIL(x, y) x ## y
#define CONCATENATE(x, y) CONCATENATE_DETAIL(x, y) #define CONCATENATE(x, y) CONCATENATE_DETAIL(x, y)
@ -31,8 +28,6 @@
#define COPY_EXPR(expr, ...) [=](__VA_ARGS__) { return expr; } #define COPY_EXPR(expr, ...) [=](__VA_ARGS__) { return expr; }
#define PURE_EXPR(expr, ...) [] (__VA_ARGS__) { return expr; } #define PURE_EXPR(expr, ...) [] (__VA_ARGS__) { return expr; }
#define return_ return
#define HERE "\n(in file " __FILE__ ":" STRINGIZE(__LINE__) ")" #define HERE "\n(in file " __FILE__ ":" STRINGIZE(__LINE__) ")"
// Ensure that the expression is evaluated to true. Always evaluated and allowed to have side effects (unlike assert() macro). // Ensure that the expression is evaluated to true. Always evaluated and allowed to have side effects (unlike assert() macro).

View File

@ -47,7 +47,7 @@ namespace ppu_cb_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct _func_arg<T, ARG_VECTOR, g_count, f_count, v_count> struct _func_arg<T, ARG_VECTOR, g_count, f_count, v_count>
{ {
static_assert(std::is_same<CV T, CV v128>::value, "Invalid callback argument type for ARG_VECTOR"); static_assert(std::is_same<std::decay_t<T>, v128>::value, "Invalid callback argument type for ARG_VECTOR");
static inline void set_value(ppu_thread& CPU, const T& arg) static inline void set_value(ppu_thread& CPU, const T& arg)
{ {
@ -71,7 +71,7 @@ namespace ppu_cb_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct _func_arg<T, ARG_CONTEXT, g_count, f_count, v_count> struct _func_arg<T, ARG_CONTEXT, g_count, f_count, v_count>
{ {
static_assert(std::is_same<T, ppu_thread&>::value, "Invalid callback argument type for ARG_CONTEXT"); static_assert(std::is_same<std::decay_t<T>, ppu_thread>::value, "Invalid callback argument type for ARG_CONTEXT");
FORCE_INLINE static void set_value(ppu_thread& CPU, const T& arg) FORCE_INLINE static void set_value(ppu_thread& CPU, const T& arg)
{ {
@ -89,8 +89,8 @@ namespace ppu_cb_detail
FORCE_INLINE static bool _bind_func_args(ppu_thread& CPU, T1 arg1, T... args) FORCE_INLINE static bool _bind_func_args(ppu_thread& CPU, T1 arg1, T... args)
{ {
const bool is_float = std::is_floating_point<T1>::value; const bool is_float = std::is_floating_point<T1>::value;
const bool is_vector = std::is_same<CV T1, CV v128>::value; const bool is_vector = std::is_same<std::decay_t<T1>, v128>::value;
const bool is_context = std::is_same<T1, ppu_thread&>::value; const bool is_context = std::is_same<std::decay_t<T1>, ppu_thread>::value;
const bool is_general = !is_float && !is_vector && !is_context; const bool is_general = !is_float && !is_vector && !is_context;
const _func_arg_type t = const _func_arg_type t =
@ -136,7 +136,7 @@ namespace ppu_cb_detail
template<typename T> template<typename T>
struct _func_res<T, ARG_VECTOR> struct _func_res<T, ARG_VECTOR>
{ {
static_assert(std::is_same<CV T, CV v128>::value, "Invalid callback result type for ARG_VECTOR"); static_assert(std::is_same<std::decay_t<T>, v128>::value, "Invalid callback result type for ARG_VECTOR");
FORCE_INLINE static T get_value(const ppu_thread& CPU) FORCE_INLINE static T get_value(const ppu_thread& CPU)
{ {
@ -154,7 +154,7 @@ namespace ppu_cb_detail
static_assert(!std::is_pointer<RT>::value, "Invalid callback result type (pointer)"); static_assert(!std::is_pointer<RT>::value, "Invalid callback result type (pointer)");
static_assert(!std::is_reference<RT>::value, "Invalid callback result type (reference)"); static_assert(!std::is_reference<RT>::value, "Invalid callback result type (reference)");
const bool is_float = std::is_floating_point<RT>::value; const bool is_float = std::is_floating_point<RT>::value;
const bool is_vector = std::is_same<std::remove_cv_t<RT>, v128>::value; const bool is_vector = std::is_same<std::decay_t<RT>, v128>::value;
const _func_arg_type t = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); const _func_arg_type t = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL);
return _func_res<RT, t>::get_value(CPU); return _func_res<RT, t>::get_value(CPU);

View File

@ -64,7 +64,7 @@ namespace ppu_func_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct bind_arg<T, ARG_VECTOR, g_count, f_count, v_count> struct bind_arg<T, ARG_VECTOR, g_count, f_count, v_count>
{ {
static_assert(std::is_same<CV T, CV v128>::value, "Invalid function argument type for ARG_VECTOR"); static_assert(std::is_same<std::decay_t<T>, v128>::value, "Invalid function argument type for ARG_VECTOR");
static FORCE_INLINE T get_arg(ppu_thread& ppu) static FORCE_INLINE T get_arg(ppu_thread& ppu)
{ {
@ -86,7 +86,7 @@ namespace ppu_func_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct bind_arg<T, ARG_CONTEXT, g_count, f_count, v_count> struct bind_arg<T, ARG_CONTEXT, g_count, f_count, v_count>
{ {
static_assert(std::is_same<T, ppu_thread&>::value, "Invalid function argument type for ARG_CONTEXT"); static_assert(std::is_same<std::decay_t<T>, ppu_thread>::value, "Invalid function argument type for ARG_CONTEXT");
static FORCE_INLINE ppu_thread& get_arg(ppu_thread& ppu) static FORCE_INLINE ppu_thread& get_arg(ppu_thread& ppu)
{ {
@ -97,7 +97,7 @@ namespace ppu_func_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct bind_arg<T, ARG_VARIADIC, g_count, f_count, v_count> struct bind_arg<T, ARG_VARIADIC, g_count, f_count, v_count>
{ {
static_assert(std::is_same<T, ppu_va_args_t>::value, "Invalid function argument type for ARG_VARIADIC"); static_assert(std::is_same<std::decay_t<T>, ppu_va_args_t>::value, "Invalid function argument type for ARG_VARIADIC");
static FORCE_INLINE ppu_va_args_t get_arg(ppu_thread& ppu) static FORCE_INLINE ppu_va_args_t get_arg(ppu_thread& ppu)
{ {
@ -131,7 +131,7 @@ namespace ppu_func_detail
template<typename T> template<typename T>
struct bind_result<T, ARG_VECTOR> struct bind_result<T, ARG_VECTOR>
{ {
static_assert(std::is_same<CV T, CV v128>::value, "Invalid function result type for ARG_VECTOR"); static_assert(std::is_same<std::decay_t<T>, v128>::value, "Invalid function result type for ARG_VECTOR");
static FORCE_INLINE void put_result(ppu_thread& ppu, const T& result) static FORCE_INLINE void put_result(ppu_thread& ppu, const T& result)
{ {
@ -183,9 +183,9 @@ namespace ppu_func_detail
// TODO: check calculations // TODO: check calculations
const bool is_float = std::is_floating_point<T>::value; const bool is_float = std::is_floating_point<T>::value;
const bool is_vector = std::is_same<CV T, CV v128>::value; const bool is_vector = std::is_same<std::decay_t<T>, v128>::value;
const bool is_context = std::is_same<T, ppu_thread&>::value; const bool is_context = std::is_same<std::decay_t<T>, ppu_thread>::value;
const bool is_variadic = std::is_same<CV T, CV ppu_va_args_t>::value; const bool is_variadic = std::is_same<std::decay_t<T>, ppu_va_args_t>::value;
const bool is_general = !is_float && !is_vector && !is_context && !is_variadic; const bool is_general = !is_float && !is_vector && !is_context && !is_variadic;
const arg_class t = const arg_class t =
@ -209,7 +209,7 @@ namespace ppu_func_detail
static_assert(!std::is_pointer<RT>::value, "Invalid function result type (pointer)"); static_assert(!std::is_pointer<RT>::value, "Invalid function result type (pointer)");
static_assert(!std::is_reference<RT>::value, "Invalid function result type (reference)"); static_assert(!std::is_reference<RT>::value, "Invalid function result type (reference)");
static const bool is_float = std::is_floating_point<RT>::value; static const bool is_float = std::is_floating_point<RT>::value;
static const bool is_vector = std::is_same<CV RT, CV v128>::value; static const bool is_vector = std::is_same<std::decay_t<RT>, v128>::value;
static const arg_class value = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); static const arg_class value = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL);
}; };

View File

@ -90,7 +90,7 @@ public:
template<typename T, T* Var> template<typename T, T* Var>
static void register_static_variable(const char* module, const char* name, u32 vnid, void(*init)()) static void register_static_variable(const char* module, const char* name, u32 vnid, void(*init)())
{ {
static_assert(std::is_same<CV u32, CV typename T::addr_type>::value, "Static variable registration: vm::gvar<T> expected"); static_assert(std::is_same<u32, std::decay_t<typename T::addr_type>>::value, "Static variable registration: vm::gvar<T> expected");
auto& info = access_static_variable(module, vnid); auto& info = access_static_variable(module, vnid);

View File

@ -166,7 +166,7 @@ template<typename T>
struct ppu_gpr_cast_impl<T, std::enable_if_t<std::is_integral<T>::value || std::is_enum<T>::value>> struct ppu_gpr_cast_impl<T, std::enable_if_t<std::is_integral<T>::value || std::is_enum<T>::value>>
{ {
static_assert(sizeof(T) <= 8, "Too big integral type for ppu_gpr_cast<>()"); static_assert(sizeof(T) <= 8, "Too big integral type for ppu_gpr_cast<>()");
static_assert(std::is_same<CV T, CV bool>::value == false, "bool type is deprecated in ppu_gpr_cast<>(), use b8 instead"); static_assert(std::is_same<std::decay_t<T>, bool>::value == false, "bool type is deprecated in ppu_gpr_cast<>(), use b8 instead");
static inline u64 to(const T& value) static inline u64 to(const T& value)
{ {

View File

@ -94,10 +94,10 @@ ppu_error_code sys_memory_allocate_from_container(u32 size, u32 cid, u64 flags,
if (!ct.take(size)) if (!ct.take(size))
{ {
result = CELL_ENOMEM; result = CELL_ENOMEM;
return_ false; return false;
} }
return_ true; return true;
}); });
if (!ct && !result) if (!ct && !result)
@ -214,10 +214,10 @@ ppu_error_code sys_memory_container_destroy(u32 cid)
if (!ct.used.compare_and_swap_test(0, ct.size)) if (!ct.used.compare_and_swap_test(0, ct.size))
{ {
result = CELL_EBUSY; result = CELL_EBUSY;
return_ false; return false;
} }
return_ true; return true;
}); });
if (!ct && !result) if (!ct && !result)

View File

@ -149,10 +149,10 @@ ppu_error_code sys_mmapper_allocate_shared_memory_from_container(u64 unk, u32 si
if (!ct.take(size)) if (!ct.take(size))
{ {
result = CELL_ENOMEM; result = CELL_ENOMEM;
return_ false; return false;
} }
return_ true; return true;
}); });
if (!ct && !result) if (!ct && !result)
@ -210,10 +210,10 @@ ppu_error_code sys_mmapper_free_shared_memory(u32 mem_id)
if (mem.addr.compare_and_swap_test(0, -1)) if (mem.addr.compare_and_swap_test(0, -1))
{ {
result = CELL_EBUSY; result = CELL_EBUSY;
return_ false; return false;
} }
return_ true; return true;
}); });
if (!mem && !result) if (!mem && !result)

View File

@ -100,7 +100,7 @@ namespace id_manager
template<typename T> template<typename T>
static inline void update() static inline void update()
{ {
access()[get_index<T>()].on_stop = [](void* ptr) { return_ id_manager::on_stop<T>::func(static_cast<T*>(ptr)); }; access()[get_index<T>()].on_stop = [](void* ptr) { return id_manager::on_stop<T>::func(static_cast<T*>(ptr)); };
} }
// Read all registered types // Read all registered types

View File

@ -170,7 +170,7 @@ namespace vm
// Pointer difference operator // Pointer difference operator
template<typename T2, typename AT2> template<typename T2, typename AT2>
std::enable_if_t<std::is_object<T2>::value && std::is_same<CV T, CV T2>::value, s32> operator -(const _ptr_base<T2, AT2>& right) const std::enable_if_t<std::is_object<T2>::value && std::is_same<std::decay_t<T>, std::decay_t<T2>>::value, s32> operator -(const _ptr_base<T2, AT2>& right) const
{ {
return static_cast<s32>(vm::cast(m_addr, HERE) - vm::cast(right.m_addr, HERE)) / SIZE_32(T); return static_cast<s32>(vm::cast(m_addr, HERE) - vm::cast(right.m_addr, HERE)) / SIZE_32(T);
} }

View File

@ -102,7 +102,7 @@ namespace arm_func_detail
struct bind_arg<T, ARG_VECTOR, g_count, f_count, v_count> struct bind_arg<T, ARG_VECTOR, g_count, f_count, v_count>
{ {
static_assert(v_count <= 0, "TODO: Unsupported argument type (vector)"); static_assert(v_count <= 0, "TODO: Unsupported argument type (vector)");
static_assert(std::is_same<CV T, CV v128>::value, "Invalid function argument type for ARG_VECTOR"); static_assert(std::is_same<std::decay_t<T>, v128>::value, "Invalid function argument type for ARG_VECTOR");
FORCE_INLINE static T get_arg(ARMv7Thread& cpu) FORCE_INLINE static T get_arg(ARMv7Thread& cpu)
{ {
@ -177,7 +177,7 @@ namespace arm_func_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct bind_arg<T, ARG_CONTEXT, g_count, f_count, v_count> struct bind_arg<T, ARG_CONTEXT, g_count, f_count, v_count>
{ {
static_assert(std::is_same<T, ARMv7Thread&>::value, "Invalid function argument type for ARG_CONTEXT"); static_assert(std::is_same<std::decay_t<T>, ARMv7Thread>::value, "Invalid function argument type for ARG_CONTEXT");
FORCE_INLINE static ARMv7Thread& get_arg(ARMv7Thread& cpu) FORCE_INLINE static ARMv7Thread& get_arg(ARMv7Thread& cpu)
{ {
@ -192,7 +192,7 @@ namespace arm_func_detail
template<typename T, u32 g_count, u32 f_count, u32 v_count> template<typename T, u32 g_count, u32 f_count, u32 v_count>
struct bind_arg<T, ARG_VARIADIC, g_count, f_count, v_count> struct bind_arg<T, ARG_VARIADIC, g_count, f_count, v_count>
{ {
static_assert(std::is_same<CV T, CV arm_va_args_t>::value, "Invalid function argument type for ARG_VARIADIC"); static_assert(std::is_same<std::decay_t<T>, arm_va_args_t>::value, "Invalid function argument type for ARG_VARIADIC");
FORCE_INLINE static arm_va_args_t get_arg(ARMv7Thread& cpu) FORCE_INLINE static arm_va_args_t get_arg(ARMv7Thread& cpu)
{ {
@ -273,7 +273,7 @@ namespace arm_func_detail
static_assert(!std::is_pointer<RT>::value, "Invalid function result type (pointer)"); static_assert(!std::is_pointer<RT>::value, "Invalid function result type (pointer)");
static_assert(!std::is_reference<RT>::value, "Invalid function result type (reference)"); static_assert(!std::is_reference<RT>::value, "Invalid function result type (reference)");
static const bool is_float = std::is_floating_point<RT>::value; static const bool is_float = std::is_floating_point<RT>::value;
static const bool is_vector = std::is_same<CV RT, CV v128>::value; static const bool is_vector = std::is_same<std::decay_t<RT>, v128>::value;
static const arg_class value = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL); static const arg_class value = is_float ? ARG_FLOAT : (is_vector ? ARG_VECTOR : ARG_GENERAL);
}; };
@ -282,9 +282,9 @@ namespace arm_func_detail
{ {
// TODO: check calculations // TODO: check calculations
static const bool is_float = std::is_floating_point<T>::value; static const bool is_float = std::is_floating_point<T>::value;
static const bool is_vector = std::is_same<CV T, CV v128>::value; static const bool is_vector = std::is_same<std::decay_t<T>, v128>::value;
static const bool is_context = std::is_same<T, ARMv7Thread&>::value; static const bool is_context = std::is_same<std::decay_t<T>, ARMv7Thread>::value;
static const bool is_variadic = std::is_same<CV T, CV arm_va_args_t>::value; static const bool is_variadic = std::is_same<std::decay_t<T>, arm_va_args_t>::value;
static const bool is_general = !is_float && !is_vector && !is_context && !is_variadic; static const bool is_general = !is_float && !is_vector && !is_context && !is_variadic;
static const u32 g_align = ALIGN_32(T) > 4 ? ALIGN_32(T) >> 2 : 1; static const u32 g_align = ALIGN_32(T) > 4 ? ALIGN_32(T) >> 2 : 1;

View File

@ -211,7 +211,7 @@ template<typename T>
struct arm_gpr_cast_impl<T, std::enable_if_t<std::is_integral<T>::value || std::is_enum<T>::value>> struct arm_gpr_cast_impl<T, std::enable_if_t<std::is_integral<T>::value || std::is_enum<T>::value>>
{ {
static_assert(sizeof(T) <= 4, "Too big integral type for arm_gpr_cast<>()"); static_assert(sizeof(T) <= 4, "Too big integral type for arm_gpr_cast<>()");
static_assert(std::is_same<CV T, CV bool>::value == false, "bool type is deprecated in arm_gpr_cast<>(), use b8 instead"); static_assert(std::is_same<std::decay_t<T>, bool>::value == false, "bool type is deprecated in arm_gpr_cast<>(), use b8 instead");
static inline u32 to(const T& value) static inline u32 to(const T& value)
{ {

View File

@ -279,7 +279,7 @@ void MainFrame::InstallPkg(wxCommandEvent& WXUNUSED(event))
if (pkg_install(pkg_f, local_path + '/', progress)) if (pkg_install(pkg_f, local_path + '/', progress))
{ {
progress = 1.; progress = 1.;
return_; return;
} }
// TODO: Ask user to delete files on cancellation/failure? // TODO: Ask user to delete files on cancellation/failure?