Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 278584b

Browse files
committed
Remove volatile from latch API
This was no longer useful since the latch functions use memory barriers already, which are also compiler barriers, and volatile does not help with cross-process access. Discussion: https://www.postgresql.org/message-id/flat/20190218202511.qsfpuj5sy4dbezcw%40alap3.anarazel.de#18783c27d73e9e40009c82f6e0df0974
1 parent 754b90f commit 278584b

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/backend/storage/ipc/latch.c

+9-9
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ InitializeLatchSupport(void)
225225
* Initialize a process-local latch.
226226
*/
227227
void
228-
InitLatch(volatile Latch *latch)
228+
InitLatch(Latch *latch)
229229
{
230230
latch->is_set = false;
231231
latch->owner_pid = MyProcPid;
@@ -257,7 +257,7 @@ InitLatch(volatile Latch *latch)
257257
* process references to postmaster-private latches or WaitEventSets.
258258
*/
259259
void
260-
InitSharedLatch(volatile Latch *latch)
260+
InitSharedLatch(Latch *latch)
261261
{
262262
#ifdef WIN32
263263
SECURITY_ATTRIBUTES sa;
@@ -293,7 +293,7 @@ InitSharedLatch(volatile Latch *latch)
293293
* as shared latches use SIGUSR1 for inter-process communication.
294294
*/
295295
void
296-
OwnLatch(volatile Latch *latch)
296+
OwnLatch(Latch *latch)
297297
{
298298
/* Sanity checks */
299299
Assert(latch->is_shared);
@@ -313,7 +313,7 @@ OwnLatch(volatile Latch *latch)
313313
* Disown a shared latch currently owned by the current process.
314314
*/
315315
void
316-
DisownLatch(volatile Latch *latch)
316+
DisownLatch(Latch *latch)
317317
{
318318
Assert(latch->is_shared);
319319
Assert(latch->owner_pid == MyProcPid);
@@ -341,7 +341,7 @@ DisownLatch(volatile Latch *latch)
341341
* we return all of them in one call, but we will return at least one.
342342
*/
343343
int
344-
WaitLatch(volatile Latch *latch, int wakeEvents, long timeout,
344+
WaitLatch(Latch *latch, int wakeEvents, long timeout,
345345
uint32 wait_event_info)
346346
{
347347
return WaitLatchOrSocket(latch, wakeEvents, PGINVALID_SOCKET, timeout,
@@ -366,7 +366,7 @@ WaitLatch(volatile Latch *latch, int wakeEvents, long timeout,
366366
* WaitEventSet instead; that's more efficient.
367367
*/
368368
int
369-
WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
369+
WaitLatchOrSocket(Latch *latch, int wakeEvents, pgsocket sock,
370370
long timeout, uint32 wait_event_info)
371371
{
372372
int ret = 0;
@@ -381,7 +381,7 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
381381

382382
if (wakeEvents & WL_LATCH_SET)
383383
AddWaitEventToSet(set, WL_LATCH_SET, PGINVALID_SOCKET,
384-
(Latch *) latch, NULL);
384+
latch, NULL);
385385

386386
/* Postmaster-managed callers must handle postmaster death somehow. */
387387
Assert(!IsUnderPostmaster ||
@@ -433,7 +433,7 @@ WaitLatchOrSocket(volatile Latch *latch, int wakeEvents, pgsocket sock,
433433
* throwing an error is not a good idea.
434434
*/
435435
void
436-
SetLatch(volatile Latch *latch)
436+
SetLatch(Latch *latch)
437437
{
438438
#ifndef WIN32
439439
pid_t owner_pid;
@@ -516,7 +516,7 @@ SetLatch(volatile Latch *latch)
516516
* the latch is set again before the WaitLatch call.
517517
*/
518518
void
519-
ResetLatch(volatile Latch *latch)
519+
ResetLatch(Latch *latch)
520520
{
521521
/* Only the owner should reset the latch */
522522
Assert(latch->owner_pid == MyProcPid);

src/include/storage/latch.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ typedef struct WaitEventSet WaitEventSet;
156156
* prototypes for functions in latch.c
157157
*/
158158
extern void InitializeLatchSupport(void);
159-
extern void InitLatch(volatile Latch *latch);
160-
extern void InitSharedLatch(volatile Latch *latch);
161-
extern void OwnLatch(volatile Latch *latch);
162-
extern void DisownLatch(volatile Latch *latch);
163-
extern void SetLatch(volatile Latch *latch);
164-
extern void ResetLatch(volatile Latch *latch);
159+
extern void InitLatch(Latch *latch);
160+
extern void InitSharedLatch(Latch *latch);
161+
extern void OwnLatch(Latch *latch);
162+
extern void DisownLatch(Latch *latch);
163+
extern void SetLatch(Latch *latch);
164+
extern void ResetLatch(Latch *latch);
165165

166166
extern WaitEventSet *CreateWaitEventSet(MemoryContext context, int nevents);
167167
extern void FreeWaitEventSet(WaitEventSet *set);
@@ -172,9 +172,9 @@ extern void ModifyWaitEvent(WaitEventSet *set, int pos, uint32 events, Latch *la
172172
extern int WaitEventSetWait(WaitEventSet *set, long timeout,
173173
WaitEvent *occurred_events, int nevents,
174174
uint32 wait_event_info);
175-
extern int WaitLatch(volatile Latch *latch, int wakeEvents, long timeout,
175+
extern int WaitLatch(Latch *latch, int wakeEvents, long timeout,
176176
uint32 wait_event_info);
177-
extern int WaitLatchOrSocket(volatile Latch *latch, int wakeEvents,
177+
extern int WaitLatchOrSocket(Latch *latch, int wakeEvents,
178178
pgsocket sock, long timeout, uint32 wait_event_info);
179179

180180
/*

0 commit comments

Comments
 (0)