Skip to content

Commit

Permalink
[orbis-config.hpp] Add integral zero/sign extension specailization fo…
Browse files Browse the repository at this point in the history
…r uwrite
  • Loading branch information
elad335 committed Jul 15, 2023
1 parent 2a9d98c commit 3dbf146
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rpcsx-os/orbis-kernel-config/orbis-config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <type_traits>
#include <immintrin.h>
#include <sys/ucontext.h>

Expand Down Expand Up @@ -80,6 +81,12 @@ template <typename T> [[nodiscard]] ErrorCode uwrite(ptr<T> pointer, T data) {
return uwriteRaw(pointer, &data, sizeof(T));
}

template <typename T, typename U> requires (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && sizeof(T) > sizeof(U) && !std::is_same_v<std::remove_cv_t<T>, bool>)
[[nodiscard]] ErrorCode uwrite(ptr<T> pointer, U data) {
T converted = data;
return uwriteRaw(pointer, &converted, sizeof(T));
}

template <typename T>
[[nodiscard]] ErrorCode uread(T *result, ptr<T> pointer, std::size_t count) {
return ureadRaw(&result, pointer, sizeof(T) * count);
Expand Down

0 comments on commit 3dbf146

Please sign in to comment.