hwint: Introduce HOST_SIZE_T_PRINT_*
commit2bb4556220285e92e599635c61029f25e9ca5e28
authorJakub Jelinek <jakub@redhat.com>
Fri, 9 Feb 2024 10:51:08 +0000 (9 11:51 +0100)
committerJakub Jelinek <jakub@redhat.com>
Fri, 9 Feb 2024 10:59:17 +0000 (9 11:59 +0100)
tree6608ce378ac4c7833c3e5f0c27a45c297ecfa9d7
parent0a329ecf1137366b2ec4bf7c2b977e817fdcf0fc
hwint: Introduce HOST_SIZE_T_PRINT_*

build_conflict_bit_table uses %ld format string for
(long) some_int_expression * sizeof (something)
argument, that doesn't work on LLP64 hosts because the
expression has then size_t aka unsigned long long type there.
It can be fixed with
(long) (some_int_expression * sizeof (something))
but it means the value is truncated if it doesn't fit into long.
Ideally we'd use %zd or %zu modifiers here, but it is unclear if we
can rely on it on all hosts, it has been introduced in C99 and C++11
includes C99 by reference, but in reality whether this works or not
depends on the host C library and some of them are helplessly obsolete.

This patch instead introduces new macros HOST_SIZE_T_PRINT_* which
one can use in *printf family function format strings and cast to
fmt_size_t type.

2024-02-09  Jakub Jelinek  <jakub@redhat.com>

* hwint.h (GCC_PRISZ, fmt_size_t, HOST_SIZE_T_PRINT_DEC,
HOST_SIZE_T_PRINT_UNSIGNED, HOST_SIZE_T_PRINT_HEX,
HOST_SIZE_T_PRINT_HEX_PURE): Define.
* ira-conflicts.cc (build_conflict_bit_table): Use it.  Formatting
fixes.
gcc/hwint.h
gcc/ira-conflicts.cc