diff options
| author | Vaxry <vaxry@vaxry.net> | 2024-09-30 17:25:39 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2024-09-30 17:25:57 +0100 |
| commit | 3ddb16bd5bb7146d125a7d68e4e9f3b54c381a20 (patch) | |
| tree | ae8fac53a2e6f7886f5599d5175f45793d18491f /src/helpers/ByteOperations.hpp | |
| parent | f6387536f62454f82039b42f641cd8c44153ad47 (diff) | |
compositor/wayland: up the max buffer size to avoid disconnects when app hangs
Diffstat (limited to 'src/helpers/ByteOperations.hpp')
| -rw-r--r-- | src/helpers/ByteOperations.hpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/helpers/ByteOperations.hpp b/src/helpers/ByteOperations.hpp new file mode 100644 index 00000000..6d9507ff --- /dev/null +++ b/src/helpers/ByteOperations.hpp @@ -0,0 +1,52 @@ +#pragma once + +#define ULL unsigned long long +#define LD long double + +constexpr ULL operator""_kB(const ULL BYTES) { + return BYTES * 1024; +} +constexpr ULL operator""_MB(const ULL BYTES) { + return BYTES * 1024 * 1024; +} +constexpr ULL operator""_GB(const ULL BYTES) { + return BYTES * 1024 * 1024 * 1024; +} +constexpr ULL operator""_TB(const ULL BYTES) { + return BYTES * 1024 * 1024 * 1024 * 1024; +} +constexpr LD operator""_kB(const LD BYTES) { + return BYTES * 1024; +} +constexpr LD operator""_MB(const LD BYTES) { + return BYTES * 1024 * 1024; +} +constexpr LD operator""_GB(const LD BYTES) { + return BYTES * 1024 * 1024 * 1024; +} +constexpr LD operator""_TB(const LD BYTES) { + return BYTES * 1024 * 1024 * 1024 * 1024; +} + +template <typename T> +using __acceptable_byte_operation_type = typename std::enable_if<std::is_trivially_constructible<T, ULL>::value || std::is_trivially_constructible<T, LD>::value>::type; + +template <typename X, typename = __acceptable_byte_operation_type<X>> +constexpr X kBtoBytes(const X kB) { + return kB * 1024; +} +template <typename X, typename = __acceptable_byte_operation_type<X>> +constexpr X MBtoBytes(const X MB) { + return MB * 1024 * 1024; +} +template <typename X, typename = __acceptable_byte_operation_type<X>> +constexpr X GBtoBytes(const X GB) { + return GB * 1024 * 1024 * 1024; +} +template <typename X, typename = __acceptable_byte_operation_type<X>> +constexpr X TBtoBytes(const X TB) { + return TB * 1024 * 1024 * 1024 * 1024; +} + +#undef ULL +#undef LD
\ No newline at end of file |
