diff options
author | Robert Haas <rhaas@postgresql.org> | 2016-12-05 10:38:08 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2016-12-05 10:38:08 -0500 |
commit | 88f626f8680fbe93444582317d1adb375111855f (patch) | |
tree | 8323bee3b24406c42f94b98e9b03c538e766a32c /src/include/utils/dsa.h | |
parent | 670b3bc8f5d1000b5475e41c6f023c490e8500fe (diff) |
Fix more DSA problems uncovered by the buildfarm.
On 32-bit systems, don't try to use 64-bit DSA pointers, because the
computation of DSA_MAX_SEGMENT_SIZE overflows Size.
Cast 1 to Size before shifting it, so that the compiler doesn't
produce a result of the wrong width.
In passing, change one use of size_t to Size.
Diffstat (limited to 'src/include/utils/dsa.h')
-rw-r--r-- | src/include/utils/dsa.h | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/include/utils/dsa.h b/src/include/utils/dsa.h index a6d674df577..0e2778c95d7 100644 --- a/src/include/utils/dsa.h +++ b/src/include/utils/dsa.h @@ -24,20 +24,25 @@ struct dsa_area; typedef struct dsa_area dsa_area; /* - * If this system doesn't support atomic operations on 64 bit values then - * we fall back to 32 bit dsa_pointer. For testing purposes, - * USE_SMALL_DSA_POINTER can be defined to force the use of 32 bit - * dsa_pointer even on systems that support 64 bit atomics. + * If this system only uses a 32-bit value for Size, then use the 32-bit + * implementation of DSA. This limits the amount of DSA that can be created + * to something significantly less than the entire 4GB address space because + * the DSA pointer must encode both a segment identifier and an offset, but + * that shouldn't be a significant limitation in practice. + * + * If this system doesn't support atomic operations on 64-bit values, then + * we fall back to 32-bit dsa_pointer for lack of other options. + * + * For testing purposes, USE_SMALL_DSA_POINTER can be defined to force the use + * of 32-bit dsa_pointer even on systems capable of supporting a 64-bit + * dsa_pointer. */ -#ifndef PG_HAVE_ATOMIC_U64_SUPPORT -#define SIZEOF_DSA_POINTER 4 -#else -#ifdef USE_SMALL_DSA_POINTER +#if SIZEOF_SIZE_T == 4 || !defined(PG_HAVE_ATOMIC_U64_SUPPORT) || \ + defined(USE_SMALL_DSA_POINTER) #define SIZEOF_DSA_POINTER 4 #else #define SIZEOF_DSA_POINTER 8 #endif -#endif /* * The type of 'relative pointers' to memory allocated by a dynamic shared |