aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2014-09-09 17:45:20 -0400
committerRobert Haas <rhaas@postgresql.org>2014-09-09 17:48:50 -0400
commit0709b7ee72e4bc71ad07b7120acd117265ab51d0 (patch)
tree0dc14e41bd0653c8433828cd213ecc74e5165671 /src/backend/storage
parente80252d424278abf65b624669c8e6b3fe8587cac (diff)
downloadpostgresql-0709b7ee72e4bc71ad07b7120acd117265ab51d0.tar.gz
postgresql-0709b7ee72e4bc71ad07b7120acd117265ab51d0.zip
Change the spinlock primitives to function as compiler barriers.
Previously, they functioned as barriers against CPU reordering but not compiler reordering, an odd API that required extensive use of volatile everywhere that spinlocks are used. That's error-prone and has negative implications for performance, so change it. In theory, this makes it safe to remove many of the uses of volatile that we currently have in our code base, but we may find that there are some bugs in this effort when we do. In the long run, though, this should make for much more maintainable code. Patch by me. Review by Andres Freund.
Diffstat (limited to 'src/backend/storage')
-rw-r--r--src/backend/storage/lmgr/s_lock.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/backend/storage/lmgr/s_lock.c b/src/backend/storage/lmgr/s_lock.c
index efe1b43fa72..e8d35027751 100644
--- a/src/backend/storage/lmgr/s_lock.c
+++ b/src/backend/storage/lmgr/s_lock.c
@@ -154,6 +154,18 @@ s_lock(volatile slock_t *lock, const char *file, int line)
return delays;
}
+#ifdef USE_DEFAULT_S_UNLOCK
+void
+s_unlock(slock_t *lock)
+{
+#ifdef TAS_ACTIVE_WORD
+ /* HP's PA-RISC */
+ *TAS_ACTIVE_WORD(lock) = -1;
+#else
+ *lock = 0;
+#endif
+}
+#endif
/*
* Set local copy of spins_per_delay during backend startup.