At Tue, 31 May 2022 15:57:14 -0400, Robert Haas <robertmh...@gmail.com> wrote in > 1. Using a relative pointer value other than 0 to represent a null > pointer. Andres suggested (Size) -1.
I thought that relptr as a part of DSM so the use of offset=0 is somewhat illegal. But I like this. We can fix this by this modification. I think ((Size) -1) is natural to signal something special. (I see glibc uses "(size_t) -1".) > 2. Not storing the free page manager for the DSM in the main shared > memory segment at byte offset 0. > 3. Dropping the assertion while loudly singing "la la la la la la". reagards. -- Kyotaro Horiguchi NTT Open Source Software Center
diff --git a/src/include/utils/relptr.h b/src/include/utils/relptr.h index cc80a7200d..c6d39a1360 100644 --- a/src/include/utils/relptr.h +++ b/src/include/utils/relptr.h @@ -41,7 +41,7 @@ #ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P #define relptr_access(base, rp) \ (AssertVariableIsOfTypeMacro(base, char *), \ - (__typeof__((rp).relptr_type)) ((rp).relptr_off == 0 ? NULL : \ + (__typeof__((rp).relptr_type)) ((rp).relptr_off == ((Size) -1) ? NULL : \ (base + (rp).relptr_off))) #else /* @@ -50,21 +50,21 @@ */ #define relptr_access(base, rp) \ (AssertVariableIsOfTypeMacro(base, char *), \ - (void *) ((rp).relptr_off == 0 ? NULL : (base + (rp).relptr_off))) + (void *) ((rp).relptr_off == ((Size) -1) ? NULL : (base + (rp).relptr_off))) #endif #define relptr_is_null(rp) \ - ((rp).relptr_off == 0) + ((rp).relptr_off == ((Size) -1)) /* We use this inline to avoid double eval of "val" in relptr_store */ static inline Size relptr_store_eval(char *base, char *val) { if (val == NULL) - return 0; + return ((Size) -1); else { - Assert(val > base); + Assert(val >= base); return val - base; } }