]> granicus.if.org Git - postgresql/commitdiff
Try to fix some DSA-related compiler warnings.
authorRobert Haas <rhaas@postgresql.org>
Mon, 5 Dec 2016 15:00:49 +0000 (10:00 -0500)
committerRobert Haas <rhaas@postgresql.org>
Mon, 5 Dec 2016 15:01:08 +0000 (10:01 -0500)
Commit 13df76a537cca3b8884911d8fdf7c89a457a8dd3 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.

src/backend/utils/mmgr/dsa.c
src/include/utils/dsa.h

index 9095da0f7713ab3933bd0e7aa71ab1309b796289..0e49e7020df16fd6724be7e14cf1a00e2a6f189c 100644 (file)
@@ -1099,9 +1099,10 @@ dsa_dump(dsa_area *area)
 
                                                span = dsa_get_address(area, span_pointer);
                                                fprintf(stderr,
-                                                               "        span descriptor at %016lx, "
-                                                               "superblock at %016lx, pages = %zu, "
-                                                               "objects free = %hu/%hu\n",
+                                                               "        span descriptor at "
+                                                               DSA_POINTER_FORMAT ", superblock at "
+                                                               DSA_POINTER_FORMAT
+                                                               ", pages = %zu, objects free = %hu/%hu\n",
                                                                span_pointer, span->start, span->npages,
                                                                span->nallocatable, span->nmax);
                                                span_pointer = span->nextspan;
index b05ab2c7f45529107e6c14c696ac8d7e69bec86e..a6d674df577be5cac332fed629c111f44326dab8 100644 (file)
@@ -54,6 +54,7 @@ typedef pg_atomic_uint32 dsa_pointer_atomic;
 #define dsa_pointer_atomic_write pg_atomic_write_u32
 #define dsa_pointer_atomic_fetch_add pg_atomic_fetch_add_u32
 #define dsa_pointer_atomic_compare_exchange pg_atomic_compare_exchange_u32
+#define DSA_POINTER_FORMAT "%08x"
 #else
 typedef uint64 dsa_pointer;
 typedef pg_atomic_uint64 dsa_pointer_atomic;
@@ -62,6 +63,7 @@ typedef pg_atomic_uint64 dsa_pointer_atomic;
 #define dsa_pointer_atomic_write pg_atomic_write_u64
 #define dsa_pointer_atomic_fetch_add pg_atomic_fetch_add_u64
 #define dsa_pointer_atomic_compare_exchange pg_atomic_compare_exchange_u64
+#define DSA_POINTER_FORMAT "%016" INT64_MODIFIER "x"
 #endif
 
 /* A sentinel value for dsa_pointer used to indicate failure to allocate. */