From a118eb1c4caa1a140cd9a8c4230b91c7bfb91773 Mon Sep 17 00:00:00 2001 From: Anton Voloshin Date: Sat, 27 Aug 2022 15:56:11 +0300 Subject: [PATCH] Make else/endif comments more consistent This only changes condition comments after some preprocessor directives (mostly else and endif). 1. #else/#elif/#endif's comment, if present, should reflect the condition of the #else/#elif block as opposed to always being a copy of #if/ifdef/ifndef condition. e.g. do this: #if LLVM_VERSION_MAJOR > 11 ... #else /* LLVM_VERSION_MAJOR <= 11 */ ... #endif /* LLVM_VERSION_MAJOR <= 11 */ as opposed to #if LLVM_VERSION_MAJOR > 11 ... #else /* LLVM_VERSION_MAJOR > 11 */ ... #endif /* LLVM_VERSION_MAJOR > 11 */ 2. In #else/#elif/#endif comments, prefer A to defined(A). E.g. prefer this: #endif /* DMETAPHONE_MAIN */ over #endif /* defined DMETAPHONE_MAIN */ And this: #else /* !_MSC_VER */ over #else /* !defined(_MSC_VER) */ 3. Textual hand-crafted condition comments are perfectly fine. Like this: #else /* no ppoll(), so use select() */ 4. #else/#endif condition comment, if present, should reflect the *effective* condition, i.e. condition taking into account previous #if/#elif-s. E.g. do this: #if defined(HAVE_INT128) ... #elif defined(HAS_64_BIT_INTRINSICS) ... #else /* !HAVE_INT128 && !HAS_64_BIT_INTRINSICS */ ... #endif /* !HAVE_INT128 && !HAS_64_BIT_INTRINSICS */ 5. Comment of the form "!A && !B", if deemed complicated enough, may also be expressed as "neither A nor B" for easier reading. Example: #if (defined(HAVE_LANGINFO_H) && defined(CODESET)) || defined(WIN32) ... #else /* neither (HAVE_LANGINFO_H && CODESET) nor WIN32 */ ... #endif /* neither (HAVE_LANGINFO_H && CODESET) nor WIN32 */ 6. Use "!" as opposed to "not" to be consistent. E.g. do this: #ifdef LOCK_DEBUG ... #else /* !LOCK_DEBUG */ ... #endif /* !LOCK_DEBUG */ as opposed to: #ifdef LOCK_DEBUG ... #else /* not LOCK_DEBUG */ ... #endif /* not LOCK_DEBUG */ --- contrib/fuzzystrmatch/dmetaphone.c | 4 ++-- contrib/uuid-ossp/uuid-ossp.c | 2 +- contrib/xml2/xslt_proc.c | 2 +- src/backend/catalog/indexing.c | 2 +- src/backend/executor/execExprInterp.c | 2 +- src/backend/jit/llvm/llvmjit.c | 16 ++++++++-------- src/backend/libpq/pqcomm.c | 5 +++-- src/backend/port/posix_sema.c | 2 +- src/backend/postmaster/postmaster.c | 4 ++-- src/backend/storage/ipc/procarray.c | 2 +- src/backend/storage/lmgr/lock.c | 4 ++-- src/backend/storage/lmgr/lwlock.c | 4 ++-- src/backend/storage/lmgr/spin.c | 2 +- src/backend/utils/adt/numeric.c | 2 +- src/backend/utils/adt/pg_locale.c | 20 ++++++++++---------- src/backend/utils/adt/varlena.c | 8 ++++---- src/backend/utils/adt/xml.c | 8 ++++---- src/backend/utils/misc/guc.c | 4 ++-- src/bin/pg_basebackup/pg_basebackup.c | 2 +- src/common/d2s.c | 5 ++--- src/common/d2s_intrinsics.h | 8 ++++---- src/common/f2s.c | 4 ++-- src/common/file_perm.c | 2 +- src/common/hashfn.c | 12 ++++++------ src/common/sha2.c | 8 ++++---- src/include/c.h | 8 ++++---- src/include/common/int128.h | 2 +- src/include/port.h | 4 ++-- src/include/port/pg_bitutils.h | 4 ++-- src/include/port/pg_bswap.h | 4 ++-- src/include/postgres.h | 2 +- src/include/postmaster/syslogger.h | 2 +- src/include/storage/s_lock.h | 4 ++-- src/include/utils/elog.h | 2 +- src/interfaces/ecpg/pgtypeslib/dt_common.c | 4 ++-- src/interfaces/ecpg/pgtypeslib/timestamp.c | 4 ++-- src/interfaces/libpq/fe-auth.c | 4 ++-- src/interfaces/libpq/fe-connect.c | 6 +++--- src/interfaces/libpq/fe-misc.c | 2 +- src/interfaces/libpq/fe-secure.c | 2 +- src/port/chklocale.c | 4 ++-- src/port/pg_crc32c_sb8.c | 2 +- src/port/pg_strong_random.c | 2 +- 43 files changed, 98 insertions(+), 98 deletions(-) diff --git a/contrib/fuzzystrmatch/dmetaphone.c b/contrib/fuzzystrmatch/dmetaphone.c index 6f4d2b730e9..20140ace47d 100644 --- a/contrib/fuzzystrmatch/dmetaphone.c +++ b/contrib/fuzzystrmatch/dmetaphone.c @@ -198,7 +198,7 @@ dmetaphone_alt(PG_FUNCTION_ARGS) */ #define META_FREE(x) ((void)true) /* pfree((x)) */ -#else /* not defined DMETAPHONE_MAIN */ +#else /* DMETAPHONE_MAIN */ /* use the standard malloc library when not running in PostgreSQL */ @@ -209,7 +209,7 @@ dmetaphone_alt(PG_FUNCTION_ARGS) (v = (t*)realloc((v),((n)*sizeof(t)))) #define META_FREE(x) free((x)) -#endif /* defined DMETAPHONE_MAIN */ +#endif /* DMETAPHONE_MAIN */ diff --git a/contrib/uuid-ossp/uuid-ossp.c b/contrib/uuid-ossp/uuid-ossp.c index b868812358d..07a32d59c9e 100644 --- a/contrib/uuid-ossp/uuid-ossp.c +++ b/contrib/uuid-ossp/uuid-ossp.c @@ -401,7 +401,7 @@ uuid_generate_internal(int v, unsigned char *ns, const char *ptr, int len) return DirectFunctionCall1(uuid_in, CStringGetDatum(strbuf)); } -#endif /* HAVE_UUID_OSSP */ +#endif /* !HAVE_UUID_OSSP */ Datum diff --git a/contrib/xml2/xslt_proc.c b/contrib/xml2/xslt_proc.c index 2189bca86ff..03f8b5874ae 100644 --- a/contrib/xml2/xslt_proc.c +++ b/contrib/xml2/xslt_proc.c @@ -189,7 +189,7 @@ xslt_process(PG_FUNCTION_ARGS) (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("xslt_process() is not available without libxslt"))); PG_RETURN_NULL(); -#endif /* USE_LIBXSLT */ +#endif /* !USE_LIBXSLT */ } #ifdef USE_LIBXSLT diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c index 0b920933226..49cdead8d6b 100644 --- a/src/backend/catalog/indexing.c +++ b/src/backend/catalog/indexing.c @@ -204,7 +204,7 @@ CatalogTupleCheckConstraints(Relation heapRel, HeapTuple tup) #define CatalogTupleCheckConstraints(heapRel, tup) ((void) 0) -#endif /* USE_ASSERT_CHECKING */ +#endif /* !USE_ASSERT_CHECKING */ /* * CatalogTupleInsert - do heap and indexing work for a new catalog tuple diff --git a/src/backend/executor/execExprInterp.c b/src/backend/executor/execExprInterp.c index 636794ca6f1..e806e4432ea 100644 --- a/src/backend/executor/execExprInterp.c +++ b/src/backend/executor/execExprInterp.c @@ -132,7 +132,7 @@ static ExprEvalOpLookup reverse_dispatch_table[EEOP_LAST]; #define EEO_DISPATCH() goto starteval #define EEO_OPCODE(opcode) (opcode) -#endif /* EEO_USE_COMPUTED_GOTO */ +#endif /* !EEO_USE_COMPUTED_GOTO */ #define EEO_NEXT() \ do { \ diff --git a/src/backend/jit/llvm/llvmjit.c b/src/backend/jit/llvm/llvmjit.c index 6c72d43beb6..d331d9afad4 100644 --- a/src/backend/jit/llvm/llvmjit.c +++ b/src/backend/jit/llvm/llvmjit.c @@ -101,10 +101,10 @@ static LLVMTargetRef llvm_targetref; static LLVMOrcThreadSafeContextRef llvm_ts_context; static LLVMOrcLLJITRef llvm_opt0_orc; static LLVMOrcLLJITRef llvm_opt3_orc; -#else /* LLVM_VERSION_MAJOR > 11 */ +#else /* LLVM_VERSION_MAJOR <= 11 */ static LLVMOrcJITStackRef llvm_opt0_orc; static LLVMOrcJITStackRef llvm_opt3_orc; -#endif /* LLVM_VERSION_MAJOR > 11 */ +#endif /* LLVM_VERSION_MAJOR <= 11 */ static void llvm_release_context(JitContext *context); @@ -211,11 +211,11 @@ llvm_release_context(JitContext *context) sp = LLVMOrcExecutionSessionGetSymbolStringPool(ee); LLVMOrcSymbolStringPoolClearDeadEntries(sp); } -#else /* LLVM_VERSION_MAJOR > 11 */ +#else /* LLVM_VERSION_MAJOR <= 11 */ { LLVMOrcRemoveModule(jit_handle->stack, jit_handle->orc_handle); } -#endif /* LLVM_VERSION_MAJOR > 11 */ +#endif /* LLVM_VERSION_MAJOR <= 11 */ pfree(jit_handle); } @@ -849,7 +849,7 @@ llvm_session_initialize(void) llvm_opt3_orc = llvm_create_jit_instance(opt3_tm); opt3_tm = 0; } -#else /* LLVM_VERSION_MAJOR > 11 */ +#else /* LLVM_VERSION_MAJOR <= 11 */ { llvm_opt0_orc = LLVMOrcCreateInstance(opt0_tm); llvm_opt3_orc = LLVMOrcCreateInstance(opt3_tm); @@ -873,7 +873,7 @@ llvm_session_initialize(void) } #endif } -#endif /* LLVM_VERSION_MAJOR > 11 */ +#endif /* LLVM_VERSION_MAJOR <= 11 */ on_proc_exit(llvm_shutdown, 0); @@ -917,7 +917,7 @@ llvm_shutdown(int code, Datum arg) llvm_ts_context = NULL; } } -#else /* LLVM_VERSION_MAJOR > 11 */ +#else /* LLVM_VERSION_MAJOR <= 11 */ { /* unregister profiling support, needs to be flushed to be useful */ @@ -941,7 +941,7 @@ llvm_shutdown(int code, Datum arg) llvm_opt0_orc = NULL; } } -#endif /* LLVM_VERSION_MAJOR > 11 */ +#endif /* LLVM_VERSION_MAJOR <= 11 */ } /* helper for llvm_create_types, returning a function's return type */ diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index cba0caced73..65276234838 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -1668,7 +1668,8 @@ pq_setkeepalivesidle(int idle, Port *port) #else /* WIN32 */ return pq_setkeepaliveswin32(port, idle, port->keepalives_interval); #endif -#else +#else /* neither PG_TCP_KEEPALIVE_IDLE + * nor SIO_KEEPALIVE_VALS */ if (idle != 0) { ereport(LOG, @@ -1752,7 +1753,7 @@ pq_setkeepalivesinterval(int interval, Port *port) #else /* WIN32 */ return pq_setkeepaliveswin32(port, port->keepalives_idle, interval); #endif -#else +#else /* neither TCP_KEEPINTVL nor SIO_KEEPALIVE_VALS */ if (interval != 0) { ereport(LOG, diff --git a/src/backend/port/posix_sema.c b/src/backend/port/posix_sema.c index a97a3ed99ee..24f60755c6e 100644 --- a/src/backend/port/posix_sema.c +++ b/src/backend/port/posix_sema.c @@ -137,7 +137,7 @@ PosixSemaphoreCreate(sem_t *sem) if (sem_init(sem, 1, 1) < 0) elog(FATAL, "sem_init failed: %m"); } -#endif /* USE_NAMED_POSIX_SEMAPHORES */ +#endif /* !USE_NAMED_POSIX_SEMAPHORES */ /* diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 1664fcee2a7..2c5f6bbd3f8 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -4213,7 +4213,7 @@ BackendStartup(Port *port) /* And run the backend */ BackendRun(port); } -#endif /* EXEC_BACKEND */ +#endif /* !EXEC_BACKEND */ if (pid < 0) { @@ -5411,7 +5411,7 @@ StartChildProcess(AuxProcType type) AuxiliaryProcessMain(type); /* does not return */ } -#endif /* EXEC_BACKEND */ +#endif /* !EXEC_BACKEND */ if (pid < 0) { diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index 0555b02a8d9..04728435f38 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -332,7 +332,7 @@ static void DisplayXidCache(void); #define xc_by_known_assigned_inc() ((void) 0) #define xc_no_overflow_inc() ((void) 0) #define xc_slow_answer_inc() ((void) 0) -#endif /* XIDCACHE_DEBUG */ +#endif /* !XIDCACHE_DEBUG */ /* Primitives for KnownAssignedXids array handling for standby */ static void KnownAssignedXidsCompress(bool force); diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 5f5803f6814..8342a6d18e1 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -360,11 +360,11 @@ PROCLOCK_PRINT(const char *where, const PROCLOCK *proclockP) PROCLOCK_LOCKMETHOD(*(proclockP)), proclockP->tag.myProc, (int) proclockP->holdMask); } -#else /* not LOCK_DEBUG */ +#else /* !LOCK_DEBUG */ #define LOCK_PRINT(where, lock, type) ((void) 0) #define PROCLOCK_PRINT(where, proclockP) ((void) 0) -#endif /* not LOCK_DEBUG */ +#endif /* !LOCK_DEBUG */ static uint32 proclock_hash(const void *key, Size keysize); diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 38317edaf96..c8d73da00e5 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -311,10 +311,10 @@ LOG_LWDEBUG(const char *where, LWLock *lock, const char *msg) } } -#else /* not LOCK_DEBUG */ +#else /* !LOCK_DEBUG */ #define PRINT_LWDEBUG(a,b,c) ((void)0) #define LOG_LWDEBUG(a,b,c) ((void)0) -#endif /* LOCK_DEBUG */ +#endif /* !LOCK_DEBUG */ #ifdef LWLOCK_STATS diff --git a/src/backend/storage/lmgr/spin.c b/src/backend/storage/lmgr/spin.c index 2a3ee1084b3..33bace7f03b 100644 --- a/src/backend/storage/lmgr/spin.c +++ b/src/backend/storage/lmgr/spin.c @@ -45,7 +45,7 @@ PGSemaphore *SpinlockSemaArray; #define NUM_EMULATION_SEMAPHORES 0 -#endif /* HAVE_SPINLOCKS */ +#endif /* !HAVE_SPINLOCKS */ /* * Report the amount of shared memory needed to store semaphores for spinlock diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 920a63b0081..bb3d3538363 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -9801,7 +9801,7 @@ sqrt_var(const NumericVar *arg, NumericVar *result, int rscale) int64_to_numericvar(s_int64, &s_var); if (step >= 0) int64_to_numericvar(r_int64, &r_var); -#endif /* HAVE_INT128 */ +#endif /* !HAVE_INT128 */ /* * The remaining iterations with src_ndigits > 8 (or 16, if have int128) diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 1a047a97d74..3c71c7f9123 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -1120,7 +1120,7 @@ IsoLocaleName(const char *winlocname) return get_iso_localename(winlocname); } -#else /* !defined(_MSC_VER) */ +#else /* !_MSC_VER */ static char * IsoLocaleName(const char *winlocname) @@ -1128,7 +1128,7 @@ IsoLocaleName(const char *winlocname) return NULL; /* Not supported on MinGW */ } -#endif /* defined(_MSC_VER) */ +#endif /* !_MSC_VER */ #endif /* WIN32 && LC_MESSAGES */ @@ -1420,12 +1420,12 @@ make_icu_collator(const char *iculocstr, /* We will leak this string if the caller errors later :-( */ resultp->info.icu.locale = MemoryContextStrdup(TopMemoryContext, iculocstr); resultp->info.icu.ucol = collator; -#else /* not USE_ICU */ +#else /* !USE_ICU */ /* could get here if a collation was created by a build with ICU */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("ICU is not supported in this build"))); -#endif /* not USE_ICU */ +#endif /* !USE_ICU */ } @@ -1569,12 +1569,12 @@ pg_newlocale_from_collation(Oid collid) } result.info.lt = loc; -#else /* not HAVE_LOCALE_T */ +#else /* !HAVE_LOCALE_T */ /* platform that doesn't support locale_t */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("collation provider LIBC is not supported on this platform"))); -#endif /* not HAVE_LOCALE_T */ +#endif /* !HAVE_LOCALE_T */ } else if (collform->collprovider == COLLPROVIDER_ICU) { @@ -2036,12 +2036,12 @@ wchar2char(char *to, const wchar_t *from, size_t tolen, pg_locale_t locale) result = wcstombs(to, from, tolen); uselocale(save_locale); -#endif /* HAVE_WCSTOMBS_L */ +#endif /* !HAVE_WCSTOMBS_L */ #else /* !HAVE_LOCALE_T */ /* Can't have locale != 0 without HAVE_LOCALE_T */ elog(ERROR, "wcstombs_l is not available"); result = 0; /* keep compiler quiet */ -#endif /* HAVE_LOCALE_T */ +#endif /* !HAVE_LOCALE_T */ } return result; @@ -2113,12 +2113,12 @@ char2wchar(wchar_t *to, size_t tolen, const char *from, size_t fromlen, result = mbstowcs(to, str, tolen); uselocale(save_locale); -#endif /* HAVE_MBSTOWCS_L */ +#endif /* !HAVE_MBSTOWCS_L */ #else /* !HAVE_LOCALE_T */ /* Can't have locale != 0 without HAVE_LOCALE_T */ elog(ERROR, "mbstowcs_l is not available"); result = 0; /* keep compiler quiet */ -#endif /* HAVE_LOCALE_T */ +#endif /* !HAVE_LOCALE_T */ } pfree(str); diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 8539cef0246..5315c073e43 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -1692,10 +1692,10 @@ varstr_cmp(const char *arg1, int len1, const char *arg2, int len2, Oid collid) pfree(uchar1); pfree(uchar2); } -#else /* not USE_ICU */ +#else /* !USE_ICU */ /* shouldn't happen */ elog(ERROR, "unsupported collprovider: %c", mylocale->provider); -#endif /* not USE_ICU */ +#endif /* !USE_ICU */ } else { @@ -2413,10 +2413,10 @@ varstrfastcmp_locale(char *a1p, int len1, char *a2p, int len2, SortSupport ssup) pfree(uchar1); pfree(uchar2); } -#else /* not USE_ICU */ +#else /* !USE_ICU */ /* shouldn't happen */ elog(ERROR, "unsupported collprovider: %c", sss->locale->provider); -#endif /* not USE_ICU */ +#endif /* !USE_ICU */ } else { diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index 60a85c46971..937bec61a88 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -922,10 +922,10 @@ xml_is_document(xmltype *arg) xmlFreeDoc(doc); return result; -#else /* not USE_LIBXML */ +#else /* !USE_LIBXML */ NO_XML_SUPPORT(); return false; -#endif /* not USE_LIBXML */ +#endif /* !USE_LIBXML */ } @@ -2077,10 +2077,10 @@ map_sql_identifier_to_xml_name(const char *ident, bool fully_escaped, } return buf.data; -#else /* not USE_LIBXML */ +#else /* !USE_LIBXML */ NO_XML_SUPPORT(); return NULL; -#endif /* not USE_LIBXML */ +#endif /* !USE_LIBXML */ } diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 9fbbfb1be54..608cadf18b3 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -3635,9 +3635,9 @@ static struct config_int ConfigureNamesInt[] = 0, #endif 0, 5, -#else /* not DISCARD_CACHES_ENABLED */ +#else /* !DISCARD_CACHES_ENABLED */ 0, 0, 0, -#endif /* not DISCARD_CACHES_ENABLED */ +#endif /* !DISCARD_CACHES_ENABLED */ NULL, NULL, NULL }, diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c index 9ce30d43a41..e135ed4497b 100644 --- a/src/bin/pg_basebackup/pg_basebackup.c +++ b/src/bin/pg_basebackup/pg_basebackup.c @@ -2180,7 +2180,7 @@ BaseBackup(char *compression_algorithm, char *compression_detail, pg_fatal("child thread exited with error %u", (unsigned int) status); /* Exited normally, we're happy */ -#endif +#endif /* WIN32 */ } /* Free the configuration file contents */ diff --git a/src/common/d2s.c b/src/common/d2s.c index e711ea6f85a..52d7fd63e15 100644 --- a/src/common/d2s.c +++ b/src/common/d2s.c @@ -213,8 +213,7 @@ mulShiftAll(const uint64 m, const uint64 *const mul, const int32 j, return mulShift(4 * m, mul, j); } -#else /* // !defined(HAVE_INT128) && - * !defined(HAS_64_BIT_INTRINSICS) */ +#else /* !HAVE_INT128 && !HAS_64_BIT_INTRINSICS */ static inline uint64 mulShiftAll(uint64 m, const uint64 *const mul, const int32 j, @@ -258,7 +257,7 @@ mulShiftAll(uint64 m, const uint64 *const mul, const int32 j, return shiftright128(mid, hi, j - 64 - 1); } -#endif /* // HAS_64_BIT_INTRINSICS */ +#endif /* !HAVE_INT128 && !HAS_64_BIT_INTRINSICS */ static inline uint32 decimalLength(const uint64 v) diff --git a/src/common/d2s_intrinsics.h b/src/common/d2s_intrinsics.h index a338d0e2e11..e8393ee7677 100644 --- a/src/common/d2s_intrinsics.h +++ b/src/common/d2s_intrinsics.h @@ -59,7 +59,7 @@ shiftright128(const uint64 lo, const uint64 hi, const uint32 dist) return __shiftright128(lo, hi, (unsigned char) dist); } -#else /* defined(HAS_64_BIT_INTRINSICS) */ +#else /* !HAS_64_BIT_INTRINSICS */ static inline uint64 umul128(const uint64 a, const uint64 b, uint64 *const productHi) @@ -111,7 +111,7 @@ shiftright128(const uint64 lo, const uint64 hi, const uint32 dist) #endif } -#endif /* // defined(HAS_64_BIT_INTRINSICS) */ +#endif /* !HAS_64_BIT_INTRINSICS */ #ifdef RYU_32_BIT_PLATFORM @@ -171,7 +171,7 @@ div1e8(const uint64 x) return umulh(x, UINT64CONST(0xABCC77118461CEFD)) >> 26; } -#else /* RYU_32_BIT_PLATFORM */ +#else /* !RYU_32_BIT_PLATFORM */ static inline uint64 div5(const uint64 x) @@ -197,6 +197,6 @@ div1e8(const uint64 x) return x / 100000000; } -#endif /* RYU_32_BIT_PLATFORM */ +#endif /* !RYU_32_BIT_PLATFORM */ #endif /* RYU_D2S_INTRINSICS_H */ diff --git a/src/common/f2s.c b/src/common/f2s.c index 39366b65c70..b81c409cdb4 100644 --- a/src/common/f2s.c +++ b/src/common/f2s.c @@ -147,7 +147,7 @@ mulShift(const uint32 m, const uint64 factor, const int32 shift) return (bits1Hi << (32 - s)) | (bits1Lo >> s); -#else /* RYU_32_BIT_PLATFORM */ +#else /* !RYU_32_BIT_PLATFORM */ const uint64 sum = (bits0 >> 32) + bits1; const uint64 shiftedSum = sum >> (shift - 32); @@ -155,7 +155,7 @@ mulShift(const uint32 m, const uint64 factor, const int32 shift) Assert(shiftedSum <= PG_UINT32_MAX); return (uint32) shiftedSum; -#endif /* RYU_32_BIT_PLATFORM */ +#endif /* !RYU_32_BIT_PLATFORM */ } static inline uint32 diff --git a/src/common/file_perm.c b/src/common/file_perm.c index 9597f9d4015..ae612692f42 100644 --- a/src/common/file_perm.c +++ b/src/common/file_perm.c @@ -78,7 +78,7 @@ GetDataDirectoryCreatePerm(const char *dataDir) /* Set permissions */ SetDataDirectoryCreatePerm(statBuf.st_mode); return true; -#else /* !defined(WIN32) && !defined(__CYGWIN__) */ +#else /* WIN32 || __CYGWIN__ */ /* * On Windows, we don't have anything to do here since they don't have * Unix-y permissions. diff --git a/src/common/hashfn.c b/src/common/hashfn.c index 8779575b991..04b02bbbb7a 100644 --- a/src/common/hashfn.c +++ b/src/common/hashfn.c @@ -251,7 +251,7 @@ hash_bytes(const unsigned char *k, int keylen) a += k[0]; /* case 0: nothing left to add */ } -#endif /* WORDS_BIGENDIAN */ +#endif /* !WORDS_BIGENDIAN */ } else { @@ -268,7 +268,7 @@ hash_bytes(const unsigned char *k, int keylen) a += (k[0] + ((uint32) k[1] << 8) + ((uint32) k[2] << 16) + ((uint32) k[3] << 24)); b += (k[4] + ((uint32) k[5] << 8) + ((uint32) k[6] << 16) + ((uint32) k[7] << 24)); c += (k[8] + ((uint32) k[9] << 8) + ((uint32) k[10] << 16) + ((uint32) k[11] << 24)); -#endif /* WORDS_BIGENDIAN */ +#endif /* !WORDS_BIGENDIAN */ mix(a, b, c); k += 12; len -= 12; @@ -351,7 +351,7 @@ hash_bytes(const unsigned char *k, int keylen) a += k[0]; /* case 0: nothing left to add */ } -#endif /* WORDS_BIGENDIAN */ +#endif /* !WORDS_BIGENDIAN */ } final(a, b, c); @@ -490,7 +490,7 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) a += k[0]; /* case 0: nothing left to add */ } -#endif /* WORDS_BIGENDIAN */ +#endif /* !WORDS_BIGENDIAN */ } else { @@ -507,7 +507,7 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) a += (k[0] + ((uint32) k[1] << 8) + ((uint32) k[2] << 16) + ((uint32) k[3] << 24)); b += (k[4] + ((uint32) k[5] << 8) + ((uint32) k[6] << 16) + ((uint32) k[7] << 24)); c += (k[8] + ((uint32) k[9] << 8) + ((uint32) k[10] << 16) + ((uint32) k[11] << 24)); -#endif /* WORDS_BIGENDIAN */ +#endif /* !WORDS_BIGENDIAN */ mix(a, b, c); k += 12; len -= 12; @@ -590,7 +590,7 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) a += k[0]; /* case 0: nothing left to add */ } -#endif /* WORDS_BIGENDIAN */ +#endif /* !WORDS_BIGENDIAN */ } final(a, b, c); diff --git a/src/common/sha2.c b/src/common/sha2.c index f1dcd330457..6e99375b41b 100644 --- a/src/common/sha2.c +++ b/src/common/sha2.c @@ -380,7 +380,7 @@ SHA256_Transform(pg_sha256_ctx *context, const uint8 *data) /* Clean up */ a = b = c = d = e = f = g = h = T1 = 0; } -#else /* SHA2_UNROLL_TRANSFORM */ +#else /* !SHA2_UNROLL_TRANSFORM */ static void SHA256_Transform(pg_sha256_ctx *context, const uint8 *data) @@ -470,7 +470,7 @@ SHA256_Transform(pg_sha256_ctx *context, const uint8 *data) /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; } -#endif /* SHA2_UNROLL_TRANSFORM */ +#endif /* !SHA2_UNROLL_TRANSFORM */ void pg_sha256_update(pg_sha256_ctx *context, const uint8 *data, size_t len) @@ -706,7 +706,7 @@ SHA512_Transform(pg_sha512_ctx *context, const uint8 *data) /* Clean up */ a = b = c = d = e = f = g = h = T1 = 0; } -#else /* SHA2_UNROLL_TRANSFORM */ +#else /* !SHA2_UNROLL_TRANSFORM */ static void SHA512_Transform(pg_sha512_ctx *context, const uint8 *data) @@ -796,7 +796,7 @@ SHA512_Transform(pg_sha512_ctx *context, const uint8 *data) /* Clean up */ a = b = c = d = e = f = g = h = T1 = T2 = 0; } -#endif /* SHA2_UNROLL_TRANSFORM */ +#endif /* !SHA2_UNROLL_TRANSFORM */ void pg_sha512_update(pg_sha512_ctx *context, const uint8 *data, size_t len) diff --git a/src/include/c.h b/src/include/c.h index 101ba41331e..9f591c0e958 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -900,7 +900,7 @@ extern void ExceptionalCondition(const char *conditionName, StaticAssertStmt(condition, errmessage) #define StaticAssertDecl(condition, errmessage) \ extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) -#endif /* HAVE__STATIC_ASSERT */ +#endif /* !HAVE__STATIC_ASSERT */ #else /* C++ */ #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410 #define StaticAssertStmt(condition, errmessage) \ @@ -916,7 +916,7 @@ extern void ExceptionalCondition(const char *conditionName, ((void) ({ StaticAssertStmt(condition, errmessage); })) #define StaticAssertDecl(condition, errmessage) \ extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) -#endif /* __cpp_static_assert */ +#endif /* !__cpp_static_assert */ #endif /* C++ */ @@ -945,7 +945,7 @@ extern void ExceptionalCondition(const char *conditionName, #define AssertVariableIsOfTypeMacro(varname, typename) \ (StaticAssertExpr(sizeof(varname) == sizeof(typename), \ CppAsString(varname) " does not have type " CppAsString(typename))) -#endif /* HAVE__BUILTIN_TYPES_COMPATIBLE_P */ +#endif /* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */ /* ---------------------------------------------------------------- @@ -1324,7 +1324,7 @@ typedef intptr_t sigjmp_buf[5]; #define sigjmp_buf jmp_buf #define sigsetjmp(x,y) setjmp(x) #define siglongjmp longjmp -#endif /* __MINGW64__ */ +#endif /* !__MINGW64__ */ #endif /* WIN32 */ /* /port compatibility functions */ diff --git a/src/include/common/int128.h b/src/include/common/int128.h index 8f035cf4cb2..140ba45dc98 100644 --- a/src/include/common/int128.h +++ b/src/include/common/int128.h @@ -271,6 +271,6 @@ int128_to_int64(INT128 val) return (int64) val.lo; } -#endif /* USE_NATIVE_INT128 */ +#endif /* !USE_NATIVE_INT128 */ #endif /* INT128_H */ diff --git a/src/include/port.h b/src/include/port.h index cec41eae713..a349f6aed76 100644 --- a/src/include/port.h +++ b/src/include/port.h @@ -327,14 +327,14 @@ extern FILE *pgwin32_popen(const char *command, const char *type); #define popen(a,b) pgwin32_popen(a,b) #define pclose(a) _pclose(a) -#else /* !WIN32 */ +#else /* !WIN32 || __CYGWIN__ */ /* * Win32 requires a special close for sockets and pipes, while on Unix * close() does them all. */ #define closesocket close -#endif /* WIN32 */ +#endif /* !WIN32 || __CYGWIN__ */ /* * On Windows, setvbuf() does not support _IOLBF mode, and interprets that diff --git a/src/include/port/pg_bitutils.h b/src/include/port/pg_bitutils.h index 814e0b2dba0..0e821bb8ca0 100644 --- a/src/include/port/pg_bitutils.h +++ b/src/include/port/pg_bitutils.h @@ -67,7 +67,7 @@ pg_leftmost_one_pos64(uint64 word) shift -= 8; return shift + pg_leftmost_one_pos[(word >> shift) & 255]; -#endif /* HAVE__BUILTIN_CLZ */ +#endif /* !HAVE__BUILTIN_CLZ */ } /* @@ -126,7 +126,7 @@ pg_rightmost_one_pos64(uint64 word) } result += pg_rightmost_one_pos[word & 255]; return result; -#endif /* HAVE__BUILTIN_CTZ */ +#endif /* !HAVE__BUILTIN_CTZ */ } /* diff --git a/src/include/port/pg_bswap.h b/src/include/port/pg_bswap.h index 4033d2bf399..70dff5ba807 100644 --- a/src/include/port/pg_bswap.h +++ b/src/include/port/pg_bswap.h @@ -154,8 +154,8 @@ pg_bswap64(uint64 x) #define DatumBigEndianToNative(x) pg_bswap64(x) #else /* SIZEOF_DATUM != 8 */ #define DatumBigEndianToNative(x) pg_bswap32(x) -#endif /* SIZEOF_DATUM == 8 */ -#endif /* WORDS_BIGENDIAN */ +#endif /* SIZEOF_DATUM != 8 */ +#endif /* !WORDS_BIGENDIAN */ #endif /* SIZEOF_DATUM */ #endif /* PG_BSWAP_H */ diff --git a/src/include/postgres.h b/src/include/postgres.h index 13903fa022a..0d21ba0f7a5 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -277,7 +277,7 @@ typedef struct (((varattrib_1b_e *) (PTR))->va_header = 0x01, \ ((varattrib_1b_e *) (PTR))->va_tag = (tag)) -#endif /* WORDS_BIGENDIAN */ +#endif /* !WORDS_BIGENDIAN */ #define VARDATA_4B(PTR) (((varattrib_4b *) (PTR))->va_4byte.va_data) #define VARDATA_4B_C(PTR) (((varattrib_4b *) (PTR))->va_compressed.va_data) diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h index 6436724f3db..b89d74d7761 100644 --- a/src/include/postmaster/syslogger.h +++ b/src/include/postmaster/syslogger.h @@ -36,7 +36,7 @@ #else #define PIPE_CHUNK_SIZE ((int) PIPE_BUF) #endif -#else /* not defined */ +#else /* !PIPE_BUF */ /* POSIX says the value of PIPE_BUF must be at least 512, so use that */ #define PIPE_CHUNK_SIZE 512 #endif diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h index 65aa66c5984..76fb08aa372 100644 --- a/src/include/storage/s_lock.h +++ b/src/include/storage/s_lock.h @@ -710,7 +710,7 @@ spin_delay(void) #define S_UNLOCK(lock) \ do { _ReadWriteBarrier(); (*(lock)) = 0; } while (0) -#endif +#endif /* _MSC_VER */ #endif /* !defined(HAS_TEST_AND_SET) */ @@ -743,7 +743,7 @@ extern int tas_sema(volatile slock_t *lock); #define TAS(lock) tas_sema(lock) -#endif /* HAVE_SPINLOCKS */ +#endif /* !HAVE_SPINLOCKS */ /* diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index 56398176901..0e41e62e39b 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -154,7 +154,7 @@ if (elevel_ >= ERROR) \ pg_unreachable(); \ } while(0) -#endif /* HAVE__BUILTIN_CONSTANT_P */ +#endif /* !HAVE__BUILTIN_CONSTANT_P */ #define ereport(elevel, ...) \ ereport_domain(elevel, TEXTDOMAIN, __VA_ARGS__) diff --git a/src/interfaces/ecpg/pgtypeslib/dt_common.c b/src/interfaces/ecpg/pgtypeslib/dt_common.c index e0fae3d5f1d..f8c90f040b0 100644 --- a/src/interfaces/ecpg/pgtypeslib/dt_common.c +++ b/src/interfaces/ecpg/pgtypeslib/dt_common.c @@ -1040,8 +1040,8 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn) } else tm->tm_isdst = -1; -#else /* not (HAVE_STRUCT_TM_TM_ZONE || - * HAVE_INT_TIMEZONE) */ +#else /* neither HAVE_STRUCT_TM_TM_ZONE + * nor HAVE_INT_TIMEZONE */ if (tzp != NULL) { /* default to UTC */ diff --git a/src/interfaces/ecpg/pgtypeslib/timestamp.c b/src/interfaces/ecpg/pgtypeslib/timestamp.c index 54cc04addd2..61f68b21b06 100644 --- a/src/interfaces/ecpg/pgtypeslib/timestamp.c +++ b/src/interfaces/ecpg/pgtypeslib/timestamp.c @@ -158,8 +158,8 @@ timestamp2tm(timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, const char **t if (tzn != NULL) *tzn = TZNAME_GLOBAL[(tm->tm_isdst > 0)]; #endif -#else /* not (HAVE_STRUCT_TM_TM_ZONE || - * HAVE_INT_TIMEZONE) */ +#else /* neither HAVE_STRUCT_TM_TM_ZONE + * nor HAVE_INT_TIMEZONE */ *tzp = 0; /* Mark this as *no* time zone available */ tm->tm_isdst = -1; diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 49a1c626f64..29490160ac6 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -971,14 +971,14 @@ pg_fe_sendauth(AuthRequest areq, int payloadlen, PGconn *conn) pgunlock_thread(); } break; -#else /* defined(ENABLE_GSS) || defined(ENABLE_SSPI) */ +#else /* !ENABLE_GSS || !ENABLE_SSPI */ /* No GSSAPI *or* SSPI support */ case AUTH_REQ_GSS: case AUTH_REQ_GSS_CONT: appendPQExpBufferStr(&conn->errorMessage, libpq_gettext("GSSAPI authentication not supported\n")); return STATUS_ERROR; -#endif /* defined(ENABLE_GSS) || defined(ENABLE_SSPI) */ +#endif /* !ENABLE_GSS || !ENABLE_SSPI */ #ifdef ENABLE_SSPI case AUTH_REQ_SSPI: diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 917b19e0e9d..417ad2ae50d 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -3111,7 +3111,7 @@ keep_going: /* We will come back to here until there is #else /* !USE_SSL */ /* can't get here */ goto error_return; -#endif /* USE_SSL */ +#endif /* !USE_SSL */ } case CONNECTION_GSS_STARTUP: @@ -3215,7 +3215,7 @@ keep_going: /* We will come back to here until there is #else /* !ENABLE_GSS */ /* unreachable */ goto error_return; -#endif /* ENABLE_GSS */ +#endif /* !ENABLE_GSS */ } /* @@ -4930,7 +4930,7 @@ ldapServiceLookup(const char *purl, PQconninfoOption *options, ldap_unbind(ld); return 3; } -#endif /* WIN32 */ +#endif /* !WIN32 */ /* search */ res = NULL; diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index 795500c5935..d2c0b693005 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -1161,7 +1161,7 @@ pqSocketPoll(int sock, int forRead, int forWrite, time_t end_time) return select(sock + 1, &input_mask, &output_mask, &except_mask, ptr_timeout); -#endif /* HAVE_POLL */ +#endif /* !HAVE_POLL */ } diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index 3df4a97f2e9..d7c011499ac 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -107,7 +107,7 @@ struct sigpipe_info if (!SIGPIPE_MASKED(conn)) \ pqsignal(SIGPIPE, spinfo); \ } while (0) -#endif /* ENABLE_THREAD_SAFETY */ +#endif /* !ENABLE_THREAD_SAFETY */ #else /* WIN32 */ #define DECLARE_SIGPIPE_INFO(spinfo) diff --git a/src/port/chklocale.c b/src/port/chklocale.c index 2aaf2ae8c04..d1b6df7baa1 100644 --- a/src/port/chklocale.c +++ b/src/port/chklocale.c @@ -415,7 +415,7 @@ pg_get_encoding_from_locale(const char *ctype, bool write_message) free(sys); return -1; } -#else /* (HAVE_LANGINFO_H && CODESET) || WIN32 */ +#else /* neither (HAVE_LANGINFO_H && CODESET) nor WIN32 */ /* * stub if no multi-language platform support @@ -430,4 +430,4 @@ pg_get_encoding_from_locale(const char *ctype, bool write_message) return PG_SQL_ASCII; } -#endif /* (HAVE_LANGINFO_H && CODESET) || WIN32 */ +#endif /* neither (HAVE_LANGINFO_H && CODESET) nor WIN32 */ diff --git a/src/port/pg_crc32c_sb8.c b/src/port/pg_crc32c_sb8.c index b3f579fcd6f..67ea7010c56 100644 --- a/src/port/pg_crc32c_sb8.c +++ b/src/port/pg_crc32c_sb8.c @@ -636,7 +636,7 @@ static const uint32 pg_crc32c_table[8][256] = { 0xE54C35A1, 0xAC704886, 0x7734CFEF, 0x3E08B2C8, 0xC451B7CC, 0x8D6DCAEB, 0x56294D82, 0x1F1530A5 } -#else /* !WORDS_BIGENDIAN */ +#else /* WORDS_BIGENDIAN */ { 0x00000000, 0x03836BF2, 0xF7703BE1, 0xF4F35013, 0x1F979AC7, 0x1C14F135, 0xE8E7A126, 0xEB64CAD4, diff --git a/src/port/pg_strong_random.c b/src/port/pg_strong_random.c index be589c9d0bd..3bb79cc69c9 100644 --- a/src/port/pg_strong_random.c +++ b/src/port/pg_strong_random.c @@ -137,7 +137,7 @@ pg_strong_random(void *buf, size_t len) return false; } -#else /* not USE_OPENSSL or WIN32 */ +#else /* neither USE_OPENSSL nor WIN32 */ /* * Without OpenSSL or Win32 support, just read /dev/urandom ourselves. -- 2.37.2