|
From: Tom H. <th...@cy...> - 2004-12-19 17:46:37
|
CVS commit by thughes:
Remove the nested function in __pthread_once so that libpthread.so doesn't
wind up being marked as needing an executable stack which seems to be
causing problems on some systems.
M +20 -18 vg_libpthread.c 1.180
--- valgrind/coregrind/vg_libpthread.c #1.179:1.180
@@ -1834,23 +1834,26 @@ static pthread_mutex_t once_masterlock =
#define P_ONCE_COMPLETED ((PTHREAD_ONCE_INIT) + 2)
-int __pthread_once ( pthread_once_t *once_control,
- void (*init_routine) (void) )
-{
- int res;
- int done;
-
-# define TAKE_LOCK \
+/* Take the master lock */
+#define TAKE_LOCK \
res = __pthread_mutex_lock(&once_masterlock); \
my_assert(res == 0);
-# define RELEASE_LOCK \
+/* Release the master lock */
+#define RELEASE_LOCK \
res = __pthread_mutex_unlock(&once_masterlock); \
my_assert(res == 0);
- void cleanup(void *v) {
+static void once_cleanup(void *v) {
+ int res;
TAKE_LOCK;
- *once_control = P_ONCE_NOT_DONE;
+ *(pthread_once_t *)v = P_ONCE_NOT_DONE;
RELEASE_LOCK;
- }
+}
+
+int __pthread_once ( pthread_once_t *once_control,
+ void (*init_routine) (void) )
+{
+ int res;
+ int done;
ensure_valgrind("pthread_once");
@@ -1867,5 +1870,5 @@ int __pthread_once ( pthread_once_t *onc
lock and run. */
*once_control = P_ONCE_RUNNING;
- _pthread_cleanup_push(NULL, cleanup, NULL);
+ _pthread_cleanup_push(NULL, once_cleanup, once_control);
RELEASE_LOCK;
init_routine();
@@ -1907,9 +1910,8 @@ int __pthread_once ( pthread_once_t *onc
return 0;
-
-# undef TAKE_LOCK
-# undef RELEASE_LOCK
}
+#undef TAKE_LOCK
+#undef RELEASE_LOCK
#undef P_ONCE_NOT_DONE
#undef P_ONCE_RUNNING
|