From 3ae3287f266001a058c25e7da2ec3cb8a21a847d Mon Sep 17 00:00:00 2001 From: OBattler Date: Wed, 9 Aug 2023 22:17:02 +0200 Subject: [PATCH] Changed the size_t's in cpu/808x/queue.c/h into uintptr_t's and made the fatal() use PRIuPTR. --- src/cpu/808x/queue.c | 20 +++++++++----------- src/cpu/808x/queue.h | 4 ++-- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/cpu/808x/queue.c b/src/cpu/808x/queue.c index 34882e124..66fd91e32 100644 --- a/src/cpu/808x/queue.c +++ b/src/cpu/808x/queue.c @@ -42,12 +42,14 @@ /* TODO: Move to cpu.h so this can eventually be reused for 286+ as well. */ #define QUEUE_MAX 6 +/* NOTE: When porting from Rust to C, please use uintptr_t and not size_t, + so it can be printed with PRIuPTR. */ typedef struct queue_t { - size_t size; - size_t len; - size_t back; - size_t front; + uintptr_t size; + uintptr_t len; + uintptr_t back; + uintptr_t front; uint8_t q[QUEUE_MAX]; uint16_t preload; queue_delay_t delay; @@ -74,19 +76,15 @@ queue_log(const char *fmt, ...) #endif void -queue_set_size(size_t size) +queue_set_size(uintptr_t size) { if (size > QUEUE_MAX) -#if (defined __amd64__ || defined _M_X64 || defined __aarch64__ || defined _M_ARM64) - fatal("Requested prefetch queue of %zu bytes is too big\n", size); -#else - fatal("Requested prefetch queue of %i bytes is too big\n", size); -#endif + fatal("Requested prefetch queue of %" PRIuPTR " bytes is too big\n", size); queue.size = size; } -size_t +uintptr_t queue_get_len(void) { return queue.len; diff --git a/src/cpu/808x/queue.h b/src/cpu/808x/queue.h index 544455784..b8d21ec85 100644 --- a/src/cpu/808x/queue.h +++ b/src/cpu/808x/queue.h @@ -26,8 +26,8 @@ typedef enum queue_delay_t #define FLAG_PRELOADED 0x8000 -extern void queue_set_size(size_t size); -extern size_t queue_get_len(void); +extern void queue_set_size(uintptr_t size); +extern uintptr_t queue_get_len(void); extern int queue_is_full(void); extern uint16_t queue_get_preload(void); extern int queue_has_preload(void);