From 67023882e7775d57429673879569ac5ac948b8b2 Mon Sep 17 00:00:00 2001 From: Antti Kantee Date: Fri, 26 Jun 2015 01:51:37 +0000 Subject: [PATCH] NetBSD src for "user", checkout.sh rev 62615fe3ca22417211c3120b3820d9a90836f8ab --- .../bsd/libc++/dist/libcxxrt/src/exception.cc | 4 +-- lib/libpthread/pthread_types.h | 35 ++++++++++++++----- sbin/raidctl/raidctl.c | 24 +++++++++---- 3 files changed, 46 insertions(+), 17 deletions(-) diff --git a/external/bsd/libc++/dist/libcxxrt/src/exception.cc b/external/bsd/libc++/dist/libcxxrt/src/exception.cc index ed5ad2b986..7781ebbebb 100644 --- a/external/bsd/libc++/dist/libcxxrt/src/exception.cc +++ b/external/bsd/libc++/dist/libcxxrt/src/exception.cc @@ -673,7 +673,7 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c) * If the failure happened by falling off the end of the stack without finding * a handler, prints a back trace before aborting. */ -#if __GNUC__ > 3 && __GNUC_MINOR__ > 2 +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) extern "C" void *__cxa_begin_catch(void *e) throw(); #else extern "C" void *__cxa_begin_catch(void *e); @@ -1189,7 +1189,7 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0) * pointer to the caught exception, which is either the adjusted pointer (for * C++ exceptions) of the unadjusted pointer (for foreign exceptions). */ -#if __GNUC__ > 3 && __GNUC_MINOR__ > 2 +#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4) extern "C" void *__cxa_begin_catch(void *e) throw() #else extern "C" void *__cxa_begin_catch(void *e) diff --git a/lib/libpthread/pthread_types.h b/lib/libpthread/pthread_types.h index cf49d0270a..45d38895ef 100644 --- a/lib/libpthread/pthread_types.h +++ b/lib/libpthread/pthread_types.h @@ -1,4 +1,4 @@ -/* $NetBSD: pthread_types.h,v 1.13 2008/08/02 19:46:30 matt Exp $ */ +/* $NetBSD: pthread_types.h,v 1.14 2015/06/26 01:33:08 pooka Exp $ */ /*- * Copyright (c) 2001, 2008 The NetBSD Foundation, Inc. @@ -83,6 +83,23 @@ struct __pthread_attr_st { void *pta_private; }; +/* + * C++ (namely libc++) 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 redefine them as non-volatile + */ +#ifdef __cplusplus +# ifdef __CPU_SIMPLE_LOCK_PAD +# define __pthread_spin_t unsigned char +# else +# define __pthread_spin_t unsigned int +# endif +# define __pthread_volatile +#else /* __cplusplus */ +# define __pthread_spin_t pthread_spin_t +# define __pthread_volatile volatile +#endif /* __cplusplus */ + /* * ptm_owner is the actual lock field which is locked via CAS operation. * This structure's layout is designed to compatible with the previous @@ -100,16 +117,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 +162,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 +196,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 +214,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; }; diff --git a/sbin/raidctl/raidctl.c b/sbin/raidctl/raidctl.c index dfc2e37701..9b2080915b 100644 --- a/sbin/raidctl/raidctl.c +++ b/sbin/raidctl/raidctl.c @@ -1,4 +1,4 @@ -/* $NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos Exp $ */ +/* $NetBSD: raidctl.c,v 1.60 2015/06/26 01:16:54 pooka Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ #include #ifndef lint -__RCSID("$NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos Exp $"); +__RCSID("$NetBSD: raidctl.c,v 1.60 2015/06/26 01:16:54 pooka Exp $"); #endif @@ -55,6 +55,7 @@ __RCSID("$NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos Exp $"); #include #include #include +#include #include #include @@ -85,6 +86,7 @@ static void get_bar(char *, double, int); static void get_time_string(char *, int); static void rf_output_pmstat(int, int); static void rf_pm_configure(int, int, char *, int[]); +static unsigned int xstrtouint(const char *); int verbose; @@ -183,7 +185,7 @@ main(int argc,char *argv[]) break; case 'I': action = RAIDFRAME_INIT_LABELS; - serial_number = atoi(optarg); + serial_number = xstrtouint(optarg); num_options++; break; case 'm': @@ -195,11 +197,11 @@ main(int argc,char *argv[]) action = RAIDFRAME_PARITYMAP_SET_DISABLE; parityconf = strdup(optarg); num_options++; - /* XXXjld: should rf_pm_configure do the atoi()s? */ + /* XXXjld: should rf_pm_configure do the strtol()s? */ i = 0; while (i < 3 && optind < argc && isdigit((int)argv[optind][0])) - parityparams[i++] = atoi(argv[optind++]); + parityparams[i++] = xstrtouint(argv[optind++]); while (i < 3) parityparams[i++] = 0; break; @@ -1095,7 +1097,7 @@ get_bar(char *string, double percent, int max_strlen) (int)((percent * max_strlen)/ 100); if (offset < 0) offset = 0; - snprintf(string,max_strlen,"%s",&stars[offset]); + snprintf(string,max_strlen,"%s",stars+offset); } static void @@ -1158,3 +1160,13 @@ usage(void) exit(1); /* NOTREACHED */ } + +static unsigned int +xstrtouint(const char *str) +{ + int e; + unsigned int num = (unsigned int)strtou(str, NULL, 10, 0, INT_MAX, &e); + if (e) + errc(EXIT_FAILURE, e, "Bad number `%s'", str); + return num; +}