mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4d
wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
This commit is contained in:
@@ -82,7 +82,7 @@ pg_atomic_clear_flag_impl(volatile pg_atomic_flag *ptr)
|
||||
S_UNLOCK((slock_t *) &ptr->sema);
|
||||
}
|
||||
|
||||
#endif /* PG_HAVE_ATOMIC_FLAG_SIMULATION */
|
||||
#endif /* PG_HAVE_ATOMIC_FLAG_SIMULATION */
|
||||
|
||||
#ifdef PG_HAVE_ATOMIC_U32_SIMULATION
|
||||
void
|
||||
@@ -156,7 +156,7 @@ pg_atomic_fetch_add_u32_impl(volatile pg_atomic_uint32 *ptr, int32 add_)
|
||||
return oldval;
|
||||
}
|
||||
|
||||
#endif /* PG_HAVE_ATOMIC_U32_SIMULATION */
|
||||
#endif /* PG_HAVE_ATOMIC_U32_SIMULATION */
|
||||
|
||||
|
||||
#ifdef PG_HAVE_ATOMIC_U64_SIMULATION
|
||||
@@ -219,4 +219,4 @@ pg_atomic_fetch_add_u64_impl(volatile pg_atomic_uint64 *ptr, int64 add_)
|
||||
return oldval;
|
||||
}
|
||||
|
||||
#endif /* PG_HAVE_ATOMIC_U64_SIMULATION */
|
||||
#endif /* PG_HAVE_ATOMIC_U64_SIMULATION */
|
||||
|
@@ -16,7 +16,7 @@
|
||||
#define PORT_PROTOS_H
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
|
||||
/*
|
||||
* In some older systems, the RTLD_NOW flag isn't defined and the mode
|
||||
@@ -36,4 +36,4 @@
|
||||
#define pg_dlclose(h) dlclose(h)
|
||||
#define pg_dlerror() dlerror()
|
||||
|
||||
#endif /* PORT_PROTOS_H */
|
||||
#endif /* PORT_PROTOS_H */
|
||||
|
@@ -13,7 +13,7 @@
|
||||
#define PORT_PROTOS_H
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
|
||||
/*
|
||||
* In some older systems, the RTLD_NOW flag isn't defined and the mode
|
||||
@@ -33,4 +33,4 @@
|
||||
#define pg_dlclose dlclose
|
||||
#define pg_dlerror dlerror
|
||||
|
||||
#endif /* PORT_PROTOS_H */
|
||||
#endif /* PORT_PROTOS_H */
|
||||
|
@@ -135,4 +135,4 @@ pg_dlerror(void)
|
||||
return (char *) errorString;
|
||||
}
|
||||
|
||||
#endif /* HAVE_DLOPEN */
|
||||
#endif /* HAVE_DLOPEN */
|
||||
|
@@ -32,7 +32,7 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
@@ -89,7 +89,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
|
||||
snprintf(buf, sizeof(buf), "_%s", name);
|
||||
name = buf;
|
||||
}
|
||||
#endif /* !__ELF__ */
|
||||
#endif /* !__ELF__ */
|
||||
if ((vp = dlsym(handle, (char *) name)) == NULL)
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlsym (%s) failed", name);
|
||||
|
@@ -17,7 +17,7 @@
|
||||
#include <link.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
|
||||
/*
|
||||
* Dynamic Loader on NetBSD 1.0.
|
||||
@@ -55,4 +55,4 @@ void *BSD44_derived_dlopen(const char *filename, int num);
|
||||
void *BSD44_derived_dlsym(void *handle, const char *name);
|
||||
void BSD44_derived_dlclose(void *handle);
|
||||
|
||||
#endif /* PORT_PROTOS_H */
|
||||
#endif /* PORT_PROTOS_H */
|
||||
|
@@ -130,4 +130,4 @@ pg_dlerror(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* !HAVE_DLOPEN */
|
||||
#endif /* !HAVE_DLOPEN */
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#ifndef PORT_PROTOS_H
|
||||
#define PORT_PROTOS_H
|
||||
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
#ifdef HAVE_DLOPEN
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
@@ -39,6 +39,6 @@
|
||||
#define pg_dlsym dlsym
|
||||
#define pg_dlclose dlclose
|
||||
#define pg_dlerror dlerror
|
||||
#endif /* HAVE_DLOPEN */
|
||||
#endif /* HAVE_DLOPEN */
|
||||
|
||||
#endif /* PORT_PROTOS_H */
|
||||
#endif /* PORT_PROTOS_H */
|
||||
|
@@ -32,7 +32,7 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
@@ -89,7 +89,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
|
||||
snprintf(buf, sizeof(buf), "_%s", name);
|
||||
name = buf;
|
||||
}
|
||||
#endif /* !__ELF__ */
|
||||
#endif /* !__ELF__ */
|
||||
if ((vp = dlsym(handle, (char *) name)) == NULL)
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlsym (%s) failed", name);
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#include <link.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
|
||||
/*
|
||||
* Dynamic Loader on NetBSD 1.0.
|
||||
@@ -56,4 +56,4 @@ void *BSD44_derived_dlopen(const char *filename, int num);
|
||||
void *BSD44_derived_dlsym(void *handle, const char *name);
|
||||
void BSD44_derived_dlclose(void *handle);
|
||||
|
||||
#endif /* PORT_PROTOS_H */
|
||||
#endif /* PORT_PROTOS_H */
|
||||
|
@@ -32,7 +32,7 @@
|
||||
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
@@ -89,7 +89,7 @@ BSD44_derived_dlsym(void *handle, const char *name)
|
||||
snprintf(buf, sizeof(buf), "_%s", name);
|
||||
name = buf;
|
||||
}
|
||||
#endif /* !__ELF__ */
|
||||
#endif /* !__ELF__ */
|
||||
if ((vp = dlsym(handle, (char *) name)) == NULL)
|
||||
snprintf(error_message, sizeof(error_message),
|
||||
"dlsym (%s) failed", name);
|
||||
|
@@ -17,7 +17,7 @@
|
||||
#include <link.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
|
||||
/*
|
||||
* Dynamic Loader on NetBSD 1.0.
|
||||
@@ -55,4 +55,4 @@ void *BSD44_derived_dlopen(const char *filename, int num);
|
||||
void *BSD44_derived_dlsym(void *handle, const char *name);
|
||||
void BSD44_derived_dlclose(void *handle);
|
||||
|
||||
#endif /* PORT_PROTOS_H */
|
||||
#endif /* PORT_PROTOS_H */
|
||||
|
@@ -15,7 +15,7 @@
|
||||
#define PORT_PROTOS_H
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
|
||||
/*
|
||||
* In some older systems, the RTLD_NOW flag isn't defined and the mode
|
||||
@@ -35,4 +35,4 @@
|
||||
#define pg_dlclose dlclose
|
||||
#define pg_dlerror dlerror
|
||||
|
||||
#endif /* PORT_PROTOS_H */
|
||||
#endif /* PORT_PROTOS_H */
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#ifndef PORT_PROTOS_H
|
||||
#define PORT_PROTOS_H
|
||||
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
#include "utils/dynamic_loader.h" /* pgrminclude ignore */
|
||||
|
||||
#define pg_dlopen(f) dlopen((f), 1)
|
||||
#define pg_dlsym dlsym
|
||||
@@ -16,4 +16,4 @@ int dlclose(void *handle);
|
||||
void *dlsym(void *handle, const char *symbol);
|
||||
void *dlopen(const char *path, int mode);
|
||||
|
||||
#endif /* PORT_PROTOS_H */
|
||||
#endif /* PORT_PROTOS_H */
|
||||
|
@@ -130,7 +130,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 */
|
||||
|
||||
|
||||
/*
|
||||
|
@@ -64,10 +64,10 @@ typedef int IpcSemaphoreId; /* semaphore ID returned by semget(2) */
|
||||
static PGSemaphore sharedSemas; /* array of PGSemaphoreData in shared memory */
|
||||
static int numSharedSemas; /* number of PGSemaphoreDatas used so far */
|
||||
static int maxSharedSemas; /* allocated size of PGSemaphoreData array */
|
||||
static IpcSemaphoreId *mySemaSets; /* IDs of sema sets acquired so far */
|
||||
static IpcSemaphoreId *mySemaSets; /* IDs of sema sets acquired so far */
|
||||
static int numSemaSets; /* number of sema sets acquired so far */
|
||||
static int maxSemaSets; /* allocated size of mySemaSets array */
|
||||
static IpcSemaphoreKey nextSemaKey; /* next key to try using */
|
||||
static IpcSemaphoreKey nextSemaKey; /* next key to try using */
|
||||
static int nextSemaNumber; /* next free sem num in last sema set */
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@ PGReserveSemaphores(int maxSemas, int port)
|
||||
elog(PANIC, "out of memory");
|
||||
numSemaSets = 0;
|
||||
nextSemaKey = port * 1000;
|
||||
nextSemaNumber = SEMAS_PER_SET; /* force sema set alloc on 1st call */
|
||||
nextSemaNumber = SEMAS_PER_SET; /* force sema set alloc on 1st call */
|
||||
|
||||
on_shmem_exit(ReleaseSemaphores, 0);
|
||||
}
|
||||
|
@@ -440,10 +440,10 @@ GetHugePageSize(Size *hugepagesize, int *mmap_flags)
|
||||
FreeFile(fp);
|
||||
}
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
#endif /* __linux__ */
|
||||
}
|
||||
|
||||
#endif /* MAP_HUGETLB */
|
||||
#endif /* MAP_HUGETLB */
|
||||
|
||||
/*
|
||||
* Creates an anonymous mmap()ed shared memory segment.
|
||||
@@ -533,7 +533,7 @@ AnonymousShmemDetach(int status, Datum arg)
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* USE_ANONYMOUS_SHMEM */
|
||||
#endif /* USE_ANONYMOUS_SHMEM */
|
||||
|
||||
/*
|
||||
* PGSharedMemoryCreate
|
||||
@@ -771,7 +771,7 @@ PGSharedMemoryNoReAttach(void)
|
||||
UsedShmemSegID = 0;
|
||||
}
|
||||
|
||||
#endif /* EXEC_BACKEND */
|
||||
#endif /* EXEC_BACKEND */
|
||||
|
||||
/*
|
||||
* PGSharedMemoryDetach
|
||||
|
@@ -49,7 +49,7 @@ GetSharedMemName(void)
|
||||
elog(FATAL, "could not get size for full pathname of datadir %s: error code %lu",
|
||||
DataDir, GetLastError());
|
||||
|
||||
retptr = malloc(bufsize + 18); /* 18 for Global\PostgreSQL: */
|
||||
retptr = malloc(bufsize + 18); /* 18 for Global\PostgreSQL: */
|
||||
if (retptr == NULL)
|
||||
elog(FATAL, "could not allocate memory for shared memory name");
|
||||
|
||||
@@ -163,9 +163,9 @@ PGSharedMemoryCreate(Size size, bool makePrivate, int port,
|
||||
|
||||
hmap = CreateFileMapping(INVALID_HANDLE_VALUE, /* Use the pagefile */
|
||||
NULL, /* Default security attrs */
|
||||
PAGE_READWRITE, /* Memory is Read/Write */
|
||||
size_high, /* Size Upper 32 Bits */
|
||||
size_low, /* Size Lower 32 bits */
|
||||
PAGE_READWRITE, /* Memory is Read/Write */
|
||||
size_high, /* Size Upper 32 Bits */
|
||||
size_low, /* Size Lower 32 bits */
|
||||
szShareMem);
|
||||
|
||||
if (!hmap)
|
||||
|
Reference in New Issue
Block a user