Skip to content

Commit

Permalink
Merge branch 'user-src' into appstack-src
Browse files Browse the repository at this point in the history
  • Loading branch information
anttikantee committed Jun 26, 2015
2 parents 7869ddb + d1b94b8 commit dc68301
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 17 deletions.
4 changes: 2 additions & 2 deletions external/bsd/libc++/dist/libcxxrt/src/exception.cc
Expand Up @@ -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);
Expand Down Expand Up @@ -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)
Expand Down
35 changes: 26 additions & 9 deletions 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.
Expand Down Expand Up @@ -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
Expand All @@ -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 */
};
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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;
};

Expand All @@ -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;
};

Expand Down
24 changes: 18 additions & 6 deletions 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.
Expand Down Expand Up @@ -39,7 +39,7 @@
#include <sys/cdefs.h>

#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


Expand All @@ -55,6 +55,7 @@ __RCSID("$NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos Exp $");
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <unistd.h>
#include <util.h>

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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':
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

0 comments on commit dc68301

Please sign in to comment.