mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-04-13 05:43:18 -07:00
vkd3d: Introduce a vkd3d_bound_range() helper.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
committed by
Alexandre Julliard
parent
9f0b475583
commit
bcf272aa0b
@@ -134,6 +134,17 @@ static inline void *vkd3d_memmem( const void *haystack, size_t haystack_len, con
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline bool vkd3d_bound_range(size_t start, size_t count, size_t limit)
|
||||
{
|
||||
#ifdef HAVE_BUILTIN_ADD_OVERFLOW
|
||||
size_t sum;
|
||||
|
||||
return !__builtin_add_overflow(start, count, &sum) && sum <= limit;
|
||||
#else
|
||||
return start <= limit && count <= limit - start;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int ascii_isupper(int c)
|
||||
{
|
||||
return 'A' <= c && c <= 'Z';
|
||||
|
Reference in New Issue
Block a user