aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2016-04-13 16:42:01 -0700
committerAndres Freund <andres@anarazel.de>2016-04-13 17:00:53 -0700
commit80abbeba23d466b6541cf95082a9e1f36704424e (patch)
tree088426c853cdd776344f04ede1d4a3bae9e3b29d /src/include
parent6cead413bb92be0579a2dbf6320121edcc32e369 (diff)
downloadpostgresql-80abbeba23d466b6541cf95082a9e1f36704424e.tar.gz
postgresql-80abbeba23d466b6541cf95082a9e1f36704424e.zip
Make init_spin_delay() C89 compliant and change stuck spinlock reporting.
The current definition of init_spin_delay (introduced recently in 48354581a) wasn't C89 compliant. It's not legal to refer to refer to non-constant expressions, and the ptr argument was one. This, as reported by Tom, lead to a failure on buildfarm animal pademelon. The pointer, especially on system systems with ASLR, isn't super helpful anyway, though. So instead of making init_spin_delay into an inline function, make s_lock_stuck() report the function name in addition to file:line and change init_spin_delay() accordingly. While not a direct replacement, the function name is likely more useful anyway (line numbers are often hard to interpret in third party reports). This also fixes what file/line number is reported for waits via s_lock(). As PG_FUNCNAME_MACRO is now used outside of elog.h, move it to c.h. Reported-By: Tom Lane Discussion: 4369.1460435533@sss.pgh.pa.us
Diffstat (limited to 'src/include')
-rw-r--r--src/include/c.h11
-rw-r--r--src/include/storage/s_lock.h9
-rw-r--r--src/include/utils/elog.h12
3 files changed, 16 insertions, 16 deletions
diff --git a/src/include/c.h b/src/include/c.h
index 7c57430c81d..4ab3f8027a5 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -169,6 +169,17 @@
#define dummyret char
#endif
+/* Which __func__ symbol do we have, if any? */
+#ifdef HAVE_FUNCNAME__FUNC
+#define PG_FUNCNAME_MACRO __func__
+#else
+#ifdef HAVE_FUNCNAME__FUNCTION
+#define PG_FUNCNAME_MACRO __FUNCTION__
+#else
+#define PG_FUNCNAME_MACRO NULL
+#endif
+#endif
+
/* ----------------------------------------------------------------
* Section 2: bool, true, false, TRUE, FALSE, NULL
* ----------------------------------------------------------------
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 11410e221b2..50ea5c0eaf7 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -930,7 +930,7 @@ extern int tas_sema(volatile slock_t *lock);
#if !defined(S_LOCK)
#define S_LOCK(lock) \
- (TAS(lock) ? s_lock((lock), __FILE__, __LINE__) : 0)
+ (TAS(lock) ? s_lock((lock), __FILE__, __LINE__, PG_FUNCNAME_MACRO) : 0)
#endif /* S_LOCK */
#if !defined(S_LOCK_FREE)
@@ -983,7 +983,7 @@ extern slock_t dummy_spinlock;
/*
* Platform-independent out-of-line support routines
*/
-extern int s_lock(volatile slock_t *lock, const char *file, int line);
+extern int s_lock(volatile slock_t *lock, const char *file, int line, const char *func);
/* Support for dynamic adjustment of spins_per_delay */
#define DEFAULT_SPINS_PER_DELAY 100
@@ -1000,12 +1000,13 @@ typedef struct
int spins;
int delays;
int cur_delay;
- void *ptr;
const char *file;
int line;
+ const char *func;
} SpinDelayStatus;
-#define init_spin_delay(ptr) {0, 0, 0, (ptr), __FILE__, __LINE__}
+#define init_spin_delay(file, line, func) {0, 0, 0, file, line, func}
+#define init_local_spin_delay() init_spin_delay(__FILE__, __LINE__, PG_FUNCNAME_MACRO)
void perform_spin_delay(SpinDelayStatus *status);
void finish_spin_delay(SpinDelayStatus *status);
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index 7471dadd4b6..c43e5b89436 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -71,18 +71,6 @@
#include "utils/errcodes.h"
-/* Which __func__ symbol do we have, if any? */
-#ifdef HAVE_FUNCNAME__FUNC
-#define PG_FUNCNAME_MACRO __func__
-#else
-#ifdef HAVE_FUNCNAME__FUNCTION
-#define PG_FUNCNAME_MACRO __FUNCTION__
-#else
-#define PG_FUNCNAME_MACRO NULL
-#endif
-#endif
-
-
/*----------
* New-style error reporting API: to be used in this way:
* ereport(ERROR,