1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-16 10:20:30 +00:00

Backout previous commit. Use of spinlocks was not approved.

PR:		15070
This commit is contained in:
Tor Egge 2001-02-09 20:31:48 +00:00
parent 3eb66e95ef
commit d7e56cc908
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=72254
3 changed files with 40 additions and 61 deletions

View File

@ -267,7 +267,7 @@ vfprintf(FILE *fp, const char *fmt0, va_list ap)
#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
#define DEFPREC 6
static char *cvt __P((double, int, int, char *, int *, int, int *, char **));
static char *cvt __P((double, int, int, char *, int *, int, int *));
static int exponent __P((char *, int, int));
#else /* no FLOATING_POINT */
@ -313,7 +313,6 @@ __vfprintf(FILE *fp, const char *fmt0, va_list ap)
int expsize; /* character count for expstr */
int ndig; /* actual number of digits returned by cvt */
char expstr[7]; /* buffer for exponent string */
char *dtoaresult; /* buffer allocated by dtoa */
#endif
u_long ulval; /* integer arguments %[diouxX] */
u_quad_t uqval; /* %q integers */
@ -422,9 +421,6 @@ __vfprintf(FILE *fp, const char *fmt0, va_list ap)
}
#ifdef FLOATING_POINT
dtoaresult = NULL;
#endif
/* sorry, fprintf(read_only_file, "") returns EOF, not 0 */
if (cantwrite(fp))
return (EOF);
@ -610,12 +606,8 @@ fp_begin: if (prec == -1)
break;
}
flags |= FPT;
if (dtoaresult != NULL) {
free(dtoaresult);
dtoaresult = NULL;
}
cp = cvt(_double, prec, flags, &softsign,
&expt, ch, &ndig, &dtoaresult);
&expt, ch, &ndig);
if (ch == 'g' || ch == 'G') {
if (expt <= -4 || expt > prec)
ch = (ch == 'g') ? 'e' : 'E';
@ -871,10 +863,6 @@ number: if ((dprec = prec) >= 0)
done:
FLUSH();
error:
#ifdef FLOATING_POINT
if (dtoaresult != NULL)
free(dtoaresult);
#endif
if (__sferror(fp))
ret = EOF;
if ((argtable != NULL) && (argtable != statargtable))
@ -1206,11 +1194,11 @@ __grow_type_table (int nextarg, unsigned char **typetable, int *tablesize)
#ifdef FLOATING_POINT
extern char *__dtoa __P((double, int, int, int *, int *, char **, char **));
extern char *__dtoa __P((double, int, int, int *, int *, char **));
static char *
cvt(double value, int ndigits, int flags, char *sign, int *decpt,
int ch, int *length, char **dtoaresultp)
int ch, int *length)
{
int mode, dsgn;
char *digits, *bp, *rve;
@ -1232,8 +1220,7 @@ cvt(double value, int ndigits, int flags, char *sign, int *decpt,
*sign = '-';
} else
*sign = '\000';
digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve,
dtoaresultp);
digits = __dtoa(value, mode, ndigits, decpt, &dsgn, &rve);
if ((ch != 'g' && ch != 'G') || flags & ALT) {
/* print trailing zeros */
bp = digits + ndigits;

View File

@ -142,7 +142,7 @@ __RCSID("$NetBSD: strtod.c,v 1.26 1998/02/03 18:44:21 perry Exp $");
#include "memory.h"
#endif
#endif
char *__dtoa __P((double, int, int, int *, int *, char **, char **));
char *__dtoa __P((double, int, int, int *, int *, char **));
#ifdef MALLOC
#ifdef KR_headers
@ -384,16 +384,6 @@ Bigint {
static Bigint *freelist[Kmax+1];
/*
* Make Balloc/Bfree thread-safe in libc for use with
* kernel threads.
*/
#include "libc_private.h"
#include "spinlock.h"
static spinlock_t thread_lock = _SPINLOCK_INITIALIZER;
#define THREAD_LOCK() if (__isthreaded) _SPINLOCK(&thread_lock);
#define THREAD_UNLOCK() if (__isthreaded) _SPINUNLOCK(&thread_lock);
static Bigint *
Balloc
#ifdef KR_headers
@ -405,13 +395,10 @@ Balloc
int x;
Bigint *rv;
THREAD_LOCK();
if ((rv = freelist[k]) != NULL) {
freelist[k] = rv->next;
THREAD_UNLOCK();
}
else {
THREAD_UNLOCK();
x = 1 << k;
rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long));
rv->k = k;
@ -430,10 +417,8 @@ Bfree
#endif
{
if (v) {
THREAD_LOCK();
v->next = freelist[v->k];
freelist[v->k] = v;
THREAD_UNLOCK();
}
}
@ -1915,11 +1900,10 @@ quorem
char *
__dtoa
#ifdef KR_headers
(d, mode, ndigits, decpt, sign, rve, resultp)
double d; int mode, ndigits, *decpt, *sign; char **rve, **resultp;
(d, mode, ndigits, decpt, sign, rve)
double d; int mode, ndigits, *decpt, *sign; char **rve;
#else
(double d, int mode, int ndigits, int *decpt, int *sign, char **rve,
char **resultp)
(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
#endif
{
/* Arguments ndigits, decpt, sign are similar to those
@ -1969,6 +1953,15 @@ __dtoa
Bigint *mlo = NULL; /* pacify gcc */
double d2, ds, eps;
char *s, *s0;
static Bigint *result;
static int result_k;
if (result) {
result->k = result_k;
result->maxwds = 1 << result_k;
Bfree(result);
result = 0;
}
if (word0(d) & Sign_bit) {
/* set sign for everything, including 0's and NaNs */
@ -2130,8 +2123,11 @@ __dtoa
if (i <= 0)
i = 1;
}
*resultp = (char *) malloc(i + 1);
s = s0 = *resultp;
j = sizeof(ULong);
for(result_k = 0; sizeof(Bigint) - sizeof(ULong) + j <= i;
j <<= 1) result_k++;
result = Balloc(result_k);
s = s0 = (char *)result;
if (ilim >= 0 && ilim <= Quick_max && try_quick) {

View File

@ -373,16 +373,6 @@ Bigint {
static Bigint *freelist[Kmax+1];
/*
* Make Balloc/Bfree thread-safe in libc for use with
* kernel threads.
*/
#include "libc_private.h"
#include "spinlock.h"
static spinlock_t thread_lock = _SPINLOCK_INITIALIZER;
#define THREAD_LOCK() if (__isthreaded) _SPINLOCK(&thread_lock);
#define THREAD_UNLOCK() if (__isthreaded) _SPINUNLOCK(&thread_lock);
static Bigint *
Balloc
#ifdef KR_headers
@ -394,12 +384,9 @@ Balloc
int x;
Bigint *rv;
THREAD_LOCK();
if ( (rv = freelist[k]) ) {
freelist[k] = rv->next;
THREAD_UNLOCK();
} else {
THREAD_UNLOCK();
x = 1 << k;
rv = (Bigint *)malloc(sizeof(Bigint) + (x-1)*sizeof(long));
rv->k = k;
@ -418,10 +405,8 @@ Bfree
#endif
{
if (v) {
THREAD_LOCK();
v->next = freelist[v->k];
freelist[v->k] = v;
THREAD_UNLOCK();
}
}
@ -1856,11 +1841,10 @@ quorem
char *
__dtoa
#ifdef KR_headers
(d, mode, ndigits, decpt, sign, rve, resultp)
double d; int mode, ndigits, *decpt, *sign; char **rve, **resultp;
(d, mode, ndigits, decpt, sign, rve)
double d; int mode, ndigits, *decpt, *sign; char **rve;
#else
(double d, int mode, int ndigits, int *decpt, int *sign, char **rve,
char **resultp)
(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
#endif
{
/* Arguments ndigits, decpt, sign are similar to those
@ -1908,6 +1892,15 @@ __dtoa
Bigint *b, *b1, *delta, *mlo, *mhi, *S;
double d2, ds, eps;
char *s, *s0;
static Bigint *result;
static int result_k;
if (result) {
result->k = result_k;
result->maxwds = 1 << result_k;
Bfree(result);
result = 0;
}
if (word0(d) & Sign_bit) {
/* set sign for everything, including 0's and NaNs */
@ -2066,8 +2059,11 @@ __dtoa
if (i <= 0)
i = 1;
}
*resultp = (char *) malloc(i + 1);
s = s0 = *resultp;
j = sizeof(unsigned long);
for (result_k = 0; sizeof(Bigint) - sizeof(unsigned long) + j < i;
j <<= 1) result_k++;
result = Balloc(result_k);
s = s0 = (char *)result;
if (ilim >= 0 && ilim <= Quick_max && try_quick) {