Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 6099 → Rev 6536

/contrib/sdk/sources/newlib/libc/stdlib/cxa_atexit.c
0,0 → 1,41
/*
* Implementation of __cxa_atexit.
*/
 
#include <stddef.h>
#include <stdlib.h>
#include <reent.h>
#include <sys/lock.h>
#include "atexit.h"
 
#ifdef _REENT_SMALL
 
#include "on_exit_args.h"
 
/* force linking of static instance of _on_exit_args */
const void * const __cxa_atexit_dummy = &__on_exit_args;
 
#endif /* def _REENT_SMALL */
 
/*
* Register a function to be performed at exit or DSO unload.
*/
 
int
_DEFUN (__cxa_atexit,
(fn, arg, d),
void (*fn) (void *) _AND
void *arg _AND
void *d)
{
#ifdef _LITE_EXIT
/* Refer to comments in __atexit.c for more details of lite exit. */
int __register_exitproc _PARAMS ((int, void (*fn) (void), _PTR, _PTR))
__attribute__ ((weak));
 
if (!__register_exitproc)
return 0;
else
#endif
return __register_exitproc (__et_cxa, (void (*)(void)) fn, arg, d);
}
/contrib/sdk/sources/newlib/libc/stdlib/cxa_finalize.c
0,0 → 1,20
/*
* Implementation if __cxa_finalize.
*/
 
 
#include <stdlib.h>
#include <reent.h>
#include "atexit.h"
 
/*
* Call registered exit handlers. If D is null then all handlers are called,
* otherwise only the handlers from that DSO are called.
*/
 
void
_DEFUN (__cxa_finalize, (d),
void * d)
{
__call_exitprocs (0, d);
}
/contrib/sdk/sources/newlib/libc/stdlib/drand48.c
0,0 → 1,30
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
*
* You may redistribute unmodified or modified versions of this source
* code provided that the above copyright notice and this and the
* following conditions are retained.
*
* This software is provided ``as is'', and comes with no warranties
* of any kind. I shall in no event be liable for anything that happens
* to anyone/anything when using this software.
*/
 
#include "rand48.h"
 
double
_DEFUN (_drand48_r, (r),
struct _reent *r)
{
_REENT_CHECK_RAND48(r);
return _erand48_r(r, __rand48_seed);
}
 
#ifndef _REENT_ONLY
double
_DEFUN_VOID (drand48)
{
return _drand48_r (_REENT);
}
#endif /* !_REENT_ONLY */
/contrib/sdk/sources/newlib/libc/stdlib/ecvtbuf.c
0,0 → 1,471
/*
FUNCTION
<<ecvtbuf>>, <<fcvtbuf>>---double or float to string
 
INDEX
ecvtbuf
INDEX
fcvtbuf
 
ANSI_SYNOPSIS
#include <stdio.h>
 
char *ecvtbuf(double <[val]>, int <[chars]>, int *<[decpt]>,
int *<[sgn]>, char *<[buf]>);
 
char *fcvtbuf(double <[val]>, int <[decimals]>, int *<[decpt]>,
int *<[sgn]>, char *<[buf]>);
 
TRAD_SYNOPSIS
#include <stdio.h>
 
char *ecvtbuf(<[val]>, <[chars]>, <[decpt]>, <[sgn]>, <[buf]>);
double <[val]>;
int <[chars]>;
int *<[decpt]>;
int *<[sgn]>;
char *<[buf]>;
 
char *fcvtbuf(<[val]>, <[decimals]>, <[decpt]>, <[sgn]>, <[buf]>);
double <[val]>;
int <[decimals]>;
int *<[decpt]>;
int *<[sgn]>;
char *<[buf]>;
 
DESCRIPTION
<<ecvtbuf>> and <<fcvtbuf>> produce (null-terminated) strings
of digits representating the <<double>> number <[val]>.
 
The only difference between <<ecvtbuf>> and <<fcvtbuf>> is the
interpretation of the second argument (<[chars]> or
<[decimals]>). For <<ecvtbuf>>, the second argument <[chars]>
specifies the total number of characters to write (which is
also the number of significant digits in the formatted string,
since these two functions write only digits). For <<fcvtbuf>>,
the second argument <[decimals]> specifies the number of
characters to write after the decimal point; all digits for
the integer part of <[val]> are always included.
 
Since <<ecvtbuf>> and <<fcvtbuf>> write only digits in the
output string, they record the location of the decimal point
in <<*<[decpt]>>>, and the sign of the number in <<*<[sgn]>>>.
After formatting a number, <<*<[decpt]>>> contains the number
of digits to the left of the decimal point. <<*<[sgn]>>>
contains <<0>> if the number is positive, and <<1>> if it is
negative. For both functions, you supply a pointer <[buf]> to
an area of memory to hold the converted string.
 
RETURNS
Both functions return a pointer to <[buf]>, the string
containing a character representation of <[val]>.
 
PORTABILITY
Neither function is ANSI C.
 
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
 
#include <_ansi.h>
#include <stdlib.h>
#include <string.h>
#include <reent.h>
#include "mprec.h"
#include "local.h"
 
static void
_DEFUN (print_f, (ptr, buf, invalue, ndigit, type, dot, mode),
struct _reent *ptr _AND
char *buf _AND
double invalue _AND
int ndigit _AND
char type _AND
int dot _AND
int mode)
{
int decpt;
int sign;
char *p, *start, *end;
 
start = p = _dtoa_r (ptr, invalue, mode, ndigit, &decpt, &sign, &end);
 
if (decpt == 9999)
{
strcpy (buf, p);
return;
}
while (*p && decpt > 0)
{
*buf++ = *p++;
decpt--;
}
/* Even if not in buffer */
while (decpt > 0)
{
*buf++ = '0';
decpt--;
}
 
if (dot || *p)
{
if (p == start)
*buf++ = '0';
*buf++ = '.';
while (decpt < 0 && ndigit > 0)
{
*buf++ = '0';
decpt++;
ndigit--;
}
 
/* Print rest of stuff */
while (*p && ndigit > 0)
{
*buf++ = *p++;
ndigit--;
}
/* And trailing zeros */
while (ndigit > 0)
{
*buf++ = '0';
ndigit--;
}
}
*buf++ = 0;
}
 
/* Print number in e format with width chars after.
 
TYPE is one of 'e' or 'E'. It may also be one of 'g' or 'G' indicating
that _gcvt is calling us and we should remove trailing zeroes.
 
WIDTH is the number of digits of precision after the decimal point. */
 
static void
_DEFUN (print_e, (ptr, buf, invalue, width, type, dot),
struct _reent *ptr _AND
char *buf _AND
double invalue _AND
int width _AND
char type _AND
int dot)
{
int sign;
char *end;
char *p;
int decpt;
int top;
int ndigit = width;
 
p = _dtoa_r (ptr, invalue, 2, width + 1, &decpt, &sign, &end);
 
if (decpt == 9999)
{
strcpy (buf, p);
return;
}
 
*buf++ = *p++;
if (dot || ndigit != 0)
*buf++ = '.';
 
while (*p && ndigit > 0)
{
*buf++ = *p++;
ndigit--;
}
 
/* Add trailing zeroes to fill out to ndigits unless this is 'g' format.
Also, convert g/G to e/E. */
 
if (type == 'g')
type = 'e';
else if (type == 'G')
type = 'E';
else
{
while (ndigit > 0)
{
*buf++ = '0';
ndigit--;
}
}
 
/* Add the exponent. */
 
*buf++ = type;
decpt--;
if (decpt < 0)
{
*buf++ = '-';
decpt = -decpt;
}
else
{
*buf++ = '+';
}
if (decpt > 99)
{
int top = decpt / 100;
*buf++ = top + '0';
decpt -= top * 100;
}
top = decpt / 10;
*buf++ = top + '0';
decpt -= top * 10;
*buf++ = decpt + '0';
 
*buf++ = 0;
}
 
#ifndef _REENT_ONLY
 
/* Undocumented behaviour: when given NULL as a buffer, return a
pointer to static space in the rent structure. This is only to
support ecvt and fcvt, which aren't ANSI anyway. */
 
char *
_DEFUN (fcvtbuf, (invalue, ndigit, decpt, sign, fcvt_buf),
double invalue _AND
int ndigit _AND
int *decpt _AND
int *sign _AND
char *fcvt_buf)
{
struct _reent *reent = _REENT;
char *save;
char *p;
char *end;
int done = 0;
 
if (fcvt_buf == NULL)
{
if (reent->_cvtlen <= ndigit + 35)
{
if ((fcvt_buf = (char *) _realloc_r (reent, reent->_cvtbuf,
ndigit + 36)) == NULL)
return NULL;
reent->_cvtlen = ndigit + 36;
reent->_cvtbuf = fcvt_buf;
}
 
fcvt_buf = reent->_cvtbuf ;
}
 
save = fcvt_buf;
 
if (invalue < 1.0 && invalue > -1.0)
{
p = _dtoa_r (reent, invalue, 2, ndigit, decpt, sign, &end);
}
else
{
p = _dtoa_r (reent, invalue, 3, ndigit, decpt, sign, &end);
}
 
/* Now copy */
 
done = -*decpt;
while (p < end)
{
*fcvt_buf++ = *p++;
done++;
}
/* And unsuppress the trailing zeroes */
while (done < ndigit)
{
*fcvt_buf++ = '0';
done++;
}
*fcvt_buf++ = 0;
return save;
}
 
char *
_DEFUN (ecvtbuf, (invalue, ndigit, decpt, sign, fcvt_buf),
double invalue _AND
int ndigit _AND
int *decpt _AND
int *sign _AND
char *fcvt_buf)
{
struct _reent *reent = _REENT;
char *save;
char *p;
char *end;
int done = 0;
 
if (fcvt_buf == NULL)
{
if (reent->_cvtlen <= ndigit)
{
if ((fcvt_buf = (char *) _realloc_r (reent, reent->_cvtbuf,
ndigit + 1)) == NULL)
return NULL;
reent->_cvtlen = ndigit + 1;
reent->_cvtbuf = fcvt_buf;
}
 
fcvt_buf = reent->_cvtbuf ;
}
 
save = fcvt_buf;
 
p = _dtoa_r (reent, invalue, 2, ndigit, decpt, sign, &end);
 
/* Now copy */
 
while (p < end)
{
*fcvt_buf++ = *p++;
done++;
}
/* And unsuppress the trailing zeroes */
while (done < ndigit)
{
*fcvt_buf++ = '0';
done++;
}
*fcvt_buf++ = 0;
return save;
}
 
#endif
 
char *
_DEFUN (_gcvt, (ptr, invalue, ndigit, buf, type, dot),
struct _reent *ptr _AND
double invalue _AND
int ndigit _AND
char *buf _AND
char type _AND
int dot)
{
char *save = buf;
 
if (invalue < 0)
{
invalue = -invalue;
}
 
if (invalue == 0)
{
*buf++ = '0';
*buf = '\0';
}
else
/* Which one to print ?
ANSI says that anything with more that 4 zeros after the . or more
than precision digits before is printed in e with the qualification
that trailing zeroes are removed from the fraction portion. */
 
if (0.0001 >= invalue || invalue >= _mprec_log10 (ndigit))
{
/* We subtract 1 from ndigit because in the 'e' format the precision is
the number of digits after the . but in 'g' format it is the number
of significant digits.
 
We defer changing type to e/E so that print_e() can know it's us
calling and thus should remove trailing zeroes. */
 
print_e (ptr, buf, invalue, ndigit - 1, type, dot);
}
else
{
int decpt;
int sign;
char *end;
char *p;
 
if (invalue < 1.0)
{
/* what we want is ndigits after the point */
p = _dtoa_r (ptr, invalue, 3, ndigit, &decpt, &sign, &end);
}
else
{
p = _dtoa_r (ptr, invalue, 2, ndigit, &decpt, &sign, &end);
}
 
if (decpt == 9999)
{
strcpy (buf, p);
return save;
}
while (*p && decpt > 0)
{
*buf++ = *p++;
decpt--;
ndigit--;
}
/* Even if not in buffer */
while (decpt > 0 && ndigit > 0)
{
*buf++ = '0';
decpt--;
ndigit--;
}
 
if (dot || *p)
{
if (buf == save)
*buf++ = '0';
*buf++ = '.';
while (decpt < 0 && ndigit > 0)
{
*buf++ = '0';
decpt++;
ndigit--;
}
 
/* Print rest of stuff */
while (*p && ndigit > 0)
{
*buf++ = *p++;
ndigit--;
}
/* And trailing zeros */
if (dot)
{
while (ndigit > 0)
{
*buf++ = '0';
ndigit--;
}
}
}
*buf++ = 0;
}
 
return save;
}
 
char *
_DEFUN (_dcvt, (ptr, buffer, invalue, precision, width, type, dot),
struct _reent *ptr _AND
char *buffer _AND
double invalue _AND
int precision _AND
int width _AND
char type _AND
int dot)
{
switch (type)
{
case 'f':
case 'F':
print_f (ptr, buffer, invalue, precision, type, precision == 0 ? dot : 1, 3);
break;
case 'g':
case 'G':
if (precision == 0)
precision = 1;
_gcvt (ptr, invalue, precision, buffer, type, dot);
break;
case 'e':
case 'E':
print_e (ptr, buffer, invalue, precision, type, dot);
}
return buffer;
}
/contrib/sdk/sources/newlib/libc/stdlib/efgcvt.c
0,0 → 1,208
/*
FUNCTION
<<ecvt>>, <<ecvtf>>, <<fcvt>>, <<fcvtf>>---double or float to string
 
INDEX
ecvt
INDEX
ecvtf
INDEX
fcvt
INDEX
fcvtf
 
ANSI_SYNOPSIS
#include <stdlib.h>
 
char *ecvt(double <[val]>, int <[chars]>, int *<[decpt]>, int *<[sgn]>);
char *ecvtf(float <[val]>, int <[chars]>, int *<[decpt]>, int *<[sgn]>);
 
char *fcvt(double <[val]>, int <[decimals]>,
int *<[decpt]>, int *<[sgn]>);
char *fcvtf(float <[val]>, int <[decimals]>,
int *<[decpt]>, int *<[sgn]>);
 
TRAD_SYNOPSIS
#include <stdlib.h>
 
char *ecvt(<[val]>, <[chars]>, <[decpt]>, <[sgn]>);
double <[val]>;
int <[chars]>;
int *<[decpt]>;
int *<[sgn]>;
char *ecvtf(<[val]>, <[chars]>, <[decpt]>, <[sgn]>);
float <[val]>;
int <[chars]>;
int *<[decpt]>;
int *<[sgn]>;
 
char *fcvt(<[val]>, <[decimals]>, <[decpt]>, <[sgn]>);
double <[val]>;
int <[decimals]>;
int *<[decpt]>;
int *<[sgn]>;
char *fcvtf(<[val]>, <[decimals]>, <[decpt]>, <[sgn]>);
float <[val]>;
int <[decimals]>;
int *<[decpt]>;
int *<[sgn]>;
 
DESCRIPTION
<<ecvt>> and <<fcvt>> produce (null-terminated) strings of digits
representating the <<double>> number <[val]>.
<<ecvtf>> and <<fcvtf>> produce the corresponding character
representations of <<float>> numbers.
 
(The <<stdlib>> functions <<ecvtbuf>> and <<fcvtbuf>> are reentrant
versions of <<ecvt>> and <<fcvt>>.)
 
The only difference between <<ecvt>> and <<fcvt>> is the
interpretation of the second argument (<[chars]> or <[decimals]>).
For <<ecvt>>, the second argument <[chars]> specifies the total number
of characters to write (which is also the number of significant digits
in the formatted string, since these two functions write only digits).
For <<fcvt>>, the second argument <[decimals]> specifies the number of
characters to write after the decimal point; all digits for the integer
part of <[val]> are always included.
 
Since <<ecvt>> and <<fcvt>> write only digits in the output string,
they record the location of the decimal point in <<*<[decpt]>>>, and
the sign of the number in <<*<[sgn]>>>. After formatting a number,
<<*<[decpt]>>> contains the number of digits to the left of the
decimal point. <<*<[sgn]>>> contains <<0>> if the number is positive,
and <<1>> if it is negative.
 
RETURNS
All four functions return a pointer to the new string containing a
character representation of <[val]>.
 
PORTABILITY
None of these functions are ANSI C.
 
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
 
NEWPAGE
FUNCTION
<<gcvt>>, <<gcvtf>>---format double or float as string
 
INDEX
gcvt
INDEX
gcvtf
 
ANSI_SYNOPSIS
#include <stdlib.h>
 
char *gcvt(double <[val]>, int <[precision]>, char *<[buf]>);
char *gcvtf(float <[val]>, int <[precision]>, char *<[buf]>);
 
TRAD_SYNOPSIS
#include <stdlib.h>
 
char *gcvt(<[val]>, <[precision]>, <[buf]>);
double <[val]>;
int <[precision]>;
char *<[buf]>;
char *gcvtf(<[val]>, <[precision]>, <[buf]>);
float <[val]>;
int <[precision]>;
char *<[buf]>;
 
DESCRIPTION
<<gcvt>> writes a fully formatted number as a null-terminated
string in the buffer <<*<[buf]>>>. <<gcvtf>> produces corresponding
character representations of <<float>> numbers.
 
<<gcvt>> uses the same rules as the <<printf>> format
`<<%.<[precision]>g>>'---only negative values are signed (with
`<<->>'), and either exponential or ordinary decimal-fraction format
is chosen depending on the number of significant digits (specified by
<[precision]>).
 
RETURNS
The result is a pointer to the formatted representation of <[val]>
(the same as the argument <[buf]>).
 
PORTABILITY
Neither function is ANSI C.
 
Supporting OS subroutines required: <<close>>, <<fstat>>, <<isatty>>,
<<lseek>>, <<read>>, <<sbrk>>, <<write>>.
*/
 
#define _XOPEN_SOURCE
#define _XOPEN_SOURCE_EXTENDED
#include <_ansi.h>
#include <reent.h>
#include <stdio.h>
#include <stdlib.h>
#include "local.h"
 
char *
_DEFUN (fcvt, (d, ndigit, decpt, sign),
double d _AND
int ndigit _AND
int *decpt _AND
int *sign)
{
return fcvtbuf (d, ndigit, decpt, sign, NULL);
}
 
char *
_DEFUN (fcvtf, (d, ndigit, decpt, sign),
float d _AND
int ndigit _AND
int *decpt _AND
int *sign)
{
return fcvt ((float) d, ndigit, decpt, sign);
}
 
 
char *
_DEFUN (gcvtf, (d, ndigit, buf),
float d _AND
int ndigit _AND
char *buf)
{
double asd = d;
return gcvt (asd, ndigit, buf);
}
 
 
char *
_DEFUN (ecvt, (d, ndigit, decpt, sign),
double d _AND
int ndigit _AND
int *decpt _AND
int *sign)
{
return ecvtbuf (d, ndigit, decpt, sign, NULL);
}
 
char *
_DEFUN (ecvtf, (d, ndigit, decpt, sign),
float d _AND
int ndigit _AND
int *decpt _AND
int *sign)
{
return ecvt ((double) d, ndigit, decpt, sign);
}
 
 
char *
_DEFUN (gcvt, (d, ndigit, buf),
double d _AND
int ndigit _AND
char *buf)
{
char *tbuf = buf;
if (d < 0) {
*buf = '-';
buf++;
ndigit--;
}
return (_gcvt (_REENT, d, ndigit, buf, 'g', 0) ? tbuf : 0);
}
/contrib/sdk/sources/newlib/libc/stdlib/eprintf.c
0,0 → 1,26
/* This is an implementation of the __eprintf function which is
compatible with the assert.h which is distributed with gcc.
 
This function is provided because in some cases libgcc.a will not
provide __eprintf. This will happen if inhibit_libc is defined,
which is done because at the time that libgcc2.c is compiled, the
correct <stdio.h> may not be available. newlib provides its own
copy of assert.h, which calls __assert, not __eprintf. However, in
some cases you may accidentally wind up compiling with the gcc
assert.h. In such a case, this __eprintf will be used if there
does not happen to be one in libgcc2.c. */
 
#include <stdlib.h>
#include <stdio.h>
 
void
__eprintf (format, file, line, expression)
const char *format;
const char *file;
unsigned int line;
const char *expression;
{
(void) fiprintf (stderr, format, file, line, expression);
abort ();
/*NOTREACHED*/
}
/contrib/sdk/sources/newlib/libc/stdlib/erand48.c
0,0 → 1,34
/*
* Copyright (c) 1993 Martin Birgmeier
* All rights reserved.
*
* You may redistribute unmodified or modified versions of this source
* code provided that the above copyright notice and this and the
* following conditions are retained.
*
* This software is provided ``as is'', and comes with no warranties
* of any kind. I shall in no event be liable for anything that happens
* to anyone/anything when using this software.
*/
 
#include "rand48.h"
 
double
_DEFUN (_erand48_r, (r, xseed),
struct _reent *r _AND
unsigned short xseed[3])
{
__dorand48(r, xseed);
return ldexp((double) xseed[0], -48) +
ldexp((double) xseed[1], -32) +
ldexp((double) xseed[2], -16);
}
 
#ifndef _REENT_ONLY
double
_DEFUN (erand48, (xseed),
unsigned short xseed[3])
{
return _erand48_r (_REENT, xseed);
}
#endif /* !_REENT_ONLY */
/contrib/sdk/sources/newlib/libc/stdlib/itoa.c
0,0 → 1,69
/*
FUNCTION
<<itoa>>---integer to string
 
INDEX
itoa
 
ANSI_SYNOPSIS
#include <stdlib.h>
char *itoa(int <[value]>, char *<[str]>, int <[base]>);
char *__itoa(int <[value]>, char *<[str]>, int <[base]>);
 
DESCRIPTION
<<itoa>> converts the integer <[value]> to a null-terminated string
using the specified base, which must be between 2 and 36, inclusive.
If <[base]> is 10, <[value]> is treated as signed and the string will be
prefixed with '-' if negative. For all other bases, <[value]> is treated as
unsigned. <[str]> should be an array long enough to contain the converted
value, which in the worst case is sizeof(int)*8+1 bytes.
 
RETURNS
A pointer to the string, <[str]>, or NULL if <[base]> is invalid.
 
PORTABILITY
<<itoa>> is non-ANSI.
 
No supporting OS subroutine calls are required.
*/
 
#include <stdlib.h>
 
char *
_DEFUN (__itoa, (value, str, base),
int value _AND
char *str _AND
int base)
{
unsigned uvalue;
int i = 0;
/* Check base is supported. */
if ((base < 2) || (base > 36))
{
str[0] = '\0';
return NULL;
}
/* Negative numbers are only supported for decimal.
* Cast to unsigned to avoid overflow for maximum negative value. */
if ((base == 10) && (value < 0))
{
str[i++] = '-';
uvalue = (unsigned)-value;
}
else
uvalue = (unsigned)value;
__utoa (uvalue, &str[i], base);
return str;
}
 
char *
_DEFUN (itoa, (value, str, base),
int value _AND
char *str _AND
int base)
{
return __itoa (value, str, base);
}
/contrib/sdk/sources/newlib/libc/stdlib/labs.c
0,0 → 1,49
/*
FUNCTION
<<labs>>---long integer absolute value
 
INDEX
labs
 
ANSI_SYNOPSIS
#include <stdlib.h>
long labs(long <[i]>);
 
TRAD_SYNOPSIS
#include <stdlib.h>
long labs(<[i]>)
long <[i]>;
 
DESCRIPTION
<<labs>> returns
@tex
$|x|$,
@end tex
the absolute value of <[i]> (also called the magnitude
of <[i]>). That is, if <[i]> is negative, the result is the opposite
of <[i]>, but if <[i]> is nonnegative the result is <[i]>.
 
The similar function <<abs>> uses and returns <<int>> rather than
<<long>> values.
 
RETURNS
The result is a nonnegative long integer.
 
PORTABILITY
<<labs>> is ANSI.
 
No supporting OS subroutine calls are required.
*/
 
#include <stdlib.h>
 
long
_DEFUN (labs, (x),
long x)
{
if (x < 0)
{
x = -x;
}
return x;
}
/contrib/sdk/sources/newlib/libc/stdlib/mallocr.c
382,7 → 382,7
size_t footprint;
size_t max_footprint;
flag_t mflags;
__libc_lock_recursive_t lock; /* locate lock among fields that rarely change */
_LOCK_RECURSIVE_T lock; /* locate lock among fields that rarely change */
msegment seg;
void* extp; /* Unused but available for extensions */
size_t exts;
425,11 → 425,11
 
__LOCK_INIT_RECURSIVE(static, malloc_global_mutex);
 
#define ACQUIRE_MALLOC_GLOBAL_LOCK() __libc_lock_lock_recursive(malloc_global_mutex);
#define RELEASE_MALLOC_GLOBAL_LOCK() __libc_lock_unlock_recursive(malloc_global_mutex);
#define ACQUIRE_MALLOC_GLOBAL_LOCK() __lock_acquire_recursive(malloc_global_mutex);
#define RELEASE_MALLOC_GLOBAL_LOCK() __lock_release_recursive(malloc_global_mutex);
 
#define PREACTION(M) ( __libc_lock_lock_recursive((M)->lock))
#define POSTACTION(M) { __libc_lock_unlock_recursive((M)->lock); }
#define PREACTION(M) ( __lock_acquire_recursive((M)->lock))
#define POSTACTION(M) { __lock_release_recursive((M)->lock); }
 
/* ---------------------------- Indexing Bins ---------------------------- */
 
991,7 → 991,7
 
/* Set up lock for main malloc area */
gm->mflags = mparams.default_mflags;
__libc_lock_init_recursive(gm->lock);
__lock_init_recursive(gm->lock);
 
magic = (size_t)(0x12345678 ^ (size_t)0x55555555U);
magic |= (size_t)8U; /* ensure nonzero */
/contrib/sdk/sources/newlib/libc/stdlib/strtold.c
30,6 → 30,8
 
#include <stdlib.h>
#include "local.h"
#include "mprec.h"
#undef FLT_ROUNDS
 
#ifdef _HAVE_LONG_DOUBLE
 
/contrib/sdk/sources/newlib/libc/stdlib/strtorx.c
88,7 → 88,8
 
case STRTOG_Infinite:
L[_0] = 0x7fff;
L[_1] = L[_2] = L[_3] = L[_4] = 0;
L[_1] = 0x8000;
L[_2] = L[_3] = L[_4] = 0;
break;
 
case STRTOG_NaN:
/contrib/sdk/sources/newlib/libc/stdlib/utoa.c
0,0 → 1,76
/*
FUNCTION
<<utoa>>---unsigned integer to string
 
INDEX
utoa
 
ANSI_SYNOPSIS
#include <stdlib.h>
char *utoa(unsigned <[value]>, char *<[str]>, int <[base]>);
char *__utoa(unsigned <[value]>, char *<[str]>, int <[base]>);
 
DESCRIPTION
<<utoa>> converts the unsigned integer [<value>] to a null-terminated string
using the specified base, which must be between 2 and 36, inclusive.
<[str]> should be an array long enough to contain the converted
value, which in the worst case is sizeof(int)*8+1 bytes.
 
RETURNS
A pointer to the string, <[str]>, or NULL if <[base]> is invalid.
 
PORTABILITY
<<utoa>> is non-ANSI.
 
No supporting OS subroutine calls are required.
*/
 
#include <stdlib.h>
 
char *
_DEFUN (__utoa, (value, str, base),
unsigned value _AND
char *str _AND
int base)
{
const char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
int i, j;
unsigned remainder;
char c;
/* Check base is supported. */
if ((base < 2) || (base > 36))
{
str[0] = '\0';
return NULL;
}
/* Convert to string. Digits are in reverse order. */
i = 0;
do
{
remainder = value % base;
str[i++] = digits[remainder];
value = value / base;
} while (value != 0);
str[i] = '\0';
/* Reverse string. */
for (j = 0, i--; j < i; j++, i--)
{
c = str[j];
str[j] = str[i];
str[i] = c;
}
return str;
}
 
char *
_DEFUN (utoa, (value, str, base),
unsigned value _AND
char *str _AND
int base)
{
return __utoa (value, str, base);
}