mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Use correct preprocessor conditional in relptr.h
When relptr.h was added (commitfbc1c12a94), there was no check for HAVE_TYPEOF, so it used HAVE__BUILTIN_TYPES_COMPATIBLE_P, which already existed (commitea473fb2de) and which was thought to cover approximately the same compilers. But the guarded code can also work without HAVE__BUILTIN_TYPES_COMPATIBLE_P, and we now have a check for HAVE_TYPEOF (commit4cb824699e), so let's fix this up to use the correct logic. Co-authored-by: Thomas Munro <thomas.munro@gmail.com> Discussion: https://www.postgresql.org/message-id/CA%2BhUKGL7trhWiJ4qxpksBztMMTWDyPnP1QN%2BLq341V7QL775DA%40mail.gmail.com
This commit is contained in:
@@ -38,16 +38,12 @@
|
|||||||
#define relptr_declare(type, relptrtype) \
|
#define relptr_declare(type, relptrtype) \
|
||||||
typedef relptr(type) relptrtype
|
typedef relptr(type) relptrtype
|
||||||
|
|
||||||
#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P
|
#ifdef HAVE_TYPEOF
|
||||||
#define relptr_access(base, rp) \
|
#define relptr_access(base, rp) \
|
||||||
(AssertVariableIsOfTypeMacro(base, char *), \
|
(AssertVariableIsOfTypeMacro(base, char *), \
|
||||||
(__typeof__((rp).relptr_type)) ((rp).relptr_off == 0 ? NULL : \
|
(typeof((rp).relptr_type)) ((rp).relptr_off == 0 ? NULL : \
|
||||||
(base) + (rp).relptr_off - 1))
|
(base) + (rp).relptr_off - 1))
|
||||||
#else
|
#else
|
||||||
/*
|
|
||||||
* If we don't have __builtin_types_compatible_p, assume we might not have
|
|
||||||
* __typeof__ either.
|
|
||||||
*/
|
|
||||||
#define relptr_access(base, rp) \
|
#define relptr_access(base, rp) \
|
||||||
(AssertVariableIsOfTypeMacro(base, char *), \
|
(AssertVariableIsOfTypeMacro(base, char *), \
|
||||||
(void *) ((rp).relptr_off == 0 ? NULL : (base) + (rp).relptr_off - 1))
|
(void *) ((rp).relptr_off == 0 ? NULL : (base) + (rp).relptr_off - 1))
|
||||||
@@ -72,16 +68,12 @@ relptr_store_eval(char *base, char *val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P
|
#ifdef HAVE_TYPEOF
|
||||||
#define relptr_store(base, rp, val) \
|
#define relptr_store(base, rp, val) \
|
||||||
(AssertVariableIsOfTypeMacro(base, char *), \
|
(AssertVariableIsOfTypeMacro(base, char *), \
|
||||||
AssertVariableIsOfTypeMacro(val, __typeof__((rp).relptr_type)), \
|
AssertVariableIsOfTypeMacro(val, typeof((rp).relptr_type)), \
|
||||||
(rp).relptr_off = relptr_store_eval((base), (char *) (val)))
|
(rp).relptr_off = relptr_store_eval((base), (char *) (val)))
|
||||||
#else
|
#else
|
||||||
/*
|
|
||||||
* If we don't have __builtin_types_compatible_p, assume we might not have
|
|
||||||
* __typeof__ either.
|
|
||||||
*/
|
|
||||||
#define relptr_store(base, rp, val) \
|
#define relptr_store(base, rp, val) \
|
||||||
(AssertVariableIsOfTypeMacro(base, char *), \
|
(AssertVariableIsOfTypeMacro(base, char *), \
|
||||||
(rp).relptr_off = relptr_store_eval((base), (char *) (val)))
|
(rp).relptr_off = relptr_store_eval((base), (char *) (val)))
|
||||||
|
|||||||
Reference in New Issue
Block a user