URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
Compare Revisions
- This comparison shows the changes necessary to convert path
/openrisc/tags/gnu-src/newlib-1.18.0/newlib-1.18.0-or32-1.0rc1/newlib/libc/stdlib
- from Rev 207 to Rev 345
- ↔ Reverse comparison
Rev 207 → Rev 345
/wcsnrtombs.c
0,0 → 1,185
/* |
FUNCTION |
<<wcsrtombs>>, <<wcsnrtombs>>---convert a wide-character string to a character string |
|
INDEX |
wcsrtombs |
INDEX |
_wcsrtombs_r |
INDEX |
wcsnrtombs |
INDEX |
_wcsnrtombs_r |
|
ANSI_SYNOPSIS |
#include <wchar.h> |
size_t wcsrtombs(char *<[dst]>, const wchar_t **<[src]>, size_t <[len]>, |
mbstate_t *<[ps]>); |
|
#include <wchar.h> |
size_t _wcsrtombs_r(struct _reent *<[ptr]>, char *<[dst]>, |
const wchar_t **<[src]>, size_t <[len]>, |
mbstate_t *<[ps]>); |
|
#include <wchar.h> |
size_t wcsnrtombs(char *<[dst]>, const wchar_t **<[src]>, |
size_t <[nwc]>, size_t <[len]>, mbstate_t *<[ps]>); |
|
#include <wchar.h> |
size_t _wcsnrtombs_r(struct _reent *<[ptr]>, char *<[dst]>, |
const wchar_t **<[src]>, size_t <[nwc]>, |
size_t <[len]>, mbstate_t *<[ps]>); |
|
TRAD_SYNOPSIS |
#include <wchar.h> |
size_t wcsrtombs(<[dst]>, <[src]>, <[len]>, <[ps]>) |
char *<[dst]>; |
const wchar_t **<[src]>; |
size_t <[len]>; |
mbstate_t *<[ps]>; |
|
#include <wchar.h> |
size_t _wcsrtombs_r(<[ptr]>, <[dst]>, <[src]>, <[len]>, <[ps]>) |
struct _rent *<[ptr]>; |
char *<[dst]>; |
const wchar_t **<[src]>; |
size_t <[len]>; |
mbstate_t *<[ps]>; |
|
#include <wchar.h> |
size_t wcsnrtombs(<[dst]>, <[src]>, <[nwc]>, <[len]>, <[ps]>) |
char *<[dst]>; |
const wchar_t **<[src]>; |
size_t <[nwc]>; |
size_t <[len]>; |
mbstate_t *<[ps]>; |
|
#include <wchar.h> |
size_t _wcsnrtombs_r(<[ptr]>, <[dst]>, <[src]>, <[nwc]>, <[len]>, <[ps]>) |
struct _rent *<[ptr]>; |
char *<[dst]>; |
const wchar_t **<[src]>; |
size_t <[nwc]>; |
size_t <[len]>; |
mbstate_t *<[ps]>; |
|
DESCRIPTION |
The <<wcsrtombs>> function converts a string of wide characters indirectly |
pointed to by <[src]> to a corresponding multibyte character string stored in |
the array pointed to by <[dst}>. No more than <[len]> bytes are written to |
<[dst}>. |
|
If <[dst}> is NULL, no characters are stored. |
|
If <[dst}> is not NULL, the pointer pointed to by <[src]> is updated to point |
to the character after the one that conversion stopped at. If conversion |
stops because a null character is encountered, *<[src]> is set to NULL. |
|
The mbstate_t argument, <[ps]>, is used to keep track of the shift state. If |
it is NULL, <<wcsrtombs>> uses an internal, static mbstate_t object, which |
is initialized to the initial conversion state at program startup. |
|
The <<wcsnrtombs>> function behaves identically to <<wcsrtombs>>, except that |
conversion stops after reading at most <[nwc]> characters from the buffer |
pointed to by <[src]>. |
|
RETURNS |
The <<wcsrtombs>> and <<wcsnrtombs>> functions return the number of bytes |
stored in the array pointed to by <[dst]> (not including any terminating |
null), if successful, otherwise it returns (size_t)-1. |
|
PORTABILITY |
<<wcsrtombs>> is defined by C99 standard. |
<<wcsnrtombs>> is defined by the POSIX.1-2008 standard. |
*/ |
|
#include <reent.h> |
#include <newlib.h> |
#include <wchar.h> |
#include <stdlib.h> |
#include <stdio.h> |
#include <errno.h> |
#include "local.h" |
|
size_t |
_DEFUN (_wcsnrtombs_r, (r, dst, src, nwc, len, ps), |
struct _reent *r _AND |
char *dst _AND |
const wchar_t **src _AND |
size_t nwc _AND |
size_t len _AND |
mbstate_t *ps) |
{ |
char *ptr = dst; |
char buff[10]; |
wchar_t *pwcs; |
size_t n; |
int i; |
|
#ifdef _MB_CAPABLE |
if (ps == NULL) |
{ |
_REENT_CHECK_MISC(r); |
ps = &(_REENT_WCSRTOMBS_STATE(r)); |
} |
#endif |
|
/* If no dst pointer, treat len as maximum possible value. */ |
if (dst == NULL) |
len = (size_t)-1; |
|
n = 0; |
pwcs = (wchar_t *)(*src); |
|
while (n < len && nwc-- > 0) |
{ |
int count = ps->__count; |
wint_t wch = ps->__value.__wch; |
int bytes = __wctomb (r, buff, *pwcs, __locale_charset (), ps); |
if (bytes == -1) |
{ |
r->_errno = EILSEQ; |
ps->__count = 0; |
return (size_t)-1; |
} |
if (n + bytes <= len) |
{ |
n += bytes; |
if (dst) |
{ |
for (i = 0; i < bytes; ++i) |
*ptr++ = buff[i]; |
++(*src); |
} |
if (*pwcs++ == 0x00) |
{ |
if (dst) |
*src = NULL; |
ps->__count = 0; |
return n - 1; |
} |
} |
else |
{ |
/* not enough room, we must back up state to before __wctomb call */ |
ps->__count = count; |
ps->__value.__wch = wch; |
len = 0; |
} |
} |
|
return n; |
} |
|
#ifndef _REENT_ONLY |
size_t |
_DEFUN (wcsnrtombs, (dst, src, nwc, len, ps), |
char *dst _AND |
const wchar_t **src _AND |
size_t nwc _AND |
size_t len _AND |
mbstate_t *ps) |
{ |
return _wcsnrtombs_r (_REENT, dst, src, nwc, len, ps); |
} |
#endif /* !_REENT_ONLY */ |
wcsnrtombs.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: Makefile.in
===================================================================
--- Makefile.in (nonexistent)
+++ Makefile.in (revision 345)
@@ -0,0 +1,1426 @@
+# Makefile.in generated by automake 1.11 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@HAVE_LONG_DOUBLE_TRUE@am__append_1 = \
+@HAVE_LONG_DOUBLE_TRUE@ strtold.c \
+@HAVE_LONG_DOUBLE_TRUE@ wcstold.c
+
+DIST_COMMON = $(srcdir)/../../Makefile.shared $(srcdir)/Makefile.in \
+ $(srcdir)/Makefile.am
+subdir = stdlib
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/../../libtool.m4 \
+ $(top_srcdir)/../../ltoptions.m4 \
+ $(top_srcdir)/../../ltsugar.m4 \
+ $(top_srcdir)/../../ltversion.m4 \
+ $(top_srcdir)/../../lt~obsolete.m4 \
+ $(top_srcdir)/../acinclude.m4 $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/../../mkinstalldirs
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+lib_a_AR = $(AR) $(ARFLAGS)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__DEPENDENCIES_1 = $(ELIX_2_OBJS)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@am__DEPENDENCIES_1 = $(ELIX_2_OBJS)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@am__DEPENDENCIES_1 = \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ $(ELIX_2_OBJS)
+@HAVE_LONG_DOUBLE_TRUE@am__objects_1 = lib_a-strtold.$(OBJEXT) \
+@HAVE_LONG_DOUBLE_TRUE@ lib_a-wcstold.$(OBJEXT)
+am__objects_2 = lib_a-__adjust.$(OBJEXT) lib_a-__atexit.$(OBJEXT) \
+ lib_a-__call_atexit.$(OBJEXT) lib_a-__exp10.$(OBJEXT) \
+ lib_a-__ten_mu.$(OBJEXT) lib_a-_Exit.$(OBJEXT) \
+ lib_a-abort.$(OBJEXT) lib_a-abs.$(OBJEXT) \
+ lib_a-assert.$(OBJEXT) lib_a-atexit.$(OBJEXT) \
+ lib_a-atof.$(OBJEXT) lib_a-atoff.$(OBJEXT) \
+ lib_a-atoi.$(OBJEXT) lib_a-atol.$(OBJEXT) \
+ lib_a-calloc.$(OBJEXT) lib_a-div.$(OBJEXT) \
+ lib_a-dtoa.$(OBJEXT) lib_a-dtoastub.$(OBJEXT) \
+ lib_a-environ.$(OBJEXT) lib_a-envlock.$(OBJEXT) \
+ lib_a-eprintf.$(OBJEXT) lib_a-exit.$(OBJEXT) \
+ lib_a-gdtoa-gethex.$(OBJEXT) lib_a-gdtoa-hexnan.$(OBJEXT) \
+ lib_a-getenv.$(OBJEXT) lib_a-getenv_r.$(OBJEXT) \
+ lib_a-labs.$(OBJEXT) lib_a-ldiv.$(OBJEXT) \
+ lib_a-ldtoa.$(OBJEXT) lib_a-malloc.$(OBJEXT) \
+ lib_a-mblen.$(OBJEXT) lib_a-mblen_r.$(OBJEXT) \
+ lib_a-mbstowcs.$(OBJEXT) lib_a-mbstowcs_r.$(OBJEXT) \
+ lib_a-mbtowc.$(OBJEXT) lib_a-mbtowc_r.$(OBJEXT) \
+ lib_a-mlock.$(OBJEXT) lib_a-mprec.$(OBJEXT) \
+ lib_a-mstats.$(OBJEXT) lib_a-rand.$(OBJEXT) \
+ lib_a-rand_r.$(OBJEXT) lib_a-realloc.$(OBJEXT) \
+ lib_a-reallocf.$(OBJEXT) lib_a-sb_charsets.$(OBJEXT) \
+ lib_a-strtod.$(OBJEXT) lib_a-strtol.$(OBJEXT) \
+ lib_a-strtoul.$(OBJEXT) lib_a-wcstod.$(OBJEXT) \
+ lib_a-wcstol.$(OBJEXT) lib_a-wcstoul.$(OBJEXT) \
+ lib_a-wcstombs.$(OBJEXT) lib_a-wcstombs_r.$(OBJEXT) \
+ lib_a-wctomb.$(OBJEXT) lib_a-wctomb_r.$(OBJEXT) \
+ $(am__objects_1)
+am__objects_3 = lib_a-cxa_atexit.$(OBJEXT) \
+ lib_a-cxa_finalize.$(OBJEXT) lib_a-drand48.$(OBJEXT) \
+ lib_a-ecvtbuf.$(OBJEXT) lib_a-efgcvt.$(OBJEXT) \
+ lib_a-erand48.$(OBJEXT) lib_a-jrand48.$(OBJEXT) \
+ lib_a-lcong48.$(OBJEXT) lib_a-lrand48.$(OBJEXT) \
+ lib_a-mrand48.$(OBJEXT) lib_a-msize.$(OBJEXT) \
+ lib_a-mtrim.$(OBJEXT) lib_a-nrand48.$(OBJEXT) \
+ lib_a-rand48.$(OBJEXT) lib_a-seed48.$(OBJEXT) \
+ lib_a-srand48.$(OBJEXT) lib_a-strtoll.$(OBJEXT) \
+ lib_a-strtoll_r.$(OBJEXT) lib_a-strtoull.$(OBJEXT) \
+ lib_a-strtoull_r.$(OBJEXT) lib_a-wcstoll.$(OBJEXT) \
+ lib_a-wcstoll_r.$(OBJEXT) lib_a-wcstoull.$(OBJEXT) \
+ lib_a-wcstoull_r.$(OBJEXT) lib_a-atoll.$(OBJEXT) \
+ lib_a-llabs.$(OBJEXT) lib_a-lldiv.$(OBJEXT)
+am__objects_4 = lib_a-a64l.$(OBJEXT) lib_a-btowc.$(OBJEXT) \
+ lib_a-getopt.$(OBJEXT) lib_a-getsubopt.$(OBJEXT) \
+ lib_a-l64a.$(OBJEXT) lib_a-malign.$(OBJEXT) \
+ lib_a-mbrlen.$(OBJEXT) lib_a-mbrtowc.$(OBJEXT) \
+ lib_a-mbsinit.$(OBJEXT) lib_a-mbsnrtowcs.$(OBJEXT) \
+ lib_a-mbsrtowcs.$(OBJEXT) lib_a-on_exit.$(OBJEXT) \
+ lib_a-valloc.$(OBJEXT) lib_a-wcrtomb.$(OBJEXT) \
+ lib_a-wcsnrtombs.$(OBJEXT) lib_a-wcsrtombs.$(OBJEXT) \
+ lib_a-wctob.$(OBJEXT)
+am__objects_5 = lib_a-putenv.$(OBJEXT) lib_a-putenv_r.$(OBJEXT) \
+ lib_a-setenv.$(OBJEXT) lib_a-setenv_r.$(OBJEXT)
+am__objects_6 = lib_a-system.$(OBJEXT)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_7 = $(am__objects_4) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_5) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_6)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@am__objects_7 = $(am__objects_4) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ $(am__objects_5)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@am__objects_7 = \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ $(am__objects_4)
+@USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_2) \
+@USE_LIBTOOL_FALSE@ $(am__objects_3) $(am__objects_7)
+lib_a_OBJECTS = $(am_lib_a_OBJECTS)
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+@HAVE_LONG_DOUBLE_TRUE@am__objects_8 = strtold.lo wcstold.lo
+am__objects_9 = __adjust.lo __atexit.lo __call_atexit.lo __exp10.lo \
+ __ten_mu.lo _Exit.lo abort.lo abs.lo assert.lo atexit.lo \
+ atof.lo atoff.lo atoi.lo atol.lo calloc.lo div.lo dtoa.lo \
+ dtoastub.lo environ.lo envlock.lo eprintf.lo exit.lo \
+ gdtoa-gethex.lo gdtoa-hexnan.lo getenv.lo getenv_r.lo labs.lo \
+ ldiv.lo ldtoa.lo malloc.lo mblen.lo mblen_r.lo mbstowcs.lo \
+ mbstowcs_r.lo mbtowc.lo mbtowc_r.lo mlock.lo mprec.lo \
+ mstats.lo rand.lo rand_r.lo realloc.lo reallocf.lo \
+ sb_charsets.lo strtod.lo strtol.lo strtoul.lo wcstod.lo \
+ wcstol.lo wcstoul.lo wcstombs.lo wcstombs_r.lo wctomb.lo \
+ wctomb_r.lo $(am__objects_8)
+am__objects_10 = cxa_atexit.lo cxa_finalize.lo drand48.lo ecvtbuf.lo \
+ efgcvt.lo erand48.lo jrand48.lo lcong48.lo lrand48.lo \
+ mrand48.lo msize.lo mtrim.lo nrand48.lo rand48.lo seed48.lo \
+ srand48.lo strtoll.lo strtoll_r.lo strtoull.lo strtoull_r.lo \
+ wcstoll.lo wcstoll_r.lo wcstoull.lo wcstoull_r.lo atoll.lo \
+ llabs.lo lldiv.lo
+am__objects_11 = a64l.lo btowc.lo getopt.lo getsubopt.lo l64a.lo \
+ malign.lo mbrlen.lo mbrtowc.lo mbsinit.lo mbsnrtowcs.lo \
+ mbsrtowcs.lo on_exit.lo valloc.lo wcrtomb.lo wcsnrtombs.lo \
+ wcsrtombs.lo wctob.lo
+am__objects_12 = putenv.lo putenv_r.lo setenv.lo setenv_r.lo
+am__objects_13 = system.lo
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@am__objects_14 = $(am__objects_11) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_12) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ $(am__objects_13)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@am__objects_14 = $(am__objects_11) \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ $(am__objects_12)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@am__objects_14 = \
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ $(am__objects_11)
+@USE_LIBTOOL_TRUE@am_libstdlib_la_OBJECTS = $(am__objects_9) \
+@USE_LIBTOOL_TRUE@ $(am__objects_10) $(am__objects_14)
+libstdlib_la_OBJECTS = $(am_libstdlib_la_OBJECTS)
+libstdlib_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(libstdlib_la_LDFLAGS) $(LDFLAGS) -o $@
+@USE_LIBTOOL_TRUE@am_libstdlib_la_rpath =
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp =
+am__depfiles_maybe =
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+SOURCES = $(lib_a_SOURCES) $(libstdlib_la_SOURCES)
+DATA = $(noinst_DATA)
+ETAGS = etags
+CTAGS = ctags
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AS = @AS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CRT0 = @CRT0@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBC_EXTRA_DEF = @LIBC_EXTRA_DEF@
+LIBC_EXTRA_LIB = @LIBC_EXTRA_LIB@
+LIBC_MACHINE_LIB = @LIBC_MACHINE_LIB@
+LIBC_POSIX_LIB = @LIBC_POSIX_LIB@
+LIBC_SIGNAL_DEF = @LIBC_SIGNAL_DEF@
+LIBC_SIGNAL_LIB = @LIBC_SIGNAL_LIB@
+LIBC_STDIO64_DEF = @LIBC_STDIO64_DEF@
+LIBC_STDIO64_LIB = @LIBC_STDIO64_LIB@
+LIBC_STDIO_DEF = @LIBC_STDIO_DEF@
+LIBC_STDIO_LIB = @LIBC_STDIO_LIB@
+LIBC_SYSCALL_LIB = @LIBC_SYSCALL_LIB@
+LIBC_SYS_LIB = @LIBC_SYS_LIB@
+LIBC_UNIX_LIB = @LIBC_UNIX_LIB@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NEWLIB_CFLAGS = @NEWLIB_CFLAGS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+READELF = @READELF@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+aext = @aext@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+extra_dir = @extra_dir@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+libm_machine_dir = @libm_machine_dir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lpfx = @lpfx@
+lt_ECHO = @lt_ECHO@
+machine_dir = @machine_dir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+newlib_basedir = @newlib_basedir@
+oext = @oext@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sys_dir = @sys_dir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = cygnus
+INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+GENERAL_SOURCES = __adjust.c __atexit.c __call_atexit.c __exp10.c \
+ __ten_mu.c _Exit.c abort.c abs.c assert.c atexit.c atof.c \
+ atoff.c atoi.c atol.c calloc.c div.c dtoa.c dtoastub.c \
+ environ.c envlock.c eprintf.c exit.c gdtoa-gethex.c \
+ gdtoa-hexnan.c getenv.c getenv_r.c labs.c ldiv.c ldtoa.c \
+ malloc.c mblen.c mblen_r.c mbstowcs.c mbstowcs_r.c mbtowc.c \
+ mbtowc_r.c mlock.c mprec.c mstats.c rand.c rand_r.c realloc.c \
+ reallocf.c sb_charsets.c strtod.c strtol.c strtoul.c wcstod.c \
+ wcstol.c wcstoul.c wcstombs.c wcstombs_r.c wctomb.c wctomb_r.c \
+ $(am__append_1)
+EXTENDED_SOURCES = \
+ cxa_atexit.c \
+ cxa_finalize.c \
+ drand48.c \
+ ecvtbuf.c \
+ efgcvt.c \
+ erand48.c \
+ jrand48.c \
+ lcong48.c \
+ lrand48.c \
+ mrand48.c \
+ msize.c \
+ mtrim.c \
+ nrand48.c \
+ rand48.c \
+ seed48.c \
+ srand48.c \
+ strtoll.c \
+ strtoll_r.c \
+ strtoull.c \
+ strtoull_r.c \
+ wcstoll.c \
+ wcstoll_r.c \
+ wcstoull.c \
+ wcstoull_r.c \
+ atoll.c \
+ llabs.c \
+ lldiv.c
+
+ELIX_2_SOURCES = \
+ a64l.c \
+ btowc.c \
+ getopt.c \
+ getsubopt.c \
+ l64a.c \
+ malign.c \
+ mbrlen.c \
+ mbrtowc.c \
+ mbsinit.c \
+ mbsnrtowcs.c \
+ mbsrtowcs.c \
+ on_exit.c \
+ valloc.c \
+ wcrtomb.c \
+ wcsnrtombs.c \
+ wcsrtombs.c \
+ wctob.c
+
+ELIX_2_OBJS = \
+ $(lpfx)malignr.$(oext) \
+ $(lpfx)malloptr.$(oext) \
+ $(lpfx)pvallocr.$(oext) \
+ $(lpfx)vallocr.$(oext)
+
+ELIX_3_SOURCES = \
+ putenv.c \
+ putenv_r.c \
+ setenv.c \
+ setenv_r.c
+
+ELIX_4_SOURCES = \
+ system.c
+
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ELIX_SOURCES = $(ELIX_2_SOURCES) $(ELIX_3_SOURCES) $(ELIX_4_SOURCES)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ELIX_SOURCES = $(ELIX_2_SOURCES) $(ELIX_3_SOURCES)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ELIX_SOURCES = $(ELIX_2_SOURCES)
+@ELIX_LEVEL_1_TRUE@ELIX_SOURCES =
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_FALSE@ELIX_OBJS = $(ELIX_2_OBJS)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_FALSE@@ELIX_LEVEL_3_TRUE@ELIX_OBJS = $(ELIX_2_OBJS)
+@ELIX_LEVEL_1_FALSE@@ELIX_LEVEL_2_TRUE@ELIX_OBJS = $(ELIX_2_OBJS)
+@ELIX_LEVEL_1_TRUE@ELIX_OBJS =
+
+# Because of how libtool moves objects around, mallocr must be built last.
+LIBADD_OBJS = $(lpfx)freer.$(oext) $(lpfx)reallocr.$(oext) \
+ $(lpfx)callocr.$(oext) $(lpfx)cfreer.$(oext) \
+ $(lpfx)mallinfor.$(oext) $(lpfx)mallstatsr.$(oext) \
+ $(lpfx)msizer.$(oext) $(lpfx)mallocr.$(oext)
+
+libstdlib_la_LDFLAGS = -Xcompiler -nostdlib
+@USE_LIBTOOL_TRUE@noinst_LTLIBRARIES = libstdlib.la
+@USE_LIBTOOL_TRUE@libstdlib_la_SOURCES = $(GENERAL_SOURCES) $(EXTENDED_SOURCES) $(ELIX_SOURCES)
+@USE_LIBTOOL_TRUE@libstdlib_la_LIBADD = $(LIBADD_OBJS) $(ELIX_OBJS)
+@USE_LIBTOOL_TRUE@libstdlib_la_DEPENDENCIES = $(LIBADD_OBJS) $(ELIX_OBJS)
+@USE_LIBTOOL_FALSE@LIB_COMPILE = $(COMPILE)
+@USE_LIBTOOL_TRUE@LIB_COMPILE = $(LTCOMPILE)
+@USE_LIBTOOL_FALSE@noinst_DATA =
+@USE_LIBTOOL_TRUE@noinst_DATA = objectlist.awk.in
+@USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a
+@USE_LIBTOOL_FALSE@lib_a_SOURCES = $(GENERAL_SOURCES) $(EXTENDED_SOURCES) $(ELIX_SOURCES)
+@USE_LIBTOOL_FALSE@lib_a_LIBADD = $(LIBADD_OBJS) $(ELIX_OBJS)
+@USE_LIBTOOL_FALSE@lib_a_CFLAGS = $(AM_CFLAGS)
+@USE_LIBTOOL_FALSE@lib_a_DEPENDENCIES = $(LIBADD_OBJS) $(ELIX_OBJS)
+MALLOC_COMPILE = $(LIB_COMPILE) -DINTERNAL_NEWLIB
+CHEWOUT_FILES = \
+ _Exit.def \
+ a64l.def \
+ abort.def \
+ abs.def \
+ assert.def \
+ atexit.def \
+ atof.def \
+ atoi.def \
+ atoll.def \
+ calloc.def \
+ div.def \
+ ecvtbuf.def \
+ efgcvt.def \
+ envlock.def \
+ exit.def \
+ getenv.def \
+ labs.def \
+ ldiv.def \
+ llabs.def \
+ lldiv.def \
+ malloc.def \
+ mallocr.def \
+ mblen.def \
+ mbsnrtowcs.def \
+ mbstowcs.def \
+ mbtowc.def \
+ mlock.def \
+ mstats.def \
+ on_exit.def \
+ rand.def \
+ rand48.def \
+ strtod.def \
+ strtol.def \
+ strtoll.def \
+ strtoul.def \
+ strtoull.def \
+ wcsnrtombs.def \
+ wcstod.def \
+ wcstol.def \
+ wcstoll.def \
+ wcstoul.def \
+ wcstoull.def \
+ system.def \
+ wcstombs.def \
+ wctomb.def
+
+SUFFIXES = .def
+CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
+TARGETDOC = ../tmp.texi
+CLEANFILES = $(CHEWOUT_FILES) *.ref
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .def .c .lo .o .obj
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(srcdir)/../../Makefile.shared $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --cygnus stdlib/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --cygnus stdlib/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+ -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+lib.a: $(lib_a_OBJECTS) $(lib_a_DEPENDENCIES)
+ -rm -f lib.a
+ $(lib_a_AR) lib.a $(lib_a_OBJECTS) $(lib_a_LIBADD)
+ $(RANLIB) lib.a
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libstdlib.la: $(libstdlib_la_OBJECTS) $(libstdlib_la_DEPENDENCIES)
+ $(libstdlib_la_LINK) $(am_libstdlib_la_rpath) $(libstdlib_la_OBJECTS) $(libstdlib_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+.c.o:
+ $(COMPILE) -c $<
+
+.c.obj:
+ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+ $(LTCOMPILE) -c -o $@ $<
+
+lib_a-__adjust.o: __adjust.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-__adjust.o `test -f '__adjust.c' || echo '$(srcdir)/'`__adjust.c
+
+lib_a-__adjust.obj: __adjust.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-__adjust.obj `if test -f '__adjust.c'; then $(CYGPATH_W) '__adjust.c'; else $(CYGPATH_W) '$(srcdir)/__adjust.c'; fi`
+
+lib_a-__atexit.o: __atexit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-__atexit.o `test -f '__atexit.c' || echo '$(srcdir)/'`__atexit.c
+
+lib_a-__atexit.obj: __atexit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-__atexit.obj `if test -f '__atexit.c'; then $(CYGPATH_W) '__atexit.c'; else $(CYGPATH_W) '$(srcdir)/__atexit.c'; fi`
+
+lib_a-__call_atexit.o: __call_atexit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-__call_atexit.o `test -f '__call_atexit.c' || echo '$(srcdir)/'`__call_atexit.c
+
+lib_a-__call_atexit.obj: __call_atexit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-__call_atexit.obj `if test -f '__call_atexit.c'; then $(CYGPATH_W) '__call_atexit.c'; else $(CYGPATH_W) '$(srcdir)/__call_atexit.c'; fi`
+
+lib_a-__exp10.o: __exp10.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-__exp10.o `test -f '__exp10.c' || echo '$(srcdir)/'`__exp10.c
+
+lib_a-__exp10.obj: __exp10.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-__exp10.obj `if test -f '__exp10.c'; then $(CYGPATH_W) '__exp10.c'; else $(CYGPATH_W) '$(srcdir)/__exp10.c'; fi`
+
+lib_a-__ten_mu.o: __ten_mu.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-__ten_mu.o `test -f '__ten_mu.c' || echo '$(srcdir)/'`__ten_mu.c
+
+lib_a-__ten_mu.obj: __ten_mu.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-__ten_mu.obj `if test -f '__ten_mu.c'; then $(CYGPATH_W) '__ten_mu.c'; else $(CYGPATH_W) '$(srcdir)/__ten_mu.c'; fi`
+
+lib_a-_Exit.o: _Exit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-_Exit.o `test -f '_Exit.c' || echo '$(srcdir)/'`_Exit.c
+
+lib_a-_Exit.obj: _Exit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-_Exit.obj `if test -f '_Exit.c'; then $(CYGPATH_W) '_Exit.c'; else $(CYGPATH_W) '$(srcdir)/_Exit.c'; fi`
+
+lib_a-abort.o: abort.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-abort.o `test -f 'abort.c' || echo '$(srcdir)/'`abort.c
+
+lib_a-abort.obj: abort.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-abort.obj `if test -f 'abort.c'; then $(CYGPATH_W) 'abort.c'; else $(CYGPATH_W) '$(srcdir)/abort.c'; fi`
+
+lib_a-abs.o: abs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-abs.o `test -f 'abs.c' || echo '$(srcdir)/'`abs.c
+
+lib_a-abs.obj: abs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-abs.obj `if test -f 'abs.c'; then $(CYGPATH_W) 'abs.c'; else $(CYGPATH_W) '$(srcdir)/abs.c'; fi`
+
+lib_a-assert.o: assert.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-assert.o `test -f 'assert.c' || echo '$(srcdir)/'`assert.c
+
+lib_a-assert.obj: assert.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-assert.obj `if test -f 'assert.c'; then $(CYGPATH_W) 'assert.c'; else $(CYGPATH_W) '$(srcdir)/assert.c'; fi`
+
+lib_a-atexit.o: atexit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atexit.o `test -f 'atexit.c' || echo '$(srcdir)/'`atexit.c
+
+lib_a-atexit.obj: atexit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atexit.obj `if test -f 'atexit.c'; then $(CYGPATH_W) 'atexit.c'; else $(CYGPATH_W) '$(srcdir)/atexit.c'; fi`
+
+lib_a-atof.o: atof.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atof.o `test -f 'atof.c' || echo '$(srcdir)/'`atof.c
+
+lib_a-atof.obj: atof.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atof.obj `if test -f 'atof.c'; then $(CYGPATH_W) 'atof.c'; else $(CYGPATH_W) '$(srcdir)/atof.c'; fi`
+
+lib_a-atoff.o: atoff.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atoff.o `test -f 'atoff.c' || echo '$(srcdir)/'`atoff.c
+
+lib_a-atoff.obj: atoff.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atoff.obj `if test -f 'atoff.c'; then $(CYGPATH_W) 'atoff.c'; else $(CYGPATH_W) '$(srcdir)/atoff.c'; fi`
+
+lib_a-atoi.o: atoi.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atoi.o `test -f 'atoi.c' || echo '$(srcdir)/'`atoi.c
+
+lib_a-atoi.obj: atoi.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atoi.obj `if test -f 'atoi.c'; then $(CYGPATH_W) 'atoi.c'; else $(CYGPATH_W) '$(srcdir)/atoi.c'; fi`
+
+lib_a-atol.o: atol.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atol.o `test -f 'atol.c' || echo '$(srcdir)/'`atol.c
+
+lib_a-atol.obj: atol.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atol.obj `if test -f 'atol.c'; then $(CYGPATH_W) 'atol.c'; else $(CYGPATH_W) '$(srcdir)/atol.c'; fi`
+
+lib_a-calloc.o: calloc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-calloc.o `test -f 'calloc.c' || echo '$(srcdir)/'`calloc.c
+
+lib_a-calloc.obj: calloc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-calloc.obj `if test -f 'calloc.c'; then $(CYGPATH_W) 'calloc.c'; else $(CYGPATH_W) '$(srcdir)/calloc.c'; fi`
+
+lib_a-div.o: div.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-div.o `test -f 'div.c' || echo '$(srcdir)/'`div.c
+
+lib_a-div.obj: div.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-div.obj `if test -f 'div.c'; then $(CYGPATH_W) 'div.c'; else $(CYGPATH_W) '$(srcdir)/div.c'; fi`
+
+lib_a-dtoa.o: dtoa.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dtoa.o `test -f 'dtoa.c' || echo '$(srcdir)/'`dtoa.c
+
+lib_a-dtoa.obj: dtoa.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dtoa.obj `if test -f 'dtoa.c'; then $(CYGPATH_W) 'dtoa.c'; else $(CYGPATH_W) '$(srcdir)/dtoa.c'; fi`
+
+lib_a-dtoastub.o: dtoastub.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dtoastub.o `test -f 'dtoastub.c' || echo '$(srcdir)/'`dtoastub.c
+
+lib_a-dtoastub.obj: dtoastub.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-dtoastub.obj `if test -f 'dtoastub.c'; then $(CYGPATH_W) 'dtoastub.c'; else $(CYGPATH_W) '$(srcdir)/dtoastub.c'; fi`
+
+lib_a-environ.o: environ.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-environ.o `test -f 'environ.c' || echo '$(srcdir)/'`environ.c
+
+lib_a-environ.obj: environ.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-environ.obj `if test -f 'environ.c'; then $(CYGPATH_W) 'environ.c'; else $(CYGPATH_W) '$(srcdir)/environ.c'; fi`
+
+lib_a-envlock.o: envlock.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-envlock.o `test -f 'envlock.c' || echo '$(srcdir)/'`envlock.c
+
+lib_a-envlock.obj: envlock.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-envlock.obj `if test -f 'envlock.c'; then $(CYGPATH_W) 'envlock.c'; else $(CYGPATH_W) '$(srcdir)/envlock.c'; fi`
+
+lib_a-eprintf.o: eprintf.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-eprintf.o `test -f 'eprintf.c' || echo '$(srcdir)/'`eprintf.c
+
+lib_a-eprintf.obj: eprintf.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-eprintf.obj `if test -f 'eprintf.c'; then $(CYGPATH_W) 'eprintf.c'; else $(CYGPATH_W) '$(srcdir)/eprintf.c'; fi`
+
+lib_a-exit.o: exit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-exit.o `test -f 'exit.c' || echo '$(srcdir)/'`exit.c
+
+lib_a-exit.obj: exit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-exit.obj `if test -f 'exit.c'; then $(CYGPATH_W) 'exit.c'; else $(CYGPATH_W) '$(srcdir)/exit.c'; fi`
+
+lib_a-gdtoa-gethex.o: gdtoa-gethex.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gdtoa-gethex.o `test -f 'gdtoa-gethex.c' || echo '$(srcdir)/'`gdtoa-gethex.c
+
+lib_a-gdtoa-gethex.obj: gdtoa-gethex.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gdtoa-gethex.obj `if test -f 'gdtoa-gethex.c'; then $(CYGPATH_W) 'gdtoa-gethex.c'; else $(CYGPATH_W) '$(srcdir)/gdtoa-gethex.c'; fi`
+
+lib_a-gdtoa-hexnan.o: gdtoa-hexnan.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gdtoa-hexnan.o `test -f 'gdtoa-hexnan.c' || echo '$(srcdir)/'`gdtoa-hexnan.c
+
+lib_a-gdtoa-hexnan.obj: gdtoa-hexnan.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-gdtoa-hexnan.obj `if test -f 'gdtoa-hexnan.c'; then $(CYGPATH_W) 'gdtoa-hexnan.c'; else $(CYGPATH_W) '$(srcdir)/gdtoa-hexnan.c'; fi`
+
+lib_a-getenv.o: getenv.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getenv.o `test -f 'getenv.c' || echo '$(srcdir)/'`getenv.c
+
+lib_a-getenv.obj: getenv.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getenv.obj `if test -f 'getenv.c'; then $(CYGPATH_W) 'getenv.c'; else $(CYGPATH_W) '$(srcdir)/getenv.c'; fi`
+
+lib_a-getenv_r.o: getenv_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getenv_r.o `test -f 'getenv_r.c' || echo '$(srcdir)/'`getenv_r.c
+
+lib_a-getenv_r.obj: getenv_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getenv_r.obj `if test -f 'getenv_r.c'; then $(CYGPATH_W) 'getenv_r.c'; else $(CYGPATH_W) '$(srcdir)/getenv_r.c'; fi`
+
+lib_a-labs.o: labs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-labs.o `test -f 'labs.c' || echo '$(srcdir)/'`labs.c
+
+lib_a-labs.obj: labs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-labs.obj `if test -f 'labs.c'; then $(CYGPATH_W) 'labs.c'; else $(CYGPATH_W) '$(srcdir)/labs.c'; fi`
+
+lib_a-ldiv.o: ldiv.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ldiv.o `test -f 'ldiv.c' || echo '$(srcdir)/'`ldiv.c
+
+lib_a-ldiv.obj: ldiv.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ldiv.obj `if test -f 'ldiv.c'; then $(CYGPATH_W) 'ldiv.c'; else $(CYGPATH_W) '$(srcdir)/ldiv.c'; fi`
+
+lib_a-ldtoa.o: ldtoa.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ldtoa.o `test -f 'ldtoa.c' || echo '$(srcdir)/'`ldtoa.c
+
+lib_a-ldtoa.obj: ldtoa.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ldtoa.obj `if test -f 'ldtoa.c'; then $(CYGPATH_W) 'ldtoa.c'; else $(CYGPATH_W) '$(srcdir)/ldtoa.c'; fi`
+
+lib_a-malloc.o: malloc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-malloc.o `test -f 'malloc.c' || echo '$(srcdir)/'`malloc.c
+
+lib_a-malloc.obj: malloc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-malloc.obj `if test -f 'malloc.c'; then $(CYGPATH_W) 'malloc.c'; else $(CYGPATH_W) '$(srcdir)/malloc.c'; fi`
+
+lib_a-mblen.o: mblen.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mblen.o `test -f 'mblen.c' || echo '$(srcdir)/'`mblen.c
+
+lib_a-mblen.obj: mblen.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mblen.obj `if test -f 'mblen.c'; then $(CYGPATH_W) 'mblen.c'; else $(CYGPATH_W) '$(srcdir)/mblen.c'; fi`
+
+lib_a-mblen_r.o: mblen_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mblen_r.o `test -f 'mblen_r.c' || echo '$(srcdir)/'`mblen_r.c
+
+lib_a-mblen_r.obj: mblen_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mblen_r.obj `if test -f 'mblen_r.c'; then $(CYGPATH_W) 'mblen_r.c'; else $(CYGPATH_W) '$(srcdir)/mblen_r.c'; fi`
+
+lib_a-mbstowcs.o: mbstowcs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbstowcs.o `test -f 'mbstowcs.c' || echo '$(srcdir)/'`mbstowcs.c
+
+lib_a-mbstowcs.obj: mbstowcs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbstowcs.obj `if test -f 'mbstowcs.c'; then $(CYGPATH_W) 'mbstowcs.c'; else $(CYGPATH_W) '$(srcdir)/mbstowcs.c'; fi`
+
+lib_a-mbstowcs_r.o: mbstowcs_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbstowcs_r.o `test -f 'mbstowcs_r.c' || echo '$(srcdir)/'`mbstowcs_r.c
+
+lib_a-mbstowcs_r.obj: mbstowcs_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbstowcs_r.obj `if test -f 'mbstowcs_r.c'; then $(CYGPATH_W) 'mbstowcs_r.c'; else $(CYGPATH_W) '$(srcdir)/mbstowcs_r.c'; fi`
+
+lib_a-mbtowc.o: mbtowc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbtowc.o `test -f 'mbtowc.c' || echo '$(srcdir)/'`mbtowc.c
+
+lib_a-mbtowc.obj: mbtowc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbtowc.obj `if test -f 'mbtowc.c'; then $(CYGPATH_W) 'mbtowc.c'; else $(CYGPATH_W) '$(srcdir)/mbtowc.c'; fi`
+
+lib_a-mbtowc_r.o: mbtowc_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbtowc_r.o `test -f 'mbtowc_r.c' || echo '$(srcdir)/'`mbtowc_r.c
+
+lib_a-mbtowc_r.obj: mbtowc_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbtowc_r.obj `if test -f 'mbtowc_r.c'; then $(CYGPATH_W) 'mbtowc_r.c'; else $(CYGPATH_W) '$(srcdir)/mbtowc_r.c'; fi`
+
+lib_a-mlock.o: mlock.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mlock.o `test -f 'mlock.c' || echo '$(srcdir)/'`mlock.c
+
+lib_a-mlock.obj: mlock.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mlock.obj `if test -f 'mlock.c'; then $(CYGPATH_W) 'mlock.c'; else $(CYGPATH_W) '$(srcdir)/mlock.c'; fi`
+
+lib_a-mprec.o: mprec.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mprec.o `test -f 'mprec.c' || echo '$(srcdir)/'`mprec.c
+
+lib_a-mprec.obj: mprec.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mprec.obj `if test -f 'mprec.c'; then $(CYGPATH_W) 'mprec.c'; else $(CYGPATH_W) '$(srcdir)/mprec.c'; fi`
+
+lib_a-mstats.o: mstats.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mstats.o `test -f 'mstats.c' || echo '$(srcdir)/'`mstats.c
+
+lib_a-mstats.obj: mstats.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mstats.obj `if test -f 'mstats.c'; then $(CYGPATH_W) 'mstats.c'; else $(CYGPATH_W) '$(srcdir)/mstats.c'; fi`
+
+lib_a-rand.o: rand.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rand.o `test -f 'rand.c' || echo '$(srcdir)/'`rand.c
+
+lib_a-rand.obj: rand.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rand.obj `if test -f 'rand.c'; then $(CYGPATH_W) 'rand.c'; else $(CYGPATH_W) '$(srcdir)/rand.c'; fi`
+
+lib_a-rand_r.o: rand_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rand_r.o `test -f 'rand_r.c' || echo '$(srcdir)/'`rand_r.c
+
+lib_a-rand_r.obj: rand_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rand_r.obj `if test -f 'rand_r.c'; then $(CYGPATH_W) 'rand_r.c'; else $(CYGPATH_W) '$(srcdir)/rand_r.c'; fi`
+
+lib_a-realloc.o: realloc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-realloc.o `test -f 'realloc.c' || echo '$(srcdir)/'`realloc.c
+
+lib_a-realloc.obj: realloc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-realloc.obj `if test -f 'realloc.c'; then $(CYGPATH_W) 'realloc.c'; else $(CYGPATH_W) '$(srcdir)/realloc.c'; fi`
+
+lib_a-reallocf.o: reallocf.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-reallocf.o `test -f 'reallocf.c' || echo '$(srcdir)/'`reallocf.c
+
+lib_a-reallocf.obj: reallocf.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-reallocf.obj `if test -f 'reallocf.c'; then $(CYGPATH_W) 'reallocf.c'; else $(CYGPATH_W) '$(srcdir)/reallocf.c'; fi`
+
+lib_a-sb_charsets.o: sb_charsets.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sb_charsets.o `test -f 'sb_charsets.c' || echo '$(srcdir)/'`sb_charsets.c
+
+lib_a-sb_charsets.obj: sb_charsets.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sb_charsets.obj `if test -f 'sb_charsets.c'; then $(CYGPATH_W) 'sb_charsets.c'; else $(CYGPATH_W) '$(srcdir)/sb_charsets.c'; fi`
+
+lib_a-strtod.o: strtod.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtod.o `test -f 'strtod.c' || echo '$(srcdir)/'`strtod.c
+
+lib_a-strtod.obj: strtod.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtod.obj `if test -f 'strtod.c'; then $(CYGPATH_W) 'strtod.c'; else $(CYGPATH_W) '$(srcdir)/strtod.c'; fi`
+
+lib_a-strtol.o: strtol.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtol.o `test -f 'strtol.c' || echo '$(srcdir)/'`strtol.c
+
+lib_a-strtol.obj: strtol.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtol.obj `if test -f 'strtol.c'; then $(CYGPATH_W) 'strtol.c'; else $(CYGPATH_W) '$(srcdir)/strtol.c'; fi`
+
+lib_a-strtoul.o: strtoul.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoul.o `test -f 'strtoul.c' || echo '$(srcdir)/'`strtoul.c
+
+lib_a-strtoul.obj: strtoul.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoul.obj `if test -f 'strtoul.c'; then $(CYGPATH_W) 'strtoul.c'; else $(CYGPATH_W) '$(srcdir)/strtoul.c'; fi`
+
+lib_a-wcstod.o: wcstod.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstod.o `test -f 'wcstod.c' || echo '$(srcdir)/'`wcstod.c
+
+lib_a-wcstod.obj: wcstod.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstod.obj `if test -f 'wcstod.c'; then $(CYGPATH_W) 'wcstod.c'; else $(CYGPATH_W) '$(srcdir)/wcstod.c'; fi`
+
+lib_a-wcstol.o: wcstol.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstol.o `test -f 'wcstol.c' || echo '$(srcdir)/'`wcstol.c
+
+lib_a-wcstol.obj: wcstol.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstol.obj `if test -f 'wcstol.c'; then $(CYGPATH_W) 'wcstol.c'; else $(CYGPATH_W) '$(srcdir)/wcstol.c'; fi`
+
+lib_a-wcstoul.o: wcstoul.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoul.o `test -f 'wcstoul.c' || echo '$(srcdir)/'`wcstoul.c
+
+lib_a-wcstoul.obj: wcstoul.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoul.obj `if test -f 'wcstoul.c'; then $(CYGPATH_W) 'wcstoul.c'; else $(CYGPATH_W) '$(srcdir)/wcstoul.c'; fi`
+
+lib_a-wcstombs.o: wcstombs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstombs.o `test -f 'wcstombs.c' || echo '$(srcdir)/'`wcstombs.c
+
+lib_a-wcstombs.obj: wcstombs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstombs.obj `if test -f 'wcstombs.c'; then $(CYGPATH_W) 'wcstombs.c'; else $(CYGPATH_W) '$(srcdir)/wcstombs.c'; fi`
+
+lib_a-wcstombs_r.o: wcstombs_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstombs_r.o `test -f 'wcstombs_r.c' || echo '$(srcdir)/'`wcstombs_r.c
+
+lib_a-wcstombs_r.obj: wcstombs_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstombs_r.obj `if test -f 'wcstombs_r.c'; then $(CYGPATH_W) 'wcstombs_r.c'; else $(CYGPATH_W) '$(srcdir)/wcstombs_r.c'; fi`
+
+lib_a-wctomb.o: wctomb.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wctomb.o `test -f 'wctomb.c' || echo '$(srcdir)/'`wctomb.c
+
+lib_a-wctomb.obj: wctomb.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wctomb.obj `if test -f 'wctomb.c'; then $(CYGPATH_W) 'wctomb.c'; else $(CYGPATH_W) '$(srcdir)/wctomb.c'; fi`
+
+lib_a-wctomb_r.o: wctomb_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wctomb_r.o `test -f 'wctomb_r.c' || echo '$(srcdir)/'`wctomb_r.c
+
+lib_a-wctomb_r.obj: wctomb_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wctomb_r.obj `if test -f 'wctomb_r.c'; then $(CYGPATH_W) 'wctomb_r.c'; else $(CYGPATH_W) '$(srcdir)/wctomb_r.c'; fi`
+
+lib_a-strtold.o: strtold.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtold.o `test -f 'strtold.c' || echo '$(srcdir)/'`strtold.c
+
+lib_a-strtold.obj: strtold.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtold.obj `if test -f 'strtold.c'; then $(CYGPATH_W) 'strtold.c'; else $(CYGPATH_W) '$(srcdir)/strtold.c'; fi`
+
+lib_a-wcstold.o: wcstold.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstold.o `test -f 'wcstold.c' || echo '$(srcdir)/'`wcstold.c
+
+lib_a-wcstold.obj: wcstold.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstold.obj `if test -f 'wcstold.c'; then $(CYGPATH_W) 'wcstold.c'; else $(CYGPATH_W) '$(srcdir)/wcstold.c'; fi`
+
+lib_a-cxa_atexit.o: cxa_atexit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cxa_atexit.o `test -f 'cxa_atexit.c' || echo '$(srcdir)/'`cxa_atexit.c
+
+lib_a-cxa_atexit.obj: cxa_atexit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cxa_atexit.obj `if test -f 'cxa_atexit.c'; then $(CYGPATH_W) 'cxa_atexit.c'; else $(CYGPATH_W) '$(srcdir)/cxa_atexit.c'; fi`
+
+lib_a-cxa_finalize.o: cxa_finalize.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cxa_finalize.o `test -f 'cxa_finalize.c' || echo '$(srcdir)/'`cxa_finalize.c
+
+lib_a-cxa_finalize.obj: cxa_finalize.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-cxa_finalize.obj `if test -f 'cxa_finalize.c'; then $(CYGPATH_W) 'cxa_finalize.c'; else $(CYGPATH_W) '$(srcdir)/cxa_finalize.c'; fi`
+
+lib_a-drand48.o: drand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-drand48.o `test -f 'drand48.c' || echo '$(srcdir)/'`drand48.c
+
+lib_a-drand48.obj: drand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-drand48.obj `if test -f 'drand48.c'; then $(CYGPATH_W) 'drand48.c'; else $(CYGPATH_W) '$(srcdir)/drand48.c'; fi`
+
+lib_a-ecvtbuf.o: ecvtbuf.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ecvtbuf.o `test -f 'ecvtbuf.c' || echo '$(srcdir)/'`ecvtbuf.c
+
+lib_a-ecvtbuf.obj: ecvtbuf.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-ecvtbuf.obj `if test -f 'ecvtbuf.c'; then $(CYGPATH_W) 'ecvtbuf.c'; else $(CYGPATH_W) '$(srcdir)/ecvtbuf.c'; fi`
+
+lib_a-efgcvt.o: efgcvt.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-efgcvt.o `test -f 'efgcvt.c' || echo '$(srcdir)/'`efgcvt.c
+
+lib_a-efgcvt.obj: efgcvt.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-efgcvt.obj `if test -f 'efgcvt.c'; then $(CYGPATH_W) 'efgcvt.c'; else $(CYGPATH_W) '$(srcdir)/efgcvt.c'; fi`
+
+lib_a-erand48.o: erand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-erand48.o `test -f 'erand48.c' || echo '$(srcdir)/'`erand48.c
+
+lib_a-erand48.obj: erand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-erand48.obj `if test -f 'erand48.c'; then $(CYGPATH_W) 'erand48.c'; else $(CYGPATH_W) '$(srcdir)/erand48.c'; fi`
+
+lib_a-jrand48.o: jrand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-jrand48.o `test -f 'jrand48.c' || echo '$(srcdir)/'`jrand48.c
+
+lib_a-jrand48.obj: jrand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-jrand48.obj `if test -f 'jrand48.c'; then $(CYGPATH_W) 'jrand48.c'; else $(CYGPATH_W) '$(srcdir)/jrand48.c'; fi`
+
+lib_a-lcong48.o: lcong48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lcong48.o `test -f 'lcong48.c' || echo '$(srcdir)/'`lcong48.c
+
+lib_a-lcong48.obj: lcong48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lcong48.obj `if test -f 'lcong48.c'; then $(CYGPATH_W) 'lcong48.c'; else $(CYGPATH_W) '$(srcdir)/lcong48.c'; fi`
+
+lib_a-lrand48.o: lrand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lrand48.o `test -f 'lrand48.c' || echo '$(srcdir)/'`lrand48.c
+
+lib_a-lrand48.obj: lrand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lrand48.obj `if test -f 'lrand48.c'; then $(CYGPATH_W) 'lrand48.c'; else $(CYGPATH_W) '$(srcdir)/lrand48.c'; fi`
+
+lib_a-mrand48.o: mrand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mrand48.o `test -f 'mrand48.c' || echo '$(srcdir)/'`mrand48.c
+
+lib_a-mrand48.obj: mrand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mrand48.obj `if test -f 'mrand48.c'; then $(CYGPATH_W) 'mrand48.c'; else $(CYGPATH_W) '$(srcdir)/mrand48.c'; fi`
+
+lib_a-msize.o: msize.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-msize.o `test -f 'msize.c' || echo '$(srcdir)/'`msize.c
+
+lib_a-msize.obj: msize.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-msize.obj `if test -f 'msize.c'; then $(CYGPATH_W) 'msize.c'; else $(CYGPATH_W) '$(srcdir)/msize.c'; fi`
+
+lib_a-mtrim.o: mtrim.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mtrim.o `test -f 'mtrim.c' || echo '$(srcdir)/'`mtrim.c
+
+lib_a-mtrim.obj: mtrim.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mtrim.obj `if test -f 'mtrim.c'; then $(CYGPATH_W) 'mtrim.c'; else $(CYGPATH_W) '$(srcdir)/mtrim.c'; fi`
+
+lib_a-nrand48.o: nrand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nrand48.o `test -f 'nrand48.c' || echo '$(srcdir)/'`nrand48.c
+
+lib_a-nrand48.obj: nrand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-nrand48.obj `if test -f 'nrand48.c'; then $(CYGPATH_W) 'nrand48.c'; else $(CYGPATH_W) '$(srcdir)/nrand48.c'; fi`
+
+lib_a-rand48.o: rand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rand48.o `test -f 'rand48.c' || echo '$(srcdir)/'`rand48.c
+
+lib_a-rand48.obj: rand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-rand48.obj `if test -f 'rand48.c'; then $(CYGPATH_W) 'rand48.c'; else $(CYGPATH_W) '$(srcdir)/rand48.c'; fi`
+
+lib_a-seed48.o: seed48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-seed48.o `test -f 'seed48.c' || echo '$(srcdir)/'`seed48.c
+
+lib_a-seed48.obj: seed48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-seed48.obj `if test -f 'seed48.c'; then $(CYGPATH_W) 'seed48.c'; else $(CYGPATH_W) '$(srcdir)/seed48.c'; fi`
+
+lib_a-srand48.o: srand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-srand48.o `test -f 'srand48.c' || echo '$(srcdir)/'`srand48.c
+
+lib_a-srand48.obj: srand48.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-srand48.obj `if test -f 'srand48.c'; then $(CYGPATH_W) 'srand48.c'; else $(CYGPATH_W) '$(srcdir)/srand48.c'; fi`
+
+lib_a-strtoll.o: strtoll.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoll.o `test -f 'strtoll.c' || echo '$(srcdir)/'`strtoll.c
+
+lib_a-strtoll.obj: strtoll.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoll.obj `if test -f 'strtoll.c'; then $(CYGPATH_W) 'strtoll.c'; else $(CYGPATH_W) '$(srcdir)/strtoll.c'; fi`
+
+lib_a-strtoll_r.o: strtoll_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoll_r.o `test -f 'strtoll_r.c' || echo '$(srcdir)/'`strtoll_r.c
+
+lib_a-strtoll_r.obj: strtoll_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoll_r.obj `if test -f 'strtoll_r.c'; then $(CYGPATH_W) 'strtoll_r.c'; else $(CYGPATH_W) '$(srcdir)/strtoll_r.c'; fi`
+
+lib_a-strtoull.o: strtoull.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoull.o `test -f 'strtoull.c' || echo '$(srcdir)/'`strtoull.c
+
+lib_a-strtoull.obj: strtoull.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoull.obj `if test -f 'strtoull.c'; then $(CYGPATH_W) 'strtoull.c'; else $(CYGPATH_W) '$(srcdir)/strtoull.c'; fi`
+
+lib_a-strtoull_r.o: strtoull_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoull_r.o `test -f 'strtoull_r.c' || echo '$(srcdir)/'`strtoull_r.c
+
+lib_a-strtoull_r.obj: strtoull_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-strtoull_r.obj `if test -f 'strtoull_r.c'; then $(CYGPATH_W) 'strtoull_r.c'; else $(CYGPATH_W) '$(srcdir)/strtoull_r.c'; fi`
+
+lib_a-wcstoll.o: wcstoll.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoll.o `test -f 'wcstoll.c' || echo '$(srcdir)/'`wcstoll.c
+
+lib_a-wcstoll.obj: wcstoll.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoll.obj `if test -f 'wcstoll.c'; then $(CYGPATH_W) 'wcstoll.c'; else $(CYGPATH_W) '$(srcdir)/wcstoll.c'; fi`
+
+lib_a-wcstoll_r.o: wcstoll_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoll_r.o `test -f 'wcstoll_r.c' || echo '$(srcdir)/'`wcstoll_r.c
+
+lib_a-wcstoll_r.obj: wcstoll_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoll_r.obj `if test -f 'wcstoll_r.c'; then $(CYGPATH_W) 'wcstoll_r.c'; else $(CYGPATH_W) '$(srcdir)/wcstoll_r.c'; fi`
+
+lib_a-wcstoull.o: wcstoull.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoull.o `test -f 'wcstoull.c' || echo '$(srcdir)/'`wcstoull.c
+
+lib_a-wcstoull.obj: wcstoull.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoull.obj `if test -f 'wcstoull.c'; then $(CYGPATH_W) 'wcstoull.c'; else $(CYGPATH_W) '$(srcdir)/wcstoull.c'; fi`
+
+lib_a-wcstoull_r.o: wcstoull_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoull_r.o `test -f 'wcstoull_r.c' || echo '$(srcdir)/'`wcstoull_r.c
+
+lib_a-wcstoull_r.obj: wcstoull_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcstoull_r.obj `if test -f 'wcstoull_r.c'; then $(CYGPATH_W) 'wcstoull_r.c'; else $(CYGPATH_W) '$(srcdir)/wcstoull_r.c'; fi`
+
+lib_a-atoll.o: atoll.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atoll.o `test -f 'atoll.c' || echo '$(srcdir)/'`atoll.c
+
+lib_a-atoll.obj: atoll.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-atoll.obj `if test -f 'atoll.c'; then $(CYGPATH_W) 'atoll.c'; else $(CYGPATH_W) '$(srcdir)/atoll.c'; fi`
+
+lib_a-llabs.o: llabs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-llabs.o `test -f 'llabs.c' || echo '$(srcdir)/'`llabs.c
+
+lib_a-llabs.obj: llabs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-llabs.obj `if test -f 'llabs.c'; then $(CYGPATH_W) 'llabs.c'; else $(CYGPATH_W) '$(srcdir)/llabs.c'; fi`
+
+lib_a-lldiv.o: lldiv.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lldiv.o `test -f 'lldiv.c' || echo '$(srcdir)/'`lldiv.c
+
+lib_a-lldiv.obj: lldiv.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lldiv.obj `if test -f 'lldiv.c'; then $(CYGPATH_W) 'lldiv.c'; else $(CYGPATH_W) '$(srcdir)/lldiv.c'; fi`
+
+lib_a-a64l.o: a64l.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-a64l.o `test -f 'a64l.c' || echo '$(srcdir)/'`a64l.c
+
+lib_a-a64l.obj: a64l.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-a64l.obj `if test -f 'a64l.c'; then $(CYGPATH_W) 'a64l.c'; else $(CYGPATH_W) '$(srcdir)/a64l.c'; fi`
+
+lib_a-btowc.o: btowc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-btowc.o `test -f 'btowc.c' || echo '$(srcdir)/'`btowc.c
+
+lib_a-btowc.obj: btowc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-btowc.obj `if test -f 'btowc.c'; then $(CYGPATH_W) 'btowc.c'; else $(CYGPATH_W) '$(srcdir)/btowc.c'; fi`
+
+lib_a-getopt.o: getopt.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getopt.o `test -f 'getopt.c' || echo '$(srcdir)/'`getopt.c
+
+lib_a-getopt.obj: getopt.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getopt.obj `if test -f 'getopt.c'; then $(CYGPATH_W) 'getopt.c'; else $(CYGPATH_W) '$(srcdir)/getopt.c'; fi`
+
+lib_a-getsubopt.o: getsubopt.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getsubopt.o `test -f 'getsubopt.c' || echo '$(srcdir)/'`getsubopt.c
+
+lib_a-getsubopt.obj: getsubopt.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-getsubopt.obj `if test -f 'getsubopt.c'; then $(CYGPATH_W) 'getsubopt.c'; else $(CYGPATH_W) '$(srcdir)/getsubopt.c'; fi`
+
+lib_a-l64a.o: l64a.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-l64a.o `test -f 'l64a.c' || echo '$(srcdir)/'`l64a.c
+
+lib_a-l64a.obj: l64a.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-l64a.obj `if test -f 'l64a.c'; then $(CYGPATH_W) 'l64a.c'; else $(CYGPATH_W) '$(srcdir)/l64a.c'; fi`
+
+lib_a-malign.o: malign.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-malign.o `test -f 'malign.c' || echo '$(srcdir)/'`malign.c
+
+lib_a-malign.obj: malign.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-malign.obj `if test -f 'malign.c'; then $(CYGPATH_W) 'malign.c'; else $(CYGPATH_W) '$(srcdir)/malign.c'; fi`
+
+lib_a-mbrlen.o: mbrlen.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbrlen.o `test -f 'mbrlen.c' || echo '$(srcdir)/'`mbrlen.c
+
+lib_a-mbrlen.obj: mbrlen.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbrlen.obj `if test -f 'mbrlen.c'; then $(CYGPATH_W) 'mbrlen.c'; else $(CYGPATH_W) '$(srcdir)/mbrlen.c'; fi`
+
+lib_a-mbrtowc.o: mbrtowc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbrtowc.o `test -f 'mbrtowc.c' || echo '$(srcdir)/'`mbrtowc.c
+
+lib_a-mbrtowc.obj: mbrtowc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbrtowc.obj `if test -f 'mbrtowc.c'; then $(CYGPATH_W) 'mbrtowc.c'; else $(CYGPATH_W) '$(srcdir)/mbrtowc.c'; fi`
+
+lib_a-mbsinit.o: mbsinit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbsinit.o `test -f 'mbsinit.c' || echo '$(srcdir)/'`mbsinit.c
+
+lib_a-mbsinit.obj: mbsinit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbsinit.obj `if test -f 'mbsinit.c'; then $(CYGPATH_W) 'mbsinit.c'; else $(CYGPATH_W) '$(srcdir)/mbsinit.c'; fi`
+
+lib_a-mbsnrtowcs.o: mbsnrtowcs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbsnrtowcs.o `test -f 'mbsnrtowcs.c' || echo '$(srcdir)/'`mbsnrtowcs.c
+
+lib_a-mbsnrtowcs.obj: mbsnrtowcs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbsnrtowcs.obj `if test -f 'mbsnrtowcs.c'; then $(CYGPATH_W) 'mbsnrtowcs.c'; else $(CYGPATH_W) '$(srcdir)/mbsnrtowcs.c'; fi`
+
+lib_a-mbsrtowcs.o: mbsrtowcs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbsrtowcs.o `test -f 'mbsrtowcs.c' || echo '$(srcdir)/'`mbsrtowcs.c
+
+lib_a-mbsrtowcs.obj: mbsrtowcs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mbsrtowcs.obj `if test -f 'mbsrtowcs.c'; then $(CYGPATH_W) 'mbsrtowcs.c'; else $(CYGPATH_W) '$(srcdir)/mbsrtowcs.c'; fi`
+
+lib_a-on_exit.o: on_exit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-on_exit.o `test -f 'on_exit.c' || echo '$(srcdir)/'`on_exit.c
+
+lib_a-on_exit.obj: on_exit.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-on_exit.obj `if test -f 'on_exit.c'; then $(CYGPATH_W) 'on_exit.c'; else $(CYGPATH_W) '$(srcdir)/on_exit.c'; fi`
+
+lib_a-valloc.o: valloc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-valloc.o `test -f 'valloc.c' || echo '$(srcdir)/'`valloc.c
+
+lib_a-valloc.obj: valloc.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-valloc.obj `if test -f 'valloc.c'; then $(CYGPATH_W) 'valloc.c'; else $(CYGPATH_W) '$(srcdir)/valloc.c'; fi`
+
+lib_a-wcrtomb.o: wcrtomb.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcrtomb.o `test -f 'wcrtomb.c' || echo '$(srcdir)/'`wcrtomb.c
+
+lib_a-wcrtomb.obj: wcrtomb.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcrtomb.obj `if test -f 'wcrtomb.c'; then $(CYGPATH_W) 'wcrtomb.c'; else $(CYGPATH_W) '$(srcdir)/wcrtomb.c'; fi`
+
+lib_a-wcsnrtombs.o: wcsnrtombs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcsnrtombs.o `test -f 'wcsnrtombs.c' || echo '$(srcdir)/'`wcsnrtombs.c
+
+lib_a-wcsnrtombs.obj: wcsnrtombs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcsnrtombs.obj `if test -f 'wcsnrtombs.c'; then $(CYGPATH_W) 'wcsnrtombs.c'; else $(CYGPATH_W) '$(srcdir)/wcsnrtombs.c'; fi`
+
+lib_a-wcsrtombs.o: wcsrtombs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcsrtombs.o `test -f 'wcsrtombs.c' || echo '$(srcdir)/'`wcsrtombs.c
+
+lib_a-wcsrtombs.obj: wcsrtombs.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wcsrtombs.obj `if test -f 'wcsrtombs.c'; then $(CYGPATH_W) 'wcsrtombs.c'; else $(CYGPATH_W) '$(srcdir)/wcsrtombs.c'; fi`
+
+lib_a-wctob.o: wctob.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wctob.o `test -f 'wctob.c' || echo '$(srcdir)/'`wctob.c
+
+lib_a-wctob.obj: wctob.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-wctob.obj `if test -f 'wctob.c'; then $(CYGPATH_W) 'wctob.c'; else $(CYGPATH_W) '$(srcdir)/wctob.c'; fi`
+
+lib_a-putenv.o: putenv.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putenv.o `test -f 'putenv.c' || echo '$(srcdir)/'`putenv.c
+
+lib_a-putenv.obj: putenv.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putenv.obj `if test -f 'putenv.c'; then $(CYGPATH_W) 'putenv.c'; else $(CYGPATH_W) '$(srcdir)/putenv.c'; fi`
+
+lib_a-putenv_r.o: putenv_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putenv_r.o `test -f 'putenv_r.c' || echo '$(srcdir)/'`putenv_r.c
+
+lib_a-putenv_r.obj: putenv_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-putenv_r.obj `if test -f 'putenv_r.c'; then $(CYGPATH_W) 'putenv_r.c'; else $(CYGPATH_W) '$(srcdir)/putenv_r.c'; fi`
+
+lib_a-setenv.o: setenv.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-setenv.o `test -f 'setenv.c' || echo '$(srcdir)/'`setenv.c
+
+lib_a-setenv.obj: setenv.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-setenv.obj `if test -f 'setenv.c'; then $(CYGPATH_W) 'setenv.c'; else $(CYGPATH_W) '$(srcdir)/setenv.c'; fi`
+
+lib_a-setenv_r.o: setenv_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-setenv_r.o `test -f 'setenv_r.c' || echo '$(srcdir)/'`setenv_r.c
+
+lib_a-setenv_r.obj: setenv_r.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-setenv_r.obj `if test -f 'setenv_r.c'; then $(CYGPATH_W) 'setenv_r.c'; else $(CYGPATH_W) '$(srcdir)/setenv_r.c'; fi`
+
+lib_a-system.o: system.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-system.o `test -f 'system.c' || echo '$(srcdir)/'`system.c
+
+lib_a-system.obj: system.c
+ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-system.obj `if test -f 'system.c'; then $(CYGPATH_W) 'system.c'; else $(CYGPATH_W) '$(srcdir)/system.c'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+check-am:
+check: check-am
+all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(DATA)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+ clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLIBRARIES clean-noinstLTLIBRARIES \
+ ctags distclean distclean-compile distclean-generic \
+ distclean-libtool distclean-tags dvi dvi-am html html-am info \
+ info-am install install-am install-data install-data-am \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-html install-html-am install-info install-info-am \
+ install-man install-pdf install-pdf-am install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+ uninstall-am
+
+objectlist.awk.in: $(noinst_LTLIBRARIES)
+ -rm -f objectlist.awk.in
+ for i in `ls *.lo` ; \
+ do \
+ echo $$i `pwd`/$$i >> objectlist.awk.in ; \
+ done
+
+$(lpfx)mallocr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MALLOC -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)freer.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_FREE -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)reallocr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_REALLOC -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)callocr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_CALLOC -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)cfreer.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_CFREE -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)malignr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MEMALIGN -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)vallocr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_VALLOC -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)pvallocr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_PVALLOC -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)mallinfor.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MALLINFO -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)mallstatsr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MALLOC_STATS -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)msizer.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)malloptr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MALLOPT -c $(srcdir)/mallocr.c -o $@
+
+.c.def:
+ $(CHEW) < $< > $*.def 2> $*.ref
+ touch stmp-def
+
+doc: $(CHEWOUT_FILES)
+ cat $(srcdir)/stdlib.tex >> $(TARGETDOC)
+
+$(lpfx)dtoa.$(oext): dtoa.c mprec.h
+$(lpfx)ldtoa.$(oext): ldtoa.c mprec.h
+$(lpfx)ecvtbuf.$(oext): ecvtbuf.c mprec.h
+$(lpfx)mbtowc_r.$(oext): mbtowc_r.c mbctype.h
+ $(LIB_COMPILE) -c -fshort-enums $(srcdir)/mbtowc_r.c -o $@
+
+$(lpfx)mprec.$(oext): mprec.c mprec.h
+$(lpfx)strtod.$(oext): strtod.c mprec.h
+$(lpfx)gdtoa-gethex.$(oext): gdtoa-gethex.c mprec.h
+$(lpfx)gdtoa-hexnan.$(oext): gdtoa-hexnan.c mprec.h
+$(lpfx)wctomb_r.$(oext): wctomb_r.c mbctype.h
+$(lpfx)drand48.$(oext): drand48.c rand48.h
+$(lpfx)erand48.$(oext): erand48.c rand48.h
+$(lpfx)jrand48.$(oext): jrand48.c rand48.h
+$(lpfx)lcong48.$(oext): lcong48.c rand48.h
+$(lpfx)lrand48.$(oext): lrand48.c rand48.h
+$(lpfx)mrand48.$(oext): mrand48.c rand48.h
+$(lpfx)nrand48.$(oext): nrand48.c rand48.h
+$(lpfx)rand48.$(oext): rand48.c rand48.h
+$(lpfx)seed48.$(oext): seed48.c rand48.h
+$(lpfx)srand48.$(oext): srand48.c rand48.h
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
Index: gdtoa.h
===================================================================
--- gdtoa.h (nonexistent)
+++ gdtoa.h (revision 345)
@@ -0,0 +1,72 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to David M. Gay (dmg at acm dot org,
+ * with " at " changed at "@" and " dot " changed to "."). */
+
+#ifndef GDTOA_H_INCLUDED
+#define GDTOA_H_INCLUDED
+
+
+ enum { /* return values from strtodg */
+ STRTOG_Zero = 0,
+ STRTOG_Normal = 1,
+ STRTOG_Denormal = 2,
+ STRTOG_Infinite = 3,
+ STRTOG_NaN = 4,
+ STRTOG_NaNbits = 5,
+ STRTOG_NoNumber = 6,
+ STRTOG_Retmask = 7,
+
+ /* The following may be or-ed into one of the above values. */
+
+ STRTOG_Neg = 0x08,
+ STRTOG_Inexlo = 0x10,
+ STRTOG_Inexhi = 0x20,
+ STRTOG_Inexact = 0x30,
+ STRTOG_Underflow= 0x40,
+ STRTOG_Overflow = 0x80
+ };
+
+ typedef struct
+FPI {
+ int nbits;
+ int emin;
+ int emax;
+ int rounding;
+ int sudden_underflow;
+ } FPI;
+
+enum { /* FPI.rounding values: same as FLT_ROUNDS */
+ FPI_Round_zero = 0,
+ FPI_Round_near = 1,
+ FPI_Round_up = 2,
+ FPI_Round_down = 3
+ };
+
+#endif /* GDTOA_H_INCLUDED */
gdtoa.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: setenv.c
===================================================================
--- setenv.c (nonexistent)
+++ setenv.c (revision 345)
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement: ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef _REENT_ONLY
+
+#include
+#include
+#include
+
+extern int _unsetenv_r _PARAMS ((struct _reent *, const char *));
+
+/*
+ * setenv --
+ * Set the value of the environmental variable "name" to be
+ * "value". If rewrite is set, replace any current value.
+ */
+
+int
+_DEFUN (setenv, (name, value, rewrite),
+ _CONST char *name _AND
+ _CONST char *value _AND
+ int rewrite)
+{
+ return _setenv_r (_REENT, name, value, rewrite);
+}
+
+/*
+ * unsetenv(name) --
+ * Delete environmental variable "name".
+ */
+int
+_DEFUN (unsetenv, (name),
+ _CONST char *name)
+{
+ return _unsetenv_r (_REENT, name);
+}
+
+#endif /* !_REENT_ONLY */
setenv.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: drand48.c
===================================================================
--- drand48.c (nonexistent)
+++ drand48.c (revision 345)
@@ -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 */
drand48.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mlock.c
===================================================================
--- mlock.c (nonexistent)
+++ mlock.c (revision 345)
@@ -0,0 +1,64 @@
+#ifndef MALLOC_PROVIDED
+/*
+FUNCTION
+<<__malloc_lock>>, <<__malloc_unlock>>---lock malloc pool
+
+INDEX
+ __malloc_lock
+INDEX
+ __malloc_unlock
+
+ANSI_SYNOPSIS
+ #include
+ void __malloc_lock (struct _reent *<[reent]>);
+ void __malloc_unlock (struct _reent *<[reent]>);
+
+TRAD_SYNOPSIS
+ void __malloc_lock(<[reent]>)
+ struct _reent *<[reent]>;
+
+ void __malloc_unlock(<[reent]>)
+ struct _reent *<[reent]>;
+
+DESCRIPTION
+The <> family of routines call these functions when they need to lock
+the memory pool. The version of these routines supplied in the library use
+the lock API defined in sys/lock.h. If multiple threads of execution can
+call <>, or if <> can be called reentrantly, then you need to
+define your own versions of these functions in order to safely lock the
+memory pool during a call. If you do not, the memory pool may become
+corrupted.
+
+A call to <> may call <<__malloc_lock>> recursively; that is,
+the sequence of calls may go <<__malloc_lock>>, <<__malloc_lock>>,
+<<__malloc_unlock>>, <<__malloc_unlock>>. Any implementation of these
+routines must be careful to avoid causing a thread to wait for a lock
+that it already holds.
+*/
+
+#include
+#include
+
+#ifndef __SINGLE_THREAD__
+__LOCK_INIT_RECURSIVE(static, __malloc_lock_object);
+#endif
+
+void
+__malloc_lock (ptr)
+ struct _reent *ptr;
+{
+#ifndef __SINGLE_THREAD__
+ __lock_acquire_recursive (__malloc_lock_object);
+#endif
+}
+
+void
+__malloc_unlock (ptr)
+ struct _reent *ptr;
+{
+#ifndef __SINGLE_THREAD__
+ __lock_release_recursive (__malloc_lock_object);
+#endif
+}
+
+#endif
mlock.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: abs.c
===================================================================
--- abs.c (nonexistent)
+++ abs.c (revision 345)
@@ -0,0 +1,43 @@
+/*
+FUNCTION
+<>---integer absolute value (magnitude)
+
+INDEX
+ abs
+
+ANSI_SYNOPSIS
+ #include
+ int abs(int <[i]>);
+
+TRAD_SYNOPSIS
+ #include
+ int abs(<[i]>)
+ int <[i]>;
+
+DESCRIPTION
+<> 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 <> uses and returns <> rather than <> values.
+
+RETURNS
+The result is a nonnegative integer.
+
+PORTABILITY
+<> is ANSI.
+
+No supporting OS subroutines are required.
+*/
+
+#include
+
+int
+_DEFUN (abs, (i), int i)
+{
+ return (i < 0) ? -i : i;
+}
abs.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: erand48.c
===================================================================
--- erand48.c (nonexistent)
+++ erand48.c (revision 345)
@@ -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 */
erand48.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: malign.c
===================================================================
--- malign.c (nonexistent)
+++ malign.c (revision 345)
@@ -0,0 +1,20 @@
+#ifndef MALLOC_PROVIDED
+/* malign.c -- a wrapper for memalign_r. */
+
+#include <_ansi.h>
+#include
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+_PTR
+_DEFUN (memalign, (align, nbytes),
+ size_t align _AND
+ size_t nbytes)
+{
+ return _memalign_r (_REENT, align, nbytes);
+}
+
+#endif
+#endif
malign.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: _Exit.c
===================================================================
--- _Exit.c (nonexistent)
+++ _Exit.c (revision 345)
@@ -0,0 +1,46 @@
+/*
+FUNCTION
+<<_Exit>>---end program execution with no cleanup processing
+
+INDEX
+ _Exit
+
+ANSI_SYNOPSIS
+ #include
+ void _Exit(int <[code]>);
+
+TRAD_SYNOPSIS
+ #include
+ void _Exit(<[code]>)
+ int <[code]>;
+
+DESCRIPTION
+Use <<_Exit>> to return control from a program to the host operating
+environment. Use the argument <[code]> to pass an exit status to the
+operating environment: two particular values, <> and
+<>, are defined in `<>' to indicate success or
+failure in a portable fashion.
+
+<<_Exit>> differs from <> in that it does not run any
+application-defined cleanup functions registered with <> and
+it does not clean up files and streams. It is identical to <<_exit>>.
+
+RETURNS
+<<_Exit>> does not return to its caller.
+
+PORTABILITY
+<<_Exit>> is defined by the C99 standard.
+
+Supporting OS subroutines required: <<_exit>>.
+*/
+
+#include
+#include /* for _exit() declaration */
+#include
+
+void
+_DEFUN (_Exit, (code),
+ int code)
+{
+ _exit (code);
+}
_Exit.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mbctype.h
===================================================================
--- mbctype.h (nonexistent)
+++ mbctype.h (revision 345)
@@ -0,0 +1,21 @@
+#ifndef _MBCTYPE_H_
+
+#define _MBCTYPE_H_
+
+/* escape character used for JIS encoding */
+#define ESC_CHAR 0x1b
+
+/* functions used to support SHIFT_JIS, EUC-JP, and JIS multibyte encodings */
+
+int _EXFUN(_issjis1, (int c));
+int _EXFUN(_issjis2, (int c));
+int _EXFUN(_iseucjp, (int c));
+int _EXFUN(_isjis, (int c));
+
+#define _issjis1(c) (((c) >= 0x81 && (c) <= 0x9f) || ((c) >= 0xe0 && (c) <= 0xef))
+#define _issjis2(c) (((c) >= 0x40 && (c) <= 0x7e) || ((c) >= 0x80 && (c) <= 0xfc))
+#define _iseucjp1(c) ((c) == 0x8e || (c) == 0x8f || ((c) >= 0xa1 && (c) <= 0xfe))
+#define _iseucjp2(c) ((c) >= 0xa1 && (c) <= 0xfe)
+#define _isjis(c) ((c) >= 0x21 && (c) <= 0x7e)
+
+#endif /* _MBCTYPE_H_ */
mbctype.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: strtoull_r.c
===================================================================
--- strtoull_r.c (nonexistent)
+++ strtoull_r.c (revision 345)
@@ -0,0 +1,120 @@
+/*
+ This code is based on strtoul.c which has the following copyright.
+ It is used to convert a string into an unsigned long long.
+
+ long long _strtoull_r (struct _reent *rptr, const char *s,
+ char **ptr, int base);
+
+*/
+
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef __GNUC__
+
+#define _GNU_SOURCE
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * Convert a string to an unsigned long long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+unsigned long long
+_DEFUN (_strtoull_r, (rptr, nptr, endptr, base),
+ struct _reent *rptr _AND
+ _CONST char *nptr _AND
+ char **endptr _AND
+ int base)
+{
+ register const char *s = nptr;
+ register unsigned long long acc;
+ register int c;
+ register unsigned long long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * See strtol for comments as to the logic used.
+ */
+ do {
+ c = *s++;
+ } while (isspace(c));
+ if (c == '-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+ cutoff = (unsigned long long)ULONG_LONG_MAX / (unsigned long long)base;
+ cutlim = (unsigned long long)ULONG_LONG_MAX % (unsigned long long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (isdigit(c))
+ c -= '0';
+ else if (isalpha(c))
+ c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = ULONG_LONG_MAX;
+ rptr->_errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (char *) (any ? s - 1 : nptr);
+ return (acc);
+}
+
+#endif /* __GNUC__ */
strtoull_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: exit.c
===================================================================
--- exit.c (nonexistent)
+++ exit.c (revision 345)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+/*
+FUNCTION
+<>---end program execution
+
+INDEX
+ exit
+
+ANSI_SYNOPSIS
+ #include
+ void exit(int <[code]>);
+
+TRAD_SYNOPSIS
+ #include
+ void exit(<[code]>)
+ int <[code]>;
+
+DESCRIPTION
+Use <> to return control from a program to the host operating
+environment. Use the argument <[code]> to pass an exit status to the
+operating environment: two particular values, <> and
+<>, are defined in `<>' to indicate success or
+failure in a portable fashion.
+
+<> does two kinds of cleanup before ending execution of your
+program. First, it calls all application-defined cleanup functions
+you have enrolled with <>. Second, files and streams are
+cleaned up: any pending output is delivered to the host system, each
+open file or stream is closed, and files created by <> are
+deleted.
+
+RETURNS
+<> does not return to its caller.
+
+PORTABILITY
+ANSI C requires <>, and specifies that <> and
+<> must be defined.
+
+Supporting OS subroutines required: <<_exit>>.
+*/
+
+#include
+#include /* for _exit() declaration */
+#include
+#include "atexit.h"
+
+/*
+ * Exit, flushing stdio buffers if necessary.
+ */
+
+void
+_DEFUN (exit, (code),
+ int code)
+{
+ __call_exitprocs (code, NULL);
+
+ if (_GLOBAL_REENT->__cleanup)
+ (*_GLOBAL_REENT->__cleanup) (_GLOBAL_REENT);
+ _exit (code);
+}
exit.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: jrand48.c
===================================================================
--- jrand48.c (nonexistent)
+++ jrand48.c (revision 345)
@@ -0,0 +1,32 @@
+/*
+ * 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"
+
+long
+_DEFUN (_jrand48_r, (r, xseed),
+ struct _reent *r _AND
+ unsigned short xseed[3])
+{
+ __dorand48(r, xseed);
+ return ((long) xseed[2] << 16) + (long) xseed[1];
+}
+
+#ifndef _REENT_ONLY
+long
+_DEFUN (jrand48, (xseed),
+ unsigned short xseed[3])
+{
+ return _jrand48_r (_REENT, xseed);
+}
+#endif /* !_REENT_ONLY */
jrand48.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mbtowc_r.c
===================================================================
--- mbtowc_r.c (nonexistent)
+++ mbtowc_r.c (revision 345)
@@ -0,0 +1,637 @@
+#include
+#include
+#include
+#include "mbctype.h"
+#include
+#include
+#include
+#include "local.h"
+
+int (*__mbtowc) (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *)
+#ifdef __CYGWIN__
+ = __utf8_mbtowc;
+#else
+ = __ascii_mbtowc;
+#endif
+
+int
+_DEFUN (_mbtowc_r, (r, pwc, s, n, state),
+ struct _reent *r _AND
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n _AND
+ mbstate_t *state)
+{
+ return __mbtowc (r, pwc, s, n, __locale_charset (), state);
+}
+
+int
+_DEFUN (__ascii_mbtowc, (r, pwc, s, n, charset, state),
+ struct _reent *r _AND
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wchar_t dummy;
+ unsigned char *t = (unsigned char *)s;
+
+ if (pwc == NULL)
+ pwc = &dummy;
+
+ if (s == NULL)
+ return 0;
+
+ if (n == 0)
+ return -2;
+
+ *pwc = (wchar_t)*t;
+
+ if (*t == '\0')
+ return 0;
+
+ return 1;
+}
+
+#ifdef _MB_CAPABLE
+typedef enum { ESCAPE, DOLLAR, BRACKET, AT, B, J,
+ NUL, JIS_CHAR, OTHER, JIS_C_NUM } JIS_CHAR_TYPE;
+typedef enum { ASCII, JIS, A_ESC, A_ESC_DL, JIS_1, J_ESC, J_ESC_BR,
+ INV, JIS_S_NUM } JIS_STATE;
+typedef enum { COPY_A, COPY_J1, COPY_J2, MAKE_A, NOOP, EMPTY, ERROR } JIS_ACTION;
+
+/**************************************************************************************
+ * state/action tables for processing JIS encoding
+ * Where possible, switches to JIS are grouped with proceding JIS characters and switches
+ * to ASCII are grouped with preceding JIS characters. Thus, maximum returned length
+ * is 2 (switch to JIS) + 2 (JIS characters) + 2 (switch back to ASCII) = 6.
+ *************************************************************************************/
+
+static JIS_STATE JIS_state_table[JIS_S_NUM][JIS_C_NUM] = {
+/* ESCAPE DOLLAR BRACKET AT B J NUL JIS_CHAR OTHER */
+/* ASCII */ { A_ESC, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII },
+/* JIS */ { J_ESC, JIS_1, JIS_1, JIS_1, JIS_1, JIS_1, INV, JIS_1, INV },
+/* A_ESC */ { ASCII, A_ESC_DL, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII, ASCII },
+/* A_ESC_DL */{ ASCII, ASCII, ASCII, JIS, JIS, ASCII, ASCII, ASCII, ASCII },
+/* JIS_1 */ { INV, JIS, JIS, JIS, JIS, JIS, INV, JIS, INV },
+/* J_ESC */ { INV, INV, J_ESC_BR, INV, INV, INV, INV, INV, INV },
+/* J_ESC_BR */{ INV, INV, INV, INV, ASCII, ASCII, INV, INV, INV },
+};
+
+static JIS_ACTION JIS_action_table[JIS_S_NUM][JIS_C_NUM] = {
+/* ESCAPE DOLLAR BRACKET AT B J NUL JIS_CHAR OTHER */
+/* ASCII */ { NOOP, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A, EMPTY, COPY_A, COPY_A},
+/* JIS */ { NOOP, COPY_J1, COPY_J1, COPY_J1, COPY_J1, COPY_J1, ERROR, COPY_J1, ERROR },
+/* A_ESC */ { COPY_A, NOOP, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A, COPY_A},
+/* A_ESC_DL */{ COPY_A, COPY_A, COPY_A, NOOP, NOOP, COPY_A, COPY_A, COPY_A, COPY_A},
+/* JIS_1 */ { ERROR, COPY_J2, COPY_J2, COPY_J2, COPY_J2, COPY_J2, ERROR, COPY_J2, ERROR },
+/* J_ESC */ { ERROR, ERROR, NOOP, ERROR, ERROR, ERROR, ERROR, ERROR, ERROR },
+/* J_ESC_BR */{ ERROR, ERROR, ERROR, ERROR, MAKE_A, MAKE_A, ERROR, ERROR, ERROR },
+};
+
+/* we override the mbstate_t __count field for more complex encodings and use it store a state value */
+#define __state __count
+
+#ifdef _MB_EXTENDED_CHARSETS_ISO
+int
+_DEFUN (__iso_mbtowc, (r, pwc, s, n, charset, state),
+ struct _reent *r _AND
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wchar_t dummy;
+ unsigned char *t = (unsigned char *)s;
+
+ if (pwc == NULL)
+ pwc = &dummy;
+
+ if (s == NULL)
+ return 0;
+
+ if (n == 0)
+ return -2;
+
+ if (*t >= 0xa0)
+ {
+ int iso_idx = __iso_8859_index (charset + 9);
+ if (iso_idx >= 0)
+ {
+ *pwc = __iso_8859_conv[iso_idx][*t - 0xa0];
+ if (*pwc == 0) /* Invalid character */
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ return 1;
+ }
+ }
+
+ *pwc = (wchar_t) *t;
+
+ if (*t == '\0')
+ return 0;
+
+ return 1;
+}
+#endif /* _MB_EXTENDED_CHARSETS_ISO */
+
+#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
+int
+_DEFUN (__cp_mbtowc, (r, pwc, s, n, charset, state),
+ struct _reent *r _AND
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wchar_t dummy;
+ unsigned char *t = (unsigned char *)s;
+
+ if (pwc == NULL)
+ pwc = &dummy;
+
+ if (s == NULL)
+ return 0;
+
+ if (n == 0)
+ return -2;
+
+ if (*t >= 0x80)
+ {
+ int cp_idx = __cp_index (charset + 2);
+ if (cp_idx >= 0)
+ {
+ *pwc = __cp_conv[cp_idx][*t - 0x80];
+ if (*pwc == 0) /* Invalid character */
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ return 1;
+ }
+ }
+
+ *pwc = (wchar_t)*t;
+
+ if (*t == '\0')
+ return 0;
+
+ return 1;
+}
+#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
+
+int
+_DEFUN (__utf8_mbtowc, (r, pwc, s, n, charset, state),
+ struct _reent *r _AND
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wchar_t dummy;
+ unsigned char *t = (unsigned char *)s;
+ int ch;
+ int i = 0;
+
+ if (pwc == NULL)
+ pwc = &dummy;
+
+ if (s == NULL)
+ return 0;
+
+ if (n == 0)
+ return -2;
+
+ if (state->__count == 0)
+ ch = t[i++];
+ else
+ ch = state->__value.__wchb[0];
+
+ if (ch == '\0')
+ {
+ *pwc = 0;
+ state->__count = 0;
+ return 0; /* s points to the null character */
+ }
+
+ if (ch <= 0x7f)
+ {
+ /* single-byte sequence */
+ state->__count = 0;
+ *pwc = ch;
+ return 1;
+ }
+ if (ch >= 0xc0 && ch <= 0xdf)
+ {
+ /* two-byte sequence */
+ state->__value.__wchb[0] = ch;
+ if (state->__count == 0)
+ state->__count = 1;
+ else if (n < (size_t)-1)
+ ++n;
+ if (n < 2)
+ return -2;
+ ch = t[i++];
+ if (ch < 0x80 || ch > 0xbf)
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ if (state->__value.__wchb[0] < 0xc2)
+ {
+ /* overlong UTF-8 sequence */
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ state->__count = 0;
+ *pwc = (wchar_t)((state->__value.__wchb[0] & 0x1f) << 6)
+ | (wchar_t)(ch & 0x3f);
+ return i;
+ }
+ if (ch >= 0xe0 && ch <= 0xef)
+ {
+ /* three-byte sequence */
+ wchar_t tmp;
+ state->__value.__wchb[0] = ch;
+ if (state->__count == 0)
+ state->__count = 1;
+ else if (n < (size_t)-1)
+ ++n;
+ if (n < 2)
+ return -2;
+ ch = (state->__count == 1) ? t[i++] : state->__value.__wchb[1];
+ if (state->__value.__wchb[0] == 0xe0 && ch < 0xa0)
+ {
+ /* overlong UTF-8 sequence */
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ if (ch < 0x80 || ch > 0xbf)
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ state->__value.__wchb[1] = ch;
+ if (state->__count == 1)
+ state->__count = 2;
+ else if (n < (size_t)-1)
+ ++n;
+ if (n < 3)
+ return -2;
+ ch = t[i++];
+ if (ch < 0x80 || ch > 0xbf)
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ state->__count = 0;
+ tmp = (wchar_t)((state->__value.__wchb[0] & 0x0f) << 12)
+ | (wchar_t)((state->__value.__wchb[1] & 0x3f) << 6)
+ | (wchar_t)(ch & 0x3f);
+ *pwc = tmp;
+ return i;
+ }
+ if (ch >= 0xf0 && ch <= 0xf4)
+ {
+ /* four-byte sequence */
+ wint_t tmp;
+ state->__value.__wchb[0] = ch;
+ if (state->__count == 0)
+ state->__count = 1;
+ else if (n < (size_t)-1)
+ ++n;
+ if (n < 2)
+ return -2;
+ ch = (state->__count == 1) ? t[i++] : state->__value.__wchb[1];
+ if ((state->__value.__wchb[0] == 0xf0 && ch < 0x90)
+ || (state->__value.__wchb[0] == 0xf4 && ch >= 0x90))
+ {
+ /* overlong UTF-8 sequence or result is > 0x10ffff */
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ if (ch < 0x80 || ch > 0xbf)
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ state->__value.__wchb[1] = ch;
+ if (state->__count == 1)
+ state->__count = 2;
+ else if (n < (size_t)-1)
+ ++n;
+ if (n < 3)
+ return -2;
+ ch = (state->__count == 2) ? t[i++] : state->__value.__wchb[2];
+ if (ch < 0x80 || ch > 0xbf)
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ state->__value.__wchb[2] = ch;
+ if (state->__count == 2)
+ state->__count = 3;
+ else if (n < (size_t)-1)
+ ++n;
+ if (state->__count == 3 && sizeof(wchar_t) == 2)
+ {
+ /* On systems which have wchar_t being UTF-16 values, the value
+ doesn't fit into a single wchar_t in this case. So what we
+ do here is to store the state with a special value of __count
+ and return the first half of a surrogate pair. The first
+ three bytes of a UTF-8 sequence are enough to generate the
+ first half of a UTF-16 surrogate pair. As return value we
+ choose to return the number of bytes actually read up to
+ here.
+ The second half of the surrogate pair is returned in case we
+ recognize the special __count value of four, and the next
+ byte is actually a valid value. See below. */
+ tmp = (wint_t)((state->__value.__wchb[0] & 0x07) << 18)
+ | (wint_t)((state->__value.__wchb[1] & 0x3f) << 12)
+ | (wint_t)((state->__value.__wchb[2] & 0x3f) << 6);
+ state->__count = 4;
+ *pwc = 0xd800 | ((tmp - 0x10000) >> 10);
+ return i;
+ }
+ if (n < 4)
+ return -2;
+ ch = t[i++];
+ if (ch < 0x80 || ch > 0xbf)
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ tmp = (wint_t)((state->__value.__wchb[0] & 0x07) << 18)
+ | (wint_t)((state->__value.__wchb[1] & 0x3f) << 12)
+ | (wint_t)((state->__value.__wchb[2] & 0x3f) << 6)
+ | (wint_t)(ch & 0x3f);
+ if (state->__count == 4 && sizeof(wchar_t) == 2)
+ /* Create the second half of the surrogate pair for systems with
+ wchar_t == UTF-16 . */
+ *pwc = 0xdc00 | (tmp & 0x3ff);
+ else
+ *pwc = tmp;
+ state->__count = 0;
+ return i;
+ }
+
+ r->_errno = EILSEQ;
+ return -1;
+}
+
+/* Cygwin defines its own doublebyte charset conversion functions
+ because the underlying OS requires wchar_t == UTF-16. */
+#ifndef __CYGWIN__
+int
+_DEFUN (__sjis_mbtowc, (r, pwc, s, n, charset, state),
+ struct _reent *r _AND
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wchar_t dummy;
+ unsigned char *t = (unsigned char *)s;
+ int ch;
+ int i = 0;
+
+ if (pwc == NULL)
+ pwc = &dummy;
+
+ if (s == NULL)
+ return 0; /* not state-dependent */
+
+ if (n == 0)
+ return -2;
+
+ ch = t[i++];
+ if (state->__count == 0)
+ {
+ if (_issjis1 (ch))
+ {
+ state->__value.__wchb[0] = ch;
+ state->__count = 1;
+ if (n <= 1)
+ return -2;
+ ch = t[i++];
+ }
+ }
+ if (state->__count == 1)
+ {
+ if (_issjis2 (ch))
+ {
+ *pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)ch;
+ state->__count = 0;
+ return i;
+ }
+ else
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ }
+
+ *pwc = (wchar_t)*t;
+
+ if (*t == '\0')
+ return 0;
+
+ return 1;
+}
+
+int
+_DEFUN (__eucjp_mbtowc, (r, pwc, s, n, charset, state),
+ struct _reent *r _AND
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wchar_t dummy;
+ unsigned char *t = (unsigned char *)s;
+ int ch;
+ int i = 0;
+
+ if (pwc == NULL)
+ pwc = &dummy;
+
+ if (s == NULL)
+ return 0;
+
+ if (n == 0)
+ return -2;
+
+ ch = t[i++];
+ if (state->__count == 0)
+ {
+ if (_iseucjp1 (ch))
+ {
+ state->__value.__wchb[0] = ch;
+ state->__count = 1;
+ if (n <= 1)
+ return -2;
+ ch = t[i++];
+ }
+ }
+ if (state->__count == 1)
+ {
+ if (_iseucjp2 (ch))
+ {
+ if (state->__value.__wchb[0] == 0x8f)
+ {
+ state->__value.__wchb[1] = ch;
+ state->__count = 2;
+ if (n <= i)
+ return -2;
+ ch = t[i++];
+ }
+ else
+ {
+ *pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)ch;
+ state->__count = 0;
+ return i;
+ }
+ }
+ else
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ }
+ if (state->__count == 2)
+ {
+ if (_iseucjp2 (ch))
+ {
+ *pwc = (((wchar_t)state->__value.__wchb[1]) << 8)
+ + (wchar_t)(ch & 0x7f);
+ state->__count = 0;
+ return i;
+ }
+ else
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ }
+
+ *pwc = (wchar_t)*t;
+
+ if (*t == '\0')
+ return 0;
+
+ return 1;
+}
+
+int
+_DEFUN (__jis_mbtowc, (r, pwc, s, n, charset, state),
+ struct _reent *r _AND
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wchar_t dummy;
+ unsigned char *t = (unsigned char *)s;
+ JIS_STATE curr_state;
+ JIS_ACTION action;
+ JIS_CHAR_TYPE ch;
+ unsigned char *ptr;
+ unsigned int i;
+ int curr_ch;
+
+ if (pwc == NULL)
+ pwc = &dummy;
+
+ if (s == NULL)
+ {
+ state->__state = ASCII;
+ return 1; /* state-dependent */
+ }
+
+ if (n == 0)
+ return -2;
+
+ curr_state = state->__state;
+ ptr = t;
+
+ for (i = 0; i < n; ++i)
+ {
+ curr_ch = t[i];
+ switch (curr_ch)
+ {
+ case ESC_CHAR:
+ ch = ESCAPE;
+ break;
+ case '$':
+ ch = DOLLAR;
+ break;
+ case '@':
+ ch = AT;
+ break;
+ case '(':
+ ch = BRACKET;
+ break;
+ case 'B':
+ ch = B;
+ break;
+ case 'J':
+ ch = J;
+ break;
+ case '\0':
+ ch = NUL;
+ break;
+ default:
+ if (_isjis (curr_ch))
+ ch = JIS_CHAR;
+ else
+ ch = OTHER;
+ }
+
+ action = JIS_action_table[curr_state][ch];
+ curr_state = JIS_state_table[curr_state][ch];
+
+ switch (action)
+ {
+ case NOOP:
+ break;
+ case EMPTY:
+ state->__state = ASCII;
+ *pwc = (wchar_t)0;
+ return 0;
+ case COPY_A:
+ state->__state = ASCII;
+ *pwc = (wchar_t)*ptr;
+ return (i + 1);
+ case COPY_J1:
+ state->__value.__wchb[0] = t[i];
+ break;
+ case COPY_J2:
+ state->__state = JIS;
+ *pwc = (((wchar_t)state->__value.__wchb[0]) << 8) + (wchar_t)(t[i]);
+ return (i + 1);
+ case MAKE_A:
+ ptr = (unsigned char *)(t + i + 1);
+ break;
+ case ERROR:
+ default:
+ r->_errno = EILSEQ;
+ return -1;
+ }
+
+ }
+
+ state->__state = curr_state;
+ return -2; /* n < bytes needed */
+}
+#endif /* !__CYGWIN__*/
+#endif /* _MB_CAPABLE */
mbtowc_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: lrand48.c
===================================================================
--- lrand48.c (nonexistent)
+++ lrand48.c (revision 345)
@@ -0,0 +1,32 @@
+/*
+ * 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"
+
+long
+_DEFUN (_lrand48_r, (r),
+ struct _reent *r)
+{
+ _REENT_CHECK_RAND48(r);
+ __dorand48(r, __rand48_seed);
+ return (long)((unsigned long) __rand48_seed[2] << 15) +
+ ((unsigned long) __rand48_seed[1] >> 1);
+}
+
+#ifndef _REENT_ONLY
+long
+_DEFUN_VOID (lrand48)
+{
+ return _lrand48_r (_REENT);
+}
+#endif /* !_REENT_ONLY */
lrand48.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wctomb_r.c
===================================================================
--- wctomb_r.c (nonexistent)
+++ wctomb_r.c (revision 345)
@@ -0,0 +1,371 @@
+#include
+#include
+#include
+#include
+#include
+#include "mbctype.h"
+#include "local.h"
+
+int (*__wctomb) (struct _reent *, char *, wchar_t, const char *charset,
+ mbstate_t *)
+#ifdef __CYGWIN__
+ = __utf8_wctomb;
+#else
+ = __ascii_wctomb;
+#endif
+
+int
+_DEFUN (_wctomb_r, (r, s, wchar, state),
+ struct _reent *r _AND
+ char *s _AND
+ wchar_t _wchar _AND
+ mbstate_t *state)
+{
+ return __wctomb (r, s, _wchar, __locale_charset (), state);
+}
+
+int
+_DEFUN (__ascii_wctomb, (r, s, wchar, charset, state),
+ struct _reent *r _AND
+ char *s _AND
+ wchar_t _wchar _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ /* Avoids compiler warnings about comparisons that are always false
+ due to limited range when sizeof(wchar_t) is 2 but sizeof(wint_t)
+ is 4, as is the case on cygwin. */
+ wint_t wchar = _wchar;
+
+ if (s == NULL)
+ return 0;
+
+ if ((size_t)wchar >= 0x100)
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+
+ *s = (char) wchar;
+ return 1;
+}
+
+#ifdef _MB_CAPABLE
+/* for some conversions, we use the __count field as a place to store a state value */
+#define __state __count
+
+int
+_DEFUN (__utf8_wctomb, (r, s, wchar, charset, state),
+ struct _reent *r _AND
+ char *s _AND
+ wchar_t _wchar _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wint_t wchar = _wchar;
+ int ret = 0;
+
+ if (s == NULL)
+ return 0; /* UTF-8 encoding is not state-dependent */
+
+ if (sizeof (wchar_t) == 2 && state->__count == -4
+ && (wchar < 0xdc00 || wchar >= 0xdfff))
+ {
+ /* There's a leftover lone high surrogate. Write out the CESU-8 value
+ of the surrogate and proceed to convert the given character. Note
+ to return extra 3 bytes. */
+ wchar_t tmp;
+ tmp = (state->__value.__wchb[0] << 16 | state->__value.__wchb[1] << 8)
+ - 0x10000 >> 10 | 0xd80d;
+ *s++ = 0xe0 | ((tmp & 0xf000) >> 12);
+ *s++ = 0x80 | ((tmp & 0xfc0) >> 6);
+ *s++ = 0x80 | (tmp & 0x3f);
+ state->__count = 0;
+ ret = 3;
+ }
+ if (wchar <= 0x7f)
+ {
+ *s = wchar;
+ return ret + 1;
+ }
+ if (wchar >= 0x80 && wchar <= 0x7ff)
+ {
+ *s++ = 0xc0 | ((wchar & 0x7c0) >> 6);
+ *s = 0x80 | (wchar & 0x3f);
+ return ret + 2;
+ }
+ if (wchar >= 0x800 && wchar <= 0xffff)
+ {
+ /* No UTF-16 surrogate handling in UCS-4 */
+ if (sizeof (wchar_t) == 2 && wchar >= 0xd800 && wchar <= 0xdfff)
+ {
+ wint_t tmp;
+ if (wchar <= 0xdbff)
+ {
+ /* First half of a surrogate pair. Store the state and
+ return ret + 0. */
+ tmp = ((wchar & 0x3ff) << 10) + 0x10000;
+ state->__value.__wchb[0] = (tmp >> 16) & 0xff;
+ state->__value.__wchb[1] = (tmp >> 8) & 0xff;
+ state->__count = -4;
+ *s = (0xf0 | ((tmp & 0x1c0000) >> 18));
+ return ret;
+ }
+ if (state->__count == -4)
+ {
+ /* Second half of a surrogate pair. Reconstruct the full
+ Unicode value and return the trailing three bytes of the
+ UTF-8 character. */
+ tmp = (state->__value.__wchb[0] << 16)
+ | (state->__value.__wchb[1] << 8)
+ | (wchar & 0x3ff);
+ state->__count = 0;
+ *s++ = 0xf0 | ((tmp & 0x1c0000) >> 18);
+ *s++ = 0x80 | ((tmp & 0x3f000) >> 12);
+ *s++ = 0x80 | ((tmp & 0xfc0) >> 6);
+ *s = 0x80 | (tmp & 0x3f);
+ return 4;
+ }
+ /* Otherwise translate into CESU-8 value. */
+ }
+ *s++ = 0xe0 | ((wchar & 0xf000) >> 12);
+ *s++ = 0x80 | ((wchar & 0xfc0) >> 6);
+ *s = 0x80 | (wchar & 0x3f);
+ return ret + 3;
+ }
+ if (wchar >= 0x10000 && wchar <= 0x10ffff)
+ {
+ *s++ = 0xf0 | ((wchar & 0x1c0000) >> 18);
+ *s++ = 0x80 | ((wchar & 0x3f000) >> 12);
+ *s++ = 0x80 | ((wchar & 0xfc0) >> 6);
+ *s = 0x80 | (wchar & 0x3f);
+ return 4;
+ }
+
+ r->_errno = EILSEQ;
+ return -1;
+}
+
+/* Cygwin defines its own doublebyte charset conversion functions
+ because the underlying OS requires wchar_t == UTF-16. */
+#ifndef __CYGWIN__
+int
+_DEFUN (__sjis_wctomb, (r, s, wchar, charset, state),
+ struct _reent *r _AND
+ char *s _AND
+ wchar_t _wchar _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wint_t wchar = _wchar;
+
+ unsigned char char2 = (unsigned char)wchar;
+ unsigned char char1 = (unsigned char)(wchar >> 8);
+
+ if (s == NULL)
+ return 0; /* not state-dependent */
+
+ if (char1 != 0x00)
+ {
+ /* first byte is non-zero..validate multi-byte char */
+ if (_issjis1(char1) && _issjis2(char2))
+ {
+ *s++ = (char)char1;
+ *s = (char)char2;
+ return 2;
+ }
+ else
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ }
+ *s = (char) wchar;
+ return 1;
+}
+
+int
+_DEFUN (__eucjp_wctomb, (r, s, wchar, charset, state),
+ struct _reent *r _AND
+ char *s _AND
+ wchar_t _wchar _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wint_t wchar = _wchar;
+ unsigned char char2 = (unsigned char)wchar;
+ unsigned char char1 = (unsigned char)(wchar >> 8);
+
+ if (s == NULL)
+ return 0; /* not state-dependent */
+
+ if (char1 != 0x00)
+ {
+ /* first byte is non-zero..validate multi-byte char */
+ if (_iseucjp1 (char1) && _iseucjp2 (char2))
+ {
+ *s++ = (char)char1;
+ *s = (char)char2;
+ return 2;
+ }
+ else if (_iseucjp2 (char1) && _iseucjp2 (char2 | 0x80))
+ {
+ *s++ = (char)0x8f;
+ *s++ = (char)char1;
+ *s = (char)(char2 | 0x80);
+ return 3;
+ }
+ else
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ }
+ *s = (char) wchar;
+ return 1;
+}
+
+int
+_DEFUN (__jis_wctomb, (r, s, wchar, charset, state),
+ struct _reent *r _AND
+ char *s _AND
+ wchar_t _wchar _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wint_t wchar = _wchar;
+ int cnt = 0;
+ unsigned char char2 = (unsigned char)wchar;
+ unsigned char char1 = (unsigned char)(wchar >> 8);
+
+ if (s == NULL)
+ return 1; /* state-dependent */
+
+ if (char1 != 0x00)
+ {
+ /* first byte is non-zero..validate multi-byte char */
+ if (_isjis (char1) && _isjis (char2))
+ {
+ if (state->__state == 0)
+ {
+ /* must switch from ASCII to JIS state */
+ state->__state = 1;
+ *s++ = ESC_CHAR;
+ *s++ = '$';
+ *s++ = 'B';
+ cnt = 3;
+ }
+ *s++ = (char)char1;
+ *s = (char)char2;
+ return cnt + 2;
+ }
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ if (state->__state != 0)
+ {
+ /* must switch from JIS to ASCII state */
+ state->__state = 0;
+ *s++ = ESC_CHAR;
+ *s++ = '(';
+ *s++ = 'B';
+ cnt = 3;
+ }
+ *s = (char)char2;
+ return cnt + 1;
+}
+#endif /* !__CYGWIN__ */
+
+#ifdef _MB_EXTENDED_CHARSETS_ISO
+int
+_DEFUN (__iso_wctomb, (r, s, wchar, charset, state),
+ struct _reent *r _AND
+ char *s _AND
+ wchar_t _wchar _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wint_t wchar = _wchar;
+
+ if (s == NULL)
+ return 0;
+
+ /* wchars <= 0x9f translate to all ISO charsets directly. */
+ if (wchar >= 0xa0)
+ {
+ int iso_idx = __iso_8859_index (charset + 9);
+ if (iso_idx >= 0)
+ {
+ unsigned char mb;
+
+ if (s == NULL)
+ return 0;
+
+ for (mb = 0; mb < 0x60; ++mb)
+ if (__iso_8859_conv[iso_idx][mb] == wchar)
+ {
+ *s = (char) (mb + 0xa0);
+ return 1;
+ }
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ }
+
+ if ((size_t)wchar >= 0x100)
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+
+ *s = (char) wchar;
+ return 1;
+}
+#endif /* _MB_EXTENDED_CHARSETS_ISO */
+
+#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
+int
+_DEFUN (__cp_wctomb, (r, s, wchar, charset, state),
+ struct _reent *r _AND
+ char *s _AND
+ wchar_t _wchar _AND
+ const char *charset _AND
+ mbstate_t *state)
+{
+ wint_t wchar = _wchar;
+
+ if (s == NULL)
+ return 0;
+
+ if (wchar >= 0x80)
+ {
+ int cp_idx = __cp_index (charset + 2);
+ if (cp_idx >= 0)
+ {
+ unsigned char mb;
+
+ if (s == NULL)
+ return 0;
+
+ for (mb = 0; mb < 0x80; ++mb)
+ if (__cp_conv[cp_idx][mb] == wchar)
+ {
+ *s = (char) (mb + 0x80);
+ return 1;
+ }
+ r->_errno = EILSEQ;
+ return -1;
+ }
+ }
+
+ if ((size_t)wchar >= 0x100)
+ {
+ r->_errno = EILSEQ;
+ return -1;
+ }
+
+ *s = (char) wchar;
+ return 1;
+}
+#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
+#endif /* _MB_CAPABLE */
wctomb_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mrand48.c
===================================================================
--- mrand48.c (nonexistent)
+++ mrand48.c (revision 345)
@@ -0,0 +1,31 @@
+/*
+ * 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"
+
+long
+_DEFUN (_mrand48_r, (r),
+ struct _reent *r)
+{
+ _REENT_CHECK_RAND48(r);
+ __dorand48(r, __rand48_seed);
+ return ((long) __rand48_seed[2] << 16) + (long) __rand48_seed[1];
+}
+
+#ifndef _REENT_ONLY
+long
+_DEFUN_VOID (mrand48)
+{
+ return _mrand48_r (_REENT);
+}
+#endif /* !_REENT_ONLY */
mrand48.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: nrand48.c
===================================================================
--- nrand48.c (nonexistent)
+++ nrand48.c (revision 345)
@@ -0,0 +1,33 @@
+/*
+ * 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"
+
+long
+_DEFUN (_nrand48_r, (r, xseed),
+ struct _reent *r _AND
+ unsigned short xseed[3])
+{
+ __dorand48 (r, xseed);
+ return (long)((unsigned long) xseed[2] << 15) +
+ ((unsigned long) xseed[1] >> 1);
+}
+
+#ifndef _REENT_ONLY
+long
+_DEFUN (nrand48, (xseed),
+ unsigned short xseed[3])
+{
+ return _nrand48_r (_REENT, xseed);
+}
+#endif /* !_REENT_ONLY */
nrand48.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: gdtoa-gethex.c
===================================================================
--- gdtoa-gethex.c (nonexistent)
+++ gdtoa-gethex.c (revision 345)
@@ -0,0 +1,354 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to David M. Gay (dmg at acm dot org,
+ * with " at " changed at "@" and " dot " changed to "."). */
+
+#include <_ansi.h>
+#include
+#include
+#include "mprec.h"
+#include "gdtoa.h"
+#include "gd_qnan.h"
+#include "locale.h"
+
+unsigned char hexdig[256];
+
+static void
+_DEFUN (htinit, (h, s, inc),
+ unsigned char *h _AND
+ unsigned char *s _AND
+ int inc)
+{
+ int i, j;
+ for(i = 0; (j = s[i]) !=0; i++)
+ h[j] = i + inc;
+}
+
+void
+_DEFUN_VOID (hexdig_init)
+{
+#define USC (unsigned char *)
+ htinit(hexdig, USC "0123456789", 0x10);
+ htinit(hexdig, USC "abcdef", 0x10 + 10);
+ htinit(hexdig, USC "ABCDEF", 0x10 + 10);
+}
+
+static void
+_DEFUN(rshift, (b, k),
+ _Bigint *b _AND
+ int k)
+{
+ __ULong *x, *x1, *xe, y;
+ int n;
+
+ x = x1 = b->_x;
+ n = k >> kshift;
+ if (n < b->_wds) {
+ xe = x + b->_wds;
+ x += n;
+ if (k &= kmask) {
+ n = ULbits - k;
+ y = *x++ >> k;
+ while(x < xe) {
+ *x1++ = (y | (*x << n)) & ALL_ON;
+ y = *x++ >> k;
+ }
+ if ((*x1 = y) !=0)
+ x1++;
+ }
+ else
+ while(x < xe)
+ *x1++ = *x++;
+ }
+ if ((b->_wds = x1 - b->_x) == 0)
+ b->_x[0] = 0;
+}
+
+static _Bigint *
+_DEFUN (increment, (ptr, b),
+ struct _reent *ptr _AND
+ _Bigint *b)
+{
+ __ULong *x, *xe;
+ _Bigint *b1;
+#ifdef Pack_16
+ __ULong carry = 1, y;
+#endif
+
+ x = b->_x;
+ xe = x + b->_wds;
+#ifdef Pack_32
+ do {
+ if (*x < (__ULong)0xffffffffL) {
+ ++*x;
+ return b;
+ }
+ *x++ = 0;
+ } while(x < xe);
+#else
+ do {
+ y = *x + carry;
+ carry = y >> 16;
+ *x++ = y & 0xffff;
+ if (!carry)
+ return b;
+ } while(x < xe);
+ if (carry)
+#endif
+ {
+ if (b->_wds >= b->_maxwds) {
+ b1 = Balloc(ptr, b->_k+1);
+ Bcopy(b1, b);
+ Bfree(ptr, b);
+ b = b1;
+ }
+ b->_x[b->_wds++] = 1;
+ }
+ return b;
+}
+
+
+int
+_DEFUN(gethex, (ptr, sp, fpi, exp, bp, sign),
+ struct _reent *ptr _AND
+ _CONST char **sp _AND
+ FPI *fpi _AND
+ Long *exp _AND
+ _Bigint **bp _AND
+ int sign)
+{
+ _Bigint *b;
+ _CONST unsigned char *decpt, *s0, *s, *s1;
+ int esign, havedig, irv, k, n, nbits, up, zret;
+ __ULong L, lostbits, *x;
+ Long e, e1;
+ unsigned char *decimalpoint = (unsigned char *)
+ _localeconv_r (ptr)->decimal_point;
+ size_t decp_len = strlen ((const char *) decimalpoint);
+ unsigned char decp_end = decimalpoint[decp_len - 1];
+
+ if (!hexdig['0'])
+ hexdig_init();
+ havedig = 0;
+ s0 = *(_CONST unsigned char **)sp + 2;
+ while(s0[havedig] == '0')
+ havedig++;
+ s0 += havedig;
+ s = s0;
+ decpt = 0;
+ zret = 0;
+ e = 0;
+ if (!hexdig[*s]) {
+ zret = 1;
+ if (strncmp ((const char *) s, (const char *) decimalpoint,
+ decp_len) != 0)
+ goto pcheck;
+ decpt = (s += decp_len);
+ if (!hexdig[*s])
+ goto pcheck;
+ while(*s == '0')
+ s++;
+ if (hexdig[*s])
+ zret = 0;
+ havedig = 1;
+ s0 = s;
+ }
+ while(hexdig[*s])
+ s++;
+ if (strncmp ((const char *) s, (const char *) decimalpoint,
+ decp_len) == 0
+ && !decpt) {
+ decpt = (s += decp_len);
+ while(hexdig[*s])
+ s++;
+ }
+ if (decpt)
+ e = -(((Long)(s-decpt)) << 2);
+ pcheck:
+ s1 = s;
+ switch(*s) {
+ case 'p':
+ case 'P':
+ esign = 0;
+ switch(*++s) {
+ case '-':
+ esign = 1;
+ /* no break */
+ case '+':
+ s++;
+ }
+ if ((n = hexdig[*s]) == 0 || n > 0x19) {
+ s = s1;
+ break;
+ }
+ e1 = n - 0x10;
+ while((n = hexdig[*++s]) !=0 && n <= 0x19)
+ e1 = 10*e1 + n - 0x10;
+ if (esign)
+ e1 = -e1;
+ e += e1;
+ }
+ *sp = (char*)s;
+ if (zret)
+ return havedig ? STRTOG_Zero : STRTOG_NoNumber;
+ n = s1 - s0 - 1;
+ for(k = 0; n > 7; n >>= 1)
+ k++;
+ b = Balloc(ptr, k);
+ x = b->_x;
+ n = 0;
+ L = 0;
+ while(s1 > s0) {
+ if (*--s1 == decp_end && s1 - decp_len + 1 >= s0
+ && strncmp ((const char *) s1 - decp_len + 1,
+ (const char *) decimalpoint, decp_len) == 0) {
+ s1 -= decp_len - 1; /* Note the --s1 above! */
+ continue;
+ }
+ if (n == 32) {
+ *x++ = L;
+ L = 0;
+ n = 0;
+ }
+ L |= (hexdig[*s1] & 0x0f) << n;
+ n += 4;
+ }
+ *x++ = L;
+ b->_wds = n = x - b->_x;
+ n = 32*n - hi0bits(L);
+ nbits = fpi->nbits;
+ lostbits = 0;
+ x = b->_x;
+ if (n > nbits) {
+ n -= nbits;
+ if (any_on(b,n)) {
+ lostbits = 1;
+ k = n - 1;
+ if (x[k>>kshift] & 1 << (k & kmask)) {
+ lostbits = 2;
+ if (k > 1 && any_on(b,k-1))
+ lostbits = 3;
+ }
+ }
+ rshift(b, n);
+ e += n;
+ }
+ else if (n < nbits) {
+ n = nbits - n;
+ b = lshift(ptr, b, n);
+ e -= n;
+ x = b->_x;
+ }
+ if (e > fpi->emax) {
+ ovfl:
+ Bfree(ptr, b);
+ *bp = 0;
+ return STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi;
+ }
+ irv = STRTOG_Normal;
+ if (e < fpi->emin) {
+ irv = STRTOG_Denormal;
+ n = fpi->emin - e;
+ if (n >= nbits) {
+ switch (fpi->rounding) {
+ case FPI_Round_near:
+ if (n == nbits && (n < 2 || any_on(b,n-1)))
+ goto one_bit;
+ break;
+ case FPI_Round_up:
+ if (!sign)
+ goto one_bit;
+ break;
+ case FPI_Round_down:
+ if (sign) {
+ one_bit:
+ *exp = fpi->emin;
+ x[0] = b->_wds = 1;
+ *bp = b;
+ return STRTOG_Denormal | STRTOG_Inexhi
+ | STRTOG_Underflow;
+ }
+ }
+ Bfree(ptr, b);
+ *bp = 0;
+ return STRTOG_Zero | STRTOG_Inexlo | STRTOG_Underflow;
+ }
+ k = n - 1;
+ if (lostbits)
+ lostbits = 1;
+ else if (k > 0)
+ lostbits = any_on(b,k);
+ if (x[k>>kshift] & 1 << (k & kmask))
+ lostbits |= 2;
+ nbits -= n;
+ rshift(b,n);
+ e = fpi->emin;
+ }
+ if (lostbits) {
+ up = 0;
+ switch(fpi->rounding) {
+ case FPI_Round_zero:
+ break;
+ case FPI_Round_near:
+ if ((lostbits & 2)
+ && ((lostbits & 1) | (x[0] & 1)))
+ up = 1;
+ break;
+ case FPI_Round_up:
+ up = 1 - sign;
+ break;
+ case FPI_Round_down:
+ up = sign;
+ }
+ if (up) {
+ k = b->_wds;
+ b = increment(ptr, b);
+ x = b->_x;
+ if (irv == STRTOG_Denormal) {
+ if (nbits == fpi->nbits - 1
+ && x[nbits >> kshift] & 1 << (nbits & kmask))
+ irv = STRTOG_Normal;
+ }
+ else if ((b->_wds > k)
+ || ((n = nbits & kmask) !=0
+ && (hi0bits(x[k-1]) < 32-n))) {
+ rshift(b,1);
+ if (++e > fpi->emax)
+ goto ovfl;
+ }
+ irv |= STRTOG_Inexhi;
+ }
+ else
+ irv |= STRTOG_Inexlo;
+ }
+ *bp = b;
+ *exp = e;
+ return irv;
+}
+
gdtoa-gethex.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcstombs_r.c
===================================================================
--- wcstombs_r.c (nonexistent)
+++ wcstombs_r.c (revision 345)
@@ -0,0 +1,43 @@
+#include
+#include
+#include "local.h"
+
+size_t
+_DEFUN (_wcstombs_r, (reent, s, pwcs, n, state),
+ struct _reent *r _AND
+ char *s _AND
+ const wchar_t *pwcs _AND
+ size_t n _AND
+ mbstate_t *state)
+{
+ char *ptr = s;
+ size_t max = n;
+ char buff[8];
+ int i, num_to_copy;
+
+ if (s == NULL)
+ {
+ size_t num_bytes = 0;
+ while (*pwcs != 0)
+ num_bytes += __wctomb (r, buff, *pwcs++, __locale_charset (), state);
+ return num_bytes;
+ }
+ else
+ {
+ while (n > 0)
+ {
+ int bytes = __wctomb (r, buff, *pwcs, __locale_charset (), state);
+ if (bytes == -1)
+ return -1;
+ num_to_copy = (n > bytes ? bytes : (int)n);
+ for (i = 0; i < num_to_copy; ++i)
+ *ptr++ = buff[i];
+
+ if (*pwcs == 0x00)
+ return ptr - s - (n >= bytes);
+ ++pwcs;
+ n -= num_to_copy;
+ }
+ return max;
+ }
+}
wcstombs_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: srand48.c
===================================================================
--- srand48.c (nonexistent)
+++ srand48.c (revision 345)
@@ -0,0 +1,38 @@
+/*
+ * 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"
+
+_VOID
+_DEFUN (_srand48_r, (r, seed),
+ struct _reent *r _AND
+ long seed)
+{
+ _REENT_CHECK_RAND48(r);
+ __rand48_seed[0] = _RAND48_SEED_0;
+ __rand48_seed[1] = (unsigned short) seed;
+ __rand48_seed[2] = (unsigned short) ((unsigned long)seed >> 16);
+ __rand48_mult[0] = _RAND48_MULT_0;
+ __rand48_mult[1] = _RAND48_MULT_1;
+ __rand48_mult[2] = _RAND48_MULT_2;
+ __rand48_add = _RAND48_ADD;
+}
+
+#ifndef _REENT_ONLY
+_VOID
+_DEFUN (srand48, (seed),
+ long seed)
+{
+ _srand48_r (_REENT, seed);
+}
+#endif /* !_REENT_ONLY */
srand48.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: __ten_mu.c
===================================================================
--- __ten_mu.c (nonexistent)
+++ __ten_mu.c (revision 345)
@@ -0,0 +1,24 @@
+/*
+ * [atw] multiply 64 bit accumulator by 10 and add digit.
+ * The KA/CA way to do this should be to use
+ * a 64-bit integer internally and use "adjust" to
+ * convert it to float at the end of processing.
+ */
+
+#include <_ansi.h>
+#include "std.h"
+
+int
+_DEFUN (__ten_mul, (acc, digit),
+ double *acc _AND
+ int digit)
+{
+ /*
+ * [atw] Crude, but effective (at least on a KB)...
+ */
+
+ *acc *= 10;
+ *acc += digit;
+
+ return 0; /* no overflow */
+}
__ten_mu.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: msize.c
===================================================================
--- msize.c (nonexistent)
+++ msize.c (revision 345)
@@ -0,0 +1,19 @@
+#ifndef MALLOC_PROVIDED
+/* msize.c -- a wrapper for malloc_usable_size. */
+
+#include <_ansi.h>
+#include
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+size_t
+_DEFUN (malloc_usable_size, (ptr),
+ _PTR ptr)
+{
+ return _malloc_usable_size_r (_REENT, ptr);
+}
+
+#endif
+#endif
msize.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: cxa_atexit.c
===================================================================
--- cxa_atexit.c (nonexistent)
+++ cxa_atexit.c (revision 345)
@@ -0,0 +1,23 @@
+/*
+ * Implementation of __cxa_atexit.
+ */
+
+#include
+#include
+#include
+#include
+#include "atexit.h"
+
+/*
+ * 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)
+{
+ return __register_exitproc (__et_cxa, (void (*)(void)) fn, arg, d);
+}
cxa_atexit.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mbtowc.c
===================================================================
--- mbtowc.c (nonexistent)
+++ mbtowc.c (revision 345)
@@ -0,0 +1,95 @@
+/*
+FUNCTION
+<>---minimal multibyte to wide char converter
+
+INDEX
+ mbtowc
+
+ANSI_SYNOPSIS
+ #include
+ int mbtowc(wchar_t *<[pwc]>, const char *<[s]>, size_t <[n]>);
+
+TRAD_SYNOPSIS
+ #include
+ int mbtowc(<[pwc]>, <[s]>, <[n]>)
+ wchar_t *<[pwc]>;
+ const char *<[s]>;
+ size_t <[n]>;
+
+DESCRIPTION
+When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming
+implementation of <>. In this case,
+only ``multi-byte character sequences'' recognized are single bytes,
+and they are ``converted'' to themselves.
+Each call to <> copies one character from <<*<[s]>>> to
+<<*<[pwc]>>>, unless <[s]> is a null pointer. The argument n
+is ignored.
+
+When _MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform
+the conversion, passing a state variable to allow state dependent
+decoding. The result is based on the locale setting which may
+be restricted to a defined set of locales.
+
+RETURNS
+This implementation of <> returns <<0>> if
+<[s]> is <> or is the empty string;
+it returns <<1>> if not _MB_CAPABLE or
+the character is a single-byte character; it returns <<-1>>
+if n is <<0>> or the multi-byte character is invalid;
+otherwise it returns the number of bytes in the multibyte character.
+If the return value is -1, no changes are made to the <>
+output string. If the input is the empty string, a wchar_t nul
+is placed in the output string and 0 is returned. If the input
+has a length of 0, no changes are made to the <> output string.
+
+PORTABILITY
+<> is required in the ANSI C standard. However, the precise
+effects vary with the locale.
+
+<> requires no supporting OS subroutines.
+*/
+
+#ifndef _REENT_ONLY
+
+#include
+#include
+#include
+#include "local.h"
+
+int
+_DEFUN (mbtowc, (pwc, s, n),
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n)
+{
+#ifdef _MB_CAPABLE
+ int retval = 0;
+ mbstate_t *ps;
+
+ _REENT_CHECK_MISC(_REENT);
+ ps = &(_REENT_MBTOWC_STATE(_REENT));
+
+ retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps);
+
+ if (retval < 0)
+ {
+ ps->__count = 0;
+ return -1;
+ }
+ return retval;
+#else /* not _MB_CAPABLE */
+ if (s == NULL)
+ return 0;
+ if (n == 0)
+ return -1;
+ if (pwc)
+ *pwc = (wchar_t) *s;
+ return (*s != '\0');
+#endif /* not _MB_CAPABLE */
+}
+
+#endif /* !_REENT_ONLY */
+
+
+
+
mbtowc.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wctomb.c
===================================================================
--- wctomb.c (nonexistent)
+++ wctomb.c (revision 345)
@@ -0,0 +1,79 @@
+/*
+FUNCTION
+<>---minimal wide char to multibyte converter
+
+INDEX
+ wctomb
+
+ANSI_SYNOPSIS
+ #include
+ int wctomb(char *<[s]>, wchar_t <[wchar]>);
+
+TRAD_SYNOPSIS
+ #include
+ int wctomb(<[s]>, <[wchar]>)
+ char *<[s]>;
+ wchar_t <[wchar]>;
+
+DESCRIPTION
+When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming
+implementation of <>. The
+only ``wide characters'' recognized are single bytes,
+and they are ``converted'' to themselves.
+
+When _MB_CAPABLE is defined, this routine calls <<_wctomb_r>> to perform
+the conversion, passing a state variable to allow state dependent
+decoding. The result is based on the locale setting which may
+be restricted to a defined set of locales.
+
+Each call to <> modifies <<*<[s]>>> unless <[s]> is a null
+pointer or _MB_CAPABLE is defined and <[wchar]> is invalid.
+
+RETURNS
+This implementation of <> returns <<0>> if
+<[s]> is <>; it returns <<-1>> if _MB_CAPABLE is enabled
+and the wchar is not a valid multi-byte character, it returns <<1>>
+if _MB_CAPABLE is not defined or the wchar is in reality a single
+byte character, otherwise it returns the number of bytes in the
+multi-byte character.
+
+PORTABILITY
+<> is required in the ANSI C standard. However, the precise
+effects vary with the locale.
+
+<> requires no supporting OS subroutines.
+*/
+
+#ifndef _REENT_ONLY
+
+#include
+#include
+#include
+#include "local.h"
+
+int
+_DEFUN (wctomb, (s, wchar),
+ char *s _AND
+ wchar_t wchar)
+{
+#ifdef _MB_CAPABLE
+ _REENT_CHECK_MISC(_REENT);
+
+ return __wctomb (_REENT, s, wchar, __locale_charset (),
+ &(_REENT_WCTOMB_STATE(_REENT)));
+#else /* not _MB_CAPABLE */
+ if (s == NULL)
+ return 0;
+
+ /* Verify that wchar is a valid single-byte character. */
+ if ((size_t)wchar >= 0x100) {
+ errno = EILSEQ;
+ return -1;
+ }
+
+ *s = (char) wchar;
+ return 1;
+#endif /* not _MB_CAPABLE */
+}
+
+#endif /* !_REENT_ONLY */
wctomb.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: local.h
===================================================================
--- local.h (nonexistent)
+++ local.h (revision 345)
@@ -0,0 +1,66 @@
+/* Misc. local definitions for libc/stdlib */
+
+#ifndef _LOCAL_H_
+#define _LOCAL_H_
+
+char * _EXFUN(_gcvt,(struct _reent *, double , int , char *, char, int));
+
+char *__locale_charset(_NOARGS);
+
+#ifndef __mbstate_t_defined
+#include
+#endif
+
+extern int (*__wctomb) (struct _reent *, char *, wchar_t, const char *,
+ mbstate_t *);
+int __ascii_wctomb (struct _reent *, char *, wchar_t, const char *,
+ mbstate_t *);
+#ifdef _MB_CAPABLE
+int __utf8_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
+int __sjis_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
+int __eucjp_wctomb (struct _reent *, char *, wchar_t, const char *,
+ mbstate_t *);
+int __jis_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
+int __iso_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
+int __cp_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
+#ifdef __CYGWIN__
+int __gbk_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
+int __kr_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
+int __big5_wctomb (struct _reent *, char *, wchar_t, const char *, mbstate_t *);
+#endif
+#endif
+
+extern int (*__mbtowc) (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+int __ascii_mbtowc (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+#ifdef _MB_CAPABLE
+int __utf8_mbtowc (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+int __sjis_mbtowc (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+int __eucjp_mbtowc (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+int __jis_mbtowc (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+int __iso_mbtowc (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+int __cp_mbtowc (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+#ifdef __CYGWIN__
+int __gbk_mbtowc (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+int __kr_mbtowc (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+int __big5_mbtowc (struct _reent *, wchar_t *, const char *, size_t,
+ const char *, mbstate_t *);
+#endif
+#endif
+
+extern wchar_t __iso_8859_conv[14][0x60];
+int __iso_8859_index (const char *);
+
+extern wchar_t __cp_conv[][0x80];
+int __cp_index (const char *);
+
+#endif
local.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: std.h
===================================================================
--- std.h (nonexistent)
+++ std.h (revision 345)
@@ -0,0 +1,33 @@
+#include
+#include
+#include
+#include
+#include
+#ifndef CYGNUS_NEC
+#include
+#endif
+
+#define Ise(c) ((c == 'e') || (c == 'E') || (c == 'd') || (c == 'D'))
+#define Isdigit(c) ((c <= '9') && (c >= '0'))
+#define Isspace(c) ((c == ' ') || (c == '\t') || (c=='\n') || (c=='\v') \
+ || (c == '\r') || (c == '\f'))
+#define Issign(c) ((c == '-') || (c == '+'))
+#define Val(c) ((c - '0'))
+
+#define MAXE 308
+#define MINE (-308)
+
+/* flags */
+#define SIGN 0x01
+#define ESIGN 0x02
+#define DECP 0x04
+
+#ifdef _HAVE_STDC
+int __ten_mul(double *acc, int digit);
+double __adjust(struct _reent *ptr, double *acc, int dexp, int sign);
+double __exp10(unsigned x);
+#else
+int __ten_mul();
+double __adjust();
+double __exp10();
+#endif
std.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: rand48.c
===================================================================
--- rand48.c (nonexistent)
+++ rand48.c (revision 345)
@@ -0,0 +1,179 @@
+/*
+ * 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.
+ */
+
+/*
+FUNCTION
+ <>, <>, <>, <>, <>, <>, <>, <>, <>, <>---pseudo-random number generators and initialization routines
+
+INDEX
+ rand48
+INDEX
+ drand48
+INDEX
+ erand48
+INDEX
+ lrand48
+INDEX
+ nrand48
+INDEX
+ mrand48
+INDEX
+ jrand48
+INDEX
+ srand48
+INDEX
+ seed48
+INDEX
+ lcong48
+
+ANSI_SYNOPSIS
+ #include
+ double drand48(void);
+ double erand48(unsigned short <[xseed]>[3]);
+ long lrand48(void);
+ long nrand48(unsigned short <[xseed]>[3]);
+ long mrand48(void);
+ long jrand48(unsigned short <[xseed]>[3]);
+ void srand48(long <[seed]>);
+ unsigned short *seed48(unsigned short <[xseed]>[3]);
+ void lcong48(unsigned short <[p]>[7]);
+
+TRAD_SYNOPSIS
+ #include
+ double drand48();
+
+ double erand48(<[xseed]>)
+ unsigned short <[xseed]>[3];
+
+ long lrand48();
+
+ long nrand48(<[xseed]>)
+ unsigned short <[xseed]>[3];
+
+ long mrand48();
+
+ long jrand48(<[xseed]>)
+ unsigned short <[xseed]>[3];
+
+ void srand48(<[seed]>)
+ long <[seed]>;
+
+ unsigned short *seed48(<[xseed]>)
+ unsigned short <[xseed]>[3];
+
+ void lcong48(<[p]>)
+ unsigned short <[p]>[7];
+
+DESCRIPTION
+The <> family of functions generates pseudo-random numbers
+using a linear congruential algorithm working on integers 48 bits in size.
+The particular formula employed is
+r(n+1) = (a * r(n) + c) mod m
+where the default values are
+for the multiplicand a = 0xfdeece66d = 25214903917 and
+the addend c = 0xb = 11. The modulo is always fixed at m = 2 ** 48.
+r(n) is called the seed of the random number generator.
+
+For all the six generator routines described next, the first
+computational step is to perform a single iteration of the algorithm.
+
+<> and <>
+return values of type double. The full 48 bits of r(n+1) are
+loaded into the mantissa of the returned value, with the exponent set
+such that the values produced lie in the interval [0.0, 1.0].
+
+<> and <>
+return values of type long in the range
+[0, 2**31-1]. The high-order (31) bits of
+r(n+1) are loaded into the lower bits of the returned value, with
+the topmost (sign) bit set to zero.
+
+<> and <>
+return values of type long in the range
+[-2**31, 2**31-1]. The high-order (32) bits of
+r(n+1) are loaded into the returned value.
+
+<>, <>, and <>
+use an internal buffer to store r(n). For these functions
+the initial value of r(0) = 0x1234abcd330e = 20017429951246.
+
+On the other hand, <>, <>, and <>
+use a user-supplied buffer to store the seed r(n),
+which consists of an array of 3 shorts, where the zeroth member
+holds the least significant bits.
+
+All functions share the same multiplicand and addend.
+
+<> is used to initialize the internal buffer r(n) of
+<>, <>, and <>
+such that the 32 bits of the seed value are copied into the upper 32 bits
+of r(n), with the lower 16 bits of r(n) arbitrarily being set to 0x330e.
+Additionally, the constant multiplicand and addend of the algorithm are
+reset to the default values given above.
+
+<> also initializes the internal buffer r(n) of
+<>, <>, and <>,
+but here all 48 bits of the seed can be specified in an array of 3 shorts,
+where the zeroth member specifies the lowest bits. Again,
+the constant multiplicand and addend of the algorithm are
+reset to the default values given above.
+<> returns a pointer to an array of 3 shorts which contains
+the old seed.
+This array is statically allocated, thus its contents are lost after
+each new call to <>.
+
+Finally, <> allows full control over the multiplicand and
+addend used in <>, <>, <>, <>,
+<>, and <>,
+and the seed used in <>, <>, and <>.
+An array of 7 shorts is passed as parameter; the first three shorts are
+used to initialize the seed; the second three are used to initialize the
+multiplicand; and the last short is used to initialize the addend.
+It is thus not possible to use values greater than 0xffff as the addend.
+
+Note that all three methods of seeding the random number generator
+always also set the multiplicand and addend for any of the six
+generator calls.
+
+For a more powerful random number generator, see <>.
+
+PORTABILITY
+SUS requires these functions.
+
+No supporting OS subroutines are required.
+*/
+
+#include "rand48.h"
+
+void
+_DEFUN (__dorand48, (r, xseed),
+ struct _reent *r _AND
+ unsigned short xseed[3])
+{
+ unsigned long accu;
+ unsigned short temp[2];
+
+ _REENT_CHECK_RAND48(r);
+ accu = (unsigned long) __rand48_mult[0] * (unsigned long) xseed[0] +
+ (unsigned long) __rand48_add;
+ temp[0] = (unsigned short) accu; /* lower 16 bits */
+ accu >>= sizeof(unsigned short) * 8;
+ accu += (unsigned long) __rand48_mult[0] * (unsigned long) xseed[1] +
+ (unsigned long) __rand48_mult[1] * (unsigned long) xseed[0];
+ temp[1] = (unsigned short) accu; /* middle 16 bits */
+ accu >>= sizeof(unsigned short) * 8;
+ accu += __rand48_mult[0] * xseed[2] + __rand48_mult[1] * xseed[1] + __rand48_mult[2] * xseed[0];
+ xseed[0] = temp[0];
+ xseed[1] = temp[1];
+ xseed[2] = (unsigned short) accu;
+}
rand48.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcstoul.c
===================================================================
--- wcstoul.c (nonexistent)
+++ wcstoul.c (revision 345)
@@ -0,0 +1,207 @@
+/*
+FUNCTION
+ <>---wide string to unsigned long
+
+INDEX
+ wcstoul
+INDEX
+ _wcstoul_r
+
+ANSI_SYNOPSIS
+ #include
+ unsigned long wcstoul(const wchar_t *<[s]>, wchar_t **<[ptr]>,
+ int <[base]>);
+
+ unsigned long _wcstoul_r(void *<[reent]>, const wchar_t *<[s]>,
+ wchar_t **<[ptr]>, int <[base]>);
+
+TRAD_SYNOPSIS
+ #include
+ unsigned long wcstoul(<[s]>, <[ptr]>, <[base]>)
+ wchar_t *<[s]>;
+ wchar_t **<[ptr]>;
+ int <[base]>;
+
+ unsigned long _wcstoul_r(<[reent]>, <[s]>, <[ptr]>, <[base]>)
+ wchar_t *<[reent]>;
+ wchar_t *<[s]>;
+ wchar_t **<[ptr]>;
+ int <[base]>;
+
+DESCRIPTION
+The function <> converts the wide string <<*<[s]>>> to
+an <>. First, it breaks down the string into three parts:
+leading whitespace, which is ignored; a subject string consisting
+of the digits meaningful in the radix specified by <[base]>
+(for example, <<0>> through <<7>> if the value of <[base]> is 8);
+and a trailing portion consisting of one or more unparseable characters,
+which always includes the terminating null character. Then, it attempts
+to convert the subject string into an unsigned long integer, and returns the
+result.
+
+If the value of <[base]> is zero, the subject string is expected to look
+like a normal C integer constant (save that no optional sign is permitted):
+a possible <<0x>> indicating hexadecimal radix, and a number.
+If <[base]> is between 2 and 36, the expected form of the subject is a
+sequence of digits (which may include letters, depending on the
+base) representing an integer in the radix specified by <[base]>.
+The letters <>--<> (or <>--<>) are used as digits valued from
+10 to 35. If <[base]> is 16, a leading <<0x>> is permitted.
+
+The subject sequence is the longest initial sequence of the input
+string that has the expected form, starting with the first
+non-whitespace character. If the string is empty or consists entirely
+of whitespace, or if the first non-whitespace character is not a
+permissible digit, the subject string is empty.
+
+If the subject string is acceptable, and the value of <[base]> is zero,
+<> attempts to determine the radix from the input string. A
+string with a leading <<0x>> is treated as a hexadecimal value; a string with
+a leading <<0>> and no <> is treated as octal; all other strings are
+treated as decimal. If <[base]> is between 2 and 36, it is used as the
+conversion radix, as described above. Finally, a pointer to the first
+character past the converted subject string is stored in <[ptr]>, if
+<[ptr]> is not <>.
+
+If the subject string is empty (that is, if <<*>><[s]> does not start
+with a substring in acceptable form), no conversion
+is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is
+not <>).
+
+The alternate function <<_wcstoul_r>> is a reentrant version. The
+extra argument <[reent]> is a pointer to a reentrancy structure.
+
+
+RETURNS
+<> returns the converted value, if any. If no conversion was
+made, <<0>> is returned.
+
+<> returns <> if the magnitude of the converted
+value is too large, and sets <> to <>.
+
+PORTABILITY
+<> is ANSI.
+
+<> requires no supporting OS subroutines.
+*/
+
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * Convert a wide string to an unsigned long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+unsigned long
+_DEFUN (_wcstoul_r, (rptr, nptr, endptr, base),
+ struct _reent *rptr _AND
+ _CONST wchar_t *nptr _AND
+ wchar_t **endptr _AND
+ int base)
+{
+ register const wchar_t *s = nptr;
+ register unsigned long acc;
+ register int c;
+ register unsigned long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * See strtol for comments as to the logic used.
+ */
+ do {
+ c = *s++;
+ } while (iswspace(c));
+ if (c == L'-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == L'+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == L'0' && (*s == L'x' || *s == L'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == L'0' ? 8 : 10;
+ cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
+ cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (iswdigit(c))
+ c -= L'0';
+ else if (iswalpha(c))
+ c -= iswupper(c) ? L'A' - 10 : L'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = ULONG_MAX;
+ rptr->_errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (wchar_t *) (any ? s - 1 : nptr);
+ return (acc);
+}
+
+#ifndef _REENT_ONLY
+
+unsigned long
+_DEFUN (wcstoul, (s, ptr, base),
+ _CONST wchar_t *s _AND
+ wchar_t **ptr _AND
+ int base)
+{
+ return _wcstoul_r (_REENT, s, ptr, base);
+}
+
+#endif
wcstoul.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcstombs.c
===================================================================
--- wcstombs.c (nonexistent)
+++ wcstombs.c (revision 345)
@@ -0,0 +1,83 @@
+/*
+FUNCTION
+<>---minimal wide char string to multibyte string converter
+
+INDEX
+ wcstombs
+
+ANSI_SYNOPSIS
+ #include
+ size_t wcstombs(char *<[s]>, const wchar_t *<[pwc]>, size_t <[n]>);
+
+TRAD_SYNOPSIS
+ #include
+ size_t wcstombs(<[s]>, <[pwc]>, <[n]>)
+ char *<[s]>;
+ const wchar_t *<[pwc]>;
+ size_t <[n]>;
+
+DESCRIPTION
+When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming
+implementation of <>. In this case,
+all wide-characters are expected to represent single bytes and so
+are converted simply by casting to char.
+
+When _MB_CAPABLE is defined, this routine calls <<_wcstombs_r>> to perform
+the conversion, passing a state variable to allow state dependent
+decoding. The result is based on the locale setting which may
+be restricted to a defined set of locales.
+
+RETURNS
+This implementation of <> returns <<0>> if
+<[s]> is <> or is the empty string;
+it returns <<-1>> if _MB_CAPABLE and one of the
+wide-char characters does not represent a valid multi-byte character;
+otherwise it returns the minimum of: <> or the
+number of bytes that are transferred to <>, not including the
+nul terminator.
+
+If the return value is -1, the state of the <> string is
+indeterminate. If the input has a length of 0, the output
+string will be modified to contain a wchar_t nul terminator if
+<> > 0.
+
+PORTABILITY
+<> is required in the ANSI C standard. However, the precise
+effects vary with the locale.
+
+<> requires no supporting OS subroutines.
+*/
+
+#ifndef _REENT_ONLY
+
+#include
+#include
+#include
+
+size_t
+_DEFUN (wcstombs, (s, pwcs, n),
+ char *s _AND
+ const wchar_t *pwcs _AND
+ size_t n)
+{
+#ifdef _MB_CAPABLE
+ mbstate_t state;
+ state.__count = 0;
+
+ return _wcstombs_r (_REENT, s, pwcs, n, &state);
+#else /* not _MB_CAPABLE */
+ int count = 0;
+
+ if (n != 0) {
+ do {
+ if ((*s++ = (char) *pwcs++) == 0)
+ break;
+ count++;
+ } while (--n != 0);
+ }
+
+ return count;
+#endif /* not _MB_CAPABLE */
+}
+
+#endif /* !_REENT_ONLY */
wcstombs.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: assert.c
===================================================================
--- assert.c (nonexistent)
+++ assert.c (revision 345)
@@ -0,0 +1,76 @@
+/*
+FUNCTION
+<>---macro for debugging diagnostics
+
+INDEX
+ assert
+
+ANSI_SYNOPSIS
+ #include
+ void assert(int <[expression]>);
+
+DESCRIPTION
+ Use this macro to embed debuggging diagnostic statements in
+ your programs. The argument <[expression]> should be an
+ expression which evaluates to true (nonzero) when your program
+ is working as you intended.
+
+ When <[expression]> evaluates to false (zero), <>
+ calls <>, after first printing a message showing what
+ failed and where:
+
+. Assertion failed: <[expression]>, file <[filename]>, line <[lineno]>, function: <[func]>
+
+ If the name of the current function is not known (for example,
+ when using a C89 compiler that does not understand __func__),
+ the function location is omitted.
+
+ The macro is defined to permit you to turn off all uses of
+ <> at compile time by defining <> as a
+ preprocessor variable. If you do this, the <> macro
+ expands to
+
+. (void(0))
+
+RETURNS
+ <> does not return a value.
+
+PORTABILITY
+ The <> macro is required by ANSI, as is the behavior
+ when <> is defined.
+
+Supporting OS subroutines required (only if enabled): <>, <>,
+<>, <>, <>, <>, <>, <>, <>.
+*/
+
+#include
+#include
+#include
+
+#ifndef HAVE_ASSERT_FUNC
+/* func can be NULL, in which case no function information is given. */
+void
+_DEFUN (__assert_func, (file, line, func, failedexpr),
+ const char *file _AND
+ int line _AND
+ const char *func _AND
+ const char *failedexpr)
+{
+ fiprintf(stderr,
+ "assertion \"%s\" failed: file \"%s\", line %d%s%s\n",
+ failedexpr, file, line,
+ func ? ", function: " : "", func ? func : "");
+ abort();
+ /* NOTREACHED */
+}
+#endif /* HAVE_ASSERT_FUNC */
+
+void
+_DEFUN (__assert, (file, line, failedexpr),
+ const char *file _AND
+ int line _AND
+ const char *failedexpr)
+{
+ __assert_func (file, line, NULL, failedexpr);
+ /* NOTREACHED */
+}
assert.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: rand_r.c
===================================================================
--- rand_r.c (nonexistent)
+++ rand_r.c (revision 345)
@@ -0,0 +1,37 @@
+#include
+
+/* Pseudo-random generator based on Minimal Standard by
+ Lewis, Goodman, and Miller in 1969.
+
+ I[j+1] = a*I[j] (mod m)
+
+ where a = 16807
+ m = 2147483647
+
+ Using Schrage's algorithm, a*I[j] (mod m) can be rewritten as:
+
+ a*(I[j] mod q) - r*{I[j]/q} if >= 0
+ a*(I[j] mod q) - r*{I[j]/q} + m otherwise
+
+ where: {} denotes integer division
+ q = {m/a} = 127773
+ r = m (mod a) = 2836
+
+ note that the seed value of 0 cannot be used in the calculation as
+ it results in 0 itself
+*/
+
+int
+_DEFUN (rand_r, (seed), unsigned int *seed)
+{
+ long k;
+ long s = (long)(*seed);
+ if (s == 0)
+ s = 0x12345987;
+ k = s / 127773;
+ s = 16807 * (s - k * 127773) - 2836 * k;
+ if (s < 0)
+ s += 2147483647;
+ (*seed) = (unsigned int)s;
+ return (int)(s & RAND_MAX);
+}
rand_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: rand48.h
===================================================================
--- rand48.h (nonexistent)
+++ rand48.h (revision 345)
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+#ifndef _RAND48_H_
+#define _RAND48_H_
+
+#include
+#include
+
+extern void _EXFUN(__dorand48,(struct _reent *r, unsigned short[3]));
+#define __rand48_seed _REENT_RAND48_SEED(r)
+#define __rand48_mult _REENT_RAND48_MULT(r)
+#define __rand48_add _REENT_RAND48_ADD(r)
+
+#if 0
+/* following values are defined in */
+#define RAND48_SEED_0 (0x330e)
+#define RAND48_SEED_1 (0xabcd)
+#define RAND48_SEED_2 (0x1234)
+#define RAND48_MULT_0 (0xe66d)
+#define RAND48_MULT_1 (0xdeec)
+#define RAND48_MULT_2 (0x0005)
+#define RAND48_ADD (0x000b)
+#endif
+
+#endif /* _RAND48_H_ */
rand48.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: a64l.c
===================================================================
--- a64l.c (nonexistent)
+++ a64l.c (revision 345)
@@ -0,0 +1,197 @@
+/*
+FUNCTION
+<>, <>---convert between radix-64 ASCII string and long
+
+INDEX
+ a64l
+INDEX
+ l64a
+
+ANSI_SYNOPSIS
+ #include
+ long a64l(const char *<[input]>);
+ char *l64a(long <[input]>);
+
+TRAD_SYNOPSIS
+ #include
+ long a64l(<[input]>)
+ const char *<[input]>;
+
+ char *l64a(<[input]>)
+ long <[input]>;
+
+DESCRIPTION
+Conversion is performed between long and radix-64 characters. The
+<> routine transforms up to 32 bits of input value starting from
+least significant bits to the most significant bits. The input value
+is split up into a maximum of 5 groups of 6 bits and possibly one
+group of 2 bits (bits 31 and 30).
+
+Each group of 6 bits forms a value from 0--63 which is translated into
+a character as follows:
+
+O+
+o 0 = '.'
+o 1 = '/'
+o 2--11 = '0' to '9'
+o 12--37 = 'A' to 'Z'
+o 38--63 = 'a' to 'z'
+O-
+
+When the remaining bits are zero or all bits have been translated, a
+null terminator is appended to the string. An input value of 0
+results in the empty string.
+
+The <> function performs the reverse translation. Each
+character is used to generate a 6-bit value for up to 30 bits and then
+a 2-bit value to complete a 32-bit result. The null terminator means
+that the remaining digits are 0. An empty input string or NULL string
+results in 0L. An invalid string results in undefined behavior. If
+the size of a long is greater than 32 bits, the result is sign-extended.
+
+RETURNS
+<> returns a null-terminated string of 0 to 6 characters.
+<> returns the 32-bit translated value from the input character string.
+
+PORTABILITY
+<> and <> are non-ANSI and are defined by the Single Unix Specification.
+
+Supporting OS subroutines required: None.
+*/
+
+#include <_ansi.h>
+#include
+#include
+
+long
+_DEFUN (a64l, (input),
+ const char *input)
+{
+ const char *ptr;
+ char ch;
+ int i, digit;
+ unsigned long result = 0;
+
+ if (input == NULL)
+ return 0;
+
+ ptr = input;
+
+ /* it easiest to go from most significant digit to least so find end of input or up
+ to 6 characters worth */
+ for (i = 0; i < 6; ++i)
+ {
+ if (*ptr)
+ ++ptr;
+ }
+
+ while (ptr > input)
+ {
+ ch = *(--ptr);
+
+#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
+ if (ch >= 'a')
+ digit = (ch - 'a') + 38;
+ else if (ch >= 'A')
+ digit = (ch - 'A') + 12;
+ else if (ch >= '0')
+ digit = (ch - '0') + 2;
+ else if (ch == '/')
+ digit = 1;
+ else
+ digit = 0;
+#else /* !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) */
+ switch (ch)
+ {
+ case '/':
+ digit = 1;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ digit = (ch - '0') + 2;
+ break;
+ case 'A':
+ case 'B':
+ case 'C':
+ case 'D':
+ case 'E':
+ case 'F':
+ case 'G':
+ case 'H':
+ case 'I':
+ case 'J':
+ case 'K':
+ case 'L':
+ case 'M':
+ case 'N':
+ case 'O':
+ case 'P':
+ case 'Q':
+ case 'R':
+ case 'S':
+ case 'T':
+ case 'U':
+ case 'V':
+ case 'W':
+ case 'X':
+ case 'Y':
+ case 'Z':
+ digit = (ch - 'A') + 12;
+ break;
+ case 'a':
+ case 'b':
+ case 'c':
+ case 'd':
+ case 'e':
+ case 'f':
+ case 'g':
+ case 'h':
+ case 'i':
+ case 'j':
+ case 'k':
+ case 'l':
+ case 'm':
+ case 'n':
+ case 'o':
+ case 'p':
+ case 'q':
+ case 'r':
+ case 's':
+ case 't':
+ case 'u':
+ case 'v':
+ case 'w':
+ case 'x':
+ case 'y':
+ case 'z':
+ digit = (ch - 'a') + 38;
+ break;
+ default:
+ digit = 0;
+ break;
+ }
+#endif /* !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) */
+
+ result = (result << 6) + digit;
+ }
+
+#if LONG_MAX > 2147483647
+ /* for implementations where long is > 32 bits, the result must be sign-extended */
+ if (result & 0x80000000)
+ return (((long)-1 >> 32) << 32) + result;
+#endif
+
+ return result;
+}
+
+
+
+
a64l.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: abort.c
===================================================================
--- abort.c (nonexistent)
+++ abort.c (revision 345)
@@ -0,0 +1,67 @@
+/* NetWare can not use this implementation of abort. It provides its
+ own version of abort in clib.nlm. If we can not use clib.nlm, then
+ we must write abort in sys/netware. */
+
+#ifdef ABORT_PROVIDED
+
+int _dummy_abort = 1;
+
+#else
+
+/*
+FUNCTION
+<>---abnormal termination of a program
+
+INDEX
+ abort
+
+ANSI_SYNOPSIS
+ #include
+ void abort(void);
+
+TRAD_SYNOPSIS
+ #include
+ void abort();
+
+DESCRIPTION
+Use <> to signal that your program has detected a condition it
+cannot deal with. Normally, <> ends your program's execution.
+
+Before terminating your program, <> raises the exception <>
+(using `<>'). If you have used <> to register
+an exception handler for this condition, that handler has the
+opportunity to retain control, thereby avoiding program termination.
+
+In this implementation, <> does not perform any stream- or
+file-related cleanup (the host environment may do so; if not, you can
+arrange for your program to do its own cleanup with a <>
+exception handler).
+
+RETURNS
+<> does not return to its caller.
+
+PORTABILITY
+ANSI C requires <>.
+
+Supporting OS subroutines required: <<_exit>> and optionally, <>.
+*/
+
+#include
+#include
+#include
+
+_VOID
+_DEFUN_VOID (abort)
+{
+#ifdef ABORT_MESSAGE
+ write (2, "Abort called\n", sizeof ("Abort called\n")-1);
+#endif
+
+ while (1)
+ {
+ raise (SIGABRT);
+ _exit (1);
+ }
+}
+
+#endif
abort.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcstoll_r.c
===================================================================
--- wcstoll_r.c (nonexistent)
+++ wcstoll_r.c (revision 345)
@@ -0,0 +1,140 @@
+/*
+ This code is based on strtoul.c which has the following copyright.
+ It is used to convert a wide string into a signed long long.
+
+ long long _wcstoll_r (struct _reent *rptr, const wchar_t *s,
+ wchar_t **ptr, int base);
+*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef __GNUC__
+
+#define _GNU_SOURCE
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * Convert a wide string to a long long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+long long
+_DEFUN (_wcstoll_r, (rptr, nptr, endptr, base),
+ struct _reent *rptr _AND
+ _CONST wchar_t *nptr _AND
+ wchar_t **endptr _AND
+ int base)
+{
+ register const wchar_t *s = nptr;
+ register unsigned long long acc;
+ register int c;
+ register unsigned long long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * Skip white space and pick up leading +/- sign if any.
+ * If base is 0, allow 0x for hex and 0 for octal, else
+ * assume decimal; if base is already 16, allow 0x.
+ */
+ do {
+ c = *s++;
+ } while (iswspace(c));
+ if (c == L'-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == L'+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == L'0' && (*s == L'x' || *s == L'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == L'0' ? 8 : 10;
+
+ /*
+ * Compute the cutoff value between legal numbers and illegal
+ * numbers. That is the largest legal value, divided by the
+ * base. An input number that is greater than this value, if
+ * followed by a legal input character, is too big. One that
+ * is equal to this value may be valid or not; the limit
+ * between valid and invalid numbers is then based on the last
+ * digit. For instance, if the range for longs is
+ * [-2147483648..2147483647] and the input base is 10,
+ * cutoff will be set to 214748364 and cutlim to either
+ * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
+ * a value > 214748364, or equal but the next digit is > 7 (or 8),
+ * the number is too big, and we will return a range error.
+ *
+ * Set any if any `digits' consumed; make it negative to indicate
+ * overflow.
+ */
+ cutoff = neg ? -(unsigned long long)LONG_LONG_MIN : LONG_LONG_MAX;
+ cutlim = cutoff % (unsigned long long)base;
+ cutoff /= (unsigned long long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (iswdigit(c))
+ c -= L'0';
+ else if (iswalpha(c))
+ c -= iswupper(c) ? L'A' - 10 : L'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = neg ? LONG_LONG_MIN : LONG_LONG_MAX;
+ rptr->_errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (wchar_t *) (any ? s - 1 : nptr);
+ return (acc);
+}
+
+#endif /* __GNUC__ */
wcstoll_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: getenv_r.c
===================================================================
--- getenv_r.c (nonexistent)
+++ getenv_r.c (revision 345)
@@ -0,0 +1,136 @@
+/*
+FUNCTION
+<<_getenv_r>>---look up environment variable
+
+INDEX
+ _getenv_r
+INDEX
+ environ
+
+ANSI_SYNOPSIS
+ #include
+ char *_getenv_r(struct _reent *<[reent_ptr]>, const char *<[name]>);
+
+TRAD_SYNOPSIS
+ #include
+ char *_getenv_r(<[reent_ptr]>, <[name]>)
+ struct _reent *<[reent_ptr]>;
+ char *<[name]>;
+
+DESCRIPTION
+<<_getenv_r>> searches the list of environment variable names and values
+(using the global pointer ``<>'') for a variable whose
+name matches the string at <[name]>. If a variable name matches,
+<<_getenv_r>> returns a pointer to the associated value.
+
+RETURNS
+A pointer to the (string) value of the environment variable, or
+<> if there is no such environment variable.
+
+PORTABILITY
+<<_getenv_r>> is not ANSI; the rules for properly forming names of environment
+variables vary from one system to another. This implementation does not
+permit '=' to be in identifiers.
+
+<<_getenv_r>> requires a global pointer <>.
+*/
+
+/* This file may have been modified by DJ Delorie (Jan 1991). If so,
+** these modifications are Copyright (C) 1991 DJ Delorie.
+*/
+
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement: ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include
+#include
+#include
+#include "envlock.h"
+
+extern char **environ;
+
+/* Only deal with a pointer to environ, to work around subtle bugs with shared
+ libraries and/or small data systems where the user declares his own
+ 'environ'. */
+static char ***p_environ = &environ;
+
+/*
+ * _findenv --
+ * Returns pointer to value associated with name, if any, else NULL.
+ * Sets offset to be the offset of the name/value combination in the
+ * environmental array, for use by setenv(3) and unsetenv(3).
+ *
+ * This routine *should* be a static; don't use it.
+ */
+
+char *
+_DEFUN (_findenv_r, (reent_ptr, name, offset),
+ struct _reent *reent_ptr _AND
+ register _CONST char *name _AND
+ int *offset)
+{
+ register int len;
+ register char **p;
+ _CONST char *c;
+
+ ENV_LOCK;
+
+ /* In some embedded systems, this does not get set. This protects
+ newlib from dereferencing a bad pointer. */
+ if (!*p_environ)
+ {
+ ENV_UNLOCK;
+ return NULL;
+ }
+
+ c = name;
+ while (*c && *c != '=') c++;
+
+ /* Identifiers may not contain an '=', so cannot match if does */
+ if(*c != '=')
+ {
+ len = c - name;
+ for (p = *p_environ; *p; ++p)
+ if (!strncmp (*p, name, len))
+ if (*(c = *p + len) == '=')
+ {
+ *offset = p - *p_environ;
+ ENV_UNLOCK;
+ return (char *) (++c);
+ }
+ }
+ ENV_UNLOCK;
+ return NULL;
+}
+
+/*
+ * _getenv_r --
+ * Returns ptr to value associated with name, if any, else NULL.
+ */
+
+char *
+_DEFUN (_getenv_r, (reent_ptr, name),
+ struct _reent *reent_ptr _AND
+ _CONST char *name)
+{
+ int offset;
+ char *_findenv_r ();
+
+ return _findenv_r (reent_ptr, name, &offset);
+}
getenv_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: atoll.c
===================================================================
--- atoll.c (nonexistent)
+++ atoll.c (revision 345)
@@ -0,0 +1,94 @@
+/*
+FUNCTION
+<>---convert a string to a long long integer
+
+INDEX
+ atoll
+INDEX
+ _atoll_r
+
+ANSI_SYNOPSIS
+ #include
+ long long atoll(const char *<[str]>);
+ long long _atoll_r(struct _reent *<[ptr]>, const char *<[str]>);
+
+TRAD_SYNOPSIS
+ #include
+ long long atoll(<[str]>)
+ const char *<[str]>;
+
+ long long _atoll_r(<[ptr]>, <[str]>)
+ struct _reent *<[ptr]>;
+ const char *<[str]>;
+
+DESCRIPTION
+The function <> converts the initial portion of the string
+pointed to by <<*<[str]>>> to a type <>. A call to
+atoll(str) in this implementation is equivalent to
+strtoll(str, (char **)NULL, 10) including behavior on error.
+
+The alternate function <<_atoll_r>> is a reentrant version. The
+extra argument <[reent]> is a pointer to a reentrancy structure.
+
+
+RETURNS
+The converted value.
+
+PORTABILITY
+<> is ISO 9899 (C99) and POSIX 1003.1-2001 compatable.
+
+No supporting OS subroutines are required.
+*/
+
+/*
+ * Copyright (c) 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include
+#include
+
+#ifndef _REENT_ONLY
+long long
+_DEFUN(atoll, (str),
+ _CONST char *str)
+{
+ return strtoll(str, (char **)NULL, 10);
+}
+#endif /* !_REENT_ONLY */
+
+long long
+_DEFUN(_atoll_r, (ptr, str),
+ struct _reent *ptr _AND
+ _CONST char *str)
+{
+ return _strtoll_r(ptr, str, (char **)NULL, 10);
+}
atoll.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcstoull.c
===================================================================
--- wcstoull.c (nonexistent)
+++ wcstoull.c (revision 345)
@@ -0,0 +1,140 @@
+/*
+FUNCTION
+ <>---wide string to unsigned long long
+
+INDEX
+ wcstoull
+INDEX
+ _wcstoull_r
+
+ANSI_SYNOPSIS
+ #include
+ unsigned long long wcstoull(const wchar_t *<[s]>, wchar_t **<[ptr]>,
+ int <[base]>);
+
+ unsigned long long _wcstoull_r(void *<[reent]>, const wchar_t *<[s]>,
+ wchar_t **<[ptr]>, int <[base]>);
+
+TRAD_SYNOPSIS
+ #include
+ unsigned long long wcstoull(<[s]>, <[ptr]>, <[base]>)
+ wchar_t *<[s]>;
+ wchar_t **<[ptr]>;
+ int <[base]>;
+
+ unsigned long long _wcstoull_r(<[reent]>, <[s]>, <[ptr]>, <[base]>)
+ wchar_t *<[reent]>;
+ wchar_t *<[s]>;
+ wchar_t **<[ptr]>;
+ int <[base]>;
+
+DESCRIPTION
+The function <> converts the wide string <<*<[s]>>> to
+an <>. First, it breaks down the string into three parts:
+leading whitespace, which is ignored; a subject string consisting
+of the digits meaningful in the radix specified by <[base]>
+(for example, <<0>> through <<7>> if the value of <[base]> is 8);
+and a trailing portion consisting of one or more unparseable characters,
+which always includes the terminating null character. Then, it attempts
+to convert the subject string into an unsigned long long integer, and returns the
+result.
+
+If the value of <[base]> is zero, the subject string is expected to look
+like a normal C integer constant: an optional sign (<<+>> or <<->>),
+a possible <<0x>> indicating hexadecimal radix or a possible <0> indicating
+octal radix, and a number.
+If <[base]> is between 2 and 36, the expected form of the subject is a
+sequence of digits (which may include letters, depending on the
+base) representing an integer in the radix specified by <[base]>.
+The letters <>--<> (or <>--<>) are used as digits valued from
+10 to 35. If <[base]> is 16, a leading <<0x>> is permitted.
+
+The subject sequence is the longest initial sequence of the input
+string that has the expected form, starting with the first
+non-whitespace character. If the string is empty or consists entirely
+of whitespace, or if the first non-whitespace character is not a
+permissible digit, the subject string is empty.
+
+If the subject string is acceptable, and the value of <[base]> is zero,
+<> attempts to determine the radix from the input string. A
+string with a leading <<0x>> is treated as a hexadecimal value; a string with
+a leading <<0>> and no <> is treated as octal; all other strings are
+treated as decimal. If <[base]> is between 2 and 36, it is used as the
+conversion radix, as described above. Finally, a pointer to the first
+character past the converted subject string is stored in <[ptr]>, if
+<[ptr]> is not <>.
+
+If the subject string is empty (that is, if <<*>><[s]> does not start
+with a substring in acceptable form), no conversion
+is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is
+not <>).
+
+The alternate function <<_wcstoull_r>> is a reentrant version. The
+extra argument <[reent]> is a pointer to a reentrancy structure.
+
+
+RETURNS
+<> returns <<0>> and sets <> to <> if the value of
+<[base]> is not supported.
+
+<> returns the converted value, if any. If no conversion was
+made, <<0>> is returned.
+
+<> returns <> if the magnitude of the converted
+value is too large, and sets <> to <>.
+
+PORTABILITY
+<> is ANSI.
+
+<> requires no supporting OS subroutines.
+*/
+
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <_ansi.h>
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+unsigned long long
+_DEFUN (wcstoull, (s, ptr, base),
+ _CONST wchar_t *s _AND
+ wchar_t **ptr _AND
+ int base)
+{
+ return _wcstoull_r (_REENT, s, ptr, base);
+}
+
+#endif
wcstoull.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: getsubopt.c
===================================================================
--- getsubopt.c (nonexistent)
+++ getsubopt.c (revision 345)
@@ -0,0 +1,101 @@
+/*-
+ * Copyright (c) 1990, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getsubopt.c 8.1 (Berkeley) 6/4/93";
+#endif /* LIBC_SCCS and not lint */
+#include
+
+#include
+#include
+#include
+
+/*
+ * The SVID interface to getsubopt provides no way of figuring out which
+ * part of the suboptions list wasn't matched. This makes error messages
+ * tricky... The extern variable suboptarg is a pointer to the token
+ * which didn't match.
+ */
+char *suboptarg;
+
+int
+getsubopt(optionp, tokens, valuep)
+ char **optionp, **valuep;
+ char * const *tokens;
+{
+ int cnt;
+ char *p;
+
+ suboptarg = *valuep = NULL;
+
+ if (!optionp || !*optionp)
+ return(-1);
+
+ /* skip leading white-space, commas */
+ for (p = *optionp; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
+
+ if (!*p) {
+ *optionp = p;
+ return(-1);
+ }
+
+ /* save the start of the token, and skip the rest of the token. */
+ for (suboptarg = p;
+ *++p && *p != ',' && *p != '=' && *p != ' ' && *p != '\t';);
+
+ if (*p) {
+ /*
+ * If there's an equals sign, set the value pointer, and
+ * skip over the value part of the token. Terminate the
+ * token.
+ */
+ if (*p == '=') {
+ *p = '\0';
+ for (*valuep = ++p;
+ *p && *p != ',' && *p != ' ' && *p != '\t'; ++p);
+ if (*p)
+ *p++ = '\0';
+ } else
+ *p++ = '\0';
+ /* Skip any whitespace or commas after this token. */
+ for (; *p && (*p == ',' || *p == ' ' || *p == '\t'); ++p);
+ }
+
+ /* set optionp for next round. */
+ *optionp = p;
+
+ for (cnt = 0; *tokens; ++tokens, ++cnt)
+ if (!strcmp(suboptarg, *tokens))
+ return(cnt);
+ return(-1);
+}
getsubopt.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wctob.c
===================================================================
--- wctob.c (nonexistent)
+++ wctob.c (revision 345)
@@ -0,0 +1,26 @@
+#include
+#include
+#include
+#include
+#include
+#include "local.h"
+
+int
+wctob (wint_t c)
+{
+ mbstate_t mbs;
+ int retval = 0;
+ unsigned char pwc;
+
+ /* Put mbs in initial state. */
+ memset (&mbs, '\0', sizeof (mbs));
+
+ _REENT_CHECK_MISC(_REENT);
+
+ retval = __wctomb (_REENT, &pwc, c, __locale_charset (), &mbs);
+
+ if (c == EOF || retval != 1)
+ return WEOF;
+ else
+ return (int)pwc;
+}
wctob.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mblen_r.c
===================================================================
--- mblen_r.c (nonexistent)
+++ mblen_r.c (revision 345)
@@ -0,0 +1,77 @@
+/*
+FUNCTION
+<<_mblen_r>>---reentrant minimal multibyte length function
+
+INDEX
+ _mblen_r
+
+ANSI_SYNOPSIS
+ #include
+ int _mblen_r(struct _reent *<[r]>, const char *<[s]>, size_t <[n]>, int *<[state]>);
+
+TRAD_SYNOPSIS
+ #include
+ int _mblen_r(<[r]>, <[s]>, <[n]>, <[state]>)
+ struct _reent *<[r]>;
+ const char *<[s]>;
+ size_t <[n]>;
+ int *<[state]>;
+
+DESCRIPTION
+When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming
+implementation of <<_mblen_r>>. In this case, the
+only ``multi-byte character sequences'' recognized are single bytes,
+and thus <<1>> is returned unless <[s]> is the null pointer or
+has a length of 0 or is the empty string.
+
+When _MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform
+the conversion, passing a state variable to allow state dependent
+decoding. The result is based on the locale setting which may
+be restricted to a defined set of locales.
+
+RETURNS
+This implementation of <<_mblen_r>> returns <<0>> if
+<[s]> is <> or the empty string; it returns <<1>> if not _MB_CAPABLE or
+the character is a single-byte character; it returns <<-1>>
+if the multi-byte character is invalid; otherwise it returns
+the number of bytes in the multibyte character.
+
+PORTABILITY
+<<_mblen>> is required in the ANSI C standard. However, the precise
+effects vary with the locale.
+
+<<_mblen_r>> requires no supporting OS subroutines.
+*/
+
+#include
+#include
+#include
+#include "local.h"
+
+int
+_DEFUN (_mblen_r, (r, s, n, state),
+ struct _reent *r _AND
+ const char *s _AND
+ size_t n _AND
+ mbstate_t *state)
+{
+#ifdef _MB_CAPABLE
+ int retval;
+ retval = __mbtowc (r, NULL, s, n, __locale_charset (), state);
+
+ if (retval < 0)
+ {
+ state->__count = 0;
+ return -1;
+ }
+
+ return retval;
+#else /* not _MB_CAPABLE */
+ if (s == NULL || *s == '\0')
+ return 0;
+ if (n == 0)
+ return -1;
+ return 1;
+#endif /* not _MB_CAPABLE */
+}
+
mblen_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcstold.c
===================================================================
--- wcstold.c (nonexistent)
+++ wcstold.c (revision 345)
@@ -0,0 +1,42 @@
+/*
+(C) Copyright IBM Corp. 2009
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+* Neither the name of IBM nor the names of its contributors may be
+used to endorse or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include
+#include "local.h"
+
+/* On platforms where long double is as wide as double. */
+#ifdef _LDBL_EQ_DBL
+long double
+wcstold (const wchar_t *nptr, wchar_t **endptr)
+{
+ return wcstod(nptr, endptr);
+}
+#endif /* _LDBL_EQ_DBL */
+
wcstold.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: valloc.c
===================================================================
--- valloc.c (nonexistent)
+++ valloc.c (revision 345)
@@ -0,0 +1,26 @@
+#ifndef MALLOC_PROVIDED
+/* valloc.c -- a wrapper for valloc_r and pvalloc_r. */
+
+#include <_ansi.h>
+#include
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+_PTR
+_DEFUN (valloc, (nbytes),
+ size_t nbytes)
+{
+ return _valloc_r (_REENT, nbytes);
+}
+
+_PTR
+_DEFUN (pvalloc, (nbytes),
+ size_t nbytes)
+{
+ return _pvalloc_r (_REENT, nbytes);
+}
+
+#endif
+#endif
valloc.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: realloc.c
===================================================================
--- realloc.c (nonexistent)
+++ realloc.c (revision 345)
@@ -0,0 +1,22 @@
+#ifdef MALLOC_PROVIDED
+int _dummy_calloc = 1;
+#else
+/* realloc.c -- a wrapper for realloc_r. */
+
+#include <_ansi.h>
+#include
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+_PTR
+_DEFUN (realloc, (ap, nbytes),
+ _PTR ap _AND
+ size_t nbytes)
+{
+ return _realloc_r (_REENT, ap, nbytes);
+}
+
+#endif
+#endif /* MALLOC_PROVIDED */
realloc.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mbstowcs_r.c
===================================================================
--- mbstowcs_r.c (nonexistent)
+++ mbstowcs_r.c (revision 345)
@@ -0,0 +1,38 @@
+#include
+#include
+#include "local.h"
+
+size_t
+_DEFUN (_mbstowcs_r, (reent, pwcs, s, n, state),
+ struct _reent *r _AND
+ wchar_t *pwcs _AND
+ const char *s _AND
+ size_t n _AND
+ mbstate_t *state)
+{
+ size_t ret = 0;
+ char *t = (char *)s;
+ int bytes;
+
+ if (!pwcs)
+ n = (size_t) 1; /* Value doesn't matter as long as it's not 0. */
+ while (n > 0)
+ {
+ bytes = __mbtowc (r, pwcs, t, MB_CUR_MAX, __locale_charset (), state);
+ if (bytes < 0)
+ {
+ state->__count = 0;
+ return -1;
+ }
+ else if (bytes == 0)
+ break;
+ t += bytes;
+ ++ret;
+ if (pwcs)
+ {
+ ++pwcs;
+ --n;
+ }
+ }
+ return ret;
+}
mbstowcs_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mbsrtowcs.c
===================================================================
--- mbsrtowcs.c (nonexistent)
+++ mbsrtowcs.c (revision 345)
@@ -0,0 +1,29 @@
+#include
+#include
+#include
+#include
+#include
+#include
+
+size_t
+_DEFUN (_mbsrtowcs_r, (r, dst, src, len, ps),
+ struct _reent *r _AND
+ wchar_t *dst _AND
+ const char **src _AND
+ size_t len _AND
+ mbstate_t *ps)
+{
+ return _mbsnrtowcs_r (r, dst, src, (size_t) -1, len, ps);
+}
+
+#ifndef _REENT_ONLY
+size_t
+_DEFUN (mbsrtowcs, (dst, src, len, ps),
+ wchar_t *dst _AND
+ const char **src _AND
+ size_t len _AND
+ mbstate_t *ps)
+{
+ return _mbsnrtowcs_r (_REENT, dst, src, (size_t) -1, len, ps);
+}
+#endif /* !_REENT_ONLY */
mbsrtowcs.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: setenv_r.c
===================================================================
--- setenv_r.c (nonexistent)
+++ setenv_r.c (revision 345)
@@ -0,0 +1,168 @@
+/* This file may have been modified by DJ Delorie (Jan 1991). If so,
+** these modifications are Copyright (C) 1991 DJ Delorie.
+*/
+
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement: ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include "envlock.h"
+
+extern char **environ;
+
+/* Only deal with a pointer to environ, to work around subtle bugs with shared
+ libraries and/or small data systems where the user declares his own
+ 'environ'. */
+static char ***p_environ = &environ;
+
+/* _findenv_r is defined in getenv_r.c. */
+extern char *_findenv_r _PARAMS ((struct _reent *, const char *, int *));
+
+/*
+ * _setenv_r --
+ * Set the value of the environmental variable "name" to be
+ * "value". If rewrite is set, replace any current value.
+ * If "name" contains equal sign, -1 is returned, and errno is
+ * set to EINVAL;
+ */
+
+int
+_DEFUN (_setenv_r, (reent_ptr, name, value, rewrite),
+ struct _reent *reent_ptr _AND
+ _CONST char *name _AND
+ _CONST char *value _AND
+ int rewrite)
+{
+ static int alloced; /* if allocated space before */
+ register char *C;
+ int l_value, offset;
+
+ if (strchr(name, '='))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ENV_LOCK;
+
+ l_value = strlen (value);
+ if ((C = _findenv_r (reent_ptr, name, &offset)))
+ { /* find if already exists */
+ if (!rewrite)
+ {
+ ENV_UNLOCK;
+ return 0;
+ }
+ if (strlen (C) >= l_value)
+ { /* old larger; copy over */
+ while ((*C++ = *value++) != 0);
+ ENV_UNLOCK;
+ /* if we are changing the TZ environment variable, update timezone info */
+ if (strcmp (name, "TZ") == 0)
+ tzset ();
+ return 0;
+ }
+ }
+ else
+ { /* create new slot */
+ register int cnt;
+ register char **P;
+
+ for (P = *p_environ, cnt = 0; *P; ++P, ++cnt);
+ if (alloced)
+ { /* just increase size */
+ *p_environ = (char **) _realloc_r (reent_ptr, (char *) environ,
+ (size_t) (sizeof (char *) * (cnt + 2)));
+ if (!*p_environ)
+ {
+ ENV_UNLOCK;
+ return -1;
+ }
+ }
+ else
+ { /* get new space */
+ alloced = 1; /* copy old entries into it */
+ P = (char **) _malloc_r (reent_ptr, (size_t) (sizeof (char *) * (cnt + 2)));
+ if (!P)
+ {
+ ENV_UNLOCK;
+ return (-1);
+ }
+ bcopy ((char *) *p_environ, (char *) P, cnt * sizeof (char *));
+ *p_environ = P;
+ }
+ (*p_environ)[cnt + 1] = NULL;
+ offset = cnt;
+ }
+ for (C = (char *) name; *C && *C != '='; ++C); /* no `=' in name */
+ if (!((*p_environ)[offset] = /* name + `=' + value */
+ _malloc_r (reent_ptr, (size_t) ((int) (C - name) + l_value + 2))))
+ {
+ ENV_UNLOCK;
+ return -1;
+ }
+ for (C = (*p_environ)[offset]; (*C = *name++) && *C != '='; ++C);
+ for (*C++ = '='; (*C++ = *value++) != 0;);
+
+ ENV_UNLOCK;
+
+ /* if we are setting the TZ environment variable, update timezone info */
+ if (strncmp ((*p_environ)[offset], "TZ=", 3) == 0)
+ tzset ();
+
+ return 0;
+}
+
+/*
+ * _unsetenv_r(name) --
+ * Delete environmental variable "name".
+ */
+int
+_DEFUN (_unsetenv_r, (reent_ptr, name),
+ struct _reent *reent_ptr _AND
+ _CONST char *name)
+{
+ register char **P;
+ int offset;
+
+ /* Name cannot be NULL, empty, or contain an equal sign. */
+ if (name == NULL || name[0] == '\0' || strchr(name, '='))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+
+ ENV_LOCK;
+
+ while (_findenv_r (reent_ptr, name, &offset)) /* if set multiple times */
+ {
+ for (P = &(*p_environ)[offset];; ++P)
+ if (!(*P = *(P + 1)))
+ break;
+ }
+
+ ENV_UNLOCK;
+ return 0;
+}
setenv_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcstoll.c
===================================================================
--- wcstoll.c (nonexistent)
+++ wcstoll.c (revision 345)
@@ -0,0 +1,138 @@
+/*
+FUNCTION
+ <>---wide string to long long
+
+INDEX
+ wcstoll
+INDEX
+ _wcstoll_r
+
+ANSI_SYNOPSIS
+ #include
+ long long wcstoll(const wchar_t *<[s]>, wchar_t **<[ptr]>,int <[base]>);
+
+ long long _wcstoll_r(void *<[reent]>,
+ const wchar_t *<[s]>, wchar_t **<[ptr]>,int <[base]>);
+
+TRAD_SYNOPSIS
+ #include
+ long long wcstoll (<[s]>, <[ptr]>, <[base]>)
+ const wchar_t *<[s]>;
+ wchar_t **<[ptr]>;
+ int <[base]>;
+
+ long long _wcstoll_r (<[reent]>, <[s]>, <[ptr]>, <[base]>)
+ wchar_t *<[reent]>;
+ const wchar_t *<[s]>;
+ wchar_t **<[ptr]>;
+ int <[base]>;
+
+DESCRIPTION
+The function <> converts the wide string <<*<[s]>>> to
+a <>. First, it breaks down the string into three parts:
+leading whitespace, which is ignored; a subject string consisting
+of characters resembling an integer in the radix specified by <[base]>;
+and a trailing portion consisting of zero or more unparseable characters,
+and always including the terminating null character. Then, it attempts
+to convert the subject string into a <> and returns the
+result.
+
+If the value of <[base]> is 0, the subject string is expected to look
+like a normal C integer constant: an optional sign, a possible `<<0x>>'
+indicating a hexadecimal base, and a number. If <[base]> is between
+2 and 36, the expected form of the subject is a sequence of letters
+and digits representing an integer in the radix specified by <[base]>,
+with an optional plus or minus sign. The letters <>--<> (or,
+equivalently, <>--<>) are used to signify values from 10 to 35;
+only letters whose ascribed values are less than <[base]> are
+permitted. If <[base]> is 16, a leading <<0x>> is permitted.
+
+The subject sequence is the longest initial sequence of the input
+string that has the expected form, starting with the first
+non-whitespace character. If the string is empty or consists entirely
+of whitespace, or if the first non-whitespace character is not a
+permissible letter or digit, the subject string is empty.
+
+If the subject string is acceptable, and the value of <[base]> is zero,
+<> attempts to determine the radix from the input string. A
+string with a leading <<0x>> is treated as a hexadecimal value; a string with
+a leading 0 and no <> is treated as octal; all other strings are
+treated as decimal. If <[base]> is between 2 and 36, it is used as the
+conversion radix, as described above. If the subject string begins with
+a minus sign, the value is negated. Finally, a pointer to the first
+character past the converted subject string is stored in <[ptr]>, if
+<[ptr]> is not <>.
+
+If the subject string is empty (or not in acceptable form), no conversion
+is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is
+not <>).
+
+The alternate function <<_wcstoll_r>> is a reentrant version. The
+extra argument <[reent]> is a pointer to a reentrancy structure.
+
+RETURNS
+<> returns the converted value, if any. If no conversion was
+made, 0 is returned.
+
+<> returns <> or <> if the magnitude of
+the converted value is too large, and sets <> to <>.
+
+PORTABILITY
+<> is ANSI.
+
+No supporting OS subroutines are required.
+*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+long long
+_DEFUN (wcstoll, (s, ptr, base),
+ _CONST wchar_t *s _AND
+ wchar_t **ptr _AND
+ int base)
+{
+ return _wcstoll_r (_REENT, s, ptr, base);
+}
+
+#endif
wcstoll.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: __adjust.c
===================================================================
--- __adjust.c (nonexistent)
+++ __adjust.c (revision 345)
@@ -0,0 +1,44 @@
+/*
+ * return (*acc) scaled by 10**dexp.
+ */
+
+#include <_ansi.h>
+#include
+#include "std.h"
+
+#define abs(x) (((x) < 0) ? -(x) : (x))
+
+double
+_DEFUN (__adjust, (ptr, acc, dexp, sign),
+ struct _reent *ptr _AND
+ double *acc _AND
+ int dexp _AND
+ int sign)
+ /* *acc the 64 bit accumulator */
+ /* dexp decimal exponent */
+ /* sign sign flag */
+{
+ double r;
+
+ if (dexp > MAXE)
+ {
+ ptr->_errno = ERANGE;
+ return (sign) ? -HUGE_VAL : HUGE_VAL;
+ }
+ else if (dexp < MINE)
+ {
+ ptr->_errno = ERANGE;
+ return 0.0;
+ }
+
+ r = *acc;
+ if (sign)
+ r = -r;
+ if (dexp == 0)
+ return r;
+
+ if (dexp < 0)
+ return r / __exp10 (abs (dexp));
+ else
+ return r * __exp10 (dexp);
+}
__adjust.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: atof.c
===================================================================
--- atof.c (nonexistent)
+++ atof.c (revision 345)
@@ -0,0 +1,72 @@
+/*
+FUNCTION
+ <>, <>---string to double or float
+
+INDEX
+ atof
+INDEX
+ atoff
+
+ANSI_SYNOPSIS
+ #include
+ double atof(const char *<[s]>);
+ float atoff(const char *<[s]>);
+
+TRAD_SYNOPSIS
+ #include
+ double atof(<[s]>)
+ char *<[s]>;
+
+ float atoff(<[s]>)
+ char *<[s]>;
+
+DESCRIPTION
+<> converts the initial portion of a string to a <>.
+<> converts the initial portion of a string to a <>.
+
+The functions parse the character string <[s]>,
+locating a substring which can be converted to a floating-point
+value. The substring must match the format:
+. [+|-]<[digits]>[.][<[digits]>][(e|E)[+|-]<[digits]>]
+The substring converted is the longest initial
+fragment of <[s]> that has the expected format, beginning with
+the first non-whitespace character. The substring
+is empty if <> is empty, consists entirely
+of whitespace, or if the first non-whitespace character is
+something other than <<+>>, <<->>, <<.>>, or a digit.
+
+<)>> is implemented as <, NULL)>>.
+<)>> is implemented as <, NULL)>>.
+
+RETURNS
+<> returns the converted substring value, if any, as a
+<>; or <<0.0>>, if no conversion could be performed.
+If the correct value is out of the range of representable values, plus
+or minus <> is returned, and <> is stored in
+<>.
+If the correct value would cause underflow, <<0.0>> is returned
+and <> is stored in <>.
+
+<> obeys the same rules as <>, except that it
+returns a <>.
+
+PORTABILITY
+<> is ANSI C. <>, <>, and <> are subsumed by <>
+and <>, but are used extensively in existing code. These functions are
+less reliable, but may be faster if the argument is verified to be in a valid
+range.
+
+Supporting OS subroutines required: <>, <>, <>,
+<>, <>, <>, <>.
+*/
+
+
+#include
+#include <_ansi.h>
+
+double
+_DEFUN (atof, (s),
+ _CONST char *s)
+{
+ return strtod (s, NULL);
+}
atof.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mallocr.c
===================================================================
--- mallocr.c (nonexistent)
+++ mallocr.c (revision 345)
@@ -0,0 +1,3692 @@
+#ifdef MALLOC_PROVIDED
+int _dummy_mallocr = 1;
+#else
+/* ---------- To make a malloc.h, start cutting here ------------ */
+
+/*
+ A version of malloc/free/realloc written by Doug Lea and released to the
+ public domain. Send questions/comments/complaints/performance data
+ to dl@cs.oswego.edu
+
+* VERSION 2.6.4 Thu Nov 28 07:54:55 1996 Doug Lea (dl at gee)
+
+ Note: There may be an updated version of this malloc obtainable at
+ ftp://g.oswego.edu/pub/misc/malloc.c
+ Check before installing!
+
+* Why use this malloc?
+
+ This is not the fastest, most space-conserving, most portable, or
+ most tunable malloc ever written. However it is among the fastest
+ while also being among the most space-conserving, portable and tunable.
+ Consistent balance across these factors results in a good general-purpose
+ allocator. For a high-level description, see
+ http://g.oswego.edu/dl/html/malloc.html
+
+* Synopsis of public routines
+
+ (Much fuller descriptions are contained in the program documentation below.)
+
+ malloc(size_t n);
+ Return a pointer to a newly allocated chunk of at least n bytes, or null
+ if no space is available.
+ free(Void_t* p);
+ Release the chunk of memory pointed to by p, or no effect if p is null.
+ realloc(Void_t* p, size_t n);
+ Return a pointer to a chunk of size n that contains the same data
+ as does chunk p up to the minimum of (n, p's size) bytes, or null
+ if no space is available. The returned pointer may or may not be
+ the same as p. If p is null, equivalent to malloc. Unless the
+ #define REALLOC_ZERO_BYTES_FREES below is set, realloc with a
+ size argument of zero (re)allocates a minimum-sized chunk.
+ memalign(size_t alignment, size_t n);
+ Return a pointer to a newly allocated chunk of n bytes, aligned
+ in accord with the alignment argument, which must be a power of
+ two.
+ valloc(size_t n);
+ Equivalent to memalign(pagesize, n), where pagesize is the page
+ size of the system (or as near to this as can be figured out from
+ all the includes/defines below.)
+ pvalloc(size_t n);
+ Equivalent to valloc(minimum-page-that-holds(n)), that is,
+ round up n to nearest pagesize.
+ calloc(size_t unit, size_t quantity);
+ Returns a pointer to quantity * unit bytes, with all locations
+ set to zero.
+ cfree(Void_t* p);
+ Equivalent to free(p).
+ malloc_trim(size_t pad);
+ Release all but pad bytes of freed top-most memory back
+ to the system. Return 1 if successful, else 0.
+ malloc_usable_size(Void_t* p);
+ Report the number usable allocated bytes associated with allocated
+ chunk p. This may or may not report more bytes than were requested,
+ due to alignment and minimum size constraints.
+ malloc_stats();
+ Prints brief summary statistics on stderr.
+ mallinfo()
+ Returns (by copy) a struct containing various summary statistics.
+ mallopt(int parameter_number, int parameter_value)
+ Changes one of the tunable parameters described below. Returns
+ 1 if successful in changing the parameter, else 0.
+
+* Vital statistics:
+
+ Alignment: 8-byte
+ 8 byte alignment is currently hardwired into the design. This
+ seems to suffice for all current machines and C compilers.
+
+ Assumed pointer representation: 4 or 8 bytes
+ Code for 8-byte pointers is untested by me but has worked
+ reliably by Wolfram Gloger, who contributed most of the
+ changes supporting this.
+
+ Assumed size_t representation: 4 or 8 bytes
+ Note that size_t is allowed to be 4 bytes even if pointers are 8.
+
+ Minimum overhead per allocated chunk: 4 or 8 bytes
+ Each malloced chunk has a hidden overhead of 4 bytes holding size
+ and status information.
+
+ Minimum allocated size: 4-byte ptrs: 16 bytes (including 4 overhead)
+ 8-byte ptrs: 24/32 bytes (including, 4/8 overhead)
+
+ When a chunk is freed, 12 (for 4byte ptrs) or 20 (for 8 byte
+ ptrs but 4 byte size) or 24 (for 8/8) additional bytes are
+ needed; 4 (8) for a trailing size field
+ and 8 (16) bytes for free list pointers. Thus, the minimum
+ allocatable size is 16/24/32 bytes.
+
+ Even a request for zero bytes (i.e., malloc(0)) returns a
+ pointer to something of the minimum allocatable size.
+
+ Maximum allocated size: 4-byte size_t: 2^31 - 8 bytes
+ 8-byte size_t: 2^63 - 16 bytes
+
+ It is assumed that (possibly signed) size_t bit values suffice to
+ represent chunk sizes. `Possibly signed' is due to the fact
+ that `size_t' may be defined on a system as either a signed or
+ an unsigned type. To be conservative, values that would appear
+ as negative numbers are avoided.
+ Requests for sizes with a negative sign bit will return a
+ minimum-sized chunk.
+
+ Maximum overhead wastage per allocated chunk: normally 15 bytes
+
+ Alignnment demands, plus the minimum allocatable size restriction
+ make the normal worst-case wastage 15 bytes (i.e., up to 15
+ more bytes will be allocated than were requested in malloc), with
+ two exceptions:
+ 1. Because requests for zero bytes allocate non-zero space,
+ the worst case wastage for a request of zero bytes is 24 bytes.
+ 2. For requests >= mmap_threshold that are serviced via
+ mmap(), the worst case wastage is 8 bytes plus the remainder
+ from a system page (the minimal mmap unit); typically 4096 bytes.
+
+* Limitations
+
+ Here are some features that are NOT currently supported
+
+ * No user-definable hooks for callbacks and the like.
+ * No automated mechanism for fully checking that all accesses
+ to malloced memory stay within their bounds.
+ * No support for compaction.
+
+* Synopsis of compile-time options:
+
+ People have reported using previous versions of this malloc on all
+ versions of Unix, sometimes by tweaking some of the defines
+ below. It has been tested most extensively on Solaris and
+ Linux. It is also reported to work on WIN32 platforms.
+ People have also reported adapting this malloc for use in
+ stand-alone embedded systems.
+
+ The implementation is in straight, hand-tuned ANSI C. Among other
+ consequences, it uses a lot of macros. Because of this, to be at
+ all usable, this code should be compiled using an optimizing compiler
+ (for example gcc -O2) that can simplify expressions and control
+ paths.
+
+ __STD_C (default: derived from C compiler defines)
+ Nonzero if using ANSI-standard C compiler, a C++ compiler, or
+ a C compiler sufficiently close to ANSI to get away with it.
+ DEBUG (default: NOT defined)
+ Define to enable debugging. Adds fairly extensive assertion-based
+ checking to help track down memory errors, but noticeably slows down
+ execution.
+ SEPARATE_OBJECTS (default: NOT defined)
+ Define this to compile into separate .o files. You must then
+ compile malloc.c several times, defining a DEFINE_* macro each
+ time. The list of DEFINE_* macros appears below.
+ MALLOC_LOCK (default: NOT defined)
+ MALLOC_UNLOCK (default: NOT defined)
+ Define these to C expressions which are run to lock and unlock
+ the malloc data structures. Calls may be nested; that is,
+ MALLOC_LOCK may be called more than once before the corresponding
+ MALLOC_UNLOCK calls. MALLOC_LOCK must avoid waiting for a lock
+ that it already holds.
+ MALLOC_ALIGNMENT (default: NOT defined)
+ Define this to 16 if you need 16 byte alignment instead of 8 byte alignment
+ which is the normal default.
+ REALLOC_ZERO_BYTES_FREES (default: NOT defined)
+ Define this if you think that realloc(p, 0) should be equivalent
+ to free(p). Otherwise, since malloc returns a unique pointer for
+ malloc(0), so does realloc(p, 0).
+ HAVE_MEMCPY (default: defined)
+ Define if you are not otherwise using ANSI STD C, but still
+ have memcpy and memset in your C library and want to use them.
+ Otherwise, simple internal versions are supplied.
+ USE_MEMCPY (default: 1 if HAVE_MEMCPY is defined, 0 otherwise)
+ Define as 1 if you want the C library versions of memset and
+ memcpy called in realloc and calloc (otherwise macro versions are used).
+ At least on some platforms, the simple macro versions usually
+ outperform libc versions.
+ HAVE_MMAP (default: defined as 1)
+ Define to non-zero to optionally make malloc() use mmap() to
+ allocate very large blocks.
+ HAVE_MREMAP (default: defined as 0 unless Linux libc set)
+ Define to non-zero to optionally make realloc() use mremap() to
+ reallocate very large blocks.
+ malloc_getpagesize (default: derived from system #includes)
+ Either a constant or routine call returning the system page size.
+ HAVE_USR_INCLUDE_MALLOC_H (default: NOT defined)
+ Optionally define if you are on a system with a /usr/include/malloc.h
+ that declares struct mallinfo. It is not at all necessary to
+ define this even if you do, but will ensure consistency.
+ INTERNAL_SIZE_T (default: size_t)
+ Define to a 32-bit type (probably `unsigned int') if you are on a
+ 64-bit machine, yet do not want or need to allow malloc requests of
+ greater than 2^31 to be handled. This saves space, especially for
+ very small chunks.
+ INTERNAL_LINUX_C_LIB (default: NOT defined)
+ Defined only when compiled as part of Linux libc.
+ Also note that there is some odd internal name-mangling via defines
+ (for example, internally, `malloc' is named `mALLOc') needed
+ when compiling in this case. These look funny but don't otherwise
+ affect anything.
+ INTERNAL_NEWLIB (default: NOT defined)
+ Defined only when compiled as part of the Cygnus newlib
+ distribution.
+ WIN32 (default: undefined)
+ Define this on MS win (95, nt) platforms to compile in sbrk emulation.
+ LACKS_UNISTD_H (default: undefined)
+ Define this if your system does not have a .
+ MORECORE (default: sbrk)
+ The name of the routine to call to obtain more memory from the system.
+ MORECORE_FAILURE (default: -1)
+ The value returned upon failure of MORECORE.
+ MORECORE_CLEARS (default 1)
+ True (1) if the routine mapped to MORECORE zeroes out memory (which
+ holds for sbrk).
+ DEFAULT_TRIM_THRESHOLD
+ DEFAULT_TOP_PAD
+ DEFAULT_MMAP_THRESHOLD
+ DEFAULT_MMAP_MAX
+ Default values of tunable parameters (described in detail below)
+ controlling interaction with host system routines (sbrk, mmap, etc).
+ These values may also be changed dynamically via mallopt(). The
+ preset defaults are those that give best performance for typical
+ programs/systems.
+
+
+*/
+
+
+
+
+/* Preliminaries */
+
+#ifndef __STD_C
+#ifdef __STDC__
+#define __STD_C 1
+#else
+#if __cplusplus
+#define __STD_C 1
+#else
+#define __STD_C 0
+#endif /*__cplusplus*/
+#endif /*__STDC__*/
+#endif /*__STD_C*/
+
+#ifndef Void_t
+#if __STD_C
+#define Void_t void
+#else
+#define Void_t char
+#endif
+#endif /*Void_t*/
+
+#if __STD_C
+#include /* for size_t */
+#else
+#include
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include /* needed for malloc_stats */
+#include /* needed for overflow checks */
+#include /* needed to set errno to ENOMEM */
+
+#ifdef WIN32
+#define WIN32_LEAN_AND_MEAN
+#include
+#endif
+
+/*
+ Compile-time options
+*/
+
+
+/*
+
+ Special defines for Cygnus newlib distribution.
+
+ */
+
+#ifdef INTERNAL_NEWLIB
+
+#include
+
+/*
+ In newlib, all the publically visible routines take a reentrancy
+ pointer. We don't currently do anything much with it, but we do
+ pass it to the lock routine.
+ */
+
+#include
+
+#define POINTER_UINT unsigned _POINTER_INT
+#define SEPARATE_OBJECTS
+#define HAVE_MMAP 0
+#define MORECORE(size) _sbrk_r(reent_ptr, (size))
+#define MORECORE_CLEARS 0
+#define MALLOC_LOCK __malloc_lock(reent_ptr)
+#define MALLOC_UNLOCK __malloc_unlock(reent_ptr)
+
+#ifdef __CYGWIN__
+# undef _WIN32
+# undef WIN32
+#endif
+
+#ifndef _WIN32
+#ifdef SMALL_MEMORY
+#define malloc_getpagesize (128)
+#else
+#define malloc_getpagesize (4096)
+#endif
+#endif
+
+#if __STD_C
+extern void __malloc_lock(struct _reent *);
+extern void __malloc_unlock(struct _reent *);
+#else
+extern void __malloc_lock();
+extern void __malloc_unlock();
+#endif
+
+#if __STD_C
+#define RARG struct _reent *reent_ptr,
+#define RONEARG struct _reent *reent_ptr
+#else
+#define RARG reent_ptr
+#define RONEARG reent_ptr
+#define RDECL struct _reent *reent_ptr;
+#endif
+
+#define RERRNO reent_ptr->_errno
+#define RCALL reent_ptr,
+#define RONECALL reent_ptr
+
+#else /* ! INTERNAL_NEWLIB */
+
+#define POINTER_UINT unsigned long
+#define RARG
+#define RONEARG
+#define RDECL
+#define RERRNO errno
+#define RCALL
+#define RONECALL
+
+#endif /* ! INTERNAL_NEWLIB */
+
+/*
+ Debugging:
+
+ Because freed chunks may be overwritten with link fields, this
+ malloc will often die when freed memory is overwritten by user
+ programs. This can be very effective (albeit in an annoying way)
+ in helping track down dangling pointers.
+
+ If you compile with -DDEBUG, a number of assertion checks are
+ enabled that will catch more memory errors. You probably won't be
+ able to make much sense of the actual assertion errors, but they
+ should help you locate incorrectly overwritten memory. The
+ checking is fairly extensive, and will slow down execution
+ noticeably. Calling malloc_stats or mallinfo with DEBUG set will
+ attempt to check every non-mmapped allocated and free chunk in the
+ course of computing the summmaries. (By nature, mmapped regions
+ cannot be checked very much automatically.)
+
+ Setting DEBUG may also be helpful if you are trying to modify
+ this code. The assertions in the check routines spell out in more
+ detail the assumptions and invariants underlying the algorithms.
+
+*/
+
+#if DEBUG
+#include
+#else
+#define assert(x) ((void)0)
+#endif
+
+
+/*
+ SEPARATE_OBJECTS should be defined if you want each function to go
+ into a separate .o file. You must then compile malloc.c once per
+ function, defining the appropriate DEFINE_ macro. See below for the
+ list of macros.
+ */
+
+#ifndef SEPARATE_OBJECTS
+#define DEFINE_MALLOC
+#define DEFINE_FREE
+#define DEFINE_REALLOC
+#define DEFINE_CALLOC
+#define DEFINE_CFREE
+#define DEFINE_MEMALIGN
+#define DEFINE_VALLOC
+#define DEFINE_PVALLOC
+#define DEFINE_MALLINFO
+#define DEFINE_MALLOC_STATS
+#define DEFINE_MALLOC_USABLE_SIZE
+#define DEFINE_MALLOPT
+
+#define STATIC static
+#else
+#define STATIC
+#endif
+
+/*
+ Define MALLOC_LOCK and MALLOC_UNLOCK to C expressions to run to
+ lock and unlock the malloc data structures. MALLOC_LOCK may be
+ called recursively.
+ */
+
+#ifndef MALLOC_LOCK
+#define MALLOC_LOCK
+#endif
+
+#ifndef MALLOC_UNLOCK
+#define MALLOC_UNLOCK
+#endif
+
+/*
+ INTERNAL_SIZE_T is the word-size used for internal bookkeeping
+ of chunk sizes. On a 64-bit machine, you can reduce malloc
+ overhead by defining INTERNAL_SIZE_T to be a 32 bit `unsigned int'
+ at the expense of not being able to handle requests greater than
+ 2^31. This limitation is hardly ever a concern; you are encouraged
+ to set this. However, the default version is the same as size_t.
+*/
+
+#ifndef INTERNAL_SIZE_T
+#define INTERNAL_SIZE_T size_t
+#endif
+
+/*
+ Following is needed on implementations whereby long > size_t.
+ The problem is caused because the code performs subtractions of
+ size_t values and stores the result in long values. In the case
+ where long > size_t and the first value is actually less than
+ the second value, the resultant value is positive. For example,
+ (long)(x - y) where x = 0 and y is 1 ends up being 0x00000000FFFFFFFF
+ which is 2*31 - 1 instead of 0xFFFFFFFFFFFFFFFF. This is due to the
+ fact that assignment from unsigned to signed won't sign extend.
+*/
+
+#define long_sub_size_t(x, y) \
+ (sizeof (long) > sizeof (INTERNAL_SIZE_T) && x < y \
+ ? -(long) (y - x) \
+ : (long) (x - y))
+
+/*
+ REALLOC_ZERO_BYTES_FREES should be set if a call to
+ realloc with zero bytes should be the same as a call to free.
+ Some people think it should. Otherwise, since this malloc
+ returns a unique pointer for malloc(0), so does realloc(p, 0).
+*/
+
+
+/* #define REALLOC_ZERO_BYTES_FREES */
+
+
+/*
+ WIN32 causes an emulation of sbrk to be compiled in
+ mmap-based options are not currently supported in WIN32.
+*/
+
+/* #define WIN32 */
+#ifdef WIN32
+#define MORECORE wsbrk
+#define HAVE_MMAP 0
+#endif
+
+
+/*
+ HAVE_MEMCPY should be defined if you are not otherwise using
+ ANSI STD C, but still have memcpy and memset in your C library
+ and want to use them in calloc and realloc. Otherwise simple
+ macro versions are defined here.
+
+ USE_MEMCPY should be defined as 1 if you actually want to
+ have memset and memcpy called. People report that the macro
+ versions are often enough faster than libc versions on many
+ systems that it is better to use them.
+
+*/
+
+#define HAVE_MEMCPY
+
+/* Although the original macro is called USE_MEMCPY, newlib actually
+ uses memmove to handle cases whereby a platform's memcpy implementation
+ copies backwards and thus destructive overlap may occur in realloc
+ whereby we are reclaiming free memory prior to the old allocation. */
+#ifndef USE_MEMCPY
+#ifdef HAVE_MEMCPY
+#define USE_MEMCPY 1
+#else
+#define USE_MEMCPY 0
+#endif
+#endif
+
+#if (__STD_C || defined(HAVE_MEMCPY))
+
+#if __STD_C
+void* memset(void*, int, size_t);
+void* memcpy(void*, const void*, size_t);
+void* memmove(void*, const void*, size_t);
+#else
+Void_t* memset();
+Void_t* memcpy();
+Void_t* memmove();
+#endif
+#endif
+
+#if USE_MEMCPY
+
+/* The following macros are only invoked with (2n+1)-multiples of
+ INTERNAL_SIZE_T units, with a positive integer n. This is exploited
+ for fast inline execution when n is small. */
+
+#define MALLOC_ZERO(charp, nbytes) \
+do { \
+ INTERNAL_SIZE_T mzsz = (nbytes); \
+ if(mzsz <= 9*sizeof(mzsz)) { \
+ INTERNAL_SIZE_T* mz = (INTERNAL_SIZE_T*) (charp); \
+ if(mzsz >= 5*sizeof(mzsz)) { *mz++ = 0; \
+ *mz++ = 0; \
+ if(mzsz >= 7*sizeof(mzsz)) { *mz++ = 0; \
+ *mz++ = 0; \
+ if(mzsz >= 9*sizeof(mzsz)) { *mz++ = 0; \
+ *mz++ = 0; }}} \
+ *mz++ = 0; \
+ *mz++ = 0; \
+ *mz = 0; \
+ } else memset((charp), 0, mzsz); \
+} while(0)
+
+#define MALLOC_COPY(dest,src,nbytes) \
+do { \
+ INTERNAL_SIZE_T mcsz = (nbytes); \
+ if(mcsz <= 9*sizeof(mcsz)) { \
+ INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) (src); \
+ INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) (dest); \
+ if(mcsz >= 5*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
+ *mcdst++ = *mcsrc++; \
+ if(mcsz >= 7*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
+ *mcdst++ = *mcsrc++; \
+ if(mcsz >= 9*sizeof(mcsz)) { *mcdst++ = *mcsrc++; \
+ *mcdst++ = *mcsrc++; }}} \
+ *mcdst++ = *mcsrc++; \
+ *mcdst++ = *mcsrc++; \
+ *mcdst = *mcsrc ; \
+ } else memmove(dest, src, mcsz); \
+} while(0)
+
+#else /* !USE_MEMCPY */
+
+/* Use Duff's device for good zeroing/copying performance. */
+
+#define MALLOC_ZERO(charp, nbytes) \
+do { \
+ INTERNAL_SIZE_T* mzp = (INTERNAL_SIZE_T*)(charp); \
+ long mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T), mcn; \
+ if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; } \
+ switch (mctmp) { \
+ case 0: for(;;) { *mzp++ = 0; \
+ case 7: *mzp++ = 0; \
+ case 6: *mzp++ = 0; \
+ case 5: *mzp++ = 0; \
+ case 4: *mzp++ = 0; \
+ case 3: *mzp++ = 0; \
+ case 2: *mzp++ = 0; \
+ case 1: *mzp++ = 0; if(mcn <= 0) break; mcn--; } \
+ } \
+} while(0)
+
+#define MALLOC_COPY(dest,src,nbytes) \
+do { \
+ INTERNAL_SIZE_T* mcsrc = (INTERNAL_SIZE_T*) src; \
+ INTERNAL_SIZE_T* mcdst = (INTERNAL_SIZE_T*) dest; \
+ long mctmp = (nbytes)/sizeof(INTERNAL_SIZE_T), mcn; \
+ if (mctmp < 8) mcn = 0; else { mcn = (mctmp-1)/8; mctmp %= 8; } \
+ switch (mctmp) { \
+ case 0: for(;;) { *mcdst++ = *mcsrc++; \
+ case 7: *mcdst++ = *mcsrc++; \
+ case 6: *mcdst++ = *mcsrc++; \
+ case 5: *mcdst++ = *mcsrc++; \
+ case 4: *mcdst++ = *mcsrc++; \
+ case 3: *mcdst++ = *mcsrc++; \
+ case 2: *mcdst++ = *mcsrc++; \
+ case 1: *mcdst++ = *mcsrc++; if(mcn <= 0) break; mcn--; } \
+ } \
+} while(0)
+
+#endif
+
+
+/*
+ Define HAVE_MMAP to optionally make malloc() use mmap() to
+ allocate very large blocks. These will be returned to the
+ operating system immediately after a free().
+*/
+
+#ifndef HAVE_MMAP
+#define HAVE_MMAP 1
+#endif
+
+/*
+ Define HAVE_MREMAP to make realloc() use mremap() to re-allocate
+ large blocks. This is currently only possible on Linux with
+ kernel versions newer than 1.3.77.
+*/
+
+#ifndef HAVE_MREMAP
+#ifdef INTERNAL_LINUX_C_LIB
+#define HAVE_MREMAP 1
+#else
+#define HAVE_MREMAP 0
+#endif
+#endif
+
+#if HAVE_MMAP
+
+#include
+#include
+#include
+
+#if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
+#endif /* HAVE_MMAP */
+
+/*
+ Access to system page size. To the extent possible, this malloc
+ manages memory from the system in page-size units.
+
+ The following mechanics for getpagesize were adapted from
+ bsd/gnu getpagesize.h
+*/
+
+#ifndef LACKS_UNISTD_H
+# include
+#endif
+
+#ifndef malloc_getpagesize
+# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */
+# ifndef _SC_PAGE_SIZE
+# define _SC_PAGE_SIZE _SC_PAGESIZE
+# endif
+# endif
+# ifdef _SC_PAGE_SIZE
+# define malloc_getpagesize sysconf(_SC_PAGE_SIZE)
+# else
+# if defined(BSD) || defined(DGUX) || defined(HAVE_GETPAGESIZE)
+ extern size_t getpagesize();
+# define malloc_getpagesize getpagesize()
+# else
+# include
+# ifdef EXEC_PAGESIZE
+# define malloc_getpagesize EXEC_PAGESIZE
+# else
+# ifdef NBPG
+# ifndef CLSIZE
+# define malloc_getpagesize NBPG
+# else
+# define malloc_getpagesize (NBPG * CLSIZE)
+# endif
+# else
+# ifdef NBPC
+# define malloc_getpagesize NBPC
+# else
+# ifdef PAGESIZE
+# define malloc_getpagesize PAGESIZE
+# else
+# define malloc_getpagesize (4096) /* just guess */
+# endif
+# endif
+# endif
+# endif
+# endif
+# endif
+#endif
+
+
+
+/*
+
+ This version of malloc supports the standard SVID/XPG mallinfo
+ routine that returns a struct containing the same kind of
+ information you can get from malloc_stats. It should work on
+ any SVID/XPG compliant system that has a /usr/include/malloc.h
+ defining struct mallinfo. (If you'd like to install such a thing
+ yourself, cut out the preliminary declarations as described above
+ and below and save them in a malloc.h file. But there's no
+ compelling reason to bother to do this.)
+
+ The main declaration needed is the mallinfo struct that is returned
+ (by-copy) by mallinfo(). The SVID/XPG malloinfo struct contains a
+ bunch of fields, most of which are not even meaningful in this
+ version of malloc. Some of these fields are are instead filled by
+ mallinfo() with other numbers that might possibly be of interest.
+
+ HAVE_USR_INCLUDE_MALLOC_H should be set if you have a
+ /usr/include/malloc.h file that includes a declaration of struct
+ mallinfo. If so, it is included; else an SVID2/XPG2 compliant
+ version is declared below. These must be precisely the same for
+ mallinfo() to work.
+
+*/
+
+/* #define HAVE_USR_INCLUDE_MALLOC_H */
+
+#if HAVE_USR_INCLUDE_MALLOC_H
+#include "/usr/include/malloc.h"
+#else
+
+/* SVID2/XPG mallinfo structure */
+
+struct mallinfo {
+ int arena; /* total space allocated from system */
+ int ordblks; /* number of non-inuse chunks */
+ int smblks; /* unused -- always zero */
+ int hblks; /* number of mmapped regions */
+ int hblkhd; /* total space in mmapped regions */
+ int usmblks; /* unused -- always zero */
+ int fsmblks; /* unused -- always zero */
+ int uordblks; /* total allocated space */
+ int fordblks; /* total non-inuse space */
+ int keepcost; /* top-most, releasable (via malloc_trim) space */
+};
+
+/* SVID2/XPG mallopt options */
+
+#define M_MXFAST 1 /* UNUSED in this malloc */
+#define M_NLBLKS 2 /* UNUSED in this malloc */
+#define M_GRAIN 3 /* UNUSED in this malloc */
+#define M_KEEP 4 /* UNUSED in this malloc */
+
+#endif
+
+/* mallopt options that actually do something */
+
+#define M_TRIM_THRESHOLD -1
+#define M_TOP_PAD -2
+#define M_MMAP_THRESHOLD -3
+#define M_MMAP_MAX -4
+
+
+
+#ifndef DEFAULT_TRIM_THRESHOLD
+#define DEFAULT_TRIM_THRESHOLD (128L * 1024L)
+#endif
+
+/*
+ M_TRIM_THRESHOLD is the maximum amount of unused top-most memory
+ to keep before releasing via malloc_trim in free().
+
+ Automatic trimming is mainly useful in long-lived programs.
+ Because trimming via sbrk can be slow on some systems, and can
+ sometimes be wasteful (in cases where programs immediately
+ afterward allocate more large chunks) the value should be high
+ enough so that your overall system performance would improve by
+ releasing.
+
+ The trim threshold and the mmap control parameters (see below)
+ can be traded off with one another. Trimming and mmapping are
+ two different ways of releasing unused memory back to the
+ system. Between these two, it is often possible to keep
+ system-level demands of a long-lived program down to a bare
+ minimum. For example, in one test suite of sessions measuring
+ the XF86 X server on Linux, using a trim threshold of 128K and a
+ mmap threshold of 192K led to near-minimal long term resource
+ consumption.
+
+ If you are using this malloc in a long-lived program, it should
+ pay to experiment with these values. As a rough guide, you
+ might set to a value close to the average size of a process
+ (program) running on your system. Releasing this much memory
+ would allow such a process to run in memory. Generally, it's
+ worth it to tune for trimming rather tham memory mapping when a
+ program undergoes phases where several large chunks are
+ allocated and released in ways that can reuse each other's
+ storage, perhaps mixed with phases where there are no such
+ chunks at all. And in well-behaved long-lived programs,
+ controlling release of large blocks via trimming versus mapping
+ is usually faster.
+
+ However, in most programs, these parameters serve mainly as
+ protection against the system-level effects of carrying around
+ massive amounts of unneeded memory. Since frequent calls to
+ sbrk, mmap, and munmap otherwise degrade performance, the default
+ parameters are set to relatively high values that serve only as
+ safeguards.
+
+ The default trim value is high enough to cause trimming only in
+ fairly extreme (by current memory consumption standards) cases.
+ It must be greater than page size to have any useful effect. To
+ disable trimming completely, you can set to (unsigned long)(-1);
+
+
+*/
+
+
+#ifndef DEFAULT_TOP_PAD
+#define DEFAULT_TOP_PAD (0)
+#endif
+
+/*
+ M_TOP_PAD is the amount of extra `padding' space to allocate or
+ retain whenever sbrk is called. It is used in two ways internally:
+
+ * When sbrk is called to extend the top of the arena to satisfy
+ a new malloc request, this much padding is added to the sbrk
+ request.
+
+ * When malloc_trim is called automatically from free(),
+ it is used as the `pad' argument.
+
+ In both cases, the actual amount of padding is rounded
+ so that the end of the arena is always a system page boundary.
+
+ The main reason for using padding is to avoid calling sbrk so
+ often. Having even a small pad greatly reduces the likelihood
+ that nearly every malloc request during program start-up (or
+ after trimming) will invoke sbrk, which needlessly wastes
+ time.
+
+ Automatic rounding-up to page-size units is normally sufficient
+ to avoid measurable overhead, so the default is 0. However, in
+ systems where sbrk is relatively slow, it can pay to increase
+ this value, at the expense of carrying around more memory than
+ the program needs.
+
+*/
+
+
+#ifndef DEFAULT_MMAP_THRESHOLD
+#define DEFAULT_MMAP_THRESHOLD (128 * 1024)
+#endif
+
+/*
+
+ M_MMAP_THRESHOLD is the request size threshold for using mmap()
+ to service a request. Requests of at least this size that cannot
+ be allocated using already-existing space will be serviced via mmap.
+ (If enough normal freed space already exists it is used instead.)
+
+ Using mmap segregates relatively large chunks of memory so that
+ they can be individually obtained and released from the host
+ system. A request serviced through mmap is never reused by any
+ other request (at least not directly; the system may just so
+ happen to remap successive requests to the same locations).
+
+ Segregating space in this way has the benefit that mmapped space
+ can ALWAYS be individually released back to the system, which
+ helps keep the system level memory demands of a long-lived
+ program low. Mapped memory can never become `locked' between
+ other chunks, as can happen with normally allocated chunks, which
+ menas that even trimming via malloc_trim would not release them.
+
+ However, it has the disadvantages that:
+
+ 1. The space cannot be reclaimed, consolidated, and then
+ used to service later requests, as happens with normal chunks.
+ 2. It can lead to more wastage because of mmap page alignment
+ requirements
+ 3. It causes malloc performance to be more dependent on host
+ system memory management support routines which may vary in
+ implementation quality and may impose arbitrary
+ limitations. Generally, servicing a request via normal
+ malloc steps is faster than going through a system's mmap.
+
+ All together, these considerations should lead you to use mmap
+ only for relatively large requests.
+
+
+*/
+
+
+
+#ifndef DEFAULT_MMAP_MAX
+#if HAVE_MMAP
+#define DEFAULT_MMAP_MAX (64)
+#else
+#define DEFAULT_MMAP_MAX (0)
+#endif
+#endif
+
+/*
+ M_MMAP_MAX is the maximum number of requests to simultaneously
+ service using mmap. This parameter exists because:
+
+ 1. Some systems have a limited number of internal tables for
+ use by mmap.
+ 2. In most systems, overreliance on mmap can degrade overall
+ performance.
+ 3. If a program allocates many large regions, it is probably
+ better off using normal sbrk-based allocation routines that
+ can reclaim and reallocate normal heap memory. Using a
+ small value allows transition into this mode after the
+ first few allocations.
+
+ Setting to 0 disables all use of mmap. If HAVE_MMAP is not set,
+ the default value is 0, and attempts to set it to non-zero values
+ in mallopt will fail.
+*/
+
+
+
+
+/*
+
+ Special defines for linux libc
+
+ Except when compiled using these special defines for Linux libc
+ using weak aliases, this malloc is NOT designed to work in
+ multithreaded applications. No semaphores or other concurrency
+ control are provided to ensure that multiple malloc or free calls
+ don't run at the same time, which could be disasterous. A single
+ semaphore could be used across malloc, realloc, and free (which is
+ essentially the effect of the linux weak alias approach). It would
+ be hard to obtain finer granularity.
+
+*/
+
+
+#ifdef INTERNAL_LINUX_C_LIB
+
+#if __STD_C
+
+Void_t * __default_morecore_init (ptrdiff_t);
+Void_t *(*__morecore)(ptrdiff_t) = __default_morecore_init;
+
+#else
+
+Void_t * __default_morecore_init ();
+Void_t *(*__morecore)() = __default_morecore_init;
+
+#endif
+
+#define MORECORE (*__morecore)
+#define MORECORE_FAILURE 0
+#define MORECORE_CLEARS 1
+
+#else /* INTERNAL_LINUX_C_LIB */
+
+#ifndef INTERNAL_NEWLIB
+#if __STD_C
+extern Void_t* sbrk(ptrdiff_t);
+#else
+extern Void_t* sbrk();
+#endif
+#endif
+
+#ifndef MORECORE
+#define MORECORE sbrk
+#endif
+
+#ifndef MORECORE_FAILURE
+#define MORECORE_FAILURE -1
+#endif
+
+#ifndef MORECORE_CLEARS
+#define MORECORE_CLEARS 1
+#endif
+
+#endif /* INTERNAL_LINUX_C_LIB */
+
+#if defined(INTERNAL_LINUX_C_LIB) && defined(__ELF__)
+
+#define cALLOc __libc_calloc
+#define fREe __libc_free
+#define mALLOc __libc_malloc
+#define mEMALIGn __libc_memalign
+#define rEALLOc __libc_realloc
+#define vALLOc __libc_valloc
+#define pvALLOc __libc_pvalloc
+#define mALLINFo __libc_mallinfo
+#define mALLOPt __libc_mallopt
+
+#pragma weak calloc = __libc_calloc
+#pragma weak free = __libc_free
+#pragma weak cfree = __libc_free
+#pragma weak malloc = __libc_malloc
+#pragma weak memalign = __libc_memalign
+#pragma weak realloc = __libc_realloc
+#pragma weak valloc = __libc_valloc
+#pragma weak pvalloc = __libc_pvalloc
+#pragma weak mallinfo = __libc_mallinfo
+#pragma weak mallopt = __libc_mallopt
+
+#else
+
+#ifdef INTERNAL_NEWLIB
+
+#define cALLOc _calloc_r
+#define fREe _free_r
+#define mALLOc _malloc_r
+#define mEMALIGn _memalign_r
+#define rEALLOc _realloc_r
+#define vALLOc _valloc_r
+#define pvALLOc _pvalloc_r
+#define mALLINFo _mallinfo_r
+#define mALLOPt _mallopt_r
+
+#define malloc_stats _malloc_stats_r
+#define malloc_trim _malloc_trim_r
+#define malloc_usable_size _malloc_usable_size_r
+
+#define malloc_update_mallinfo __malloc_update_mallinfo
+
+#define malloc_av_ __malloc_av_
+#define malloc_current_mallinfo __malloc_current_mallinfo
+#define malloc_max_sbrked_mem __malloc_max_sbrked_mem
+#define malloc_max_total_mem __malloc_max_total_mem
+#define malloc_sbrk_base __malloc_sbrk_base
+#define malloc_top_pad __malloc_top_pad
+#define malloc_trim_threshold __malloc_trim_threshold
+
+#else /* ! INTERNAL_NEWLIB */
+
+#define cALLOc calloc
+#define fREe free
+#define mALLOc malloc
+#define mEMALIGn memalign
+#define rEALLOc realloc
+#define vALLOc valloc
+#define pvALLOc pvalloc
+#define mALLINFo mallinfo
+#define mALLOPt mallopt
+
+#endif /* ! INTERNAL_NEWLIB */
+#endif
+
+/* Public routines */
+
+#if __STD_C
+
+Void_t* mALLOc(RARG size_t);
+void fREe(RARG Void_t*);
+Void_t* rEALLOc(RARG Void_t*, size_t);
+Void_t* mEMALIGn(RARG size_t, size_t);
+Void_t* vALLOc(RARG size_t);
+Void_t* pvALLOc(RARG size_t);
+Void_t* cALLOc(RARG size_t, size_t);
+void cfree(Void_t*);
+int malloc_trim(RARG size_t);
+size_t malloc_usable_size(RARG Void_t*);
+void malloc_stats(RONEARG);
+int mALLOPt(RARG int, int);
+struct mallinfo mALLINFo(RONEARG);
+#else
+Void_t* mALLOc();
+void fREe();
+Void_t* rEALLOc();
+Void_t* mEMALIGn();
+Void_t* vALLOc();
+Void_t* pvALLOc();
+Void_t* cALLOc();
+void cfree();
+int malloc_trim();
+size_t malloc_usable_size();
+void malloc_stats();
+int mALLOPt();
+struct mallinfo mALLINFo();
+#endif
+
+
+#ifdef __cplusplus
+}; /* end of extern "C" */
+#endif
+
+/* ---------- To make a malloc.h, end cutting here ------------ */
+
+
+/*
+ Emulation of sbrk for WIN32
+ All code within the ifdef WIN32 is untested by me.
+*/
+
+
+#ifdef WIN32
+
+#define AlignPage(add) (((add) + (malloc_getpagesize-1)) & \
+~(malloc_getpagesize-1))
+
+/* resrve 64MB to insure large contiguous space */
+#define RESERVED_SIZE (1024*1024*64)
+#define NEXT_SIZE (2048*1024)
+#define TOP_MEMORY ((unsigned long)2*1024*1024*1024)
+
+struct GmListElement;
+typedef struct GmListElement GmListElement;
+
+struct GmListElement
+{
+ GmListElement* next;
+ void* base;
+};
+
+static GmListElement* head = 0;
+static unsigned int gNextAddress = 0;
+static unsigned int gAddressBase = 0;
+static unsigned int gAllocatedSize = 0;
+
+static
+GmListElement* makeGmListElement (void* bas)
+{
+ GmListElement* this;
+ this = (GmListElement*)(void*)LocalAlloc (0, sizeof (GmListElement));
+ ASSERT (this);
+ if (this)
+ {
+ this->base = bas;
+ this->next = head;
+ head = this;
+ }
+ return this;
+}
+
+void gcleanup ()
+{
+ BOOL rval;
+ ASSERT ( (head == NULL) || (head->base == (void*)gAddressBase));
+ if (gAddressBase && (gNextAddress - gAddressBase))
+ {
+ rval = VirtualFree ((void*)gAddressBase,
+ gNextAddress - gAddressBase,
+ MEM_DECOMMIT);
+ ASSERT (rval);
+ }
+ while (head)
+ {
+ GmListElement* next = head->next;
+ rval = VirtualFree (head->base, 0, MEM_RELEASE);
+ ASSERT (rval);
+ LocalFree (head);
+ head = next;
+ }
+}
+
+static
+void* findRegion (void* start_address, unsigned long size)
+{
+ MEMORY_BASIC_INFORMATION info;
+ while ((unsigned long)start_address < TOP_MEMORY)
+ {
+ VirtualQuery (start_address, &info, sizeof (info));
+ if (info.State != MEM_FREE)
+ start_address = (char*)info.BaseAddress + info.RegionSize;
+ else if (info.RegionSize >= size)
+ return start_address;
+ else
+ start_address = (char*)info.BaseAddress + info.RegionSize;
+ }
+ return NULL;
+
+}
+
+
+void* wsbrk (long size)
+{
+ void* tmp;
+ if (size > 0)
+ {
+ if (gAddressBase == 0)
+ {
+ gAllocatedSize = max (RESERVED_SIZE, AlignPage (size));
+ gNextAddress = gAddressBase =
+ (unsigned int)VirtualAlloc (NULL, gAllocatedSize,
+ MEM_RESERVE, PAGE_NOACCESS);
+ } else if (AlignPage (gNextAddress + size) > (gAddressBase +
+gAllocatedSize))
+ {
+ long new_size = max (NEXT_SIZE, AlignPage (size));
+ void* new_address = (void*)(gAddressBase+gAllocatedSize);
+ do
+ {
+ new_address = findRegion (new_address, new_size);
+
+ if (new_address == 0)
+ return (void*)-1;
+
+ gAddressBase = gNextAddress =
+ (unsigned int)VirtualAlloc (new_address, new_size,
+ MEM_RESERVE, PAGE_NOACCESS);
+ // repeat in case of race condition
+ // The region that we found has been snagged
+ // by another thread
+ }
+ while (gAddressBase == 0);
+
+ ASSERT (new_address == (void*)gAddressBase);
+
+ gAllocatedSize = new_size;
+
+ if (!makeGmListElement ((void*)gAddressBase))
+ return (void*)-1;
+ }
+ if ((size + gNextAddress) > AlignPage (gNextAddress))
+ {
+ void* res;
+ res = VirtualAlloc ((void*)AlignPage (gNextAddress),
+ (size + gNextAddress -
+ AlignPage (gNextAddress)),
+ MEM_COMMIT, PAGE_READWRITE);
+ if (res == 0)
+ return (void*)-1;
+ }
+ tmp = (void*)gNextAddress;
+ gNextAddress = (unsigned int)tmp + size;
+ return tmp;
+ }
+ else if (size < 0)
+ {
+ unsigned int alignedGoal = AlignPage (gNextAddress + size);
+ /* Trim by releasing the virtual memory */
+ if (alignedGoal >= gAddressBase)
+ {
+ VirtualFree ((void*)alignedGoal, gNextAddress - alignedGoal,
+ MEM_DECOMMIT);
+ gNextAddress = gNextAddress + size;
+ return (void*)gNextAddress;
+ }
+ else
+ {
+ VirtualFree ((void*)gAddressBase, gNextAddress - gAddressBase,
+ MEM_DECOMMIT);
+ gNextAddress = gAddressBase;
+ return (void*)-1;
+ }
+ }
+ else
+ {
+ return (void*)gNextAddress;
+ }
+}
+
+#endif
+
+
+
+/*
+ Type declarations
+*/
+
+
+struct malloc_chunk
+{
+ INTERNAL_SIZE_T prev_size; /* Size of previous chunk (if free). */
+ INTERNAL_SIZE_T size; /* Size in bytes, including overhead. */
+ struct malloc_chunk* fd; /* double links -- used only if free. */
+ struct malloc_chunk* bk;
+};
+
+typedef struct malloc_chunk* mchunkptr;
+
+/*
+
+ malloc_chunk details:
+
+ (The following includes lightly edited explanations by Colin Plumb.)
+
+ Chunks of memory are maintained using a `boundary tag' method as
+ described in e.g., Knuth or Standish. (See the paper by Paul
+ Wilson ftp://ftp.cs.utexas.edu/pub/garbage/allocsrv.ps for a
+ survey of such techniques.) Sizes of free chunks are stored both
+ in the front of each chunk and at the end. This makes
+ consolidating fragmented chunks into bigger chunks very fast. The
+ size fields also hold bits representing whether chunks are free or
+ in use.
+
+ An allocated chunk looks like this:
+
+
+ chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Size of previous chunk, if allocated | |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Size of chunk, in bytes |P|
+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | User data starts here... .
+ . .
+ . (malloc_usable_space() bytes) .
+ . |
+nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Size of chunk |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+
+ Where "chunk" is the front of the chunk for the purpose of most of
+ the malloc code, but "mem" is the pointer that is returned to the
+ user. "Nextchunk" is the beginning of the next contiguous chunk.
+
+ Chunks always begin on even word boundries, so the mem portion
+ (which is returned to the user) is also on an even word boundary, and
+ thus double-word aligned.
+
+ Free chunks are stored in circular doubly-linked lists, and look like this:
+
+ chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Size of previous chunk |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ `head:' | Size of chunk, in bytes |P|
+ mem-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Forward pointer to next chunk in list |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Back pointer to previous chunk in list |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ | Unused space (may be 0 bytes long) .
+ . .
+ . |
+nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ `foot:' | Size of chunk, in bytes |
+ +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+
+ The P (PREV_INUSE) bit, stored in the unused low-order bit of the
+ chunk size (which is always a multiple of two words), is an in-use
+ bit for the *previous* chunk. If that bit is *clear*, then the
+ word before the current chunk size contains the previous chunk
+ size, and can be used to find the front of the previous chunk.
+ (The very first chunk allocated always has this bit set,
+ preventing access to non-existent (or non-owned) memory.)
+
+ Note that the `foot' of the current chunk is actually represented
+ as the prev_size of the NEXT chunk. (This makes it easier to
+ deal with alignments etc).
+
+ The two exceptions to all this are
+
+ 1. The special chunk `top', which doesn't bother using the
+ trailing size field since there is no
+ next contiguous chunk that would have to index off it. (After
+ initialization, `top' is forced to always exist. If it would
+ become less than MINSIZE bytes long, it is replenished via
+ malloc_extend_top.)
+
+ 2. Chunks allocated via mmap, which have the second-lowest-order
+ bit (IS_MMAPPED) set in their size fields. Because they are
+ never merged or traversed from any other chunk, they have no
+ foot size or inuse information.
+
+ Available chunks are kept in any of several places (all declared below):
+
+ * `av': An array of chunks serving as bin headers for consolidated
+ chunks. Each bin is doubly linked. The bins are approximately
+ proportionally (log) spaced. There are a lot of these bins
+ (128). This may look excessive, but works very well in
+ practice. All procedures maintain the invariant that no
+ consolidated chunk physically borders another one. Chunks in
+ bins are kept in size order, with ties going to the
+ approximately least recently used chunk.
+
+ The chunks in each bin are maintained in decreasing sorted order by
+ size. This is irrelevant for the small bins, which all contain
+ the same-sized chunks, but facilitates best-fit allocation for
+ larger chunks. (These lists are just sequential. Keeping them in
+ order almost never requires enough traversal to warrant using
+ fancier ordered data structures.) Chunks of the same size are
+ linked with the most recently freed at the front, and allocations
+ are taken from the back. This results in LRU or FIFO allocation
+ order, which tends to give each chunk an equal opportunity to be
+ consolidated with adjacent freed chunks, resulting in larger free
+ chunks and less fragmentation.
+
+ * `top': The top-most available chunk (i.e., the one bordering the
+ end of available memory) is treated specially. It is never
+ included in any bin, is used only if no other chunk is
+ available, and is released back to the system if it is very
+ large (see M_TRIM_THRESHOLD).
+
+ * `last_remainder': A bin holding only the remainder of the
+ most recently split (non-top) chunk. This bin is checked
+ before other non-fitting chunks, so as to provide better
+ locality for runs of sequentially allocated chunks.
+
+ * Implicitly, through the host system's memory mapping tables.
+ If supported, requests greater than a threshold are usually
+ serviced via calls to mmap, and then later released via munmap.
+
+*/
+
+
+
+
+
+
+/* sizes, alignments */
+
+#define SIZE_SZ (sizeof(INTERNAL_SIZE_T))
+#ifndef MALLOC_ALIGNMENT
+#define MALLOC_ALIGN 8
+#define MALLOC_ALIGNMENT (SIZE_SZ < 4 ? 8 : (SIZE_SZ + SIZE_SZ))
+#else
+#define MALLOC_ALIGN MALLOC_ALIGNMENT
+#endif
+#define MALLOC_ALIGN_MASK (MALLOC_ALIGNMENT - 1)
+#define MINSIZE (sizeof(struct malloc_chunk))
+
+/* conversion from malloc headers to user pointers, and back */
+
+#define chunk2mem(p) ((Void_t*)((char*)(p) + 2*SIZE_SZ))
+#define mem2chunk(mem) ((mchunkptr)((char*)(mem) - 2*SIZE_SZ))
+
+/* pad request bytes into a usable size */
+
+#define request2size(req) \
+ (((unsigned long)((req) + (SIZE_SZ + MALLOC_ALIGN_MASK)) < \
+ (unsigned long)(MINSIZE + MALLOC_ALIGN_MASK)) ? ((MINSIZE + MALLOC_ALIGN_MASK) & ~(MALLOC_ALIGN_MASK)) : \
+ (((req) + (SIZE_SZ + MALLOC_ALIGN_MASK)) & ~(MALLOC_ALIGN_MASK)))
+
+/* Check if m has acceptable alignment */
+
+#define aligned_OK(m) (((unsigned long)((m)) & (MALLOC_ALIGN_MASK)) == 0)
+
+
+
+
+/*
+ Physical chunk operations
+*/
+
+
+/* size field is or'ed with PREV_INUSE when previous adjacent chunk in use */
+
+#define PREV_INUSE 0x1
+
+/* size field is or'ed with IS_MMAPPED if the chunk was obtained with mmap() */
+
+#define IS_MMAPPED 0x2
+
+/* Bits to mask off when extracting size */
+
+#define SIZE_BITS (PREV_INUSE|IS_MMAPPED)
+
+
+/* Ptr to next physical malloc_chunk. */
+
+#define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->size & ~PREV_INUSE) ))
+
+/* Ptr to previous physical malloc_chunk */
+
+#define prev_chunk(p)\
+ ((mchunkptr)( ((char*)(p)) - ((p)->prev_size) ))
+
+
+/* Treat space at ptr + offset as a chunk */
+
+#define chunk_at_offset(p, s) ((mchunkptr)(((char*)(p)) + (s)))
+
+
+
+
+/*
+ Dealing with use bits
+*/
+
+/* extract p's inuse bit */
+
+#define inuse(p)\
+((((mchunkptr)(((char*)(p))+((p)->size & ~PREV_INUSE)))->size) & PREV_INUSE)
+
+/* extract inuse bit of previous chunk */
+
+#define prev_inuse(p) ((p)->size & PREV_INUSE)
+
+/* check for mmap()'ed chunk */
+
+#define chunk_is_mmapped(p) ((p)->size & IS_MMAPPED)
+
+/* set/clear chunk as in use without otherwise disturbing */
+
+#define set_inuse(p)\
+((mchunkptr)(((char*)(p)) + ((p)->size & ~PREV_INUSE)))->size |= PREV_INUSE
+
+#define clear_inuse(p)\
+((mchunkptr)(((char*)(p)) + ((p)->size & ~PREV_INUSE)))->size &= ~(PREV_INUSE)
+
+/* check/set/clear inuse bits in known places */
+
+#define inuse_bit_at_offset(p, s)\
+ (((mchunkptr)(((char*)(p)) + (s)))->size & PREV_INUSE)
+
+#define set_inuse_bit_at_offset(p, s)\
+ (((mchunkptr)(((char*)(p)) + (s)))->size |= PREV_INUSE)
+
+#define clear_inuse_bit_at_offset(p, s)\
+ (((mchunkptr)(((char*)(p)) + (s)))->size &= ~(PREV_INUSE))
+
+
+
+
+/*
+ Dealing with size fields
+*/
+
+/* Get size, ignoring use bits */
+
+#define chunksize(p) ((p)->size & ~(SIZE_BITS))
+
+/* Set size at head, without disturbing its use bit */
+
+#define set_head_size(p, s) ((p)->size = (((p)->size & PREV_INUSE) | (s)))
+
+/* Set size/use ignoring previous bits in header */
+
+#define set_head(p, s) ((p)->size = (s))
+
+/* Set size at footer (only when chunk is not in use) */
+
+#define set_foot(p, s) (((mchunkptr)((char*)(p) + (s)))->prev_size = (s))
+
+
+
+
+
+/*
+ Bins
+
+ The bins, `av_' are an array of pairs of pointers serving as the
+ heads of (initially empty) doubly-linked lists of chunks, laid out
+ in a way so that each pair can be treated as if it were in a
+ malloc_chunk. (This way, the fd/bk offsets for linking bin heads
+ and chunks are the same).
+
+ Bins for sizes < 512 bytes contain chunks of all the same size, spaced
+ 8 bytes apart. Larger bins are approximately logarithmically
+ spaced. (See the table below.) The `av_' array is never mentioned
+ directly in the code, but instead via bin access macros.
+
+ Bin layout:
+
+ 64 bins of size 8
+ 32 bins of size 64
+ 16 bins of size 512
+ 8 bins of size 4096
+ 4 bins of size 32768
+ 2 bins of size 262144
+ 1 bin of size what's left
+
+ There is actually a little bit of slop in the numbers in bin_index
+ for the sake of speed. This makes no difference elsewhere.
+
+ The special chunks `top' and `last_remainder' get their own bins,
+ (this is implemented via yet more trickery with the av_ array),
+ although `top' is never properly linked to its bin since it is
+ always handled specially.
+
+*/
+
+#ifdef SEPARATE_OBJECTS
+#define av_ malloc_av_
+#endif
+
+#define NAV 128 /* number of bins */
+
+typedef struct malloc_chunk* mbinptr;
+
+/* access macros */
+
+#define bin_at(i) ((mbinptr)((char*)&(av_[2*(i) + 2]) - 2*SIZE_SZ))
+#define next_bin(b) ((mbinptr)((char*)(b) + 2 * sizeof(mbinptr)))
+#define prev_bin(b) ((mbinptr)((char*)(b) - 2 * sizeof(mbinptr)))
+
+/*
+ The first 2 bins are never indexed. The corresponding av_ cells are instead
+ used for bookkeeping. This is not to save space, but to simplify
+ indexing, maintain locality, and avoid some initialization tests.
+*/
+
+#define top (bin_at(0)->fd) /* The topmost chunk */
+#define last_remainder (bin_at(1)) /* remainder from last split */
+
+
+/*
+ Because top initially points to its own bin with initial
+ zero size, thus forcing extension on the first malloc request,
+ we avoid having any special code in malloc to check whether
+ it even exists yet. But we still need to in malloc_extend_top.
+*/
+
+#define initial_top ((mchunkptr)(bin_at(0)))
+
+/* Helper macro to initialize bins */
+
+#define IAV(i) bin_at(i), bin_at(i)
+
+#ifdef DEFINE_MALLOC
+STATIC mbinptr av_[NAV * 2 + 2] = {
+ 0, 0,
+ IAV(0), IAV(1), IAV(2), IAV(3), IAV(4), IAV(5), IAV(6), IAV(7),
+ IAV(8), IAV(9), IAV(10), IAV(11), IAV(12), IAV(13), IAV(14), IAV(15),
+ IAV(16), IAV(17), IAV(18), IAV(19), IAV(20), IAV(21), IAV(22), IAV(23),
+ IAV(24), IAV(25), IAV(26), IAV(27), IAV(28), IAV(29), IAV(30), IAV(31),
+ IAV(32), IAV(33), IAV(34), IAV(35), IAV(36), IAV(37), IAV(38), IAV(39),
+ IAV(40), IAV(41), IAV(42), IAV(43), IAV(44), IAV(45), IAV(46), IAV(47),
+ IAV(48), IAV(49), IAV(50), IAV(51), IAV(52), IAV(53), IAV(54), IAV(55),
+ IAV(56), IAV(57), IAV(58), IAV(59), IAV(60), IAV(61), IAV(62), IAV(63),
+ IAV(64), IAV(65), IAV(66), IAV(67), IAV(68), IAV(69), IAV(70), IAV(71),
+ IAV(72), IAV(73), IAV(74), IAV(75), IAV(76), IAV(77), IAV(78), IAV(79),
+ IAV(80), IAV(81), IAV(82), IAV(83), IAV(84), IAV(85), IAV(86), IAV(87),
+ IAV(88), IAV(89), IAV(90), IAV(91), IAV(92), IAV(93), IAV(94), IAV(95),
+ IAV(96), IAV(97), IAV(98), IAV(99), IAV(100), IAV(101), IAV(102), IAV(103),
+ IAV(104), IAV(105), IAV(106), IAV(107), IAV(108), IAV(109), IAV(110), IAV(111),
+ IAV(112), IAV(113), IAV(114), IAV(115), IAV(116), IAV(117), IAV(118), IAV(119),
+ IAV(120), IAV(121), IAV(122), IAV(123), IAV(124), IAV(125), IAV(126), IAV(127)
+};
+#else
+extern mbinptr av_[NAV * 2 + 2];
+#endif
+
+
+
+/* field-extraction macros */
+
+#define first(b) ((b)->fd)
+#define last(b) ((b)->bk)
+
+/*
+ Indexing into bins
+*/
+
+#define bin_index(sz) \
+(((((unsigned long)(sz)) >> 9) == 0) ? (((unsigned long)(sz)) >> 3): \
+ ((((unsigned long)(sz)) >> 9) <= 4) ? 56 + (((unsigned long)(sz)) >> 6): \
+ ((((unsigned long)(sz)) >> 9) <= 20) ? 91 + (((unsigned long)(sz)) >> 9): \
+ ((((unsigned long)(sz)) >> 9) <= 84) ? 110 + (((unsigned long)(sz)) >> 12): \
+ ((((unsigned long)(sz)) >> 9) <= 340) ? 119 + (((unsigned long)(sz)) >> 15): \
+ ((((unsigned long)(sz)) >> 9) <= 1364) ? 124 + (((unsigned long)(sz)) >> 18): \
+ 126)
+/*
+ bins for chunks < 512 are all spaced SMALLBIN_WIDTH bytes apart, and hold
+ identically sized chunks. This is exploited in malloc.
+*/
+
+#define MAX_SMALLBIN_SIZE 512
+#define SMALLBIN_WIDTH 8
+#define SMALLBIN_WIDTH_BITS 3
+#define MAX_SMALLBIN (MAX_SMALLBIN_SIZE / SMALLBIN_WIDTH) - 1
+
+#define smallbin_index(sz) (((unsigned long)(sz)) >> SMALLBIN_WIDTH_BITS)
+
+/*
+ Requests are `small' if both the corresponding and the next bin are small
+*/
+
+#define is_small_request(nb) (nb < MAX_SMALLBIN_SIZE - SMALLBIN_WIDTH)
+
+
+
+/*
+ To help compensate for the large number of bins, a one-level index
+ structure is used for bin-by-bin searching. `binblocks' is a
+ one-word bitvector recording whether groups of BINBLOCKWIDTH bins
+ have any (possibly) non-empty bins, so they can be skipped over
+ all at once during during traversals. The bits are NOT always
+ cleared as soon as all bins in a block are empty, but instead only
+ when all are noticed to be empty during traversal in malloc.
+*/
+
+#define BINBLOCKWIDTH 4 /* bins per block */
+
+#define binblocks (bin_at(0)->size) /* bitvector of nonempty blocks */
+
+/* bin<->block macros */
+
+#define idx2binblock(ix) ((unsigned long)1 << (ix / BINBLOCKWIDTH))
+#define mark_binblock(ii) (binblocks |= idx2binblock(ii))
+#define clear_binblock(ii) (binblocks &= ~(idx2binblock(ii)))
+
+
+
+
+
+/* Other static bookkeeping data */
+
+#ifdef SEPARATE_OBJECTS
+#define trim_threshold malloc_trim_threshold
+#define top_pad malloc_top_pad
+#define n_mmaps_max malloc_n_mmaps_max
+#define mmap_threshold malloc_mmap_threshold
+#define sbrk_base malloc_sbrk_base
+#define max_sbrked_mem malloc_max_sbrked_mem
+#define max_total_mem malloc_max_total_mem
+#define current_mallinfo malloc_current_mallinfo
+#define n_mmaps malloc_n_mmaps
+#define max_n_mmaps malloc_max_n_mmaps
+#define mmapped_mem malloc_mmapped_mem
+#define max_mmapped_mem malloc_max_mmapped_mem
+#endif
+
+/* variables holding tunable values */
+
+#ifdef DEFINE_MALLOC
+
+STATIC unsigned long trim_threshold = DEFAULT_TRIM_THRESHOLD;
+STATIC unsigned long top_pad = DEFAULT_TOP_PAD;
+#if HAVE_MMAP
+STATIC unsigned int n_mmaps_max = DEFAULT_MMAP_MAX;
+STATIC unsigned long mmap_threshold = DEFAULT_MMAP_THRESHOLD;
+#endif
+
+/* The first value returned from sbrk */
+STATIC char* sbrk_base = (char*)(-1);
+
+/* The maximum memory obtained from system via sbrk */
+STATIC unsigned long max_sbrked_mem = 0;
+
+/* The maximum via either sbrk or mmap */
+STATIC unsigned long max_total_mem = 0;
+
+/* internal working copy of mallinfo */
+STATIC struct mallinfo current_mallinfo = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+#if HAVE_MMAP
+
+/* Tracking mmaps */
+
+STATIC unsigned int n_mmaps = 0;
+STATIC unsigned int max_n_mmaps = 0;
+STATIC unsigned long mmapped_mem = 0;
+STATIC unsigned long max_mmapped_mem = 0;
+
+#endif
+
+#else /* ! DEFINE_MALLOC */
+
+extern unsigned long trim_threshold;
+extern unsigned long top_pad;
+#if HAVE_MMAP
+extern unsigned int n_mmaps_max;
+extern unsigned long mmap_threshold;
+#endif
+extern char* sbrk_base;
+extern unsigned long max_sbrked_mem;
+extern unsigned long max_total_mem;
+extern struct mallinfo current_mallinfo;
+#if HAVE_MMAP
+extern unsigned int n_mmaps;
+extern unsigned int max_n_mmaps;
+extern unsigned long mmapped_mem;
+extern unsigned long max_mmapped_mem;
+#endif
+
+#endif /* ! DEFINE_MALLOC */
+
+/* The total memory obtained from system via sbrk */
+#define sbrked_mem (current_mallinfo.arena)
+
+
+
+/*
+ Debugging support
+*/
+
+#if DEBUG
+
+
+/*
+ These routines make a number of assertions about the states
+ of data structures that should be true at all times. If any
+ are not true, it's very likely that a user program has somehow
+ trashed memory. (It's also possible that there is a coding error
+ in malloc. In which case, please report it!)
+*/
+
+#if __STD_C
+static void do_check_chunk(mchunkptr p)
+#else
+static void do_check_chunk(p) mchunkptr p;
+#endif
+{
+ INTERNAL_SIZE_T sz = p->size & ~PREV_INUSE;
+
+ /* No checkable chunk is mmapped */
+ assert(!chunk_is_mmapped(p));
+
+ /* Check for legal address ... */
+ assert((char*)p >= sbrk_base);
+ if (p != top)
+ assert((char*)p + sz <= (char*)top);
+ else
+ assert((char*)p + sz <= sbrk_base + sbrked_mem);
+
+}
+
+
+#if __STD_C
+static void do_check_free_chunk(mchunkptr p)
+#else
+static void do_check_free_chunk(p) mchunkptr p;
+#endif
+{
+ INTERNAL_SIZE_T sz = p->size & ~PREV_INUSE;
+ mchunkptr next = chunk_at_offset(p, sz);
+
+ do_check_chunk(p);
+
+ /* Check whether it claims to be free ... */
+ assert(!inuse(p));
+
+ /* Unless a special marker, must have OK fields */
+ if ((long)sz >= (long)MINSIZE)
+ {
+ assert((sz & MALLOC_ALIGN_MASK) == 0);
+ assert(aligned_OK(chunk2mem(p)));
+ /* ... matching footer field */
+ assert(next->prev_size == sz);
+ /* ... and is fully consolidated */
+ assert(prev_inuse(p));
+ assert (next == top || inuse(next));
+
+ /* ... and has minimally sane links */
+ assert(p->fd->bk == p);
+ assert(p->bk->fd == p);
+ }
+ else /* markers are always of size SIZE_SZ */
+ assert(sz == SIZE_SZ);
+}
+
+#if __STD_C
+static void do_check_inuse_chunk(mchunkptr p)
+#else
+static void do_check_inuse_chunk(p) mchunkptr p;
+#endif
+{
+ mchunkptr next = next_chunk(p);
+ do_check_chunk(p);
+
+ /* Check whether it claims to be in use ... */
+ assert(inuse(p));
+
+ /* ... and is surrounded by OK chunks.
+ Since more things can be checked with free chunks than inuse ones,
+ if an inuse chunk borders them and debug is on, it's worth doing them.
+ */
+ if (!prev_inuse(p))
+ {
+ mchunkptr prv = prev_chunk(p);
+ assert(next_chunk(prv) == p);
+ do_check_free_chunk(prv);
+ }
+ if (next == top)
+ {
+ assert(prev_inuse(next));
+ assert(chunksize(next) >= MINSIZE);
+ }
+ else if (!inuse(next))
+ do_check_free_chunk(next);
+
+}
+
+#if __STD_C
+static void do_check_malloced_chunk(mchunkptr p, INTERNAL_SIZE_T s)
+#else
+static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
+#endif
+{
+ INTERNAL_SIZE_T sz = p->size & ~PREV_INUSE;
+ long room = long_sub_size_t(sz, s);
+
+ do_check_inuse_chunk(p);
+
+ /* Legal size ... */
+ assert((long)sz >= (long)MINSIZE);
+ assert((sz & MALLOC_ALIGN_MASK) == 0);
+ assert(room >= 0);
+ assert(room < (long)MINSIZE);
+
+ /* ... and alignment */
+ assert(aligned_OK(chunk2mem(p)));
+
+
+ /* ... and was allocated at front of an available chunk */
+ assert(prev_inuse(p));
+
+}
+
+
+#define check_free_chunk(P) do_check_free_chunk(P)
+#define check_inuse_chunk(P) do_check_inuse_chunk(P)
+#define check_chunk(P) do_check_chunk(P)
+#define check_malloced_chunk(P,N) do_check_malloced_chunk(P,N)
+#else
+#define check_free_chunk(P)
+#define check_inuse_chunk(P)
+#define check_chunk(P)
+#define check_malloced_chunk(P,N)
+#endif
+
+
+
+/*
+ Macro-based internal utilities
+*/
+
+
+/*
+ Linking chunks in bin lists.
+ Call these only with variables, not arbitrary expressions, as arguments.
+*/
+
+/*
+ Place chunk p of size s in its bin, in size order,
+ putting it ahead of others of same size.
+*/
+
+
+#define frontlink(P, S, IDX, BK, FD) \
+{ \
+ if (S < MAX_SMALLBIN_SIZE) \
+ { \
+ IDX = smallbin_index(S); \
+ mark_binblock(IDX); \
+ BK = bin_at(IDX); \
+ FD = BK->fd; \
+ P->bk = BK; \
+ P->fd = FD; \
+ FD->bk = BK->fd = P; \
+ } \
+ else \
+ { \
+ IDX = bin_index(S); \
+ BK = bin_at(IDX); \
+ FD = BK->fd; \
+ if (FD == BK) mark_binblock(IDX); \
+ else \
+ { \
+ while (FD != BK && S < chunksize(FD)) FD = FD->fd; \
+ BK = FD->bk; \
+ } \
+ P->bk = BK; \
+ P->fd = FD; \
+ FD->bk = BK->fd = P; \
+ } \
+}
+
+
+/* take a chunk off a list */
+
+#define unlink(P, BK, FD) \
+{ \
+ BK = P->bk; \
+ FD = P->fd; \
+ FD->bk = BK; \
+ BK->fd = FD; \
+} \
+
+/* Place p as the last remainder */
+
+#define link_last_remainder(P) \
+{ \
+ last_remainder->fd = last_remainder->bk = P; \
+ P->fd = P->bk = last_remainder; \
+}
+
+/* Clear the last_remainder bin */
+
+#define clear_last_remainder \
+ (last_remainder->fd = last_remainder->bk = last_remainder)
+
+
+
+
+
+
+/* Routines dealing with mmap(). */
+
+#if HAVE_MMAP
+
+#ifdef DEFINE_MALLOC
+
+#if __STD_C
+static mchunkptr mmap_chunk(size_t size)
+#else
+static mchunkptr mmap_chunk(size) size_t size;
+#endif
+{
+ size_t page_mask = malloc_getpagesize - 1;
+ mchunkptr p;
+
+#ifndef MAP_ANONYMOUS
+ static int fd = -1;
+#endif
+
+ if(n_mmaps >= n_mmaps_max) return 0; /* too many regions */
+
+ /* For mmapped chunks, the overhead is one SIZE_SZ unit larger, because
+ * there is no following chunk whose prev_size field could be used.
+ */
+ size = (size + SIZE_SZ + page_mask) & ~page_mask;
+
+#ifdef MAP_ANONYMOUS
+ p = (mchunkptr)mmap(0, size, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
+#else /* !MAP_ANONYMOUS */
+ if (fd < 0)
+ {
+ fd = open("/dev/zero", O_RDWR);
+ if(fd < 0) return 0;
+ }
+ p = (mchunkptr)mmap(0, size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);
+#endif
+
+ if(p == (mchunkptr)-1) return 0;
+
+ n_mmaps++;
+ if (n_mmaps > max_n_mmaps) max_n_mmaps = n_mmaps;
+
+ /* We demand that eight bytes into a page must be 8-byte aligned. */
+ assert(aligned_OK(chunk2mem(p)));
+
+ /* The offset to the start of the mmapped region is stored
+ * in the prev_size field of the chunk; normally it is zero,
+ * but that can be changed in memalign().
+ */
+ p->prev_size = 0;
+ set_head(p, size|IS_MMAPPED);
+
+ mmapped_mem += size;
+ if ((unsigned long)mmapped_mem > (unsigned long)max_mmapped_mem)
+ max_mmapped_mem = mmapped_mem;
+ if ((unsigned long)(mmapped_mem + sbrked_mem) > (unsigned long)max_total_mem)
+ max_total_mem = mmapped_mem + sbrked_mem;
+ return p;
+}
+
+#endif /* DEFINE_MALLOC */
+
+#ifdef SEPARATE_OBJECTS
+#define munmap_chunk malloc_munmap_chunk
+#endif
+
+#ifdef DEFINE_FREE
+
+#if __STD_C
+STATIC void munmap_chunk(mchunkptr p)
+#else
+STATIC void munmap_chunk(p) mchunkptr p;
+#endif
+{
+ INTERNAL_SIZE_T size = chunksize(p);
+ int ret;
+
+ assert (chunk_is_mmapped(p));
+ assert(! ((char*)p >= sbrk_base && (char*)p < sbrk_base + sbrked_mem));
+ assert((n_mmaps > 0));
+ assert(((p->prev_size + size) & (malloc_getpagesize-1)) == 0);
+
+ n_mmaps--;
+ mmapped_mem -= (size + p->prev_size);
+
+ ret = munmap((char *)p - p->prev_size, size + p->prev_size);
+
+ /* munmap returns non-zero on failure */
+ assert(ret == 0);
+}
+
+#else /* ! DEFINE_FREE */
+
+#if __STD_C
+extern void munmap_chunk(mchunkptr);
+#else
+extern void munmap_chunk();
+#endif
+
+#endif /* ! DEFINE_FREE */
+
+#if HAVE_MREMAP
+
+#ifdef DEFINE_REALLOC
+
+#if __STD_C
+static mchunkptr mremap_chunk(mchunkptr p, size_t new_size)
+#else
+static mchunkptr mremap_chunk(p, new_size) mchunkptr p; size_t new_size;
+#endif
+{
+ size_t page_mask = malloc_getpagesize - 1;
+ INTERNAL_SIZE_T offset = p->prev_size;
+ INTERNAL_SIZE_T size = chunksize(p);
+ char *cp;
+
+ assert (chunk_is_mmapped(p));
+ assert(! ((char*)p >= sbrk_base && (char*)p < sbrk_base + sbrked_mem));
+ assert((n_mmaps > 0));
+ assert(((size + offset) & (malloc_getpagesize-1)) == 0);
+
+ /* Note the extra SIZE_SZ overhead as in mmap_chunk(). */
+ new_size = (new_size + offset + SIZE_SZ + page_mask) & ~page_mask;
+
+ cp = (char *)mremap((char *)p - offset, size + offset, new_size, 1);
+
+ if (cp == (char *)-1) return 0;
+
+ p = (mchunkptr)(cp + offset);
+
+ assert(aligned_OK(chunk2mem(p)));
+
+ assert((p->prev_size == offset));
+ set_head(p, (new_size - offset)|IS_MMAPPED);
+
+ mmapped_mem -= size + offset;
+ mmapped_mem += new_size;
+ if ((unsigned long)mmapped_mem > (unsigned long)max_mmapped_mem)
+ max_mmapped_mem = mmapped_mem;
+ if ((unsigned long)(mmapped_mem + sbrked_mem) > (unsigned long)max_total_mem)
+ max_total_mem = mmapped_mem + sbrked_mem;
+ return p;
+}
+
+#endif /* DEFINE_REALLOC */
+
+#endif /* HAVE_MREMAP */
+
+#endif /* HAVE_MMAP */
+
+
+
+
+#ifdef DEFINE_MALLOC
+
+/*
+ Extend the top-most chunk by obtaining memory from system.
+ Main interface to sbrk (but see also malloc_trim).
+*/
+
+#if __STD_C
+static void malloc_extend_top(RARG INTERNAL_SIZE_T nb)
+#else
+static void malloc_extend_top(RARG nb) RDECL INTERNAL_SIZE_T nb;
+#endif
+{
+ char* brk; /* return value from sbrk */
+ INTERNAL_SIZE_T front_misalign; /* unusable bytes at front of sbrked space */
+ INTERNAL_SIZE_T correction; /* bytes for 2nd sbrk call */
+ int correction_failed = 0; /* whether we should relax the assertion */
+ char* new_brk; /* return of 2nd sbrk call */
+ INTERNAL_SIZE_T top_size; /* new size of top chunk */
+
+ mchunkptr old_top = top; /* Record state of old top */
+ INTERNAL_SIZE_T old_top_size = chunksize(old_top);
+ char* old_end = (char*)(chunk_at_offset(old_top, old_top_size));
+
+ /* Pad request with top_pad plus minimal overhead */
+
+ INTERNAL_SIZE_T sbrk_size = nb + top_pad + MINSIZE;
+ unsigned long pagesz = malloc_getpagesize;
+
+ /* If not the first time through, round to preserve page boundary */
+ /* Otherwise, we need to correct to a page size below anyway. */
+ /* (We also correct below if an intervening foreign sbrk call.) */
+
+ if (sbrk_base != (char*)(-1))
+ sbrk_size = (sbrk_size + (pagesz - 1)) & ~(pagesz - 1);
+
+ brk = (char*)(MORECORE (sbrk_size));
+
+ /* Fail if sbrk failed or if a foreign sbrk call killed our space */
+ if (brk == (char*)(MORECORE_FAILURE) ||
+ (brk < old_end && old_top != initial_top))
+ return;
+
+ sbrked_mem += sbrk_size;
+
+ if (brk == old_end /* can just add bytes to current top, unless
+ previous correction failed */
+ && ((POINTER_UINT)old_end & (pagesz - 1)) == 0)
+ {
+ top_size = sbrk_size + old_top_size;
+ set_head(top, top_size | PREV_INUSE);
+ }
+ else
+ {
+ if (sbrk_base == (char*)(-1)) /* First time through. Record base */
+ sbrk_base = brk;
+ else /* Someone else called sbrk(). Count those bytes as sbrked_mem. */
+ sbrked_mem += brk - (char*)old_end;
+
+ /* Guarantee alignment of first new chunk made from this space */
+ front_misalign = (POINTER_UINT)chunk2mem(brk) & MALLOC_ALIGN_MASK;
+ if (front_misalign > 0)
+ {
+ correction = (MALLOC_ALIGNMENT) - front_misalign;
+ brk += correction;
+ }
+ else
+ correction = 0;
+
+ /* Guarantee the next brk will be at a page boundary */
+ correction += pagesz - ((POINTER_UINT)(brk + sbrk_size) & (pagesz - 1));
+
+ /* Allocate correction */
+ new_brk = (char*)(MORECORE (correction));
+ if (new_brk == (char*)(MORECORE_FAILURE))
+ {
+ correction = 0;
+ correction_failed = 1;
+ new_brk = brk;
+ }
+
+ sbrked_mem += correction;
+
+ top = (mchunkptr)brk;
+ top_size = new_brk - brk + correction;
+ set_head(top, top_size | PREV_INUSE);
+
+ if (old_top != initial_top)
+ {
+
+ /* There must have been an intervening foreign sbrk call. */
+ /* A double fencepost is necessary to prevent consolidation */
+
+ /* If not enough space to do this, then user did something very wrong */
+ if (old_top_size < MINSIZE)
+ {
+ set_head(top, PREV_INUSE); /* will force null return from malloc */
+ return;
+ }
+
+ /* Also keep size a multiple of MALLOC_ALIGNMENT */
+ old_top_size = (old_top_size - 3*SIZE_SZ) & ~MALLOC_ALIGN_MASK;
+ chunk_at_offset(old_top, old_top_size )->size =
+ SIZE_SZ|PREV_INUSE;
+ chunk_at_offset(old_top, old_top_size + SIZE_SZ)->size =
+ SIZE_SZ|PREV_INUSE;
+ set_head_size(old_top, old_top_size);
+ /* If possible, release the rest. */
+ if (old_top_size >= MINSIZE)
+ fREe(RCALL chunk2mem(old_top));
+ }
+ }
+
+ if ((unsigned long)sbrked_mem > (unsigned long)max_sbrked_mem)
+ max_sbrked_mem = sbrked_mem;
+#if HAVE_MMAP
+ if ((unsigned long)(mmapped_mem + sbrked_mem) > (unsigned long)max_total_mem)
+ max_total_mem = mmapped_mem + sbrked_mem;
+#else
+ if ((unsigned long)(sbrked_mem) > (unsigned long)max_total_mem)
+ max_total_mem = sbrked_mem;
+#endif
+
+ /* We always land on a page boundary */
+ assert(((unsigned long)((char*)top + top_size) & (pagesz - 1)) == 0
+ || correction_failed);
+}
+
+#endif /* DEFINE_MALLOC */
+
+
+/* Main public routines */
+
+#ifdef DEFINE_MALLOC
+
+/*
+ Malloc Algorthim:
+
+ The requested size is first converted into a usable form, `nb'.
+ This currently means to add 4 bytes overhead plus possibly more to
+ obtain 8-byte alignment and/or to obtain a size of at least
+ MINSIZE (currently 16 bytes), the smallest allocatable size.
+ (All fits are considered `exact' if they are within MINSIZE bytes.)
+
+ From there, the first successful of the following steps is taken:
+
+ 1. The bin corresponding to the request size is scanned, and if
+ a chunk of exactly the right size is found, it is taken.
+
+ 2. The most recently remaindered chunk is used if it is big
+ enough. This is a form of (roving) first fit, used only in
+ the absence of exact fits. Runs of consecutive requests use
+ the remainder of the chunk used for the previous such request
+ whenever possible. This limited use of a first-fit style
+ allocation strategy tends to give contiguous chunks
+ coextensive lifetimes, which improves locality and can reduce
+ fragmentation in the long run.
+
+ 3. Other bins are scanned in increasing size order, using a
+ chunk big enough to fulfill the request, and splitting off
+ any remainder. This search is strictly by best-fit; i.e.,
+ the smallest (with ties going to approximately the least
+ recently used) chunk that fits is selected.
+
+ 4. If large enough, the chunk bordering the end of memory
+ (`top') is split off. (This use of `top' is in accord with
+ the best-fit search rule. In effect, `top' is treated as
+ larger (and thus less well fitting) than any other available
+ chunk since it can be extended to be as large as necessary
+ (up to system limitations).
+
+ 5. If the request size meets the mmap threshold and the
+ system supports mmap, and there are few enough currently
+ allocated mmapped regions, and a call to mmap succeeds,
+ the request is allocated via direct memory mapping.
+
+ 6. Otherwise, the top of memory is extended by
+ obtaining more space from the system (normally using sbrk,
+ but definable to anything else via the MORECORE macro).
+ Memory is gathered from the system (in system page-sized
+ units) in a way that allows chunks obtained across different
+ sbrk calls to be consolidated, but does not require
+ contiguous memory. Thus, it should be safe to intersperse
+ mallocs with other sbrk calls.
+
+
+ All allocations are made from the the `lowest' part of any found
+ chunk. (The implementation invariant is that prev_inuse is
+ always true of any allocated chunk; i.e., that each allocated
+ chunk borders either a previously allocated and still in-use chunk,
+ or the base of its memory arena.)
+
+*/
+
+#if __STD_C
+Void_t* mALLOc(RARG size_t bytes)
+#else
+Void_t* mALLOc(RARG bytes) RDECL size_t bytes;
+#endif
+{
+#ifdef MALLOC_PROVIDED
+
+ return malloc (bytes); // Make sure that the pointer returned by malloc is returned back.
+
+#else
+
+ mchunkptr victim; /* inspected/selected chunk */
+ INTERNAL_SIZE_T victim_size; /* its size */
+ int idx; /* index for bin traversal */
+ mbinptr bin; /* associated bin */
+ mchunkptr remainder; /* remainder from a split */
+ long remainder_size; /* its size */
+ int remainder_index; /* its bin index */
+ unsigned long block; /* block traverser bit */
+ int startidx; /* first bin of a traversed block */
+ mchunkptr fwd; /* misc temp for linking */
+ mchunkptr bck; /* misc temp for linking */
+ mbinptr q; /* misc temp */
+
+ INTERNAL_SIZE_T nb = request2size(bytes); /* padded request size; */
+
+ /* Check for overflow and just fail, if so. */
+ if (nb > INT_MAX || nb < bytes)
+ {
+ RERRNO = ENOMEM;
+ return 0;
+ }
+
+ MALLOC_LOCK;
+
+ /* Check for exact match in a bin */
+
+ if (is_small_request(nb)) /* Faster version for small requests */
+ {
+ idx = smallbin_index(nb);
+
+ /* No traversal or size check necessary for small bins. */
+
+ q = bin_at(idx);
+ victim = last(q);
+
+#if MALLOC_ALIGN != 16
+ /* Also scan the next one, since it would have a remainder < MINSIZE */
+ if (victim == q)
+ {
+ q = next_bin(q);
+ victim = last(q);
+ }
+#endif
+ if (victim != q)
+ {
+ victim_size = chunksize(victim);
+ unlink(victim, bck, fwd);
+ set_inuse_bit_at_offset(victim, victim_size);
+ check_malloced_chunk(victim, nb);
+ MALLOC_UNLOCK;
+ return chunk2mem(victim);
+ }
+
+ idx += 2; /* Set for bin scan below. We've already scanned 2 bins. */
+
+ }
+ else
+ {
+ idx = bin_index(nb);
+ bin = bin_at(idx);
+
+ for (victim = last(bin); victim != bin; victim = victim->bk)
+ {
+ victim_size = chunksize(victim);
+ remainder_size = long_sub_size_t(victim_size, nb);
+
+ if (remainder_size >= (long)MINSIZE) /* too big */
+ {
+ --idx; /* adjust to rescan below after checking last remainder */
+ break;
+ }
+
+ else if (remainder_size >= 0) /* exact fit */
+ {
+ unlink(victim, bck, fwd);
+ set_inuse_bit_at_offset(victim, victim_size);
+ check_malloced_chunk(victim, nb);
+ MALLOC_UNLOCK;
+ return chunk2mem(victim);
+ }
+ }
+
+ ++idx;
+
+ }
+
+ /* Try to use the last split-off remainder */
+
+ if ( (victim = last_remainder->fd) != last_remainder)
+ {
+ victim_size = chunksize(victim);
+ remainder_size = long_sub_size_t(victim_size, nb);
+
+ if (remainder_size >= (long)MINSIZE) /* re-split */
+ {
+ remainder = chunk_at_offset(victim, nb);
+ set_head(victim, nb | PREV_INUSE);
+ link_last_remainder(remainder);
+ set_head(remainder, remainder_size | PREV_INUSE);
+ set_foot(remainder, remainder_size);
+ check_malloced_chunk(victim, nb);
+ MALLOC_UNLOCK;
+ return chunk2mem(victim);
+ }
+
+ clear_last_remainder;
+
+ if (remainder_size >= 0) /* exhaust */
+ {
+ set_inuse_bit_at_offset(victim, victim_size);
+ check_malloced_chunk(victim, nb);
+ MALLOC_UNLOCK;
+ return chunk2mem(victim);
+ }
+
+ /* Else place in bin */
+
+ frontlink(victim, victim_size, remainder_index, bck, fwd);
+ }
+
+ /*
+ If there are any possibly nonempty big-enough blocks,
+ search for best fitting chunk by scanning bins in blockwidth units.
+ */
+
+ if ( (block = idx2binblock(idx)) <= binblocks)
+ {
+
+ /* Get to the first marked block */
+
+ if ( (block & binblocks) == 0)
+ {
+ /* force to an even block boundary */
+ idx = (idx & ~(BINBLOCKWIDTH - 1)) + BINBLOCKWIDTH;
+ block <<= 1;
+ while ((block & binblocks) == 0)
+ {
+ idx += BINBLOCKWIDTH;
+ block <<= 1;
+ }
+ }
+
+ /* For each possibly nonempty block ... */
+ for (;;)
+ {
+ startidx = idx; /* (track incomplete blocks) */
+ q = bin = bin_at(idx);
+
+ /* For each bin in this block ... */
+ do
+ {
+ /* Find and use first big enough chunk ... */
+
+ for (victim = last(bin); victim != bin; victim = victim->bk)
+ {
+ victim_size = chunksize(victim);
+ remainder_size = long_sub_size_t(victim_size, nb);
+
+ if (remainder_size >= (long)MINSIZE) /* split */
+ {
+ remainder = chunk_at_offset(victim, nb);
+ set_head(victim, nb | PREV_INUSE);
+ unlink(victim, bck, fwd);
+ link_last_remainder(remainder);
+ set_head(remainder, remainder_size | PREV_INUSE);
+ set_foot(remainder, remainder_size);
+ check_malloced_chunk(victim, nb);
+ MALLOC_UNLOCK;
+ return chunk2mem(victim);
+ }
+
+ else if (remainder_size >= 0) /* take */
+ {
+ set_inuse_bit_at_offset(victim, victim_size);
+ unlink(victim, bck, fwd);
+ check_malloced_chunk(victim, nb);
+ MALLOC_UNLOCK;
+ return chunk2mem(victim);
+ }
+
+ }
+
+ bin = next_bin(bin);
+
+#if MALLOC_ALIGN == 16
+ if (idx < MAX_SMALLBIN)
+ {
+ bin = next_bin(bin);
+ ++idx;
+ }
+#endif
+ } while ((++idx & (BINBLOCKWIDTH - 1)) != 0);
+
+ /* Clear out the block bit. */
+
+ do /* Possibly backtrack to try to clear a partial block */
+ {
+ if ((startidx & (BINBLOCKWIDTH - 1)) == 0)
+ {
+ binblocks &= ~block;
+ break;
+ }
+ --startidx;
+ q = prev_bin(q);
+ } while (first(q) == q);
+
+ /* Get to the next possibly nonempty block */
+
+ if ( (block <<= 1) <= binblocks && (block != 0) )
+ {
+ while ((block & binblocks) == 0)
+ {
+ idx += BINBLOCKWIDTH;
+ block <<= 1;
+ }
+ }
+ else
+ break;
+ }
+ }
+
+
+ /* Try to use top chunk */
+
+ /* Require that there be a remainder, ensuring top always exists */
+ remainder_size = long_sub_size_t(chunksize(top), nb);
+ if (chunksize(top) < nb || remainder_size < (long)MINSIZE)
+ {
+
+#if HAVE_MMAP
+ /* If big and would otherwise need to extend, try to use mmap instead */
+ if ((unsigned long)nb >= (unsigned long)mmap_threshold &&
+ (victim = mmap_chunk(nb)) != 0)
+ {
+ MALLOC_UNLOCK;
+ return chunk2mem(victim);
+ }
+#endif
+
+ /* Try to extend */
+ malloc_extend_top(RCALL nb);
+ remainder_size = long_sub_size_t(chunksize(top), nb);
+ if (chunksize(top) < nb || remainder_size < (long)MINSIZE)
+ {
+ MALLOC_UNLOCK;
+ return 0; /* propagate failure */
+ }
+ }
+
+ victim = top;
+ set_head(victim, nb | PREV_INUSE);
+ top = chunk_at_offset(victim, nb);
+ set_head(top, remainder_size | PREV_INUSE);
+ check_malloced_chunk(victim, nb);
+ MALLOC_UNLOCK;
+ return chunk2mem(victim);
+
+#endif /* MALLOC_PROVIDED */
+}
+
+#endif /* DEFINE_MALLOC */
+
+#ifdef DEFINE_FREE
+
+/*
+
+ free() algorithm :
+
+ cases:
+
+ 1. free(0) has no effect.
+
+ 2. If the chunk was allocated via mmap, it is release via munmap().
+
+ 3. If a returned chunk borders the current high end of memory,
+ it is consolidated into the top, and if the total unused
+ topmost memory exceeds the trim threshold, malloc_trim is
+ called.
+
+ 4. Other chunks are consolidated as they arrive, and
+ placed in corresponding bins. (This includes the case of
+ consolidating with the current `last_remainder').
+
+*/
+
+
+#if __STD_C
+void fREe(RARG Void_t* mem)
+#else
+void fREe(RARG mem) RDECL Void_t* mem;
+#endif
+{
+#ifdef MALLOC_PROVIDED
+
+ free (mem);
+
+#else
+
+ mchunkptr p; /* chunk corresponding to mem */
+ INTERNAL_SIZE_T hd; /* its head field */
+ INTERNAL_SIZE_T sz; /* its size */
+ int idx; /* its bin index */
+ mchunkptr next; /* next contiguous chunk */
+ INTERNAL_SIZE_T nextsz; /* its size */
+ INTERNAL_SIZE_T prevsz; /* size of previous contiguous chunk */
+ mchunkptr bck; /* misc temp for linking */
+ mchunkptr fwd; /* misc temp for linking */
+ int islr; /* track whether merging with last_remainder */
+
+ if (mem == 0) /* free(0) has no effect */
+ return;
+
+ MALLOC_LOCK;
+
+ p = mem2chunk(mem);
+ hd = p->size;
+
+#if HAVE_MMAP
+ if (hd & IS_MMAPPED) /* release mmapped memory. */
+ {
+ munmap_chunk(p);
+ MALLOC_UNLOCK;
+ return;
+ }
+#endif
+
+ check_inuse_chunk(p);
+
+ sz = hd & ~PREV_INUSE;
+ next = chunk_at_offset(p, sz);
+ nextsz = chunksize(next);
+
+ if (next == top) /* merge with top */
+ {
+ sz += nextsz;
+
+ if (!(hd & PREV_INUSE)) /* consolidate backward */
+ {
+ prevsz = p->prev_size;
+ p = chunk_at_offset(p, -prevsz);
+ sz += prevsz;
+ unlink(p, bck, fwd);
+ }
+
+ set_head(p, sz | PREV_INUSE);
+ top = p;
+ if ((unsigned long)(sz) >= (unsigned long)trim_threshold)
+ malloc_trim(RCALL top_pad);
+ MALLOC_UNLOCK;
+ return;
+ }
+
+ set_head(next, nextsz); /* clear inuse bit */
+
+ islr = 0;
+
+ if (!(hd & PREV_INUSE)) /* consolidate backward */
+ {
+ prevsz = p->prev_size;
+ p = chunk_at_offset(p, -prevsz);
+ sz += prevsz;
+
+ if (p->fd == last_remainder) /* keep as last_remainder */
+ islr = 1;
+ else
+ unlink(p, bck, fwd);
+ }
+
+ if (!(inuse_bit_at_offset(next, nextsz))) /* consolidate forward */
+ {
+ sz += nextsz;
+
+ if (!islr && next->fd == last_remainder) /* re-insert last_remainder */
+ {
+ islr = 1;
+ link_last_remainder(p);
+ }
+ else
+ unlink(next, bck, fwd);
+ }
+
+
+ set_head(p, sz | PREV_INUSE);
+ set_foot(p, sz);
+ if (!islr)
+ frontlink(p, sz, idx, bck, fwd);
+
+ MALLOC_UNLOCK;
+
+#endif /* MALLOC_PROVIDED */
+}
+
+#endif /* DEFINE_FREE */
+
+#ifdef DEFINE_REALLOC
+
+/*
+
+ Realloc algorithm:
+
+ Chunks that were obtained via mmap cannot be extended or shrunk
+ unless HAVE_MREMAP is defined, in which case mremap is used.
+ Otherwise, if their reallocation is for additional space, they are
+ copied. If for less, they are just left alone.
+
+ Otherwise, if the reallocation is for additional space, and the
+ chunk can be extended, it is, else a malloc-copy-free sequence is
+ taken. There are several different ways that a chunk could be
+ extended. All are tried:
+
+ * Extending forward into following adjacent free chunk.
+ * Shifting backwards, joining preceding adjacent space
+ * Both shifting backwards and extending forward.
+ * Extending into newly sbrked space
+
+ Unless the #define REALLOC_ZERO_BYTES_FREES is set, realloc with a
+ size argument of zero (re)allocates a minimum-sized chunk.
+
+ If the reallocation is for less space, and the new request is for
+ a `small' (<512 bytes) size, then the newly unused space is lopped
+ off and freed.
+
+ The old unix realloc convention of allowing the last-free'd chunk
+ to be used as an argument to realloc is no longer supported.
+ I don't know of any programs still relying on this feature,
+ and allowing it would also allow too many other incorrect
+ usages of realloc to be sensible.
+
+
+*/
+
+
+#if __STD_C
+Void_t* rEALLOc(RARG Void_t* oldmem, size_t bytes)
+#else
+Void_t* rEALLOc(RARG oldmem, bytes) RDECL Void_t* oldmem; size_t bytes;
+#endif
+{
+#ifdef MALLOC_PROVIDED
+
+ realloc (oldmem, bytes);
+
+#else
+
+ INTERNAL_SIZE_T nb; /* padded request size */
+
+ mchunkptr oldp; /* chunk corresponding to oldmem */
+ INTERNAL_SIZE_T oldsize; /* its size */
+
+ mchunkptr newp; /* chunk to return */
+ INTERNAL_SIZE_T newsize; /* its size */
+ Void_t* newmem; /* corresponding user mem */
+
+ mchunkptr next; /* next contiguous chunk after oldp */
+ INTERNAL_SIZE_T nextsize; /* its size */
+
+ mchunkptr prev; /* previous contiguous chunk before oldp */
+ INTERNAL_SIZE_T prevsize; /* its size */
+
+ mchunkptr remainder; /* holds split off extra space from newp */
+ INTERNAL_SIZE_T remainder_size; /* its size */
+
+ mchunkptr bck; /* misc temp for linking */
+ mchunkptr fwd; /* misc temp for linking */
+
+#ifdef REALLOC_ZERO_BYTES_FREES
+ if (bytes == 0) { fREe(RCALL oldmem); return 0; }
+#endif
+
+
+ /* realloc of null is supposed to be same as malloc */
+ if (oldmem == 0) return mALLOc(RCALL bytes);
+
+ MALLOC_LOCK;
+
+ newp = oldp = mem2chunk(oldmem);
+ newsize = oldsize = chunksize(oldp);
+
+
+ nb = request2size(bytes);
+
+ /* Check for overflow and just fail, if so. */
+ if (nb > INT_MAX || nb < bytes)
+ {
+ RERRNO = ENOMEM;
+ return 0;
+ }
+
+#if HAVE_MMAP
+ if (chunk_is_mmapped(oldp))
+ {
+#if HAVE_MREMAP
+ newp = mremap_chunk(oldp, nb);
+ if(newp)
+ {
+ MALLOC_UNLOCK;
+ return chunk2mem(newp);
+ }
+#endif
+ /* Note the extra SIZE_SZ overhead. */
+ if(oldsize - SIZE_SZ >= nb)
+ {
+ MALLOC_UNLOCK;
+ return oldmem; /* do nothing */
+ }
+ /* Must alloc, copy, free. */
+ newmem = mALLOc(RCALL bytes);
+ if (newmem == 0)
+ {
+ MALLOC_UNLOCK;
+ return 0; /* propagate failure */
+ }
+ MALLOC_COPY(newmem, oldmem, oldsize - 2*SIZE_SZ);
+ munmap_chunk(oldp);
+ MALLOC_UNLOCK;
+ return newmem;
+ }
+#endif
+
+ check_inuse_chunk(oldp);
+
+ if ((long)(oldsize) < (long)(nb))
+ {
+
+ /* Try expanding forward */
+
+ next = chunk_at_offset(oldp, oldsize);
+ if (next == top || !inuse(next))
+ {
+ nextsize = chunksize(next);
+
+ /* Forward into top only if a remainder */
+ if (next == top)
+ {
+ if ((long)(nextsize + newsize) >= (long)(nb + MINSIZE))
+ {
+ newsize += nextsize;
+ top = chunk_at_offset(oldp, nb);
+ set_head(top, (newsize - nb) | PREV_INUSE);
+ set_head_size(oldp, nb);
+ MALLOC_UNLOCK;
+ return chunk2mem(oldp);
+ }
+ }
+
+ /* Forward into next chunk */
+ else if (((long)(nextsize + newsize) >= (long)(nb)))
+ {
+ unlink(next, bck, fwd);
+ newsize += nextsize;
+ goto split;
+ }
+ }
+ else
+ {
+ next = 0;
+ nextsize = 0;
+ }
+
+ /* Try shifting backwards. */
+
+ if (!prev_inuse(oldp))
+ {
+ prev = prev_chunk(oldp);
+ prevsize = chunksize(prev);
+
+ /* try forward + backward first to save a later consolidation */
+
+ if (next != 0)
+ {
+ /* into top */
+ if (next == top)
+ {
+ if ((long)(nextsize + prevsize + newsize) >= (long)(nb + MINSIZE))
+ {
+ unlink(prev, bck, fwd);
+ newp = prev;
+ newsize += prevsize + nextsize;
+ newmem = chunk2mem(newp);
+ MALLOC_COPY(newmem, oldmem, oldsize - SIZE_SZ);
+ top = chunk_at_offset(newp, nb);
+ set_head(top, (newsize - nb) | PREV_INUSE);
+ set_head_size(newp, nb);
+ MALLOC_UNLOCK;
+ return newmem;
+ }
+ }
+
+ /* into next chunk */
+ else if (((long)(nextsize + prevsize + newsize) >= (long)(nb)))
+ {
+ unlink(next, bck, fwd);
+ unlink(prev, bck, fwd);
+ newp = prev;
+ newsize += nextsize + prevsize;
+ newmem = chunk2mem(newp);
+ MALLOC_COPY(newmem, oldmem, oldsize - SIZE_SZ);
+ goto split;
+ }
+ }
+
+ /* backward only */
+ if (prev != 0 && (long)(prevsize + newsize) >= (long)nb)
+ {
+ unlink(prev, bck, fwd);
+ newp = prev;
+ newsize += prevsize;
+ newmem = chunk2mem(newp);
+ MALLOC_COPY(newmem, oldmem, oldsize - SIZE_SZ);
+ goto split;
+ }
+ }
+
+ /* Must allocate */
+
+ newmem = mALLOc (RCALL bytes);
+
+ if (newmem == 0) /* propagate failure */
+ {
+ MALLOC_UNLOCK;
+ return 0;
+ }
+
+ /* Avoid copy if newp is next chunk after oldp. */
+ /* (This can only happen when new chunk is sbrk'ed.) */
+
+ if ( (newp = mem2chunk(newmem)) == next_chunk(oldp))
+ {
+ newsize += chunksize(newp);
+ newp = oldp;
+ goto split;
+ }
+
+ /* Otherwise copy, free, and exit */
+ MALLOC_COPY(newmem, oldmem, oldsize - SIZE_SZ);
+ fREe(RCALL oldmem);
+ MALLOC_UNLOCK;
+ return newmem;
+ }
+
+
+ split: /* split off extra room in old or expanded chunk */
+
+ remainder_size = long_sub_size_t(newsize, nb);
+
+ if (remainder_size >= (long)MINSIZE) /* split off remainder */
+ {
+ remainder = chunk_at_offset(newp, nb);
+ set_head_size(newp, nb);
+ set_head(remainder, remainder_size | PREV_INUSE);
+ set_inuse_bit_at_offset(remainder, remainder_size);
+ fREe(RCALL chunk2mem(remainder)); /* let free() deal with it */
+ }
+ else
+ {
+ set_head_size(newp, newsize);
+ set_inuse_bit_at_offset(newp, newsize);
+ }
+
+ check_inuse_chunk(newp);
+ MALLOC_UNLOCK;
+ return chunk2mem(newp);
+
+#endif /* MALLOC_PROVIDED */
+}
+
+#endif /* DEFINE_REALLOC */
+
+#ifdef DEFINE_MEMALIGN
+
+/*
+
+ memalign algorithm:
+
+ memalign requests more than enough space from malloc, finds a spot
+ within that chunk that meets the alignment request, and then
+ possibly frees the leading and trailing space.
+
+ The alignment argument must be a power of two. This property is not
+ checked by memalign, so misuse may result in random runtime errors.
+
+ 8-byte alignment is guaranteed by normal malloc calls, so don't
+ bother calling memalign with an argument of 8 or less.
+
+ Overreliance on memalign is a sure way to fragment space.
+
+*/
+
+
+#if __STD_C
+Void_t* mEMALIGn(RARG size_t alignment, size_t bytes)
+#else
+Void_t* mEMALIGn(RARG alignment, bytes) RDECL size_t alignment; size_t bytes;
+#endif
+{
+ INTERNAL_SIZE_T nb; /* padded request size */
+ char* m; /* memory returned by malloc call */
+ mchunkptr p; /* corresponding chunk */
+ char* brk; /* alignment point within p */
+ mchunkptr newp; /* chunk to return */
+ INTERNAL_SIZE_T newsize; /* its size */
+ INTERNAL_SIZE_T leadsize; /* leading space befor alignment point */
+ mchunkptr remainder; /* spare room at end to split off */
+ long remainder_size; /* its size */
+
+ /* If need less alignment than we give anyway, just relay to malloc */
+
+ if (alignment <= MALLOC_ALIGNMENT) return mALLOc(RCALL bytes);
+
+ /* Otherwise, ensure that it is at least a minimum chunk size */
+
+ if (alignment < MINSIZE) alignment = MINSIZE;
+
+ /* Call malloc with worst case padding to hit alignment. */
+
+ nb = request2size(bytes);
+
+ /* Check for overflow. */
+ if (nb > INT_MAX || nb < bytes)
+ {
+ RERRNO = ENOMEM;
+ return 0;
+ }
+
+ m = (char*)(mALLOc(RCALL nb + alignment + MINSIZE));
+
+ if (m == 0) return 0; /* propagate failure */
+
+ MALLOC_LOCK;
+
+ p = mem2chunk(m);
+
+ if ((((unsigned long)(m)) % alignment) == 0) /* aligned */
+ {
+#if HAVE_MMAP
+ if(chunk_is_mmapped(p))
+ {
+ MALLOC_UNLOCK;
+ return chunk2mem(p); /* nothing more to do */
+ }
+#endif
+ }
+ else /* misaligned */
+ {
+ /*
+ Find an aligned spot inside chunk.
+ Since we need to give back leading space in a chunk of at
+ least MINSIZE, if the first calculation places us at
+ a spot with less than MINSIZE leader, we can move to the
+ next aligned spot -- we've allocated enough total room so that
+ this is always possible.
+ */
+
+ brk = (char*)mem2chunk(((unsigned long)(m + alignment - 1)) & -alignment);
+ if ((long)(brk - (char*)(p)) < (long)MINSIZE) brk = brk + alignment;
+
+ newp = (mchunkptr)brk;
+ leadsize = brk - (char*)(p);
+ newsize = chunksize(p) - leadsize;
+
+#if HAVE_MMAP
+ if(chunk_is_mmapped(p))
+ {
+ newp->prev_size = p->prev_size + leadsize;
+ set_head(newp, newsize|IS_MMAPPED);
+ MALLOC_UNLOCK;
+ return chunk2mem(newp);
+ }
+#endif
+
+ /* give back leader, use the rest */
+
+ set_head(newp, newsize | PREV_INUSE);
+ set_inuse_bit_at_offset(newp, newsize);
+ set_head_size(p, leadsize);
+ fREe(RCALL chunk2mem(p));
+ p = newp;
+
+ assert (newsize >= nb && (((unsigned long)(chunk2mem(p))) % alignment) == 0);
+ }
+
+ /* Also give back spare room at the end */
+
+ remainder_size = long_sub_size_t(chunksize(p), nb);
+
+ if (remainder_size >= (long)MINSIZE)
+ {
+ remainder = chunk_at_offset(p, nb);
+ set_head(remainder, remainder_size | PREV_INUSE);
+ set_head_size(p, nb);
+ fREe(RCALL chunk2mem(remainder));
+ }
+
+ check_inuse_chunk(p);
+ MALLOC_UNLOCK;
+ return chunk2mem(p);
+
+}
+
+#endif /* DEFINE_MEMALIGN */
+
+#ifdef DEFINE_VALLOC
+
+/*
+ valloc just invokes memalign with alignment argument equal
+ to the page size of the system (or as near to this as can
+ be figured out from all the includes/defines above.)
+*/
+
+#if __STD_C
+Void_t* vALLOc(RARG size_t bytes)
+#else
+Void_t* vALLOc(RARG bytes) RDECL size_t bytes;
+#endif
+{
+ return mEMALIGn (RCALL malloc_getpagesize, bytes);
+}
+
+#endif /* DEFINE_VALLOC */
+
+#ifdef DEFINE_PVALLOC
+
+/*
+ pvalloc just invokes valloc for the nearest pagesize
+ that will accommodate request
+*/
+
+
+#if __STD_C
+Void_t* pvALLOc(RARG size_t bytes)
+#else
+Void_t* pvALLOc(RARG bytes) RDECL size_t bytes;
+#endif
+{
+ size_t pagesize = malloc_getpagesize;
+ return mEMALIGn (RCALL pagesize, (bytes + pagesize - 1) & ~(pagesize - 1));
+}
+
+#endif /* DEFINE_PVALLOC */
+
+#ifdef DEFINE_CALLOC
+
+/*
+
+ calloc calls malloc, then zeroes out the allocated chunk.
+
+*/
+
+#if __STD_C
+Void_t* cALLOc(RARG size_t n, size_t elem_size)
+#else
+Void_t* cALLOc(RARG n, elem_size) RDECL size_t n; size_t elem_size;
+#endif
+{
+ mchunkptr p;
+ INTERNAL_SIZE_T csz;
+
+ INTERNAL_SIZE_T sz = n * elem_size;
+
+#if MORECORE_CLEARS
+ mchunkptr oldtop;
+ INTERNAL_SIZE_T oldtopsize;
+#endif
+ Void_t* mem;
+
+ /* check if expand_top called, in which case don't need to clear */
+#if MORECORE_CLEARS
+ MALLOC_LOCK;
+ oldtop = top;
+ oldtopsize = chunksize(top);
+#endif
+
+ mem = mALLOc (RCALL sz);
+
+ if (mem == 0)
+ {
+#if MORECORE_CLEARS
+ MALLOC_UNLOCK;
+#endif
+ return 0;
+ }
+ else
+ {
+ p = mem2chunk(mem);
+
+ /* Two optional cases in which clearing not necessary */
+
+
+#if HAVE_MMAP
+ if (chunk_is_mmapped(p))
+ {
+#if MORECORE_CLEARS
+ MALLOC_UNLOCK;
+#endif
+ return mem;
+ }
+#endif
+
+ csz = chunksize(p);
+
+#if MORECORE_CLEARS
+ if (p == oldtop && csz > oldtopsize)
+ {
+ /* clear only the bytes from non-freshly-sbrked memory */
+ csz = oldtopsize;
+ }
+ MALLOC_UNLOCK;
+#endif
+
+ MALLOC_ZERO(mem, csz - SIZE_SZ);
+ return mem;
+ }
+}
+
+#endif /* DEFINE_CALLOC */
+
+#if defined(DEFINE_CFREE) && !defined(__CYGWIN__)
+
+/*
+
+ cfree just calls free. It is needed/defined on some systems
+ that pair it with calloc, presumably for odd historical reasons.
+
+*/
+
+#if !defined(INTERNAL_LINUX_C_LIB) || !defined(__ELF__)
+#if !defined(INTERNAL_NEWLIB) || !defined(_REENT_ONLY)
+#if __STD_C
+void cfree(Void_t *mem)
+#else
+void cfree(mem) Void_t *mem;
+#endif
+{
+#ifdef INTERNAL_NEWLIB
+ fREe(_REENT, mem);
+#else
+ fREe(mem);
+#endif
+}
+#endif
+#endif
+
+#endif /* DEFINE_CFREE */
+
+#ifdef DEFINE_FREE
+
+/*
+
+ Malloc_trim gives memory back to the system (via negative
+ arguments to sbrk) if there is unused memory at the `high' end of
+ the malloc pool. You can call this after freeing large blocks of
+ memory to potentially reduce the system-level memory requirements
+ of a program. However, it cannot guarantee to reduce memory. Under
+ some allocation patterns, some large free blocks of memory will be
+ locked between two used chunks, so they cannot be given back to
+ the system.
+
+ The `pad' argument to malloc_trim represents the amount of free
+ trailing space to leave untrimmed. If this argument is zero,
+ only the minimum amount of memory to maintain internal data
+ structures will be left (one page or less). Non-zero arguments
+ can be supplied to maintain enough trailing space to service
+ future expected allocations without having to re-obtain memory
+ from the system.
+
+ Malloc_trim returns 1 if it actually released any memory, else 0.
+
+*/
+
+#if __STD_C
+int malloc_trim(RARG size_t pad)
+#else
+int malloc_trim(RARG pad) RDECL size_t pad;
+#endif
+{
+ long top_size; /* Amount of top-most memory */
+ long extra; /* Amount to release */
+ char* current_brk; /* address returned by pre-check sbrk call */
+ char* new_brk; /* address returned by negative sbrk call */
+
+ unsigned long pagesz = malloc_getpagesize;
+
+ MALLOC_LOCK;
+
+ top_size = chunksize(top);
+ extra = ((top_size - pad - MINSIZE + (pagesz-1)) / pagesz - 1) * pagesz;
+
+ if (extra < (long)pagesz) /* Not enough memory to release */
+ {
+ MALLOC_UNLOCK;
+ return 0;
+ }
+
+ else
+ {
+ /* Test to make sure no one else called sbrk */
+ current_brk = (char*)(MORECORE (0));
+ if (current_brk != (char*)(top) + top_size)
+ {
+ MALLOC_UNLOCK;
+ return 0; /* Apparently we don't own memory; must fail */
+ }
+
+ else
+ {
+ new_brk = (char*)(MORECORE (-extra));
+
+ if (new_brk == (char*)(MORECORE_FAILURE)) /* sbrk failed? */
+ {
+ /* Try to figure out what we have */
+ current_brk = (char*)(MORECORE (0));
+ top_size = current_brk - (char*)top;
+ if (top_size >= (long)MINSIZE) /* if not, we are very very dead! */
+ {
+ sbrked_mem = current_brk - sbrk_base;
+ set_head(top, top_size | PREV_INUSE);
+ }
+ check_chunk(top);
+ MALLOC_UNLOCK;
+ return 0;
+ }
+
+ else
+ {
+ /* Success. Adjust top accordingly. */
+ set_head(top, (top_size - extra) | PREV_INUSE);
+ sbrked_mem -= extra;
+ check_chunk(top);
+ MALLOC_UNLOCK;
+ return 1;
+ }
+ }
+ }
+}
+
+#endif /* DEFINE_FREE */
+
+#ifdef DEFINE_MALLOC_USABLE_SIZE
+
+/*
+ malloc_usable_size:
+
+ This routine tells you how many bytes you can actually use in an
+ allocated chunk, which may be more than you requested (although
+ often not). You can use this many bytes without worrying about
+ overwriting other allocated objects. Not a particularly great
+ programming practice, but still sometimes useful.
+
+*/
+
+#if __STD_C
+size_t malloc_usable_size(RARG Void_t* mem)
+#else
+size_t malloc_usable_size(RARG mem) RDECL Void_t* mem;
+#endif
+{
+ mchunkptr p;
+ if (mem == 0)
+ return 0;
+ else
+ {
+ p = mem2chunk(mem);
+ if(!chunk_is_mmapped(p))
+ {
+ if (!inuse(p)) return 0;
+#if DEBUG
+ MALLOC_LOCK;
+ check_inuse_chunk(p);
+ MALLOC_UNLOCK;
+#endif
+ return chunksize(p) - SIZE_SZ;
+ }
+ return chunksize(p) - 2*SIZE_SZ;
+ }
+}
+
+#endif /* DEFINE_MALLOC_USABLE_SIZE */
+
+#ifdef DEFINE_MALLINFO
+
+/* Utility to update current_mallinfo for malloc_stats and mallinfo() */
+
+STATIC void malloc_update_mallinfo()
+{
+ int i;
+ mbinptr b;
+ mchunkptr p;
+#if DEBUG
+ mchunkptr q;
+#endif
+
+ INTERNAL_SIZE_T avail = chunksize(top);
+ int navail = ((long)(avail) >= (long)MINSIZE)? 1 : 0;
+
+ for (i = 1; i < NAV; ++i)
+ {
+ b = bin_at(i);
+ for (p = last(b); p != b; p = p->bk)
+ {
+#if DEBUG
+ check_free_chunk(p);
+ for (q = next_chunk(p);
+ q < top && inuse(q) && (long)(chunksize(q)) >= (long)MINSIZE;
+ q = next_chunk(q))
+ check_inuse_chunk(q);
+#endif
+ avail += chunksize(p);
+ navail++;
+ }
+ }
+
+ current_mallinfo.ordblks = navail;
+ current_mallinfo.uordblks = sbrked_mem - avail;
+ current_mallinfo.fordblks = avail;
+#if HAVE_MMAP
+ current_mallinfo.hblks = n_mmaps;
+ current_mallinfo.hblkhd = mmapped_mem;
+#endif
+ current_mallinfo.keepcost = chunksize(top);
+
+}
+
+#else /* ! DEFINE_MALLINFO */
+
+#if __STD_C
+extern void malloc_update_mallinfo(void);
+#else
+extern void malloc_update_mallinfo();
+#endif
+
+#endif /* ! DEFINE_MALLINFO */
+
+#ifdef DEFINE_MALLOC_STATS
+
+/*
+
+ malloc_stats:
+
+ Prints on stderr the amount of space obtain from the system (both
+ via sbrk and mmap), the maximum amount (which may be more than
+ current if malloc_trim and/or munmap got called), the maximum
+ number of simultaneous mmap regions used, and the current number
+ of bytes allocated via malloc (or realloc, etc) but not yet
+ freed. (Note that this is the number of bytes allocated, not the
+ number requested. It will be larger than the number requested
+ because of alignment and bookkeeping overhead.)
+
+*/
+
+#if __STD_C
+void malloc_stats(RONEARG)
+#else
+void malloc_stats(RONEARG) RDECL
+#endif
+{
+ unsigned long local_max_total_mem;
+ int local_sbrked_mem;
+ struct mallinfo local_mallinfo;
+#if HAVE_MMAP
+ unsigned long local_mmapped_mem, local_max_n_mmaps;
+#endif
+ FILE *fp;
+
+ MALLOC_LOCK;
+ malloc_update_mallinfo();
+ local_max_total_mem = max_total_mem;
+ local_sbrked_mem = sbrked_mem;
+ local_mallinfo = current_mallinfo;
+#if HAVE_MMAP
+ local_mmapped_mem = mmapped_mem;
+ local_max_n_mmaps = max_n_mmaps;
+#endif
+ MALLOC_UNLOCK;
+
+#ifdef INTERNAL_NEWLIB
+ _REENT_SMALL_CHECK_INIT(reent_ptr);
+ fp = _stderr_r(reent_ptr);
+#define fprintf fiprintf
+#else
+ fp = stderr;
+#endif
+
+ fprintf(fp, "max system bytes = %10u\n",
+ (unsigned int)(local_max_total_mem));
+#if HAVE_MMAP
+ fprintf(fp, "system bytes = %10u\n",
+ (unsigned int)(local_sbrked_mem + local_mmapped_mem));
+ fprintf(fp, "in use bytes = %10u\n",
+ (unsigned int)(local_mallinfo.uordblks + local_mmapped_mem));
+#else
+ fprintf(fp, "system bytes = %10u\n",
+ (unsigned int)local_sbrked_mem);
+ fprintf(fp, "in use bytes = %10u\n",
+ (unsigned int)local_mallinfo.uordblks);
+#endif
+#if HAVE_MMAP
+ fprintf(fp, "max mmap regions = %10u\n",
+ (unsigned int)local_max_n_mmaps);
+#endif
+}
+
+#endif /* DEFINE_MALLOC_STATS */
+
+#ifdef DEFINE_MALLINFO
+
+/*
+ mallinfo returns a copy of updated current mallinfo.
+*/
+
+#if __STD_C
+struct mallinfo mALLINFo(RONEARG)
+#else
+struct mallinfo mALLINFo(RONEARG) RDECL
+#endif
+{
+ struct mallinfo ret;
+
+ MALLOC_LOCK;
+ malloc_update_mallinfo();
+ ret = current_mallinfo;
+ MALLOC_UNLOCK;
+ return ret;
+}
+
+#endif /* DEFINE_MALLINFO */
+
+#ifdef DEFINE_MALLOPT
+
+/*
+ mallopt:
+
+ mallopt is the general SVID/XPG interface to tunable parameters.
+ The format is to provide a (parameter-number, parameter-value) pair.
+ mallopt then sets the corresponding parameter to the argument
+ value if it can (i.e., so long as the value is meaningful),
+ and returns 1 if successful else 0.
+
+ See descriptions of tunable parameters above.
+
+*/
+
+#if __STD_C
+int mALLOPt(RARG int param_number, int value)
+#else
+int mALLOPt(RARG param_number, value) RDECL int param_number; int value;
+#endif
+{
+ MALLOC_LOCK;
+ switch(param_number)
+ {
+ case M_TRIM_THRESHOLD:
+ trim_threshold = value; MALLOC_UNLOCK; return 1;
+ case M_TOP_PAD:
+ top_pad = value; MALLOC_UNLOCK; return 1;
+ case M_MMAP_THRESHOLD:
+#if HAVE_MMAP
+ mmap_threshold = value;
+#endif
+ MALLOC_UNLOCK;
+ return 1;
+ case M_MMAP_MAX:
+#if HAVE_MMAP
+ n_mmaps_max = value; MALLOC_UNLOCK; return 1;
+#else
+ MALLOC_UNLOCK; return value == 0;
+#endif
+
+ default:
+ MALLOC_UNLOCK;
+ return 0;
+ }
+}
+
+#endif /* DEFINE_MALLOPT */
+
+/*
+
+History:
+
+ V2.6.3 Sun May 19 08:17:58 1996 Doug Lea (dl at gee)
+ * Added pvalloc, as recommended by H.J. Liu
+ * Added 64bit pointer support mainly from Wolfram Gloger
+ * Added anonymously donated WIN32 sbrk emulation
+ * Malloc, calloc, getpagesize: add optimizations from Raymond Nijssen
+ * malloc_extend_top: fix mask error that caused wastage after
+ foreign sbrks
+ * Add linux mremap support code from HJ Liu
+
+ V2.6.2 Tue Dec 5 06:52:55 1995 Doug Lea (dl at gee)
+ * Integrated most documentation with the code.
+ * Add support for mmap, with help from
+ Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
+ * Use last_remainder in more cases.
+ * Pack bins using idea from colin@nyx10.cs.du.edu
+ * Use ordered bins instead of best-fit threshhold
+ * Eliminate block-local decls to simplify tracing and debugging.
+ * Support another case of realloc via move into top
+ * Fix error occuring when initial sbrk_base not word-aligned.
+ * Rely on page size for units instead of SBRK_UNIT to
+ avoid surprises about sbrk alignment conventions.
+ * Add mallinfo, mallopt. Thanks to Raymond Nijssen
+ (raymond@es.ele.tue.nl) for the suggestion.
+ * Add `pad' argument to malloc_trim and top_pad mallopt parameter.
+ * More precautions for cases where other routines call sbrk,
+ courtesy of Wolfram Gloger (Gloger@lrz.uni-muenchen.de).
+ * Added macros etc., allowing use in linux libc from
+ H.J. Lu (hjl@gnu.ai.mit.edu)
+ * Inverted this history list
+
+ V2.6.1 Sat Dec 2 14:10:57 1995 Doug Lea (dl at gee)
+ * Re-tuned and fixed to behave more nicely with V2.6.0 changes.
+ * Removed all preallocation code since under current scheme
+ the work required to undo bad preallocations exceeds
+ the work saved in good cases for most test programs.
+ * No longer use return list or unconsolidated bins since
+ no scheme using them consistently outperforms those that don't
+ given above changes.
+ * Use best fit for very large chunks to prevent some worst-cases.
+ * Added some support for debugging
+
+ V2.6.0 Sat Nov 4 07:05:23 1995 Doug Lea (dl at gee)
+ * Removed footers when chunks are in use. Thanks to
+ Paul Wilson (wilson@cs.texas.edu) for the suggestion.
+
+ V2.5.4 Wed Nov 1 07:54:51 1995 Doug Lea (dl at gee)
+ * Added malloc_trim, with help from Wolfram Gloger
+ (wmglo@Dent.MED.Uni-Muenchen.DE).
+
+ V2.5.3 Tue Apr 26 10:16:01 1994 Doug Lea (dl at g)
+
+ V2.5.2 Tue Apr 5 16:20:40 1994 Doug Lea (dl at g)
+ * realloc: try to expand in both directions
+ * malloc: swap order of clean-bin strategy;
+ * realloc: only conditionally expand backwards
+ * Try not to scavenge used bins
+ * Use bin counts as a guide to preallocation
+ * Occasionally bin return list chunks in first scan
+ * Add a few optimizations from colin@nyx10.cs.du.edu
+
+ V2.5.1 Sat Aug 14 15:40:43 1993 Doug Lea (dl at g)
+ * faster bin computation & slightly different binning
+ * merged all consolidations to one part of malloc proper
+ (eliminating old malloc_find_space & malloc_clean_bin)
+ * Scan 2 returns chunks (not just 1)
+ * Propagate failure in realloc if malloc returns 0
+ * Add stuff to allow compilation on non-ANSI compilers
+ from kpv@research.att.com
+
+ V2.5 Sat Aug 7 07:41:59 1993 Doug Lea (dl at g.oswego.edu)
+ * removed potential for odd address access in prev_chunk
+ * removed dependency on getpagesize.h
+ * misc cosmetics and a bit more internal documentation
+ * anticosmetics: mangled names in macros to evade debugger strangeness
+ * tested on sparc, hp-700, dec-mips, rs6000
+ with gcc & native cc (hp, dec only) allowing
+ Detlefs & Zorn comparison study (in SIGPLAN Notices.)
+
+ Trial version Fri Aug 28 13:14:29 1992 Doug Lea (dl at g.oswego.edu)
+ * Based loosely on libg++-1.2X malloc. (It retains some of the overall
+ structure of old version, but most details differ.)
+
+*/
+#endif
mallocr.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mblen.c
===================================================================
--- mblen.c (nonexistent)
+++ mblen.c (revision 345)
@@ -0,0 +1,80 @@
+/*
+FUNCTION
+<>---minimal multibyte length function
+
+INDEX
+ mblen
+
+ANSI_SYNOPSIS
+ #include
+ int mblen(const char *<[s]>, size_t <[n]>);
+
+TRAD_SYNOPSIS
+ #include
+ int mblen(<[s]>, <[n]>)
+ const char *<[s]>;
+ size_t <[n]>;
+
+DESCRIPTION
+When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming
+implementation of <>. In this case, the
+only ``multi-byte character sequences'' recognized are single bytes,
+and thus <<1>> is returned unless <[s]> is the null pointer or
+has a length of 0 or is the empty string.
+
+When _MB_CAPABLE is defined, this routine calls <<_mbtowc_r>> to perform
+the conversion, passing a state variable to allow state dependent
+decoding. The result is based on the locale setting which may
+be restricted to a defined set of locales.
+
+RETURNS
+This implementation of <> returns <<0>> if
+<[s]> is <> or the empty string; it returns <<1>> if not _MB_CAPABLE or
+the character is a single-byte character; it returns <<-1>>
+if the multi-byte character is invalid; otherwise it returns
+the number of bytes in the multibyte character.
+
+PORTABILITY
+<> is required in the ANSI C standard. However, the precise
+effects vary with the locale.
+
+<> requires no supporting OS subroutines.
+*/
+
+#ifndef _REENT_ONLY
+
+#include
+#include
+#include
+#include "local.h"
+
+int
+_DEFUN (mblen, (s, n),
+ const char *s _AND
+ size_t n)
+{
+#ifdef _MB_CAPABLE
+ int retval = 0;
+ mbstate_t *state;
+
+ _REENT_CHECK_MISC(_REENT);
+ state = &(_REENT_MBLEN_STATE(_REENT));
+ retval = __mbtowc (_REENT, NULL, s, n, __locale_charset (), state);
+ if (retval < 0)
+ {
+ state->__count = 0;
+ return -1;
+ }
+ else
+ return retval;
+
+#else /* not _MB_CAPABLE */
+ if (s == NULL || *s == '\0')
+ return 0;
+ if (n == 0)
+ return -1;
+ return 1;
+#endif /* not _MB_CAPABLE */
+}
+
+#endif /* !_REENT_ONLY */
mblen.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: ecvtbuf.c
===================================================================
--- ecvtbuf.c (nonexistent)
+++ ecvtbuf.c (revision 345)
@@ -0,0 +1,469 @@
+/*
+FUNCTION
+<>, <>---double or float to string
+
+INDEX
+ ecvtbuf
+INDEX
+ fcvtbuf
+
+ANSI_SYNOPSIS
+ #include
+
+ 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
+
+ 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
+ <> and <> produce (null-terminated) strings
+ of digits representating the <> number <[val]>.
+
+ The only difference between <> and <> is the
+ interpretation of the second argument (<[chars]> or
+ <[decimals]>). For <>, 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 <>,
+ 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 <> and <> 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: <>, <>, <>,
+<>, <>, <>, <>.
+*/
+
+#include <_ansi.h>
+#include
+#include
+#include
+#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)
+{
+ 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)
+{
+ 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;
+}
ecvtbuf.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: atexit.c
===================================================================
--- atexit.c (nonexistent)
+++ atexit.c (revision 345)
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+/*
+FUNCTION
+<>---request execution of functions at program exit
+
+INDEX
+ atexit
+
+ANSI_SYNOPSIS
+ #include
+ int atexit (void (*<[function]>)(void));
+
+TRAD_SYNOPSIS
+ #include
+ int atexit ((<[function]>)
+ void (*<[function]>)();
+
+DESCRIPTION
+You can use <> to enroll functions in a list of functions that
+will be called when your program terminates normally. The argument is
+a pointer to a user-defined function (which must not require arguments and
+must not return a result).
+
+The functions are kept in a LIFO stack; that is, the last function
+enrolled by <> will be the first to execute when your program
+exits.
+
+There is no built-in limit to the number of functions you can enroll
+in this list; however, after every group of 32 functions is enrolled,
+<> will call <> to get space for the next part of the
+list. The initial list of 32 functions is statically allocated, so
+you can always count on at least that many slots available.
+
+RETURNS
+<> returns <<0>> if it succeeds in enrolling your function,
+<<-1>> if it fails (possible only if no space was available for
+<> to extend the list of functions).
+
+PORTABILITY
+<> is required by the ANSI standard, which also specifies that
+implementations must support enrolling at least 32 functions.
+
+Supporting OS subroutines required: <>, <>, <>,
+<>, <>, <>, <>.
+*/
+
+#include
+#include "atexit.h"
+
+/*
+ * Register a function to be performed at exit.
+ */
+
+int
+_DEFUN (atexit,
+ (fn),
+ _VOID _EXFNPTR(fn, (_VOID)))
+{
+ return __register_exitproc (__et_atexit, fn, NULL, NULL);
+}
atexit.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: atol.c
===================================================================
--- atol.c (nonexistent)
+++ atol.c (revision 345)
@@ -0,0 +1,21 @@
+/*
+ * Andy Wilson, 2-Oct-89.
+ */
+
+#include
+#include <_ansi.h>
+
+#ifndef _REENT_ONLY
+long
+_DEFUN (atol, (s), _CONST char *s)
+{
+ return strtol (s, NULL, 10);
+}
+#endif /* !_REENT_ONLY */
+
+long
+_DEFUN (_atol_r, (ptr, s), struct _reent *ptr _AND _CONST char *s)
+{
+ return _strtol_r (ptr, s, NULL, 10);
+}
+
atol.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: sb_charsets.c
===================================================================
--- sb_charsets.c (nonexistent)
+++ sb_charsets.c (revision 345)
@@ -0,0 +1,737 @@
+#include
+#include
+
+#ifdef _MB_CAPABLE
+extern char *__locale_charset ();
+
+#ifdef _MB_EXTENDED_CHARSETS_ISO
+/* Tables for the ISO-8859-x to UTF conversion. The first index into the
+ table is a value computed from the value x (function __iso_8859_index),
+ the second index is the value of the incoming character - 0xa0.
+ Values < 0xa0 don't have to be converted anyway. */
+wchar_t __iso_8859_conv[14][0x60] = {
+ /* ISO-8859-2 */
+ { 0xa0, 0x104, 0x2d8, 0x141, 0xa4, 0x13d, 0x15a, 0xa7,
+ 0xa8, 0x160, 0x15e, 0x164, 0x179, 0xad, 0x17d, 0x17b,
+ 0xb0, 0x105, 0x2db, 0x142, 0xb4, 0x13e, 0x15b, 0x2c7,
+ 0xb8, 0x161, 0x15f, 0x165, 0x17a, 0x2dd, 0x17e, 0x17c,
+ 0x154, 0xc1, 0xc2, 0x102, 0xc4, 0x139, 0x106, 0xc7,
+ 0x10c, 0xc9, 0x118, 0xcb, 0x11a, 0xcd, 0xce, 0x10e,
+ 0x110, 0x143, 0x147, 0xd3, 0xd4, 0x150, 0xd6, 0xd7,
+ 0x158, 0x16e, 0xda, 0x170, 0xdc, 0xdd, 0x162, 0xdf,
+ 0x155, 0xe1, 0xe2, 0x103, 0xe4, 0x13a, 0x107, 0xe7,
+ 0x10d, 0xe9, 0x119, 0xeb, 0x11b, 0xed, 0xee, 0x10f,
+ 0x111, 0x144, 0x148, 0xf3, 0xf4, 0x151, 0xf6, 0xf7,
+ 0x159, 0x16f, 0xfa, 0x171, 0xfc, 0xfd, 0x163, 0x2d9 },
+ /* ISO-8859-3 */
+ { 0xa0, 0x126, 0x2d8, 0xa3, 0xa4, 0xf7f5, 0x124, 0xa7,
+ 0xa8, 0x130, 0x15e, 0x11e, 0x134, 0xad, 0xf7f6, 0x17b,
+ 0xb0, 0x127, 0xb2, 0xb3, 0xb4, 0xb5, 0x125, 0xb7,
+ 0xb8, 0x131, 0x15f, 0x11f, 0x135, 0xbd, 0xf7f7, 0x17c,
+ 0xc0, 0xc1, 0xc2, 0xf7f8, 0xc4, 0x10a, 0x108, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xf7f9, 0xd1, 0xd2, 0xd3, 0xd4, 0x120, 0xd6, 0xd7,
+ 0x11c, 0xd9, 0xda, 0xdb, 0xdc, 0x16c, 0x15c, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xf7fa, 0xe4, 0x10b, 0x109, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf7fb, 0xf1, 0xf2, 0xf3, 0xf4, 0x121, 0xf6, 0xf7,
+ 0x11d, 0xf9, 0xfa, 0xfb, 0xfc, 0x16d, 0x15d, 0x2d9 },
+ /* ISO-8859-4 */
+ { 0xa0, 0x104, 0x138, 0x156, 0xa4, 0x128, 0x13b, 0xa7,
+ 0xa8, 0x160, 0x112, 0x122, 0x166, 0xad, 0x17d, 0xaf,
+ 0xb0, 0x105, 0x2db, 0x157, 0xb4, 0x129, 0x13c, 0x2c7,
+ 0xb8, 0x161, 0x113, 0x123, 0x167, 0x14a, 0x17e, 0x14b,
+ 0x100, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0x12e,
+ 0x10c, 0xc9, 0x118, 0xcb, 0x116, 0xcd, 0xce, 0x12a,
+ 0x110, 0x145, 0x14c, 0x136, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0x172, 0xda, 0xdb, 0xdc, 0x168, 0x16a, 0xdf,
+ 0x101, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0x12f,
+ 0x10d, 0xe9, 0x119, 0xeb, 0x117, 0xed, 0xee, 0x12b,
+ 0x111, 0x146, 0x14d, 0x137, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0x173, 0xfa, 0xfb, 0xfc, 0x169, 0x16b, 0x2d9 },
+ /* ISO-8859-5 */
+ { 0xa0, 0x401, 0x402, 0x403, 0x404, 0x405, 0x406, 0x407,
+ 0x408, 0x409, 0x40a, 0x40b, 0x40c, 0xad, 0x40e, 0x40f,
+ 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417,
+ 0x418, 0x419, 0x41a, 0x41b, 0x41c, 0x41d, 0x41e, 0x41f,
+ 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427,
+ 0x428, 0x429, 0x42a, 0x42b, 0x42c, 0x42d, 0x42e, 0x42f,
+ 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437,
+ 0x438, 0x439, 0x43a, 0x43b, 0x43c, 0x43d, 0x43e, 0x43f,
+ 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447,
+ 0x448, 0x449, 0x44a, 0x44b, 0x44c, 0x44d, 0x44e, 0x44f,
+ 0x2116, 0x451, 0x452, 0x453, 0x454, 0x455, 0x456, 0x457,
+ 0x458, 0x459, 0x45a, 0x45b, 0x45c, 0xa7, 0x45e, 0x45f },
+ /* ISO-8859-6 */
+ { 0xa0, 0xf7c8, 0xf7c9, 0xf7ca, 0xa4, 0xf7cb, 0xf7cc, 0xf7cd,
+ 0xf7ce, 0xf7cf, 0xf7d0, 0xf7d1, 0x60c, 0xad, 0xf7d2, 0xf7d3,
+ 0xf7d4, 0xf7d5, 0xf7d6, 0xf7d7, 0xf7d8, 0xf7d9, 0xf7da, 0xf7db,
+ 0xf7dc, 0xf7dd, 0xf7de, 0x61b, 0xf7df, 0xf7e0, 0xf7e1, 0x61f,
+ 0xf7e2, 0x621, 0x622, 0x623, 0x624, 0x625, 0x626, 0x627,
+ 0x628, 0x629, 0x62a, 0x62b, 0x62c, 0x62d, 0x62e, 0x62f,
+ 0x630, 0x631, 0x632, 0x633, 0x634, 0x635, 0x636, 0x637,
+ 0x638, 0x639, 0x63a, 0xf7e3, 0xf7e4, 0xf7e5, 0xf7e6, 0xf7e7,
+ 0x640, 0x641, 0x642, 0x643, 0x644, 0x645, 0x646, 0x647,
+ 0x648, 0x649, 0x64a, 0x64b, 0x64c, 0x64d, 0x64e, 0x64f,
+ 0x650, 0x651, 0x652, 0xf7e8, 0xf7e9, 0xf7ea, 0xf7eb, 0xf7ec,
+ 0xf7ed, 0xf7ee, 0xf7ef, 0xf7f0, 0xf7f1, 0xf7f2, 0xf7f3, 0xf7f4 },
+ /* ISO-8859-7 */
+ { 0xa0, 0x2bd, 0x2bc, 0xa3, 0xf7c2, 0xf7c3, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xf7c4, 0xab, 0xac, 0xad, 0xf7c5, 0x2015,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0x384, 0x385, 0x386, 0xb7,
+ 0x388, 0x389, 0x38a, 0xbb, 0x38c, 0xbd, 0x38e, 0x38f,
+ 0x390, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397,
+ 0x398, 0x399, 0x39a, 0x39b, 0x39c, 0x39d, 0x39e, 0x39f,
+ 0x3a0, 0x3a1, 0xf7c6, 0x3a3, 0x3a4, 0x3a5, 0x3a6, 0x3a7,
+ 0x3a8, 0x3a9, 0x3aa, 0x3ab, 0x3ac, 0x3ad, 0x3ae, 0x3af,
+ 0x3b0, 0x3b1, 0x3b2, 0x3b3, 0x3b4, 0x3b5, 0x3b6, 0x3b7,
+ 0x3b8, 0x3b9, 0x3ba, 0x3bb, 0x3bc, 0x3bd, 0x3be, 0x3bf,
+ 0x3c0, 0x3c1, 0x3c2, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7,
+ 0x3c8, 0x3c9, 0x3ca, 0x3cb, 0x3cc, 0x3cd, 0x3ce, 0xf7c7 },
+ /* ISO-8859-8 */
+ { 0xa0, 0xf79c, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xd7, 0xab, 0xac, 0xad, 0xae, 0x203e,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xf7, 0xbb, 0xbc, 0xbd, 0xbe, 0xf79d,
+ 0xf79e, 0xf79f, 0xf7a0, 0xf7a1, 0xf7a2, 0xf7a3, 0xf7a4, 0xf7a5,
+ 0xf7a6, 0xf7a7, 0xf7a8, 0xf7a9, 0xf7aa, 0xf7ab, 0xf7ac, 0xf7ad,
+ 0xf7ae, 0xf7af, 0xf7b0, 0xf7b1, 0xf7b2, 0xf7b3, 0xf7b4, 0xf7b5,
+ 0xf7b6, 0xf7b7, 0xf7b8, 0xf7b9, 0xf7ba, 0xf7bb, 0xf7bc, 0x2017,
+ 0x5d0, 0x5d1, 0x5d2, 0x5d3, 0x5d4, 0x5d5, 0x5d6, 0x5d7,
+ 0x5d8, 0x5d9, 0x5da, 0x5db, 0x5dc, 0x5dd, 0x5de, 0x5df,
+ 0x5e0, 0x5e1, 0x5e2, 0x5e3, 0x5e4, 0x5e5, 0x5e6, 0x5e7,
+ 0x5e8, 0x5e9, 0x5ea, 0xf7bd, 0xf7be, 0xf7bf, 0xf7c0, 0xf7c1 },
+ /* ISO-8859-9 */
+ { 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0x11e, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0x130, 0x15e, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0x11f, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x131, 0x15f, 0xff },
+ /* ISO-8859-10 */
+ { 0xa0, 0x104, 0x112, 0x122, 0x12a, 0x128, 0x136, 0xa7,
+ 0x13b, 0x110, 0x160, 0x166, 0x17d, 0xad, 0x16a, 0x14a,
+ 0xb0, 0x105, 0x113, 0x123, 0x12b, 0x129, 0x137, 0xb7,
+ 0x13c, 0x111, 0x161, 0x167, 0x17e, 0x2015, 0x16b, 0x14b,
+ 0x100, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0x12e,
+ 0x10c, 0xc9, 0x118, 0xcb, 0x116, 0xcd, 0xce, 0xcf,
+ 0xd0, 0x145, 0x14c, 0xd3, 0xd4, 0xd5, 0xd6, 0x168,
+ 0xd8, 0x172, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0x101, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0x12f,
+ 0x10d, 0xe9, 0x119, 0xeb, 0x117, 0xed, 0xee, 0xef,
+ 0xf0, 0x146, 0x14d, 0xf3, 0xf4, 0xf5, 0xf6, 0x169,
+ 0xf8, 0x173, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0x138 },
+ /* ISO-8859-11 */
+ { 0xa0, 0xe01, 0xe02, 0xe03, 0xe04, 0xe05, 0xe06, 0xe07,
+ 0xe08, 0xe09, 0xe0a, 0xe0b, 0xe0c, 0xe0d, 0xe0e, 0xe0f,
+ 0xe10, 0xe11, 0xe12, 0xe13, 0xe14, 0xe15, 0xe16, 0xe17,
+ 0xe18, 0xe19, 0xe1a, 0xe1b, 0xe1c, 0xe1d, 0xe1e, 0xe1f,
+ 0xe20, 0xe21, 0xe22, 0xe23, 0xe24, 0xe25, 0xe26, 0xe27,
+ 0xe28, 0xe29, 0xe2a, 0xe2b, 0xe2c, 0xe2d, 0xe2e, 0xe2f,
+ 0xe30, 0xe31, 0xe32, 0xe33, 0xe34, 0xe35, 0xe36, 0xe37,
+ 0xe38, 0xe39, 0xe3a, 0xdb, 0xdc, 0xdd, 0xde, 0xe3f,
+ 0xe40, 0xe41, 0xe42, 0xe43, 0xe44, 0xe45, 0xe46, 0xe47,
+ 0xe48, 0xe49, 0xe4a, 0xe4b, 0xe4c, 0xe4d, 0xe4e, 0xe4f,
+ 0xe50, 0xe51, 0xe52, 0xe53, 0xe54, 0xe55, 0xe56, 0xe57,
+ 0xe58, 0xe59, 0xe5a, 0xe5b, 0xe31, 0xe34, 0xe47, 0xff },
+ /* ISO-8859-12 doesn't exist. The below code decrements the index
+ into the table by one for ISO numbers > 12. */
+ /* ISO-8859-13 */
+ { 0xa0, 0x201d, 0xa2, 0xa3, 0xa4, 0x201e, 0xa6, 0xa7,
+ 0xd8, 0xa9, 0x156, 0xab, 0xac, 0xad, 0xae, 0xc6,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0x201c, 0xb5, 0xb6, 0xb7,
+ 0xf8, 0xb9, 0x157, 0xbb, 0xbc, 0xbd, 0xbe, 0xe6,
+ 0x104, 0x12e, 0x100, 0x106, 0xc4, 0xc5, 0x118, 0x112,
+ 0x10c, 0xc9, 0x179, 0x116, 0x122, 0x136, 0x12a, 0x13b,
+ 0x160, 0x143, 0x145, 0xd3, 0x14c, 0xd5, 0xd6, 0xd7,
+ 0x172, 0x141, 0x15a, 0x16a, 0xdc, 0x17b, 0x17d, 0xdf,
+ 0x105, 0x12f, 0x101, 0x107, 0xe4, 0xe5, 0x119, 0x113,
+ 0x10d, 0xe9, 0x17a, 0x117, 0x123, 0x137, 0x12b, 0x13c,
+ 0x161, 0x144, 0x146, 0xf3, 0x14d, 0xf5, 0xf6, 0xf7,
+ 0x173, 0x142, 0x15b, 0x16b, 0xfc, 0x17c, 0x17e, 0x2019 },
+ /* ISO-8859-14 */
+ { 0xa0, 0x1e02, 0x1e03, 0xa3, 0x10a, 0x10b, 0x1e0a, 0xa7,
+ 0x1e80, 0xa9, 0x1e82, 0x1e0b, 0x1ef2, 0xad, 0xae, 0x178,
+ 0x1e1e, 0x1e1f, 0x120, 0x121, 0x1e40, 0x1e41, 0xb6, 0x1e56,
+ 0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0x174, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0x1e6a,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0x176, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0x175, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0x1e6b,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0x177, 0xff },
+ /* ISO-8859-15 */
+ { 0xa0, 0xa1, 0xa2, 0xa3, 0x20ac, 0xa5, 0x160, 0xa7,
+ 0x161, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0x17d, 0xb5, 0xb6, 0xb7,
+ 0x17e, 0xb9, 0xba, 0xbb, 0x152, 0x153, 0x178, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
+ /* ISO-8859-16 */
+ { 0xa0, 0x104, 0x105, 0x141, 0x20ac, 0x201e, 0x160, 0xa7,
+ 0x161, 0xa9, 0x218, 0xab, 0x179, 0xad, 0x17a, 0x17b,
+ 0xb0, 0xb1, 0x10c, 0x142, 0x17d, 0x201d, 0xb6, 0xb7,
+ 0x17e, 0x10d, 0x219, 0xbb, 0x152, 0x153, 0x178, 0x17c,
+ 0xc0, 0xc1, 0xc2, 0x102, 0xc4, 0x106, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0x110, 0x143, 0xd2, 0xd3, 0xd4, 0x150, 0xd6, 0x15a,
+ 0x170, 0xd9, 0xda, 0xdb, 0xdc, 0x118, 0x21a, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0x103, 0xe4, 0x107, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0x111, 0x144, 0xf2, 0xf3, 0xf4, 0x151, 0xf6, 0x15b,
+ 0x171, 0xf9, 0xfa, 0xfb, 0xfc, 0x119, 0x21b, 0xff }
+};
+#endif /* _MB_EXTENDED_CHARSETS_ISO */
+
+#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
+/* Tables for the Windows default singlebyte ANSI codepage conversion.
+ The first index into the table is a value computed from the codepage
+ value (function __cp_index), the second index is the value of the
+ incoming character - 0x80.
+ Values < 0x80 don't have to be converted anyway. */
+wchar_t __cp_conv[24][0x80] = {
+ /* CP437 */
+ { 0xc7, 0xfc, 0xe9, 0xe2, 0xe4, 0xe0, 0xe5, 0xe7,
+ 0xea, 0xeb, 0xe8, 0xef, 0xee, 0xec, 0xc4, 0xc5,
+ 0xc9, 0xe6, 0xc6, 0xf4, 0xf6, 0xf2, 0xfb, 0xf9,
+ 0xff, 0xd6, 0xdc, 0xa2, 0xa3, 0xa5, 0x20a7, 0x192,
+ 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xaa, 0xba,
+ 0xbf, 0x2310, 0xac, 0xbd, 0xbc, 0xa1, 0xab, 0xbb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
+ 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
+ 0x3b1, 0xdf, 0x393, 0x3c0, 0x3a3, 0x3c3, 0xb5, 0x3c4,
+ 0x3a6, 0x398, 0x3a9, 0x3b4, 0x221e, 0x3c6, 0x3b5, 0x2229,
+ 0x2261, 0xb1, 0x2265, 0x2264, 0x2320, 0x2321, 0xf7, 0x2248,
+ 0xb0, 0x2219, 0xb7, 0x221a, 0x207f, 0xb2, 0x25a0, 0xa0 },
+ /* CP720 */
+ { 0x80, 0x81, 0xe9, 0xe2, 0x84, 0xe0, 0x86, 0xe7,
+ 0xea, 0xeb, 0xe8, 0xef, 0xee, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x651, 0x652, 0xf4, 0xa4, 0x640, 0xfb, 0xf9,
+ 0x621, 0x622, 0x623, 0x624, 0xa3, 0x625, 0x626, 0x627,
+ 0x628, 0x629, 0x62a, 0x62b, 0x62c, 0x62d, 0x62e, 0x62f,
+ 0x630, 0x631, 0x632, 0x633, 0x634, 0x635, 0xab, 0xbb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
+ 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
+ 0x636, 0x637, 0x638, 0x639, 0x63a, 0x641, 0xb5, 0x642,
+ 0x643, 0x644, 0x645, 0x646, 0x647, 0x648, 0x649, 0x64a,
+ 0x2261, 0x64b, 0x64c, 0x64d, 0x64e, 0x64f, 0x650, 0x2248,
+ 0xb0, 0x2219, 0xb7, 0x221a, 0x207f, 0xb2, 0x25a0, 0xa0 },
+ /* CP737 */
+ { 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397, 0x398,
+ 0x399, 0x39a, 0x39b, 0x39c, 0x39d, 0x39e, 0x39f, 0x3a0,
+ 0x3a1, 0x3a3, 0x3a4, 0x3a5, 0x3a6, 0x3a7, 0x3a8, 0x3a9,
+ 0x3b1, 0x3b2, 0x3b3, 0x3b4, 0x3b5, 0x3b6, 0x3b7, 0x3b8,
+ 0x3b9, 0x3ba, 0x3bb, 0x3bc, 0x3bd, 0x3be, 0x3bf, 0x3c0,
+ 0x3c1, 0x3c3, 0x3c2, 0x3c4, 0x3c5, 0x3c6, 0x3c7, 0x3c8,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
+ 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
+ 0x3c9, 0x3ac, 0x3ad, 0x3ae, 0x3ca, 0x3af, 0x3cc, 0x3cd,
+ 0x3cb, 0x3ce, 0x386, 0x388, 0x389, 0x38a, 0x38c, 0x38e,
+ 0x38f, 0xb1, 0x2265, 0x2264, 0x3aa, 0x3ab, 0xf7, 0x2248,
+ 0xb0, 0x2219, 0xb7, 0x221a, 0x207f, 0xb2, 0x25a0, 0xa0 },
+ /* CP775 */
+ { 0x106, 0xfc, 0xe9, 0x101, 0xe4, 0x123, 0xe5, 0x107,
+ 0x142, 0x113, 0x156, 0x157, 0x12b, 0x179, 0xc4, 0xc5,
+ 0xc9, 0xe6, 0xc6, 0x14d, 0xf6, 0x122, 0xa2, 0x15a,
+ 0x15b, 0xd6, 0xdc, 0xf8, 0xa3, 0xd8, 0xd7, 0xa4,
+ 0x100, 0x12a, 0xf3, 0x17b, 0x17c, 0x17a, 0x201d, 0xa6,
+ 0xa9, 0xae, 0xac, 0xbd, 0xbc, 0x141, 0xab, 0xbb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x104, 0x10c, 0x118,
+ 0x116, 0x2563, 0x2551, 0x2557, 0x255d, 0x12e, 0x160, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x172, 0x16a,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x17d,
+ 0x105, 0x10d, 0x119, 0x117, 0x12f, 0x161, 0x173, 0x16b,
+ 0x17e, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
+ 0xd3, 0xdf, 0x14c, 0x143, 0xf5, 0xd5, 0xb5, 0x144,
+ 0x136, 0x137, 0x13b, 0x13c, 0x146, 0x112, 0x145, 0x2019,
+ 0xad, 0xb1, 0x201c, 0xbe, 0xb6, 0xa7, 0xf7, 0x201e,
+ 0xb0, 0x2219, 0xb7, 0xb9, 0xb3, 0xb2, 0x25a0, 0xa0 },
+ /* CP850 */
+ { 0xc7, 0xfc, 0xe9, 0xe2, 0xe4, 0xe0, 0xe5, 0xe7,
+ 0xea, 0xeb, 0xe8, 0xef, 0xee, 0xec, 0xc4, 0xc5,
+ 0xc9, 0xe6, 0xc6, 0xf4, 0xf6, 0xf2, 0xfb, 0xf9,
+ 0xff, 0xd6, 0xdc, 0xf8, 0xa3, 0xd8, 0xd7, 0x192,
+ 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xaa, 0xba,
+ 0xbf, 0xae, 0xac, 0xbd, 0xbc, 0xa1, 0xab, 0xbb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0xc1, 0xc2, 0xc0,
+ 0xa9, 0x2563, 0x2551, 0x2557, 0x255d, 0xa2, 0xa5, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0xe3, 0xc3,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0xa4,
+ 0xf0, 0xd0, 0xca, 0xcb, 0xc8, 0x131, 0xcd, 0xce,
+ 0xcf, 0x2518, 0x250c, 0x2588, 0x2584, 0xa6, 0xcc, 0x2580,
+ 0xd3, 0xdf, 0xd4, 0xd2, 0xf5, 0xd5, 0xb5, 0xfe,
+ 0xde, 0xda, 0xdb, 0xd9, 0xfd, 0xdd, 0xaf, 0xb4,
+ 0xad, 0xb1, 0x2017, 0xbe, 0xb6, 0xa7, 0xf7, 0xb8,
+ 0xb0, 0xa8, 0xb7, 0xb9, 0xb3, 0xb2, 0x25a0, 0xa0 },
+ /* CP852 */
+ { 0xc7, 0xfc, 0xe9, 0xe2, 0xe4, 0x16f, 0x107, 0xe7,
+ 0x142, 0xeb, 0x150, 0x151, 0xee, 0x179, 0xc4, 0x106,
+ 0xc9, 0x139, 0x13a, 0xf4, 0xf6, 0x13d, 0x13e, 0x15a,
+ 0x15b, 0xd6, 0xdc, 0x164, 0x165, 0x141, 0xd7, 0x10d,
+ 0xe1, 0xed, 0xf3, 0xfa, 0x104, 0x105, 0x17d, 0x17e,
+ 0x118, 0x119, 0xac, 0x17a, 0x10c, 0x15f, 0xab, 0xbb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0xc1, 0xc2, 0x11a,
+ 0x15e, 0x2563, 0x2551, 0x2557, 0x255d, 0x17b, 0x17c, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x102, 0x103,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0xa4,
+ 0x111, 0x110, 0x10e, 0xcb, 0x10f, 0x147, 0xcd, 0xce,
+ 0x11b, 0x2518, 0x250c, 0x2588, 0x2584, 0x162, 0x16e, 0x2580,
+ 0xd3, 0xdf, 0xd4, 0x143, 0x144, 0x148, 0x160, 0x161,
+ 0x154, 0xda, 0x155, 0x170, 0xfd, 0xdd, 0x163, 0xb4,
+ 0xad, 0x2dd, 0x2db, 0x2c7, 0x2d8, 0xa7, 0xf7, 0xb8,
+ 0xb0, 0xa8, 0x2d9, 0x171, 0x158, 0x159, 0x25a0, 0xa0 },
+ /* CP855 */
+ { 0x452, 0x402, 0x453, 0x403, 0x451, 0x401, 0x454, 0x404,
+ 0x455, 0x405, 0x456, 0x406, 0x457, 0x407, 0x458, 0x408,
+ 0x459, 0x409, 0x45a, 0x40a, 0x45b, 0x40b, 0x45c, 0x40c,
+ 0x45e, 0x40e, 0x45f, 0x40f, 0x44e, 0x42e, 0x44a, 0x42a,
+ 0x430, 0x410, 0x431, 0x411, 0x446, 0x426, 0x434, 0x414,
+ 0x435, 0x415, 0x444, 0x424, 0x433, 0x413, 0xab, 0xbb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x445, 0x425, 0x438,
+ 0x418, 0x2563, 0x2551, 0x2557, 0x255d, 0x439, 0x419, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x43a, 0x41a,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0xa4,
+ 0x43b, 0x41b, 0x43c, 0x41c, 0x43d, 0x41d, 0x43e, 0x41e,
+ 0x43f, 0x2518, 0x250c, 0x2588, 0x2584, 0x41f, 0x44f, 0x2580,
+ 0x42f, 0x440, 0x420, 0x441, 0x421, 0x442, 0x422, 0x443,
+ 0x423, 0x436, 0x416, 0x432, 0x412, 0x44c, 0x42c, 0x2116,
+ 0xad, 0x44b, 0x42b, 0x437, 0x417, 0x448, 0x428, 0x44d,
+ 0x42d, 0x449, 0x429, 0x447, 0x427, 0xa7, 0x25a0, 0xa0 },
+ /* CP857 */
+ { 0xc7, 0xfc, 0xe9, 0xe2, 0xe4, 0xe0, 0xe5, 0xe7,
+ 0xea, 0xeb, 0xe8, 0xef, 0xee, 0x131, 0xc4, 0xc5,
+ 0xc9, 0xe6, 0xc6, 0xf4, 0xf6, 0xf2, 0xfb, 0xf9,
+ 0x130, 0xd6, 0xdc, 0xf8, 0xa3, 0xd8, 0x15e, 0x15f,
+ 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0x11e, 0x11f,
+ 0xbf, 0xae, 0xac, 0xbd, 0xbc, 0xa1, 0xab, 0xbb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0xc1, 0xc2, 0xc0,
+ 0xa9, 0x2563, 0x2551, 0x2557, 0x255d, 0xa2, 0xa5, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0xe3, 0xc3,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0xa4,
+ 0xba, 0xaa, 0xca, 0xcb, 0xc8, 0xf8bb, 0xcd, 0xce,
+ 0xcf, 0x2518, 0x250c, 0x2588, 0x2584, 0xa6, 0xcc, 0x2580,
+ 0xd3, 0xdf, 0xd4, 0xd2, 0xf5, 0xd5, 0xb5, 0xf8bc,
+ 0xd7, 0xda, 0xdb, 0xd9, 0xec, 0xff, 0xaf, 0xb4,
+ 0xad, 0xb1, 0xf8bd, 0xbe, 0xb6, 0xa7, 0xf7, 0xb8,
+ 0xb0, 0xa8, 0xb7, 0xb9, 0xb3, 0xb2, 0x25a0, 0xa0 },
+ /* CP858 */
+ { 0xc7, 0xfc, 0xe9, 0xe2, 0xe4, 0xe0, 0xe5, 0xe7,
+ 0xea, 0xeb, 0xe8, 0xef, 0xee, 0xec, 0xc4, 0xc5,
+ 0xc9, 0xe6, 0xc6, 0xf4, 0xf6, 0xf2, 0xfb, 0xf9,
+ 0xff, 0xd6, 0xdc, 0xf8, 0xa3, 0xd8, 0xd7, 0x192,
+ 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xaa, 0xba,
+ 0xbf, 0xae, 0xac, 0xbd, 0xbc, 0xa1, 0xab, 0xbb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0xc1, 0xc2, 0xc0,
+ 0xa9, 0x2563, 0x2551, 0x2557, 0x255d, 0xa2, 0xa5, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0xe3, 0xc3,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0xa4,
+ 0xf0, 0xd0, 0xca, 0xcb, 0xc8, 0x20ac, 0xcd, 0xce,
+ 0xcf, 0x2518, 0x250c, 0x2588, 0x2584, 0xa6, 0xcc, 0x2580,
+ 0xd3, 0xdf, 0xd4, 0xd2, 0xf5, 0xd5, 0xb5, 0xfe,
+ 0xde, 0xda, 0xdb, 0xd9, 0xfd, 0xdd, 0xaf, 0xb4,
+ 0xad, 0xb1, 0x2017, 0xbe, 0xb6, 0xa7, 0xf7, 0xb8,
+ 0xb0, 0xa8, 0xb7, 0xb9, 0xb3, 0xb2, 0x25a0, 0xa0 },
+ /* CP862 */
+ { 0x5d0, 0x5d1, 0x5d2, 0x5d3, 0x5d4, 0x5d5, 0x5d6, 0x5d7,
+ 0x5d8, 0x5d9, 0x5da, 0x5db, 0x5dc, 0x5dd, 0x5de, 0x5df,
+ 0x5e0, 0x5e1, 0x5e2, 0x5e3, 0x5e4, 0x5e5, 0x5e6, 0x5e7,
+ 0x5e8, 0x5e9, 0x5ea, 0xa2, 0xa3, 0xa5, 0x20a7, 0x192,
+ 0xe1, 0xed, 0xf3, 0xfa, 0xf1, 0xd1, 0xaa, 0xba,
+ 0xbf, 0x2310, 0xac, 0xbd, 0xbc, 0xa1, 0xab, 0xbb,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
+ 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
+ 0x3b1, 0xdf, 0x393, 0x3c0, 0x3a3, 0x3c3, 0xb5, 0x3c4,
+ 0x3a6, 0x398, 0x3a9, 0x3b4, 0x221e, 0x3c6, 0x3b5, 0x2229,
+ 0x2261, 0xb1, 0x2265, 0x2264, 0x2320, 0x2321, 0xf7, 0x2248,
+ 0xb0, 0x2219, 0xb7, 0x221a, 0x207f, 0xb2, 0x25a0, 0xa0 },
+ /* CP866 */
+ { 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417,
+ 0x418, 0x419, 0x41a, 0x41b, 0x41c, 0x41d, 0x41e, 0x41f,
+ 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427,
+ 0x428, 0x429, 0x42a, 0x42b, 0x42c, 0x42d, 0x42e, 0x42f,
+ 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437,
+ 0x438, 0x439, 0x43a, 0x43b, 0x43c, 0x43d, 0x43e, 0x43f,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
+ 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
+ 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447,
+ 0x448, 0x449, 0x44a, 0x44b, 0x44c, 0x44d, 0x44e, 0x44f,
+ 0x401, 0x451, 0x404, 0x454, 0x407, 0x457, 0x40e, 0x45e,
+ 0xb0, 0x2219, 0xb7, 0x221a, 0x2116, 0xa4, 0x25a0, 0xa0 },
+ /* CP874 */
+ { 0x20ac, 0x81, 0x82, 0x83, 0x84, 0x2026, 0x86, 0x87,
+ 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
+ 0xa0, 0xe01, 0xe02, 0xe03, 0xe04, 0xe05, 0xe06, 0xe07,
+ 0xe08, 0xe09, 0xe0a, 0xe0b, 0xe0c, 0xe0d, 0xe0e, 0xe0f,
+ 0xe10, 0xe11, 0xe12, 0xe13, 0xe14, 0xe15, 0xe16, 0xe17,
+ 0xe18, 0xe19, 0xe1a, 0xe1b, 0xe1c, 0xe1d, 0xe1e, 0xe1f,
+ 0xe20, 0xe21, 0xe22, 0xe23, 0xe24, 0xe25, 0xe26, 0xe27,
+ 0xe28, 0xe29, 0xe2a, 0xe2b, 0xe2c, 0xe2d, 0xe2e, 0xe2f,
+ 0xe30, 0xe31, 0xe32, 0xe33, 0xe34, 0xe35, 0xe36, 0xe37,
+ 0xe38, 0xe39, 0xe3a, 0xf8c1, 0xf8c2, 0xf8c3, 0xf8c4, 0xe3f,
+ 0xe40, 0xe41, 0xe42, 0xe43, 0xe44, 0xe45, 0xe46, 0xe47,
+ 0xe48, 0xe49, 0xe4a, 0xe4b, 0xe4c, 0xe4d, 0xe4e, 0xe4f,
+ 0xe50, 0xe51, 0xe52, 0xe53, 0xe54, 0xe55, 0xe56, 0xe57,
+ 0xe58, 0xe59, 0xe5a, 0xe5b, 0xf8c5, 0xf8c6, 0xf8c7, 0xf8c8 },
+ /* CP1125 */
+ { 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417,
+ 0x418, 0x419, 0x41a, 0x41b, 0x41c, 0x41d, 0x41e, 0x41f,
+ 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427,
+ 0x428, 0x429, 0x42a, 0x42b, 0x42c, 0x42d, 0x42e, 0x42f,
+ 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437,
+ 0x438, 0x439, 0x43a, 0x43b, 0x43c, 0x43d, 0x43e, 0x43f,
+ 0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
+ 0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
+ 0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
+ 0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
+ 0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
+ 0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
+ 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447,
+ 0x448, 0x449, 0x44a, 0x44b, 0x44c, 0x44d, 0x44e, 0x44f,
+ 0x401, 0x451, 0x490, 0x491, 0x404, 0x454, 0x406, 0x456,
+ 0x407, 0x457, 0xb7, 0x221a, 0x2116, 0xa4, 0x25a0, 0xa0 },
+ /* CP1250 */
+ { 0x20ac, 0x81, 0x201a, 0x83, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x88, 0x2030, 0x160, 0x2039, 0x15a, 0x164, 0x17d, 0x179,
+ 0x90, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x98, 0x2122, 0x161, 0x203a, 0x15b, 0x165, 0x17e, 0x17a,
+ 0xa0, 0x2c7, 0x2d8, 0x141, 0xa4, 0x104, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0x15e, 0xab, 0xac, 0xad, 0xae, 0x17b,
+ 0xb0, 0xb1, 0x2db, 0x142, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0x105, 0x15f, 0xbb, 0x13d, 0x2dd, 0x13e, 0x17c,
+ 0x154, 0xc1, 0xc2, 0x102, 0xc4, 0x139, 0x106, 0xc7,
+ 0x10c, 0xc9, 0x118, 0xcb, 0x11a, 0xcd, 0xce, 0x10e,
+ 0x110, 0x143, 0x147, 0xd3, 0xd4, 0x150, 0xd6, 0xd7,
+ 0x158, 0x16e, 0xda, 0x170, 0xdc, 0xdd, 0x162, 0xdf,
+ 0x155, 0xe1, 0xe2, 0x103, 0xe4, 0x13a, 0x107, 0xe7,
+ 0x10d, 0xe9, 0x119, 0xeb, 0x11b, 0xed, 0xee, 0x10f,
+ 0x111, 0x144, 0x148, 0xf3, 0xf4, 0x151, 0xf6, 0xf7,
+ 0x159, 0x16f, 0xfa, 0x171, 0xfc, 0xfd, 0x163, 0x2d9 },
+ /* CP1251 */
+ { 0x402, 0x403, 0x201a, 0x453, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x20ac, 0x2030, 0x409, 0x2039, 0x40a, 0x40c, 0x40b, 0x40f,
+ 0x452, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x98, 0x2122, 0x459, 0x203a, 0x45a, 0x45c, 0x45b, 0x45f,
+ 0xa0, 0x40e, 0x45e, 0x408, 0xa4, 0x490, 0xa6, 0xa7,
+ 0x401, 0xa9, 0x404, 0xab, 0xac, 0xad, 0xae, 0x407,
+ 0xb0, 0xb1, 0x406, 0x456, 0x491, 0xb5, 0xb6, 0xb7,
+ 0x451, 0x2116, 0x454, 0xbb, 0x458, 0x405, 0x455, 0x457,
+ 0x410, 0x411, 0x412, 0x413, 0x414, 0x415, 0x416, 0x417,
+ 0x418, 0x419, 0x41a, 0x41b, 0x41c, 0x41d, 0x41e, 0x41f,
+ 0x420, 0x421, 0x422, 0x423, 0x424, 0x425, 0x426, 0x427,
+ 0x428, 0x429, 0x42a, 0x42b, 0x42c, 0x42d, 0x42e, 0x42f,
+ 0x430, 0x431, 0x432, 0x433, 0x434, 0x435, 0x436, 0x437,
+ 0x438, 0x439, 0x43a, 0x43b, 0x43c, 0x43d, 0x43e, 0x43f,
+ 0x440, 0x441, 0x442, 0x443, 0x444, 0x445, 0x446, 0x447,
+ 0x448, 0x449, 0x44a, 0x44b, 0x44c, 0x44d, 0x44e, 0x44f },
+ /* CP1252 */
+ { 0x20ac, 0x81, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x2c6, 0x2030, 0x160, 0x2039, 0x152, 0x8d, 0x17d, 0x8f,
+ 0x90, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x2dc, 0x2122, 0x161, 0x203a, 0x153, 0x9d, 0x17e, 0x178,
+ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff },
+ /* CP1253 */
+ { 0x20ac, 0x81, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x88, 0x2030, 0x8a, 0x2039, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x98, 0x2122, 0x9a, 0x203a, 0x9c, 0x9d, 0x9e, 0x9f,
+ 0xa0, 0x385, 0x386, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xf8f9, 0xab, 0xac, 0xad, 0xae, 0x2015,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0x384, 0xb5, 0xb6, 0xb7,
+ 0x388, 0x389, 0x38a, 0xbb, 0x38c, 0xbd, 0x38e, 0x38f,
+ 0x390, 0x391, 0x392, 0x393, 0x394, 0x395, 0x396, 0x397,
+ 0x398, 0x399, 0x39a, 0x39b, 0x39c, 0x39d, 0x39e, 0x39f,
+ 0x3a0, 0x3a1, 0xf8fa, 0x3a3, 0x3a4, 0x3a5, 0x3a6, 0x3a7,
+ 0x3a8, 0x3a9, 0x3aa, 0x3ab, 0x3ac, 0x3ad, 0x3ae, 0x3af,
+ 0x3b0, 0x3b1, 0x3b2, 0x3b3, 0x3b4, 0x3b5, 0x3b6, 0x3b7,
+ 0x3b8, 0x3b9, 0x3ba, 0x3bb, 0x3bc, 0x3bd, 0x3be, 0x3bf,
+ 0x3c0, 0x3c1, 0x3c2, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7,
+ 0x3c8, 0x3c9, 0x3ca, 0x3cb, 0x3cc, 0x3cd, 0x3ce, 0xf8fb },
+ /* CP1254 */
+ { 0x20ac, 0x81, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x2c6, 0x2030, 0x160, 0x2039, 0x152, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x2dc, 0x2122, 0x161, 0x203a, 0x153, 0x9d, 0x9e, 0x178,
+ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0x11e, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0x130, 0x15e, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0x11f, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x131, 0x15f, 0xff },
+ /* CP1255 */
+ { 0x20ac, 0x81, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x2c6, 0x2030, 0x8a, 0x2039, 0x8c, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x2dc, 0x2122, 0x9a, 0x203a, 0x9c, 0x9d, 0x9e, 0x9f,
+ 0xa0, 0xa1, 0xa2, 0xa3, 0x20aa, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xd7, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xf7, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0x5b0, 0x5b1, 0x5b2, 0x5b3, 0x5b4, 0x5b5, 0x5b6, 0x5b7,
+ 0x5b8, 0x5b9, 0x5ba, 0x5bb, 0x5bc, 0x5bd, 0x5be, 0x5bf,
+ 0x5c0, 0x5c1, 0x5c2, 0x5c3, 0x5f0, 0x5f1, 0x5f2, 0x5f3,
+ 0x5f4, 0xf88d, 0xf88e, 0xf88f, 0xf890, 0xf891, 0xf892, 0xf893,
+ 0x5d0, 0x5d1, 0x5d2, 0x5d3, 0x5d4, 0x5d5, 0x5d6, 0x5d7,
+ 0x5d8, 0x5d9, 0x5da, 0x5db, 0x5dc, 0x5dd, 0x5de, 0x5df,
+ 0x5e0, 0x5e1, 0x5e2, 0x5e3, 0x5e4, 0x5e5, 0x5e6, 0x5e7,
+ 0x5e8, 0x5e9, 0x5ea, 0xf894, 0xf895, 0x200e, 0x200f, 0xf896 },
+ /* CP1256 */
+ { 0x20ac, 0x67e, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x2c6, 0x2030, 0x679, 0x2039, 0x152, 0x686, 0x698, 0x688,
+ 0x6af, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x6a9, 0x2122, 0x691, 0x203a, 0x153, 0x200c, 0x200d, 0x6ba,
+ 0xa0, 0x60c, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0x6be, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0x61b, 0xbb, 0xbc, 0xbd, 0xbe, 0x61f,
+ 0x6c1, 0x621, 0x622, 0x623, 0x624, 0x625, 0x626, 0x627,
+ 0x628, 0x629, 0x62a, 0x62b, 0x62c, 0x62d, 0x62e, 0x62f,
+ 0x630, 0x631, 0x632, 0x633, 0x634, 0x635, 0x636, 0xd7,
+ 0x637, 0x638, 0x639, 0x63a, 0x640, 0x641, 0x642, 0x643,
+ 0xe0, 0x644, 0xe2, 0x645, 0x646, 0x647, 0x648, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0x649, 0x64a, 0xee, 0xef,
+ 0x64b, 0x64c, 0x64d, 0x64e, 0xf4, 0x64f, 0x650, 0xf7,
+ 0x651, 0xf9, 0x652, 0xfb, 0xfc, 0x200e, 0x200f, 0x6d2 },
+ /* CP1257 */
+ { 0x20ac, 0x81, 0x201a, 0x83, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x88, 0x2030, 0x8a, 0x2039, 0x8c, 0xa8, 0x2c7, 0xb8,
+ 0x90, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x98, 0x2122, 0x9a, 0x203a, 0x9c, 0xaf, 0x2db, 0x9f,
+ 0xa0, 0xf8fc, 0xa2, 0xa3, 0xa4, 0xf8fd, 0xa6, 0xa7,
+ 0xd8, 0xa9, 0x156, 0xab, 0xac, 0xad, 0xae, 0xc6,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xf8, 0xb9, 0x157, 0xbb, 0xbc, 0xbd, 0xbe, 0xe6,
+ 0x104, 0x12e, 0x100, 0x106, 0xc4, 0xc5, 0x118, 0x112,
+ 0x10c, 0xc9, 0x179, 0x116, 0x122, 0x136, 0x12a, 0x13b,
+ 0x160, 0x143, 0x145, 0xd3, 0x14c, 0xd5, 0xd6, 0xd7,
+ 0x172, 0x141, 0x15a, 0x16a, 0xdc, 0x17b, 0x17d, 0xdf,
+ 0x105, 0x12f, 0x101, 0x107, 0xe4, 0xe5, 0x119, 0x113,
+ 0x10d, 0xe9, 0x17a, 0x117, 0x123, 0x137, 0x12b, 0x13c,
+ 0x161, 0x144, 0x146, 0xf3, 0x14d, 0xf5, 0xf6, 0xf7,
+ 0x173, 0x142, 0x15b, 0x16b, 0xfc, 0x17c, 0x17e, 0x2d9 },
+ /* CP1258 */
+ { 0x20ac, 0x81, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021,
+ 0x2c6, 0x2030, 0x8a, 0x2039, 0x152, 0x8d, 0x8e, 0x8f,
+ 0x90, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014,
+ 0x2dc, 0x2122, 0x9a, 0x203a, 0x153, 0x9d, 0x9e, 0x178,
+ 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
+ 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
+ 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
+ 0xc0, 0xc1, 0xc2, 0x102, 0xc4, 0xc5, 0xc6, 0xc7,
+ 0xc8, 0xc9, 0xca, 0xcb, 0x300, 0xcd, 0xce, 0xcf,
+ 0x110, 0xd1, 0x309, 0xd3, 0xd4, 0x1a0, 0xd6, 0xd7,
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0x1af, 0x303, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0x103, 0xe4, 0xe5, 0xe6, 0xe7,
+ 0xe8, 0xe9, 0xea, 0xeb, 0x301, 0xed, 0xee, 0xef,
+ 0x111, 0xf1, 0x323, 0xf3, 0xf4, 0x1a1, 0xf6, 0xf7,
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x1b0, 0x20ab, 0xff },
+ /* CP20866 (KOI8-R) */
+ { 0x2500, 0x2502, 0x250c, 0x2510, 0x2514, 0x2518, 0x251c, 0x2524,
+ 0x252c, 0x2534, 0x253c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590,
+ 0x2591, 0x2592, 0x2593, 0x2320, 0x25a0, 0x2219, 0x221a, 0x2248,
+ 0x2264, 0x2265, 0xa0, 0x2321, 0xb0, 0xb2, 0xb7, 0xf7,
+ 0x2550, 0x2551, 0x2552, 0x451, 0x2553, 0x2554, 0x2555, 0x2556,
+ 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, 0x255e,
+ 0x255f, 0x2560, 0x2561, 0x401, 0x2562, 0x2563, 0x2564, 0x2565,
+ 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0xa9,
+ 0x44e, 0x430, 0x431, 0x446, 0x434, 0x435, 0x444, 0x433,
+ 0x445, 0x438, 0x439, 0x43a, 0x43b, 0x43c, 0x43d, 0x43e,
+ 0x43f, 0x44f, 0x440, 0x441, 0x442, 0x443, 0x436, 0x432,
+ 0x44c, 0x44b, 0x437, 0x448, 0x44d, 0x449, 0x447, 0x44a,
+ 0x42e, 0x410, 0x411, 0x426, 0x414, 0x415, 0x424, 0x413,
+ 0x425, 0x418, 0x419, 0x41a, 0x41b, 0x41c, 0x41d, 0x41e,
+ 0x41f, 0x42f, 0x420, 0x421, 0x422, 0x423, 0x416, 0x412,
+ 0x42c, 0x42b, 0x417, 0x428, 0x42d, 0x429, 0x427, 0x42a },
+ /* CP21866 (KOI8-U) */
+ { 0x2500, 0x2502, 0x250c, 0x2510, 0x2514, 0x2518, 0x251c, 0x2524,
+ 0x252c, 0x2534, 0x253c, 0x2580, 0x2584, 0x2588, 0x258c, 0x2590,
+ 0x2591, 0x2592, 0x2593, 0x2320, 0x25a0, 0x2219, 0x221a, 0x2248,
+ 0x2264, 0x2265, 0xa0, 0x2321, 0xb0, 0xb2, 0xb7, 0xf7,
+ 0x2550, 0x2551, 0x2552, 0x451, 0x454, 0x2554, 0x456, 0x457,
+ 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x491, 0x45e, 0x255e,
+ 0x255f, 0x2560, 0x2561, 0x401, 0x404, 0x2563, 0x406, 0x407,
+ 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x490, 0x40e, 0xa9,
+ 0x44e, 0x430, 0x431, 0x446, 0x434, 0x435, 0x444, 0x433,
+ 0x445, 0x438, 0x439, 0x43a, 0x43b, 0x43c, 0x43d, 0x43e,
+ 0x43f, 0x44f, 0x440, 0x441, 0x442, 0x443, 0x436, 0x432,
+ 0x44c, 0x44b, 0x437, 0x448, 0x44d, 0x449, 0x447, 0x44a,
+ 0x42e, 0x410, 0x411, 0x426, 0x414, 0x415, 0x424, 0x413,
+ 0x425, 0x418, 0x419, 0x41a, 0x41b, 0x41c, 0x41d, 0x41e,
+ 0x41f, 0x42f, 0x420, 0x421, 0x422, 0x423, 0x416, 0x412,
+ 0x42c, 0x42b, 0x417, 0x428, 0x42d, 0x429, 0x427, 0x42a }
+};
+#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
+
+/* Handle one to five decimal digits. Return -1 in any other case. */
+static int
+__micro_atoi (const char *s)
+{
+ int ret = 0;
+
+ if (!*s)
+ return -1;
+ while (*s)
+ {
+ if (*s < '0' || *s > '9' || ret >= 100000)
+ return -1;
+ ret = 10 * ret + (*s++ - '0');
+ }
+ return ret;
+}
+
+#ifdef _MB_EXTENDED_CHARSETS_ISO
+int
+__iso_8859_index (const char *charset_ext)
+{
+ int iso_idx = __micro_atoi (charset_ext);
+ if (iso_idx >= 2 && iso_idx <= 16)
+ {
+ iso_idx -= 2;
+ if (iso_idx > 10)
+ --iso_idx;
+ return iso_idx;
+ }
+ return -1;
+}
+#endif /* _MB_EXTENDED_CHARSETS_ISO */
+
+#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
+int
+__cp_index (const char *charset_ext)
+{
+ int cp_idx = __micro_atoi (charset_ext);
+ switch (cp_idx)
+ {
+ case 437:
+ cp_idx = 0;
+ break;
+ case 720:
+ cp_idx = 1;
+ break;
+ case 737:
+ cp_idx = 2;
+ break;
+ case 775:
+ cp_idx = 3;
+ break;
+ case 850:
+ cp_idx = 4;
+ break;
+ case 852:
+ cp_idx = 5;
+ break;
+ case 855:
+ cp_idx = 6;
+ break;
+ case 857:
+ cp_idx = 7;
+ break;
+ case 858:
+ cp_idx = 8;
+ break;
+ case 862:
+ cp_idx = 9;
+ break;
+ case 866:
+ cp_idx = 10;
+ break;
+ case 874:
+ cp_idx = 11;
+ break;
+ case 1125:
+ cp_idx = 12;
+ break;
+ case 1250:
+ cp_idx = 13;
+ break;
+ case 1251:
+ cp_idx = 14;
+ break;
+ case 1252:
+ cp_idx = 15;
+ break;
+ case 1253:
+ cp_idx = 16;
+ break;
+ case 1254:
+ cp_idx = 17;
+ break;
+ case 1255:
+ cp_idx = 18;
+ break;
+ case 1256:
+ cp_idx = 19;
+ break;
+ case 1257:
+ cp_idx = 20;
+ break;
+ case 1258:
+ cp_idx = 21;
+ break;
+ case 20866:
+ cp_idx = 22;
+ break;
+ case 21866:
+ cp_idx = 23;
+ break;
+ default:
+ cp_idx = -1;
+ break;
+ }
+ return cp_idx;
+}
+#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
+#endif /* _MB_CAPABLE */
sb_charsets.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mbstowcs.c
===================================================================
--- mbstowcs.c (nonexistent)
+++ mbstowcs.c (revision 345)
@@ -0,0 +1,83 @@
+/*
+FUNCTION
+<>---minimal multibyte string to wide char converter
+
+INDEX
+ mbstowcs
+
+ANSI_SYNOPSIS
+ #include
+ int mbstowcs(wchar_t *<[pwc]>, const char *<[s]>, size_t <[n]>);
+
+TRAD_SYNOPSIS
+ #include
+ int mbstowcs(<[pwc]>, <[s]>, <[n]>)
+ wchar_t *<[pwc]>;
+ const char *<[s]>;
+ size_t <[n]>;
+
+DESCRIPTION
+When _MB_CAPABLE is not defined, this is a minimal ANSI-conforming
+implementation of <>. In this case, the
+only ``multi-byte character sequences'' recognized are single bytes,
+and they are ``converted'' to wide-char versions simply by byte
+extension.
+
+When _MB_CAPABLE is defined, this routine calls <<_mbstowcs_r>> to perform
+the conversion, passing a state variable to allow state dependent
+decoding. The result is based on the locale setting which may
+be restricted to a defined set of locales.
+
+RETURNS
+This implementation of <> returns <<0>> if
+<[s]> is <> or is the empty string;
+it returns <<-1>> if _MB_CAPABLE and one of the
+multi-byte characters is invalid or incomplete;
+otherwise it returns the minimum of: <> or the
+number of multi-byte characters in <> plus 1 (to
+compensate for the nul character).
+If the return value is -1, the state of the <> string is
+indeterminate. If the input has a length of 0, the output
+string will be modified to contain a wchar_t nul terminator.
+
+PORTABILITY
+<> is required in the ANSI C standard. However, the precise
+effects vary with the locale.
+
+<> requires no supporting OS subroutines.
+*/
+
+#ifndef _REENT_ONLY
+
+#include
+#include
+#include
+
+size_t
+_DEFUN (mbstowcs, (pwcs, s, n),
+ wchar_t *pwcs _AND
+ const char *s _AND
+ size_t n)
+{
+#ifdef _MB_CAPABLE
+ mbstate_t state;
+ state.__count = 0;
+
+ return _mbstowcs_r (_REENT, pwcs, s, n, &state);
+#else /* not _MB_CAPABLE */
+
+ int count = 0;
+
+ if (n != 0) {
+ do {
+ if ((*pwcs++ = (wchar_t) *s++) == 0)
+ break;
+ count++;
+ } while (--n != 0);
+ }
+
+ return count;
+#endif /* not _MB_CAPABLE */
+}
+
+#endif /* !_REENT_ONLY */
mbstowcs.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: getopt.c
===================================================================
--- getopt.c (nonexistent)
+++ getopt.c (revision 345)
@@ -0,0 +1,479 @@
+/****************************************************************************
+
+getopt.c - Read command line options
+
+AUTHOR: Gregory Pietsch
+CREATED Fri Jan 10 21:13:05 1997
+
+DESCRIPTION:
+
+The getopt() function parses the command line arguments. Its arguments argc
+and argv are the argument count and array as passed to the main() function
+on program invocation. The argument optstring is a list of available option
+characters. If such a character is followed by a colon (`:'), the option
+takes an argument, which is placed in optarg. If such a character is
+followed by two colons, the option takes an optional argument, which is
+placed in optarg. If the option does not take an argument, optarg is NULL.
+
+The external variable optind is the index of the next array element of argv
+to be processed; it communicates from one call to the next which element to
+process.
+
+The getopt_long() function works like getopt() except that it also accepts
+long options started by two dashes `--'. If these take values, it is either
+in the form
+
+--arg=value
+
+ or
+
+--arg value
+
+It takes the additional arguments longopts which is a pointer to the first
+element of an array of type struct option. The last element of the array
+has to be filled with NULL for the name field.
+
+The longind pointer points to the index of the current long option relative
+to longopts if it is non-NULL.
+
+The getopt() function returns the option character if the option was found
+successfully, `:' if there was a missing parameter for one of the options,
+`?' for an unknown option character, and EOF for the end of the option list.
+
+The getopt_long() function's return value is described in the header file.
+
+The function getopt_long_only() is identical to getopt_long(), except that a
+plus sign `+' can introduce long options as well as `--'.
+
+The following describes how to deal with options that follow non-option
+argv-elements.
+
+If the caller did not specify anything, the default is REQUIRE_ORDER if the
+environment variable POSIXLY_CORRECT is defined, PERMUTE otherwise.
+
+REQUIRE_ORDER means don't recognize them as options; stop option processing
+when the first non-option is seen. This is what Unix does. This mode of
+operation is selected by either setting the environment variable
+POSIXLY_CORRECT, or using `+' as the first character of the optstring
+parameter.
+
+PERMUTE is the default. We permute the contents of ARGV as we scan, so that
+eventually all the non-options are at the end. This allows options to be
+given in any order, even with programs that were not written to expect this.
+
+RETURN_IN_ORDER is an option available to programs that were written to
+expect options and other argv-elements in any order and that care about the
+ordering of the two. We describe each non-option argv-element as if it were
+the argument of an option with character code 1. Using `-' as the first
+character of the optstring parameter selects this mode of operation.
+
+The special argument `--' forces an end of option-scanning regardless of the
+value of ordering. In the case of RETURN_IN_ORDER, only `--' can cause
+getopt() and friends to return EOF with optind != argc.
+
+COPYRIGHT NOTICE AND DISCLAIMER:
+
+Copyright (C) 1997 Gregory Pietsch
+
+This file and the accompanying getopt.h header file are hereby placed in the
+public domain without restrictions. Just give the author credit, don't
+claim you wrote it or prevent anyone else from using it.
+
+Gregory Pietsch's current e-mail address:
+gpietsch@comcast.net
+****************************************************************************/
+
+#ifndef HAVE_GETOPT
+
+/* include files */
+#include
+#include
+#include
+#define __need_getopt_newlib
+#include
+
+/* macros */
+
+/* types */
+typedef enum GETOPT_ORDERING_T
+{
+ PERMUTE,
+ RETURN_IN_ORDER,
+ REQUIRE_ORDER
+} GETOPT_ORDERING_T;
+
+/* globally-defined variables */
+char *optarg = 0;
+int optind = 0;
+int opterr = 1;
+int optopt = '?';
+
+/* static variables */
+static int optwhere = 0;
+
+/* functions */
+
+/* reverse_argv_elements: reverses num elements starting at argv */
+static void
+reverse_argv_elements (char **argv, int num)
+{
+ int i;
+ char *tmp;
+
+ for (i = 0; i < (num >> 1); i++)
+ {
+ tmp = argv[i];
+ argv[i] = argv[num - i - 1];
+ argv[num - i - 1] = tmp;
+ }
+}
+
+/* permute: swap two blocks of argv-elements given their lengths */
+static void
+permute (char *const argv[], int len1, int len2)
+{
+ reverse_argv_elements ((char **) argv, len1);
+ reverse_argv_elements ((char **) argv, len1 + len2);
+ reverse_argv_elements ((char **) argv, len2);
+}
+
+/* is_option: is this argv-element an option or the end of the option list? */
+static int
+is_option (char *argv_element, int only)
+{
+ return ((argv_element == 0)
+ || (argv_element[0] == '-') || (only && argv_element[0] == '+'));
+}
+
+/* read_globals: read the values from the globals into a getopt_data
+ structure */
+static void
+read_globals (struct getopt_data *data)
+{
+ data->optarg = optarg;
+ data->optind = optind;
+ data->opterr = opterr;
+ data->optopt = optopt;
+ data->optwhere = optwhere;
+}
+
+/* write_globals: write the values into the globals from a getopt_data
+ structure */
+static void
+write_globals (struct getopt_data *data)
+{
+ optarg = data->optarg;
+ optind = data->optind;
+ opterr = data->opterr;
+ optopt = data->optopt;
+ optwhere = data->optwhere;
+}
+
+/* getopt_internal: the function that does all the dirty work */
+static int
+getopt_internal (int argc, char *const argv[], const char *shortopts,
+ const struct option *longopts, int *longind, int only,
+ struct getopt_data *data)
+{
+ GETOPT_ORDERING_T ordering = PERMUTE;
+ size_t permute_from = 0;
+ int num_nonopts = 0;
+ int optindex = 0;
+ size_t match_chars = 0;
+ char *possible_arg = 0;
+ int longopt_match = -1;
+ int has_arg = -1;
+ char *cp = 0;
+ int arg_next = 0;
+
+ /* first, deal with silly parameters and easy stuff */
+ if (argc == 0 || argv == 0 || (shortopts == 0 && longopts == 0)
+ || data->optind >= argc || argv[data->optind] == 0)
+ return EOF;
+ if (strcmp (argv[data->optind], "--") == 0)
+ {
+ data->optind++;
+ return EOF;
+ }
+
+ /* if this is our first time through */
+ if (data->optind == 0)
+ data->optind = data->optwhere = 1;
+
+ /* define ordering */
+ if (shortopts != 0 && (*shortopts == '-' || *shortopts == '+'))
+ {
+ ordering = (*shortopts == '-') ? RETURN_IN_ORDER : REQUIRE_ORDER;
+ shortopts++;
+ }
+ else
+ ordering = (getenv ("POSIXLY_CORRECT") != 0) ? REQUIRE_ORDER : PERMUTE;
+
+ /*
+ * based on ordering, find our next option, if we're at the beginning of
+ * one
+ */
+ if (data->optwhere == 1)
+ {
+ switch (ordering)
+ {
+ default: /* shouldn't happen */
+ case PERMUTE:
+ permute_from = data->optind;
+ num_nonopts = 0;
+ while (!is_option (argv[data->optind], only))
+ {
+ data->optind++;
+ num_nonopts++;
+ }
+ if (argv[data->optind] == 0)
+ {
+ /* no more options */
+ data->optind = permute_from;
+ return EOF;
+ }
+ else if (strcmp (argv[data->optind], "--") == 0)
+ {
+ /* no more options, but have to get `--' out of the way */
+ permute (argv + permute_from, num_nonopts, 1);
+ data->optind = permute_from + 1;
+ return EOF;
+ }
+ break;
+ case RETURN_IN_ORDER:
+ if (!is_option (argv[data->optind], only))
+ {
+ data->optarg = argv[data->optind++];
+ return (data->optopt = 1);
+ }
+ break;
+ case REQUIRE_ORDER:
+ if (!is_option (argv[data->optind], only))
+ return EOF;
+ break;
+ }
+ }
+ /* we've got an option, so parse it */
+
+ /* first, is it a long option? */
+ if (longopts != 0
+ && (memcmp (argv[data->optind], "--", 2) == 0
+ || (only && argv[data->optind][0] == '+')) && data->optwhere == 1)
+ {
+ /* handle long options */
+ if (memcmp (argv[data->optind], "--", 2) == 0)
+ data->optwhere = 2;
+ longopt_match = -1;
+ possible_arg = strchr (argv[data->optind] + data->optwhere, '=');
+ if (possible_arg == 0)
+ {
+ /* no =, so next argv might be arg */
+ match_chars = strlen (argv[data->optind]);
+ possible_arg = argv[data->optind] + match_chars;
+ match_chars = match_chars - data->optwhere;
+ }
+ else
+ match_chars = (possible_arg - argv[data->optind]) - data->optwhere;
+ for (optindex = 0; longopts[optindex].name != 0; ++optindex)
+ {
+ if (memcmp
+ (argv[data->optind] + data->optwhere, longopts[optindex].name,
+ match_chars) == 0)
+ {
+ /* do we have an exact match? */
+ if (match_chars == (int) (strlen (longopts[optindex].name)))
+ {
+ longopt_match = optindex;
+ break;
+ }
+ /* do any characters match? */
+ else
+ {
+ if (longopt_match < 0)
+ longopt_match = optindex;
+ else
+ {
+ /* we have ambiguous options */
+ if (data->opterr)
+ fprintf (stderr, "%s: option `%s' is ambiguous "
+ "(could be `--%s' or `--%s')\n",
+ argv[0],
+ argv[data->optind],
+ longopts[longopt_match].name,
+ longopts[optindex].name);
+ return (data->optopt = '?');
+ }
+ }
+ }
+ }
+ if (longopt_match >= 0)
+ has_arg = longopts[longopt_match].has_arg;
+ }
+
+ /* if we didn't find a long option, is it a short option? */
+ if (longopt_match < 0 && shortopts != 0)
+ {
+ cp = strchr (shortopts, argv[data->optind][data->optwhere]);
+ if (cp == 0)
+ {
+ /* couldn't find option in shortopts */
+ if (data->opterr)
+ fprintf (stderr,
+ "%s: invalid option -- `-%c'\n",
+ argv[0], argv[data->optind][data->optwhere]);
+ data->optwhere++;
+ if (argv[data->optind][data->optwhere] == '\0')
+ {
+ data->optind++;
+ data->optwhere = 1;
+ }
+ return (data->optopt = '?');
+ }
+ has_arg = ((cp[1] == ':')
+ ? ((cp[2] == ':') ? OPTIONAL_ARG : REQUIRED_ARG) : NO_ARG);
+ possible_arg = argv[data->optind] + data->optwhere + 1;
+ data->optopt = *cp;
+ }
+
+ /* get argument and reset data->optwhere */
+ arg_next = 0;
+ switch (has_arg)
+ {
+ case OPTIONAL_ARG:
+ if (*possible_arg == '=')
+ possible_arg++;
+ data->optarg = (*possible_arg != '\0') ? possible_arg : 0;
+ data->optwhere = 1;
+ break;
+ case REQUIRED_ARG:
+ if (*possible_arg == '=')
+ possible_arg++;
+ if (*possible_arg != '\0')
+ {
+ data->optarg = possible_arg;
+ data->optwhere = 1;
+ }
+ else if (data->optind + 1 >= argc)
+ {
+ if (data->opterr)
+ {
+ fprintf (stderr, "%s: argument required for option `", argv[0]);
+ if (longopt_match >= 0)
+ fprintf (stderr, "--%s'\n", longopts[longopt_match].name);
+ else
+ fprintf (stderr, "-%c'\n", *cp);
+ }
+ data->optind++;
+ return (data->optopt = ':');
+ }
+ else
+ {
+ data->optarg = argv[data->optind + 1];
+ arg_next = 1;
+ data->optwhere = 1;
+ }
+ break;
+ default: /* shouldn't happen */
+ case NO_ARG:
+ if (longopt_match < 0)
+ {
+ data->optwhere++;
+ if (argv[data->optind][data->optwhere] == '\0')
+ data->optwhere = 1;
+ }
+ else
+ data->optwhere = 1;
+ data->optarg = 0;
+ break;
+ }
+
+ /* do we have to permute or otherwise modify data->optind? */
+ if (ordering == PERMUTE && data->optwhere == 1 && num_nonopts != 0)
+ {
+ permute (argv + permute_from, num_nonopts, 1 + arg_next);
+ data->optind = permute_from + 1 + arg_next;
+ }
+ else if (data->optwhere == 1)
+ data->optind = data->optind + 1 + arg_next;
+
+ /* finally return */
+ if (longopt_match >= 0)
+ {
+ if (longind != 0)
+ *longind = longopt_match;
+ if (longopts[longopt_match].flag != 0)
+ {
+ *(longopts[longopt_match].flag) = longopts[longopt_match].val;
+ return 0;
+ }
+ else
+ return longopts[longopt_match].val;
+ }
+ else
+ return data->optopt;
+}
+
+int
+getopt (int argc, char *const argv[], const char *optstring)
+{
+ struct getopt_data data;
+ int r;
+
+ read_globals (&data);
+ r = getopt_internal (argc, argv, optstring, 0, 0, 0, &data);
+ write_globals (&data);
+ return r;
+}
+
+int
+getopt_long (int argc, char *const argv[], const char *shortopts,
+ const struct option *longopts, int *longind)
+{
+ struct getopt_data data;
+ int r;
+
+ read_globals (&data);
+ r = getopt_internal (argc, argv, shortopts, longopts, longind, 0, &data);
+ write_globals (&data);
+ return r;
+}
+
+int
+getopt_long_only (int argc, char *const argv[], const char *shortopts,
+ const struct option *longopts, int *longind)
+{
+ struct getopt_data data;
+ int r;
+
+ read_globals (&data);
+ r = getopt_internal (argc, argv, shortopts, longopts, longind, 1, &data);
+ write_globals (&data);
+ return r;
+}
+
+int
+__getopt_r (int argc, char *const argv[], const char *optstring,
+ struct getopt_data *data)
+{
+ return getopt_internal (argc, argv, optstring, 0, 0, 0, data);
+}
+
+int
+__getopt_long_r (int argc, char *const argv[], const char *shortopts,
+ const struct option *longopts, int *longind,
+ struct getopt_data *data)
+{
+ return getopt_internal (argc, argv, shortopts, longopts, longind, 0, data);
+}
+
+int
+__getopt_long_only_r (int argc, char *const argv[], const char *shortopts,
+ const struct option *longopts, int *longind,
+ struct getopt_data *data)
+{
+ return getopt_internal (argc, argv, shortopts, longopts, longind, 1, data);
+}
+
+#endif /* !HAVE_GETOPT */
+
+/* end of file GETOPT.C */
getopt.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcstod.c
===================================================================
--- wcstod.c (nonexistent)
+++ wcstod.c (revision 345)
@@ -0,0 +1,230 @@
+/*
+FUNCTION
+ <>, <>---wide char string to double or float
+
+INDEX
+ wcstod
+INDEX
+ _wcstod_r
+INDEX
+ wcstof
+INDEX
+ _wcstof_r
+
+ANSI_SYNOPSIS
+ #include
+ double wcstod(const wchar_t *<[str]>, wchar_t **<[tail]>);
+ float wcstof(const wchar_t *<[str]>, wchar_t **<[tail]>);
+
+ double _wcstod_r(void *<[reent]>,
+ const wchar_t *<[str]>, wchar_t **<[tail]>);
+ float _wcstof_r(void *<[reent]>,
+ const wchar_t *<[str]>, wchar_t **<[tail]>);
+
+TRAD_SYNOPSIS
+ #include
+ double wcstod(<[str]>,<[tail]>)
+ wchar_t *<[str]>;
+ wchar_t **<[tail]>;
+
+ float wcstof(<[str]>,<[tail]>)
+ wchar_t *<[str]>;
+ wchar_t **<[tail]>;
+
+ double _wcstod_r(<[reent]>,<[str]>,<[tail]>)
+ wchar_t *<[reent]>;
+ wchar_t *<[str]>;
+ wchar_t **<[tail]>;
+
+ float _wcstof_r(<[reent]>,<[str]>,<[tail]>)
+ wchar_t *<[reent]>;
+ wchar_t *<[str]>;
+ wchar_t **<[tail]>;
+
+DESCRIPTION
+ The function <> parses the wide character string <[str]>,
+ producing a substring which can be converted to a double
+ value. The substring converted is the longest initial
+ subsequence of <[str]>, beginning with the first
+ non-whitespace character, that has one of these formats:
+ .[+|-]<[digits]>[.[<[digits]>]][(e|E)[+|-]<[digits]>]
+ .[+|-].<[digits]>[(e|E)[+|-]<[digits]>]
+ .[+|-](i|I)(n|N)(f|F)[(i|I)(n|N)(i|I)(t|T)(y|Y)]
+ .[+|-](n|N)(a|A)(n|N)[<(>[<[hexdigits]>]<)>]
+ .[+|-]0(x|X)<[hexdigits]>[.[<[hexdigits]>]][(p|P)[+|-]<[digits]>]
+ .[+|-]0(x|X).<[hexdigits]>[(p|P)[+|-]<[digits]>]
+ The substring contains no characters if <[str]> is empty, consists
+ entirely of whitespace, or if the first non-whitespace
+ character is something other than <<+>>, <<->>, <<.>>, or a
+ digit, and cannot be parsed as infinity or NaN. If the platform
+ does not support NaN, then NaN is treated as an empty substring.
+ If the substring is empty, no conversion is done, and
+ the value of <[str]> is stored in <<*<[tail]>>>. Otherwise,
+ the substring is converted, and a pointer to the final string
+ (which will contain at least the terminating null character of
+ <[str]>) is stored in <<*<[tail]>>>. If you want no
+ assignment to <<*<[tail]>>>, pass a null pointer as <[tail]>.
+ <> is identical to <> except for its return type.
+
+ This implementation returns the nearest machine number to the
+ input decimal string. Ties are broken by using the IEEE
+ round-even rule. However, <> is currently subject to
+ double rounding errors.
+
+ The alternate functions <<_wcstod_r>> and <<_wcstof_r>> are
+ reentrant versions of <> and <>, respectively.
+ The extra argument <[reent]> is a pointer to a reentrancy structure.
+
+RETURNS
+ Return the converted substring value, if any. If
+ no conversion could be performed, 0 is returned. If the
+ correct value is out of the range of representable values,
+ plus or minus <> is returned, and <> is
+ stored in errno. If the correct value would cause underflow, 0
+ is returned and <> is stored in errno.
+
+Supporting OS subroutines required: <>, <>, <>,
+<>, <>, <>, <>.
+*/
+
+/*-
+ * Copyright (c) 2002 Tim J. Robbins
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+double
+_DEFUN (_wcstod_r, (ptr, nptr, endptr),
+ struct _reent *ptr _AND
+ _CONST wchar_t *nptr _AND
+ wchar_t **endptr)
+{
+ static const mbstate_t initial;
+ mbstate_t mbs;
+ double val;
+ char *buf, *end;
+ const wchar_t *wcp;
+ size_t len;
+
+ while (iswspace(*nptr))
+ nptr++;
+
+ /*
+ * Convert the supplied numeric wide char. string to multibyte.
+ *
+ * We could attempt to find the end of the numeric portion of the
+ * wide char. string to avoid converting unneeded characters but
+ * choose not to bother; optimising the uncommon case where
+ * the input string contains a lot of text after the number
+ * duplicates a lot of strtod()'s functionality and slows down the
+ * most common cases.
+ */
+ wcp = nptr;
+ mbs = initial;
+ if ((len = _wcsrtombs_r(ptr, NULL, &wcp, 0, &mbs)) == (size_t)-1) {
+ if (endptr != NULL)
+ *endptr = (wchar_t *)nptr;
+ return (0.0);
+ }
+ if ((buf = _malloc_r(ptr, len + 1)) == NULL)
+ return (0.0);
+ mbs = initial;
+ _wcsrtombs_r(ptr, buf, &wcp, len + 1, &mbs);
+
+ /* Let strtod() do most of the work for us. */
+ val = _strtod_r(ptr, buf, &end);
+
+ /*
+ * We only know where the number ended in the _multibyte_
+ * representation of the string. If the caller wants to know
+ * where it ended, count multibyte characters to find the
+ * corresponding position in the wide char string.
+ */
+ if (endptr != NULL) {
+ /* The only valid multibyte char in a float converted by
+ strtod/wcstod is the radix char. What we do here is,
+ figure out if the radix char was in the valid leading
+ float sequence in the incoming string. If so, the
+ multibyte float string is strlen(radix char) - 1 bytes
+ longer than the incoming wide char string has characters.
+ To fix endptr, reposition end as if the radix char was
+ just one byte long. The resulting difference (end - buf)
+ is then equivalent to the number of valid wide characters
+ in the input string. */
+ len = strlen (_localeconv_r (ptr)->decimal_point);
+ if (len > 1) {
+ char *d = strstr (buf,
+ _localeconv_r (ptr)->decimal_point);
+ if (d && d < end)
+ end -= len - 1;
+ }
+ *endptr = (wchar_t *)nptr + (end - buf);
+ }
+
+ _free_r(ptr, buf);
+
+ return (val);
+}
+
+float
+_DEFUN (_wcstof_r, (ptr, nptr, endptr),
+ struct _reent *ptr _AND
+ _CONST wchar_t *nptr _AND
+ wchar_t **endptr)
+{
+ double retval = _wcstod_r (ptr, nptr, endptr);
+ if (isnan (retval))
+ return nanf (NULL);
+ return (float)retval;
+}
+
+#ifndef _REENT_ONLY
+
+double
+_DEFUN (wcstod, (nptr, endptr),
+ _CONST wchar_t *nptr _AND wchar_t **endptr)
+{
+ return _wcstod_r (_REENT, nptr, endptr);
+}
+
+float
+_DEFUN (wcstof, (nptr, endptr),
+ _CONST wchar_t *nptr _AND
+ wchar_t **endptr)
+{
+ double retval = _wcstod_r (_REENT, nptr, endptr);
+ if (isnan (retval))
+ return nanf (NULL);
+ return (float)retval;
+}
+
+#endif
wcstod.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: atexit.h
===================================================================
--- atexit.h (nonexistent)
+++ atexit.h (revision 345)
@@ -0,0 +1,14 @@
+/*
+ * Common definitions for atexit-like routines
+ */
+
+enum __atexit_types
+{
+ __et_atexit,
+ __et_onexit,
+ __et_cxa
+};
+
+void __call_exitprocs _PARAMS ((int, _PTR));
+int __register_exitproc _PARAMS ((int, void (*fn) (void), _PTR, _PTR));
+
atexit.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: ldtoa.c
===================================================================
--- ldtoa.c (nonexistent)
+++ ldtoa.c (revision 345)
@@ -0,0 +1,3743 @@
+ /* Extended precision arithmetic functions for long double I/O.
+ * This program has been placed in the public domain.
+ */
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include "mprec.h"
+
+/* These are the externally visible entries. */
+/* linux name: long double _IO_strtold (char *, char **); */
+long double _strtold (char *, char **);
+char * _ldtoa_r (struct _reent *, long double, int, int, int *, int *, char **);
+int _ldcheck (long double *);
+#if 0
+void _IO_ldtostr(long double *, char *, int, int, char);
+#endif
+
+ /* Number of 16 bit words in external x type format */
+ #define NE 10
+
+ /* Number of 16 bit words in internal format */
+ #define NI (NE+3)
+
+ /* Array offset to exponent */
+ #define E 1
+
+ /* Array offset to high guard word */
+ #define M 2
+
+ /* Number of bits of precision */
+ #define NBITS ((NI-4)*16)
+
+ /* Maximum number of decimal digits in ASCII conversion
+ * = NBITS*log10(2)
+ */
+ #define NDEC (NBITS*8/27)
+
+ /* The exponent of 1.0 */
+ #define EXONE (0x3fff)
+
+ /* Maximum exponent digits - base 10 */
+ #define MAX_EXP_DIGITS 5
+
+/* Control structure for long double conversion including rounding precision values.
+ * rndprc can be set to 80 (if NE=6), 64, 56, 53, or 24 bits.
+ */
+typedef struct
+{
+ int rlast;
+ int rndprc;
+ int rw;
+ int re;
+ int outexpon;
+ unsigned short rmsk;
+ unsigned short rmbit;
+ unsigned short rebit;
+ unsigned short rbit[NI];
+ unsigned short equot[NI];
+} LDPARMS;
+
+static void esub(short unsigned int *a, short unsigned int *b, short unsigned int *c, LDPARMS *ldp);
+static void emul(short unsigned int *a, short unsigned int *b, short unsigned int *c, LDPARMS *ldp);
+static void ediv(short unsigned int *a, short unsigned int *b, short unsigned int *c, LDPARMS *ldp);
+static int ecmp(short unsigned int *a, short unsigned int *b);
+static int enormlz(short unsigned int *x);
+static int eshift(short unsigned int *x, int sc);
+static void eshup1(register short unsigned int *x);
+static void eshup8(register short unsigned int *x);
+static void eshup6(register short unsigned int *x);
+static void eshdn1(register short unsigned int *x);
+static void eshdn8(register short unsigned int *x);
+static void eshdn6(register short unsigned int *x);
+static void eneg(short unsigned int *x);
+static void emov(register short unsigned int *a, register short unsigned int *b);
+static void eclear(register short unsigned int *x);
+static void einfin(register short unsigned int *x, register LDPARMS *ldp);
+static void efloor(short unsigned int *x, short unsigned int *y, LDPARMS *ldp);
+static void etoasc(short unsigned int *x, char *string, int ndigs, int outformat, LDPARMS *ldp);
+
+union uconv
+{
+ unsigned short pe;
+ long double d;
+};
+
+#if LDBL_MANT_DIG == 24
+static void e24toe(short unsigned int *pe, short unsigned int *y, LDPARMS *ldp);
+#elif LDBL_MANT_DIG == 53
+static void e53toe(short unsigned int *pe, short unsigned int *y, LDPARMS *ldp);
+#elif LDBL_MANT_DIG == 64
+static void e64toe(short unsigned int *pe, short unsigned int *y, LDPARMS *ldp);
+#else
+static void e113toe(short unsigned int *pe, short unsigned int *y, LDPARMS *ldp);
+#endif
+
+/* econst.c */
+/* e type constants used by high precision check routines */
+
+#if NE == 10
+/* 0.0 */
+static unsigned short ezero[NE] =
+ {0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,};
+
+/* 1.0E0 */
+static unsigned short eone[NE] =
+ {0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x8000, 0x3fff,};
+
+#else
+
+/* 0.0 */
+static unsigned short ezero[NE] = {
+0, 0000000,0000000,0000000,0000000,0000000,};
+/* 1.0E0 */
+static unsigned short eone[NE] = {
+0, 0000000,0000000,0000000,0100000,0x3fff,};
+
+#endif
+
+/* Debugging routine for displaying errors */
+#ifdef DEBUG
+/* Notice: the order of appearance of the following
+ * messages is bound to the error codes defined
+ * in mconf.h.
+ */
+static char *ermsg[7] = {
+"unknown", /* error code 0 */
+"domain", /* error code 1 */
+"singularity", /* et seq. */
+"overflow",
+"underflow",
+"total loss of precision",
+"partial loss of precision"
+};
+#define mtherr(name, code) printf( "\n%s %s error\n", name, ermsg[code] );
+#else
+#define mtherr(name, code)
+#endif
+
+/* ieee.c
+ *
+ * Extended precision IEEE binary floating point arithmetic routines
+ *
+ * Numbers are stored in C language as arrays of 16-bit unsigned
+ * short integers. The arguments of the routines are pointers to
+ * the arrays.
+ *
+ *
+ * External e type data structure, simulates Intel 8087 chip
+ * temporary real format but possibly with a larger significand:
+ *
+ * NE-1 significand words (least significant word first,
+ * most significant bit is normally set)
+ * exponent (value = EXONE for 1.0,
+ * top bit is the sign)
+ *
+ *
+ * Internal data structure of a number (a "word" is 16 bits):
+ *
+ * ei[0] sign word (0 for positive, 0xffff for negative)
+ * ei[1] biased exponent (value = EXONE for the number 1.0)
+ * ei[2] high guard word (always zero after normalization)
+ * ei[3]
+ * to ei[NI-2] significand (NI-4 significand words,
+ * most significant word first,
+ * most significant bit is set)
+ * ei[NI-1] low guard word (0x8000 bit is rounding place)
+ *
+ *
+ *
+ * Routines for external format numbers
+ *
+ * asctoe( string, e ) ASCII string to extended double e type
+ * asctoe64( string, &d ) ASCII string to long double
+ * asctoe53( string, &d ) ASCII string to double
+ * asctoe24( string, &f ) ASCII string to single
+ * asctoeg( string, e, prec, ldp ) ASCII string to specified precision
+ * e24toe( &f, e, ldp ) IEEE single precision to e type
+ * e53toe( &d, e, ldp ) IEEE double precision to e type
+ * e64toe( &d, e, ldp ) IEEE long double precision to e type
+ * e113toe( &d, e, ldp ) IEEE long double precision to e type
+ * eabs(e) absolute value
+ * eadd( a, b, c ) c = b + a
+ * eclear(e) e = 0
+ * ecmp (a, b) Returns 1 if a > b, 0 if a == b,
+ * -1 if a < b, -2 if either a or b is a NaN.
+ * ediv( a, b, c, ldp ) c = b / a
+ * efloor( a, b, ldp ) truncate to integer, toward -infinity
+ * efrexp( a, exp, s ) extract exponent and significand
+ * eifrac( e, &l, frac ) e to long integer and e type fraction
+ * euifrac( e, &l, frac ) e to unsigned long integer and e type fraction
+ * einfin( e, ldp ) set e to infinity, leaving its sign alone
+ * eldexp( a, n, b ) multiply by 2**n
+ * emov( a, b ) b = a
+ * emul( a, b, c, ldp ) c = b * a
+ * eneg(e) e = -e
+ * eround( a, b ) b = nearest integer value to a
+ * esub( a, b, c, ldp ) c = b - a
+ * e24toasc( &f, str, n ) single to ASCII string, n digits after decimal
+ * e53toasc( &d, str, n ) double to ASCII string, n digits after decimal
+ * e64toasc( &d, str, n ) long double to ASCII string
+ * etoasc(e,str,n,fmt,ldp)e to ASCII string, n digits after decimal
+ * etoe24( e, &f ) convert e type to IEEE single precision
+ * etoe53( e, &d ) convert e type to IEEE double precision
+ * etoe64( e, &d ) convert e type to IEEE long double precision
+ * ltoe( &l, e ) long (32 bit) integer to e type
+ * ultoe( &l, e ) unsigned long (32 bit) integer to e type
+ * eisneg( e ) 1 if sign bit of e != 0, else 0
+ * eisinf( e ) 1 if e has maximum exponent (non-IEEE)
+ * or is infinite (IEEE)
+ * eisnan( e ) 1 if e is a NaN
+ * esqrt( a, b ) b = square root of a
+ *
+ *
+ * Routines for internal format numbers
+ *
+ * eaddm( ai, bi ) add significands, bi = bi + ai
+ * ecleaz(ei) ei = 0
+ * ecleazs(ei) set ei = 0 but leave its sign alone
+ * ecmpm( ai, bi ) compare significands, return 1, 0, or -1
+ * edivm( ai, bi, ldp ) divide significands, bi = bi / ai
+ * emdnorm(ai,l,s,exp,ldp) normalize and round off
+ * emovi( a, ai ) convert external a to internal ai
+ * emovo( ai, a, ldp ) convert internal ai to external a
+ * emovz( ai, bi ) bi = ai, low guard word of bi = 0
+ * emulm( ai, bi, ldp ) multiply significands, bi = bi * ai
+ * enormlz(ei) left-justify the significand
+ * eshdn1( ai ) shift significand and guards down 1 bit
+ * eshdn8( ai ) shift down 8 bits
+ * eshdn6( ai ) shift down 16 bits
+ * eshift( ai, n ) shift ai n bits up (or down if n < 0)
+ * eshup1( ai ) shift significand and guards up 1 bit
+ * eshup8( ai ) shift up 8 bits
+ * eshup6( ai ) shift up 16 bits
+ * esubm( ai, bi ) subtract significands, bi = bi - ai
+ *
+ *
+ * The result is always normalized and rounded to NI-4 word precision
+ * after each arithmetic operation.
+ *
+ * Exception flags are NOT fully supported.
+ *
+ * Define USE_INFINITY in mconf.h for support of infinity; otherwise a
+ * saturation arithmetic is implemented.
+ *
+ * Define NANS for support of Not-a-Number items; otherwise the
+ * arithmetic will never produce a NaN output, and might be confused
+ * by a NaN input.
+ * If NaN's are supported, the output of ecmp(a,b) is -2 if
+ * either a or b is a NaN. This means asking if(ecmp(a,b) < 0)
+ * may not be legitimate. Use if(ecmp(a,b) == -1) for less-than
+ * if in doubt.
+ * Signaling NaN's are NOT supported; they are treated the same
+ * as quiet NaN's.
+ *
+ * Denormals are always supported here where appropriate (e.g., not
+ * for conversion to DEC numbers).
+ */
+
+/*
+ * Revision history:
+ *
+ * 5 Jan 84 PDP-11 assembly language version
+ * 6 Dec 86 C language version
+ * 30 Aug 88 100 digit version, improved rounding
+ * 15 May 92 80-bit long double support
+ * 22 Nov 00 Revised to fit into newlib by Jeff Johnston
+ *
+ * Author: S. L. Moshier.
+ *
+ * Copyright (c) 1984,2000 S.L. Moshier
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose without fee is hereby granted, provided that this entire notice
+ * is included in all copies of any software which is or includes a copy
+ * or modification of this software and in all copies of the supporting
+ * documentation for such software.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY. IN PARTICULAR, THE AUTHOR MAKES NO REPRESENTATION
+ * OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS
+ * SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ *
+ */
+
+#include
+/* #include "\usr\include\stdio.h" */
+/*#include "ehead.h"*/
+/*#include "mconf.h"*/
+/* mconf.h
+ *
+ * Common include file for math routines
+ *
+ *
+ *
+ * SYNOPSIS:
+ *
+ * #include "mconf.h"
+ *
+ *
+ *
+ * DESCRIPTION:
+ *
+ * This file contains definitions for error codes that are
+ * passed to the common error handling routine mtherr()
+ * (which see).
+ *
+ * The file also includes a conditional assembly definition
+ * for the type of computer arithmetic (IEEE, DEC, Motorola
+ * IEEE, or UNKnown).
+ *
+ * For Digital Equipment PDP-11 and VAX computers, certain
+ * IBM systems, and others that use numbers with a 56-bit
+ * significand, the symbol DEC should be defined. In this
+ * mode, most floating point constants are given as arrays
+ * of octal integers to eliminate decimal to binary conversion
+ * errors that might be introduced by the compiler.
+ *
+ * For computers, such as IBM PC, that follow the IEEE
+ * Standard for Binary Floating Point Arithmetic (ANSI/IEEE
+ * Std 754-1985), the symbol IBMPC should be defined. These
+ * numbers have 53-bit significands. In this mode, constants
+ * are provided as arrays of hexadecimal 16 bit integers.
+ *
+ * To accommodate other types of computer arithmetic, all
+ * constants are also provided in a normal decimal radix
+ * which one can hope are correctly converted to a suitable
+ * format by the available C language compiler. To invoke
+ * this mode, the symbol UNK is defined.
+ *
+ * An important difference among these modes is a predefined
+ * set of machine arithmetic constants for each. The numbers
+ * MACHEP (the machine roundoff error), MAXNUM (largest number
+ * represented), and several other parameters are preset by
+ * the configuration symbol. Check the file const.c to
+ * ensure that these values are correct for your computer.
+ *
+ * For ANSI C compatibility, define ANSIC equal to 1. Currently
+ * this affects only the atan2() function and others that use it.
+ */
+
+/* Constant definitions for math error conditions
+ */
+
+#define DOMAIN 1 /* argument domain error */
+#define SING 2 /* argument singularity */
+#define OVERFLOW 3 /* overflow range error */
+#define UNDERFLOW 4 /* underflow range error */
+#define TLOSS 5 /* total loss of precision */
+#define PLOSS 6 /* partial loss of precision */
+
+#define EDOM 33
+#define ERANGE 34
+
+typedef struct
+ {
+ double r;
+ double i;
+ }cmplx;
+
+/* Type of computer arithmetic */
+
+#ifndef DEC
+#ifdef __IEEE_LITTLE_ENDIAN
+#define IBMPC 1
+#else /* !__IEEE_LITTLE_ENDIAN */
+#define MIEEE 1
+#endif /* !__IEEE_LITTLE_ENDIAN */
+#endif /* !DEC */
+
+/* Define 1 for ANSI C atan2() function
+ * See atan.c and clog.c.
+ */
+#define ANSIC 1
+
+/*define VOLATILE volatile*/
+#define VOLATILE
+
+#define NANS
+#define USE_INFINITY
+
+/* NaN's require infinity support. */
+#ifdef NANS
+#ifndef INFINITY
+#define USE_INFINITY
+#endif
+#endif
+
+/* This handles 64-bit long ints. */
+#define LONGBITS (8 * sizeof(long))
+
+
+static void eaddm(short unsigned int *x, short unsigned int *y);
+static void esubm(short unsigned int *x, short unsigned int *y);
+static void emdnorm(short unsigned int *s, int lost, int subflg, long int exp, int rcntrl, LDPARMS *ldp);
+static int asctoeg(char *ss, short unsigned int *y, int oprec, LDPARMS *ldp);
+static void enan(short unsigned int *nan, int size);
+#if LDBL_MANT_DIG == 24
+static void toe24(short unsigned int *x, short unsigned int *y);
+#elif LDBL_MANT_DIG == 53
+static void toe53(short unsigned int *x, short unsigned int *y);
+#elif LDBL_MANT_DIG == 64
+static void toe64(short unsigned int *a, short unsigned int *b);
+#else
+static void toe113(short unsigned int *a, short unsigned int *b);
+#endif
+static void eiremain(short unsigned int *den, short unsigned int *num, LDPARMS *ldp);
+static int ecmpm(register short unsigned int *a, register short unsigned int *b);
+static int edivm(short unsigned int *den, short unsigned int *num, LDPARMS *ldp);
+static int emulm(short unsigned int *a, short unsigned int *b, LDPARMS *ldp);
+static int eisneg(short unsigned int *x);
+static int eisinf(short unsigned int *x);
+static void emovi(short unsigned int *a, short unsigned int *b);
+static void emovo(short unsigned int *a, short unsigned int *b, LDPARMS *ldp);
+static void emovz(register short unsigned int *a, register short unsigned int *b);
+static void ecleaz(register short unsigned int *xi);
+static void eadd1(short unsigned int *a, short unsigned int *b, short unsigned int *c, int subflg, LDPARMS *ldp);
+static int eisnan(short unsigned int *x);
+static int eiisnan(short unsigned int *x);
+
+#ifdef DEC
+static void etodec(), todec(), dectoe();
+#endif
+
+/*
+; Clear out entire external format number.
+;
+; unsigned short x[];
+; eclear( x );
+*/
+
+static void eclear(register short unsigned int *x)
+{
+register int i;
+
+for( i=0; irndprc < NBITS )
+ {
+ if (ldp->rndprc == 113)
+ {
+ *(x - 9) = 0;
+ *(x - 8) = 0;
+ }
+ if( ldp->rndprc == 64 )
+ {
+ *(x-5) = 0;
+ }
+ if( ldp->rndprc == 53 )
+ {
+ *(x-4) = 0xf800;
+ }
+ else
+ {
+ *(x-4) = 0;
+ *(x-3) = 0;
+ *(x-2) = 0xff00;
+ }
+ }
+#endif
+}
+
+/* Move in external format number,
+ * converting it to internal format.
+ */
+static void emovi(short unsigned int *a, short unsigned int *b)
+{
+register unsigned short *p, *q;
+int i;
+
+q = b;
+p = a + (NE-1); /* point to last word of external number */
+/* get the sign bit */
+if( *p & 0x8000 )
+ *q++ = 0xffff;
+else
+ *q++ = 0;
+/* get the exponent */
+*q = *p--;
+*q++ &= 0x7fff; /* delete the sign bit */
+#ifdef USE_INFINITY
+if( (*(q-1) & 0x7fff) == 0x7fff )
+ {
+#ifdef NANS
+ if( eisnan(a) )
+ {
+ *q++ = 0;
+ for( i=3; i b
+; 0 if a == b
+; -1 if a < b
+*/
+static int ecmpm(register short unsigned int *a, register short unsigned int *b)
+{
+int i;
+
+a += M; /* skip up to significand area */
+b += M;
+for( i=M; i *(--b) )
+ return(1);
+else
+ return(-1);
+}
+
+
+/*
+; Shift significand down by 1 bit
+*/
+
+static void eshdn1(register short unsigned int *x)
+{
+register unsigned short bits;
+int i;
+
+x += M; /* point to significand area */
+
+bits = 0;
+for( i=M; i>= 1;
+ if( bits & 2 )
+ *x |= 0x8000;
+ bits <<= 1;
+ ++x;
+ }
+}
+
+
+
+/*
+; Shift significand up by 1 bit
+*/
+
+static void eshup1(register short unsigned int *x)
+{
+register unsigned short bits;
+int i;
+
+x += NI-1;
+bits = 0;
+
+for( i=M; i>= 8;
+ *x |= oldbyt;
+ oldbyt = newbyt;
+ ++x;
+ }
+}
+
+/*
+; Shift significand up by 8 bits
+*/
+
+static void eshup8(register short unsigned int *x)
+{
+int i;
+register unsigned short newbyt, oldbyt;
+
+x += NI-1;
+oldbyt = 0;
+
+for( i=M; i> 8;
+ *x <<= 8;
+ *x |= oldbyt;
+ oldbyt = newbyt;
+ --x;
+ }
+}
+
+/*
+; Shift significand up by 16 bits
+*/
+
+static void eshup6(register short unsigned int *x)
+{
+int i;
+register unsigned short *p;
+
+p = x + M;
+x += M + 1;
+
+for( i=M; i> 16) + (m >> 16) + *pp;
+ *pp = (unsigned short )carry;
+ *(pp-1) = carry >> 16;
+ }
+ }
+for( i=M; iequot;
+
+p = &equot[0];
+*p++ = num[0];
+*p++ = num[1];
+
+for( i=M; i tdenm )
+ tquot = 0xffff;
+*/
+ /* Multiply denominator by trial quotient digit. */
+ m16m( tquot, den, tprod );
+ /* The quotient digit may have been overestimated. */
+ if( ecmpm( tprod, num ) > 0 )
+ {
+ tquot -= 1;
+ esubm( den, tprod );
+ if( ecmpm( tprod, num ) > 0 )
+ {
+ tquot -= 1;
+ esubm( den, tprod );
+ }
+ }
+/*
+ if( ecmpm( tprod, num ) > 0 )
+ {
+ eshow( "tprod", tprod );
+ eshow( "num ", num );
+ printf( "tnum = %08lx, tden = %04x, tquot = %04x\n",
+ tnum, den[M+1], tquot );
+ }
+*/
+ esubm( tprod, num );
+/*
+ if( ecmpm( num, den ) >= 0 )
+ {
+ eshow( "num ", num );
+ eshow( "den ", den );
+ printf( "tnum = %08lx, tden = %04x, tquot = %04x\n",
+ tnum, den[M+1], tquot );
+ }
+*/
+ equot[i] = tquot;
+ eshup6(num);
+ }
+/* test for nonzero remainder after roundoff bit */
+p = &num[M];
+j = 0;
+for( i=M; iequot;
+
+equot[0] = b[0];
+equot[1] = b[1];
+for( i=M; i NBITS )
+ {
+ ecleazs( s );
+ return;
+ }
+#endif
+exp -= j;
+#ifndef USE_INFINITY
+if( exp >= 32767L )
+ goto overf;
+#else
+if( (j > NBITS) && (exp < 32767L) )
+ {
+ ecleazs( s );
+ return;
+ }
+#endif
+if( exp < 0L )
+ {
+ if( exp > (long )(-NBITS-1) )
+ {
+ j = (int )exp;
+ i = eshift( s, j );
+ if( i )
+ lost = 1;
+ }
+ else
+ {
+ ecleazs( s );
+ return;
+ }
+ }
+/* Round off, unless told not to by rcntrl. */
+if( rcntrl == 0 )
+ goto mdfin;
+/* Set up rounding parameters if the control register changed. */
+if( ldp->rndprc != ldp->rlast )
+ {
+ ecleaz( ldp->rbit );
+ switch( ldp->rndprc )
+ {
+ default:
+ case NBITS:
+ ldp->rw = NI-1; /* low guard word */
+ ldp->rmsk = 0xffff;
+ ldp->rmbit = 0x8000;
+ ldp->rebit = 1;
+ ldp->re = ldp->rw - 1;
+ break;
+ case 113:
+ ldp->rw = 10;
+ ldp->rmsk = 0x7fff;
+ ldp->rmbit = 0x4000;
+ ldp->rebit = 0x8000;
+ ldp->re = ldp->rw;
+ break;
+ case 64:
+ ldp->rw = 7;
+ ldp->rmsk = 0xffff;
+ ldp->rmbit = 0x8000;
+ ldp->rebit = 1;
+ ldp->re = ldp->rw-1;
+ break;
+/* For DEC arithmetic */
+ case 56:
+ ldp->rw = 6;
+ ldp->rmsk = 0xff;
+ ldp->rmbit = 0x80;
+ ldp->rebit = 0x100;
+ ldp->re = ldp->rw;
+ break;
+ case 53:
+ ldp->rw = 6;
+ ldp->rmsk = 0x7ff;
+ ldp->rmbit = 0x0400;
+ ldp->rebit = 0x800;
+ ldp->re = ldp->rw;
+ break;
+ case 24:
+ ldp->rw = 4;
+ ldp->rmsk = 0xff;
+ ldp->rmbit = 0x80;
+ ldp->rebit = 0x100;
+ ldp->re = ldp->rw;
+ break;
+ }
+ ldp->rbit[ldp->re] = ldp->rebit;
+ ldp->rlast = ldp->rndprc;
+ }
+
+/* Shift down 1 temporarily if the data structure has an implied
+ * most significant bit and the number is denormal.
+ * For rndprc = 64 or NBITS, there is no implied bit.
+ * But Intel long double denormals lose one bit of significance even so.
+ */
+#if IBMPC
+if( (exp <= 0) && (ldp->rndprc != NBITS) )
+#else
+if( (exp <= 0) && (ldp->rndprc != 64) && (ldp->rndprc != NBITS) )
+#endif
+ {
+ lost |= s[NI-1] & 1;
+ eshdn1(s);
+ }
+/* Clear out all bits below the rounding bit,
+ * remembering in r if any were nonzero.
+ */
+r = s[ldp->rw] & ldp->rmsk;
+if( ldp->rndprc < NBITS )
+ {
+ i = ldp->rw + 1;
+ while( i < NI )
+ {
+ if( s[i] )
+ r |= 1;
+ s[i] = 0;
+ ++i;
+ }
+ }
+s[ldp->rw] &= ~ldp->rmsk;
+if( (r & ldp->rmbit) != 0 )
+ {
+ if( r == ldp->rmbit )
+ {
+ if( lost == 0 )
+ { /* round to even */
+ if( (s[ldp->re] & ldp->rebit) == 0 )
+ goto mddone;
+ }
+ else
+ {
+ if( subflg != 0 )
+ goto mddone;
+ }
+ }
+ eaddm( ldp->rbit, s );
+ }
+mddone:
+#if IBMPC
+if( (exp <= 0) && (ldp->rndprc != NBITS) )
+#else
+if( (exp <= 0) && (ldp->rndprc != 64) && (ldp->rndprc != NBITS) )
+#endif
+ {
+ eshup1(s);
+ }
+if( s[2] != 0 )
+ { /* overflow on roundoff */
+ eshdn1(s);
+ exp += 1;
+ }
+mdfin:
+s[NI-1] = 0;
+if( exp >= 32767L )
+ {
+#ifndef USE_INFINITY
+overf:
+#endif
+#ifdef USE_INFINITY
+ s[1] = 32767;
+ for( i=2; irndprc < 64) || (ldp->rndprc == 113) )
+ {
+ s[ldp->rw] &= ~ldp->rmsk;
+ if( ldp->rndprc == 24 )
+ {
+ s[5] = 0;
+ s[6] = 0;
+ }
+ }
+#endif
+ return;
+ }
+if( exp < 0 )
+ s[1] = 0;
+else
+ s[1] = (unsigned short )exp;
+}
+
+
+
+/*
+; Subtract external format numbers.
+;
+; unsigned short a[NE], b[NE], c[NE];
+; LDPARMS *ldp;
+; esub( a, b, c, ldp ); c = b - a
+*/
+
+static void esub(short unsigned int *a, short unsigned int *b, short unsigned int *c, LDPARMS *ldp)
+{
+
+#ifdef NANS
+if( eisnan(a) )
+ {
+ emov (a, c);
+ return;
+ }
+if( eisnan(b) )
+ {
+ emov(b,c);
+ return;
+ }
+/* Infinity minus infinity is a NaN.
+ * Test for subtracting infinities of the same sign.
+ */
+if( eisinf(a) && eisinf(b) && ((eisneg (a) ^ eisneg (b)) == 0))
+ {
+ mtherr( "esub", DOMAIN );
+ enan( c, NBITS );
+ return;
+ }
+#endif
+eadd1( a, b, c, 1, ldp );
+}
+
+
+
+static void eadd1(short unsigned int *a, short unsigned int *b, short unsigned int *c, int subflg, LDPARMS *ldp)
+{
+unsigned short ai[NI], bi[NI], ci[NI];
+int i, lost, j, k;
+long lt, lta, ltb;
+
+#ifdef USE_INFINITY
+if( eisinf(a) )
+ {
+ emov(a,c);
+ if( subflg )
+ eneg(c);
+ return;
+ }
+if( eisinf(b) )
+ {
+ emov(b,c);
+ return;
+ }
+#endif
+emovi( a, ai );
+emovi( b, bi );
+if( subflg )
+ ai[0] = ~ai[0];
+
+/* compare exponents */
+lta = ai[E];
+ltb = bi[E];
+lt = lta - ltb;
+if( lt > 0L )
+ { /* put the larger number in bi */
+ emovz( bi, ci );
+ emovz( ai, bi );
+ emovz( ci, ai );
+ ltb = bi[E];
+ lt = -lt;
+ }
+lost = 0;
+if( lt != 0L )
+ {
+ if( lt < (long )(-NBITS-1) )
+ goto done; /* answer same as larger addend */
+ k = (int )lt;
+ lost = eshift( ai, k ); /* shift the smaller number down */
+ }
+else
+ {
+/* exponents were the same, so must compare significands */
+ i = ecmpm( ai, bi );
+ if( i == 0 )
+ { /* the numbers are identical in magnitude */
+ /* if different signs, result is zero */
+ if( ai[0] != bi[0] )
+ {
+ eclear(c);
+ return;
+ }
+ /* if same sign, result is double */
+ /* double denomalized tiny number */
+ if( (bi[E] == 0) && ((bi[3] & 0x8000) == 0) )
+ {
+ eshup1( bi );
+ goto done;
+ }
+ /* add 1 to exponent unless both are zero! */
+ for( j=1; j 0 )
+ { /* put the larger number in bi */
+ emovz( bi, ci );
+ emovz( ai, bi );
+ emovz( ci, ai );
+ }
+ }
+if( ai[0] == bi[0] )
+ {
+ eaddm( ai, bi );
+ subflg = 0;
+ }
+else
+ {
+ esubm( ai, bi );
+ subflg = 1;
+ }
+emdnorm( bi, lost, subflg, ltb, 64, ldp );
+
+done:
+emovo( bi, c, ldp );
+}
+
+
+
+/*
+; Divide.
+;
+; unsigned short a[NE], b[NE], c[NE];
+; LDPARMS *ldp;
+; ediv( a, b, c, ldp ); c = b / a
+*/
+static void ediv(short unsigned int *a, short unsigned int *b, short unsigned int *c, LDPARMS *ldp)
+{
+unsigned short ai[NI], bi[NI];
+int i;
+long lt, lta, ltb;
+
+#ifdef NANS
+/* Return any NaN input. */
+if( eisnan(a) )
+ {
+ emov(a,c);
+ return;
+ }
+if( eisnan(b) )
+ {
+ emov(b,c);
+ return;
+ }
+/* Zero over zero, or infinity over infinity, is a NaN. */
+if( ((ecmp(a,ezero) == 0) && (ecmp(b,ezero) == 0))
+ || (eisinf (a) && eisinf (b)) )
+ {
+ mtherr( "ediv", DOMAIN );
+ enan( c, NBITS );
+ return;
+ }
+#endif
+/* Infinity over anything else is infinity. */
+#ifdef USE_INFINITY
+if( eisinf(b) )
+ {
+ if( eisneg(a) ^ eisneg(b) )
+ *(c+(NE-1)) = 0x8000;
+ else
+ *(c+(NE-1)) = 0;
+ einfin(c, ldp);
+ return;
+ }
+if( eisinf(a) )
+ {
+ eclear(c);
+ return;
+ }
+#endif
+emovi( a, ai );
+emovi( b, bi );
+lta = ai[E];
+ltb = bi[E];
+if( bi[E] == 0 )
+ { /* See if numerator is zero. */
+ for( i=1; i 64
+static void e113toe(short unsigned int *pe, short unsigned int *y, LDPARMS *ldp)
+{
+register unsigned short r;
+unsigned short *e, *p;
+unsigned short yy[NI];
+int denorm, i;
+
+e = pe;
+denorm = 0;
+ecleaz(yy);
+#ifdef IBMPC
+e += 7;
+#endif
+r = *e;
+yy[0] = 0;
+if( r & 0x8000 )
+ yy[0] = 0xffff;
+r &= 0x7fff;
+#ifdef USE_INFINITY
+if( r == 0x7fff )
+ {
+#ifdef NANS
+#ifdef IBMPC
+ for( i=0; i<7; i++ )
+ {
+ if( pe[i] != 0 )
+ {
+ enan( y, NBITS );
+ return;
+ }
+ }
+#else /* !IBMPC */
+ for( i=1; i<8; i++ )
+ {
+ if( pe[i] != 0 )
+ {
+ enan( y, NBITS );
+ return;
+ }
+ }
+#endif /* !IBMPC */
+#endif /* NANS */
+ eclear( y );
+ einfin( y, ldp );
+ if( *e & 0x8000 )
+ eneg(y);
+ return;
+ }
+#endif /* INFINITY */
+yy[E] = r;
+p = &yy[M + 1];
+#ifdef IBMPC
+for( i=0; i<7; i++ )
+ *p++ = *(--e);
+#else /* IBMPC */
+++e;
+for( i=0; i<7; i++ )
+ *p++ = *e++;
+#endif /* IBMPC */
+/* If denormal, remove the implied bit; else shift down 1. */
+if( r == 0 )
+ {
+ yy[M] = 0;
+ }
+else
+ {
+ yy[M] = 1;
+ eshift( yy, -1 );
+ }
+emovo(yy,y,ldp);
+}
+
+/* move out internal format to ieee long double */
+static void toe113(short unsigned int *a, short unsigned int *b)
+{
+register unsigned short *p, *q;
+unsigned short i;
+
+#ifdef NANS
+if( eiisnan(a) )
+ {
+ enan( b, 113 );
+ return;
+ }
+#endif
+p = a;
+#ifdef MIEEE
+q = b;
+#else
+q = b + 7; /* point to output exponent */
+#endif
+
+/* If not denormal, delete the implied bit. */
+if( a[E] != 0 )
+ {
+ eshup1 (a);
+ }
+/* combine sign and exponent */
+i = *p++;
+#ifdef MIEEE
+if( i )
+ *q++ = *p++ | 0x8000;
+else
+ *q++ = *p++;
+#else
+if( i )
+ *q-- = *p++ | 0x8000;
+else
+ *q-- = *p++;
+#endif
+/* skip over guard word */
+++p;
+/* move the significand */
+#ifdef MIEEE
+for (i = 0; i < 7; i++)
+ *q++ = *p++;
+#else
+for (i = 0; i < 7; i++)
+ *q-- = *p++;
+#endif
+}
+#endif /* LDBL_MANT_DIG > 64 */
+
+
+#if LDBL_MANT_DIG == 64
+static void e64toe(short unsigned int *pe, short unsigned int *y, LDPARMS *ldp)
+{
+unsigned short yy[NI];
+unsigned short *p, *q, *e;
+int i;
+
+e = pe;
+p = yy;
+
+for( i=0; i>= 4;
+/* If zero exponent, then the significand is denormalized.
+ * So, take back the understood high significand bit. */
+if( r == 0 )
+ {
+ denorm = 1;
+ yy[M] &= ~0x10;
+ }
+r += EXONE - 01777;
+yy[E] = r;
+p = &yy[M+1];
+#ifdef IBMPC
+*p++ = *(--e);
+*p++ = *(--e);
+*p++ = *(--e);
+#else /* !IBMPC */
+++e;
+*p++ = *e++;
+*p++ = *e++;
+*p++ = *e++;
+#endif /* !IBMPC */
+(void )eshift( yy, -5 );
+if( denorm )
+ { /* if zero exponent, then normalize the significand */
+ if( (k = enormlz(yy)) > NBITS )
+ ecleazs(yy);
+ else
+ yy[E] -= (unsigned short )(k-1);
+ }
+emovo( yy, y, ldp );
+#endif /* !DEC */
+}
+
+/*
+; e type to IEEE double precision
+; double d;
+; unsigned short x[NE];
+; etoe53( x, &d );
+*/
+
+#ifdef DEC
+
+static void etoe53( x, e )
+unsigned short *x, *e;
+{
+etodec( x, e ); /* see etodec.c */
+}
+
+static void toe53( x, y )
+unsigned short *x, *y;
+{
+todec( x, y );
+}
+
+#else
+
+static void toe53(short unsigned int *x, short unsigned int *y)
+{
+unsigned short i;
+unsigned short *p;
+
+
+#ifdef NANS
+if( eiisnan(x) )
+ {
+ enan( y, 53 );
+ return;
+ }
+#endif
+p = &x[0];
+#ifdef IBMPC
+y += 3;
+#endif
+#ifdef DEC
+y += 3;
+#endif
+*y = 0; /* output high order */
+if( *p++ )
+ *y = 0x8000; /* output sign bit */
+
+i = *p++;
+if( i >= (unsigned int )2047 )
+ { /* Saturate at largest number less than infinity. */
+#ifdef USE_INFINITY
+ *y |= 0x7ff0;
+#ifdef IBMPC
+ *(--y) = 0;
+ *(--y) = 0;
+ *(--y) = 0;
+#else /* !IBMPC */
+ ++y;
+ *y++ = 0;
+ *y++ = 0;
+ *y++ = 0;
+#endif /* IBMPC */
+#else /* !USE_INFINITY */
+ *y |= (unsigned short )0x7fef;
+#ifdef IBMPC
+ *(--y) = 0xffff;
+ *(--y) = 0xffff;
+ *(--y) = 0xffff;
+#else /* !IBMPC */
+ ++y;
+ *y++ = 0xffff;
+ *y++ = 0xffff;
+ *y++ = 0xffff;
+#endif
+#endif /* !USE_INFINITY */
+ return;
+ }
+if( i == 0 )
+ {
+ (void )eshift( x, 4 );
+ }
+else
+ {
+ i <<= 4;
+ (void )eshift( x, 5 );
+ }
+i |= *p++ & (unsigned short )0x0f; /* *p = xi[M] */
+*y |= (unsigned short )i; /* high order output already has sign bit set */
+#ifdef IBMPC
+*(--y) = *p++;
+*(--y) = *p++;
+*(--y) = *p;
+#else /* !IBMPC */
+++y;
+*y++ = *p++;
+*y++ = *p++;
+*y++ = *p++;
+#endif /* !IBMPC */
+}
+
+#endif /* not DEC */
+#endif /* LDBL_MANT_DIG == 53 */
+
+#if LDBL_MANT_DIG == 24
+/*
+; Convert IEEE single precision to e type
+; float d;
+; unsigned short x[N+2];
+; dtox( &d, x );
+*/
+void e24toe( short unsigned int *pe, short unsigned int *y, LDPARMS *ldp )
+{
+register unsigned short r;
+register unsigned short *p, *e;
+unsigned short yy[NI];
+int denorm, k;
+
+e = pe;
+denorm = 0; /* flag if denormalized number */
+ecleaz(yy);
+#ifdef IBMPC
+e += 1;
+#endif
+#ifdef DEC
+e += 1;
+#endif
+r = *e;
+yy[0] = 0;
+if( r & 0x8000 )
+ yy[0] = 0xffff;
+yy[M] = (r & 0x7f) | 0200;
+r &= ~0x807f; /* strip sign and 7 significand bits */
+#ifdef USE_INFINITY
+if( r == 0x7f80 )
+ {
+#ifdef NANS
+#ifdef MIEEE
+ if( ((pe[0] & 0x7f) != 0) || (pe[1] != 0) )
+ {
+ enan( y, NBITS );
+ return;
+ }
+#else /* !MIEEE */
+ if( ((pe[1] & 0x7f) != 0) || (pe[0] != 0) )
+ {
+ enan( y, NBITS );
+ return;
+ }
+#endif /* !MIEEE */
+#endif /* NANS */
+ eclear( y );
+ einfin( y, ldp );
+ if( yy[0] )
+ eneg(y);
+ return;
+ }
+#endif
+r >>= 7;
+/* If zero exponent, then the significand is denormalized.
+ * So, take back the understood high significand bit. */
+if( r == 0 )
+ {
+ denorm = 1;
+ yy[M] &= ~0200;
+ }
+r += EXONE - 0177;
+yy[E] = r;
+p = &yy[M+1];
+#ifdef IBMPC
+*p++ = *(--e);
+#endif
+#ifdef DEC
+*p++ = *(--e);
+#endif
+#ifdef MIEEE
+++e;
+*p++ = *e++;
+#endif
+(void )eshift( yy, -8 );
+if( denorm )
+ { /* if zero exponent, then normalize the significand */
+ if( (k = enormlz(yy)) > NBITS )
+ ecleazs(yy);
+ else
+ yy[E] -= (unsigned short )(k-1);
+ }
+emovo( yy, y, ldp );
+}
+
+static void toe24(short unsigned int *x, short unsigned int *y)
+{
+unsigned short i;
+unsigned short *p;
+
+#ifdef NANS
+if( eiisnan(x) )
+ {
+ enan( y, 24 );
+ return;
+ }
+#endif
+p = &x[0];
+#ifdef IBMPC
+y += 1;
+#endif
+#ifdef DEC
+y += 1;
+#endif
+*y = 0; /* output high order */
+if( *p++ )
+ *y = 0x8000; /* output sign bit */
+
+i = *p++;
+if( i >= 255 )
+ { /* Saturate at largest number less than infinity. */
+#ifdef USE_INFINITY
+ *y |= (unsigned short )0x7f80;
+#ifdef IBMPC
+ *(--y) = 0;
+#endif
+#ifdef DEC
+ *(--y) = 0;
+#endif
+#ifdef MIEEE
+ ++y;
+ *y = 0;
+#endif
+#else /* !USE_INFINITY */
+ *y |= (unsigned short )0x7f7f;
+#ifdef IBMPC
+ *(--y) = 0xffff;
+#endif
+#ifdef DEC
+ *(--y) = 0xffff;
+#endif
+#ifdef MIEEE
+ ++y;
+ *y = 0xffff;
+#endif
+#endif /* !USE_INFINITY */
+ return;
+ }
+if( i == 0 )
+ {
+ (void )eshift( x, 7 );
+ }
+else
+ {
+ i <<= 7;
+ (void )eshift( x, 8 );
+ }
+i |= *p++ & (unsigned short )0x7f; /* *p = xi[M] */
+*y |= i; /* high order output already has sign bit set */
+#ifdef IBMPC
+*(--y) = *p;
+#endif
+#ifdef DEC
+*(--y) = *p;
+#endif
+#ifdef MIEEE
+++y;
+*y = *p;
+#endif
+}
+#endif /* LDBL_MANT_DIG == 24 */
+
+/* Compare two e type numbers.
+ *
+ * unsigned short a[NE], b[NE];
+ * ecmp( a, b );
+ *
+ * returns +1 if a > b
+ * 0 if a == b
+ * -1 if a < b
+ * -2 if either a or b is a NaN.
+ */
+static int ecmp(short unsigned int *a, short unsigned int *b)
+{
+unsigned short ai[NI], bi[NI];
+register unsigned short *p, *q;
+register int i;
+int msign;
+
+#ifdef NANS
+if (eisnan (a) || eisnan (b))
+ return( -2 );
+#endif
+emovi( a, ai );
+p = ai;
+emovi( b, bi );
+q = bi;
+
+if( *p != *q )
+ { /* the signs are different */
+/* -0 equals + 0 */
+ for( i=1; i 0 );
+
+return(0); /* equality */
+
+
+
+diff:
+
+if( *(--p) > *(--q) )
+ return( msign ); /* p is bigger */
+else
+ return( -msign ); /* p is littler */
+}
+
+
+/*
+; Shift significand
+;
+; Shifts significand area up or down by the number of bits
+; given by the variable sc.
+*/
+static int eshift(short unsigned int *x, int sc)
+{
+unsigned short lost;
+unsigned short *p;
+
+if( sc == 0 )
+ return( 0 );
+
+lost = 0;
+p = x + NI-1;
+
+if( sc < 0 )
+ {
+ sc = -sc;
+ while( sc >= 16 )
+ {
+ lost |= *p; /* remember lost bits */
+ eshdn6(x);
+ sc -= 16;
+ }
+
+ while( sc >= 8 )
+ {
+ lost |= *p & 0xff;
+ eshdn8(x);
+ sc -= 8;
+ }
+
+ while( sc > 0 )
+ {
+ lost |= *p & 1;
+ eshdn1(x);
+ sc -= 1;
+ }
+ }
+else
+ {
+ while( sc >= 16 )
+ {
+ eshup6(x);
+ sc -= 16;
+ }
+
+ while( sc >= 8 )
+ {
+ eshup8(x);
+ sc -= 8;
+ }
+
+ while( sc > 0 )
+ {
+ eshup1(x);
+ sc -= 1;
+ }
+ }
+if( lost )
+ lost = 1;
+return( (int )lost );
+}
+
+
+
+/*
+; normalize
+;
+; Shift normalizes the significand area pointed to by argument
+; shift count (up = positive) is returned.
+*/
+static int enormlz(short unsigned int *x)
+{
+register unsigned short *p;
+int sc;
+
+sc = 0;
+p = &x[M];
+if( *p != 0 )
+ goto normdn;
+++p;
+if( *p & 0x8000 )
+ return( 0 ); /* already normalized */
+while( *p == 0 )
+ {
+ eshup6(x);
+ sc += 16;
+/* With guard word, there are NBITS+16 bits available.
+ * return true if all are zero.
+ */
+ if( sc > NBITS )
+ return( sc );
+ }
+/* see if high byte is zero */
+while( (*p & 0xff00) == 0 )
+ {
+ eshup8(x);
+ sc += 8;
+ }
+/* now shift 1 bit at a time */
+while( (*p & 0x8000) == 0)
+ {
+ eshup1(x);
+ sc += 1;
+ if( sc > (NBITS+16) )
+ {
+ mtherr( "enormlz", UNDERFLOW );
+ return( sc );
+ }
+ }
+return( sc );
+
+/* Normalize by shifting down out of the high guard word
+ of the significand */
+normdn:
+
+if( *p & 0xff00 )
+ {
+ eshdn8(x);
+ sc -= 8;
+ }
+while( *p != 0 )
+ {
+ eshdn1(x);
+ sc -= 1;
+
+ if( sc < -NBITS )
+ {
+ mtherr( "enormlz", OVERFLOW );
+ return( sc );
+ }
+ }
+return( sc );
+}
+
+
+
+
+/* Convert e type number to decimal format ASCII string.
+ * The constants are for 64 bit precision.
+ */
+
+#define NTEN 12
+#define MAXP 4096
+
+#if NE == 10
+static unsigned short etens[NTEN + 1][NE] =
+{
+ {0x6576, 0x4a92, 0x804a, 0x153f,
+ 0xc94c, 0x979a, 0x8a20, 0x5202, 0xc460, 0x7525,}, /* 10**4096 */
+ {0x6a32, 0xce52, 0x329a, 0x28ce,
+ 0xa74d, 0x5de4, 0xc53d, 0x3b5d, 0x9e8b, 0x5a92,}, /* 10**2048 */
+ {0x526c, 0x50ce, 0xf18b, 0x3d28,
+ 0x650d, 0x0c17, 0x8175, 0x7586, 0xc976, 0x4d48,},
+ {0x9c66, 0x58f8, 0xbc50, 0x5c54,
+ 0xcc65, 0x91c6, 0xa60e, 0xa0ae, 0xe319, 0x46a3,},
+ {0x851e, 0xeab7, 0x98fe, 0x901b,
+ 0xddbb, 0xde8d, 0x9df9, 0xebfb, 0xaa7e, 0x4351,},
+ {0x0235, 0x0137, 0x36b1, 0x336c,
+ 0xc66f, 0x8cdf, 0x80e9, 0x47c9, 0x93ba, 0x41a8,},
+ {0x50f8, 0x25fb, 0xc76b, 0x6b71,
+ 0x3cbf, 0xa6d5, 0xffcf, 0x1f49, 0xc278, 0x40d3,},
+ {0x0000, 0x0000, 0x0000, 0x0000,
+ 0xf020, 0xb59d, 0x2b70, 0xada8, 0x9dc5, 0x4069,},
+ {0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0400, 0xc9bf, 0x8e1b, 0x4034,},
+ {0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x2000, 0xbebc, 0x4019,},
+ {0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x9c40, 0x400c,},
+ {0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0xc800, 0x4005,},
+ {0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0xa000, 0x4002,}, /* 10**1 */
+};
+
+static unsigned short emtens[NTEN + 1][NE] =
+{
+ {0x2030, 0xcffc, 0xa1c3, 0x8123,
+ 0x2de3, 0x9fde, 0xd2ce, 0x04c8, 0xa6dd, 0x0ad8,}, /* 10**-4096 */
+ {0x8264, 0xd2cb, 0xf2ea, 0x12d4,
+ 0x4925, 0x2de4, 0x3436, 0x534f, 0xceae, 0x256b,}, /* 10**-2048 */
+ {0xf53f, 0xf698, 0x6bd3, 0x0158,
+ 0x87a6, 0xc0bd, 0xda57, 0x82a5, 0xa2a6, 0x32b5,},
+ {0xe731, 0x04d4, 0xe3f2, 0xd332,
+ 0x7132, 0xd21c, 0xdb23, 0xee32, 0x9049, 0x395a,},
+ {0xa23e, 0x5308, 0xfefb, 0x1155,
+ 0xfa91, 0x1939, 0x637a, 0x4325, 0xc031, 0x3cac,},
+ {0xe26d, 0xdbde, 0xd05d, 0xb3f6,
+ 0xac7c, 0xe4a0, 0x64bc, 0x467c, 0xddd0, 0x3e55,},
+ {0x2a20, 0x6224, 0x47b3, 0x98d7,
+ 0x3f23, 0xe9a5, 0xa539, 0xea27, 0xa87f, 0x3f2a,},
+ {0x0b5b, 0x4af2, 0xa581, 0x18ed,
+ 0x67de, 0x94ba, 0x4539, 0x1ead, 0xcfb1, 0x3f94,},
+ {0xbf71, 0xa9b3, 0x7989, 0xbe68,
+ 0x4c2e, 0xe15b, 0xc44d, 0x94be, 0xe695, 0x3fc9,},
+ {0x3d4d, 0x7c3d, 0x36ba, 0x0d2b,
+ 0xfdc2, 0xcefc, 0x8461, 0x7711, 0xabcc, 0x3fe4,},
+ {0xc155, 0xa4a8, 0x404e, 0x6113,
+ 0xd3c3, 0x652b, 0xe219, 0x1758, 0xd1b7, 0x3ff1,},
+ {0xd70a, 0x70a3, 0x0a3d, 0xa3d7,
+ 0x3d70, 0xd70a, 0x70a3, 0x0a3d, 0xa3d7, 0x3ff8,},
+ {0xcccd, 0xcccc, 0xcccc, 0xcccc,
+ 0xcccc, 0xcccc, 0xcccc, 0xcccc, 0xcccc, 0x3ffb,}, /* 10**-1 */
+};
+#else
+static unsigned short etens[NTEN+1][NE] = {
+{0xc94c,0x979a,0x8a20,0x5202,0xc460,0x7525,},/* 10**4096 */
+{0xa74d,0x5de4,0xc53d,0x3b5d,0x9e8b,0x5a92,},/* 10**2048 */
+{0x650d,0x0c17,0x8175,0x7586,0xc976,0x4d48,},
+{0xcc65,0x91c6,0xa60e,0xa0ae,0xe319,0x46a3,},
+{0xddbc,0xde8d,0x9df9,0xebfb,0xaa7e,0x4351,},
+{0xc66f,0x8cdf,0x80e9,0x47c9,0x93ba,0x41a8,},
+{0x3cbf,0xa6d5,0xffcf,0x1f49,0xc278,0x40d3,},
+{0xf020,0xb59d,0x2b70,0xada8,0x9dc5,0x4069,},
+{0x0000,0x0000,0x0400,0xc9bf,0x8e1b,0x4034,},
+{0x0000,0x0000,0x0000,0x2000,0xbebc,0x4019,},
+{0x0000,0x0000,0x0000,0x0000,0x9c40,0x400c,},
+{0x0000,0x0000,0x0000,0x0000,0xc800,0x4005,},
+{0x0000,0x0000,0x0000,0x0000,0xa000,0x4002,}, /* 10**1 */
+};
+
+static unsigned short emtens[NTEN+1][NE] = {
+{0x2de4,0x9fde,0xd2ce,0x04c8,0xa6dd,0x0ad8,}, /* 10**-4096 */
+{0x4925,0x2de4,0x3436,0x534f,0xceae,0x256b,}, /* 10**-2048 */
+{0x87a6,0xc0bd,0xda57,0x82a5,0xa2a6,0x32b5,},
+{0x7133,0xd21c,0xdb23,0xee32,0x9049,0x395a,},
+{0xfa91,0x1939,0x637a,0x4325,0xc031,0x3cac,},
+{0xac7d,0xe4a0,0x64bc,0x467c,0xddd0,0x3e55,},
+{0x3f24,0xe9a5,0xa539,0xea27,0xa87f,0x3f2a,},
+{0x67de,0x94ba,0x4539,0x1ead,0xcfb1,0x3f94,},
+{0x4c2f,0xe15b,0xc44d,0x94be,0xe695,0x3fc9,},
+{0xfdc2,0xcefc,0x8461,0x7711,0xabcc,0x3fe4,},
+{0xd3c3,0x652b,0xe219,0x1758,0xd1b7,0x3ff1,},
+{0x3d71,0xd70a,0x70a3,0x0a3d,0xa3d7,0x3ff8,},
+{0xcccd,0xcccc,0xcccc,0xcccc,0xcccc,0x3ffb,}, /* 10**-1 */
+};
+#endif
+
+
+
+/* ASCII string outputs for unix */
+
+
+#if 0
+void _IO_ldtostr(x, string, ndigs, flags, fmt)
+long double *x;
+char *string;
+int ndigs;
+int flags;
+char fmt;
+{
+unsigned short w[NI];
+char *t, *u;
+LDPARMS rnd;
+LDPARMS *ldp = &rnd;
+
+rnd.rlast = -1;
+rnd.rndprc = NBITS;
+
+if (sizeof(long double) == 16)
+ e113toe( (unsigned short *)x, w, ldp );
+else
+ e64toe( (unsigned short *)x, w, ldp );
+
+etoasc( w, string, ndigs, -1, ldp );
+if( ndigs == 0 && flags == 0 )
+ {
+ /* Delete the decimal point unless alternate format. */
+ t = string;
+ while( *t != '.' )
+ ++t;
+ u = t + 1;
+ while( *t != '\0' )
+ *t++ = *u++;
+ }
+if (*string == ' ')
+ {
+ t = string;
+ u = t + 1;
+ while( *t != '\0' )
+ *t++ = *u++;
+ }
+if (fmt == 'E')
+ {
+ t = string;
+ while( *t != 'e' )
+ ++t;
+ *t = 'E';
+ }
+}
+
+#endif
+
+/* This routine will not return more than NDEC+1 digits. */
+
+char *
+_ldtoa_r (struct _reent *ptr, long double d, int mode, int ndigits, int *decpt,
+ int *sign, char **rve)
+{
+unsigned short e[NI];
+char *s, *p;
+int i, j, k;
+int orig_ndigits;
+LDPARMS rnd;
+LDPARMS *ldp = &rnd;
+char *outstr;
+char outbuf[NDEC + MAX_EXP_DIGITS + 10];
+union uconv du;
+du.d = d;
+
+orig_ndigits = ndigits;
+rnd.rlast = -1;
+rnd.rndprc = NBITS;
+
+ _REENT_CHECK_MP(ptr);
+
+/* reentrancy addition to use mprec storage pool */
+if (_REENT_MP_RESULT(ptr))
+ {
+ _REENT_MP_RESULT(ptr)->_k = _REENT_MP_RESULT_K(ptr);
+ _REENT_MP_RESULT(ptr)->_maxwds = 1 << _REENT_MP_RESULT_K(ptr);
+ Bfree (ptr, _REENT_MP_RESULT(ptr));
+ _REENT_MP_RESULT(ptr) = 0;
+ }
+
+#if LDBL_MANT_DIG == 24
+e24toe( &du.pe, e, ldp );
+#elif LDBL_MANT_DIG == 53
+e53toe( &du.pe, e, ldp );
+#elif LDBL_MANT_DIG == 64
+e64toe( &du.pe, e, ldp );
+#else
+e113toe( &du.pe, e, ldp );
+#endif
+
+if( eisneg(e) )
+ *sign = 1;
+else
+ *sign = 0;
+/* Mode 3 is "f" format. */
+if( mode != 3 )
+ ndigits -= 1;
+/* Mode 0 is for %.999 format, which is supposed to give a
+ minimum length string that will convert back to the same binary value.
+ For now, just ask for 20 digits which is enough but sometimes too many. */
+if( mode == 0 )
+ ndigits = 20;
+
+/* This sanity limit must agree with the corresponding one in etoasc, to
+ keep straight the returned value of outexpon. */
+if( ndigits > NDEC )
+ ndigits = NDEC;
+
+etoasc( e, outbuf, ndigits, mode, ldp );
+s = outbuf;
+if( eisinf(e) || eisnan(e) )
+ {
+ *decpt = 9999;
+ goto stripspaces;
+ }
+*decpt = ldp->outexpon + 1;
+
+/* Transform the string returned by etoasc into what the caller wants. */
+
+/* Look for decimal point and delete it from the string. */
+s = outbuf;
+while( *s != '\0' )
+ {
+ if( *s == '.' )
+ goto yesdecpt;
+ ++s;
+ }
+goto nodecpt;
+
+yesdecpt:
+
+/* Delete the decimal point. */
+while( *s != '\0' )
+ {
+ *s = *(s+1);
+ ++s;
+ }
+
+nodecpt:
+
+/* Back up over the exponent field. */
+while( *s != 'E' && s > outbuf)
+ --s;
+*s = '\0';
+
+stripspaces:
+
+/* Strip leading spaces and sign. */
+p = outbuf;
+while( *p == ' ' || *p == '-')
+ ++p;
+
+/* Find new end of string. */
+s = outbuf;
+while( (*s++ = *p++) != '\0' )
+ ;
+--s;
+
+/* Strip trailing zeros. */
+if( mode == 2 )
+ k = 1;
+else if( ndigits > ldp->outexpon )
+ k = ndigits;
+else
+ k = ldp->outexpon;
+
+while( *(s-1) == '0' && ((s - outbuf) > k))
+ *(--s) = '\0';
+
+/* In f format, flush small off-scale values to zero.
+ Rounding has been taken care of by etoasc. */
+if( mode == 3 && ((ndigits + ldp->outexpon) < 0))
+ {
+ s = outbuf;
+ *s = '\0';
+ *decpt = 0;
+ }
+
+/* reentrancy addition to use mprec storage pool */
+/* we want to have enough space to hold the formatted result */
+
+if (mode == 3) /* f format, account for sign + dec digits + decpt + frac */
+ i = *decpt + orig_ndigits + 3;
+else /* account for sign + max precision digs + E + exp sign + exponent */
+ i = orig_ndigits + MAX_EXP_DIGITS + 4;
+
+j = sizeof (__ULong);
+for (_REENT_MP_RESULT_K(ptr) = 0; sizeof (_Bigint) - sizeof (__ULong) + j <= i; j <<= 1)
+ _REENT_MP_RESULT_K(ptr)++;
+_REENT_MP_RESULT(ptr) = Balloc (ptr, _REENT_MP_RESULT_K(ptr));
+
+/* Copy from internal temporary buffer to permanent buffer. */
+outstr = (char *)_REENT_MP_RESULT(ptr);
+strcpy (outstr, outbuf);
+
+if( rve )
+ *rve = outstr + (s - outbuf);
+
+return outstr;
+}
+
+/* Routine used to tell if long double is NaN or Infinity or regular number.
+ Returns: 0 = regular number
+ 1 = Nan
+ 2 = Infinity
+*/
+int
+_ldcheck (long double *d)
+{
+unsigned short e[NI];
+LDPARMS rnd;
+LDPARMS *ldp = &rnd;
+
+union uconv du;
+
+rnd.rlast = -1;
+rnd.rndprc = NBITS;
+du.d = *d;
+#if LDBL_MANT_DIG == 24
+e24toe( &du.pe, e, ldp );
+#elif LDBL_MANT_DIG == 53
+e53toe( &du.pe, e, ldp );
+#elif LDBL_MANT_DIG == 64
+e64toe( &du.pe, e, ldp );
+#else
+e113toe( &du.pe, e, ldp );
+#endif
+
+if( (e[NE-1] & 0x7fff) == 0x7fff )
+ {
+#ifdef NANS
+ if( eisnan(e) )
+ return( 1 );
+#endif
+ return( 2 );
+ }
+else
+ return( 0 );
+} /* _ldcheck */
+
+static void etoasc(short unsigned int *x, char *string, int ndigits, int outformat, LDPARMS *ldp)
+{
+long digit;
+unsigned short y[NI], t[NI], u[NI], w[NI];
+unsigned short *p, *r, *ten;
+unsigned short sign;
+int i, j, k, expon, rndsav, ndigs;
+char *s, *ss;
+unsigned short m;
+unsigned short *equot = ldp->equot;
+
+ndigs = ndigits;
+rndsav = ldp->rndprc;
+#ifdef NANS
+if( eisnan(x) )
+ {
+ sprintf( string, " NaN " );
+ expon = 9999;
+ goto bxit;
+ }
+#endif
+ldp->rndprc = NBITS; /* set to full precision */
+emov( x, y ); /* retain external format */
+if( y[NE-1] & 0x8000 )
+ {
+ sign = 0xffff;
+ y[NE-1] &= 0x7fff;
+ }
+else
+ {
+ sign = 0;
+ }
+expon = 0;
+ten = &etens[NTEN][0];
+emov( eone, t );
+/* Test for zero exponent */
+if( y[NE-1] == 0 )
+ {
+ for( k=0; k>= 1;
+ }
+while( m != 0 );
+
+/* Rescale from integer significand */
+ u[NE-1] += y[NE-1] - (unsigned int )(EXONE + NBITS - 1);
+ emov( u, y );
+/* Find power of 10 */
+ emov( eone, t );
+ m = MAXP;
+ p = &etens[0][0];
+ while( ecmp( ten, u ) <= 0 )
+ {
+ if( ecmp( p, u ) <= 0 )
+ {
+ ediv( p, u, u, ldp );
+ emul( p, t, t, ldp );
+ expon += (int )m;
+ }
+ m >>= 1;
+ if( m == 0 )
+ break;
+ p += NE;
+ }
+ }
+else
+ { /* Number is less than 1.0 */
+/* Pad significand with trailing decimal zeros. */
+ if( y[NE-1] == 0 )
+ {
+ while( (y[NE-2] & 0x8000) == 0 )
+ {
+ emul( ten, y, y, ldp );
+ expon -= 1;
+ }
+ }
+ else
+ {
+ emovi( y, w );
+ for( i=0; i 0 )
+ {
+ if( ecmp( p, w ) >= 0 )
+ {
+ emul( r, w, w, ldp );
+ emul( r, t, t, ldp );
+ expon += k;
+ }
+ k /= 2;
+ if( k == 0 )
+ break;
+ p += NE;
+ r += NE;
+ }
+ ediv( t, eone, t, ldp );
+ }
+isone:
+/* Find the first (leading) digit. */
+emovi( t, w );
+emovz( w, t );
+emovi( y, w );
+emovz( w, y );
+eiremain( t, y, ldp );
+digit = equot[NI-1];
+while( (digit == 0) && (ecmp(y,ezero) != 0) )
+ {
+ eshup1( y );
+ emovz( y, u );
+ eshup1( u );
+ eshup1( u );
+ eaddm( u, y );
+ eiremain( t, y, ldp );
+ digit = equot[NI-1];
+ expon -= 1;
+ }
+s = string;
+if( sign )
+ *s++ = '-';
+else
+ *s++ = ' ';
+/* Examine number of digits requested by caller. */
+if( outformat == 3 )
+ ndigs += expon;
+/*
+else if( ndigs < 0 )
+ ndigs = 0;
+*/
+if( ndigs > NDEC )
+ ndigs = NDEC;
+if( digit == 10 )
+ {
+ *s++ = '1';
+ *s++ = '.';
+ if( ndigs > 0 )
+ {
+ *s++ = '0';
+ ndigs -= 1;
+ }
+ expon += 1;
+ if( ndigs < 0 )
+ {
+ ss = s;
+ goto doexp;
+ }
+ }
+else
+ {
+ *s++ = (char )digit + '0';
+ *s++ = '.';
+ }
+/* Generate digits after the decimal point. */
+for( k=0; k<=ndigs; k++ )
+ {
+/* multiply current number by 10, without normalizing */
+ eshup1( y );
+ emovz( y, u );
+ eshup1( u );
+ eshup1( u );
+ eaddm( u, y );
+ eiremain( t, y, ldp );
+ *s++ = (char )equot[NI-1] + '0';
+ }
+digit = equot[NI-1];
+--s;
+ss = s;
+/* round off the ASCII string */
+if( digit > 4 )
+ {
+/* Test for critical rounding case in ASCII output. */
+ if( digit == 5 )
+ {
+ emovo( y, t, ldp );
+ if( ecmp(t,ezero) != 0 )
+ goto roun; /* round to nearest */
+ if( ndigs < 0 || (*(s-1-(*(s-1)=='.')) & 1) == 0 )
+ goto doexp; /* round to even */
+ }
+/* Round up and propagate carry-outs */
+roun:
+ --s;
+ k = *s & 0x7f;
+/* Carry out to most significant digit? */
+ if( ndigs < 0 )
+ {
+ /* This will print like "1E-6". */
+ *s = '1';
+ expon += 1;
+ goto doexp;
+ }
+ else if( k == '.' )
+ {
+ --s;
+ k = *s;
+ k += 1;
+ *s = (char )k;
+/* Most significant digit carries to 10? */
+ if( k > '9' )
+ {
+ expon += 1;
+ *s = '1';
+ }
+ goto doexp;
+ }
+/* Round up and carry out from less significant digits */
+ k += 1;
+ *s = (char )k;
+ if( k > '9' )
+ {
+ *s = '0';
+ goto roun;
+ }
+ }
+doexp:
+#ifdef __GO32__
+if( expon >= 0 )
+ sprintf( ss, "e+%02d", expon );
+else
+ sprintf( ss, "e-%02d", -expon );
+#else
+ sprintf( ss, "E%d", expon );
+#endif
+bxit:
+ldp->rndprc = rndsav;
+ldp->outexpon = expon;
+}
+
+
+
+
+/*
+; ASCTOQ
+; ASCTOQ.MAC LATEST REV: 11 JAN 84
+; SLM, 3 JAN 78
+;
+; Convert ASCII string to quadruple precision floating point
+;
+; Numeric input is free field decimal number
+; with max of 15 digits with or without
+; decimal point entered as ASCII from teletype.
+; Entering E after the number followed by a second
+; number causes the second number to be interpreted
+; as a power of 10 to be multiplied by the first number
+; (i.e., "scientific" notation).
+;
+; Usage:
+; asctoq( string, q );
+*/
+
+long double _strtold (char *s, char **se)
+{
+ union uconv x;
+ LDPARMS rnd;
+ LDPARMS *ldp = &rnd;
+ int lenldstr;
+
+ rnd.rlast = -1;
+ rnd.rndprc = NBITS;
+
+ lenldstr = asctoeg( s, &x.pe, LDBL_MANT_DIG, ldp );
+ if (se)
+ *se = s + lenldstr;
+ return x.d;
+}
+
+#define REASONABLE_LEN 200
+
+static int
+asctoeg(char *ss, short unsigned int *y, int oprec, LDPARMS *ldp)
+{
+unsigned short yy[NI], xt[NI], tt[NI];
+int esign, decflg, sgnflg, nexp, exp, prec, lost;
+int k, trail, c, rndsav;
+long lexp;
+unsigned short nsign, *p;
+char *sp, *s, *lstr;
+int lenldstr;
+int mflag = 0;
+char tmpstr[REASONABLE_LEN];
+
+/* Copy the input string. */
+c = strlen (ss) + 2;
+if (c <= REASONABLE_LEN)
+ lstr = tmpstr;
+else
+ {
+ lstr = (char *) calloc (c, 1);
+ mflag = 1;
+ }
+s = ss;
+lenldstr = 0;
+while( *s == ' ' ) /* skip leading spaces */
+ {
+ ++s;
+ ++lenldstr;
+ }
+sp = lstr;
+for( k=0; krndprc;
+ldp->rndprc = NBITS; /* Set to full precision */
+lost = 0;
+nsign = 0;
+decflg = 0;
+sgnflg = 0;
+nexp = 0;
+exp = 0;
+prec = 0;
+ecleaz( yy );
+trail = 0;
+
+nxtcom:
+k = *s - '0';
+if( (k >= 0) && (k <= 9) )
+ {
+/* Ignore leading zeros */
+ if( (prec == 0) && (decflg == 0) && (k == 0) )
+ goto donchr;
+/* Identify and strip trailing zeros after the decimal point. */
+ if( (trail == 0) && (decflg != 0) )
+ {
+ sp = s;
+ while( (*sp >= '0') && (*sp <= '9') )
+ ++sp;
+/* Check for syntax error */
+ c = *sp & 0x7f;
+ if( (c != 'e') && (c != 'E') && (c != '\0')
+ && (c != '\n') && (c != '\r') && (c != ' ')
+ && (c != ',') )
+ goto error;
+ --sp;
+ while( *sp == '0' )
+ *sp-- = 'z';
+ trail = 1;
+ if( *s == 'z' )
+ goto donchr;
+ }
+/* If enough digits were given to more than fill up the yy register,
+ * continuing until overflow into the high guard word yy[2]
+ * guarantees that there will be a roundoff bit at the top
+ * of the low guard word after normalization.
+ */
+ if( yy[2] == 0 )
+ {
+ if( decflg )
+ nexp += 1; /* count digits after decimal point */
+ eshup1( yy ); /* multiply current number by 10 */
+ emovz( yy, xt );
+ eshup1( xt );
+ eshup1( xt );
+ eaddm( xt, yy );
+ ecleaz( xt );
+ xt[NI-2] = (unsigned short )k;
+ eaddm( xt, yy );
+ }
+ else
+ {
+ /* Mark any lost non-zero digit. */
+ lost |= k;
+ /* Count lost digits before the decimal point. */
+ if (decflg == 0)
+ nexp -= 1;
+ }
+ prec += 1;
+ goto donchr;
+ }
+
+switch( *s )
+ {
+ case 'z':
+ break;
+ case 'E':
+ case 'e':
+ goto expnt;
+ case '.': /* decimal point */
+ if( decflg )
+ goto error;
+ ++decflg;
+ break;
+ case '-':
+ nsign = 0xffff;
+ if( sgnflg )
+ goto error;
+ ++sgnflg;
+ break;
+ case '+':
+ if( sgnflg )
+ goto error;
+ ++sgnflg;
+ break;
+ case ',':
+ case ' ':
+ case '\0':
+ case '\n':
+ case '\r':
+ goto daldone;
+ case 'i':
+ case 'I':
+ goto infinite;
+ default:
+ error:
+#ifdef NANS
+ enan( yy, NI*16 );
+#else
+ mtherr( "asctoe", DOMAIN );
+ ecleaz(yy);
+#endif
+ goto aexit;
+ }
+donchr:
+++s;
+goto nxtcom;
+
+/* Exponent interpretation */
+expnt:
+
+esign = 1;
+exp = 0;
+++s;
+/* check for + or - */
+if( *s == '-' )
+ {
+ esign = -1;
+ ++s;
+ }
+if( *s == '+' )
+ ++s;
+while( (*s >= '0') && (*s <= '9') )
+ {
+ exp *= 10;
+ exp += *s++ - '0';
+ if (exp > 4977)
+ {
+ if (esign < 0)
+ goto zero;
+ else
+ goto infinite;
+ }
+ }
+if( esign < 0 )
+ exp = -exp;
+if( exp > 4932 )
+ {
+infinite:
+ ecleaz(yy);
+ yy[E] = 0x7fff; /* infinity */
+ goto aexit;
+ }
+if( exp < -4977 )
+ {
+zero:
+ ecleaz(yy);
+ goto aexit;
+ }
+
+daldone:
+nexp = exp - nexp;
+/* Pad trailing zeros to minimize power of 10, per IEEE spec. */
+while( (nexp > 0) && (yy[2] == 0) )
+ {
+ emovz( yy, xt );
+ eshup1( xt );
+ eshup1( xt );
+ eaddm( yy, xt );
+ eshup1( xt );
+ if( xt[2] != 0 )
+ break;
+ nexp -= 1;
+ emovz( xt, yy );
+ }
+if( (k = enormlz(yy)) > NBITS )
+ {
+ ecleaz(yy);
+ goto aexit;
+ }
+lexp = (EXONE - 1 + NBITS) - k;
+emdnorm( yy, lost, 0, lexp, 64, ldp );
+/* convert to external format */
+
+
+/* Multiply by 10**nexp. If precision is 64 bits,
+ * the maximum relative error incurred in forming 10**n
+ * for 0 <= n <= 324 is 8.2e-20, at 10**180.
+ * For 0 <= n <= 999, the peak relative error is 1.4e-19 at 10**947.
+ * For 0 >= n >= -999, it is -1.55e-19 at 10**-435.
+ */
+lexp = yy[E];
+if( nexp == 0 )
+ {
+ k = 0;
+ goto expdon;
+ }
+esign = 1;
+if( nexp < 0 )
+ {
+ nexp = -nexp;
+ esign = -1;
+ if( nexp > 4096 )
+ { /* Punt. Can't handle this without 2 divides. */
+ emovi( etens[0], tt );
+ lexp -= tt[E];
+ k = edivm( tt, yy, ldp );
+ lexp += EXONE;
+ nexp -= 4096;
+ }
+ }
+p = &etens[NTEN][0];
+emov( eone, xt );
+exp = 1;
+do
+ {
+ if( exp & nexp )
+ emul( p, xt, xt, ldp );
+ p -= NE;
+ exp = exp + exp;
+ }
+while( exp <= MAXP );
+
+emovi( xt, tt );
+if( esign < 0 )
+ {
+ lexp -= tt[E];
+ k = edivm( tt, yy, ldp );
+ lexp += EXONE;
+ }
+else
+ {
+ lexp += tt[E];
+ k = emulm( tt, yy, ldp );
+ lexp -= EXONE - 1;
+ }
+
+expdon:
+
+/* Round and convert directly to the destination type */
+if( oprec == 53 )
+ lexp -= EXONE - 0x3ff;
+else if( oprec == 24 )
+ lexp -= EXONE - 0177;
+#ifdef DEC
+else if( oprec == 56 )
+ lexp -= EXONE - 0201;
+#endif
+ldp->rndprc = oprec;
+emdnorm( yy, k, 0, lexp, 64, ldp );
+
+aexit:
+
+ldp->rndprc = rndsav;
+yy[0] = nsign;
+switch( oprec )
+ {
+#ifdef DEC
+ case 56:
+ todec( yy, y ); /* see etodec.c */
+ break;
+#endif
+#if LDBL_MANT_DIG == 53
+ case 53:
+ toe53( yy, y );
+ break;
+#elif LDBL_MANT_DIG == 24
+ case 24:
+ toe24( yy, y );
+ break;
+#elif LDBL_MANT_DIG == 64
+ case 64:
+ toe64( yy, y );
+ break;
+#elif LDBL_MANT_DIG == 113
+ case 113:
+ toe113( yy, y );
+ break;
+#else
+ case NBITS:
+ emovo( yy, y, ldp );
+ break;
+#endif
+ }
+lenldstr += s - lstr;
+if (mflag)
+ free (lstr);
+return lenldstr;
+}
+
+
+
+/* y = largest integer not greater than x
+ * (truncated toward minus infinity)
+ *
+ * unsigned short x[NE], y[NE]
+ * LDPARMS *ldp
+ *
+ * efloor( x, y, ldp );
+ */
+static unsigned short bmask[] = {
+0xffff,
+0xfffe,
+0xfffc,
+0xfff8,
+0xfff0,
+0xffe0,
+0xffc0,
+0xff80,
+0xff00,
+0xfe00,
+0xfc00,
+0xf800,
+0xf000,
+0xe000,
+0xc000,
+0x8000,
+0x0000,
+};
+
+static void efloor(short unsigned int *x, short unsigned int *y, LDPARMS *ldp)
+{
+register unsigned short *p;
+int e, expon, i;
+unsigned short f[NE];
+
+emov( x, f ); /* leave in external format */
+expon = (int )f[NE-1];
+e = (expon & 0x7fff) - (EXONE - 1);
+if( e <= 0 )
+ {
+ eclear(y);
+ goto isitneg;
+ }
+/* number of bits to clear out */
+e = NBITS - e;
+emov( f, y );
+if( e <= 0 )
+ return;
+
+p = &y[0];
+while( e >= 16 )
+ {
+ *p++ = 0;
+ e -= 16;
+ }
+/* clear the remaining bits */
+*p &= bmask[e];
+/* truncate negatives toward minus infinity */
+isitneg:
+
+if( (unsigned short )expon & (unsigned short )0x8000 )
+ {
+ for( i=0; iequot;
+
+ld = den[E];
+ld -= enormlz( den );
+ln = num[E];
+ln -= enormlz( num );
+ecleaz( equot );
+while( ln >= ld )
+ {
+ if( ecmpm(den,num) <= 0 )
+ {
+ esubm(den, num);
+ j = 1;
+ }
+ else
+ {
+ j = 0;
+ }
+ eshup1(equot);
+ equot[NI-1] |= j;
+ eshup1(num);
+ ln -= 1;
+ }
+emdnorm( num, 0, 0, ln, 0, ldp );
+}
+
+/* NaN bit patterns
+ */
+#ifdef MIEEE
+static unsigned short nan113[8] = {
+ 0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
+static unsigned short nan64[6] = {0x7fff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff};
+static unsigned short nan53[4] = {0x7fff, 0xffff, 0xffff, 0xffff};
+static unsigned short nan24[2] = {0x7fff, 0xffff};
+#else /* !MIEEE */
+static unsigned short nan113[8] = {0, 0, 0, 0, 0, 0, 0x8000, 0x7fff};
+static unsigned short nan64[6] = {0, 0, 0, 0, 0xc000, 0x7fff};
+static unsigned short nan53[4] = {0, 0, 0, 0x7ff8};
+static unsigned short nan24[2] = {0, 0x7fc0};
+#endif /* !MIEEE */
+
+
+static void enan (short unsigned int *nan, int size)
+{
+int i, n;
+unsigned short *p;
+
+switch( size )
+ {
+#ifndef DEC
+ case 113:
+ n = 8;
+ p = nan113;
+ break;
+
+ case 64:
+ n = 6;
+ p = nan64;
+ break;
+
+ case 53:
+ n = 4;
+ p = nan53;
+ break;
+
+ case 24:
+ n = 2;
+ p = nan24;
+ break;
+
+ case NBITS:
+ for( i=0; i
ldtoa.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mbsinit.c
===================================================================
--- mbsinit.c (nonexistent)
+++ mbsinit.c (revision 345)
@@ -0,0 +1,14 @@
+#include
+#include
+#include
+#include
+#include
+
+int
+mbsinit(const mbstate_t *ps)
+{
+ if (ps == NULL || ps->__count == 0)
+ return 1;
+ else
+ return 0;
+}
mbsinit.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: on_exit.c
===================================================================
--- on_exit.c (nonexistent)
+++ on_exit.c (revision 345)
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ *
+ * This function is a modified version of atexit.c
+ */
+
+/*
+FUNCTION
+<>---request execution of function with argument at program exit
+
+INDEX
+ on_exit
+
+ANSI_SYNOPSIS
+ #include
+ int on_exit (void (*<[function]>)(int, void *), void *<[arg]>);
+
+TRAD_SYNOPSIS
+ #include
+ int on_exit ((<[function]>, <[arg]>)
+ void (*<[function]>)(int, void *);
+ void *<[arg]>;
+
+DESCRIPTION
+You can use <> to enroll functions in a list of functions that
+will be called when your program terminates normally. The argument is
+a pointer to a user-defined function which takes two arguments. The
+first is the status code passed to exit and the second argument is of type
+pointer to void. The function must not return a result. The value
+of <[arg]> is registered and passed as the argument to <[function]>.
+
+The functions are kept in a LIFO stack; that is, the last function
+enrolled by <> or <> will be the first to execute when
+your program exits. You can intermix functions using <> and
+<>.
+
+There is no built-in limit to the number of functions you can enroll
+in this list; however, after every group of 32 functions is enrolled,
+<>/<> will call <> to get space for the next part
+of the list. The initial list of 32 functions is statically allocated, so
+you can always count on at least that many slots available.
+
+RETURNS
+<> returns <<0>> if it succeeds in enrolling your function,
+<<-1>> if it fails (possible only if no space was available for
+<> to extend the list of functions).
+
+PORTABILITY
+<> is a non-standard glibc extension
+
+Supporting OS subroutines required: None
+*/
+
+#include
+#include
+#include "atexit.h"
+
+/*
+ * Register a function to be performed at exit.
+ */
+
+int
+_DEFUN (on_exit,
+ (fn, arg),
+ _VOID _EXFNPTR(fn, (int, _PTR)) _AND
+ _PTR arg)
+{
+ return __register_exitproc (__et_onexit, (void (*)(void)) fn, arg, NULL);
+}
on_exit.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: l64a.c
===================================================================
--- l64a.c (nonexistent)
+++ l64a.c (revision 345)
@@ -0,0 +1,64 @@
+/* l64a - convert long to radix-64 ascii string
+ *
+ * Conversion is performed on at most 32-bits of input value starting
+ * from least significant bits to the most significant bits.
+ *
+ * The routine splits the input value into groups of 6 bits for up to
+ * 32 bits of input. This means that the last group may be 2 bits
+ * (bits 30 and 31).
+ *
+ * Each group of 6 bits forms a value from 0-63 which is converted into
+ * a character as follows:
+ * 0 = '.'
+ * 1 = '/'
+ * 2-11 = '0' to '9'
+ * 12-37 = 'A' to 'Z'
+ * 38-63 = 'a' to 'z'
+ *
+ * When the remaining bits are zero or all 32 bits have been translated,
+ * a nul terminator is appended to the resulting string. An input value of
+ * 0 results in an empty string.
+ */
+
+#include <_ansi.h>
+#include
+#include
+
+static const char R64_ARRAY[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
+
+char *
+_DEFUN (l64a, (value),
+ long value)
+{
+ return _l64a_r (_REENT, value);
+}
+
+char *
+_DEFUN (_l64a_r, (rptr, value),
+ struct _reent *rptr _AND
+ long value)
+{
+ char *ptr;
+ char *result;
+ int i, index;
+ unsigned long tmp = (unsigned long)value & 0xffffffff;
+
+ _REENT_CHECK_MISC(rptr);
+ result = _REENT_L64A_BUF(rptr);
+ ptr = result;
+
+ for (i = 0; i < 6; ++i)
+ {
+ if (tmp == 0)
+ {
+ *ptr = '\0';
+ break;
+ }
+
+ index = tmp & (64 - 1);
+ *ptr++ = R64_ARRAY[index];
+ tmp >>= 6;
+ }
+
+ return result;
+}
l64a.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mprec.c
===================================================================
--- mprec.c (nonexistent)
+++ mprec.c (revision 345)
@@ -0,0 +1,1049 @@
+/****************************************************************
+ *
+ * The author of this software is David M. Gay.
+ *
+ * Copyright (c) 1991 by AT&T.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose without fee is hereby granted, provided that this entire notice
+ * is included in all copies of any software which is or includes a copy
+ * or modification of this software and in all copies of the supporting
+ * documentation for such software.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
+ * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ *
+ ***************************************************************/
+
+/* Please send bug reports to
+ David M. Gay
+ AT&T Bell Laboratories, Room 2C-463
+ 600 Mountain Avenue
+ Murray Hill, NJ 07974-2070
+ U.S.A.
+ dmg@research.att.com or research!dmg
+ */
+
+/* strtod for IEEE-, VAX-, and IBM-arithmetic machines.
+ *
+ * This strtod returns a nearest machine number to the input decimal
+ * string (or sets errno to ERANGE). With IEEE arithmetic, ties are
+ * broken by the IEEE round-even rule. Otherwise ties are broken by
+ * biased rounding (add half and chop).
+ *
+ * Inspired loosely by William D. Clinger's paper "How to Read Floating
+ * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101].
+ *
+ * Modifications:
+ *
+ * 1. We only require IEEE, IBM, or VAX double-precision
+ * arithmetic (not IEEE double-extended).
+ * 2. We get by with floating-point arithmetic in a case that
+ * Clinger missed -- when we're computing d * 10^n
+ * for a small integer d and the integer n is not too
+ * much larger than 22 (the maximum integer k for which
+ * we can represent 10^k exactly), we may be able to
+ * compute (d*10^k) * 10^(e-k) with just one roundoff.
+ * 3. Rather than a bit-at-a-time adjustment of the binary
+ * result in the hard case, we use floating-point
+ * arithmetic to determine the adjustment to within
+ * one bit; only in really hard cases do we need to
+ * compute a second residual.
+ * 4. Because of 3., we don't need a large table of powers of 10
+ * for ten-to-e (just some small tables, e.g. of 10^k
+ * for 0 <= k <= 22).
+ */
+
+/*
+ * #define IEEE_8087 for IEEE-arithmetic machines where the least
+ * significant byte has the lowest address.
+ * #define IEEE_MC68k for IEEE-arithmetic machines where the most
+ * significant byte has the lowest address.
+ * #define Sudden_Underflow for IEEE-format machines without gradual
+ * underflow (i.e., that flush to zero on underflow).
+ * #define IBM for IBM mainframe-style floating-point arithmetic.
+ * #define VAX for VAX-style floating-point arithmetic.
+ * #define Unsigned_Shifts if >> does treats its left operand as unsigned.
+ * #define No_leftright to omit left-right logic in fast floating-point
+ * computation of dtoa.
+ * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3.
+ * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines
+ * that use extended-precision instructions to compute rounded
+ * products and quotients) with IBM.
+ * #define ROUND_BIASED for IEEE-format with biased rounding.
+ * #define Inaccurate_Divide for IEEE-format with correctly rounded
+ * products but inaccurate quotients, e.g., for Intel i860.
+ * #define Just_16 to store 16 bits per 32-bit long when doing high-precision
+ * integer arithmetic. Whether this speeds things up or slows things
+ * down depends on the machine and the number being converted.
+ */
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include "mprec.h"
+
+/* This is defined in sys/reent.h as (sizeof (size_t) << 3) now, as in NetBSD.
+ The old value of 15 was wrong and made newlib vulnerable against buffer
+ overrun attacks (CVE-2009-0689), same as other implementations of gdtoa
+ based on BSD code.
+#define _Kmax 15
+*/
+
+_Bigint *
+_DEFUN (Balloc, (ptr, k), struct _reent *ptr _AND int k)
+{
+ int x;
+ _Bigint *rv ;
+
+ _REENT_CHECK_MP(ptr);
+ if (_REENT_MP_FREELIST(ptr) == NULL)
+ {
+ /* Allocate a list of pointers to the mprec objects */
+ _REENT_MP_FREELIST(ptr) = (struct _Bigint **) _calloc_r (ptr,
+ sizeof (struct _Bigint *),
+ _Kmax + 1);
+ if (_REENT_MP_FREELIST(ptr) == NULL)
+ {
+ return NULL;
+ }
+ }
+
+ if ((rv = _REENT_MP_FREELIST(ptr)[k]) != 0)
+ {
+ _REENT_MP_FREELIST(ptr)[k] = rv->_next;
+ }
+ else
+ {
+ x = 1 << k;
+ /* Allocate an mprec Bigint and stick in in the freelist */
+ rv = (_Bigint *) _calloc_r (ptr,
+ 1,
+ sizeof (_Bigint) +
+ (x-1) * sizeof(rv->_x));
+ if (rv == NULL) return NULL;
+ rv->_k = k;
+ rv->_maxwds = x;
+ }
+ rv->_sign = rv->_wds = 0;
+ return rv;
+}
+
+void
+_DEFUN (Bfree, (ptr, v), struct _reent *ptr _AND _Bigint * v)
+{
+ _REENT_CHECK_MP(ptr);
+ if (v)
+ {
+ v->_next = _REENT_MP_FREELIST(ptr)[v->_k];
+ _REENT_MP_FREELIST(ptr)[v->_k] = v;
+ }
+}
+
+_Bigint *
+_DEFUN (multadd, (ptr, b, m, a),
+ struct _reent *ptr _AND
+ _Bigint * b _AND
+ int m _AND
+ int a)
+{
+ int i, wds;
+ __ULong *x, y;
+#ifdef Pack_32
+ __ULong xi, z;
+#endif
+ _Bigint *b1;
+
+ wds = b->_wds;
+ x = b->_x;
+ i = 0;
+ do
+ {
+#ifdef Pack_32
+ xi = *x;
+ y = (xi & 0xffff) * m + a;
+ z = (xi >> 16) * m + (y >> 16);
+ a = (int) (z >> 16);
+ *x++ = (z << 16) + (y & 0xffff);
+#else
+ y = *x * m + a;
+ a = (int) (y >> 16);
+ *x++ = y & 0xffff;
+#endif
+ }
+ while (++i < wds);
+ if (a)
+ {
+ if (wds >= b->_maxwds)
+ {
+ b1 = Balloc (ptr, b->_k + 1);
+ Bcopy (b1, b);
+ Bfree (ptr, b);
+ b = b1;
+ }
+ b->_x[wds++] = a;
+ b->_wds = wds;
+ }
+ return b;
+}
+
+_Bigint *
+_DEFUN (s2b, (ptr, s, nd0, nd, y9),
+ struct _reent * ptr _AND
+ _CONST char *s _AND
+ int nd0 _AND
+ int nd _AND
+ __ULong y9)
+{
+ _Bigint *b;
+ int i, k;
+ __Long x, y;
+
+ x = (nd + 8) / 9;
+ for (k = 0, y = 1; x > y; y <<= 1, k++);
+#ifdef Pack_32
+ b = Balloc (ptr, k);
+ b->_x[0] = y9;
+ b->_wds = 1;
+#else
+ b = Balloc (ptr, k + 1);
+ b->_x[0] = y9 & 0xffff;
+ b->_wds = (b->_x[1] = y9 >> 16) ? 2 : 1;
+#endif
+
+ i = 9;
+ if (9 < nd0)
+ {
+ s += 9;
+ do
+ b = multadd (ptr, b, 10, *s++ - '0');
+ while (++i < nd0);
+ s++;
+ }
+ else
+ s += 10;
+ for (; i < nd; i++)
+ b = multadd (ptr, b, 10, *s++ - '0');
+ return b;
+}
+
+int
+_DEFUN (hi0bits,
+ (x), register __ULong x)
+{
+ register int k = 0;
+
+ if (!(x & 0xffff0000))
+ {
+ k = 16;
+ x <<= 16;
+ }
+ if (!(x & 0xff000000))
+ {
+ k += 8;
+ x <<= 8;
+ }
+ if (!(x & 0xf0000000))
+ {
+ k += 4;
+ x <<= 4;
+ }
+ if (!(x & 0xc0000000))
+ {
+ k += 2;
+ x <<= 2;
+ }
+ if (!(x & 0x80000000))
+ {
+ k++;
+ if (!(x & 0x40000000))
+ return 32;
+ }
+ return k;
+}
+
+int
+_DEFUN (lo0bits, (y), __ULong *y)
+{
+ register int k;
+ register __ULong x = *y;
+
+ if (x & 7)
+ {
+ if (x & 1)
+ return 0;
+ if (x & 2)
+ {
+ *y = x >> 1;
+ return 1;
+ }
+ *y = x >> 2;
+ return 2;
+ }
+ k = 0;
+ if (!(x & 0xffff))
+ {
+ k = 16;
+ x >>= 16;
+ }
+ if (!(x & 0xff))
+ {
+ k += 8;
+ x >>= 8;
+ }
+ if (!(x & 0xf))
+ {
+ k += 4;
+ x >>= 4;
+ }
+ if (!(x & 0x3))
+ {
+ k += 2;
+ x >>= 2;
+ }
+ if (!(x & 1))
+ {
+ k++;
+ x >>= 1;
+ if (!x & 1)
+ return 32;
+ }
+ *y = x;
+ return k;
+}
+
+_Bigint *
+_DEFUN (i2b, (ptr, i), struct _reent * ptr _AND int i)
+{
+ _Bigint *b;
+
+ b = Balloc (ptr, 1);
+ b->_x[0] = i;
+ b->_wds = 1;
+ return b;
+}
+
+_Bigint *
+_DEFUN (mult, (ptr, a, b), struct _reent * ptr _AND _Bigint * a _AND _Bigint * b)
+{
+ _Bigint *c;
+ int k, wa, wb, wc;
+ __ULong carry, y, z;
+ __ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
+#ifdef Pack_32
+ __ULong z2;
+#endif
+
+ if (a->_wds < b->_wds)
+ {
+ c = a;
+ a = b;
+ b = c;
+ }
+ k = a->_k;
+ wa = a->_wds;
+ wb = b->_wds;
+ wc = wa + wb;
+ if (wc > a->_maxwds)
+ k++;
+ c = Balloc (ptr, k);
+ for (x = c->_x, xa = x + wc; x < xa; x++)
+ *x = 0;
+ xa = a->_x;
+ xae = xa + wa;
+ xb = b->_x;
+ xbe = xb + wb;
+ xc0 = c->_x;
+#ifdef Pack_32
+ for (; xb < xbe; xb++, xc0++)
+ {
+ if ((y = *xb & 0xffff) != 0)
+ {
+ x = xa;
+ xc = xc0;
+ carry = 0;
+ do
+ {
+ z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
+ carry = z >> 16;
+ z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
+ carry = z2 >> 16;
+ Storeinc (xc, z2, z);
+ }
+ while (x < xae);
+ *xc = carry;
+ }
+ if ((y = *xb >> 16) != 0)
+ {
+ x = xa;
+ xc = xc0;
+ carry = 0;
+ z2 = *xc;
+ do
+ {
+ z = (*x & 0xffff) * y + (*xc >> 16) + carry;
+ carry = z >> 16;
+ Storeinc (xc, z, z2);
+ z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
+ carry = z2 >> 16;
+ }
+ while (x < xae);
+ *xc = z2;
+ }
+ }
+#else
+ for (; xb < xbe; xc0++)
+ {
+ if (y = *xb++)
+ {
+ x = xa;
+ xc = xc0;
+ carry = 0;
+ do
+ {
+ z = *x++ * y + *xc + carry;
+ carry = z >> 16;
+ *xc++ = z & 0xffff;
+ }
+ while (x < xae);
+ *xc = carry;
+ }
+ }
+#endif
+ for (xc0 = c->_x, xc = xc0 + wc; wc > 0 && !*--xc; --wc);
+ c->_wds = wc;
+ return c;
+}
+
+_Bigint *
+_DEFUN (pow5mult,
+ (ptr, b, k), struct _reent * ptr _AND _Bigint * b _AND int k)
+{
+ _Bigint *b1, *p5, *p51;
+ int i;
+ static _CONST int p05[3] = {5, 25, 125};
+
+ if ((i = k & 3) != 0)
+ b = multadd (ptr, b, p05[i - 1], 0);
+
+ if (!(k >>= 2))
+ return b;
+ _REENT_CHECK_MP(ptr);
+ if (!(p5 = _REENT_MP_P5S(ptr)))
+ {
+ /* first time */
+ p5 = _REENT_MP_P5S(ptr) = i2b (ptr, 625);
+ p5->_next = 0;
+ }
+ for (;;)
+ {
+ if (k & 1)
+ {
+ b1 = mult (ptr, b, p5);
+ Bfree (ptr, b);
+ b = b1;
+ }
+ if (!(k >>= 1))
+ break;
+ if (!(p51 = p5->_next))
+ {
+ p51 = p5->_next = mult (ptr, p5, p5);
+ p51->_next = 0;
+ }
+ p5 = p51;
+ }
+ return b;
+}
+
+_Bigint *
+_DEFUN (lshift, (ptr, b, k), struct _reent * ptr _AND _Bigint * b _AND int k)
+{
+ int i, k1, n, n1;
+ _Bigint *b1;
+ __ULong *x, *x1, *xe, z;
+
+#ifdef Pack_32
+ n = k >> 5;
+#else
+ n = k >> 4;
+#endif
+ k1 = b->_k;
+ n1 = n + b->_wds + 1;
+ for (i = b->_maxwds; n1 > i; i <<= 1)
+ k1++;
+ b1 = Balloc (ptr, k1);
+ x1 = b1->_x;
+ for (i = 0; i < n; i++)
+ *x1++ = 0;
+ x = b->_x;
+ xe = x + b->_wds;
+#ifdef Pack_32
+ if (k &= 0x1f)
+ {
+ k1 = 32 - k;
+ z = 0;
+ do
+ {
+ *x1++ = *x << k | z;
+ z = *x++ >> k1;
+ }
+ while (x < xe);
+ if ((*x1 = z) != 0)
+ ++n1;
+ }
+#else
+ if (k &= 0xf)
+ {
+ k1 = 16 - k;
+ z = 0;
+ do
+ {
+ *x1++ = *x << k & 0xffff | z;
+ z = *x++ >> k1;
+ }
+ while (x < xe);
+ if (*x1 = z)
+ ++n1;
+ }
+#endif
+ else
+ do
+ *x1++ = *x++;
+ while (x < xe);
+ b1->_wds = n1 - 1;
+ Bfree (ptr, b);
+ return b1;
+}
+
+int
+_DEFUN (cmp, (a, b), _Bigint * a _AND _Bigint * b)
+{
+ __ULong *xa, *xa0, *xb, *xb0;
+ int i, j;
+
+ i = a->_wds;
+ j = b->_wds;
+#ifdef DEBUG
+ if (i > 1 && !a->_x[i - 1])
+ Bug ("cmp called with a->_x[a->_wds-1] == 0");
+ if (j > 1 && !b->_x[j - 1])
+ Bug ("cmp called with b->_x[b->_wds-1] == 0");
+#endif
+ if (i -= j)
+ return i;
+ xa0 = a->_x;
+ xa = xa0 + j;
+ xb0 = b->_x;
+ xb = xb0 + j;
+ for (;;)
+ {
+ if (*--xa != *--xb)
+ return *xa < *xb ? -1 : 1;
+ if (xa <= xa0)
+ break;
+ }
+ return 0;
+}
+
+_Bigint *
+_DEFUN (diff, (ptr, a, b), struct _reent * ptr _AND
+ _Bigint * a _AND _Bigint * b)
+{
+ _Bigint *c;
+ int i, wa, wb;
+ __Long borrow, y; /* We need signed shifts here. */
+ __ULong *xa, *xae, *xb, *xbe, *xc;
+#ifdef Pack_32
+ __Long z;
+#endif
+
+ i = cmp (a, b);
+ if (!i)
+ {
+ c = Balloc (ptr, 0);
+ c->_wds = 1;
+ c->_x[0] = 0;
+ return c;
+ }
+ if (i < 0)
+ {
+ c = a;
+ a = b;
+ b = c;
+ i = 1;
+ }
+ else
+ i = 0;
+ c = Balloc (ptr, a->_k);
+ c->_sign = i;
+ wa = a->_wds;
+ xa = a->_x;
+ xae = xa + wa;
+ wb = b->_wds;
+ xb = b->_x;
+ xbe = xb + wb;
+ xc = c->_x;
+ borrow = 0;
+#ifdef Pack_32
+ do
+ {
+ y = (*xa & 0xffff) - (*xb & 0xffff) + borrow;
+ borrow = y >> 16;
+ Sign_Extend (borrow, y);
+ z = (*xa++ >> 16) - (*xb++ >> 16) + borrow;
+ borrow = z >> 16;
+ Sign_Extend (borrow, z);
+ Storeinc (xc, z, y);
+ }
+ while (xb < xbe);
+ while (xa < xae)
+ {
+ y = (*xa & 0xffff) + borrow;
+ borrow = y >> 16;
+ Sign_Extend (borrow, y);
+ z = (*xa++ >> 16) + borrow;
+ borrow = z >> 16;
+ Sign_Extend (borrow, z);
+ Storeinc (xc, z, y);
+ }
+#else
+ do
+ {
+ y = *xa++ - *xb++ + borrow;
+ borrow = y >> 16;
+ Sign_Extend (borrow, y);
+ *xc++ = y & 0xffff;
+ }
+ while (xb < xbe);
+ while (xa < xae)
+ {
+ y = *xa++ + borrow;
+ borrow = y >> 16;
+ Sign_Extend (borrow, y);
+ *xc++ = y & 0xffff;
+ }
+#endif
+ while (!*--xc)
+ wa--;
+ c->_wds = wa;
+ return c;
+}
+
+double
+_DEFUN (ulp, (_x), double _x)
+{
+ union double_union x, a;
+ register __Long L;
+
+ x.d = _x;
+
+ L = (word0 (x) & Exp_mask) - (P - 1) * Exp_msk1;
+#ifndef Sudden_Underflow
+ if (L > 0)
+ {
+#endif
+#ifdef IBM
+ L |= Exp_msk1 >> 4;
+#endif
+ word0 (a) = L;
+#ifndef _DOUBLE_IS_32BITS
+ word1 (a) = 0;
+#endif
+
+#ifndef Sudden_Underflow
+ }
+ else
+ {
+ L = -L >> Exp_shift;
+ if (L < Exp_shift)
+ {
+ word0 (a) = 0x80000 >> L;
+#ifndef _DOUBLE_IS_32BITS
+ word1 (a) = 0;
+#endif
+ }
+ else
+ {
+ word0 (a) = 0;
+ L -= Exp_shift;
+#ifndef _DOUBLE_IS_32BITS
+ word1 (a) = L >= 31 ? 1 : 1 << (31 - L);
+#endif
+ }
+ }
+#endif
+ return a.d;
+}
+
+double
+_DEFUN (b2d, (a, e),
+ _Bigint * a _AND int *e)
+{
+ __ULong *xa, *xa0, w, y, z;
+ int k;
+ union double_union d;
+#ifdef VAX
+ __ULong d0, d1;
+#else
+#define d0 word0(d)
+#define d1 word1(d)
+#endif
+
+ xa0 = a->_x;
+ xa = xa0 + a->_wds;
+ y = *--xa;
+#ifdef DEBUG
+ if (!y)
+ Bug ("zero y in b2d");
+#endif
+ k = hi0bits (y);
+ *e = 32 - k;
+#ifdef Pack_32
+ if (k < Ebits)
+ {
+ d0 = Exp_1 | y >> (Ebits - k);
+ w = xa > xa0 ? *--xa : 0;
+#ifndef _DOUBLE_IS_32BITS
+ d1 = y << ((32 - Ebits) + k) | w >> (Ebits - k);
+#endif
+ goto ret_d;
+ }
+ z = xa > xa0 ? *--xa : 0;
+ if (k -= Ebits)
+ {
+ d0 = Exp_1 | y << k | z >> (32 - k);
+ y = xa > xa0 ? *--xa : 0;
+#ifndef _DOUBLE_IS_32BITS
+ d1 = z << k | y >> (32 - k);
+#endif
+ }
+ else
+ {
+ d0 = Exp_1 | y;
+#ifndef _DOUBLE_IS_32BITS
+ d1 = z;
+#endif
+ }
+#else
+ if (k < Ebits + 16)
+ {
+ z = xa > xa0 ? *--xa : 0;
+ d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k;
+ w = xa > xa0 ? *--xa : 0;
+ y = xa > xa0 ? *--xa : 0;
+ d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k;
+ goto ret_d;
+ }
+ z = xa > xa0 ? *--xa : 0;
+ w = xa > xa0 ? *--xa : 0;
+ k -= Ebits + 16;
+ d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k;
+ y = xa > xa0 ? *--xa : 0;
+ d1 = w << k + 16 | y << k;
+#endif
+ret_d:
+#ifdef VAX
+ word0 (d) = d0 >> 16 | d0 << 16;
+ word1 (d) = d1 >> 16 | d1 << 16;
+#else
+#undef d0
+#undef d1
+#endif
+ return d.d;
+}
+
+_Bigint *
+_DEFUN (d2b,
+ (ptr, _d, e, bits),
+ struct _reent * ptr _AND
+ double _d _AND
+ int *e _AND
+ int *bits)
+
+{
+ union double_union d;
+ _Bigint *b;
+ int de, i, k;
+ __ULong *x, y, z;
+#ifdef VAX
+ __ULong d0, d1;
+#endif
+ d.d = _d;
+#ifdef VAX
+ d0 = word0 (d) >> 16 | word0 (d) << 16;
+ d1 = word1 (d) >> 16 | word1 (d) << 16;
+#else
+#define d0 word0(d)
+#define d1 word1(d)
+ d.d = _d;
+#endif
+
+#ifdef Pack_32
+ b = Balloc (ptr, 1);
+#else
+ b = Balloc (ptr, 2);
+#endif
+ x = b->_x;
+
+ z = d0 & Frac_mask;
+ d0 &= 0x7fffffff; /* clear sign bit, which we ignore */
+#ifdef Sudden_Underflow
+ de = (int) (d0 >> Exp_shift);
+#ifndef IBM
+ z |= Exp_msk11;
+#endif
+#else
+ if ((de = (int) (d0 >> Exp_shift)) != 0)
+ z |= Exp_msk1;
+#endif
+#ifdef Pack_32
+#ifndef _DOUBLE_IS_32BITS
+ if (d1)
+ {
+ y = d1;
+ k = lo0bits (&y);
+ if (k)
+ {
+ x[0] = y | z << (32 - k);
+ z >>= k;
+ }
+ else
+ x[0] = y;
+ i = b->_wds = (x[1] = z) ? 2 : 1;
+ }
+ else
+#endif
+ {
+#ifdef DEBUG
+ if (!z)
+ Bug ("Zero passed to d2b");
+#endif
+ k = lo0bits (&z);
+ x[0] = z;
+ i = b->_wds = 1;
+#ifndef _DOUBLE_IS_32BITS
+ k += 32;
+#endif
+ }
+#else
+ if (d1)
+ {
+ y = d1;
+ k = lo0bits (&y);
+ if (k)
+ if (k >= 16)
+ {
+ x[0] = y | z << 32 - k & 0xffff;
+ x[1] = z >> k - 16 & 0xffff;
+ x[2] = z >> k;
+ i = 2;
+ }
+ else
+ {
+ x[0] = y & 0xffff;
+ x[1] = y >> 16 | z << 16 - k & 0xffff;
+ x[2] = z >> k & 0xffff;
+ x[3] = z >> k + 16;
+ i = 3;
+ }
+ else
+ {
+ x[0] = y & 0xffff;
+ x[1] = y >> 16;
+ x[2] = z & 0xffff;
+ x[3] = z >> 16;
+ i = 3;
+ }
+ }
+ else
+ {
+#ifdef DEBUG
+ if (!z)
+ Bug ("Zero passed to d2b");
+#endif
+ k = lo0bits (&z);
+ if (k >= 16)
+ {
+ x[0] = z;
+ i = 0;
+ }
+ else
+ {
+ x[0] = z & 0xffff;
+ x[1] = z >> 16;
+ i = 1;
+ }
+ k += 32;
+ }
+ while (!x[i])
+ --i;
+ b->_wds = i + 1;
+#endif
+#ifndef Sudden_Underflow
+ if (de)
+ {
+#endif
+#ifdef IBM
+ *e = (de - Bias - (P - 1) << 2) + k;
+ *bits = 4 * P + 8 - k - hi0bits (word0 (d) & Frac_mask);
+#else
+ *e = de - Bias - (P - 1) + k;
+ *bits = P - k;
+#endif
+#ifndef Sudden_Underflow
+ }
+ else
+ {
+ *e = de - Bias - (P - 1) + 1 + k;
+#ifdef Pack_32
+ *bits = 32 * i - hi0bits (x[i - 1]);
+#else
+ *bits = (i + 2) * 16 - hi0bits (x[i]);
+#endif
+ }
+#endif
+ return b;
+}
+#undef d0
+#undef d1
+
+double
+_DEFUN (ratio, (a, b), _Bigint * a _AND _Bigint * b)
+
+{
+ union double_union da, db;
+ int k, ka, kb;
+
+ da.d = b2d (a, &ka);
+ db.d = b2d (b, &kb);
+#ifdef Pack_32
+ k = ka - kb + 32 * (a->_wds - b->_wds);
+#else
+ k = ka - kb + 16 * (a->_wds - b->_wds);
+#endif
+#ifdef IBM
+ if (k > 0)
+ {
+ word0 (da) += (k >> 2) * Exp_msk1;
+ if (k &= 3)
+ da.d *= 1 << k;
+ }
+ else
+ {
+ k = -k;
+ word0 (db) += (k >> 2) * Exp_msk1;
+ if (k &= 3)
+ db.d *= 1 << k;
+ }
+#else
+ if (k > 0)
+ word0 (da) += k * Exp_msk1;
+ else
+ {
+ k = -k;
+ word0 (db) += k * Exp_msk1;
+ }
+#endif
+ return da.d / db.d;
+}
+
+
+_CONST double
+ tens[] =
+{
+ 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9,
+ 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19,
+ 1e20, 1e21, 1e22, 1e23, 1e24
+
+};
+
+#if !defined(_DOUBLE_IS_32BITS) && !defined(__v800)
+_CONST double bigtens[] =
+{1e16, 1e32, 1e64, 1e128, 1e256};
+
+_CONST double tinytens[] =
+{1e-16, 1e-32, 1e-64, 1e-128, 1e-256};
+#else
+_CONST double bigtens[] =
+{1e16, 1e32};
+
+_CONST double tinytens[] =
+{1e-16, 1e-32};
+#endif
+
+
+double
+_DEFUN (_mprec_log10, (dig),
+ int dig)
+{
+ double v = 1.0;
+ if (dig < 24)
+ return tens[dig];
+ while (dig > 0)
+ {
+ v *= 10;
+ dig--;
+ }
+ return v;
+}
+
+void
+_DEFUN (copybits, (c, n, b),
+ __ULong *c _AND
+ int n _AND
+ _Bigint *b)
+{
+ __ULong *ce, *x, *xe;
+#ifdef Pack_16
+ int nw, nw1;
+#endif
+
+ ce = c + ((n-1) >> kshift) + 1;
+ x = b->_x;
+#ifdef Pack_32
+ xe = x + b->_wds;
+ while(x < xe)
+ *c++ = *x++;
+#else
+ nw = b->_wds;
+ nw1 = nw & 1;
+ for(xe = x + (nw - nw1); x < xe; x += 2)
+ Storeinc(c, x[1], x[0]);
+ if (nw1)
+ *c++ = *x;
+#endif
+ while(c < ce)
+ *c++ = 0;
+}
+
+__ULong
+_DEFUN (any_on, (b, k),
+ _Bigint *b _AND
+ int k)
+{
+ int n, nwds;
+ __ULong *x, *x0, x1, x2;
+
+ x = b->_x;
+ nwds = b->_wds;
+ n = k >> kshift;
+ if (n > nwds)
+ n = nwds;
+ else if (n < nwds && (k &= kmask)) {
+ x1 = x2 = x[n];
+ x1 >>= k;
+ x1 <<= k;
+ if (x1 != x2)
+ return 1;
+ }
+ x0 = x;
+ x += n;
+ while(x > x0)
+ if (*--x)
+ return 1;
+ return 0;
+}
+
mprec.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: malloc.c
===================================================================
--- malloc.c (nonexistent)
+++ malloc.c (revision 345)
@@ -0,0 +1,227 @@
+/* VxWorks provides its own version of malloc, and we can't use this
+ one because VxWorks does not provide sbrk. So we have a hook to
+ not compile this code. */
+
+/* The routines here are simple cover fns to the routines that do the real
+ work (the reentrant versions). */
+/* FIXME: Does the warning below (see WARNINGS) about non-reentrancy still
+ apply? A first guess would be "no", but how about reentrancy in the *same*
+ thread? */
+
+#ifdef MALLOC_PROVIDED
+
+int _dummy_malloc = 1;
+
+#else
+
+/*
+FUNCTION
+<>, <>, <>---manage memory
+
+INDEX
+ malloc
+INDEX
+ realloc
+INDEX
+ reallocf
+INDEX
+ free
+INDEX
+ memalign
+INDEX
+ malloc_usable_size
+INDEX
+ _malloc_r
+INDEX
+ _realloc_r
+INDEX
+ _reallocf_r
+INDEX
+ _free_r
+INDEX
+ _memalign_r
+INDEX
+ _malloc_usable_size_r
+
+ANSI_SYNOPSIS
+ #include
+ void *malloc(size_t <[nbytes]>);
+ void *realloc(void *<[aptr]>, size_t <[nbytes]>);
+ void *reallocf(void *<[aptr]>, size_t <[nbytes]>);
+ void free(void *<[aptr]>);
+
+ void *memalign(size_t <[align]>, size_t <[nbytes]>);
+
+ size_t malloc_usable_size(void *<[aptr]>);
+
+ void *_malloc_r(void *<[reent]>, size_t <[nbytes]>);
+ void *_realloc_r(void *<[reent]>,
+ void *<[aptr]>, size_t <[nbytes]>);
+ void *_reallocf_r(void *<[reent]>,
+ void *<[aptr]>, size_t <[nbytes]>);
+ void _free_r(void *<[reent]>, void *<[aptr]>);
+
+ void *_memalign_r(void *<[reent]>,
+ size_t <[align]>, size_t <[nbytes]>);
+
+ size_t _malloc_usable_size_r(void *<[reent]>, void *<[aptr]>);
+
+TRAD_SYNOPSIS
+ #include
+ char *malloc(<[nbytes]>)
+ size_t <[nbytes]>;
+
+ char *realloc(<[aptr]>, <[nbytes]>)
+ char *<[aptr]>;
+ size_t <[nbytes]>;
+
+ char *reallocf(<[aptr]>, <[nbytes]>)
+ char *<[aptr]>;
+ size_t <[nbytes]>;
+
+ void free(<[aptr]>)
+ char *<[aptr]>;
+
+ char *memalign(<[align]>, <[nbytes]>)
+ size_t <[align]>;
+ size_t <[nbytes]>;
+
+ size_t malloc_usable_size(<[aptr]>)
+ char *<[aptr]>;
+
+ char *_malloc_r(<[reent]>,<[nbytes]>)
+ char *<[reent]>;
+ size_t <[nbytes]>;
+
+ char *_realloc_r(<[reent]>, <[aptr]>, <[nbytes]>)
+ char *<[reent]>;
+ char *<[aptr]>;
+ size_t <[nbytes]>;
+
+ char *_reallocf_r(<[reent]>, <[aptr]>, <[nbytes]>)
+ char *<[reent]>;
+ char *<[aptr]>;
+ size_t <[nbytes]>;
+
+ void _free_r(<[reent]>, <[aptr]>)
+ char *<[reent]>;
+ char *<[aptr]>;
+
+ char *_memalign_r(<[reent]>, <[align]>, <[nbytes]>)
+ char *<[reent]>;
+ size_t <[align]>;
+ size_t <[nbytes]>;
+
+ size_t malloc_usable_size(<[reent]>, <[aptr]>)
+ char *<[reent]>;
+ char *<[aptr]>;
+
+DESCRIPTION
+These functions manage a pool of system memory.
+
+Use <> to request allocation of an object with at least
+<[nbytes]> bytes of storage available. If the space is available,
+<> returns a pointer to a newly allocated block as its result.
+
+If you already have a block of storage allocated by <>, but
+you no longer need all the space allocated to it, you can make it
+smaller by calling <> with both the object pointer and the
+new desired size as arguments. <> guarantees that the
+contents of the smaller object match the beginning of the original object.
+
+Similarly, if you need more space for an object, use <> to
+request the larger size; again, <> guarantees that the
+beginning of the new, larger object matches the contents of the
+original object.
+
+When you no longer need an object originally allocated by <>
+or <> (or the related function <>), return it to the
+memory storage pool by calling <> with the address of the object
+as the argument. You can also use <> for this purpose by
+calling it with <<0>> as the <[nbytes]> argument.
+
+The <> function behaves just like <> except if the
+function is required to allocate new storage and this fails. In this
+case <> will free the original object passed in whereas
+<> will not.
+
+The <> function returns a block of size <[nbytes]> aligned
+to a <[align]> boundary. The <[align]> argument must be a power of
+two.
+
+The <> function takes a pointer to a block
+allocated by <>. It returns the amount of space that is
+available in the block. This may or may not be more than the size
+requested from <>, due to alignment or minimum size
+constraints.
+
+The alternate functions <<_malloc_r>>, <<_realloc_r>>, <<_reallocf_r>>,
+<<_free_r>>, <<_memalign_r>>, and <<_malloc_usable_size_r>> are reentrant
+versions. The extra argument <[reent]> is a pointer to a reentrancy structure.
+
+If you have multiple threads of execution which may call any of these
+routines, or if any of these routines may be called reentrantly, then
+you must provide implementations of the <<__malloc_lock>> and
+<<__malloc_unlock>> functions for your system. See the documentation
+for those functions.
+
+These functions operate by calling the function <<_sbrk_r>> or
+<>, which allocates space. You may need to provide one of these
+functions for your system. <<_sbrk_r>> is called with a positive
+value to allocate more space, and with a negative value to release
+previously allocated space if it is no longer required.
+@xref{Stubs}.
+
+RETURNS
+<> returns a pointer to the newly allocated space, if
+successful; otherwise it returns <>. If your application needs
+to generate empty objects, you may use <> for this purpose.
+
+<> returns a pointer to the new block of memory, or <>
+if a new block could not be allocated. <> is also the result
+when you use `<,0)>>' (which has the same effect as
+`<)>>'). You should always check the result of
+<>; successful reallocation is not guaranteed even when
+you request a smaller object.
+
+<> does not return a result.
+
+<> returns a pointer to the newly allocated space.
+
+<> returns the usable size.
+
+PORTABILITY
+<>, <>, and <> are specified by the ANSI C
+standard, but other conforming implementations of <> may
+behave differently when <[nbytes]> is zero.
+
+<> is part of SVR4.
+
+<> is not portable.
+
+Supporting OS subroutines required: <>. */
+
+#include <_ansi.h>
+#include
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+_PTR
+_DEFUN (malloc, (nbytes),
+ size_t nbytes) /* get a block */
+{
+ return _malloc_r (_REENT, nbytes);
+}
+
+void
+_DEFUN (free, (aptr),
+ _PTR aptr)
+{
+ _free_r (_REENT, aptr);
+}
+
+#endif
+
+#endif /* ! defined (MALLOC_PROVIDED) */
malloc.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: lldiv.c
===================================================================
--- lldiv.c (nonexistent)
+++ lldiv.c (revision 345)
@@ -0,0 +1,115 @@
+/*
+FUNCTION
+<>---divide two long long integers
+
+INDEX
+ lldiv
+
+ANSI_SYNOPSIS
+ #include
+ lldiv_t lldiv(long long <[n]>, long long <[d]>);
+
+TRAD_SYNOPSIS
+ #include
+ lldiv_t lldiv(<[n]>, <[d]>)
+ long long <[n]>, <[d]>;
+
+DESCRIPTION
+Divide
+@tex
+$n/d$,
+@end tex
+@ifnottex
+<[n]>/<[d]>,
+@end ifnottex
+returning quotient and remainder as two long long integers in a structure
+<>.
+
+RETURNS
+The result is represented with the structure
+
+. typedef struct
+. {
+. long long quot;
+. long long rem;
+. } lldiv_t;
+
+where the <> field represents the quotient, and <> the
+remainder. For nonzero <[d]>, if `<<<[r]> = ldiv(<[n]>,<[d]>);>>' then
+<[n]> equals `<<<[r]>.rem + <[d]>*<[r]>.quot>>'.
+
+To divide <> rather than <> values, use the similar
+function <>.
+
+PORTABILITY
+<> is ISO 9899 (C99) compatable.
+
+No supporting OS subroutines are required.
+*/
+
+/*-
+ * Copyright (c) 2001 Mike Barcroft
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include
+
+/*
+ * The ANSI standard says that |r.quot| <= |n/d|, where
+ * n/d is to be computed in infinite precision. In other
+ * words, we should always truncate the quotient towards
+ * 0, never -infinity.
+ *
+ * Machine division and remainer may work either way when
+ * one or both of n or d is negative. If only one is
+ * negative and r.quot has been truncated towards -inf,
+ * r.rem will have the same sign as denom and the opposite
+ * sign of num; if both are negative and r.quot has been
+ * truncated towards -inf, r.rem will be positive (will
+ * have the opposite sign of num). These are considered
+ * `wrong'.
+ *
+ * If both are num and denom are positive, r will always
+ * be positive.
+ *
+ * This all boils down to:
+ * if num >= 0, but r.rem < 0, we got the wrong answer.
+ * In that case, to get the right answer, add 1 to r.quot and
+ * subtract denom from r.rem.
+ */
+lldiv_t
+_DEFUN (lldiv, (number, denom),
+ long long numer _AND long long denom)
+{
+ lldiv_t retval;
+
+ retval.quot = numer / denom;
+ retval.rem = numer % denom;
+ if (numer >= 0 && retval.rem < 0) {
+ retval.quot++;
+ retval.rem -= denom;
+ }
+ return (retval);
+}
+
lldiv.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mprec.h
===================================================================
--- mprec.h (nonexistent)
+++ mprec.h (revision 345)
@@ -0,0 +1,415 @@
+/****************************************************************
+ *
+ * The author of this software is David M. Gay.
+ *
+ * Copyright (c) 1991 by AT&T.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose without fee is hereby granted, provided that this entire notice
+ * is included in all copies of any software which is or includes a copy
+ * or modification of this software and in all copies of the supporting
+ * documentation for such software.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
+ * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ *
+ ***************************************************************/
+
+/* Please send bug reports to
+ David M. Gay
+ AT&T Bell Laboratories, Room 2C-463
+ 600 Mountain Avenue
+ Murray Hill, NJ 07974-2070
+ U.S.A.
+ dmg@research.att.com or research!dmg
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef __IEEE_LITTLE_ENDIAN
+#define IEEE_8087
+#endif
+
+#ifdef __IEEE_BIG_ENDIAN
+#define IEEE_MC68k
+#endif
+
+#ifdef __Z8000__
+#define Just_16
+#endif
+
+#ifdef DEBUG
+#include "stdio.h"
+#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);}
+#endif
+
+#ifdef Unsigned_Shifts
+#define Sign_Extend(a,b) if (b < 0) a |= (__uint32_t)0xffff0000;
+#else
+#define Sign_Extend(a,b) /*no-op*/
+#endif
+
+#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1
+Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined.
+#endif
+
+/* If we are going to examine or modify specific bits in a double using
+ the word0 and/or word1 macros, then we must wrap the double inside
+ a union. This is necessary to avoid undefined behavior according to
+ the ANSI C spec. */
+union double_union
+{
+ double d;
+ __uint32_t i[2];
+};
+
+#ifdef IEEE_8087
+#define word0(x) (x.i[1])
+#define word1(x) (x.i[0])
+#else
+#define word0(x) (x.i[0])
+#define word1(x) (x.i[1])
+#endif
+
+/* The following is taken from gdtoaimp.h for use with new strtod, but
+ adjusted to avoid invalid type-punning. */
+typedef __int32_t Long;
+
+/* Unfortunately, because __ULong might be a different type than
+ __uint32_t, we can't re-use union double_union as-is without
+ further edits in strtod.c. */
+typedef union { double d; __ULong i[2]; } U;
+
+#define dword0(x) word0(x)
+#define dword1(x) word1(x)
+#define dval(x) (x.d)
+
+#undef SI
+#ifdef Sudden_Underflow
+#define SI 1
+#else
+#define SI 0
+#endif
+
+#define Storeinc(a,b,c) (*(a)++ = (b) << 16 | (c) & 0xffff)
+
+/* #define P DBL_MANT_DIG */
+/* Ten_pmax = floor(P*log(2)/log(5)) */
+/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */
+/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */
+/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */
+
+#if defined(IEEE_8087) + defined(IEEE_MC68k)
+#if defined (_DOUBLE_IS_32BITS)
+#define Exp_shift 23
+#define Exp_shift1 23
+#define Exp_msk1 ((__uint32_t)0x00800000L)
+#define Exp_msk11 ((__uint32_t)0x00800000L)
+#define Exp_mask ((__uint32_t)0x7f800000L)
+#define P 24
+#define Bias 127
+#define NO_HEX_FP /* not supported in this case */
+#define IEEE_Arith
+#define Emin (-126)
+#define Exp_1 ((__uint32_t)0x3f800000L)
+#define Exp_11 ((__uint32_t)0x3f800000L)
+#define Ebits 8
+#define Frac_mask ((__uint32_t)0x007fffffL)
+#define Frac_mask1 ((__uint32_t)0x007fffffL)
+#define Ten_pmax 10
+#define Sign_bit ((__uint32_t)0x80000000L)
+#define Ten_pmax 10
+#define Bletch 2
+#define Bndry_mask ((__uint32_t)0x007fffffL)
+#define Bndry_mask1 ((__uint32_t)0x007fffffL)
+#define LSB 1
+#define Sign_bit ((__uint32_t)0x80000000L)
+#define Log2P 1
+#define Tiny0 0
+#define Tiny1 1
+#define Quick_max 5
+#define Int_max 6
+#define Infinite(x) (word0(x) == ((__uint32_t)0x7f800000L))
+#undef word0
+#undef word1
+#undef dword0
+#undef dword1
+
+#define word0(x) (x.i[0])
+#define word1(x) 0
+#define dword0(x) word0(x)
+#define dword1(x) 0
+#else
+
+#define Exp_shift 20
+#define Exp_shift1 20
+#define Exp_msk1 ((__uint32_t)0x100000L)
+#define Exp_msk11 ((__uint32_t)0x100000L)
+#define Exp_mask ((__uint32_t)0x7ff00000L)
+#define P 53
+#define Bias 1023
+#define IEEE_Arith
+#define Emin (-1022)
+#define Exp_1 ((__uint32_t)0x3ff00000L)
+#define Exp_11 ((__uint32_t)0x3ff00000L)
+#define Ebits 11
+#define Frac_mask ((__uint32_t)0xfffffL)
+#define Frac_mask1 ((__uint32_t)0xfffffL)
+#define Ten_pmax 22
+#define Bletch 0x10
+#define Bndry_mask ((__uint32_t)0xfffffL)
+#define Bndry_mask1 ((__uint32_t)0xfffffL)
+#define LSB 1
+#define Sign_bit ((__uint32_t)0x80000000L)
+#define Log2P 1
+#define Tiny0 0
+#define Tiny1 1
+#define Quick_max 14
+#define Int_max 14
+#define Infinite(x) (word0(x) == ((__uint32_t)0x7ff00000L)) /* sufficient test for here */
+
+#endif /* !_DOUBLE_IS_32BITS */
+
+#ifndef Flt_Rounds
+#ifdef FLT_ROUNDS
+#define Flt_Rounds FLT_ROUNDS
+#else
+#define Flt_Rounds 1
+#endif
+#endif /*Flt_Rounds*/
+
+#else /* !IEEE_8087 && !IEEE_MC68k */
+#undef Sudden_Underflow
+#define Sudden_Underflow
+#ifdef IBM
+#define Flt_Rounds 0
+#define Exp_shift 24
+#define Exp_shift1 24
+#define Exp_msk1 ((__uint32_t)0x1000000L)
+#define Exp_msk11 ((__uint32_t)0x1000000L)
+#define Exp_mask ((__uint32_t)0x7f000000L)
+#define P 14
+#define Bias 65
+#define Exp_1 ((__uint32_t)0x41000000L)
+#define Exp_11 ((__uint32_t)0x41000000L)
+#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */
+#define Frac_mask ((__uint32_t)0xffffffL)
+#define Frac_mask1 ((__uint32_t)0xffffffL)
+#define Bletch 4
+#define Ten_pmax 22
+#define Bndry_mask ((__uint32_t)0xefffffL)
+#define Bndry_mask1 ((__uint32_t)0xffffffL)
+#define LSB 1
+#define Sign_bit ((__uint32_t)0x80000000L)
+#define Log2P 4
+#define Tiny0 ((__uint32_t)0x100000L)
+#define Tiny1 0
+#define Quick_max 14
+#define Int_max 15
+#else /* VAX */
+#define Flt_Rounds 1
+#define Exp_shift 23
+#define Exp_shift1 7
+#define Exp_msk1 0x80
+#define Exp_msk11 ((__uint32_t)0x800000L)
+#define Exp_mask ((__uint32_t)0x7f80L)
+#define P 56
+#define Bias 129
+#define Exp_1 ((__uint32_t)0x40800000L)
+#define Exp_11 ((__uint32_t)0x4080L)
+#define Ebits 8
+#define Frac_mask ((__uint32_t)0x7fffffL)
+#define Frac_mask1 ((__uint32_t)0xffff007fL)
+#define Ten_pmax 24
+#define Bletch 2
+#define Bndry_mask ((__uint32_t)0xffff007fL)
+#define Bndry_mask1 ((__uint32_t)0xffff007fL)
+#define LSB ((__uint32_t)0x10000L)
+#define Sign_bit ((__uint32_t)0x8000L)
+#define Log2P 1
+#define Tiny0 0x80
+#define Tiny1 0
+#define Quick_max 15
+#define Int_max 15
+#endif
+#endif
+
+#ifndef IEEE_Arith
+#define ROUND_BIASED
+#else
+#define Scale_Bit 0x10
+#if defined(_DOUBLE_IS_32BITS) && defined(__v800)
+#define n_bigtens 2
+#else
+#define n_bigtens 5
+#endif
+#endif
+
+#ifdef IBM
+#define n_bigtens 3
+#endif
+
+#ifdef VAX
+#define n_bigtens 2
+#endif
+
+#ifndef __NO_INFNAN_CHECK
+#define INFNAN_CHECK
+#endif
+
+/*
+ * NAN_WORD0 and NAN_WORD1 are only referenced in strtod.c. Prior to
+ * 20050115, they used to be hard-wired here (to 0x7ff80000 and 0,
+ * respectively), but now are determined by compiling and running
+ * qnan.c to generate gd_qnan.h, which specifies d_QNAN0 and d_QNAN1.
+ * Formerly gdtoaimp.h recommended supplying suitable -DNAN_WORD0=...
+ * and -DNAN_WORD1=... values if necessary. This should still work.
+ * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.)
+ */
+#ifdef IEEE_Arith
+#ifdef IEEE_MC68k
+#define _0 0
+#define _1 1
+#ifndef NAN_WORD0
+#define NAN_WORD0 d_QNAN0
+#endif
+#ifndef NAN_WORD1
+#define NAN_WORD1 d_QNAN1
+#endif
+#else
+#define _0 1
+#define _1 0
+#ifndef NAN_WORD0
+#define NAN_WORD0 d_QNAN1
+#endif
+#ifndef NAN_WORD1
+#define NAN_WORD1 d_QNAN0
+#endif
+#endif
+#else
+#undef INFNAN_CHECK
+#endif
+
+#ifdef RND_PRODQUOT
+#define rounded_product(a,b) a = rnd_prod(a, b)
+#define rounded_quotient(a,b) a = rnd_quot(a, b)
+#ifdef KR_headers
+extern double rnd_prod(), rnd_quot();
+#else
+extern double rnd_prod(double, double), rnd_quot(double, double);
+#endif
+#else
+#define rounded_product(a,b) a *= b
+#define rounded_quotient(a,b) a /= b
+#endif
+
+#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1))
+#define Big1 ((__uint32_t)0xffffffffL)
+
+#ifndef Just_16
+/* When Pack_32 is not defined, we store 16 bits per 32-bit long.
+ * This makes some inner loops simpler and sometimes saves work
+ * during multiplications, but it often seems to make things slightly
+ * slower. Hence the default is now to store 32 bits per long.
+ */
+
+ #ifndef Pack_32
+ #define Pack_32
+ #endif
+#else /* Just_16 */
+ #ifndef Pack_16
+ #define Pack_16
+ #endif
+#endif /* Just_16 */
+
+#ifdef Pack_32
+#define ULbits 32
+#define kshift 5
+#define kmask 31
+#define ALL_ON 0xffffffff
+#else
+#define ULbits 16
+#define kshift 4
+#define kmask 15
+#define ALL_ON 0xffff
+#endif
+
+#ifdef __cplusplus
+extern "C" double strtod(const char *s00, char **se);
+extern "C" char *dtoa(double d, int mode, int ndigits,
+ int *decpt, int *sign, char **rve);
+#endif
+
+
+typedef struct _Bigint _Bigint;
+
+#define Balloc _Balloc
+#define Bfree _Bfree
+#define multadd __multadd
+#define s2b __s2b
+#define lo0bits __lo0bits
+#define hi0bits __hi0bits
+#define i2b __i2b
+#define mult __multiply
+#define pow5mult __pow5mult
+#define lshift __lshift
+#define cmp __mcmp
+#define diff __mdiff
+#define ulp __ulp
+#define b2d __b2d
+#define d2b __d2b
+#define ratio __ratio
+#define any_on __any_on
+#define gethex __gethex
+#define copybits __copybits
+#define hexnan __hexnan
+#define hexdig_init __hexdig_init
+
+#define hexdig __hexdig
+
+#define tens __mprec_tens
+#define bigtens __mprec_bigtens
+#define tinytens __mprec_tinytens
+
+struct _reent ;
+struct FPI;
+double _EXFUN(ulp,(double x));
+double _EXFUN(b2d,(_Bigint *a , int *e));
+_Bigint * _EXFUN(Balloc,(struct _reent *p, int k));
+void _EXFUN(Bfree,(struct _reent *p, _Bigint *v));
+_Bigint * _EXFUN(multadd,(struct _reent *p, _Bigint *, int, int));
+_Bigint * _EXFUN(s2b,(struct _reent *, const char*, int, int, __ULong));
+_Bigint * _EXFUN(i2b,(struct _reent *,int));
+_Bigint * _EXFUN(mult, (struct _reent *, _Bigint *, _Bigint *));
+_Bigint * _EXFUN(pow5mult, (struct _reent *, _Bigint *, int k));
+int _EXFUN(hi0bits,(__ULong));
+int _EXFUN(lo0bits,(__ULong *));
+_Bigint * _EXFUN(d2b,(struct _reent *p, double d, int *e, int *bits));
+_Bigint * _EXFUN(lshift,(struct _reent *p, _Bigint *b, int k));
+_Bigint * _EXFUN(diff,(struct _reent *p, _Bigint *a, _Bigint *b));
+int _EXFUN(cmp,(_Bigint *a, _Bigint *b));
+int _EXFUN(gethex,(struct _reent *p, _CONST char **sp, struct FPI *fpi, Long *exp, _Bigint **bp, int sign));
+double _EXFUN(ratio,(_Bigint *a, _Bigint *b));
+__ULong _EXFUN(any_on,(_Bigint *b, int k));
+void _EXFUN(copybits,(__ULong *c, int n, _Bigint *b));
+void _EXFUN(hexdig_init,(void));
+#ifdef INFNAN_CHECK
+int _EXFUN(hexnan,(_CONST char **sp, struct FPI *fpi, __ULong *x0));
+#endif
+
+#define Bcopy(x,y) memcpy((char *)&x->_sign, (char *)&y->_sign, y->_wds*sizeof(__Long) + 2*sizeof(int))
+
+extern _CONST double tinytens[];
+extern _CONST double bigtens[];
+extern _CONST double tens[];
+extern unsigned char hexdig[];
+
+
+double _EXFUN(_mprec_log10,(int));
mprec.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mstats.c
===================================================================
--- mstats.c (nonexistent)
+++ mstats.c (revision 345)
@@ -0,0 +1,160 @@
+/* VxWorks provides its own version of malloc, and we can't use this
+ one because VxWorks does not provide sbrk. So we have a hook to
+ not compile this code. */
+
+#ifdef MALLOC_PROVIDED
+
+int _dummy_mstats = 1;
+
+#else
+
+/*
+FUNCTION
+<>, <>, <>---malloc support
+
+INDEX
+ mallinfo
+INDEX
+ malloc_stats
+INDEX
+ mallopt
+INDEX
+ _mallinfo_r
+INDEX
+ _malloc_stats_r
+INDEX
+ _mallopt_r
+
+ANSI_SYNOPSIS
+ #include
+ struct mallinfo mallinfo(void);
+ void malloc_stats(void);
+ int mallopt(int <[parameter]>, <[value]>);
+
+ struct mallinfo _mallinfo_r(void *<[reent]>);
+ void _malloc_stats_r(void *<[reent]>);
+ int _mallopt_r(void *<[reent]>, int <[parameter]>, <[value]>);
+
+TRAD_SYNOPSIS
+ #include
+ struct mallinfo mallinfo();
+
+ void malloc_stats();
+
+ int mallopt(<[parameter]>, <[value]>)
+ int <[parameter]>;
+ int <[value]>;
+
+ struct mallinfo _mallinfo_r(<[reent]>);
+ char *<[reent]>;
+
+ void _malloc_stats_r(<[reent]>);
+ char *<[reent]>;
+
+ int _mallopt_r(<[reent]>, <[parameter]>, <[value]>)
+ char *<[reent]>;
+ int <[parameter]>;
+ int <[value]>;
+
+DESCRIPTION
+<> returns a structure describing the current state of
+memory allocation. The structure is defined in malloc.h. The
+following fields are defined: <> is the total amount of space
+in the heap; <> is the number of chunks which are not in use;
+<> is the total amount of space allocated by <>;
+<> is the total amount of space not in use; <> is
+the size of the top most memory block.
+
+<> print some statistics about memory allocation on
+standard error.
+
+<> takes a parameter and a value. The parameters are defined
+in malloc.h, and may be one of the following: <>
+sets the maximum amount of unused space in the top most block before
+releasing it back to the system in <> (the space is released by
+calling <<_sbrk_r>> with a negative argument); <> is the
+amount of padding to allocate whenever <<_sbrk_r>> is called to
+allocate more space.
+
+The alternate functions <<_mallinfo_r>>, <<_malloc_stats_r>>, and
+<<_mallopt_r>> are reentrant versions. The extra argument <[reent]>
+is a pointer to a reentrancy structure.
+
+RETURNS
+<> returns a mallinfo structure. The structure is defined
+in malloc.h.
+
+<> does not return a result.
+
+<> returns zero if the parameter could not be set, or
+non-zero if it could be set.
+
+PORTABILITY
+<> and <> are provided by SVR4, but <>
+takes different parameters on different systems. <> is
+not portable.
+
+*/
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+struct mallinfo
+_DEFUN_VOID (mallinfo)
+{
+ return _mallinfo_r (_REENT);
+}
+
+#if !defined (_ELIX_LEVEL) || _ELIX_LEVEL >= 2
+void
+_DEFUN_VOID (malloc_stats)
+{
+ _malloc_stats_r (_REENT);
+}
+
+int
+_DEFUN (mallopt, (p, v),
+ int p _AND
+ int v)
+{
+ return _mallopt_r (_REENT, p, v);
+}
+
+#endif /* !_ELIX_LEVEL || _ELIX_LEVEL >= 2 */
+
+#endif
+
+#if !defined (_ELIX_LEVEL) || _ELIX_LEVEL >= 2
+
+/* mstats is now compatibility code. It used to be real, for a
+ previous version of the malloc routines. It now just calls
+ malloc_stats. */
+
+void
+_DEFUN (_mstats_r, (ptr, s),
+ struct _reent *ptr _AND
+ char *s)
+{
+ _REENT_SMALL_CHECK_INIT(ptr);
+ fiprintf (_stderr_r (ptr), "Memory allocation statistics %s\n", s);
+ _malloc_stats_r (ptr);
+}
+
+#ifndef _REENT_ONLY
+void
+_DEFUN (mstats, (s),
+ char *s)
+{
+ _mstats_r (_REENT, s);
+}
+
+#endif
+
+#endif /* !_ELIX_LEVEL || _ELIX_LEVEL >= 2 */
+
+#endif /* ! defined (MALLOC_PROVIDED) */
mstats.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcstol.c
===================================================================
--- wcstol.c (nonexistent)
+++ wcstol.c (revision 345)
@@ -0,0 +1,226 @@
+/*
+FUNCTION
+ <>---wide string to long
+
+INDEX
+ wcstol
+INDEX
+ _wcstol_r
+
+ANSI_SYNOPSIS
+ #include
+ long wcstol(const wchar_t *<[s]>, wchar_t **<[ptr]>,int <[base]>);
+
+ long _wcstol_r(void *<[reent]>,
+ const wchar_t *<[s]>, wchar_t **<[ptr]>,int <[base]>);
+
+TRAD_SYNOPSIS
+ #include
+ long wcstol (<[s]>, <[ptr]>, <[base]>)
+ wchar_t *<[s]>;
+ wchar_t **<[ptr]>;
+ int <[base]>;
+
+ long _wcstol_r (<[reent]>, <[s]>, <[ptr]>, <[base]>)
+ struct _reent *<[reent]>;
+ wchar_t *<[s]>;
+ wchar_t **<[ptr]>;
+ int <[base]>;
+
+DESCRIPTION
+The function <> converts the wide string <<*<[s]>>> to
+a <>. First, it breaks down the string into three parts:
+leading whitespace, which is ignored; a subject string consisting
+of characters resembling an integer in the radix specified by <[base]>;
+and a trailing portion consisting of zero or more unparseable characters,
+and always including the terminating null character. Then, it attempts
+to convert the subject string into a <> and returns the
+result.
+
+If the value of <[base]> is 0, the subject string is expected to look
+like a normal C integer constant: an optional sign, a possible `<<0x>>'
+indicating a hexadecimal base, and a number. If <[base]> is between
+2 and 36, the expected form of the subject is a sequence of letters
+and digits representing an integer in the radix specified by <[base]>,
+with an optional plus or minus sign. The letters <>--<> (or,
+equivalently, <>--<>) are used to signify values from 10 to 35;
+only letters whose ascribed values are less than <[base]> are
+permitted. If <[base]> is 16, a leading <<0x>> is permitted.
+
+The subject sequence is the longest initial sequence of the input
+string that has the expected form, starting with the first
+non-whitespace character. If the string is empty or consists entirely
+of whitespace, or if the first non-whitespace character is not a
+permissible letter or digit, the subject string is empty.
+
+If the subject string is acceptable, and the value of <[base]> is zero,
+<> attempts to determine the radix from the input string. A
+string with a leading <<0x>> is treated as a hexadecimal value; a string with
+a leading 0 and no <> is treated as octal; all other strings are
+treated as decimal. If <[base]> is between 2 and 36, it is used as the
+conversion radix, as described above. If the subject string begins with
+a minus sign, the value is negated. Finally, a pointer to the first
+character past the converted subject string is stored in <[ptr]>, if
+<[ptr]> is not <>.
+
+If the subject string is empty (or not in acceptable form), no conversion
+is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is
+not <>).
+
+The alternate function <<_wcstol_r>> is a reentrant version. The
+extra argument <[reent]> is a pointer to a reentrancy structure.
+
+RETURNS
+<> returns the converted value, if any. If no conversion was
+made, 0 is returned.
+
+<> returns <> or <> if the magnitude of
+the converted value is too large, and sets <> to <>.
+
+PORTABILITY
+<> is ANSI.
+
+No supporting OS subroutines are required.
+*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * Convert a wide string to a long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+long
+_DEFUN (_wcstol_r, (rptr, nptr, endptr, base),
+ struct _reent *rptr _AND
+ _CONST wchar_t *nptr _AND
+ wchar_t **endptr _AND
+ int base)
+{
+ register const wchar_t *s = nptr;
+ register unsigned long acc;
+ register int c;
+ register unsigned long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * Skip white space and pick up leading +/- sign if any.
+ * If base is 0, allow 0x for hex and 0 for octal, else
+ * assume decimal; if base is already 16, allow 0x.
+ */
+ do {
+ c = *s++;
+ } while (iswspace(c));
+ if (c == L'-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == L'+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == L'0' && (*s == L'x' || *s == L'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == L'0' ? 8 : 10;
+
+ /*
+ * Compute the cutoff value between legal numbers and illegal
+ * numbers. That is the largest legal value, divided by the
+ * base. An input number that is greater than this value, if
+ * followed by a legal input character, is too big. One that
+ * is equal to this value may be valid or not; the limit
+ * between valid and invalid numbers is then based on the last
+ * digit. For instance, if the range for longs is
+ * [-2147483648..2147483647] and the input base is 10,
+ * cutoff will be set to 214748364 and cutlim to either
+ * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
+ * a value > 214748364, or equal but the next digit is > 7 (or 8),
+ * the number is too big, and we will return a range error.
+ *
+ * Set any if any `digits' consumed; make it negative to indicate
+ * overflow.
+ */
+ cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
+ cutlim = cutoff % (unsigned long)base;
+ cutoff /= (unsigned long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (iswdigit(c))
+ c -= L'0';
+ else if (iswalpha(c))
+ c -= iswupper(c) ? L'A' - 10 : L'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = neg ? LONG_MIN : LONG_MAX;
+ rptr->_errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (wchar_t *) (any ? s - 1 : nptr);
+ return (acc);
+}
+
+#ifndef _REENT_ONLY
+
+long
+_DEFUN (wcstol, (s, ptr, base),
+ _CONST wchar_t *s _AND
+ wchar_t **ptr _AND
+ int base)
+{
+ return _wcstol_r (_REENT, s, ptr, base);
+}
+
+#endif
wcstol.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: strtoul.c
===================================================================
--- strtoul.c (nonexistent)
+++ strtoul.c (revision 345)
@@ -0,0 +1,206 @@
+/*
+FUNCTION
+ <>---string to unsigned long
+
+INDEX
+ strtoul
+INDEX
+ _strtoul_r
+
+ANSI_SYNOPSIS
+ #include
+ unsigned long strtoul(const char *<[s]>, char **<[ptr]>,
+ int <[base]>);
+
+ unsigned long _strtoul_r(void *<[reent]>, const char *<[s]>,
+ char **<[ptr]>, int <[base]>);
+
+TRAD_SYNOPSIS
+ #include
+ unsigned long strtoul(<[s]>, <[ptr]>, <[base]>)
+ char *<[s]>;
+ char **<[ptr]>;
+ int <[base]>;
+
+ unsigned long _strtoul_r(<[reent]>, <[s]>, <[ptr]>, <[base]>)
+ char *<[reent]>;
+ char *<[s]>;
+ char **<[ptr]>;
+ int <[base]>;
+
+DESCRIPTION
+The function <> converts the string <<*<[s]>>> to
+an <>. First, it breaks down the string into three parts:
+leading whitespace, which is ignored; a subject string consisting
+of the digits meaningful in the radix specified by <[base]>
+(for example, <<0>> through <<7>> if the value of <[base]> is 8);
+and a trailing portion consisting of one or more unparseable characters,
+which always includes the terminating null character. Then, it attempts
+to convert the subject string into an unsigned long integer, and returns the
+result.
+
+If the value of <[base]> is zero, the subject string is expected to look
+like a normal C integer constant (save that no optional sign is permitted):
+a possible <<0x>> indicating hexadecimal radix, and a number.
+If <[base]> is between 2 and 36, the expected form of the subject is a
+sequence of digits (which may include letters, depending on the
+base) representing an integer in the radix specified by <[base]>.
+The letters <>--<> (or <>--<>) are used as digits valued from
+10 to 35. If <[base]> is 16, a leading <<0x>> is permitted.
+
+The subject sequence is the longest initial sequence of the input
+string that has the expected form, starting with the first
+non-whitespace character. If the string is empty or consists entirely
+of whitespace, or if the first non-whitespace character is not a
+permissible digit, the subject string is empty.
+
+If the subject string is acceptable, and the value of <[base]> is zero,
+<> attempts to determine the radix from the input string. A
+string with a leading <<0x>> is treated as a hexadecimal value; a string with
+a leading <<0>> and no <> is treated as octal; all other strings are
+treated as decimal. If <[base]> is between 2 and 36, it is used as the
+conversion radix, as described above. Finally, a pointer to the first
+character past the converted subject string is stored in <[ptr]>, if
+<[ptr]> is not <>.
+
+If the subject string is empty (that is, if <<*>><[s]> does not start
+with a substring in acceptable form), no conversion
+is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is
+not <>).
+
+The alternate function <<_strtoul_r>> is a reentrant version. The
+extra argument <[reent]> is a pointer to a reentrancy structure.
+
+
+RETURNS
+<> returns the converted value, if any. If no conversion was
+made, <<0>> is returned.
+
+<> returns <> if the magnitude of the converted
+value is too large, and sets <> to <>.
+
+PORTABILITY
+<> is ANSI.
+
+<> requires no supporting OS subroutines.
+*/
+
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * Convert a string to an unsigned long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+unsigned long
+_DEFUN (_strtoul_r, (rptr, nptr, endptr, base),
+ struct _reent *rptr _AND
+ _CONST char *nptr _AND
+ char **endptr _AND
+ int base)
+{
+ register const char *s = nptr;
+ register unsigned long acc;
+ register int c;
+ register unsigned long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * See strtol for comments as to the logic used.
+ */
+ do {
+ c = *s++;
+ } while (isspace(c));
+ if (c == '-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+ cutoff = (unsigned long)ULONG_MAX / (unsigned long)base;
+ cutlim = (unsigned long)ULONG_MAX % (unsigned long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (isdigit(c))
+ c -= '0';
+ else if (isalpha(c))
+ c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = ULONG_MAX;
+ rptr->_errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (char *) (any ? s - 1 : nptr);
+ return (acc);
+}
+
+#ifndef _REENT_ONLY
+
+unsigned long
+_DEFUN (strtoul, (s, ptr, base),
+ _CONST char *s _AND
+ char **ptr _AND
+ int base)
+{
+ return _strtoul_r (_REENT, s, ptr, base);
+}
+
+#endif
strtoul.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcrtomb.c
===================================================================
--- wcrtomb.c (nonexistent)
+++ wcrtomb.c (revision 345)
@@ -0,0 +1,78 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include "local.h"
+
+size_t
+_DEFUN (_wcrtomb_r, (ptr, s, wc, ps),
+ struct _reent *ptr _AND
+ char *s _AND
+ wchar_t wc _AND
+ mbstate_t *ps)
+{
+ int retval = 0;
+ char buf[10];
+
+#ifdef _MB_CAPABLE
+ if (ps == NULL)
+ {
+ _REENT_CHECK_MISC(ptr);
+ ps = &(_REENT_WCRTOMB_STATE(ptr));
+ }
+#endif
+
+ if (s == NULL)
+ retval = __wctomb (ptr, buf, L'\0', __locale_charset (), ps);
+ else
+ retval = __wctomb (ptr, s, wc, __locale_charset (), ps);
+
+ if (retval == -1)
+ {
+ ps->__count = 0;
+ ptr->_errno = EILSEQ;
+ return (size_t)(-1);
+ }
+ else
+ return (size_t)retval;
+}
+
+#ifndef _REENT_ONLY
+size_t
+_DEFUN (wcrtomb, (s, wc, ps),
+ char *s _AND
+ wchar_t wc _AND
+ mbstate_t *ps)
+{
+#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
+ return _wcrtomb_r (_REENT, s, wc, ps);
+#else
+ int retval = 0;
+ char buf[10];
+
+#ifdef _MB_CAPABLE
+ if (ps == NULL)
+ {
+ _REENT_CHECK_MISC(_REENT);
+ ps = &(_REENT_WCRTOMB_STATE(_REENT));
+ }
+#endif
+
+ if (s == NULL)
+ retval = __wctomb (_REENT, buf, L'\0', __locale_charset (), ps);
+ else
+ retval = __wctomb (_REENT, s, wc, __locale_charset (), ps);
+
+ if (retval == -1)
+ {
+ ps->__count = 0;
+ _REENT->_errno = EILSEQ;
+ return (size_t)(-1);
+ }
+ else
+ return (size_t)retval;
+#endif /* not PREFER_SIZE_OVER_SPEED */
+}
+#endif /* !_REENT_ONLY */
wcrtomb.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: btowc.c
===================================================================
--- btowc.c (nonexistent)
+++ btowc.c (revision 345)
@@ -0,0 +1,29 @@
+#include
+#include
+#include
+#include
+#include
+#include "local.h"
+
+wint_t
+btowc (int c)
+{
+ mbstate_t mbs;
+ int retval = 0;
+ wchar_t pwc;
+ unsigned char b;
+
+ b = (unsigned char)c;
+
+ /* Put mbs in initial state. */
+ memset (&mbs, '\0', sizeof (mbs));
+
+ _REENT_CHECK_MISC(_REENT);
+
+ retval = __mbtowc (_REENT, &pwc, &b, 1, __locale_charset (), &mbs);
+
+ if (c == EOF || retval != 1)
+ return WEOF;
+ else
+ return (wint_t)pwc;
+}
btowc.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: efgcvt.c
===================================================================
--- efgcvt.c (nonexistent)
+++ efgcvt.c (revision 345)
@@ -0,0 +1,206 @@
+/*
+FUNCTION
+<>, <>, <>, <>---double or float to string
+
+INDEX
+ ecvt
+INDEX
+ ecvtf
+INDEX
+ fcvt
+INDEX
+ fcvtf
+
+ANSI_SYNOPSIS
+ #include
+
+ 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
+
+ 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
+<> and <> produce (null-terminated) strings of digits
+representating the <> number <[val]>.
+<> and <> produce the corresponding character
+representations of <> numbers.
+
+(The <> functions <> and <> are reentrant
+versions of <> and <>.)
+
+The only difference between <> and <> is the
+interpretation of the second argument (<[chars]> or <[decimals]>).
+For <>, 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 <>, 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 <> and <> 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: <>, <>, <>,
+<>, <>, <>, <>.
+
+NEWPAGE
+FUNCTION
+<>, <>---format double or float as string
+
+INDEX
+ gcvt
+INDEX
+ gcvtf
+
+ANSI_SYNOPSIS
+ #include
+
+ char *gcvt(double <[val]>, int <[precision]>, char *<[buf]>);
+ char *gcvtf(float <[val]>, int <[precision]>, char *<[buf]>);
+
+TRAD_SYNOPSIS
+ #include
+
+ char *gcvt(<[val]>, <[precision]>, <[buf]>);
+ double <[val]>;
+ int <[precision]>;
+ char *<[buf]>;
+ char *gcvtf(<[val]>, <[precision]>, <[buf]>);
+ float <[val]>;
+ int <[precision]>;
+ char *<[buf]>;
+
+DESCRIPTION
+<> writes a fully formatted number as a null-terminated
+string in the buffer <<*<[buf]>>>. <> produces corresponding
+character representations of <> numbers.
+
+<> uses the same rules as the <> 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: <>, <>, <>,
+<>, <>, <>, <>.
+*/
+
+#include <_ansi.h>
+#include
+#include
+#include
+#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);
+}
efgcvt.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mbrlen.c
===================================================================
--- mbrlen.c (nonexistent)
+++ mbrlen.c (revision 345)
@@ -0,0 +1,20 @@
+#include
+#include
+#include
+#include
+#include
+#include
+
+size_t
+mbrlen(const char *s, size_t n, mbstate_t *ps)
+{
+#ifdef _MB_CAPABLE
+ if (ps == NULL)
+ {
+ _REENT_CHECK_MISC(_REENT);
+ ps = &(_REENT_MBRLEN_STATE(_REENT));
+ }
+#endif
+
+ return mbrtowc(NULL, s, n, ps);
+}
mbrlen.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: environ.c
===================================================================
--- environ.c (nonexistent)
+++ environ.c (revision 345)
@@ -0,0 +1,36 @@
+/* Copyright (c) 1995, 1996, 2002 Red Hat Incorporated.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * The name of Red Hat Incorporated may not be used to endorse
+ * or promote products derived from this software without specific
+ * prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Provide a definition of `environ' if crt0.o doesn't. */
+
+static char *initial_env[] = { 0 };
+
+/* Posix says `environ' is a pointer to a null terminated list of pointers.
+ Hence `environ' itself is never NULL. */
+char **environ = &initial_env[0];
environ.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: strtoll_r.c
===================================================================
--- strtoll_r.c (nonexistent)
+++ strtoll_r.c (revision 345)
@@ -0,0 +1,140 @@
+/*
+ This code is based on strtoul.c which has the following copyright.
+ It is used to convert a string into a signed long long.
+
+ long long _strtoll_r (struct _reent *rptr, const char *s,
+ char **ptr, int base);
+*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef __GNUC__
+
+#define _GNU_SOURCE
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * Convert a string to a long long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+long long
+_DEFUN (_strtoll_r, (rptr, nptr, endptr, base),
+ struct _reent *rptr _AND
+ _CONST char *nptr _AND
+ char **endptr _AND
+ int base)
+{
+ register const char *s = nptr;
+ register unsigned long long acc;
+ register int c;
+ register unsigned long long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * Skip white space and pick up leading +/- sign if any.
+ * If base is 0, allow 0x for hex and 0 for octal, else
+ * assume decimal; if base is already 16, allow 0x.
+ */
+ do {
+ c = *s++;
+ } while (isspace(c));
+ if (c == '-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+
+ /*
+ * Compute the cutoff value between legal numbers and illegal
+ * numbers. That is the largest legal value, divided by the
+ * base. An input number that is greater than this value, if
+ * followed by a legal input character, is too big. One that
+ * is equal to this value may be valid or not; the limit
+ * between valid and invalid numbers is then based on the last
+ * digit. For instance, if the range for longs is
+ * [-2147483648..2147483647] and the input base is 10,
+ * cutoff will be set to 214748364 and cutlim to either
+ * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
+ * a value > 214748364, or equal but the next digit is > 7 (or 8),
+ * the number is too big, and we will return a range error.
+ *
+ * Set any if any `digits' consumed; make it negative to indicate
+ * overflow.
+ */
+ cutoff = neg ? -(unsigned long long)LONG_LONG_MIN : LONG_LONG_MAX;
+ cutlim = cutoff % (unsigned long long)base;
+ cutoff /= (unsigned long long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (isdigit(c))
+ c -= '0';
+ else if (isalpha(c))
+ c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = neg ? LONG_LONG_MIN : LONG_LONG_MAX;
+ rptr->_errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (char *) (any ? s - 1 : nptr);
+ return (acc);
+}
+
+#endif /* __GNUC__ */
strtoll_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: system.c
===================================================================
--- system.c (nonexistent)
+++ system.c (revision 345)
@@ -0,0 +1,191 @@
+/*
+FUNCTION
+<>---execute command string
+
+INDEX
+ system
+INDEX
+ _system_r
+
+ANSI_SYNOPSIS
+ #include
+ int system(char *<[s]>);
+
+ int _system_r(void *<[reent]>, char *<[s]>);
+
+TRAD_SYNOPSIS
+ #include
+ int system(<[s]>)
+ char *<[s]>;
+
+ int _system_r(<[reent]>, <[s]>)
+ char *<[reent]>;
+ char *<[s]>;
+
+DESCRIPTION
+
+Use <> to pass a command string <<*<[s]>>> to <> on
+your system, and wait for it to finish executing.
+
+Use ``<>'' to test whether your system has <>
+available.
+
+The alternate function <<_system_r>> is a reentrant version. The
+extra argument <[reent]> is a pointer to a reentrancy structure.
+
+RETURNS
+<> returns a non-zero value if <> is available, and
+<<0>> if it is not.
+
+With a command argument, the result of <> is the exit status
+returned by <>.
+
+PORTABILITY
+ANSI C requires <>, but leaves the nature and effects of a
+command processor undefined. ANSI C does, however, specify that
+<> return zero or nonzero to report on the existence of
+a command processor.
+
+POSIX.2 requires <>, and requires that it invoke a <>.
+Where <> is found is left unspecified.
+
+Supporting OS subroutines required: <<_exit>>, <<_execve>>, <<_fork_r>>,
+<<_wait_r>>.
+*/
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include <_syslist.h>
+#include
+
+#if defined (unix) || defined (__CYGWIN__)
+static int _EXFUN(do_system, (struct _reent *ptr _AND _CONST char *s));
+#endif
+
+int
+_DEFUN(_system_r, (ptr, s),
+ struct _reent *ptr _AND
+ _CONST char *s)
+{
+#if defined(HAVE_SYSTEM)
+ return _system (s);
+ ptr = ptr;
+#elif defined(NO_EXEC)
+ if (s == NULL)
+ return 0;
+ errno = ENOSYS;
+ return -1;
+#else
+
+ /* ??? How to handle (s == NULL) here is not exactly clear.
+ If _fork_r fails, that's not really a justification for returning 0.
+ For now we always return 0 and leave it to each target to explicitly
+ handle otherwise (this can always be relaxed in the future). */
+
+#if defined (unix) || defined (__CYGWIN__)
+ if (s == NULL)
+ return 1;
+ return do_system (ptr, s);
+#else
+ if (s == NULL)
+ return 0;
+ errno = ENOSYS;
+ return -1;
+#endif
+
+#endif
+}
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN(system, (s),
+ _CONST char *s)
+{
+ return _system_r (_REENT, s);
+}
+
+#endif
+
+#if defined (unix) && !defined (__CYGWIN__) && !defined(__rtems__)
+extern char **environ;
+
+/* Only deal with a pointer to environ, to work around subtle bugs with shared
+ libraries and/or small data systems where the user declares his own
+ 'environ'. */
+static char ***p_environ = &environ;
+
+static int
+_DEFUN(do_system, (ptr, s),
+ struct _reent *ptr _AND
+ _CONST char *s)
+{
+ char *argv[4];
+ int pid, status;
+
+ argv[0] = "sh";
+ argv[1] = "-c";
+ argv[2] = (char *) s;
+ argv[3] = NULL;
+
+ if ((pid = _fork_r (ptr)) == 0)
+ {
+ _execve ("/bin/sh", argv, *p_environ);
+ exit (100);
+ }
+ else if (pid == -1)
+ return -1;
+ else
+ {
+ int rc = _wait_r (ptr, &status);
+ if (rc == -1)
+ return -1;
+ status = (status >> 8) & 0xff;
+ return status;
+ }
+}
+#endif
+
+#if defined (__CYGWIN__)
+static int
+_DEFUN(do_system, (ptr, s),
+ struct _reent *ptr _AND
+ _CONST char *s)
+{
+ char *argv[4];
+ int pid, status;
+
+ argv[0] = "sh";
+ argv[1] = "-c";
+ argv[2] = (char *) s;
+ argv[3] = NULL;
+
+ if ((pid = vfork ()) == 0)
+ {
+ /* ??? It's not clear what's the right path to take (pun intended :-).
+ There won't be an "sh" in any fixed location so we need each user
+ to be able to say where to find "sh". That suggests using an
+ environment variable, but after a few more such situations we may
+ have too many of them. */
+ char *sh = getenv ("SH_PATH");
+ if (sh == NULL)
+ sh = "/bin/sh";
+ _execve (sh, argv, environ);
+ exit (100);
+ }
+ else if (pid == -1)
+ return -1;
+ else
+ {
+ extern int _wait (int *);
+ int rc = _wait (&status);
+ if (rc == -1)
+ return -1;
+ status = (status >> 8) & 0xff;
+ return status;
+ }
+}
+#endif
system.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: dtoastub.c
===================================================================
--- dtoastub.c (nonexistent)
+++ dtoastub.c (revision 345)
@@ -0,0 +1,23 @@
+#include <_ansi.h>
+#include
+#include
+#include
+
+/* Nothing in newlib actually *calls* dtoa, they all call _dtoa_r, so this
+ is a safe way of providing it to the user. */
+#ifndef _REENT_ONLY
+
+char *
+_DEFUN (__dtoa,
+ (d, mode, ndigits, decpt, sign, rve),
+ double d _AND
+ int mode _AND
+ int ndigits _AND
+ int *decpt _AND
+ int *sign _AND
+ char **rve)
+{
+ return _dtoa_r (_REENT, d, mode, ndigits, decpt, sign, rve);
+}
+
+#endif
dtoastub.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: dtoa.c
===================================================================
--- dtoa.c (nonexistent)
+++ dtoa.c (revision 345)
@@ -0,0 +1,862 @@
+/****************************************************************
+ *
+ * The author of this software is David M. Gay.
+ *
+ * Copyright (c) 1991 by AT&T.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose without fee is hereby granted, provided that this entire notice
+ * is included in all copies of any software which is or includes a copy
+ * or modification of this software and in all copies of the supporting
+ * documentation for such software.
+ *
+ * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED
+ * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY
+ * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
+ * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
+ *
+ ***************************************************************/
+
+/* Please send bug reports to
+ David M. Gay
+ AT&T Bell Laboratories, Room 2C-463
+ 600 Mountain Avenue
+ Murray Hill, NJ 07974-2070
+ U.S.A.
+ dmg@research.att.com or research!dmg
+ */
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include "mprec.h"
+
+static int
+_DEFUN (quorem,
+ (b, S),
+ _Bigint * b _AND _Bigint * S)
+{
+ int n;
+ __Long borrow, y;
+ __ULong carry, q, ys;
+ __ULong *bx, *bxe, *sx, *sxe;
+#ifdef Pack_32
+ __Long z;
+ __ULong si, zs;
+#endif
+
+ n = S->_wds;
+#ifdef DEBUG
+ /*debug*/ if (b->_wds > n)
+ /*debug*/ Bug ("oversize b in quorem");
+#endif
+ if (b->_wds < n)
+ return 0;
+ sx = S->_x;
+ sxe = sx + --n;
+ bx = b->_x;
+ bxe = bx + n;
+ q = *bxe / (*sxe + 1); /* ensure q <= true quotient */
+#ifdef DEBUG
+ /*debug*/ if (q > 9)
+ /*debug*/ Bug ("oversized quotient in quorem");
+#endif
+ if (q)
+ {
+ borrow = 0;
+ carry = 0;
+ do
+ {
+#ifdef Pack_32
+ si = *sx++;
+ ys = (si & 0xffff) * q + carry;
+ zs = (si >> 16) * q + (ys >> 16);
+ carry = zs >> 16;
+ y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
+ borrow = y >> 16;
+ Sign_Extend (borrow, y);
+ z = (*bx >> 16) - (zs & 0xffff) + borrow;
+ borrow = z >> 16;
+ Sign_Extend (borrow, z);
+ Storeinc (bx, z, y);
+#else
+ ys = *sx++ * q + carry;
+ carry = ys >> 16;
+ y = *bx - (ys & 0xffff) + borrow;
+ borrow = y >> 16;
+ Sign_Extend (borrow, y);
+ *bx++ = y & 0xffff;
+#endif
+ }
+ while (sx <= sxe);
+ if (!*bxe)
+ {
+ bx = b->_x;
+ while (--bxe > bx && !*bxe)
+ --n;
+ b->_wds = n;
+ }
+ }
+ if (cmp (b, S) >= 0)
+ {
+ q++;
+ borrow = 0;
+ carry = 0;
+ bx = b->_x;
+ sx = S->_x;
+ do
+ {
+#ifdef Pack_32
+ si = *sx++;
+ ys = (si & 0xffff) + carry;
+ zs = (si >> 16) + (ys >> 16);
+ carry = zs >> 16;
+ y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
+ borrow = y >> 16;
+ Sign_Extend (borrow, y);
+ z = (*bx >> 16) - (zs & 0xffff) + borrow;
+ borrow = z >> 16;
+ Sign_Extend (borrow, z);
+ Storeinc (bx, z, y);
+#else
+ ys = *sx++ + carry;
+ carry = ys >> 16;
+ y = *bx - (ys & 0xffff) + borrow;
+ borrow = y >> 16;
+ Sign_Extend (borrow, y);
+ *bx++ = y & 0xffff;
+#endif
+ }
+ while (sx <= sxe);
+ bx = b->_x;
+ bxe = bx + n;
+ if (!*bxe)
+ {
+ while (--bxe > bx && !*bxe)
+ --n;
+ b->_wds = n;
+ }
+ }
+ return q;
+}
+
+/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string.
+ *
+ * Inspired by "How to Print Floating-Point Numbers Accurately" by
+ * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101].
+ *
+ * Modifications:
+ * 1. Rather than iterating, we use a simple numeric overestimate
+ * to determine k = floor(log10(d)). We scale relevant
+ * quantities using O(log2(k)) rather than O(k) multiplications.
+ * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't
+ * try to generate digits strictly left to right. Instead, we
+ * compute with fewer bits and propagate the carry if necessary
+ * when rounding the final digit up. This is often faster.
+ * 3. Under the assumption that input will be rounded nearest,
+ * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22.
+ * That is, we allow equality in stopping tests when the
+ * round-nearest rule will give the same floating-point value
+ * as would satisfaction of the stopping test with strict
+ * inequality.
+ * 4. We remove common factors of powers of 2 from relevant
+ * quantities.
+ * 5. When converting floating-point integers less than 1e16,
+ * we use floating-point arithmetic rather than resorting
+ * to multiple-precision integers.
+ * 6. When asked to produce fewer than 15 digits, we first try
+ * to get by with floating-point arithmetic; we resort to
+ * multiple-precision integer arithmetic only if we cannot
+ * guarantee that the floating-point calculation has given
+ * the correctly rounded result. For k requested digits and
+ * "uniformly" distributed input, the probability is
+ * something like 10^(k-15) that we must resort to the long
+ * calculation.
+ */
+
+
+char *
+_DEFUN (_dtoa_r,
+ (ptr, _d, mode, ndigits, decpt, sign, rve),
+ struct _reent *ptr _AND
+ double _d _AND
+ int mode _AND
+ int ndigits _AND
+ int *decpt _AND
+ int *sign _AND
+ char **rve)
+{
+ /* Arguments ndigits, decpt, sign are similar to those
+ of ecvt and fcvt; trailing zeros are suppressed from
+ the returned string. If not null, *rve is set to point
+ to the end of the return value. If d is +-Infinity or NaN,
+ then *decpt is set to 9999.
+
+ mode:
+ 0 ==> shortest string that yields d when read in
+ and rounded to nearest.
+ 1 ==> like 0, but with Steele & White stopping rule;
+ e.g. with IEEE P754 arithmetic , mode 0 gives
+ 1e23 whereas mode 1 gives 9.999999999999999e22.
+ 2 ==> max(1,ndigits) significant digits. This gives a
+ return value similar to that of ecvt, except
+ that trailing zeros are suppressed.
+ 3 ==> through ndigits past the decimal point. This
+ gives a return value similar to that from fcvt,
+ except that trailing zeros are suppressed, and
+ ndigits can be negative.
+ 4-9 should give the same return values as 2-3, i.e.,
+ 4 <= mode <= 9 ==> same return as mode
+ 2 + (mode & 1). These modes are mainly for
+ debugging; often they run slower but sometimes
+ faster than modes 2-3.
+ 4,5,8,9 ==> left-to-right digit generation.
+ 6-9 ==> don't try fast floating-point estimate
+ (if applicable).
+
+ Values of mode other than 0-9 are treated as mode 0.
+
+ Sufficient space is allocated to the return value
+ to hold the suppressed trailing zeros.
+ */
+
+ int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, j, j1, k, k0,
+ k_check, leftright, m2, m5, s2, s5, spec_case, try_quick;
+ union double_union d, d2, eps;
+ __Long L;
+#ifndef Sudden_Underflow
+ int denorm;
+ __ULong x;
+#endif
+ _Bigint *b, *b1, *delta, *mlo = NULL, *mhi, *S;
+ double ds;
+ char *s, *s0;
+
+ d.d = _d;
+
+ _REENT_CHECK_MP(ptr);
+ if (_REENT_MP_RESULT(ptr))
+ {
+ _REENT_MP_RESULT(ptr)->_k = _REENT_MP_RESULT_K(ptr);
+ _REENT_MP_RESULT(ptr)->_maxwds = 1 << _REENT_MP_RESULT_K(ptr);
+ Bfree (ptr, _REENT_MP_RESULT(ptr));
+ _REENT_MP_RESULT(ptr) = 0;
+ }
+
+ if (word0 (d) & Sign_bit)
+ {
+ /* set sign for everything, including 0's and NaNs */
+ *sign = 1;
+ word0 (d) &= ~Sign_bit; /* clear sign bit */
+ }
+ else
+ *sign = 0;
+
+#if defined(IEEE_Arith) + defined(VAX)
+#ifdef IEEE_Arith
+ if ((word0 (d) & Exp_mask) == Exp_mask)
+#else
+ if (word0 (d) == 0x8000)
+#endif
+ {
+ /* Infinity or NaN */
+ *decpt = 9999;
+ s =
+#ifdef IEEE_Arith
+ !word1 (d) && !(word0 (d) & 0xfffff) ? "Infinity" :
+#endif
+ "NaN";
+ if (rve)
+ *rve =
+#ifdef IEEE_Arith
+ s[3] ? s + 8 :
+#endif
+ s + 3;
+ return s;
+ }
+#endif
+#ifdef IBM
+ d.d += 0; /* normalize */
+#endif
+ if (!d.d)
+ {
+ *decpt = 1;
+ s = "0";
+ if (rve)
+ *rve = s + 1;
+ return s;
+ }
+
+ b = d2b (ptr, d.d, &be, &bbits);
+#ifdef Sudden_Underflow
+ i = (int) (word0 (d) >> Exp_shift1 & (Exp_mask >> Exp_shift1));
+#else
+ if ((i = (int) (word0 (d) >> Exp_shift1 & (Exp_mask >> Exp_shift1))) != 0)
+ {
+#endif
+ d2.d = d.d;
+ word0 (d2) &= Frac_mask1;
+ word0 (d2) |= Exp_11;
+#ifdef IBM
+ if (j = 11 - hi0bits (word0 (d2) & Frac_mask))
+ d2.d /= 1 << j;
+#endif
+
+ /* log(x) ~=~ log(1.5) + (x-1.5)/1.5
+ * log10(x) = log(x) / log(10)
+ * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10))
+ * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2)
+ *
+ * This suggests computing an approximation k to log10(d) by
+ *
+ * k = (i - Bias)*0.301029995663981
+ * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 );
+ *
+ * We want k to be too large rather than too small.
+ * The error in the first-order Taylor series approximation
+ * is in our favor, so we just round up the constant enough
+ * to compensate for any error in the multiplication of
+ * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077,
+ * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14,
+ * adding 1e-13 to the constant term more than suffices.
+ * Hence we adjust the constant term to 0.1760912590558.
+ * (We could get a more accurate k by invoking log10,
+ * but this is probably not worthwhile.)
+ */
+
+ i -= Bias;
+#ifdef IBM
+ i <<= 2;
+ i += j;
+#endif
+#ifndef Sudden_Underflow
+ denorm = 0;
+ }
+ else
+ {
+ /* d is denormalized */
+
+ i = bbits + be + (Bias + (P - 1) - 1);
+#if defined (_DOUBLE_IS_32BITS)
+ x = word0 (d) << (32 - i);
+#else
+ x = (i > 32) ? (word0 (d) << (64 - i)) | (word1 (d) >> (i - 32))
+ : (word1 (d) << (32 - i));
+#endif
+ d2.d = x;
+ word0 (d2) -= 31 * Exp_msk1; /* adjust exponent */
+ i -= (Bias + (P - 1) - 1) + 1;
+ denorm = 1;
+ }
+#endif
+#if defined (_DOUBLE_IS_32BITS)
+ ds = (d2.d - 1.5) * 0.289529651 + 0.176091269 + i * 0.30103001;
+#else
+ ds = (d2.d - 1.5) * 0.289529654602168 + 0.1760912590558 + i * 0.301029995663981;
+#endif
+ k = (int) ds;
+ if (ds < 0. && ds != k)
+ k--; /* want k = floor(ds) */
+ k_check = 1;
+ if (k >= 0 && k <= Ten_pmax)
+ {
+ if (d.d < tens[k])
+ k--;
+ k_check = 0;
+ }
+ j = bbits - i - 1;
+ if (j >= 0)
+ {
+ b2 = 0;
+ s2 = j;
+ }
+ else
+ {
+ b2 = -j;
+ s2 = 0;
+ }
+ if (k >= 0)
+ {
+ b5 = 0;
+ s5 = k;
+ s2 += k;
+ }
+ else
+ {
+ b2 -= k;
+ b5 = -k;
+ s5 = 0;
+ }
+ if (mode < 0 || mode > 9)
+ mode = 0;
+ try_quick = 1;
+ if (mode > 5)
+ {
+ mode -= 4;
+ try_quick = 0;
+ }
+ leftright = 1;
+ ilim = ilim1 = -1;
+ switch (mode)
+ {
+ case 0:
+ case 1:
+ i = 18;
+ ndigits = 0;
+ break;
+ case 2:
+ leftright = 0;
+ /* no break */
+ case 4:
+ if (ndigits <= 0)
+ ndigits = 1;
+ ilim = ilim1 = i = ndigits;
+ break;
+ case 3:
+ leftright = 0;
+ /* no break */
+ case 5:
+ i = ndigits + k + 1;
+ ilim = i;
+ ilim1 = i - 1;
+ if (i <= 0)
+ i = 1;
+ }
+ j = sizeof (__ULong);
+ for (_REENT_MP_RESULT_K(ptr) = 0; sizeof (_Bigint) - sizeof (__ULong) + j <= i;
+ j <<= 1)
+ _REENT_MP_RESULT_K(ptr)++;
+ _REENT_MP_RESULT(ptr) = Balloc (ptr, _REENT_MP_RESULT_K(ptr));
+ s = s0 = (char *) _REENT_MP_RESULT(ptr);
+
+ if (ilim >= 0 && ilim <= Quick_max && try_quick)
+ {
+ /* Try to get by with floating-point arithmetic. */
+
+ i = 0;
+ d2.d = d.d;
+ k0 = k;
+ ilim0 = ilim;
+ ieps = 2; /* conservative */
+ if (k > 0)
+ {
+ ds = tens[k & 0xf];
+ j = k >> 4;
+ if (j & Bletch)
+ {
+ /* prevent overflows */
+ j &= Bletch - 1;
+ d.d /= bigtens[n_bigtens - 1];
+ ieps++;
+ }
+ for (; j; j >>= 1, i++)
+ if (j & 1)
+ {
+ ieps++;
+ ds *= bigtens[i];
+ }
+ d.d /= ds;
+ }
+ else if ((j1 = -k) != 0)
+ {
+ d.d *= tens[j1 & 0xf];
+ for (j = j1 >> 4; j; j >>= 1, i++)
+ if (j & 1)
+ {
+ ieps++;
+ d.d *= bigtens[i];
+ }
+ }
+ if (k_check && d.d < 1. && ilim > 0)
+ {
+ if (ilim1 <= 0)
+ goto fast_failed;
+ ilim = ilim1;
+ k--;
+ d.d *= 10.;
+ ieps++;
+ }
+ eps.d = ieps * d.d + 7.;
+ word0 (eps) -= (P - 1) * Exp_msk1;
+ if (ilim == 0)
+ {
+ S = mhi = 0;
+ d.d -= 5.;
+ if (d.d > eps.d)
+ goto one_digit;
+ if (d.d < -eps.d)
+ goto no_digits;
+ goto fast_failed;
+ }
+#ifndef No_leftright
+ if (leftright)
+ {
+ /* Use Steele & White method of only
+ * generating digits needed.
+ */
+ eps.d = 0.5 / tens[ilim - 1] - eps.d;
+ for (i = 0;;)
+ {
+ L = d.d;
+ d.d -= L;
+ *s++ = '0' + (int) L;
+ if (d.d < eps.d)
+ goto ret1;
+ if (1. - d.d < eps.d)
+ goto bump_up;
+ if (++i >= ilim)
+ break;
+ eps.d *= 10.;
+ d.d *= 10.;
+ }
+ }
+ else
+ {
+#endif
+ /* Generate ilim digits, then fix them up. */
+ eps.d *= tens[ilim - 1];
+ for (i = 1;; i++, d.d *= 10.)
+ {
+ L = d.d;
+ d.d -= L;
+ *s++ = '0' + (int) L;
+ if (i == ilim)
+ {
+ if (d.d > 0.5 + eps.d)
+ goto bump_up;
+ else if (d.d < 0.5 - eps.d)
+ {
+ while (*--s == '0');
+ s++;
+ goto ret1;
+ }
+ break;
+ }
+ }
+#ifndef No_leftright
+ }
+#endif
+ fast_failed:
+ s = s0;
+ d.d = d2.d;
+ k = k0;
+ ilim = ilim0;
+ }
+
+ /* Do we have a "small" integer? */
+
+ if (be >= 0 && k <= Int_max)
+ {
+ /* Yes. */
+ ds = tens[k];
+ if (ndigits < 0 && ilim <= 0)
+ {
+ S = mhi = 0;
+ if (ilim < 0 || d.d <= 5 * ds)
+ goto no_digits;
+ goto one_digit;
+ }
+ for (i = 1;; i++)
+ {
+ L = d.d / ds;
+ d.d -= L * ds;
+#ifdef Check_FLT_ROUNDS
+ /* If FLT_ROUNDS == 2, L will usually be high by 1 */
+ if (d.d < 0)
+ {
+ L--;
+ d.d += ds;
+ }
+#endif
+ *s++ = '0' + (int) L;
+ if (i == ilim)
+ {
+ d.d += d.d;
+ if ((d.d > ds) || ((d.d == ds) && (L & 1)))
+ {
+ bump_up:
+ while (*--s == '9')
+ if (s == s0)
+ {
+ k++;
+ *s = '0';
+ break;
+ }
+ ++*s++;
+ }
+ break;
+ }
+ if (!(d.d *= 10.))
+ break;
+ }
+ goto ret1;
+ }
+
+ m2 = b2;
+ m5 = b5;
+ mhi = mlo = 0;
+ if (leftright)
+ {
+ if (mode < 2)
+ {
+ i =
+#ifndef Sudden_Underflow
+ denorm ? be + (Bias + (P - 1) - 1 + 1) :
+#endif
+#ifdef IBM
+ 1 + 4 * P - 3 - bbits + ((bbits + be - 1) & 3);
+#else
+ 1 + P - bbits;
+#endif
+ }
+ else
+ {
+ j = ilim - 1;
+ if (m5 >= j)
+ m5 -= j;
+ else
+ {
+ s5 += j -= m5;
+ b5 += j;
+ m5 = 0;
+ }
+ if ((i = ilim) < 0)
+ {
+ m2 -= i;
+ i = 0;
+ }
+ }
+ b2 += i;
+ s2 += i;
+ mhi = i2b (ptr, 1);
+ }
+ if (m2 > 0 && s2 > 0)
+ {
+ i = m2 < s2 ? m2 : s2;
+ b2 -= i;
+ m2 -= i;
+ s2 -= i;
+ }
+ if (b5 > 0)
+ {
+ if (leftright)
+ {
+ if (m5 > 0)
+ {
+ mhi = pow5mult (ptr, mhi, m5);
+ b1 = mult (ptr, mhi, b);
+ Bfree (ptr, b);
+ b = b1;
+ }
+ if ((j = b5 - m5) != 0)
+ b = pow5mult (ptr, b, j);
+ }
+ else
+ b = pow5mult (ptr, b, b5);
+ }
+ S = i2b (ptr, 1);
+ if (s5 > 0)
+ S = pow5mult (ptr, S, s5);
+
+ /* Check for special case that d is a normalized power of 2. */
+
+ spec_case = 0;
+ if (mode < 2)
+ {
+ if (!word1 (d) && !(word0 (d) & Bndry_mask)
+#ifndef Sudden_Underflow
+ && word0 (d) & Exp_mask
+#endif
+ )
+ {
+ /* The special case */
+ b2 += Log2P;
+ s2 += Log2P;
+ spec_case = 1;
+ }
+ }
+
+ /* Arrange for convenient computation of quotients:
+ * shift left if necessary so divisor has 4 leading 0 bits.
+ *
+ * Perhaps we should just compute leading 28 bits of S once
+ * and for all and pass them and a shift to quorem, so it
+ * can do shifts and ors to compute the numerator for q.
+ */
+
+#ifdef Pack_32
+ if ((i = ((s5 ? 32 - hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0x1f) != 0)
+ i = 32 - i;
+#else
+ if ((i = ((s5 ? 32 - hi0bits (S->_x[S->_wds - 1]) : 1) + s2) & 0xf) != 0)
+ i = 16 - i;
+#endif
+ if (i > 4)
+ {
+ i -= 4;
+ b2 += i;
+ m2 += i;
+ s2 += i;
+ }
+ else if (i < 4)
+ {
+ i += 28;
+ b2 += i;
+ m2 += i;
+ s2 += i;
+ }
+ if (b2 > 0)
+ b = lshift (ptr, b, b2);
+ if (s2 > 0)
+ S = lshift (ptr, S, s2);
+ if (k_check)
+ {
+ if (cmp (b, S) < 0)
+ {
+ k--;
+ b = multadd (ptr, b, 10, 0); /* we botched the k estimate */
+ if (leftright)
+ mhi = multadd (ptr, mhi, 10, 0);
+ ilim = ilim1;
+ }
+ }
+ if (ilim <= 0 && mode > 2)
+ {
+ if (ilim < 0 || cmp (b, S = multadd (ptr, S, 5, 0)) <= 0)
+ {
+ /* no digits, fcvt style */
+ no_digits:
+ k = -1 - ndigits;
+ goto ret;
+ }
+ one_digit:
+ *s++ = '1';
+ k++;
+ goto ret;
+ }
+ if (leftright)
+ {
+ if (m2 > 0)
+ mhi = lshift (ptr, mhi, m2);
+
+ /* Compute mlo -- check for special case
+ * that d is a normalized power of 2.
+ */
+
+ mlo = mhi;
+ if (spec_case)
+ {
+ mhi = Balloc (ptr, mhi->_k);
+ Bcopy (mhi, mlo);
+ mhi = lshift (ptr, mhi, Log2P);
+ }
+
+ for (i = 1;; i++)
+ {
+ dig = quorem (b, S) + '0';
+ /* Do we yet have the shortest decimal string
+ * that will round to d?
+ */
+ j = cmp (b, mlo);
+ delta = diff (ptr, S, mhi);
+ j1 = delta->_sign ? 1 : cmp (b, delta);
+ Bfree (ptr, delta);
+#ifndef ROUND_BIASED
+ if (j1 == 0 && !mode && !(word1 (d) & 1))
+ {
+ if (dig == '9')
+ goto round_9_up;
+ if (j > 0)
+ dig++;
+ *s++ = dig;
+ goto ret;
+ }
+#endif
+ if ((j < 0) || ((j == 0) && !mode
+#ifndef ROUND_BIASED
+ && !(word1 (d) & 1)
+#endif
+ ))
+ {
+ if (j1 > 0)
+ {
+ b = lshift (ptr, b, 1);
+ j1 = cmp (b, S);
+ if (((j1 > 0) || ((j1 == 0) && (dig & 1)))
+ && dig++ == '9')
+ goto round_9_up;
+ }
+ *s++ = dig;
+ goto ret;
+ }
+ if (j1 > 0)
+ {
+ if (dig == '9')
+ { /* possible if i == 1 */
+ round_9_up:
+ *s++ = '9';
+ goto roundoff;
+ }
+ *s++ = dig + 1;
+ goto ret;
+ }
+ *s++ = dig;
+ if (i == ilim)
+ break;
+ b = multadd (ptr, b, 10, 0);
+ if (mlo == mhi)
+ mlo = mhi = multadd (ptr, mhi, 10, 0);
+ else
+ {
+ mlo = multadd (ptr, mlo, 10, 0);
+ mhi = multadd (ptr, mhi, 10, 0);
+ }
+ }
+ }
+ else
+ for (i = 1;; i++)
+ {
+ *s++ = dig = quorem (b, S) + '0';
+ if (i >= ilim)
+ break;
+ b = multadd (ptr, b, 10, 0);
+ }
+
+ /* Round off last digit */
+
+ b = lshift (ptr, b, 1);
+ j = cmp (b, S);
+ if ((j > 0) || ((j == 0) && (dig & 1)))
+ {
+ roundoff:
+ while (*--s == '9')
+ if (s == s0)
+ {
+ k++;
+ *s++ = '1';
+ goto ret;
+ }
+ ++*s++;
+ }
+ else
+ {
+ while (*--s == '0');
+ s++;
+ }
+ret:
+ Bfree (ptr, S);
+ if (mhi)
+ {
+ if (mlo && mlo != mhi)
+ Bfree (ptr, mlo);
+ Bfree (ptr, mhi);
+ }
+ret1:
+ Bfree (ptr, b);
+ *s = 0;
+ *decpt = k + 1;
+ if (rve)
+ *rve = s;
+ return s0;
+}
dtoa.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: reallocf.c
===================================================================
--- reallocf.c (nonexistent)
+++ reallocf.c (revision 345)
@@ -0,0 +1,55 @@
+/*-
+ * Copyright (c) 1998, M. Warner Losh
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+/* Documented in malloc.c. */
+
+#include
+
+#include
+
+_PTR
+_DEFUN (_reallocf_r, (reentptr, ptr, size),
+ struct _reent *reentptr _AND
+ _PTR ptr _AND
+ size_t size)
+{
+ void *nptr;
+
+ nptr = _realloc_r(reentptr, ptr, size);
+ if (!nptr && ptr)
+ _free_r(reentptr, ptr);
+ return (nptr);
+}
+
+#ifndef _REENT_ONLY
+_PTR
+_DEFUN (reallocf, (ptr, size),
+ _PTR ptr _AND
+ size_t size)
+{
+ return _reallocf_r(_REENT, ptr, size);
+}
+#endif
reallocf.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mtrim.c
===================================================================
--- mtrim.c (nonexistent)
+++ mtrim.c (revision 345)
@@ -0,0 +1,19 @@
+#ifndef MALLOC_PROVIDED
+/* mtrim.c -- a wrapper for malloc_trim. */
+
+#include <_ansi.h>
+#include
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+int
+_DEFUN (malloc_trim, (pad),
+ size_t pad)
+{
+ return _malloc_trim_r (_REENT, pad);
+}
+
+#endif
+#endif
mtrim.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: strtoull.c
===================================================================
--- strtoull.c (nonexistent)
+++ strtoull.c (revision 345)
@@ -0,0 +1,139 @@
+/*
+FUNCTION
+ <>---string to unsigned long long
+
+INDEX
+ strtoull
+INDEX
+ _strtoull_r
+
+ANSI_SYNOPSIS
+ #include
+ unsigned long long strtoull(const char *<[s]>, char **<[ptr]>,
+ int <[base]>);
+
+ unsigned long long _strtoull_r(void *<[reent]>, const char *<[s]>,
+ char **<[ptr]>, int <[base]>);
+
+TRAD_SYNOPSIS
+ #include
+ unsigned long long strtoull(<[s]>, <[ptr]>, <[base]>)
+ char *<[s]>;
+ char **<[ptr]>;
+ int <[base]>;
+
+ unsigned long long _strtoull_r(<[reent]>, <[s]>, <[ptr]>, <[base]>)
+ char *<[reent]>;
+ char *<[s]>;
+ char **<[ptr]>;
+ int <[base]>;
+
+DESCRIPTION
+The function <> converts the string <<*<[s]>>> to
+an <>. First, it breaks down the string into three parts:
+leading whitespace, which is ignored; a subject string consisting
+of the digits meaningful in the radix specified by <[base]>
+(for example, <<0>> through <<7>> if the value of <[base]> is 8);
+and a trailing portion consisting of one or more unparseable characters,
+which always includes the terminating null character. Then, it attempts
+to convert the subject string into an unsigned long long integer, and returns the
+result.
+
+If the value of <[base]> is zero, the subject string is expected to look
+like a normal C integer constant (save that no optional sign is permitted):
+a possible <<0x>> indicating hexadecimal radix, and a number.
+If <[base]> is between 2 and 36, the expected form of the subject is a
+sequence of digits (which may include letters, depending on the
+base) representing an integer in the radix specified by <[base]>.
+The letters <>--<> (or <>--<>) are used as digits valued from
+10 to 35. If <[base]> is 16, a leading <<0x>> is permitted.
+
+The subject sequence is the longest initial sequence of the input
+string that has the expected form, starting with the first
+non-whitespace character. If the string is empty or consists entirely
+of whitespace, or if the first non-whitespace character is not a
+permissible digit, the subject string is empty.
+
+If the subject string is acceptable, and the value of <[base]> is zero,
+<> attempts to determine the radix from the input string. A
+string with a leading <<0x>> is treated as a hexadecimal value; a string with
+a leading <<0>> and no <> is treated as octal; all other strings are
+treated as decimal. If <[base]> is between 2 and 36, it is used as the
+conversion radix, as described above. Finally, a pointer to the first
+character past the converted subject string is stored in <[ptr]>, if
+<[ptr]> is not <>.
+
+If the subject string is empty (that is, if <<*>><[s]> does not start
+with a substring in acceptable form), no conversion
+is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is
+not <>).
+
+The alternate function <<_strtoull_r>> is a reentrant version. The
+extra argument <[reent]> is a pointer to a reentrancy structure.
+
+
+RETURNS
+<> returns the converted value, if any. If no conversion was
+made, <<0>> is returned.
+
+<> returns <> if the magnitude of the converted
+value is too large, and sets <> to <>.
+
+PORTABILITY
+<> is ANSI.
+
+<> requires no supporting OS subroutines.
+*/
+
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+unsigned long long
+_DEFUN (strtoull, (s, ptr, base),
+ _CONST char *s _AND
+ char **ptr _AND
+ int base)
+{
+ return _strtoull_r (_REENT, s, ptr, base);
+}
+
+#endif
strtoull.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: strtold.c
===================================================================
--- strtold.c (nonexistent)
+++ strtold.c (revision 345)
@@ -0,0 +1,42 @@
+/*
+(C) Copyright IBM Corp. 2009
+
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice,
+this list of conditions and the following disclaimer.
+* Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+* Neither the name of IBM nor the names of its contributors may be
+used to endorse or promote products derived from this software without
+specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
+*/
+
+#include
+#include "local.h"
+
+/* On platforms where long double is as wide as double. */
+#ifdef _LDBL_EQ_DBL
+long double
+strtold (const char *s00, char **se)
+{
+ return strtod(s00, se);
+}
+#endif /* _LDBL_EQ_DBL */
+
strtold.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: __atexit.c
===================================================================
--- __atexit.c (nonexistent)
+++ __atexit.c (revision 345)
@@ -0,0 +1,100 @@
+/*
+ * Common routine to implement atexit-like functionality.
+ */
+
+#include
+#include
+#include
+#include
+#include "atexit.h"
+
+/* Make this a weak reference to avoid pulling in malloc. */
+void * malloc(size_t) _ATTRIBUTE((__weak__));
+
+/*
+ * Register a function to be performed at exit or on shared library unload.
+ */
+
+int
+_DEFUN (__register_exitproc,
+ (type, fn, arg, d),
+ int type _AND
+ void (*fn) (void) _AND
+ void *arg _AND
+ void *d)
+{
+ struct _on_exit_args * args;
+ register struct _atexit *p;
+
+#ifndef __SINGLE_THREAD__
+ __LOCK_INIT(static, lock);
+
+ __lock_acquire(lock);
+#endif
+
+ p = _GLOBAL_REENT->_atexit;
+ if (p == NULL)
+ _GLOBAL_REENT->_atexit = p = &_GLOBAL_REENT->_atexit0;
+ if (p->_ind >= _ATEXIT_SIZE)
+ {
+#ifndef _ATEXIT_DYNAMIC_ALLOC
+ return -1;
+#else
+ /* Don't dynamically allocate the atexit array if malloc is not
+ available. */
+ if (!malloc)
+ return -1;
+
+ p = (struct _atexit *) malloc (sizeof *p);
+ if (p == NULL)
+ {
+#ifndef __SINGLE_THREAD__
+ __lock_release(lock);
+#endif
+ return -1;
+ }
+ p->_ind = 0;
+ p->_next = _GLOBAL_REENT->_atexit;
+ _GLOBAL_REENT->_atexit = p;
+#ifndef _REENT_SMALL
+ p->_on_exit_args._fntypes = 0;
+ p->_on_exit_args._is_cxa = 0;
+#endif
+#endif
+ }
+
+ if (type != __et_atexit)
+ {
+#ifdef _REENT_SMALL
+ args = p->_on_exit_args_ptr;
+ if (args == NULL)
+ {
+ if (malloc)
+ args = malloc (sizeof * p->_on_exit_args_ptr);
+
+ if (args == NULL)
+ {
+#ifndef __SINGLE_THREAD__
+ __lock_release(lock);
+#endif
+ return -1;
+ }
+ args->_fntypes = 0;
+ args->_is_cxa = 0;
+ p->_on_exit_args_ptr = args;
+ }
+#else
+ args = &p->_on_exit_args;
+#endif
+ args->_fnargs[p->_ind] = arg;
+ args->_fntypes |= (1 << p->_ind);
+ args->_dso_handle[p->_ind] = d;
+ if (type == __et_cxa)
+ args->_is_cxa |= (1 << p->_ind);
+ }
+ p->_fns[p->_ind++] = fn;
+#ifndef __SINGLE_THREAD__
+ __lock_release(lock);
+#endif
+ return 0;
+}
__atexit.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: seed48.c
===================================================================
--- seed48.c (nonexistent)
+++ seed48.c (revision 345)
@@ -0,0 +1,44 @@
+/*
+ * 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"
+
+unsigned short *
+_DEFUN (_seed48_r, (r, xseed),
+ struct _reent *r _AND
+ unsigned short xseed[3])
+{
+ static unsigned short sseed[3];
+
+ _REENT_CHECK_RAND48(r);
+ sseed[0] = __rand48_seed[0];
+ sseed[1] = __rand48_seed[1];
+ sseed[2] = __rand48_seed[2];
+ __rand48_seed[0] = xseed[0];
+ __rand48_seed[1] = xseed[1];
+ __rand48_seed[2] = xseed[2];
+ __rand48_mult[0] = _RAND48_MULT_0;
+ __rand48_mult[1] = _RAND48_MULT_1;
+ __rand48_mult[2] = _RAND48_MULT_2;
+ __rand48_add = _RAND48_ADD;
+ return sseed;
+}
+
+#ifndef _REENT_ONLY
+unsigned short *
+_DEFUN (seed48, (xseed),
+ unsigned short xseed[3])
+{
+ return _seed48_r (_REENT, xseed);
+}
+#endif /* !_REENT_ONLY */
seed48.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: llabs.c
===================================================================
--- llabs.c (nonexistent)
+++ llabs.c (revision 345)
@@ -0,0 +1,66 @@
+/*
+FUNCTION
+<>---compute the absolute value of an long long integer.
+
+INDEX
+ llabs
+
+ANSI_SYNOPSIS
+ #include
+ long long llabs(long long j);
+
+TRAD_SYNOPSIS
+ #include
+ long long llabs(<[j]>)
+ long long <[j]>;
+
+DESCRIPTION
+The <> function computes the absolute value of the long long integer
+argument <[j]> (also called the magnitude of <[j]>).
+
+The similar function <> uses and returns <> rather than
+<> values.
+
+RETURNS
+A nonnegative long long integer.
+
+PORTABILITY
+<> is ISO 9899 (C99) compatable.
+
+No supporting OS subroutines are required.
+*/
+
+/*-
+ * Copyright (c) 2001 Mike Barcroft
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include
+
+long long
+_DEFUN(llabs, (j),
+ long long j)
+{
+ return (j < 0 ? -j : j);
+}
llabs.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcstoull_r.c
===================================================================
--- wcstoull_r.c (nonexistent)
+++ wcstoull_r.c (revision 345)
@@ -0,0 +1,130 @@
+/*
+ This code is based on wcstoul.c which has the following copyright.
+ It is used to convert a wide string into an unsigned long long.
+
+ unsigned long long _wcstoull_r (struct _reent *rptr, const wchar_t *s,
+ wchar_t **ptr, int base);
+
+*/
+
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef __GNUC__
+
+#define _GNU_SOURCE
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+
+/* Make up for older non-compliant limits.h. (This is a C99/POSIX function,
+ * and both require ULLONG_MAX in limits.h.) */
+#if !defined(ULLONG_MAX)
+# define ULLONG_MAX ULONG_LONG_MAX
+#endif
+
+/*
+ * Convert a wide string to an unsigned long long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+unsigned long long
+_DEFUN (_wcstoull_r, (rptr, nptr, endptr, base),
+ struct _reent *rptr _AND
+ _CONST wchar_t *nptr _AND
+ wchar_t **endptr _AND
+ int base)
+{
+ register const wchar_t *s = nptr;
+ register unsigned long long acc;
+ register int c;
+ register unsigned long long cutoff;
+ register int neg = 0, any, cutlim;
+
+ if(base < 0 || base == 1 || base > 36) {
+ rptr->_errno = EINVAL;
+ return(0ULL);
+ }
+ /*
+ * See strtol for comments as to the logic used.
+ */
+ do {
+ c = *s++;
+ } while (iswspace(c));
+ if (c == L'-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == L'+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == L'0' && (*s == L'x' || *s == L'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == L'0' ? 8 : 10;
+ cutoff = (unsigned long long)ULLONG_MAX / (unsigned long long)base;
+ cutlim = (unsigned long long)ULLONG_MAX % (unsigned long long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (iswdigit(c))
+ c -= L'0';
+ else if (iswalpha(c))
+ c -= iswupper(c) ? L'A' - 10 : L'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = ULLONG_MAX;
+ rptr->_errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (wchar_t *) (any ? s - 1 : nptr);
+ return (acc);
+}
+
+#endif /* __GNUC__ */
wcstoull_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: ldiv.c
===================================================================
--- ldiv.c (nonexistent)
+++ ldiv.c (revision 345)
@@ -0,0 +1,109 @@
+/*
+FUNCTION
+<>---divide two long integers
+
+INDEX
+ ldiv
+
+ANSI_SYNOPSIS
+ #include
+ ldiv_t ldiv(long <[n]>, long <[d]>);
+
+TRAD_SYNOPSIS
+ #include
+ ldiv_t ldiv(<[n]>, <[d]>)
+ long <[n]>, <[d]>;
+
+DESCRIPTION
+Divide
+@tex
+$n/d$,
+@end tex
+@ifnottex
+<[n]>/<[d]>,
+@end ifnottex
+returning quotient and remainder as two long integers in a structure <>.
+
+RETURNS
+The result is represented with the structure
+
+. typedef struct
+. {
+. long quot;
+. long rem;
+. } ldiv_t;
+
+where the <> field represents the quotient, and <> the
+remainder. For nonzero <[d]>, if `<<<[r]> = ldiv(<[n]>,<[d]>);>>' then
+<[n]> equals `<<<[r]>.rem + <[d]>*<[r]>.quot>>'.
+
+To divide <> rather than <> values, use the similar
+function <
>.
+
+PORTABILITY
+<> is ANSI.
+
+No supporting OS subroutines are required.
+*/
+
+
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <_ansi.h>
+#include /* ldiv_t */
+
+ldiv_t
+_DEFUN (ldiv, (num, denom),
+ long num _AND
+ long denom)
+{
+ ldiv_t r;
+
+ /* see div.c for comments */
+
+ r.quot = num / denom;
+ r.rem = num % denom;
+ if (num >= 0 && r.rem < 0) {
+ ++r.quot;
+ r.rem -= denom;
+ }
+ else if (num < 0 && r.rem > 0) {
+ --r.quot;
+ r.rem += denom;
+ }
+ return (r);
+}
ldiv.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: atoff.c
===================================================================
--- atoff.c (nonexistent)
+++ atoff.c (revision 345)
@@ -0,0 +1,9 @@
+#include
+#include <_ansi.h>
+
+float
+_DEFUN (atoff, (s),
+ _CONST char *s)
+{
+ return strtof (s, NULL);
+}
atoff.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: stdlib.tex
===================================================================
--- stdlib.tex (nonexistent)
+++ stdlib.tex (revision 345)
@@ -0,0 +1,186 @@
+@node Stdlib
+@chapter Standard Utility Functions (@file{stdlib.h})
+
+This chapter groups utility functions useful in a variety of programs.
+The corresponding declarations are in the header file @file{stdlib.h}.
+
+@menu
+* _Exit:: End program execution without cleaning up
+* a64l:: String to long long
+* abort:: Abnormal termination of a program
+* abs:: Integer absolute value (magnitude)
+* assert:: Macro for Debugging Diagnostics
+* atexit:: Request execution of functions at program exit
+* atof:: String to double or float
+* atoi:: String to integer
+* atoll:: String to long long
+* calloc:: Allocate space for arrays
+* div:: Divide two integers
+* ecvtbuf:: Double or float to string of digits
+* ecvt:: Double or float to string of digits (malloc result)
+* __env_lock:: Lock environment list for getenv and setenv
+* gvcvt:: Format double or float as string
+* exit:: End program execution
+* getenv:: Look up environment variable
+* labs:: Long integer absolute value (magnitude)
+* ldiv:: Divide two long integers
+* llabs:: Long long integer absolute value (magnitude)
+* lldiv:: Divide two long long integers
+* malloc:: Allocate and manage memory (malloc, realloc, free)
+* mallinfo:: Get information about allocated memory
+* __malloc_lock:: Lock memory pool for malloc and free
+* mbsrtowcs:: Convert a character string to a wide-character string
+* mbstowcs:: Minimal multibyte string to wide string converter
+* mblen:: Minimal multibyte length
+* mbtowc:: Minimal multibyte to wide character converter
+* on_exit:: Request execution of functions at program exit
+* rand:: Pseudo-random numbers
+* rand48:: Uniformly distributed pseudo-random numbers
+* strtod:: String to double or float
+* strtol:: String to long
+* strtoll:: String to long long
+* strtoul:: String to unsigned long
+* strtoull:: String to unsigned long long
+* wcsrtombs:: Convert a wide-character string to a character string
+* wcstod:: Wide string to double or float
+* wcstol:: Wide string to long
+* wcstoll:: Wide string to long long
+* wcstoul:: Wide string to unsigned long
+* wcstoull:: Wide string to unsigned long long
+* system:: Execute command string
+* wcstombs:: Minimal wide string to multibyte string converter
+* wctomb:: Minimal wide character to multibyte converter
+@end menu
+
+@page
+@include stdlib/_Exit.def
+
+@page
+@include stdlib/a64l.def
+
+@page
+@include stdlib/abort.def
+
+@page
+@include stdlib/abs.def
+
+@page
+@include stdlib/assert.def
+
+@page
+@include stdlib/atexit.def
+
+@page
+@include stdlib/atof.def
+
+@page
+@include stdlib/atoi.def
+
+@page
+@include stdlib/atoll.def
+
+@page
+@include stdlib/calloc.def
+
+@page
+@include stdlib/div.def
+
+@page
+@include stdlib/efgcvt.def
+
+@page
+@include stdlib/ecvtbuf.def
+
+@page
+@include stdlib/envlock.def
+
+@page
+@include stdlib/exit.def
+
+@page
+@include stdlib/getenv.def
+
+@page
+@include stdlib/labs.def
+
+@page
+@include stdlib/ldiv.def
+
+@page
+@include stdlib/llabs.def
+
+@page
+@include stdlib/lldiv.def
+
+@page
+@include stdlib/malloc.def
+
+@page
+@include stdlib/mstats.def
+
+@page
+@include stdlib/mlock.def
+
+@page
+@include stdlib/mblen.def
+
+@page
+@include stdlib/mbsnrtowcs.def
+
+@page
+@include stdlib/mbstowcs.def
+
+@page
+@include stdlib/mbtowc.def
+
+@page
+@include stdlib/on_exit.def
+
+@page
+@include stdlib/rand.def
+
+@page
+@include stdlib/rand48.def
+
+@page
+@include stdlib/strtod.def
+
+@page
+@include stdlib/strtol.def
+
+@page
+@include stdlib/strtoll.def
+
+@page
+@include stdlib/strtoul.def
+
+@page
+@include stdlib/strtoull.def
+
+@page
+@include stdlib/wcsnrtombs.def
+
+@page
+@include stdlib/wcstod.def
+
+@page
+@include stdlib/wcstol.def
+
+@page
+@include stdlib/wcstoll.def
+
+@page
+@include stdlib/wcstoul.def
+
+@page
+@include stdlib/wcstoull.def
+
+@page
+@include stdlib/system.def
+
+@page
+@include stdlib/wcstombs.def
+
+@page
+@include stdlib/wctomb.def
+
Index: mbsnrtowcs.c
===================================================================
--- mbsnrtowcs.c (nonexistent)
+++ mbsnrtowcs.c (revision 345)
@@ -0,0 +1,179 @@
+/*
+FUNCTION
+<>, <>---convert a character string to a wide-character string
+
+INDEX
+ mbsrtowcs
+INDEX
+ _mbsrtowcs_r
+INDEX
+ mbsnrtowcs
+INDEX
+ _mbsnrtowcs_r
+
+ANSI_SYNOPSIS
+ #include
+ size_t mbsrtowcs(wchar_t *<[dst]>, const char **<[src]>, size_t <[len]>,
+ mbstate_t *<[ps]>);
+
+ #include
+ size_t _mbsrtowcs_r(struct _reent *<[ptr]>, wchar_t *<[dst]>,
+ const char **<[src]>, size_t <[len]>,
+ mbstate_t *<[ps]>);
+
+ #include
+ size_t mbsnrtowcs(wchar_t *<[dst]>, const char **<[src]>,
+ size_t <[nms]>, size_t <[len]>, mbstate_t *<[ps]>);
+
+ #include
+ size_t _mbsnrtowcs_r(struct _reent *<[ptr]>, wchar_t *<[dst]>,
+ const char **<[src]>, size_t <[nms]>,
+ size_t <[len]>, mbstate_t *<[ps]>);
+
+TRAD_SYNOPSIS
+ #include
+ size_t mbsrtowcs(<[dst]>, <[src]>, <[len]>, <[ps]>)
+ wchar_t *<[dst]>;
+ const char **<[src]>;
+ size_t <[len]>;
+ mbstate_t *<[ps]>;
+
+ #include
+ size_t _mbsrtowcs_r(<[ptr]>, <[dst]>, <[src]>, <[len]>, <[ps]>)
+ struct _reent *<[ptr]>;
+ wchar_t *<[dst]>;
+ const char **<[src]>;
+ size_t <[len]>;
+ mbstate_t *<[ps]>;
+
+ #include
+ size_t mbsnrtowcs(<[dst]>, <[src]>, <[nms]>, <[len]>, <[ps]>)
+ wchar_t *<[dst]>;
+ const char **<[src]>;
+ size_t <[nms]>;
+ size_t <[len]>;
+ mbstate_t *<[ps]>;
+
+ #include
+ size_t _mbsnrtowcs_r(<[ptr]>, <[dst]>, <[src]>, <[nms]>, <[len]>, <[ps]>)
+ struct _reent *<[ptr]>;
+ wchar_t *<[dst]>;
+ const char **<[src]>;
+ size_t <[nms]>;
+ size_t <[len]>;
+ mbstate_t *<[ps]>;
+
+DESCRIPTION
+The <> function converts a sequence of multibyte characters
+pointed to indirectly by <[src]> into a sequence of corresponding wide
+characters and stores at most <[len]> of them in the wchar_t array pointed
+to by <[dst]>, until it encounters a terminating null character ('\0').
+
+If <[dst]> is NULL, no characters are stored.
+
+If <[dst]> is not NULL, the pointer pointed to by <[src]> is updated to point
+to the character after the one that conversion stopped at. If conversion
+stops because a null character is encountered, *<[src]> is set to NULL.
+
+The mbstate_t argument, <[ps]>, is used to keep track of the shift state. If
+it is NULL, <> uses an internal, static mbstate_t object, which
+is initialized to the initial conversion state at program startup.
+
+The <> function behaves identically to <>, except that
+conversion stops after reading at most <[nms]> bytes from the buffer pointed
+to by <[src]>.
+
+RETURNS
+The <> and <> functions return the number of wide
+characters stored in the array pointed to by <[dst]> if successful, otherwise
+it returns (size_t)-1.
+
+PORTABILITY
+<> is defined by the C99 standard.
+<> is defined by the POSIX.1-2008 standard.
+*/
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+size_t
+_DEFUN (_mbsnrtowcs_r, (r, dst, src, nms, len, ps),
+ struct _reent *r _AND
+ wchar_t *dst _AND
+ const char **src _AND
+ size_t nms _AND
+ size_t len _AND
+ mbstate_t *ps)
+{
+ wchar_t *ptr = dst;
+ const char *tmp_src;
+ size_t max;
+ size_t count = 0;
+ int bytes;
+
+#ifdef _MB_CAPABLE
+ if (ps == NULL)
+ {
+ _REENT_CHECK_MISC(r);
+ ps = &(_REENT_MBSRTOWCS_STATE(r));
+ }
+#endif
+
+ if (dst == NULL)
+ {
+ /* Ignore original len value and do not alter src pointer if the
+ dst pointer is NULL. */
+ len = (size_t)-1;
+ tmp_src = *src;
+ src = &tmp_src;
+ }
+
+ max = len;
+ while (len > 0)
+ {
+ bytes = _mbrtowc_r (r, ptr, *src, nms, ps);
+ if (bytes > 0)
+ {
+ *src += bytes;
+ nms -= bytes;
+ ++count;
+ ptr = (dst == NULL) ? NULL : ptr + 1;
+ --len;
+ }
+ else if (bytes == -2)
+ {
+ *src += nms;
+ return count;
+ }
+ else if (bytes == 0)
+ {
+ *src = NULL;
+ return count;
+ }
+ else
+ {
+ ps->__count = 0;
+ r->_errno = EILSEQ;
+ return (size_t)-1;
+ }
+ }
+
+ return (size_t)max;
+}
+
+#ifndef _REENT_ONLY
+size_t
+_DEFUN (mbsnrtowcs, (dst, src, nms, len, ps),
+ wchar_t *dst _AND
+ const char **src _AND
+ size_t nms _AND
+ size_t len _AND
+ mbstate_t *ps)
+{
+ return _mbsnrtowcs_r (_REENT, dst, src, nms, len, ps);
+}
+#endif /* !_REENT_ONLY */
mbsnrtowcs.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: envlock.c
===================================================================
--- envlock.c (nonexistent)
+++ envlock.c (revision 345)
@@ -0,0 +1,61 @@
+/*
+FUNCTION
+<<__env_lock>>, <<__env_unlock>>---lock environ variable
+
+INDEX
+ __env_lock
+INDEX
+ __env_unlock
+
+ANSI_SYNOPSIS
+ #include
+ void __env_lock (struct _reent *<[reent]>);
+ void __env_unlock (struct _reent *<[reent]>);
+
+TRAD_SYNOPSIS
+ void __env_lock(<[reent]>)
+ struct _reent *<[reent]>;
+
+ void __env_unlock(<[reent]>)
+ struct _reent *<[reent]>;
+
+DESCRIPTION
+The <> family of routines call these functions when they need to
+modify the environ variable. The version of these routines supplied in the
+library use the lock API defined in sys/lock.h. If multiple threads of
+execution can call <>, or if <> can be called reentrantly,
+then you need to define your own versions of these functions in order to
+safely lock the memory pool during a call. If you do not, the memory pool
+may become corrupted.
+
+A call to <> may call <<__env_lock>> recursively; that is,
+the sequence of calls may go <<__env_lock>>, <<__env_lock>>,
+<<__env_unlock>>, <<__env_unlock>>. Any implementation of these
+routines must be careful to avoid causing a thread to wait for a lock
+that it already holds.
+*/
+
+#include "envlock.h"
+#include
+
+#ifndef __SINGLE_THREAD__
+__LOCK_INIT_RECURSIVE(static, __env_lock_object);
+#endif
+
+void
+__env_lock (ptr)
+ struct _reent *ptr;
+{
+#ifndef __SINGLE_THREAD__
+ __lock_acquire_recursive (__env_lock_object);
+#endif
+}
+
+void
+__env_unlock (ptr)
+ struct _reent *ptr;
+{
+#ifndef __SINGLE_THREAD__
+ __lock_release_recursive (__env_lock_object);
+#endif
+}
envlock.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: putenv_r.c
===================================================================
--- putenv_r.c (nonexistent)
+++ putenv_r.c (revision 345)
@@ -0,0 +1,57 @@
+/* This file may have been modified by DJ Delorie (Jan 1991). If so,
+** these modifications are Copyright (C) 1991 DJ Delorie.
+*/
+
+/*-
+ * Copyright (c) 1988 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement: ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include
+#include
+#include
+
+#include "envlock.h"
+
+/* _putenv_r - reentrant version of putenv that either adds
+ or replaces the environment variable "name"
+ with "value" which is specified by str as "name=value". */
+int
+_DEFUN (_putenv_r, (reent_ptr, str),
+ struct _reent *reent_ptr _AND
+ char *str)
+{
+ register char *p, *equal;
+ int rval;
+
+ p = _strdup_r (reent_ptr, str);
+
+ if (!p)
+ return 1;
+
+ if (!(equal = index (p, '=')))
+ {
+ (void) _free_r (reent_ptr, p);
+ return 1;
+ }
+
+ *equal = '\0';
+ rval = _setenv_r (reent_ptr, p, equal + 1, 1);
+ (void) _free_r (reent_ptr, p);
+
+ return rval;
+}
putenv_r.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: strtoll.c
===================================================================
--- strtoll.c (nonexistent)
+++ strtoll.c (revision 345)
@@ -0,0 +1,138 @@
+/*
+FUNCTION
+ <>---string to long long
+
+INDEX
+ strtoll
+INDEX
+ _strtoll_r
+
+ANSI_SYNOPSIS
+ #include
+ long long strtoll(const char *<[s]>, char **<[ptr]>,int <[base]>);
+
+ long long _strtoll_r(void *<[reent]>,
+ const char *<[s]>, char **<[ptr]>,int <[base]>);
+
+TRAD_SYNOPSIS
+ #include
+ long long strtoll (<[s]>, <[ptr]>, <[base]>)
+ const char *<[s]>;
+ char **<[ptr]>;
+ int <[base]>;
+
+ long long _strtoll_r (<[reent]>, <[s]>, <[ptr]>, <[base]>)
+ char *<[reent]>;
+ const char *<[s]>;
+ char **<[ptr]>;
+ int <[base]>;
+
+DESCRIPTION
+The function <> converts the string <<*<[s]>>> to
+a <>. First, it breaks down the string into three parts:
+leading whitespace, which is ignored; a subject string consisting
+of characters resembling an integer in the radix specified by <[base]>;
+and a trailing portion consisting of zero or more unparseable characters,
+and always including the terminating null character. Then, it attempts
+to convert the subject string into a <> and returns the
+result.
+
+If the value of <[base]> is 0, the subject string is expected to look
+like a normal C integer constant: an optional sign, a possible `<<0x>>'
+indicating a hexadecimal base, and a number. If <[base]> is between
+2 and 36, the expected form of the subject is a sequence of letters
+and digits representing an integer in the radix specified by <[base]>,
+with an optional plus or minus sign. The letters <>--<> (or,
+equivalently, <>--<>) are used to signify values from 10 to 35;
+only letters whose ascribed values are less than <[base]> are
+permitted. If <[base]> is 16, a leading <<0x>> is permitted.
+
+The subject sequence is the longest initial sequence of the input
+string that has the expected form, starting with the first
+non-whitespace character. If the string is empty or consists entirely
+of whitespace, or if the first non-whitespace character is not a
+permissible letter or digit, the subject string is empty.
+
+If the subject string is acceptable, and the value of <[base]> is zero,
+<> attempts to determine the radix from the input string. A
+string with a leading <<0x>> is treated as a hexadecimal value; a string with
+a leading 0 and no <> is treated as octal; all other strings are
+treated as decimal. If <[base]> is between 2 and 36, it is used as the
+conversion radix, as described above. If the subject string begins with
+a minus sign, the value is negated. Finally, a pointer to the first
+character past the converted subject string is stored in <[ptr]>, if
+<[ptr]> is not <>.
+
+If the subject string is empty (or not in acceptable form), no conversion
+is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is
+not <>).
+
+The alternate function <<_strtoll_r>> is a reentrant version. The
+extra argument <[reent]> is a pointer to a reentrancy structure.
+
+RETURNS
+<> returns the converted value, if any. If no conversion was
+made, 0 is returned.
+
+<> returns <> or <> if the magnitude of
+the converted value is too large, and sets <> to <>.
+
+PORTABILITY
+<> is ANSI.
+
+No supporting OS subroutines are required.
+*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+long long
+_DEFUN (strtoll, (s, ptr, base),
+ _CONST char *s _AND
+ char **ptr _AND
+ int base)
+{
+ return _strtoll_r (_REENT, s, ptr, base);
+}
+
+#endif
strtoll.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: eprintf.c
===================================================================
--- eprintf.c (nonexistent)
+++ eprintf.c (revision 345)
@@ -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 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
+#include
+
+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*/
+}
eprintf.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: gd_qnan.h
===================================================================
--- gd_qnan.h (nonexistent)
+++ gd_qnan.h (revision 345)
@@ -0,0 +1,33 @@
+#ifdef __IEEE_BIG_ENDIAN
+
+#define f_QNAN 0x7fc00000
+#define d_QNAN0 0x7ff80000
+#define d_QNAN1 0x0
+#define ld_QNAN0 0x7ff80000
+#define ld_QNAN1 0x0
+#define ld_QNAN2 0x0
+#define ld_QNAN3 0x0
+#define ldus_QNAN0 0x7ff8
+#define ldus_QNAN1 0x0
+#define ldus_QNAN2 0x0
+#define ldus_QNAN3 0x0
+#define ldus_QNAN4 0x0
+
+#elif defined(__IEEE_LITTLE_ENDIAN)
+
+#define f_QNAN 0xffc00000
+#define d_QNAN0 0x0
+#define d_QNAN1 0xfff80000
+#define ld_QNAN0 0x0
+#define ld_QNAN1 0xc0000000
+#define ld_QNAN2 0xffff
+#define ld_QNAN3 0x0
+#define ldus_QNAN0 0x0
+#define ldus_QNAN1 0x0
+#define ldus_QNAN2 0x0
+#define ldus_QNAN3 0xc000
+#define ldus_QNAN4 0xffff
+
+#else
+#error IEEE endian not defined
+#endif
gd_qnan.h
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: mbrtowc.c
===================================================================
--- mbrtowc.c (nonexistent)
+++ mbrtowc.c (revision 345)
@@ -0,0 +1,79 @@
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "local.h"
+
+size_t
+_DEFUN (_mbrtowc_r, (ptr, pwc, s, n, ps),
+ struct _reent *ptr _AND
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n _AND
+ mbstate_t *ps)
+{
+ int retval = 0;
+
+#ifdef _MB_CAPABLE
+ if (ps == NULL)
+ {
+ _REENT_CHECK_MISC(ptr);
+ ps = &(_REENT_MBRTOWC_STATE(ptr));
+ }
+#endif
+
+ if (s == NULL)
+ retval = __mbtowc (ptr, NULL, "", 1, __locale_charset (), ps);
+ else
+ retval = __mbtowc (ptr, pwc, s, n, __locale_charset (), ps);
+
+ if (retval == -1)
+ {
+ ps->__count = 0;
+ ptr->_errno = EILSEQ;
+ return (size_t)(-1);
+ }
+ else
+ return (size_t)retval;
+}
+
+#ifndef _REENT_ONLY
+size_t
+_DEFUN (mbrtowc, (pwc, s, n, ps),
+ wchar_t *pwc _AND
+ const char *s _AND
+ size_t n _AND
+ mbstate_t *ps)
+{
+#if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__)
+ return _mbrtowc_r (_REENT, pwc, s, n, ps);
+#else
+ int retval = 0;
+
+#ifdef _MB_CAPABLE
+ if (ps == NULL)
+ {
+ _REENT_CHECK_MISC(_REENT);
+ ps = &(_REENT_MBRTOWC_STATE(_REENT));
+ }
+#endif
+
+ if (s == NULL)
+ retval = __mbtowc (_REENT, NULL, "", 1, __locale_charset (), ps);
+ else
+ retval = __mbtowc (_REENT, pwc, s, n, __locale_charset (), ps);
+
+ if (retval == -1)
+ {
+ ps->__count = 0;
+ _REENT->_errno = EILSEQ;
+ return (size_t)(-1);
+ }
+ else
+ return (size_t)retval;
+#endif /* not PREFER_SIZE_OVER_SPEED */
+}
+#endif /* !_REENT_ONLY */
mbrtowc.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: gdtoa-hexnan.c
===================================================================
--- gdtoa-hexnan.c (nonexistent)
+++ gdtoa-hexnan.c (revision 345)
@@ -0,0 +1,142 @@
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 2000 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to
+ David M. Gay
+ Bell Laboratories, Room 2C-463
+ 600 Mountain Avenue
+ Murray Hill, NJ 07974-0636
+ U.S.A.
+ dmg@bell-labs.com
+ */
+
+/* Modified 06-21-2006 by Jeff Johnston to work with newlib. */
+
+#include <_ansi.h>
+#include
+#include
+#include "mprec.h"
+#include "gdtoa.h"
+
+#ifdef INFNAN_CHECK
+static void
+_DEFUN (L_shift, (x, x1, i),
+ __ULong *x _AND
+ __ULong *x1 _AND
+ int i)
+{
+ int j;
+
+ i = 8 - i;
+ i <<= 2;
+ j = ULbits - i;
+ do {
+ *x |= x[1] << j;
+ x[1] >>= i;
+ } while(++x < x1);
+}
+
+int
+_DEFUN (hexnan, (sp, fpi, x0),
+ _CONST char **sp _AND
+ FPI *fpi _AND
+ __ULong *x0)
+{
+ __ULong c, h, *x, *x1, *xe;
+ _CONST char *s;
+ int havedig, hd0, i, nbits;
+
+ if (!hexdig['0'])
+ hexdig_init();
+ nbits = fpi->nbits;
+ x = x0 + (nbits >> kshift);
+ if (nbits & kmask)
+ x++;
+ *--x = 0;
+ x1 = xe = x;
+ havedig = hd0 = i = 0;
+ s = *sp;
+ while((c = *(_CONST unsigned char*)++s)) {
+ if (!(h = hexdig[c])) {
+ if (c <= ' ') {
+ if (hd0 < havedig) {
+ if (x < x1 && i < 8)
+ L_shift(x, x1, i);
+ if (x <= x0) {
+ i = 8;
+ continue;
+ }
+ hd0 = havedig;
+ *--x = 0;
+ x1 = x;
+ i = 0;
+ }
+ continue;
+ }
+ if (/*(*/ c == ')') {
+ *sp = s + 1;
+ break;
+ }
+ return STRTOG_NaN;
+ }
+ havedig++;
+ if (++i > 8) {
+ if (x <= x0)
+ continue;
+ i = 1;
+ *--x = 0;
+ }
+ *x = ((*x << 4) | (h & 0xf));
+ }
+ if (!havedig)
+ return STRTOG_NaN;
+ if (x < x1 && i < 8)
+ L_shift(x, x1, i);
+ if (x > x0) {
+ x1 = x0;
+ do *x1++ = *x++;
+ while(x <= xe);
+ do *x1++ = 0;
+ while(x1 <= xe);
+ }
+ else {
+ /* truncate high-order word if necessary */
+ if ( (i = nbits & (ULbits-1)) !=0)
+ *xe &= ((__ULong)0xffffffff) >> (ULbits - i);
+ }
+ for(x1 = xe;; --x1) {
+ if (*x1 != 0)
+ break;
+ if (x1 == x0) {
+ *x1 = 1;
+ break;
+ }
+ }
+ return STRTOG_NaNbits;
+}
+#endif /* INFNAN_CHECK */
gdtoa-hexnan.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: lcong48.c
===================================================================
--- lcong48.c (nonexistent)
+++ lcong48.c (revision 345)
@@ -0,0 +1,38 @@
+/*
+ * 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"
+
+_VOID
+_DEFUN (_lcong48_r, (r, p),
+ struct _reent *r _AND
+ unsigned short p[7])
+{
+ _REENT_CHECK_RAND48(r);
+ __rand48_seed[0] = p[0];
+ __rand48_seed[1] = p[1];
+ __rand48_seed[2] = p[2];
+ __rand48_mult[0] = p[3];
+ __rand48_mult[1] = p[4];
+ __rand48_mult[2] = p[5];
+ __rand48_add = p[6];
+}
+
+#ifndef _REENT_ONLY
+_VOID
+_DEFUN (lcong48, (p),
+ unsigned short p[7])
+{
+ _lcong48_r (_REENT, p);
+}
+#endif /* !_REENT_ONLY */
lcong48.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: strtod.c
===================================================================
--- strtod.c (nonexistent)
+++ strtod.c (revision 345)
@@ -0,0 +1,1187 @@
+/*
+FUNCTION
+ <>, <>---string to double or float
+
+INDEX
+ strtod
+INDEX
+ _strtod_r
+INDEX
+ strtof
+
+ANSI_SYNOPSIS
+ #include
+ double strtod(const char *<[str]>, char **<[tail]>);
+ float strtof(const char *<[str]>, char **<[tail]>);
+
+ double _strtod_r(void *<[reent]>,
+ const char *<[str]>, char **<[tail]>);
+
+TRAD_SYNOPSIS
+ #include
+ double strtod(<[str]>,<[tail]>)
+ char *<[str]>;
+ char **<[tail]>;
+
+ float strtof(<[str]>,<[tail]>)
+ char *<[str]>;
+ char **<[tail]>;
+
+ double _strtod_r(<[reent]>,<[str]>,<[tail]>)
+ char *<[reent]>;
+ char *<[str]>;
+ char **<[tail]>;
+
+DESCRIPTION
+ The function <> parses the character string <[str]>,
+ producing a substring which can be converted to a double
+ value. The substring converted is the longest initial
+ subsequence of <[str]>, beginning with the first
+ non-whitespace character, that has one of these formats:
+ .[+|-]<[digits]>[.[<[digits]>]][(e|E)[+|-]<[digits]>]
+ .[+|-].<[digits]>[(e|E)[+|-]<[digits]>]
+ .[+|-](i|I)(n|N)(f|F)[(i|I)(n|N)(i|I)(t|T)(y|Y)]
+ .[+|-](n|N)(a|A)(n|N)[<(>[<[hexdigits]>]<)>]
+ .[+|-]0(x|X)<[hexdigits]>[.[<[hexdigits]>]][(p|P)[+|-]<[digits]>]
+ .[+|-]0(x|X).<[hexdigits]>[(p|P)[+|-]<[digits]>]
+ The substring contains no characters if <[str]> is empty, consists
+ entirely of whitespace, or if the first non-whitespace
+ character is something other than <<+>>, <<->>, <<.>>, or a
+ digit, and cannot be parsed as infinity or NaN. If the platform
+ does not support NaN, then NaN is treated as an empty substring.
+ If the substring is empty, no conversion is done, and
+ the value of <[str]> is stored in <<*<[tail]>>>. Otherwise,
+ the substring is converted, and a pointer to the final string
+ (which will contain at least the terminating null character of
+ <[str]>) is stored in <<*<[tail]>>>. If you want no
+ assignment to <<*<[tail]>>>, pass a null pointer as <[tail]>.
+ <> is identical to <> except for its return type.
+
+ This implementation returns the nearest machine number to the
+ input decimal string. Ties are broken by using the IEEE
+ round-even rule. However, <> is currently subject to
+ double rounding errors.
+
+ The alternate function <<_strtod_r>> is a reentrant version.
+ The extra argument <[reent]> is a pointer to a reentrancy structure.
+
+RETURNS
+ <> returns the converted substring value, if any. If
+ no conversion could be performed, 0 is returned. If the
+ correct value is out of the range of representable values,
+ plus or minus <> is returned, and <> is
+ stored in errno. If the correct value would cause underflow, 0
+ is returned and <> is stored in errno.
+
+Supporting OS subroutines required: <>, <>, <>,
+<>, <>, <>, <>.
+*/
+
+/****************************************************************
+
+The author of this software is David M. Gay.
+
+Copyright (C) 1998-2001 by Lucent Technologies
+All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and
+its documentation for any purpose and without fee is hereby
+granted, provided that the above copyright notice appear in all
+copies and that both that the copyright notice and this
+permission notice and warranty disclaimer appear in supporting
+documentation, and that the name of Lucent or any of its entities
+not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission.
+
+LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
+IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY
+SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
+IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+THIS SOFTWARE.
+
+****************************************************************/
+
+/* Please send bug reports to David M. Gay (dmg at acm dot org,
+ * with " at " changed at "@" and " dot " changed to "."). */
+
+/* Original file gdtoa-strtod.c Modified 06-21-2006 by Jeff Johnston to work within newlib. */
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include "mprec.h"
+#include "gdtoa.h"
+#include "gd_qnan.h"
+
+/* #ifndef NO_FENV_H */
+/* #include */
+/* #endif */
+
+#include "locale.h"
+
+#ifdef IEEE_Arith
+#ifndef NO_IEEE_Scale
+#define Avoid_Underflow
+#undef tinytens
+/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */
+/* flag unnecessarily. It leads to a song and dance at the end of strtod. */
+static _CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128,
+ 9007199254740992.e-256
+ };
+#endif
+#endif
+
+#ifdef Honor_FLT_ROUNDS
+#define Rounding rounding
+#undef Check_FLT_ROUNDS
+#define Check_FLT_ROUNDS
+#else
+#define Rounding Flt_Rounds
+#endif
+
+#ifndef NO_HEX_FP
+
+static void
+_DEFUN (ULtod, (L, bits, exp, k),
+ __ULong *L _AND
+ __ULong *bits _AND
+ Long exp _AND
+ int k)
+{
+ switch(k & STRTOG_Retmask) {
+ case STRTOG_NoNumber:
+ case STRTOG_Zero:
+ L[0] = L[1] = 0;
+ break;
+
+ case STRTOG_Denormal:
+ L[_1] = bits[0];
+ L[_0] = bits[1];
+ break;
+
+ case STRTOG_Normal:
+ case STRTOG_NaNbits:
+ L[_1] = bits[0];
+ L[_0] = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20);
+ break;
+
+ case STRTOG_Infinite:
+ L[_0] = 0x7ff00000;
+ L[_1] = 0;
+ break;
+
+ case STRTOG_NaN:
+ L[_0] = 0x7fffffff;
+ L[_1] = (__ULong)-1;
+ }
+ if (k & STRTOG_Neg)
+ L[_0] |= 0x80000000L;
+}
+#endif /* !NO_HEX_FP */
+
+#ifdef INFNAN_CHECK
+static int
+_DEFUN (match, (sp, t),
+ _CONST char **sp _AND
+ char *t)
+{
+ int c, d;
+ _CONST char *s = *sp;
+
+ while( (d = *t++) !=0) {
+ if ((c = *++s) >= 'A' && c <= 'Z')
+ c += 'a' - 'A';
+ if (c != d)
+ return 0;
+ }
+ *sp = s + 1;
+ return 1;
+}
+#endif /* INFNAN_CHECK */
+
+
+double
+_DEFUN (_strtod_r, (ptr, s00, se),
+ struct _reent *ptr _AND
+ _CONST char *s00 _AND
+ char **se)
+{
+#ifdef Avoid_Underflow
+ int scale;
+#endif
+ int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, decpt, dsign,
+ e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
+ _CONST char *s, *s0, *s1;
+ double aadj, adj;
+ U aadj1, rv, rv0;
+ Long L;
+ __ULong y, z;
+ _Bigint *bb, *bb1, *bd, *bd0, *bs, *delta;
+#ifdef SET_INEXACT
+ int inexact, oldinexact;
+#endif
+#ifdef Honor_FLT_ROUNDS
+ int rounding;
+#endif
+
+ delta = bs = bd = NULL;
+ sign = nz0 = nz = decpt = 0;
+ dval(rv) = 0.;
+ for(s = s00;;s++) switch(*s) {
+ case '-':
+ sign = 1;
+ /* no break */
+ case '+':
+ if (*++s)
+ goto break2;
+ /* no break */
+ case 0:
+ goto ret0;
+ case '\t':
+ case '\n':
+ case '\v':
+ case '\f':
+ case '\r':
+ case ' ':
+ continue;
+ default:
+ goto break2;
+ }
+ break2:
+ if (*s == '0') {
+#ifndef NO_HEX_FP
+ {
+ static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI };
+ Long exp;
+ __ULong bits[2];
+ switch(s[1]) {
+ case 'x':
+ case 'X':
+ /* If the number is not hex, then the parse of
+ 0 is still valid. */
+ s00 = s + 1;
+ {
+#if defined(FE_DOWNWARD) && defined(FE_TONEAREST) && defined(FE_TOWARDZERO) && defined(FE_UPWARD)
+ FPI fpi1 = fpi;
+ switch(fegetround()) {
+ case FE_TOWARDZERO: fpi1.rounding = 0; break;
+ case FE_UPWARD: fpi1.rounding = 2; break;
+ case FE_DOWNWARD: fpi1.rounding = 3;
+ }
+#else
+#define fpi1 fpi
+#endif
+ switch((i = gethex(ptr, &s, &fpi1, &exp, &bb, sign)) & STRTOG_Retmask) {
+ case STRTOG_NoNumber:
+ s = s00;
+ case STRTOG_Zero:
+ break;
+ default:
+ if (bb) {
+ copybits(bits, fpi.nbits, bb);
+ Bfree(ptr,bb);
+ }
+ ULtod(rv.i, bits, exp, i);
+ }}
+ goto ret;
+ }
+ }
+#endif
+ nz0 = 1;
+ while(*++s == '0') ;
+ if (!*s)
+ goto ret;
+ }
+ s0 = s;
+ y = z = 0;
+ for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
+ if (nd < 9)
+ y = 10*y + c - '0';
+ else if (nd < 16)
+ z = 10*z + c - '0';
+ nd0 = nd;
+ if (strncmp (s, _localeconv_r (ptr)->decimal_point,
+ strlen (_localeconv_r (ptr)->decimal_point)) == 0)
+ {
+ decpt = 1;
+ c = *(s += strlen (_localeconv_r (ptr)->decimal_point));
+ if (!nd) {
+ for(; c == '0'; c = *++s)
+ nz++;
+ if (c > '0' && c <= '9') {
+ s0 = s;
+ nf += nz;
+ nz = 0;
+ goto have_dig;
+ }
+ goto dig_done;
+ }
+ for(; c >= '0' && c <= '9'; c = *++s) {
+ have_dig:
+ nz++;
+ if (c -= '0') {
+ nf += nz;
+ for(i = 1; i < nz; i++)
+ if (nd++ < 9)
+ y *= 10;
+ else if (nd <= DBL_DIG + 1)
+ z *= 10;
+ if (nd++ < 9)
+ y = 10*y + c;
+ else if (nd <= DBL_DIG + 1)
+ z = 10*z + c;
+ nz = 0;
+ }
+ }
+ }
+ dig_done:
+ e = 0;
+ if (c == 'e' || c == 'E') {
+ if (!nd && !nz && !nz0) {
+ goto ret0;
+ }
+ s00 = s;
+ esign = 0;
+ switch(c = *++s) {
+ case '-':
+ esign = 1;
+ case '+':
+ c = *++s;
+ }
+ if (c >= '0' && c <= '9') {
+ while(c == '0')
+ c = *++s;
+ if (c > '0' && c <= '9') {
+ L = c - '0';
+ s1 = s;
+ while((c = *++s) >= '0' && c <= '9')
+ L = 10*L + c - '0';
+ if (s - s1 > 8 || L > 19999)
+ /* Avoid confusion from exponents
+ * so large that e might overflow.
+ */
+ e = 19999; /* safe for 16 bit ints */
+ else
+ e = (int)L;
+ if (esign)
+ e = -e;
+ }
+ else
+ e = 0;
+ }
+ else
+ s = s00;
+ }
+ if (!nd) {
+ if (!nz && !nz0) {
+#ifdef INFNAN_CHECK
+ /* Check for Nan and Infinity */
+ __ULong bits[2];
+ static FPI fpinan = /* only 52 explicit bits */
+ { 52, 1-1023-53+1, 2046-1023-53+1, 1, SI };
+ if (!decpt)
+ switch(c) {
+ case 'i':
+ case 'I':
+ if (match(&s,"nf")) {
+ --s;
+ if (!match(&s,"inity"))
+ ++s;
+ dword0(rv) = 0x7ff00000;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = 0;
+#endif /*!_DOUBLE_IS_32BITS*/
+ goto ret;
+ }
+ break;
+ case 'n':
+ case 'N':
+ if (match(&s, "an")) {
+#ifndef No_Hex_NaN
+ if (*s == '(' /*)*/
+ && hexnan(&s, &fpinan, bits)
+ == STRTOG_NaNbits) {
+ dword0(rv) = 0x7ff00000 | bits[1];
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = bits[0];
+#endif /*!_DOUBLE_IS_32BITS*/
+ }
+ else {
+#endif
+ dword0(rv) = NAN_WORD0;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = NAN_WORD1;
+#endif /*!_DOUBLE_IS_32BITS*/
+#ifndef No_Hex_NaN
+ }
+#endif
+ goto ret;
+ }
+ }
+#endif /* INFNAN_CHECK */
+ ret0:
+ s = s00;
+ sign = 0;
+ }
+ goto ret;
+ }
+ e1 = e -= nf;
+
+ /* Now we have nd0 digits, starting at s0, followed by a
+ * decimal point, followed by nd-nd0 digits. The number we're
+ * after is the integer represented by those digits times
+ * 10**e */
+
+ if (!nd0)
+ nd0 = nd;
+ k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
+ dval(rv) = y;
+ if (k > 9) {
+#ifdef SET_INEXACT
+ if (k > DBL_DIG)
+ oldinexact = get_inexact();
+#endif
+ dval(rv) = tens[k - 9] * dval(rv) + z;
+ }
+ bd0 = 0;
+ if (nd <= DBL_DIG
+#ifndef RND_PRODQUOT
+#ifndef Honor_FLT_ROUNDS
+ && Flt_Rounds == 1
+#endif
+#endif
+ ) {
+ if (!e)
+ goto ret;
+ if (e > 0) {
+ if (e <= Ten_pmax) {
+#ifdef VAX
+ goto vax_ovfl_check;
+#else
+#ifdef Honor_FLT_ROUNDS
+ /* round correctly FLT_ROUNDS = 2 or 3 */
+ if (sign) {
+ dval(rv) = -dval(rv);
+ sign = 0;
+ }
+#endif
+ /* rv = */ rounded_product(dval(rv), tens[e]);
+ goto ret;
+#endif
+ }
+ i = DBL_DIG - nd;
+ if (e <= Ten_pmax + i) {
+ /* A fancier test would sometimes let us do
+ * this for larger i values.
+ */
+#ifdef Honor_FLT_ROUNDS
+ /* round correctly FLT_ROUNDS = 2 or 3 */
+ if (sign) {
+ dval(rv) = -dval(rv);
+ sign = 0;
+ }
+#endif
+ e -= i;
+ dval(rv) *= tens[i];
+#ifdef VAX
+ /* VAX exponent range is so narrow we must
+ * worry about overflow here...
+ */
+ vax_ovfl_check:
+ dword0(rv) -= P*Exp_msk1;
+ /* rv = */ rounded_product(dval(rv), tens[e]);
+ if ((dword0(rv) & Exp_mask)
+ > Exp_msk1*(DBL_MAX_EXP+Bias-1-P))
+ goto ovfl;
+ dword0(rv) += P*Exp_msk1;
+#else
+ /* rv = */ rounded_product(dval(rv), tens[e]);
+#endif
+ goto ret;
+ }
+ }
+#ifndef Inaccurate_Divide
+ else if (e >= -Ten_pmax) {
+#ifdef Honor_FLT_ROUNDS
+ /* round correctly FLT_ROUNDS = 2 or 3 */
+ if (sign) {
+ dval(rv) = -dval(rv);
+ sign = 0;
+ }
+#endif
+ /* rv = */ rounded_quotient(dval(rv), tens[-e]);
+ goto ret;
+ }
+#endif
+ }
+ e1 += nd - k;
+
+#ifdef IEEE_Arith
+#ifdef SET_INEXACT
+ inexact = 1;
+ if (k <= DBL_DIG)
+ oldinexact = get_inexact();
+#endif
+#ifdef Avoid_Underflow
+ scale = 0;
+#endif
+#ifdef Honor_FLT_ROUNDS
+ if ((rounding = Flt_Rounds) >= 2) {
+ if (sign)
+ rounding = rounding == 2 ? 0 : 2;
+ else
+ if (rounding != 2)
+ rounding = 0;
+ }
+#endif
+#endif /*IEEE_Arith*/
+
+ /* Get starting approximation = rv * 10**e1 */
+
+ if (e1 > 0) {
+ if ( (i = e1 & 15) !=0)
+ dval(rv) *= tens[i];
+ if (e1 &= ~15) {
+ if (e1 > DBL_MAX_10_EXP) {
+ ovfl:
+#ifndef NO_ERRNO
+ ptr->_errno = ERANGE;
+#endif
+ /* Can't trust HUGE_VAL */
+#ifdef IEEE_Arith
+#ifdef Honor_FLT_ROUNDS
+ switch(rounding) {
+ case 0: /* toward 0 */
+ case 3: /* toward -infinity */
+ dword0(rv) = Big0;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = Big1;
+#endif /*!_DOUBLE_IS_32BITS*/
+ break;
+ default:
+ dword0(rv) = Exp_mask;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = 0;
+#endif /*!_DOUBLE_IS_32BITS*/
+ }
+#else /*Honor_FLT_ROUNDS*/
+ dword0(rv) = Exp_mask;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = 0;
+#endif /*!_DOUBLE_IS_32BITS*/
+#endif /*Honor_FLT_ROUNDS*/
+#ifdef SET_INEXACT
+ /* set overflow bit */
+ dval(rv0) = 1e300;
+ dval(rv0) *= dval(rv0);
+#endif
+#else /*IEEE_Arith*/
+ dword0(rv) = Big0;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = Big1;
+#endif /*!_DOUBLE_IS_32BITS*/
+#endif /*IEEE_Arith*/
+ if (bd0)
+ goto retfree;
+ goto ret;
+ }
+ e1 >>= 4;
+ for(j = 0; e1 > 1; j++, e1 >>= 1)
+ if (e1 & 1)
+ dval(rv) *= bigtens[j];
+ /* The last multiplication could overflow. */
+ dword0(rv) -= P*Exp_msk1;
+ dval(rv) *= bigtens[j];
+ if ((z = dword0(rv) & Exp_mask)
+ > Exp_msk1*(DBL_MAX_EXP+Bias-P))
+ goto ovfl;
+ if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) {
+ /* set to largest number */
+ /* (Can't trust DBL_MAX) */
+ dword0(rv) = Big0;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = Big1;
+#endif /*!_DOUBLE_IS_32BITS*/
+ }
+ else
+ dword0(rv) += P*Exp_msk1;
+ }
+ }
+ else if (e1 < 0) {
+ e1 = -e1;
+ if ( (i = e1 & 15) !=0)
+ dval(rv) /= tens[i];
+ if (e1 >>= 4) {
+ if (e1 >= 1 << n_bigtens)
+ goto undfl;
+#ifdef Avoid_Underflow
+ if (e1 & Scale_Bit)
+ scale = 2*P;
+ for(j = 0; e1 > 0; j++, e1 >>= 1)
+ if (e1 & 1)
+ dval(rv) *= tinytens[j];
+ if (scale && (j = 2*P + 1 - ((dword0(rv) & Exp_mask)
+ >> Exp_shift)) > 0) {
+ /* scaled rv is denormal; zap j low bits */
+ if (j >= 32) {
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = 0;
+#endif /*!_DOUBLE_IS_32BITS*/
+ if (j >= 53)
+ dword0(rv) = (P+2)*Exp_msk1;
+ else
+ dword0(rv) &= 0xffffffff << (j-32);
+ }
+#ifndef _DOUBLE_IS_32BITS
+ else
+ dword1(rv) &= 0xffffffff << j;
+#endif /*!_DOUBLE_IS_32BITS*/
+ }
+#else
+ for(j = 0; e1 > 1; j++, e1 >>= 1)
+ if (e1 & 1)
+ dval(rv) *= tinytens[j];
+ /* The last multiplication could underflow. */
+ dval(rv0) = dval(rv);
+ dval(rv) *= tinytens[j];
+ if (!dval(rv)) {
+ dval(rv) = 2.*dval(rv0);
+ dval(rv) *= tinytens[j];
+#endif
+ if (!dval(rv)) {
+ undfl:
+ dval(rv) = 0.;
+#ifndef NO_ERRNO
+ ptr->_errno = ERANGE;
+#endif
+ if (bd0)
+ goto retfree;
+ goto ret;
+ }
+#ifndef Avoid_Underflow
+#ifndef _DOUBLE_IS_32BITS
+ dword0(rv) = Tiny0;
+ dword1(rv) = Tiny1;
+#else
+ dword0(rv) = Tiny1;
+#endif /*_DOUBLE_IS_32BITS*/
+ /* The refinement below will clean
+ * this approximation up.
+ */
+ }
+#endif
+ }
+ }
+
+ /* Now the hard part -- adjusting rv to the correct value.*/
+
+ /* Put digits into bd: true value = bd * 10^e */
+
+ bd0 = s2b(ptr, s0, nd0, nd, y);
+
+ for(;;) {
+ bd = Balloc(ptr,bd0->_k);
+ Bcopy(bd, bd0);
+ bb = d2b(ptr,dval(rv), &bbe, &bbbits); /* rv = bb * 2^bbe */
+ bs = i2b(ptr,1);
+
+ if (e >= 0) {
+ bb2 = bb5 = 0;
+ bd2 = bd5 = e;
+ }
+ else {
+ bb2 = bb5 = -e;
+ bd2 = bd5 = 0;
+ }
+ if (bbe >= 0)
+ bb2 += bbe;
+ else
+ bd2 -= bbe;
+ bs2 = bb2;
+#ifdef Honor_FLT_ROUNDS
+ if (rounding != 1)
+ bs2++;
+#endif
+#ifdef Avoid_Underflow
+ j = bbe - scale;
+ i = j + bbbits - 1; /* logb(rv) */
+ if (i < Emin) /* denormal */
+ j += P - Emin;
+ else
+ j = P + 1 - bbbits;
+#else /*Avoid_Underflow*/
+#ifdef Sudden_Underflow
+#ifdef IBM
+ j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3);
+#else
+ j = P + 1 - bbbits;
+#endif
+#else /*Sudden_Underflow*/
+ j = bbe;
+ i = j + bbbits - 1; /* logb(rv) */
+ if (i < Emin) /* denormal */
+ j += P - Emin;
+ else
+ j = P + 1 - bbbits;
+#endif /*Sudden_Underflow*/
+#endif /*Avoid_Underflow*/
+ bb2 += j;
+ bd2 += j;
+#ifdef Avoid_Underflow
+ bd2 += scale;
+#endif
+ i = bb2 < bd2 ? bb2 : bd2;
+ if (i > bs2)
+ i = bs2;
+ if (i > 0) {
+ bb2 -= i;
+ bd2 -= i;
+ bs2 -= i;
+ }
+ if (bb5 > 0) {
+ bs = pow5mult(ptr, bs, bb5);
+ bb1 = mult(ptr, bs, bb);
+ Bfree(ptr, bb);
+ bb = bb1;
+ }
+ if (bb2 > 0)
+ bb = lshift(ptr, bb, bb2);
+ if (bd5 > 0)
+ bd = pow5mult(ptr, bd, bd5);
+ if (bd2 > 0)
+ bd = lshift(ptr, bd, bd2);
+ if (bs2 > 0)
+ bs = lshift(ptr, bs, bs2);
+ delta = diff(ptr, bb, bd);
+ dsign = delta->_sign;
+ delta->_sign = 0;
+ i = cmp(delta, bs);
+#ifdef Honor_FLT_ROUNDS
+ if (rounding != 1) {
+ if (i < 0) {
+ /* Error is less than an ulp */
+ if (!delta->_x[0] && delta->_wds <= 1) {
+ /* exact */
+#ifdef SET_INEXACT
+ inexact = 0;
+#endif
+ break;
+ }
+ if (rounding) {
+ if (dsign) {
+ adj = 1.;
+ goto apply_adj;
+ }
+ }
+ else if (!dsign) {
+ adj = -1.;
+ if (!dword1(rv)
+ && !(dword0(rv) & Frac_mask)) {
+ y = dword0(rv) & Exp_mask;
+#ifdef Avoid_Underflow
+ if (!scale || y > 2*P*Exp_msk1)
+#else
+ if (y)
+#endif
+ {
+ delta = lshift(ptr, delta,Log2P);
+ if (cmp(delta, bs) <= 0)
+ adj = -0.5;
+ }
+ }
+ apply_adj:
+#ifdef Avoid_Underflow
+ if (scale && (y = dword0(rv) & Exp_mask)
+ <= 2*P*Exp_msk1)
+ dword0(adj) += (2*P+1)*Exp_msk1 - y;
+#else
+#ifdef Sudden_Underflow
+ if ((dword0(rv) & Exp_mask) <=
+ P*Exp_msk1) {
+ dword0(rv) += P*Exp_msk1;
+ dval(rv) += adj*ulp(dval(rv));
+ dword0(rv) -= P*Exp_msk1;
+ }
+ else
+#endif /*Sudden_Underflow*/
+#endif /*Avoid_Underflow*/
+ dval(rv) += adj*ulp(dval(rv));
+ }
+ break;
+ }
+ adj = ratio(delta, bs);
+ if (adj < 1.)
+ adj = 1.;
+ if (adj <= 0x7ffffffe) {
+ /* adj = rounding ? ceil(adj) : floor(adj); */
+ y = adj;
+ if (y != adj) {
+ if (!((rounding>>1) ^ dsign))
+ y++;
+ adj = y;
+ }
+ }
+#ifdef Avoid_Underflow
+ if (scale && (y = dword0(rv) & Exp_mask) <= 2*P*Exp_msk1)
+ dword0(adj) += (2*P+1)*Exp_msk1 - y;
+#else
+#ifdef Sudden_Underflow
+ if ((dword0(rv) & Exp_mask) <= P*Exp_msk1) {
+ dword0(rv) += P*Exp_msk1;
+ adj *= ulp(dval(rv));
+ if (dsign)
+ dval(rv) += adj;
+ else
+ dval(rv) -= adj;
+ dword0(rv) -= P*Exp_msk1;
+ goto cont;
+ }
+#endif /*Sudden_Underflow*/
+#endif /*Avoid_Underflow*/
+ adj *= ulp(dval(rv));
+ if (dsign)
+ dval(rv) += adj;
+ else
+ dval(rv) -= adj;
+ goto cont;
+ }
+#endif /*Honor_FLT_ROUNDS*/
+
+ if (i < 0) {
+ /* Error is less than half an ulp -- check for
+ * special case of mantissa a power of two.
+ */
+ if (dsign || dword1(rv) || dword0(rv) & Bndry_mask
+#ifdef IEEE_Arith
+#ifdef Avoid_Underflow
+ || (dword0(rv) & Exp_mask) <= (2*P+1)*Exp_msk1
+#else
+ || (dword0(rv) & Exp_mask) <= Exp_msk1
+#endif
+#endif
+ ) {
+#ifdef SET_INEXACT
+ if (!delta->x[0] && delta->wds <= 1)
+ inexact = 0;
+#endif
+ break;
+ }
+ if (!delta->_x[0] && delta->_wds <= 1) {
+ /* exact result */
+#ifdef SET_INEXACT
+ inexact = 0;
+#endif
+ break;
+ }
+ delta = lshift(ptr,delta,Log2P);
+ if (cmp(delta, bs) > 0)
+ goto drop_down;
+ break;
+ }
+ if (i == 0) {
+ /* exactly half-way between */
+ if (dsign) {
+ if ((dword0(rv) & Bndry_mask1) == Bndry_mask1
+ && dword1(rv) == (
+#ifdef Avoid_Underflow
+ (scale && (y = dword0(rv) & Exp_mask) <= 2*P*Exp_msk1)
+ ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) :
+#endif
+ 0xffffffff)) {
+ /*boundary case -- increment exponent*/
+ dword0(rv) = (dword0(rv) & Exp_mask)
+ + Exp_msk1
+#ifdef IBM
+ | Exp_msk1 >> 4
+#endif
+ ;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = 0;
+#endif /*!_DOUBLE_IS_32BITS*/
+#ifdef Avoid_Underflow
+ dsign = 0;
+#endif
+ break;
+ }
+ }
+ else if (!(dword0(rv) & Bndry_mask) && !dword1(rv)) {
+ drop_down:
+ /* boundary case -- decrement exponent */
+#ifdef Sudden_Underflow /*{{*/
+ L = dword0(rv) & Exp_mask;
+#ifdef IBM
+ if (L < Exp_msk1)
+#else
+#ifdef Avoid_Underflow
+ if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1))
+#else
+ if (L <= Exp_msk1)
+#endif /*Avoid_Underflow*/
+#endif /*IBM*/
+ goto undfl;
+ L -= Exp_msk1;
+#else /*Sudden_Underflow}{*/
+#ifdef Avoid_Underflow
+ if (scale) {
+ L = dword0(rv) & Exp_mask;
+ if (L <= (2*P+1)*Exp_msk1) {
+ if (L > (P+2)*Exp_msk1)
+ /* round even ==> */
+ /* accept rv */
+ break;
+ /* rv = smallest denormal */
+ goto undfl;
+ }
+ }
+#endif /*Avoid_Underflow*/
+ L = (dword0(rv) & Exp_mask) - Exp_msk1;
+#endif /*Sudden_Underflow}*/
+ dword0(rv) = L | Bndry_mask1;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = 0xffffffff;
+#endif /*!_DOUBLE_IS_32BITS*/
+#ifdef IBM
+ goto cont;
+#else
+ break;
+#endif
+ }
+#ifndef ROUND_BIASED
+ if (!(dword1(rv) & LSB))
+ break;
+#endif
+ if (dsign)
+ dval(rv) += ulp(dval(rv));
+#ifndef ROUND_BIASED
+ else {
+ dval(rv) -= ulp(dval(rv));
+#ifndef Sudden_Underflow
+ if (!dval(rv))
+ goto undfl;
+#endif
+ }
+#ifdef Avoid_Underflow
+ dsign = 1 - dsign;
+#endif
+#endif
+ break;
+ }
+ if ((aadj = ratio(delta, bs)) <= 2.) {
+ if (dsign)
+ aadj = dval(aadj1) = 1.;
+ else if (dword1(rv) || dword0(rv) & Bndry_mask) {
+#ifndef Sudden_Underflow
+ if (dword1(rv) == Tiny1 && !dword0(rv))
+ goto undfl;
+#endif
+ aadj = 1.;
+ dval(aadj1) = -1.;
+ }
+ else {
+ /* special case -- power of FLT_RADIX to be */
+ /* rounded down... */
+
+ if (aadj < 2./FLT_RADIX)
+ aadj = 1./FLT_RADIX;
+ else
+ aadj *= 0.5;
+ dval(aadj1) = -aadj;
+ }
+ }
+ else {
+ aadj *= 0.5;
+ dval(aadj1) = dsign ? aadj : -aadj;
+#ifdef Check_FLT_ROUNDS
+ switch(Rounding) {
+ case 2: /* towards +infinity */
+ dval(aadj1) -= 0.5;
+ break;
+ case 0: /* towards 0 */
+ case 3: /* towards -infinity */
+ dval(aadj1) += 0.5;
+ }
+#else
+ if (Flt_Rounds == 0)
+ dval(aadj1) += 0.5;
+#endif /*Check_FLT_ROUNDS*/
+ }
+ y = dword0(rv) & Exp_mask;
+
+ /* Check for overflow */
+
+ if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
+ dval(rv0) = dval(rv);
+ dword0(rv) -= P*Exp_msk1;
+ adj = dval(aadj1) * ulp(dval(rv));
+ dval(rv) += adj;
+ if ((dword0(rv) & Exp_mask) >=
+ Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
+ if (dword0(rv0) == Big0 && dword1(rv0) == Big1)
+ goto ovfl;
+ dword0(rv) = Big0;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv) = Big1;
+#endif /*!_DOUBLE_IS_32BITS*/
+ goto cont;
+ }
+ else
+ dword0(rv) += P*Exp_msk1;
+ }
+ else {
+#ifdef Avoid_Underflow
+ if (scale && y <= 2*P*Exp_msk1) {
+ if (aadj <= 0x7fffffff) {
+ if ((z = aadj) <= 0)
+ z = 1;
+ aadj = z;
+ dval(aadj1) = dsign ? aadj : -aadj;
+ }
+ dword0(aadj1) += (2*P+1)*Exp_msk1 - y;
+ }
+ adj = dval(aadj1) * ulp(dval(rv));
+ dval(rv) += adj;
+#else
+#ifdef Sudden_Underflow
+ if ((dword0(rv) & Exp_mask) <= P*Exp_msk1) {
+ dval(rv0) = dval(rv);
+ dword0(rv) += P*Exp_msk1;
+ adj = dval(aadj1) * ulp(dval(rv));
+ dval(rv) += adj;
+#ifdef IBM
+ if ((dword0(rv) & Exp_mask) < P*Exp_msk1)
+#else
+ if ((dword0(rv) & Exp_mask) <= P*Exp_msk1)
+#endif
+ {
+ if (dword0(rv0) == Tiny0
+ && dword1(rv0) == Tiny1)
+ goto undfl;
+#ifndef _DOUBLE_IS_32BITS
+ dword0(rv) = Tiny0;
+ dword1(rv) = Tiny1;
+#else
+ dword0(rv) = Tiny1;
+#endif /*_DOUBLE_IS_32BITS*/
+ goto cont;
+ }
+ else
+ dword0(rv) -= P*Exp_msk1;
+ }
+ else {
+ adj = dval(aadj1) * ulp(dval(rv));
+ dval(rv) += adj;
+ }
+#else /*Sudden_Underflow*/
+ /* Compute adj so that the IEEE rounding rules will
+ * correctly round rv + adj in some half-way cases.
+ * If rv * ulp(rv) is denormalized (i.e.,
+ * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid
+ * trouble from bits lost to denormalization;
+ * example: 1.2e-307 .
+ */
+ if (y <= (P-1)*Exp_msk1 && aadj > 1.) {
+ dval(aadj1) = (double)(int)(aadj + 0.5);
+ if (!dsign)
+ dval(aadj1) = -dval(aadj1);
+ }
+ adj = dval(aadj1) * ulp(dval(rv));
+ dval(rv) += adj;
+#endif /*Sudden_Underflow*/
+#endif /*Avoid_Underflow*/
+ }
+ z = dword0(rv) & Exp_mask;
+#ifndef SET_INEXACT
+#ifdef Avoid_Underflow
+ if (!scale)
+#endif
+ if (y == z) {
+ /* Can we stop now? */
+ L = (Long)aadj;
+ aadj -= L;
+ /* The tolerances below are conservative. */
+ if (dsign || dword1(rv) || dword0(rv) & Bndry_mask) {
+ if (aadj < .4999999 || aadj > .5000001)
+ break;
+ }
+ else if (aadj < .4999999/FLT_RADIX)
+ break;
+ }
+#endif
+ cont:
+ Bfree(ptr,bb);
+ Bfree(ptr,bd);
+ Bfree(ptr,bs);
+ Bfree(ptr,delta);
+ }
+#ifdef SET_INEXACT
+ if (inexact) {
+ if (!oldinexact) {
+ dword0(rv0) = Exp_1 + (70 << Exp_shift);
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv0) = 0;
+#endif /*!_DOUBLE_IS_32BITS*/
+ dval(rv0) += 1.;
+ }
+ }
+ else if (!oldinexact)
+ clear_inexact();
+#endif
+#ifdef Avoid_Underflow
+ if (scale) {
+ dword0(rv0) = Exp_1 - 2*P*Exp_msk1;
+#ifndef _DOUBLE_IS_32BITS
+ dword1(rv0) = 0;
+#endif /*!_DOUBLE_IS_32BITS*/
+ dval(rv) *= dval(rv0);
+#ifndef NO_ERRNO
+ /* try to avoid the bug of testing an 8087 register value */
+ if (dword0(rv) == 0 && dword1(rv) == 0)
+ ptr->_errno = ERANGE;
+#endif
+ }
+#endif /* Avoid_Underflow */
+#ifdef SET_INEXACT
+ if (inexact && !(dword0(rv) & Exp_mask)) {
+ /* set underflow bit */
+ dval(rv0) = 1e-300;
+ dval(rv0) *= dval(rv0);
+ }
+#endif
+ retfree:
+ Bfree(ptr,bb);
+ Bfree(ptr,bd);
+ Bfree(ptr,bs);
+ Bfree(ptr,bd0);
+ Bfree(ptr,delta);
+ ret:
+ if (se)
+ *se = (char *)s;
+ return sign ? -dval(rv) : dval(rv);
+}
+
+#ifndef _REENT_ONLY
+
+double
+_DEFUN (strtod, (s00, se),
+ _CONST char *s00 _AND char **se)
+{
+ return _strtod_r (_REENT, s00, se);
+}
+
+float
+_DEFUN (strtof, (s00, se),
+ _CONST char *s00 _AND
+ char **se)
+{
+ double retval = _strtod_r (_REENT, s00, se);
+ if (isnan (retval))
+ return nanf (NULL);
+ return (float)retval;
+}
+
+#endif
strtod.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: labs.c
===================================================================
--- labs.c (nonexistent)
+++ labs.c (revision 345)
@@ -0,0 +1,49 @@
+/*
+FUNCTION
+<>---long integer absolute value
+
+INDEX
+ labs
+
+ANSI_SYNOPSIS
+ #include
+ long labs(long <[i]>);
+
+TRAD_SYNOPSIS
+ #include
+ long labs(<[i]>)
+ long <[i]>;
+
+DESCRIPTION
+<> 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 <> uses and returns <> rather than
+<> values.
+
+RETURNS
+The result is a nonnegative long integer.
+
+PORTABILITY
+<> is ANSI.
+
+No supporting OS subroutine calls are required.
+*/
+
+#include
+
+long
+_DEFUN (labs, (x),
+ long x)
+{
+ if (x < 0)
+ {
+ x = -x;
+ }
+ return x;
+}
labs.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: putenv.c
===================================================================
--- putenv.c (nonexistent)
+++ putenv.c (revision 345)
@@ -0,0 +1,32 @@
+/*-
+ * Copyright (c) 1988 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement: ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef _REENT_ONLY
+
+#include
+#include
+
+int
+_DEFUN (putenv, (str),
+ char *str)
+{
+ return _putenv_r (_REENT, str);
+}
+
+#endif /* !_REENT_ONLY */
putenv.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: div.c
===================================================================
--- div.c (nonexistent)
+++ div.c (revision 345)
@@ -0,0 +1,132 @@
+/*
+FUNCTION
+<
>---divide two integers
+
+INDEX
+ div
+
+ANSI_SYNOPSIS
+ #include
+ div_t div(int <[n]>, int <[d]>);
+
+TRAD_SYNOPSIS
+ #include
+ div_t div(<[n]>, <[d]>)
+ int <[n]>, <[d]>;
+
+DESCRIPTION
+Divide
+@tex
+$n/d$,
+@end tex
+@ifnottex
+<[n]>/<[d]>,
+@end ifnottex
+returning quotient and remainder as two integers in a structure <>.
+
+RETURNS
+The result is represented with the structure
+
+. typedef struct
+. {
+. int quot;
+. int rem;
+. } div_t;
+
+where the <> field represents the quotient, and <> the
+remainder. For nonzero <[d]>, if `<<<[r]> = div(<[n]>,<[d]>);>>' then
+<[n]> equals `<<<[r]>.rem + <[d]>*<[r]>.quot>>'.
+
+To divide <> rather than <> values, use the similar
+function <>.
+
+PORTABILITY
+<
> is ANSI.
+
+No supporting OS subroutines are required.
+*/
+
+/*
+ * Copyright (c) 1990 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Chris Torek.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <_ansi.h>
+#include /* div_t */
+
+div_t
+_DEFUN (div, (num, denom),
+ int num _AND
+ int denom)
+{
+ div_t r;
+
+ r.quot = num / denom;
+ r.rem = num % denom;
+ /*
+ * The ANSI standard says that |r.quot| <= |n/d|, where
+ * n/d is to be computed in infinite precision. In other
+ * words, we should always truncate the quotient towards
+ * 0, never -infinity or +infinity.
+ *
+ * Machine division and remainer may work either way when
+ * one or both of n or d is negative. If only one is
+ * negative and r.quot has been truncated towards -inf,
+ * r.rem will have the same sign as denom and the opposite
+ * sign of num; if both are negative and r.quot has been
+ * truncated towards -inf, r.rem will be positive (will
+ * have the opposite sign of num). These are considered
+ * `wrong'.
+ *
+ * If both are num and denom are positive, r will always
+ * be positive.
+ *
+ * This all boils down to:
+ * if num >= 0, but r.rem < 0, we got the wrong answer.
+ * In that case, to get the right answer, add 1 to r.quot and
+ * subtract denom from r.rem.
+ * if num < 0, but r.rem > 0, we also have the wrong answer.
+ * In this case, to get the right answer, subtract 1 from r.quot and
+ * add denom to r.rem.
+ */
+ if (num >= 0 && r.rem < 0) {
+ ++r.quot;
+ r.rem -= denom;
+ }
+ else if (num < 0 && r.rem > 0) {
+ --r.quot;
+ r.rem += denom;
+ }
+ return (r);
+}
div.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: wcsrtombs.c
===================================================================
--- wcsrtombs.c (nonexistent)
+++ wcsrtombs.c (revision 345)
@@ -0,0 +1,26 @@
+#include
+#include
+#include
+
+size_t
+_DEFUN (_wcsrtombs_r, (r, dst, src, len, ps),
+ struct _reent *r _AND
+ char *dst _AND
+ const wchar_t **src _AND
+ size_t len _AND
+ mbstate_t *ps)
+{
+ return _wcsnrtombs_r (r, dst, src, (size_t) -1, len, ps);
+}
+
+#ifndef _REENT_ONLY
+size_t
+_DEFUN (wcsrtombs, (dst, src, len, ps),
+ char *dst _AND
+ const wchar_t **src _AND
+ size_t len _AND
+ mbstate_t *ps)
+{
+ return _wcsnrtombs_r (_REENT, dst, src, (size_t) -1, len, ps);
+}
+#endif /* !_REENT_ONLY */
wcsrtombs.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: rand.c
===================================================================
--- rand.c (nonexistent)
+++ rand.c (revision 345)
@@ -0,0 +1,91 @@
+/*
+FUNCTION
+<>, <>---pseudo-random numbers
+
+INDEX
+ rand
+INDEX
+ srand
+INDEX
+ rand_r
+
+ANSI_SYNOPSIS
+ #include
+ int rand(void);
+ void srand(unsigned int <[seed]>);
+ int rand_r(unsigned int *<[seed]>);
+
+TRAD_SYNOPSIS
+ #include
+ int rand();
+
+ void srand(<[seed]>)
+ unsigned int <[seed]>;
+
+ void rand_r(<[seed]>)
+ unsigned int *<[seed]>;
+
+
+DESCRIPTION
+<> returns a different integer each time it is called; each
+integer is chosen by an algorithm designed to be unpredictable, so
+that you can use <> when you require a random number.
+The algorithm depends on a static variable called the ``random seed'';
+starting with a given value of the random seed always produces the
+same sequence of numbers in successive calls to <>.
+
+You can set the random seed using <>; it does nothing beyond
+storing its argument in the static variable used by <>. You can
+exploit this to make the pseudo-random sequence less predictable, if
+you wish, by using some other unpredictable value (often the least
+significant parts of a time-varying value) as the random seed before
+beginning a sequence of calls to <>; or, if you wish to ensure
+(for example, while debugging) that successive runs of your program
+use the same ``random'' numbers, you can use <> to set the same
+random seed at the outset.
+
+RETURNS
+<> returns the next pseudo-random integer in sequence; it is a
+number between <<0>> and <> (inclusive).
+
+<> does not return a result.
+
+NOTES
+<> and <> are unsafe for multi-threaded applications.
+<> is thread-safe and should be used instead.
+
+
+PORTABILITY
+<> is required by ANSI, but the algorithm for pseudo-random
+number generation is not specified; therefore, even if you use
+the same random seed, you cannot expect the same sequence of results
+on two different systems.
+
+<> requires no supporting OS subroutines.
+*/
+
+#ifndef _REENT_ONLY
+
+#include
+#include
+
+void
+_DEFUN (srand, (seed), unsigned int seed)
+{
+ _REENT_CHECK_RAND48(_REENT);
+ _REENT_RAND_NEXT(_REENT) = seed;
+}
+
+int
+_DEFUN_VOID (rand)
+{
+ /* This multiplier was obtained from Knuth, D.E., "The Art of
+ Computer Programming," Vol 2, Seminumerical Algorithms, Third
+ Edition, Addison-Wesley, 1998, p. 106 (line 26) & p. 108 */
+ _REENT_CHECK_RAND48(_REENT);
+ _REENT_RAND_NEXT(_REENT) =
+ _REENT_RAND_NEXT(_REENT) * __extension__ 6364136223846793005LL + 1;
+ return (int)((_REENT_RAND_NEXT(_REENT) >> 32) & RAND_MAX);
+}
+
+#endif /* _REENT_ONLY */
rand.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: __call_atexit.c
===================================================================
--- __call_atexit.c (nonexistent)
+++ __call_atexit.c (revision 345)
@@ -0,0 +1,107 @@
+/*
+ * COmmon routine to call call registered atexit-like routines.
+ */
+
+
+#include
+#include
+#include "atexit.h"
+
+/* Make this a weak reference to avoid pulling in free. */
+void free(void *) _ATTRIBUTE((__weak__));
+
+/*
+ * Call registered exit handlers. If D is null then all handlers are called,
+ * otherwise only the handlers from that DSO are called.
+ */
+
+void
+_DEFUN (__call_exitprocs, (code, d),
+ int code _AND _PTR d)
+{
+ register struct _atexit *p;
+ struct _atexit **lastp;
+ register struct _on_exit_args * args;
+ register int n;
+ int i;
+ void (*fn) (void);
+
+ restart:
+
+ p = _GLOBAL_REENT->_atexit;
+ lastp = &_GLOBAL_REENT->_atexit;
+ while (p)
+ {
+#ifdef _REENT_SMALL
+ args = p->_on_exit_args_ptr;
+#else
+ args = &p->_on_exit_args;
+#endif
+ for (n = p->_ind - 1; n >= 0; n--)
+ {
+ int ind;
+
+ i = 1 << n;
+
+ /* Skip functions not from this dso. */
+ if (d && (!args || args->_dso_handle[n] != d))
+ continue;
+
+ /* Remove the function now to protect against the
+ function calling exit recursively. */
+ fn = p->_fns[n];
+ if (n == p->_ind - 1)
+ p->_ind--;
+ else
+ p->_fns[n] = NULL;
+
+ /* Skip functions that have already been called. */
+ if (!fn)
+ continue;
+
+ ind = p->_ind;
+
+ /* Call the function. */
+ if (!args || (args->_fntypes & i) == 0)
+ fn ();
+ else if ((args->_is_cxa & i) == 0)
+ (*((void (*)(int, _PTR)) fn))(code, args->_fnargs[n]);
+ else
+ (*((void (*)(_PTR)) fn))(args->_fnargs[n]);
+
+ /* The function we called call atexit and registered another
+ function (or functions). Call these new functions before
+ continuing with the already registered functions. */
+ if (ind != p->_ind || *lastp != p)
+ goto restart;
+ }
+
+#ifndef _ATEXIT_DYNAMIC_ALLOC
+ break;
+#else
+ /* Don't dynamically free the atexit array if free is not
+ available. */
+ if (!free)
+ break;
+
+ /* Move to the next block. Free empty blocks except the last one,
+ which is part of _GLOBAL_REENT. */
+ if (p->_ind == 0 && p->_next)
+ {
+ /* Remove empty block from the list. */
+ *lastp = p->_next;
+#ifdef _REENT_SMALL
+ if (args)
+ free (args);
+#endif
+ free (p);
+ p = *lastp;
+ }
+ else
+ {
+ lastp = &p->_next;
+ p = p->_next;
+ }
+#endif
+ }
+}
__call_atexit.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: strtol.c
===================================================================
--- strtol.c (nonexistent)
+++ strtol.c (revision 345)
@@ -0,0 +1,226 @@
+/*
+FUNCTION
+ <>---string to long
+
+INDEX
+ strtol
+INDEX
+ _strtol_r
+
+ANSI_SYNOPSIS
+ #include
+ long strtol(const char *<[s]>, char **<[ptr]>,int <[base]>);
+
+ long _strtol_r(void *<[reent]>,
+ const char *<[s]>, char **<[ptr]>,int <[base]>);
+
+TRAD_SYNOPSIS
+ #include
+ long strtol (<[s]>, <[ptr]>, <[base]>)
+ char *<[s]>;
+ char **<[ptr]>;
+ int <[base]>;
+
+ long _strtol_r (<[reent]>, <[s]>, <[ptr]>, <[base]>)
+ char *<[reent]>;
+ char *<[s]>;
+ char **<[ptr]>;
+ int <[base]>;
+
+DESCRIPTION
+The function <> converts the string <<*<[s]>>> to
+a <>. First, it breaks down the string into three parts:
+leading whitespace, which is ignored; a subject string consisting
+of characters resembling an integer in the radix specified by <[base]>;
+and a trailing portion consisting of zero or more unparseable characters,
+and always including the terminating null character. Then, it attempts
+to convert the subject string into a <> and returns the
+result.
+
+If the value of <[base]> is 0, the subject string is expected to look
+like a normal C integer constant: an optional sign, a possible `<<0x>>'
+indicating a hexadecimal base, and a number. If <[base]> is between
+2 and 36, the expected form of the subject is a sequence of letters
+and digits representing an integer in the radix specified by <[base]>,
+with an optional plus or minus sign. The letters <>--<> (or,
+equivalently, <>--<>) are used to signify values from 10 to 35;
+only letters whose ascribed values are less than <[base]> are
+permitted. If <[base]> is 16, a leading <<0x>> is permitted.
+
+The subject sequence is the longest initial sequence of the input
+string that has the expected form, starting with the first
+non-whitespace character. If the string is empty or consists entirely
+of whitespace, or if the first non-whitespace character is not a
+permissible letter or digit, the subject string is empty.
+
+If the subject string is acceptable, and the value of <[base]> is zero,
+<> attempts to determine the radix from the input string. A
+string with a leading <<0x>> is treated as a hexadecimal value; a string with
+a leading 0 and no <> is treated as octal; all other strings are
+treated as decimal. If <[base]> is between 2 and 36, it is used as the
+conversion radix, as described above. If the subject string begins with
+a minus sign, the value is negated. Finally, a pointer to the first
+character past the converted subject string is stored in <[ptr]>, if
+<[ptr]> is not <>.
+
+If the subject string is empty (or not in acceptable form), no conversion
+is performed and the value of <[s]> is stored in <[ptr]> (if <[ptr]> is
+not <>).
+
+The alternate function <<_strtol_r>> is a reentrant version. The
+extra argument <[reent]> is a pointer to a reentrancy structure.
+
+RETURNS
+<> returns the converted value, if any. If no conversion was
+made, 0 is returned.
+
+<> returns <> or <> if the magnitude of
+the converted value is too large, and sets <> to <>.
+
+PORTABILITY
+<> is ANSI.
+
+No supporting OS subroutines are required.
+*/
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+
+#include <_ansi.h>
+#include
+#include
+#include
+#include
+#include
+
+/*
+ * Convert a string to a long integer.
+ *
+ * Ignores `locale' stuff. Assumes that the upper and lower case
+ * alphabets and digits are each contiguous.
+ */
+long
+_DEFUN (_strtol_r, (rptr, nptr, endptr, base),
+ struct _reent *rptr _AND
+ _CONST char *nptr _AND
+ char **endptr _AND
+ int base)
+{
+ register const char *s = nptr;
+ register unsigned long acc;
+ register int c;
+ register unsigned long cutoff;
+ register int neg = 0, any, cutlim;
+
+ /*
+ * Skip white space and pick up leading +/- sign if any.
+ * If base is 0, allow 0x for hex and 0 for octal, else
+ * assume decimal; if base is already 16, allow 0x.
+ */
+ do {
+ c = *s++;
+ } while (isspace(c));
+ if (c == '-') {
+ neg = 1;
+ c = *s++;
+ } else if (c == '+')
+ c = *s++;
+ if ((base == 0 || base == 16) &&
+ c == '0' && (*s == 'x' || *s == 'X')) {
+ c = s[1];
+ s += 2;
+ base = 16;
+ }
+ if (base == 0)
+ base = c == '0' ? 8 : 10;
+
+ /*
+ * Compute the cutoff value between legal numbers and illegal
+ * numbers. That is the largest legal value, divided by the
+ * base. An input number that is greater than this value, if
+ * followed by a legal input character, is too big. One that
+ * is equal to this value may be valid or not; the limit
+ * between valid and invalid numbers is then based on the last
+ * digit. For instance, if the range for longs is
+ * [-2147483648..2147483647] and the input base is 10,
+ * cutoff will be set to 214748364 and cutlim to either
+ * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated
+ * a value > 214748364, or equal but the next digit is > 7 (or 8),
+ * the number is too big, and we will return a range error.
+ *
+ * Set any if any `digits' consumed; make it negative to indicate
+ * overflow.
+ */
+ cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
+ cutlim = cutoff % (unsigned long)base;
+ cutoff /= (unsigned long)base;
+ for (acc = 0, any = 0;; c = *s++) {
+ if (isdigit(c))
+ c -= '0';
+ else if (isalpha(c))
+ c -= isupper(c) ? 'A' - 10 : 'a' - 10;
+ else
+ break;
+ if (c >= base)
+ break;
+ if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
+ any = -1;
+ else {
+ any = 1;
+ acc *= base;
+ acc += c;
+ }
+ }
+ if (any < 0) {
+ acc = neg ? LONG_MIN : LONG_MAX;
+ rptr->_errno = ERANGE;
+ } else if (neg)
+ acc = -acc;
+ if (endptr != 0)
+ *endptr = (char *) (any ? s - 1 : nptr);
+ return (acc);
+}
+
+#ifndef _REENT_ONLY
+
+long
+_DEFUN (strtol, (s, ptr, base),
+ _CONST char *s _AND
+ char **ptr _AND
+ int base)
+{
+ return _strtol_r (_REENT, s, ptr, base);
+}
+
+#endif
strtol.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: getenv.c
===================================================================
--- getenv.c (nonexistent)
+++ getenv.c (revision 345)
@@ -0,0 +1,94 @@
+/*
+FUNCTION
+<>---look up environment variable
+
+INDEX
+ getenv
+INDEX
+ environ
+
+ANSI_SYNOPSIS
+ #include
+ char *getenv(const char *<[name]>);
+
+TRAD_SYNOPSIS
+ #include
+ char *getenv(<[name]>)
+ char *<[name]>;
+
+DESCRIPTION
+<> searches the list of environment variable names and values
+(using the global pointer ``<>'') for a variable whose
+name matches the string at <[name]>. If a variable name matches,
+<> returns a pointer to the associated value.
+
+RETURNS
+A pointer to the (string) value of the environment variable, or
+<> if there is no such environment variable.
+
+PORTABILITY
+<> is ANSI, but the rules for properly forming names of environment
+variables vary from one system to another.
+
+<> requires a global pointer <>.
+*/
+
+/*
+ * Copyright (c) 1987, 2000 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement: ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef _REENT_ONLY
+
+#include
+#include
+#include
+
+/*
+ * _findenv --
+ * Returns pointer to value associated with name, if any, else NULL.
+ * Sets offset to be the offset of the name/value combination in the
+ * environmental array, for use by setenv(3) and unsetenv(3).
+ * Explicitly removes '=' in argument name.
+ *
+ * This routine *should* be a static; don't use it.
+ */
+
+char *
+_DEFUN (_findenv, (name, offset),
+ register _CONST char *name _AND
+ int *offset)
+{
+ return _findenv_r (_REENT, name, offset);
+}
+
+/*
+ * getenv --
+ * Returns ptr to value associated with name, if any, else NULL.
+ */
+
+char *
+_DEFUN (getenv, (name),
+ _CONST char *name)
+{
+ int offset;
+ char *_findenv_r ();
+
+ return _findenv_r (_REENT, name, &offset);
+}
+
+#endif /* !_REENT_ONLY */
getenv.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: Makefile.am
===================================================================
--- Makefile.am (nonexistent)
+++ Makefile.am (revision 345)
@@ -0,0 +1,297 @@
+## Process this file with automake to generate Makefile.in
+
+AUTOMAKE_OPTIONS = cygnus
+
+INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
+
+GENERAL_SOURCES = \
+ __adjust.c \
+ __atexit.c \
+ __call_atexit.c \
+ __exp10.c \
+ __ten_mu.c \
+ _Exit.c \
+ abort.c \
+ abs.c \
+ assert.c \
+ atexit.c \
+ atof.c \
+ atoff.c \
+ atoi.c \
+ atol.c \
+ calloc.c \
+ div.c \
+ dtoa.c \
+ dtoastub.c \
+ environ.c \
+ envlock.c \
+ eprintf.c \
+ exit.c \
+ gdtoa-gethex.c \
+ gdtoa-hexnan.c \
+ getenv.c \
+ getenv_r.c \
+ labs.c \
+ ldiv.c \
+ ldtoa.c \
+ malloc.c \
+ mblen.c \
+ mblen_r.c \
+ mbstowcs.c \
+ mbstowcs_r.c \
+ mbtowc.c \
+ mbtowc_r.c \
+ mlock.c \
+ mprec.c \
+ mstats.c \
+ rand.c \
+ rand_r.c \
+ realloc.c \
+ reallocf.c \
+ sb_charsets.c \
+ strtod.c \
+ strtol.c \
+ strtoul.c \
+ wcstod.c \
+ wcstol.c \
+ wcstoul.c \
+ wcstombs.c \
+ wcstombs_r.c \
+ wctomb.c \
+ wctomb_r.c
+
+if HAVE_LONG_DOUBLE
+GENERAL_SOURCES += \
+ strtold.c \
+ wcstold.c
+endif # HAVE_LONG_DOUBLE
+
+EXTENDED_SOURCES = \
+ cxa_atexit.c \
+ cxa_finalize.c \
+ drand48.c \
+ ecvtbuf.c \
+ efgcvt.c \
+ erand48.c \
+ jrand48.c \
+ lcong48.c \
+ lrand48.c \
+ mrand48.c \
+ msize.c \
+ mtrim.c \
+ nrand48.c \
+ rand48.c \
+ seed48.c \
+ srand48.c \
+ strtoll.c \
+ strtoll_r.c \
+ strtoull.c \
+ strtoull_r.c \
+ wcstoll.c \
+ wcstoll_r.c \
+ wcstoull.c \
+ wcstoull_r.c \
+ atoll.c \
+ llabs.c \
+ lldiv.c
+
+ELIX_2_SOURCES = \
+ a64l.c \
+ btowc.c \
+ getopt.c \
+ getsubopt.c \
+ l64a.c \
+ malign.c \
+ mbrlen.c \
+ mbrtowc.c \
+ mbsinit.c \
+ mbsnrtowcs.c \
+ mbsrtowcs.c \
+ on_exit.c \
+ valloc.c \
+ wcrtomb.c \
+ wcsnrtombs.c \
+ wcsrtombs.c \
+ wctob.c
+
+ELIX_2_OBJS = \
+ $(lpfx)malignr.$(oext) \
+ $(lpfx)malloptr.$(oext) \
+ $(lpfx)pvallocr.$(oext) \
+ $(lpfx)vallocr.$(oext)
+
+ELIX_3_SOURCES = \
+ putenv.c \
+ putenv_r.c \
+ setenv.c \
+ setenv_r.c
+
+ELIX_4_SOURCES = \
+ system.c
+
+if ELIX_LEVEL_1
+ELIX_SOURCES =
+ELIX_OBJS =
+else
+if ELIX_LEVEL_2
+ELIX_SOURCES = $(ELIX_2_SOURCES)
+ELIX_OBJS = $(ELIX_2_OBJS)
+else
+if ELIX_LEVEL_3
+ELIX_SOURCES = $(ELIX_2_SOURCES) $(ELIX_3_SOURCES)
+ELIX_OBJS = $(ELIX_2_OBJS)
+else
+ELIX_SOURCES = $(ELIX_2_SOURCES) $(ELIX_3_SOURCES) $(ELIX_4_SOURCES)
+ELIX_OBJS = $(ELIX_2_OBJS)
+endif
+endif
+endif
+
+# Because of how libtool moves objects around, mallocr must be built last.
+LIBADD_OBJS = $(lpfx)freer.$(oext) $(lpfx)reallocr.$(oext) \
+ $(lpfx)callocr.$(oext) $(lpfx)cfreer.$(oext) \
+ $(lpfx)mallinfor.$(oext) $(lpfx)mallstatsr.$(oext) \
+ $(lpfx)msizer.$(oext) $(lpfx)mallocr.$(oext)
+
+libstdlib_la_LDFLAGS = -Xcompiler -nostdlib
+
+if USE_LIBTOOL
+noinst_LTLIBRARIES = libstdlib.la
+libstdlib_la_SOURCES = $(GENERAL_SOURCES) $(EXTENDED_SOURCES) $(ELIX_SOURCES)
+libstdlib_la_LIBADD = $(LIBADD_OBJS) $(ELIX_OBJS)
+libstdlib_la_DEPENDENCIES = $(LIBADD_OBJS) $(ELIX_OBJS)
+LIB_COMPILE = $(LTCOMPILE)
+noinst_DATA = objectlist.awk.in
+else
+noinst_LIBRARIES = lib.a
+lib_a_SOURCES = $(GENERAL_SOURCES) $(EXTENDED_SOURCES) $(ELIX_SOURCES)
+lib_a_LIBADD = $(LIBADD_OBJS) $(ELIX_OBJS)
+lib_a_CFLAGS = $(AM_CFLAGS)
+lib_a_DEPENDENCIES = $(LIBADD_OBJS) $(ELIX_OBJS)
+LIB_COMPILE = $(COMPILE)
+noinst_DATA =
+endif # USE_LIBTOOL
+
+include $(srcdir)/../../Makefile.shared
+
+MALLOC_COMPILE = $(LIB_COMPILE) -DINTERNAL_NEWLIB
+
+$(lpfx)mallocr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MALLOC -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)freer.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_FREE -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)reallocr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_REALLOC -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)callocr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_CALLOC -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)cfreer.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_CFREE -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)malignr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MEMALIGN -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)vallocr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_VALLOC -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)pvallocr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_PVALLOC -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)mallinfor.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MALLINFO -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)mallstatsr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MALLOC_STATS -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)msizer.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MALLOC_USABLE_SIZE -c $(srcdir)/mallocr.c -o $@
+
+$(lpfx)malloptr.$(oext): mallocr.c
+ $(MALLOC_COMPILE) -DDEFINE_MALLOPT -c $(srcdir)/mallocr.c -o $@
+
+CHEWOUT_FILES= \
+ _Exit.def \
+ a64l.def \
+ abort.def \
+ abs.def \
+ assert.def \
+ atexit.def \
+ atof.def \
+ atoi.def \
+ atoll.def \
+ calloc.def \
+ div.def \
+ ecvtbuf.def \
+ efgcvt.def \
+ envlock.def \
+ exit.def \
+ getenv.def \
+ labs.def \
+ ldiv.def \
+ llabs.def \
+ lldiv.def \
+ malloc.def \
+ mallocr.def \
+ mblen.def \
+ mbsnrtowcs.def \
+ mbstowcs.def \
+ mbtowc.def \
+ mlock.def \
+ mstats.def \
+ on_exit.def \
+ rand.def \
+ rand48.def \
+ strtod.def \
+ strtol.def \
+ strtoll.def \
+ strtoul.def \
+ strtoull.def \
+ wcsnrtombs.def \
+ wcstod.def \
+ wcstol.def \
+ wcstoll.def \
+ wcstoul.def \
+ wcstoull.def \
+ system.def \
+ wcstombs.def \
+ wctomb.def
+
+SUFFIXES = .def
+
+CHEW = ../../doc/makedoc -f $(srcdir)/../../doc/doc.str
+
+.c.def:
+ $(CHEW) < $< > $*.def 2> $*.ref
+ touch stmp-def
+
+TARGETDOC = ../tmp.texi
+
+doc: $(CHEWOUT_FILES)
+ cat $(srcdir)/stdlib.tex >> $(TARGETDOC)
+
+CLEANFILES = $(CHEWOUT_FILES) *.ref
+
+$(lpfx)dtoa.$(oext): dtoa.c mprec.h
+$(lpfx)ldtoa.$(oext): ldtoa.c mprec.h
+$(lpfx)ecvtbuf.$(oext): ecvtbuf.c mprec.h
+$(lpfx)mbtowc_r.$(oext): mbtowc_r.c mbctype.h
+ $(LIB_COMPILE) -c -fshort-enums $(srcdir)/mbtowc_r.c -o $@
+
+$(lpfx)mprec.$(oext): mprec.c mprec.h
+$(lpfx)strtod.$(oext): strtod.c mprec.h
+$(lpfx)gdtoa-gethex.$(oext): gdtoa-gethex.c mprec.h
+$(lpfx)gdtoa-hexnan.$(oext): gdtoa-hexnan.c mprec.h
+$(lpfx)wctomb_r.$(oext): wctomb_r.c mbctype.h
+$(lpfx)drand48.$(oext): drand48.c rand48.h
+$(lpfx)erand48.$(oext): erand48.c rand48.h
+$(lpfx)jrand48.$(oext): jrand48.c rand48.h
+$(lpfx)lcong48.$(oext): lcong48.c rand48.h
+$(lpfx)lrand48.$(oext): lrand48.c rand48.h
+$(lpfx)mrand48.$(oext): mrand48.c rand48.h
+$(lpfx)nrand48.$(oext): nrand48.c rand48.h
+$(lpfx)rand48.$(oext): rand48.c rand48.h
+$(lpfx)seed48.$(oext): seed48.c rand48.h
+$(lpfx)srand48.$(oext): srand48.c rand48.h
Makefile.am
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: __exp10.c
===================================================================
--- __exp10.c (nonexistent)
+++ __exp10.c (revision 345)
@@ -0,0 +1,30 @@
+/*
+ * compute 10**x by successive squaring.
+ */
+
+#include <_ansi.h>
+#include "std.h"
+
+double
+_DEFUN (__exp10, (x),
+ unsigned x)
+{
+ static _CONST double powtab[] =
+ {1.0,
+ 10.0,
+ 100.0,
+ 1000.0,
+ 10000.0};
+
+ if (x < (sizeof (powtab) / sizeof (double)))
+ return powtab[x];
+ else if (x & 1)
+ {
+ return 10.0 * __exp10 (x - 1);
+ }
+ else
+ {
+ double n = __exp10 (x / 2);
+ return n * n;
+ }
+}
__exp10.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: getsubopt.3
===================================================================
--- getsubopt.3 (nonexistent)
+++ getsubopt.3 (revision 345)
@@ -0,0 +1,149 @@
+.\" Copyright (c) 1990, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" @(#)getsubopt.3 8.1 (Berkeley) 6/9/93
+.\" $FreeBSD: src/lib/libc/stdlib/getsubopt.3,v 1.9 2001/09/07 14:46:35 asmodai Exp $
+.\"
+.Dd June 9, 1993
+.Dt GETSUBOPT 3
+.Os
+.Sh NAME
+.Nm getsubopt
+.Nd get sub options from an argument
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.In unistd.h
+.Vt extern char *suboptarg ;
+.Ft int
+.Fn getsubopt "char **optionp" "char * const *tokens" "char **valuep"
+.Sh DESCRIPTION
+The
+.Fn getsubopt
+function
+parses a string containing tokens delimited by one or more tab, space or
+comma
+.Pq Ql \&,
+characters.
+It is intended for use in parsing groups of option arguments provided
+as part of a utility command line.
+.Pp
+The argument
+.Fa optionp
+is a pointer to a pointer to the string.
+The argument
+.Fa tokens
+is a pointer to a
+.Dv NULL Ns -terminated
+array of pointers to strings.
+.Pp
+The
+.Fn getsubopt
+function
+returns the zero-based offset of the pointer in the
+.Fa tokens
+array referencing a string which matches the first token
+in the string, or, \-1 if the string contains no tokens or
+.Fa tokens
+does not contain a matching string.
+.Pp
+If the token is of the form ``name=value'', the location referenced by
+.Fa valuep
+will be set to point to the start of the ``value'' portion of the token.
+.Pp
+On return from
+.Fn getsubopt ,
+.Fa optionp
+will be set to point to the start of the next token in the string,
+or the null at the end of the string if no more tokens are present.
+The external variable
+.Fa suboptarg
+will be set to point to the start of the current token, or
+.Dv NULL
+if no
+tokens were present.
+The argument
+.Fa valuep
+will be set to point to the ``value'' portion of the token, or
+.Dv NULL
+if no ``value'' portion was present.
+.Sh EXAMPLES
+.Bd -literal -compact
+char *tokens[] = {
+ #define ONE 0
+ "one",
+ #define TWO 1
+ "two",
+ NULL
+};
+
+\&...
+
+extern char *optarg, *suboptarg;
+char *options, *value;
+
+while ((ch = getopt(argc, argv, "ab:")) != \-1) {
+ switch(ch) {
+ case 'a':
+ /* process ``a'' option */
+ break;
+ case 'b':
+ options = optarg;
+ while (*options) {
+ switch(getsubopt(&options, tokens, &value)) {
+ case ONE:
+ /* process ``one'' sub option */
+ break;
+ case TWO:
+ /* process ``two'' sub option */
+ if (!value)
+ error("no value for two");
+ i = atoi(value);
+ break;
+ case \-1:
+ if (suboptarg)
+ error("illegal sub option %s",
+ suboptarg);
+ else
+ error("missing sub option");
+ break;
+ }
+ break;
+ }
+.Ed
+.Sh SEE ALSO
+.Xr getopt 3 ,
+.Xr strsep 3
+.Sh HISTORY
+The
+.Fn getsubopt
+function first appeared in
+.Bx 4.4 .
Index: atoi.c
===================================================================
--- atoi.c (nonexistent)
+++ atoi.c (revision 345)
@@ -0,0 +1,81 @@
+/*
+FUNCTION
+ <>, <>---string to integer
+
+INDEX
+ atoi
+INDEX
+ atol
+INDEX
+ _atoi_r
+INDEX
+ _atol_r
+
+ANSI_SYNOPSIS
+ #include
+ int atoi(const char *<[s]>);
+ long atol(const char *<[s]>);
+ int _atoi_r(struct _reent *<[ptr]>, const char *<[s]>);
+ long _atol_r(struct _reent *<[ptr]>, const char *<[s]>);
+
+TRAD_SYNOPSIS
+ #include
+ int atoi(<[s]>)
+ char *<[s]>;
+
+ long atol(<[s]>)
+ char *<[s]>;
+
+ int _atoi_r(<[ptr]>, <[s]>)
+ struct _reent *<[ptr]>;
+ char *<[s]>;
+
+ long _atol_r(<[ptr]>, <[s]>)
+ struct _reent *<[ptr]>;
+ char *<[s]>;
+
+
+DESCRIPTION
+ <> converts the initial portion of a string to an <>.
+ <> converts the initial portion of a string to a <>.
+
+ <> is implemented as <<(int)strtol(s, NULL, 10).>>
+ <> is implemented as <>
+
+ <<_atoi_r>> and <<_atol_r>> are reentrant versions of <> and
+ <> respectively, passing the reentrancy struct pointer.
+
+RETURNS
+ The functions return the converted value, if any. If no conversion was
+ made, <<0>> is returned.
+
+PORTABILITY
+<>, <> are ANSI.
+
+No supporting OS subroutines are required.
+*/
+
+/*
+ * Andy Wilson, 2-Oct-89.
+ */
+
+#include
+#include <_ansi.h>
+
+#ifndef _REENT_ONLY
+int
+_DEFUN (atoi, (s),
+ _CONST char *s)
+{
+ return (int) strtol (s, NULL, 10);
+}
+#endif /* !_REENT_ONLY */
+
+int
+_DEFUN (_atoi_r, (s),
+ struct _reent *ptr _AND
+ _CONST char *s)
+{
+ return (int) _strtol_r (ptr, s, NULL, 10);
+}
+
atoi.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: cxa_finalize.c
===================================================================
--- cxa_finalize.c (nonexistent)
+++ cxa_finalize.c (revision 345)
@@ -0,0 +1,20 @@
+/*
+ * Implementation if __cxa_finalize.
+ */
+
+
+#include
+#include
+#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);
+}
cxa_finalize.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
Index: calloc.c
===================================================================
--- calloc.c (nonexistent)
+++ calloc.c (revision 345)
@@ -0,0 +1,69 @@
+#ifdef MALLOC_PROVIDED
+int _dummy_calloc = 1;
+#else
+/*
+FUNCTION
+<>---allocate space for arrays
+
+INDEX
+ calloc
+
+INDEX
+ _calloc_r
+
+ANSI_SYNOPSIS
+ #include
+ void *calloc(size_t <[n]>, size_t <[s]>);
+ void *_calloc_r(void *<[reent]>, size_t <[n]>, size_t <[s]>);
+
+TRAD_SYNOPSIS
+ #include
+ char *calloc(<[n]>, <[s]>)
+ size_t <[n]>, <[s]>;
+
+ char *_calloc_r(<[reent]>, <[n]>, <[s]>)
+ char *<[reent]>;
+ size_t <[n]>;
+ size_t <[s]>;
+
+
+
+DESCRIPTION
+Use <> to request a block of memory sufficient to hold an
+array of <[n]> elements, each of which has size <[s]>.
+
+The memory allocated by <> comes out of the same memory pool
+used by <>, but the memory block is initialized to all zero
+bytes. (To avoid the overhead of initializing the space, use
+<> instead.)
+
+The alternate function <<_calloc_r>> is reentrant.
+The extra argument <[reent]> is a pointer to a reentrancy structure.
+
+RETURNS
+If successful, a pointer to the newly allocated space.
+
+If unsuccessful, <>.
+
+PORTABILITY
+<> is ANSI.
+
+Supporting OS subroutines required: <>, <>, <>,
+<>, <>, <>, <>.
+*/
+
+#include
+#include
+
+#ifndef _REENT_ONLY
+
+_PTR
+_DEFUN (calloc, (n, size),
+ size_t n _AND
+ size_t size)
+{
+ return _calloc_r (_REENT, n, size);
+}
+
+#endif
+#endif /* MALLOC_PROVIDED */
calloc.c
Property changes :
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Id
\ No newline at end of property
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.