Skip to content

Commit 6702388

Browse files
committed
NetBSD src for "user", checkout.sh rev 62615fe3ca22417211c3120b3820d9a90836f8ab
1 parent 8c36009 commit 6702388

File tree

3 files changed

+46
-17
lines changed

3 files changed

+46
-17
lines changed

external/bsd/libc++/dist/libcxxrt/src/exception.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,7 @@ static _Unwind_Reason_Code trace(struct _Unwind_Context *context, void *c)
673673
* If the failure happened by falling off the end of the stack without finding
674674
* a handler, prints a back trace before aborting.
675675
*/
676-
#if __GNUC__ > 3 && __GNUC_MINOR__ > 2
676+
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
677677
extern "C" void *__cxa_begin_catch(void *e) throw();
678678
#else
679679
extern "C" void *__cxa_begin_catch(void *e);
@@ -1189,7 +1189,7 @@ BEGIN_PERSONALITY_FUNCTION(__gxx_personality_v0)
11891189
* pointer to the caught exception, which is either the adjusted pointer (for
11901190
* C++ exceptions) of the unadjusted pointer (for foreign exceptions).
11911191
*/
1192-
#if __GNUC__ > 3 && __GNUC_MINOR__ > 2
1192+
#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
11931193
extern "C" void *__cxa_begin_catch(void *e) throw()
11941194
#else
11951195
extern "C" void *__cxa_begin_catch(void *e)

lib/libpthread/pthread_types.h

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: pthread_types.h,v 1.13 2008/08/02 19:46:30 matt Exp $ */
1+
/* $NetBSD: pthread_types.h,v 1.14 2015/06/26 01:33:08 pooka Exp $ */
22

33
/*-
44
* Copyright (c) 2001, 2008 The NetBSD Foundation, Inc.
@@ -83,6 +83,23 @@ struct __pthread_attr_st {
8383
void *pta_private;
8484
};
8585

86+
/*
87+
* C++ (namely libc++) expects to be using PTHREAD_FOO_INITIALIZER as a
88+
* member initializer. This does not work for volatile types. Since C++
89+
* does not touch the guts of those types, we redefine them as non-volatile
90+
*/
91+
#ifdef __cplusplus
92+
# ifdef __CPU_SIMPLE_LOCK_PAD
93+
# define __pthread_spin_t unsigned char
94+
# else
95+
# define __pthread_spin_t unsigned int
96+
# endif
97+
# define __pthread_volatile
98+
#else /* __cplusplus */
99+
# define __pthread_spin_t pthread_spin_t
100+
# define __pthread_volatile volatile
101+
#endif /* __cplusplus */
102+
86103
/*
87104
* ptm_owner is the actual lock field which is locked via CAS operation.
88105
* This structure's layout is designed to compatible with the previous
@@ -100,16 +117,16 @@ struct __pthread_attr_st {
100117
#endif
101118
struct __pthread_mutex_st {
102119
unsigned int ptm_magic;
103-
pthread_spin_t ptm_errorcheck;
120+
__pthread_spin_t ptm_errorcheck;
104121
#ifdef __CPU_SIMPLE_LOCK_PAD
105122
uint8_t ptm_pad1[3];
106123
#endif
107-
pthread_spin_t ptm_interlock; /* unused - backwards compat */
124+
__pthread_spin_t ptm_interlock; /* unused - backwards compat */
108125
#ifdef __CPU_SIMPLE_LOCK_PAD
109126
uint8_t ptm_pad2[3];
110127
#endif
111-
volatile pthread_t ptm_owner;
112-
pthread_t * volatile ptm_waiters;
128+
__pthread_volatile pthread_t ptm_owner;
129+
pthread_t * __pthread_volatile ptm_waiters;
113130
unsigned int ptm_recursed;
114131
void *ptm_spare2; /* unused - backwards compat */
115132
};
@@ -145,7 +162,7 @@ struct __pthread_cond_st {
145162
unsigned int ptc_magic;
146163

147164
/* Protects the queue of waiters */
148-
pthread_spin_t ptc_lock;
165+
__pthread_spin_t ptc_lock;
149166
pthread_queue_t ptc_waiters;
150167

151168
pthread_mutex_t *ptc_mutex; /* Current mutex */
@@ -179,7 +196,7 @@ struct __pthread_once_st {
179196

180197
struct __pthread_spinlock_st {
181198
unsigned int pts_magic;
182-
pthread_spin_t pts_spin;
199+
__pthread_spin_t pts_spin;
183200
int pts_flags;
184201
};
185202

@@ -197,12 +214,12 @@ struct __pthread_rwlock_st {
197214
unsigned int ptr_magic;
198215

199216
/* Protects data below */
200-
pthread_spin_t ptr_interlock;
217+
__pthread_spin_t ptr_interlock;
201218

202219
pthread_queue_t ptr_rblocked;
203220
pthread_queue_t ptr_wblocked;
204221
unsigned int ptr_nreaders;
205-
volatile pthread_t ptr_owner;
222+
__pthread_volatile pthread_t ptr_owner;
206223
void *ptr_private;
207224
};
208225

sbin/raidctl/raidctl.c

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos Exp $ */
1+
/* $NetBSD: raidctl.c,v 1.60 2015/06/26 01:16:54 pooka Exp $ */
22

33
/*-
44
* Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -39,7 +39,7 @@
3939
#include <sys/cdefs.h>
4040

4141
#ifndef lint
42-
__RCSID("$NetBSD: raidctl.c,v 1.57 2014/04/03 18:54:10 christos Exp $");
42+
__RCSID("$NetBSD: raidctl.c,v 1.60 2015/06/26 01:16:54 pooka Exp $");
4343
#endif
4444

4545

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

@@ -85,6 +86,7 @@ static void get_bar(char *, double, int);
8586
static void get_time_string(char *, int);
8687
static void rf_output_pmstat(int, int);
8788
static void rf_pm_configure(int, int, char *, int[]);
89+
static unsigned int xstrtouint(const char *);
8890

8991
int verbose;
9092

@@ -183,7 +185,7 @@ main(int argc,char *argv[])
183185
break;
184186
case 'I':
185187
action = RAIDFRAME_INIT_LABELS;
186-
serial_number = atoi(optarg);
188+
serial_number = xstrtouint(optarg);
187189
num_options++;
188190
break;
189191
case 'm':
@@ -195,11 +197,11 @@ main(int argc,char *argv[])
195197
action = RAIDFRAME_PARITYMAP_SET_DISABLE;
196198
parityconf = strdup(optarg);
197199
num_options++;
198-
/* XXXjld: should rf_pm_configure do the atoi()s? */
200+
/* XXXjld: should rf_pm_configure do the strtol()s? */
199201
i = 0;
200202
while (i < 3 && optind < argc &&
201203
isdigit((int)argv[optind][0]))
202-
parityparams[i++] = atoi(argv[optind++]);
204+
parityparams[i++] = xstrtouint(argv[optind++]);
203205
while (i < 3)
204206
parityparams[i++] = 0;
205207
break;
@@ -1095,7 +1097,7 @@ get_bar(char *string, double percent, int max_strlen)
10951097
(int)((percent * max_strlen)/ 100);
10961098
if (offset < 0)
10971099
offset = 0;
1098-
snprintf(string,max_strlen,"%s",&stars[offset]);
1100+
snprintf(string,max_strlen,"%s",stars+offset);
10991101
}
11001102

11011103
static void
@@ -1158,3 +1160,13 @@ usage(void)
11581160
exit(1);
11591161
/* NOTREACHED */
11601162
}
1163+
1164+
static unsigned int
1165+
xstrtouint(const char *str)
1166+
{
1167+
int e;
1168+
unsigned int num = (unsigned int)strtou(str, NULL, 10, 0, INT_MAX, &e);
1169+
if (e)
1170+
errc(EXIT_FAILURE, e, "Bad number `%s'", str);
1171+
return num;
1172+
}

0 commit comments

Comments
 (0)