Fix PTHREAD_FOO_INITIALIZER for C++ by not using volatile in the relevant
pthread types in C++ builds, attempt 2. The problem with attempt 1 was making assumptions of what the MD __cpu_simple_lock_t (declared volatile) looks like. To get a same type except non-volatile, we change the MD type to __cpu_simple_lock_nv_t and typedef __cpu_simple_lock_t as a volatile __cpu_simple_lock_nv_t. IMO, __cpu_simple_lock_t should not be volatile at all, but changing it now is too risky. Fixes at least Rumprun w/ gcc 5.1/5.2. Furthermore, the mpd application (and possibly others) will no longer require NetBSD-specific patches. Tested: build.sh for i386, Rumprun for x86_64 w/ gcc 5.2. Based on the patch from Christos in lib/49989.
This commit is contained in:
parent
5e9af25b8a
commit
01d7ebdd80
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: pthread_types.h,v 1.16 2015/06/26 11:25:22 pooka Exp $ */
|
||||
/* $NetBSD: pthread_types.h,v 1.17 2015/08/27 12:30:50 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -35,8 +35,19 @@
|
|||
/*
|
||||
* We use the "pthread_spin_t" name internally; "pthread_spinlock_t" is the
|
||||
* POSIX spinlock object.
|
||||
*
|
||||
* C++ expects to be using PTHREAD_FOO_INITIALIZER as a member initializer.
|
||||
* This does not work for volatile types. Since C++ does not touch the guts
|
||||
* of those types, we do not include volatile in the C++ definitions.
|
||||
*/
|
||||
typedef __cpu_simple_lock_t pthread_spin_t;
|
||||
typedef __cpu_simple_lock_t pthread_spin_t;
|
||||
#ifdef __cplusplus
|
||||
typedef __cpu_simple_lock_nv_t __pthread_spin_t;
|
||||
#define __pthread_volatile
|
||||
#else
|
||||
typedef pthread_spin_t __pthread_spin_t;
|
||||
#define __pthread_volatile volatile
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Copied from PTQ_HEAD in pthread_queue.h
|
||||
|
@ -100,16 +111,16 @@ struct __pthread_attr_st {
|
|||
#endif
|
||||
struct __pthread_mutex_st {
|
||||
unsigned int ptm_magic;
|
||||
pthread_spin_t ptm_errorcheck;
|
||||
__pthread_spin_t ptm_errorcheck;
|
||||
#ifdef __CPU_SIMPLE_LOCK_PAD
|
||||
uint8_t ptm_pad1[3];
|
||||
#endif
|
||||
pthread_spin_t ptm_interlock; /* unused - backwards compat */
|
||||
__pthread_spin_t ptm_interlock; /* unused - backwards compat */
|
||||
#ifdef __CPU_SIMPLE_LOCK_PAD
|
||||
uint8_t ptm_pad2[3];
|
||||
#endif
|
||||
volatile pthread_t ptm_owner;
|
||||
pthread_t * volatile ptm_waiters;
|
||||
__pthread_volatile pthread_t ptm_owner;
|
||||
pthread_t * __pthread_volatile ptm_waiters;
|
||||
unsigned int ptm_recursed;
|
||||
void *ptm_spare2; /* unused - backwards compat */
|
||||
};
|
||||
|
@ -145,7 +156,7 @@ struct __pthread_cond_st {
|
|||
unsigned int ptc_magic;
|
||||
|
||||
/* Protects the queue of waiters */
|
||||
pthread_spin_t ptc_lock;
|
||||
__pthread_spin_t ptc_lock;
|
||||
pthread_queue_t ptc_waiters;
|
||||
|
||||
pthread_mutex_t *ptc_mutex; /* Current mutex */
|
||||
|
@ -179,7 +190,7 @@ struct __pthread_once_st {
|
|||
|
||||
struct __pthread_spinlock_st {
|
||||
unsigned int pts_magic;
|
||||
pthread_spin_t pts_spin;
|
||||
__pthread_spin_t pts_spin;
|
||||
int pts_flags;
|
||||
};
|
||||
|
||||
|
@ -197,12 +208,12 @@ struct __pthread_rwlock_st {
|
|||
unsigned int ptr_magic;
|
||||
|
||||
/* Protects data below */
|
||||
pthread_spin_t ptr_interlock;
|
||||
__pthread_spin_t ptr_interlock;
|
||||
|
||||
pthread_queue_t ptr_rblocked;
|
||||
pthread_queue_t ptr_wblocked;
|
||||
unsigned int ptr_nreaders;
|
||||
volatile pthread_t ptr_owner;
|
||||
__pthread_volatile pthread_t ptr_owner;
|
||||
void *ptr_private;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.1 2014/08/10 05:47:38 matt Exp $ */
|
||||
/* $NetBSD: types.h,v 1.2 2015/08/27 12:30:50 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||
|
@ -74,7 +74,7 @@ typedef struct label_t { /* Used by setjmp & longjmp */
|
|||
/*
|
||||
* This should have always been an 8-bit type.
|
||||
*/
|
||||
typedef volatile unsigned char __cpu_simple_lock_t;
|
||||
typedef unsigned char __cpu_simple_lock_nv_t;
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 1
|
||||
#define __SIMPLELOCK_UNLOCKED 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.47 2015/08/21 14:22:14 pooka Exp $ */
|
||||
/* $NetBSD: types.h,v 1.48 2015/08/27 12:30:50 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -67,7 +67,7 @@ typedef int register32_t;
|
|||
#define PRIxREGISTER "lx"
|
||||
#define PRIxREGISTER32 "x"
|
||||
|
||||
typedef volatile unsigned char __cpu_simple_lock_t;
|
||||
typedef unsigned char __cpu_simple_lock_nv_t;
|
||||
|
||||
/* __cpu_simple_lock_t used to be a full word. */
|
||||
#define __CPU_SIMPLE_LOCK_PAD
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.29 2014/09/13 17:41:03 matt Exp $ */
|
||||
/* $NetBSD: types.h,v 1.30 2015/08/27 12:30:50 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -71,9 +71,9 @@ typedef unsigned short tlb_asid_t;
|
|||
* to user-space, we don't want ABI breakage there.
|
||||
*/
|
||||
#if defined(_KERNEL)
|
||||
typedef volatile unsigned char __cpu_simple_lock_t;
|
||||
typedef unsigned char __cpu_simple_lock_nv_t;
|
||||
#else
|
||||
typedef volatile int __cpu_simple_lock_t;
|
||||
typedef int __cpu_simple_lock_nv_t;
|
||||
#endif /* _KERNEL */
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.23 2014/02/24 07:23:43 skrll Exp $ */
|
||||
/* $NetBSD: types.h,v 1.24 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/* $OpenBSD: types.h,v 1.6 2001/08/11 01:58:34 art Exp $ */
|
||||
|
||||
|
@ -68,9 +68,9 @@ typedef unsigned long psize_t;
|
|||
/*
|
||||
* Semaphores must be aligned on 16-byte boundaries on the PA-RISC.
|
||||
*/
|
||||
typedef volatile struct {
|
||||
typedef struct {
|
||||
volatile unsigned long csl_lock[4];
|
||||
} __cpu_simple_lock_t;
|
||||
} __cpu_simple_lock_nv_t;
|
||||
|
||||
|
||||
#define __SIMPLELOCK_LOCKED { { 0, 0, 0, 0} }
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.82 2015/08/21 14:22:14 pooka Exp $ */
|
||||
/* $NetBSD: types.h,v 1.83 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -90,7 +90,7 @@ typedef __uint64_t pmc_ctr_t;
|
|||
typedef int register_t;
|
||||
#define PRIxREGISTER "x"
|
||||
|
||||
typedef volatile unsigned char __cpu_simple_lock_t;
|
||||
typedef unsigned char __cpu_simple_lock_nv_t;
|
||||
|
||||
/* __cpu_simple_lock_t used to be a full word. */
|
||||
#define __CPU_SIMPLE_LOCK_PAD
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.7 2012/12/26 19:43:10 martin Exp $ */
|
||||
/* $NetBSD: types.h,v 1.8 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -63,7 +63,7 @@ typedef __uint64_t pmc_ctr_t;
|
|||
typedef long int register_t;
|
||||
#define PRIxREGISTER "lx"
|
||||
|
||||
typedef __volatile int __cpu_simple_lock_t;
|
||||
typedef int __cpu_simple_lock_nv_t;
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 1
|
||||
#define __SIMPLELOCK_UNLOCKED 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.30 2011/11/22 15:25:28 joerg Exp $ */
|
||||
/* $NetBSD: types.h,v 1.31 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -63,7 +63,7 @@ typedef unsigned long vsize_t;
|
|||
typedef int register_t;
|
||||
#define PRIxREGISTER "x"
|
||||
|
||||
typedef volatile unsigned char __cpu_simple_lock_t;
|
||||
typedef unsigned char __cpu_simple_lock_nv_t;
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 0x80 /* result of `tas' insn */
|
||||
#define __SIMPLELOCK_UNLOCKED 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.58 2015/06/11 14:32:16 matt Exp $ */
|
||||
/* $NetBSD: types.h,v 1.59 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -133,7 +133,7 @@ typedef __uint32_t tlb_asid_t;
|
|||
#define PCU_UNIT_COUNT 2
|
||||
#endif
|
||||
|
||||
typedef volatile unsigned int __cpu_simple_lock_t;
|
||||
typedef unsigned int __cpu_simple_lock_nv_t;
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 1
|
||||
#define __SIMPLELOCK_UNLOCKED 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.1 2014/09/03 19:34:26 matt Exp $ */
|
||||
/* $NetBSD: types.h,v 1.2 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||
|
@ -66,7 +66,7 @@ typedef struct label_t { /* Used by setjmp & longjmp */
|
|||
} label_t;
|
||||
#endif
|
||||
|
||||
typedef volatile unsigned int __cpu_simple_lock_t;
|
||||
typedef unsigned int __cpu_simple_lock_nv_t;
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 1
|
||||
#define __SIMPLELOCK_UNLOCKED 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.50 2014/12/14 23:49:17 chs Exp $ */
|
||||
/* $NetBSD: types.h,v 1.51 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1995 Wolfgang Solfrank.
|
||||
|
@ -68,7 +68,7 @@ typedef struct label_t {
|
|||
typedef __uint32_t tlb_asid_t; /* for booke */
|
||||
#endif
|
||||
|
||||
typedef volatile int __cpu_simple_lock_t;
|
||||
typedef int __cpu_simple_lock_nv_t;
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 1
|
||||
#define __SIMPLELOCK_UNLOCKED 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.2 2015/03/28 16:13:56 matt Exp $ */
|
||||
/* $NetBSD: types.h,v 1.3 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 The NetBSD Foundation, Inc.
|
||||
|
@ -75,7 +75,7 @@ typedef struct label_t { /* Used by setjmp & longjmp */
|
|||
} label_t;
|
||||
#endif
|
||||
|
||||
typedef volatile unsigned int __cpu_simple_lock_t;
|
||||
typedef unsigned int __cpu_simple_lock_nv_t;
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 1
|
||||
#define __SIMPLELOCK_UNLOCKED 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.34 2011/07/17 23:48:35 dyoung Exp $ */
|
||||
/* $NetBSD: types.h,v 1.35 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -64,7 +64,7 @@ typedef unsigned long vsize_t;
|
|||
typedef int register_t;
|
||||
#define PRIxREGISTER "x"
|
||||
|
||||
typedef volatile unsigned char __cpu_simple_lock_t;
|
||||
typedef unsigned char __cpu_simple_lock_nv_t;
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 0x80
|
||||
#define __SIMPLELOCK_UNLOCKED 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.62 2012/11/02 00:01:19 chs Exp $ */
|
||||
/* $NetBSD: types.h,v 1.63 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -107,7 +107,7 @@ typedef paddr_t psize_t;
|
|||
#define PRIxPSIZE PRIxPADDR
|
||||
#endif
|
||||
|
||||
typedef volatile unsigned char __cpu_simple_lock_t;
|
||||
typedef unsigned char __cpu_simple_lock_nv_t;
|
||||
|
||||
/* __cpu_simple_lock_t used to be a full word. */
|
||||
#define __CPU_SIMPLE_LOCK_PAD
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.8 2012/02/08 17:55:21 reinoud Exp $ */
|
||||
/* $NetBSD: types.h,v 1.9 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2007 Jared D. McNeill <jmcneill@invisible.ca>
|
||||
|
@ -52,7 +52,7 @@ typedef long int register_t;
|
|||
#define PRIuVSIZE "lu"
|
||||
#define PRIxREGISTER "lx"
|
||||
|
||||
typedef volatile unsigned char __cpu_simple_lock_t;
|
||||
typedef unsigned char __cpu_simple_lock_nv_t;
|
||||
#define __CPU_SIMPLE_LOCK_PAD
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 1
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.47 2013/08/25 03:08:56 matt Exp $ */
|
||||
/* $NetBSD: types.h,v 1.48 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1990 The Regents of the University of California.
|
||||
|
@ -64,7 +64,7 @@ typedef int register_t;
|
|||
/*
|
||||
* BBCCI/BBSSI can operate on bytes so let's save some space.
|
||||
*/
|
||||
typedef volatile char __cpu_simple_lock_t;
|
||||
typedef char __cpu_simple_lock_nv_t;
|
||||
|
||||
#define __SIMPLELOCK_LOCKED 1
|
||||
#define __SIMPLELOCK_UNLOCKED 0
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: types.h,v 1.94 2015/07/30 21:38:53 kamil Exp $ */
|
||||
/* $NetBSD: types.h,v 1.95 2015/08/27 12:30:51 pooka Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1982, 1986, 1991, 1993, 1994
|
||||
|
@ -199,6 +199,8 @@ typedef unsigned long cpuid_t;
|
|||
|
||||
typedef int psetid_t;
|
||||
|
||||
typedef volatile __cpu_simple_lock_nv_t __cpu_simple_lock_t;
|
||||
|
||||
#if defined(_KERNEL) || defined(_STANDALONE)
|
||||
|
||||
#include <sys/stdbool.h>
|
||||
|
|
Loading…
Reference in New Issue