define short-hand types for int32/uint32 et cetera

This commit is contained in:
2025-06-20 19:54:34 +02:00
parent ad66d9465a
commit 80b8b65b73
10 changed files with 103 additions and 82 deletions

View File

@@ -1,6 +1,6 @@
#pragma once
#include <stdint.h>
#include "../types.h"
#if defined(__GNUC__) || defined(__clang__)
#define bswap16 __builtin_bswap16
@@ -19,18 +19,18 @@
#endif
#if defined(IMPL_BSWAP) || !defined(NDEBUG)
static inline uint16_t bswap16_impl(uint16_t x) {
static inline u16 bswap16_impl(u16 x) {
return (x << 8) | (x >> 8);
}
static inline uint32_t bswap32_impl(uint32_t x) {
static inline u32 bswap32_impl(u32 x) {
return (x << 24) |
((0x0000FF00U & x) << 8) |
((0x00FF0000U & x) >> 8) |
(x >> 24);
}
static inline uint64_t bswap64_impl(uint64_t x) {
static inline u64 bswap64_impl(u64 x) {
return (x << 56) |
((0x000000000000FF00ULL & x) << 40) |
((0x0000000000FF0000ULL & x) << 24) |