Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 670b3bc

Browse files
committed
Try to fix some DSA-related compiler warnings.
Commit 13df76a was overconfident about how portable %016lx is. Some compilers complain because they need %016llx, while platforms where DSA pointers are only 32 bits get unhappy about using a 64-bit format for a 32-bit quantity. Thomas Munro, per an off-list suggestion from me.
1 parent 7dd8eb3 commit 670b3bc

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/backend/utils/mmgr/dsa.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,9 +1099,10 @@ dsa_dump(dsa_area *area)
10991099

11001100
span = dsa_get_address(area, span_pointer);
11011101
fprintf(stderr,
1102-
" span descriptor at %016lx, "
1103-
"superblock at %016lx, pages = %zu, "
1104-
"objects free = %hu/%hu\n",
1102+
" span descriptor at "
1103+
DSA_POINTER_FORMAT ", superblock at "
1104+
DSA_POINTER_FORMAT
1105+
", pages = %zu, objects free = %hu/%hu\n",
11051106
span_pointer, span->start, span->npages,
11061107
span->nallocatable, span->nmax);
11071108
span_pointer = span->nextspan;

src/include/utils/dsa.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ typedef pg_atomic_uint32 dsa_pointer_atomic;
5454
#define dsa_pointer_atomic_write pg_atomic_write_u32
5555
#define dsa_pointer_atomic_fetch_add pg_atomic_fetch_add_u32
5656
#define dsa_pointer_atomic_compare_exchange pg_atomic_compare_exchange_u32
57+
#define DSA_POINTER_FORMAT "%08x"
5758
#else
5859
typedef uint64 dsa_pointer;
5960
typedef pg_atomic_uint64 dsa_pointer_atomic;
@@ -62,6 +63,7 @@ typedef pg_atomic_uint64 dsa_pointer_atomic;
6263
#define dsa_pointer_atomic_write pg_atomic_write_u64
6364
#define dsa_pointer_atomic_fetch_add pg_atomic_fetch_add_u64
6465
#define dsa_pointer_atomic_compare_exchange pg_atomic_compare_exchange_u64
66+
#define DSA_POINTER_FORMAT "%016" INT64_MODIFIER "x"
6567
#endif
6668

6769
/* A sentinel value for dsa_pointer used to indicate failure to allocate. */

0 commit comments

Comments
 (0)