summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarc <marc@openbsd.org>2002-02-17 04:33:33 +0000
committermarc <marc@openbsd.org>2002-02-17 04:33:33 +0000
commitb99c213a744a1fd4b0d17cd8487ade8a1055f7cb (patch)
treee46de6a42ecba73410ead0bd3e9783e1f7f4fdee
parentEnable stackgap_random. Set it initially to 1k. (diff)
downloadwireguard-openbsd-b99c213a744a1fd4b0d17cd8487ade8a1055f7cb.tar.xz
wireguard-openbsd-b99c213a744a1fd4b0d17cd8487ade8a1055f7cb.zip
a state variable used by multiple threads needs to be volatile
-rw-r--r--regress/lib/libc_r/cancel/cancel.c5
-rw-r--r--regress/lib/libpthread/cancel/cancel.c5
2 files changed, 6 insertions, 4 deletions
diff --git a/regress/lib/libc_r/cancel/cancel.c b/regress/lib/libc_r/cancel/cancel.c
index 13db747e45d..6f9359246d2 100644
--- a/regress/lib/libc_r/cancel/cancel.c
+++ b/regress/lib/libc_r/cancel/cancel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cancel.c,v 1.3 2001/09/20 16:43:15 todd Exp $ */
+/* $OpenBSD: cancel.c,v 1.4 2002/02/17 04:33:33 marc Exp $ */
/* David Leonard <d@openbsd.org>, 1999. Public Domain. */
#include <pthread.h>
@@ -13,7 +13,8 @@ static pthread_cond_t cond;
static pthread_mutex_t mutex;
static struct timespec expiretime;
-static int pv_state = 0;
+static volatile int pv_state = 0;
+
void p() {
CHECKr(pthread_mutex_lock(&mutex));
if (pv_state <= 0) {
diff --git a/regress/lib/libpthread/cancel/cancel.c b/regress/lib/libpthread/cancel/cancel.c
index 13db747e45d..6f9359246d2 100644
--- a/regress/lib/libpthread/cancel/cancel.c
+++ b/regress/lib/libpthread/cancel/cancel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cancel.c,v 1.3 2001/09/20 16:43:15 todd Exp $ */
+/* $OpenBSD: cancel.c,v 1.4 2002/02/17 04:33:33 marc Exp $ */
/* David Leonard <d@openbsd.org>, 1999. Public Domain. */
#include <pthread.h>
@@ -13,7 +13,8 @@ static pthread_cond_t cond;
static pthread_mutex_t mutex;
static struct timespec expiretime;
-static int pv_state = 0;
+static volatile int pv_state = 0;
+
void p() {
CHECKr(pthread_mutex_lock(&mutex));
if (pv_state <= 0) {