summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--arch/arm/bits/alltypes.h.in14
-rw-r--r--arch/i386/bits/alltypes.h.in14
-rw-r--r--arch/microblaze/bits/alltypes.h.in14
-rw-r--r--arch/mips/bits/alltypes.h.in14
-rw-r--r--arch/or1k/bits/alltypes.h.in14
-rw-r--r--arch/powerpc/bits/alltypes.h.in14
-rw-r--r--arch/sh/bits/alltypes.h.in14
-rw-r--r--arch/x32/bits/alltypes.h.in14
-rw-r--r--arch/x86_64/bits/alltypes.h.in14
-rw-r--r--include/aio.h2
-rw-r--r--include/semaphore.h2
-rw-r--r--src/aio/aio.c3
-rw-r--r--src/dirent/__dirent.h2
-rw-r--r--src/exit/at_quick_exit.c2
-rw-r--r--src/exit/atexit.c2
-rw-r--r--src/internal/libc.h6
-rw-r--r--src/internal/pthread_impl.h30
-rw-r--r--src/internal/stdio_impl.h4
-rw-r--r--src/ldso/dynlink.c2
-rw-r--r--src/locale/__setlocalecat.c2
-rw-r--r--src/locale/dcngettext.c8
-rw-r--r--src/malloc/lite_malloc.c2
-rw-r--r--src/malloc/malloc.c10
-rw-r--r--src/misc/syslog.c4
-rw-r--r--src/prng/random.c2
-rw-r--r--src/thread/pthread_atfork.c2
-rw-r--r--src/thread/pthread_barrier_wait.c8
-rw-r--r--src/thread/pthread_cond_timedwait.c10
-rw-r--r--src/thread/pthread_key_create.c2
-rw-r--r--src/thread/pthread_once.c2
-rw-r--r--src/thread/sem_open.c2
-rw-r--r--src/thread/sem_timedwait.c2
-rw-r--r--src/thread/synccall.c4
-rw-r--r--src/thread/vmlock.c2
-rw-r--r--src/time/__tz.c2
-rw-r--r--src/time/clock_gettime.c2
36 files changed, 125 insertions, 122 deletions
diff --git a/arch/arm/bits/alltypes.h.in b/arch/arm/bits/alltypes.h.in
index 8d49e7ec..667963c7 100644
--- a/arch/arm/bits/alltypes.h.in
+++ b/arch/arm/bits/alltypes.h.in
@@ -17,10 +17,10 @@ TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
TYPEDEF long time_t;
TYPEDEF long suseconds_t;
-TYPEDEF struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } pthread_cond_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } cnd_t;
-TYPEDEF struct { union { int __i[8]; void *__p[8]; } __u; } pthread_rwlock_t;
-TYPEDEF struct { union { int __i[5]; void *__p[5]; } __u; } pthread_barrier_t;
+TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
+TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;
diff --git a/arch/i386/bits/alltypes.h.in b/arch/i386/bits/alltypes.h.in
index 3621af58..b8902db7 100644
--- a/arch/i386/bits/alltypes.h.in
+++ b/arch/i386/bits/alltypes.h.in
@@ -35,10 +35,10 @@ TYPEDEF struct { _Alignas(8) long long __ll; long double __ld; } max_align_t;
TYPEDEF long time_t;
TYPEDEF long suseconds_t;
-TYPEDEF struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } pthread_cond_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } cnd_t;
-TYPEDEF struct { union { int __i[8]; void *__p[8]; } __u; } pthread_rwlock_t;
-TYPEDEF struct { union { int __i[5]; void *__p[5]; } __u; } pthread_barrier_t;
+TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
+TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;
diff --git a/arch/microblaze/bits/alltypes.h.in b/arch/microblaze/bits/alltypes.h.in
index a04363d8..66ca18ad 100644
--- a/arch/microblaze/bits/alltypes.h.in
+++ b/arch/microblaze/bits/alltypes.h.in
@@ -17,10 +17,10 @@ TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
TYPEDEF long time_t;
TYPEDEF long suseconds_t;
-TYPEDEF struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } pthread_cond_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } cnd_t;
-TYPEDEF struct { union { int __i[8]; void *__p[8]; } __u; } pthread_rwlock_t;
-TYPEDEF struct { union { int __i[5]; void *__p[5]; } __u; } pthread_barrier_t;
+TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
+TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;
diff --git a/arch/mips/bits/alltypes.h.in b/arch/mips/bits/alltypes.h.in
index a04363d8..66ca18ad 100644
--- a/arch/mips/bits/alltypes.h.in
+++ b/arch/mips/bits/alltypes.h.in
@@ -17,10 +17,10 @@ TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
TYPEDEF long time_t;
TYPEDEF long suseconds_t;
-TYPEDEF struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } pthread_cond_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } cnd_t;
-TYPEDEF struct { union { int __i[8]; void *__p[8]; } __u; } pthread_rwlock_t;
-TYPEDEF struct { union { int __i[5]; void *__p[5]; } __u; } pthread_barrier_t;
+TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
+TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;
diff --git a/arch/or1k/bits/alltypes.h.in b/arch/or1k/bits/alltypes.h.in
index 8d49e7ec..667963c7 100644
--- a/arch/or1k/bits/alltypes.h.in
+++ b/arch/or1k/bits/alltypes.h.in
@@ -17,10 +17,10 @@ TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
TYPEDEF long time_t;
TYPEDEF long suseconds_t;
-TYPEDEF struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } pthread_cond_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } cnd_t;
-TYPEDEF struct { union { int __i[8]; void *__p[8]; } __u; } pthread_rwlock_t;
-TYPEDEF struct { union { int __i[5]; void *__p[5]; } __u; } pthread_barrier_t;
+TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
+TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;
diff --git a/arch/powerpc/bits/alltypes.h.in b/arch/powerpc/bits/alltypes.h.in
index 86280728..37f27d6f 100644
--- a/arch/powerpc/bits/alltypes.h.in
+++ b/arch/powerpc/bits/alltypes.h.in
@@ -17,10 +17,10 @@ TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
TYPEDEF long time_t;
TYPEDEF long suseconds_t;
-TYPEDEF struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } pthread_cond_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } cnd_t;
-TYPEDEF struct { union { int __i[8]; void *__p[8]; } __u; } pthread_rwlock_t;
-TYPEDEF struct { union { int __i[5]; void *__p[5]; } __u; } pthread_barrier_t;
+TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
+TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;
diff --git a/arch/sh/bits/alltypes.h.in b/arch/sh/bits/alltypes.h.in
index 86280728..37f27d6f 100644
--- a/arch/sh/bits/alltypes.h.in
+++ b/arch/sh/bits/alltypes.h.in
@@ -17,10 +17,10 @@ TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
TYPEDEF long time_t;
TYPEDEF long suseconds_t;
-TYPEDEF struct { union { int __i[9]; unsigned __s[9]; } __u; } pthread_attr_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
-TYPEDEF struct { union { int __i[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } pthread_cond_t;
-TYPEDEF struct { union { int __i[12]; void *__p[12]; } __u; } cnd_t;
-TYPEDEF struct { union { int __i[8]; void *__p[8]; } __u; } pthread_rwlock_t;
-TYPEDEF struct { union { int __i[5]; void *__p[5]; } __u; } pthread_barrier_t;
+TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t;
+TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t;
diff --git a/arch/x32/bits/alltypes.h.in b/arch/x32/bits/alltypes.h.in
index 74cb212e..38230c42 100644
--- a/arch/x32/bits/alltypes.h.in
+++ b/arch/x32/bits/alltypes.h.in
@@ -22,10 +22,10 @@ TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
TYPEDEF long long time_t;
TYPEDEF long long suseconds_t;
-TYPEDEF struct { union { int __i[14]; unsigned long __s[7]; } __u; } pthread_attr_t;
-TYPEDEF struct { union { int __i[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t;
-TYPEDEF struct { union { int __i[10]; volatile void *volatile __p[5]; } __u; } mtx_t;
-TYPEDEF struct { union { int __i[12]; void *__p[6]; } __u; } pthread_cond_t;
-TYPEDEF struct { union { int __i[12]; void *__p[6]; } __u; } cnd_t;
-TYPEDEF struct { union { int __i[14]; void *__p[7]; } __u; } pthread_rwlock_t;
-TYPEDEF struct { union { int __i[8]; void *__p[4]; } __u; } pthread_barrier_t;
+TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; unsigned long __s[7]; } __u; } pthread_attr_t;
+TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } mtx_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } cnd_t;
+TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; void *__p[7]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[4]; } __u; } pthread_barrier_t;
diff --git a/arch/x86_64/bits/alltypes.h.in b/arch/x86_64/bits/alltypes.h.in
index aaec334c..dc551d47 100644
--- a/arch/x86_64/bits/alltypes.h.in
+++ b/arch/x86_64/bits/alltypes.h.in
@@ -22,10 +22,10 @@ TYPEDEF struct { long long __ll; long double __ld; } max_align_t;
TYPEDEF long time_t;
TYPEDEF long suseconds_t;
-TYPEDEF struct { union { int __i[14]; unsigned long __s[7]; } __u; } pthread_attr_t;
-TYPEDEF struct { union { int __i[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t;
-TYPEDEF struct { union { int __i[10]; volatile void *volatile __p[5]; } __u; } mtx_t;
-TYPEDEF struct { union { int __i[12]; void *__p[6]; } __u; } pthread_cond_t;
-TYPEDEF struct { union { int __i[12]; void *__p[6]; } __u; } cnd_t;
-TYPEDEF struct { union { int __i[14]; void *__p[7]; } __u; } pthread_rwlock_t;
-TYPEDEF struct { union { int __i[8]; void *__p[4]; } __u; } pthread_barrier_t;
+TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; unsigned long __s[7]; } __u; } pthread_attr_t;
+TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } mtx_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } cnd_t;
+TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; void *__p[7]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[4]; } __u; } pthread_barrier_t;
diff --git a/include/aio.h b/include/aio.h
index d9330ebe..19bc28a9 100644
--- a/include/aio.h
+++ b/include/aio.h
@@ -21,7 +21,7 @@ struct aiocb {
struct sigevent aio_sigevent;
void *__td;
int __lock[2];
- int __err;
+ volatile int __err;
ssize_t __ret;
off_t aio_offset;
void *__next, *__prev;
diff --git a/include/semaphore.h b/include/semaphore.h
index 20d46f0d..277c47d6 100644
--- a/include/semaphore.h
+++ b/include/semaphore.h
@@ -15,7 +15,7 @@ extern "C" {
#define SEM_FAILED ((sem_t *)0)
typedef struct {
- int __val[4*sizeof(long)/sizeof(int)];
+ volatile int __val[4*sizeof(long)/sizeof(int)];
} sem_t;
int sem_close(sem_t *);
diff --git a/src/aio/aio.c b/src/aio/aio.c
index d1ee7681..aafd8e8c 100644
--- a/src/aio/aio.c
+++ b/src/aio/aio.c
@@ -53,7 +53,8 @@ struct aio_thread {
struct aiocb *cb;
struct aio_thread *next, *prev;
struct aio_queue *q;
- int running, err, op;
+ volatile int running;
+ int err, op;
ssize_t ret;
};
diff --git a/src/dirent/__dirent.h b/src/dirent/__dirent.h
index 45509e19..32871baf 100644
--- a/src/dirent/__dirent.h
+++ b/src/dirent/__dirent.h
@@ -4,6 +4,6 @@ struct __dirstream
off_t tell;
int buf_pos;
int buf_end;
- int lock[2];
+ volatile int lock[2];
char buf[2048];
};
diff --git a/src/exit/at_quick_exit.c b/src/exit/at_quick_exit.c
index 85c3d26e..34541bad 100644
--- a/src/exit/at_quick_exit.c
+++ b/src/exit/at_quick_exit.c
@@ -5,7 +5,7 @@
static void (*funcs[COUNT])(void);
static int count;
-static int lock[2];
+static volatile int lock[2];
void __funcs_on_quick_exit()
{
diff --git a/src/exit/atexit.c b/src/exit/atexit.c
index 89ff4ff3..be827181 100644
--- a/src/exit/atexit.c
+++ b/src/exit/atexit.c
@@ -12,7 +12,7 @@ static struct fl
void *a[COUNT];
} builtin, *head;
-static int lock[2];
+static volatile int lock[2];
void __funcs_on_exit()
{
diff --git a/src/internal/libc.h b/src/internal/libc.h
index 2eef98e4..3751cca2 100644
--- a/src/internal/libc.h
+++ b/src/internal/libc.h
@@ -8,9 +8,9 @@
struct __locale_map;
struct __locale_struct {
- int ctype_utf8;
+ volatile int ctype_utf8;
char *messages_name;
- struct __locale_map *cat[4];
+ struct __locale_map *volatile cat[4];
};
struct __libc {
@@ -21,7 +21,7 @@ struct __libc {
size_t *auxv;
volatile int threads_minus_1;
FILE *ofl_head;
- int ofl_lock[2];
+ volatile int ofl_lock[2];
size_t tls_size;
size_t page_size;
volatile int uselocale_cnt;
diff --git a/src/internal/pthread_impl.h b/src/internal/pthread_impl.h
index 7e7baa90..441b075f 100644
--- a/src/internal/pthread_impl.h
+++ b/src/internal/pthread_impl.h
@@ -38,11 +38,11 @@ struct pthread {
volatile void *volatile pending;
} robust_list;
int unblock_cancel;
- int timer_id;
+ volatile int timer_id;
locale_t locale;
- int killlock[2];
- int exitlock[2];
- int startlock[2];
+ volatile int killlock[2];
+ volatile int exitlock[2];
+ volatile int startlock[2];
unsigned long sigmask[_NSIG/8/sizeof(long)];
void *stdio_locks;
};
@@ -62,26 +62,26 @@ struct __timer {
#define _a_policy __u.__i[3*__SU+2]
#define _a_prio __u.__i[3*__SU+3]
#define _m_type __u.__i[0]
-#define _m_lock __u.__i[1]
-#define _m_waiters __u.__i[2]
+#define _m_lock __u.__vi[1]
+#define _m_waiters __u.__vi[2]
#define _m_prev __u.__p[3]
#define _m_next __u.__p[4]
#define _m_count __u.__i[5]
#define _c_shared __u.__p[0]
-#define _c_seq __u.__i[2]
-#define _c_waiters __u.__i[3]
+#define _c_seq __u.__vi[2]
+#define _c_waiters __u.__vi[3]
#define _c_clock __u.__i[4]
-#define _c_lock __u.__i[8]
+#define _c_lock __u.__vi[8]
#define _c_head __u.__p[1]
#define _c_tail __u.__p[5]
-#define _rw_lock __u.__i[0]
-#define _rw_waiters __u.__i[1]
+#define _rw_lock __u.__vi[0]
+#define _rw_waiters __u.__vi[1]
#define _rw_shared __u.__i[2]
-#define _b_lock __u.__i[0]
-#define _b_waiters __u.__i[1]
+#define _b_lock __u.__vi[0]
+#define _b_waiters __u.__vi[1]
#define _b_limit __u.__i[2]
-#define _b_count __u.__i[3]
-#define _b_waiters2 __u.__i[4]
+#define _b_count __u.__vi[3]
+#define _b_waiters2 __u.__vi[4]
#define _b_inst __u.__p[3]
#include "pthread_arch.h"
diff --git a/src/internal/stdio_impl.h b/src/internal/stdio_impl.h
index d659522f..e1325fe1 100644
--- a/src/internal/stdio_impl.h
+++ b/src/internal/stdio_impl.h
@@ -38,8 +38,8 @@ struct _IO_FILE {
short dummy3;
signed char mode;
signed char lbf;
- int lock;
- int waiters;
+ volatile int lock;
+ volatile int waiters;
void *cookie;
off_t off;
char *getln_buf;
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 00af8865..0bdc988c 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -85,7 +85,7 @@ struct dso {
size_t relro_start, relro_end;
void **new_dtv;
unsigned char *new_tls;
- int new_dtv_idx, new_tls_idx;
+ volatile int new_dtv_idx, new_tls_idx;
struct td_index *td_index;
struct dso *fini_next;
char *shortname;
diff --git a/src/locale/__setlocalecat.c b/src/locale/__setlocalecat.c
index 1c894d9c..c93e9ba0 100644
--- a/src/locale/__setlocalecat.c
+++ b/src/locale/__setlocalecat.c
@@ -17,7 +17,7 @@ char *__strchrnul(const char *, int);
static struct __locale_map *findlocale(const char *name, size_t n)
{
- static void *loc_head;
+ static void *volatile loc_head;
struct __locale_map *p, *new, *old_head;
const char *path = 0, *z;
char buf[256];
diff --git a/src/locale/dcngettext.c b/src/locale/dcngettext.c
index d3462fd2..0057cb56 100644
--- a/src/locale/dcngettext.c
+++ b/src/locale/dcngettext.c
@@ -12,7 +12,7 @@
struct binding {
struct binding *next;
int dirlen;
- int active;
+ volatile int active;
char *domainname;
char *dirname;
char buf[];
@@ -34,7 +34,7 @@ static char *gettextdir(const char *domainname, size_t *dirlen)
char *bindtextdomain(const char *domainname, const char *dirname)
{
- static int lock[2];
+ static volatile int lock[2];
struct binding *p, *q;
if (!domainname) return 0;
@@ -96,8 +96,8 @@ struct msgcat {
struct msgcat *next;
const void *map;
size_t map_size;
- void *plural_rule;
- int nplurals;
+ void *volatile plural_rule;
+ volatile int nplurals;
char name[];
};
diff --git a/src/malloc/lite_malloc.c b/src/malloc/lite_malloc.c
index 673966a1..7643fc2c 100644
--- a/src/malloc/lite_malloc.c
+++ b/src/malloc/lite_malloc.c
@@ -12,7 +12,7 @@ void *__simple_malloc(size_t n)
{
static uintptr_t cur, brk;
uintptr_t base, new;
- static int lock[2];
+ static volatile int lock[2];
size_t align=1;
if (!n) n++;
diff --git a/src/malloc/malloc.c b/src/malloc/malloc.c
index 7932a975..70c7b3f3 100644
--- a/src/malloc/malloc.c
+++ b/src/malloc/malloc.c
@@ -25,7 +25,7 @@ struct chunk {
};
struct bin {
- int lock[2];
+ volatile int lock[2];
struct chunk *head;
struct chunk *tail;
};
@@ -33,10 +33,10 @@ struct bin {
static struct {
uintptr_t brk;
size_t *heap;
- uint64_t binmap;
+ volatile uint64_t binmap;
struct bin bins[64];
- int brk_lock[2];
- int free_lock[2];
+ volatile int brk_lock[2];
+ volatile int free_lock[2];
unsigned mmap_step;
} mal;
@@ -205,7 +205,7 @@ fail:
static int init_malloc(size_t n)
{
- static int init, waiters;
+ static volatile int init, waiters;
int state;
struct chunk *c;
diff --git a/src/misc/syslog.c b/src/misc/syslog.c
index d5874991..b934a686 100644
--- a/src/misc/syslog.c
+++ b/src/misc/syslog.c
@@ -12,11 +12,11 @@
#include "libc.h"
#include "atomic.h"
-static int lock[2];
+static volatile int lock[2];
static char log_ident[32];
static int log_opt;
static int log_facility = LOG_USER;
-static int log_mask = 0xff;
+static volatile int log_mask = 0xff;
static int log_fd = -1;
int setlogmask(int maskpri)
diff --git a/src/prng/random.c b/src/prng/random.c
index e250e28e..7d557d70 100644
--- a/src/prng/random.c
+++ b/src/prng/random.c
@@ -22,7 +22,7 @@ static int n = 31;
static int i = 3;
static int j = 0;
static uint32_t *x = init+1;
-static int lock[2];
+static volatile int lock[2];
static uint32_t lcg31(uint32_t x) {
return (1103515245*x + 12345) & 0x7fffffff;
diff --git a/src/thread/pthread_atfork.c b/src/thread/pthread_atfork.c
index 95fce207..a40d7f63 100644
--- a/src/thread/pthread_atfork.c
+++ b/src/thread/pthread_atfork.c
@@ -8,7 +8,7 @@ static struct atfork_funcs {
struct atfork_funcs *prev, *next;
} *funcs;
-static int lock[2];
+static volatile int lock[2];
void __fork_handler(int who)
{
diff --git a/src/thread/pthread_barrier_wait.c b/src/thread/pthread_barrier_wait.c
index e15abb84..bfeb3464 100644
--- a/src/thread/pthread_barrier_wait.c
+++ b/src/thread/pthread_barrier_wait.c
@@ -54,10 +54,10 @@ static int pshared_barrier_wait(pthread_barrier_t *b)
struct instance
{
- int count;
- int last;
- int waiters;
- int finished;
+ volatile int count;
+ volatile int last;
+ volatile int waiters;
+ volatile int finished;
};
int pthread_barrier_wait(pthread_barrier_t *b)
diff --git a/src/thread/pthread_cond_timedwait.c b/src/thread/pthread_cond_timedwait.c
index f5fd08c0..27b1a99a 100644
--- a/src/thread/pthread_cond_timedwait.c
+++ b/src/thread/pthread_cond_timedwait.c
@@ -29,8 +29,8 @@ int __pthread_setcancelstate(int, int *);
struct waiter {
struct waiter *prev, *next;
- int state, barrier;
- int *notify;
+ volatile int state, barrier;
+ volatile int *notify;
};
/* Self-synchronized-destruction-safe lock functions */
@@ -67,7 +67,8 @@ enum {
int __pthread_cond_timedwait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m, const struct timespec *restrict ts)
{
struct waiter node = { 0 };
- int e, seq, *fut, clock = c->_c_clock, cs, shared=0, oldstate, tmp;
+ int e, seq, clock = c->_c_clock, cs, shared=0, oldstate, tmp;
+ volatile int *fut;
if ((m->_m_type&15) && (m->_m_lock&INT_MAX) != __pthread_self()->tid)
return EPERM;
@@ -175,7 +176,8 @@ done:
int __private_cond_signal(pthread_cond_t *c, int n)
{
struct waiter *p, *first=0;
- int ref = 0, cur;
+ volatile int ref = 0;
+ int cur;
lock(&c->_c_lock);
for (p=c->_c_tail; n && p; p=p->prev) {
diff --git a/src/thread/pthread_key_create.c b/src/thread/pthread_key_create.c
index bfcd5976..198ae56e 100644
--- a/src/thread/pthread_key_create.c
+++ b/src/thread/pthread_key_create.c
@@ -3,7 +3,7 @@
volatile size_t __pthread_tsd_size = sizeof(void *) * PTHREAD_KEYS_MAX;
void *__pthread_tsd_main[PTHREAD_KEYS_MAX] = { 0 };
-static void (*keys[PTHREAD_KEYS_MAX])(void *);
+static void (*volatile keys[PTHREAD_KEYS_MAX])(void *);
static void nodtor(void *dummy)
{
diff --git a/src/thread/pthread_once.c b/src/thread/pthread_once.c
index df655ef9..a8f8aeb1 100644
--- a/src/thread/pthread_once.c
+++ b/src/thread/pthread_once.c
@@ -40,7 +40,7 @@ int __pthread_once(pthread_once_t *control, void (*init)(void))
{
/* Return immediately if init finished before, but ensure that
* effects of the init routine are visible to the caller. */
- if (*control == 2) {
+ if (*(volatile int *)control == 2) {
a_barrier();
return 0;
}
diff --git a/src/thread/sem_open.c b/src/thread/sem_open.c
index 9a95d257..ab884a42 100644
--- a/src/thread/sem_open.c
+++ b/src/thread/sem_open.c
@@ -20,7 +20,7 @@ static struct {
sem_t *sem;
int refcnt;
} *semtab;
-static int lock[2];
+static volatile int lock[2];
#define FLAGS (O_RDWR|O_NOFOLLOW|O_CLOEXEC|O_NONBLOCK)
diff --git a/src/thread/sem_timedwait.c b/src/thread/sem_timedwait.c
index a7488df7..8132eb1b 100644
--- a/src/thread/sem_timedwait.c
+++ b/src/thread/sem_timedwait.c
@@ -19,7 +19,7 @@ int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict at)
int r;
a_inc(sem->__val+1);
a_cas(sem->__val, 0, -1);
- pthread_cleanup_push(cleanup, sem->__val+1);
+ pthread_cleanup_push(cleanup, (void *)(sem->__val+1));
r = __timedwait_cp(sem->__val, -1, CLOCK_REALTIME, at, sem->__val[2]);
pthread_cleanup_pop(1);
if (r && r != EINTR) {
diff --git a/src/thread/synccall.c b/src/thread/synccall.c
index 47d070b4..000ec4e3 100644
--- a/src/thread/synccall.c
+++ b/src/thread/synccall.c
@@ -14,8 +14,8 @@ static struct chain {
sem_t target_sem, caller_sem;
} *volatile head;
-static int synccall_lock[2];
-static int target_tid;
+static volatile int synccall_lock[2];
+static volatile int target_tid;
static void (*callback)(void *), *context;
static volatile int dummy = 0;
weak_alias(dummy, __block_new_threads);
diff --git a/src/thread/vmlock.c b/src/thread/vmlock.c
index aba9e311..125c6dc9 100644
--- a/src/thread/vmlock.c
+++ b/src/thread/vmlock.c
@@ -1,6 +1,6 @@
#include "pthread_impl.h"
-static int vmlock[2];
+static volatile int vmlock[2];
void __vm_lock(int inc)
{
diff --git a/src/time/__tz.c b/src/time/__tz.c
index 4ce20258..13cb1aed 100644
--- a/src/time/__tz.c
+++ b/src/time/__tz.c
@@ -27,7 +27,7 @@ static char old_tz_buf[32];
static char *old_tz = old_tz_buf;
static size_t old_tz_size = sizeof old_tz_buf;
-static int lock[2];
+static volatile int lock[2];
static int getint(const char **p)
{
diff --git a/src/time/clock_gettime.c b/src/time/clock_gettime.c
index 799251d8..1572de0e 100644
--- a/src/time/clock_gettime.c
+++ b/src/time/clock_gettime.c
@@ -26,7 +26,7 @@ void *__vdsosym(const char *, const char *);
int __clock_gettime(clockid_t clk, struct timespec *ts)
{
#ifdef VDSO_CGT_SYM
- static int (*cgt)(clockid_t, struct timespec *);
+ static int (*volatile cgt)(clockid_t, struct timespec *);
if (!cgt) {
void *f = __vdsosym(VDSO_CGT_VER, VDSO_CGT_SYM);
if (!f) f = (void *)sc_clock_gettime;