From 27b1a2992f7bebd9db0b0779cc7fe9b9faf5dca4 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 24 Mar 2023 18:07:02 +0900 Subject: Adjust SHAPE_BUFFER_SIZE with shape_id_t MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On platforms where `shape_id_t` is 16-bits, 0x80000 is out of range of this type. ``` ../src/shape.c: In function ‘shape_alloc’: ../src/shape.c:129:18: warning: comparison is always false due to limited range of data type [-Wtype-limits] 129 | if (shape_id == MAX_SHAPE_ID) { | ^~ ``` --- shape.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'shape.h') diff --git a/shape.h b/shape.h index 53c3cce48e..ab5f707383 100644 --- a/shape.h +++ b/shape.h @@ -3,7 +3,7 @@ #include "internal/gc.h" -#if (SIZEOF_UINT64_T == SIZEOF_VALUE) +#if (SIZEOF_UINT64_T <= SIZEOF_VALUE) #define SIZEOF_SHAPE_T 4 #define SHAPE_IN_BASIC_FLAGS 1 typedef uint32_t attr_index_t; @@ -18,9 +18,11 @@ typedef uint16_t attr_index_t; #if SIZEOF_SHAPE_T == 4 typedef uint32_t shape_id_t; # define SHAPE_ID_NUM_BITS 32 +# define SHAPE_BUFFER_SIZE 0x80000 #else typedef uint16_t shape_id_t; # define SHAPE_ID_NUM_BITS 16 +# define SHAPE_BUFFER_SIZE 0x8000 #endif # define SHAPE_MASK (((uintptr_t)1 << SHAPE_ID_NUM_BITS) - 1) @@ -28,8 +30,6 @@ typedef uint16_t shape_id_t; # define SHAPE_FLAG_SHIFT ((SIZEOF_VALUE * 8) - SHAPE_ID_NUM_BITS) -# define SHAPE_BUFFER_SIZE 0x80000 - # define SHAPE_MAX_VARIATIONS 8 # define SHAPE_MAX_NUM_IVS 80 -- cgit v1.2.1