Module Name: src Committed By: pooka Date: Thu Aug 27 12:30:51 UTC 2015
Modified Files: src/lib/libpthread: pthread_types.h src/sys/arch/aarch64/include: types.h src/sys/arch/amd64/include: types.h src/sys/arch/arm/include: types.h src/sys/arch/hppa/include: types.h src/sys/arch/i386/include: types.h src/sys/arch/ia64/include: types.h src/sys/arch/m68k/include: types.h src/sys/arch/mips/include: types.h src/sys/arch/or1k/include: types.h src/sys/arch/powerpc/include: types.h src/sys/arch/riscv/include: types.h src/sys/arch/sh3/include: types.h src/sys/arch/sparc/include: types.h src/sys/arch/usermode/include: types.h src/sys/arch/vax/include: types.h src/sys/sys: types.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/lib/libpthread/pthread_types.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/aarch64/include/types.h cvs rdiff -u -r1.47 -r1.48 src/sys/arch/amd64/include/types.h cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/include/types.h cvs rdiff -u -r1.23 -r1.24 src/sys/arch/hppa/include/types.h cvs rdiff -u -r1.82 -r1.83 src/sys/arch/i386/include/types.h cvs rdiff -u -r1.7 -r1.8 src/sys/arch/ia64/include/types.h cvs rdiff -u -r1.30 -r1.31 src/sys/arch/m68k/include/types.h cvs rdiff -u -r1.58 -r1.59 src/sys/arch/mips/include/types.h cvs rdiff -u -r1.1 -r1.2 src/sys/arch/or1k/include/types.h cvs rdiff -u -r1.50 -r1.51 src/sys/arch/powerpc/include/types.h cvs rdiff -u -r1.2 -r1.3 src/sys/arch/riscv/include/types.h cvs rdiff -u -r1.34 -r1.35 src/sys/arch/sh3/include/types.h cvs rdiff -u -r1.62 -r1.63 src/sys/arch/sparc/include/types.h cvs rdiff -u -r1.8 -r1.9 src/sys/arch/usermode/include/types.h cvs rdiff -u -r1.47 -r1.48 src/sys/arch/vax/include/types.h cvs rdiff -u -r1.94 -r1.95 src/sys/sys/types.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libpthread/pthread_types.h diff -u src/lib/libpthread/pthread_types.h:1.16 src/lib/libpthread/pthread_types.h:1.17 --- src/lib/libpthread/pthread_types.h:1.16 Fri Jun 26 11:25:22 2015 +++ src/lib/libpthread/pthread_types.h Thu Aug 27 12:30:50 2015 @@ -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; }; Index: src/sys/arch/aarch64/include/types.h diff -u src/sys/arch/aarch64/include/types.h:1.1 src/sys/arch/aarch64/include/types.h:1.2 --- src/sys/arch/aarch64/include/types.h:1.1 Sun Aug 10 05:47:38 2014 +++ src/sys/arch/aarch64/include/types.h Thu Aug 27 12:30:50 2015 @@ -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 setj /* * 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 Index: src/sys/arch/amd64/include/types.h diff -u src/sys/arch/amd64/include/types.h:1.47 src/sys/arch/amd64/include/types.h:1.48 --- src/sys/arch/amd64/include/types.h:1.47 Fri Aug 21 14:22:14 2015 +++ src/sys/arch/amd64/include/types.h Thu Aug 27 12:30:50 2015 @@ -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 Index: src/sys/arch/arm/include/types.h diff -u src/sys/arch/arm/include/types.h:1.29 src/sys/arch/arm/include/types.h:1.30 --- src/sys/arch/arm/include/types.h:1.29 Sat Sep 13 17:41:03 2014 +++ src/sys/arch/arm/include/types.h Thu Aug 27 12:30:50 2015 @@ -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 Index: src/sys/arch/hppa/include/types.h diff -u src/sys/arch/hppa/include/types.h:1.23 src/sys/arch/hppa/include/types.h:1.24 --- src/sys/arch/hppa/include/types.h:1.23 Mon Feb 24 07:23:43 2014 +++ src/sys/arch/hppa/include/types.h Thu Aug 27 12:30:51 2015 @@ -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} } Index: src/sys/arch/i386/include/types.h diff -u src/sys/arch/i386/include/types.h:1.82 src/sys/arch/i386/include/types.h:1.83 --- src/sys/arch/i386/include/types.h:1.82 Fri Aug 21 14:22:14 2015 +++ src/sys/arch/i386/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 Index: src/sys/arch/ia64/include/types.h diff -u src/sys/arch/ia64/include/types.h:1.7 src/sys/arch/ia64/include/types.h:1.8 --- src/sys/arch/ia64/include/types.h:1.7 Wed Dec 26 19:43:10 2012 +++ src/sys/arch/ia64/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 Index: src/sys/arch/m68k/include/types.h diff -u src/sys/arch/m68k/include/types.h:1.30 src/sys/arch/m68k/include/types.h:1.31 --- src/sys/arch/m68k/include/types.h:1.30 Tue Nov 22 15:25:28 2011 +++ src/sys/arch/m68k/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 Index: src/sys/arch/mips/include/types.h diff -u src/sys/arch/mips/include/types.h:1.58 src/sys/arch/mips/include/types.h:1.59 --- src/sys/arch/mips/include/types.h:1.58 Thu Jun 11 14:32:16 2015 +++ src/sys/arch/mips/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 Index: src/sys/arch/or1k/include/types.h diff -u src/sys/arch/or1k/include/types.h:1.1 src/sys/arch/or1k/include/types.h:1.2 --- src/sys/arch/or1k/include/types.h:1.1 Wed Sep 3 19:34:26 2014 +++ src/sys/arch/or1k/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 setj } 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 Index: src/sys/arch/powerpc/include/types.h diff -u src/sys/arch/powerpc/include/types.h:1.50 src/sys/arch/powerpc/include/types.h:1.51 --- src/sys/arch/powerpc/include/types.h:1.50 Sun Dec 14 23:49:17 2014 +++ src/sys/arch/powerpc/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 Index: src/sys/arch/riscv/include/types.h diff -u src/sys/arch/riscv/include/types.h:1.2 src/sys/arch/riscv/include/types.h:1.3 --- src/sys/arch/riscv/include/types.h:1.2 Sat Mar 28 16:13:56 2015 +++ src/sys/arch/riscv/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 setj } 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 Index: src/sys/arch/sh3/include/types.h diff -u src/sys/arch/sh3/include/types.h:1.34 src/sys/arch/sh3/include/types.h:1.35 --- src/sys/arch/sh3/include/types.h:1.34 Sun Jul 17 23:48:35 2011 +++ src/sys/arch/sh3/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 Index: src/sys/arch/sparc/include/types.h diff -u src/sys/arch/sparc/include/types.h:1.62 src/sys/arch/sparc/include/types.h:1.63 --- src/sys/arch/sparc/include/types.h:1.62 Fri Nov 2 00:01:19 2012 +++ src/sys/arch/sparc/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 Index: src/sys/arch/usermode/include/types.h diff -u src/sys/arch/usermode/include/types.h:1.8 src/sys/arch/usermode/include/types.h:1.9 --- src/sys/arch/usermode/include/types.h:1.8 Wed Feb 8 17:55:21 2012 +++ src/sys/arch/usermode/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 <jmcne...@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 Index: src/sys/arch/vax/include/types.h diff -u src/sys/arch/vax/include/types.h:1.47 src/sys/arch/vax/include/types.h:1.48 --- src/sys/arch/vax/include/types.h:1.47 Sun Aug 25 03:08:56 2013 +++ src/sys/arch/vax/include/types.h Thu Aug 27 12:30:51 2015 @@ -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 Index: src/sys/sys/types.h diff -u src/sys/sys/types.h:1.94 src/sys/sys/types.h:1.95 --- src/sys/sys/types.h:1.94 Thu Jul 30 21:38:53 2015 +++ src/sys/sys/types.h Thu Aug 27 12:30:51 2015 @@ -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>