summaryrefslogtreecommitdiff
path: root/usr/src/lib/libbc/libc/gen/common
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libbc/libc/gen/common')
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_add.c66
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_cmp.c43
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_cmpe.c43
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_div.c45
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_dtoq.c42
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_fcc.c79
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_get_rp_rd.S55
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_itoq.c41
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_mul.c45
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_neg.c44
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_qtod.c43
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_qtoi.c46
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_qtos.c43
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_qtou.c55
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_sqrt.c44
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_stoq.c42
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_sub.c45
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Q_utoq.c49
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Qfaddsub.c216
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Qfcompare.c82
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Qfdiv.c295
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Qfmul.c183
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Qfpack.c428
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Qfunpack.c231
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Qfutility.c278
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Qglobals.h115
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_Qquad.h151
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_base_S.c118
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_base_il.c97
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_base_sup.c307
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_big_power.c1772
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_crypt.c470
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_nlist.c107
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_perror.c59
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_psignal.c60
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_small_power.c878
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_sprintf_sup.c324
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_times_power.c454
-rw-r--r--usr/src/lib/libbc/libc/gen/common/_unpack_dble.c250
-rw-r--r--usr/src/lib/libbc/libc/gen/common/a64l.c51
-rw-r--r--usr/src/lib/libbc/libc/gen/common/abs.c34
-rw-r--r--usr/src/lib/libbc/libc/gen/common/alarm.c48
-rw-r--r--usr/src/lib/libbc/libc/gen/common/asctime.c62
-rw-r--r--usr/src/lib/libbc/libc/gen/common/atof.c38
-rw-r--r--usr/src/lib/libbc/libc/gen/common/atoi.c64
-rw-r--r--usr/src/lib/libbc/libc/gen/common/atol.c64
-rw-r--r--usr/src/lib/libbc/libc/gen/common/base_conversion.h424
-rw-r--r--usr/src/lib/libbc/libc/gen/common/bcmp.c37
-rw-r--r--usr/src/lib/libbc/libc/gen/common/bsearch.c59
-rw-r--r--usr/src/lib/libbc/libc/gen/common/calloc.c65
-rw-r--r--usr/src/lib/libbc/libc/gen/common/char_to_decimal.h532
-rw-r--r--usr/src/lib/libbc/libc/gen/common/clock.c52
-rw-r--r--usr/src/lib/libbc/libc/gen/common/closedir.c49
-rw-r--r--usr/src/lib/libbc/libc/gen/common/codeset.h73
-rw-r--r--usr/src/lib/libbc/libc/gen/common/crypt.c75
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ctime.c35
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ctype_.c172
-rw-r--r--usr/src/lib/libbc/libc/gen/common/decimal_bin.c694
-rw-r--r--usr/src/lib/libbc/libc/gen/common/double_decim.c697
-rw-r--r--usr/src/lib/libbc/libc/gen/common/drand48.c177
-rw-r--r--usr/src/lib/libbc/libc/gen/common/dysize.c43
-rw-r--r--usr/src/lib/libbc/libc/gen/common/econvert.c143
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ecvt.c52
-rw-r--r--usr/src/lib/libbc/libc/gen/common/errlst.c114
-rw-r--r--usr/src/lib/libbc/libc/gen/common/euc.h40
-rw-r--r--usr/src/lib/libbc/libc/gen/common/euc.multibyte.c195
-rw-r--r--usr/src/lib/libbc/libc/gen/common/execvp.c126
-rw-r--r--usr/src/lib/libbc/libc/gen/common/exit.c56
-rw-r--r--usr/src/lib/libbc/libc/gen/common/exportent.c259
-rw-r--r--usr/src/lib/libbc/libc/gen/common/fabs.c39
-rw-r--r--usr/src/lib/libbc/libc/gen/common/file_decim.c82
-rw-r--r--usr/src/lib/libbc/libc/gen/common/float_decim.c94
-rw-r--r--usr/src/lib/libbc/libc/gen/common/fmod.c150
-rw-r--r--usr/src/lib/libbc/libc/gen/common/frexp.c59
-rw-r--r--usr/src/lib/libbc/libc/gen/common/fstab.c148
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ftok.c41
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ftw.c239
-rw-r--r--usr/src/lib/libbc/libc/gen/common/func_decim.c83
-rw-r--r--usr/src/lib/libbc/libc/gen/common/gconvert.c164
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getauditflags.c495
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getauid.c38
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getcwd.c80
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getenv.c67
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getgraent.c462
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getlogin.c42
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getopt.c107
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getpass.c103
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getpwaent.c557
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getsubopt.c72
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getttyent.c163
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getttynam.c24
-rw-r--r--usr/src/lib/libbc/libc/gen/common/getusershell.c110
-rw-r--r--usr/src/lib/libbc/libc/gen/common/grpauth.c71
-rw-r--r--usr/src/lib/libbc/libc/gen/common/hsearch.c545
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ieee_globals.c57
-rw-r--r--usr/src/lib/libbc/libc/gen/common/index.c42
-rw-r--r--usr/src/lib/libbc/libc/gen/common/isatty.c50
-rw-r--r--usr/src/lib/libbc/libc/gen/common/iso.multibyte.c923
-rw-r--r--usr/src/lib/libbc/libc/gen/common/iso2022.h76
-rw-r--r--usr/src/lib/libbc/libc/gen/common/issecure.c44
-rw-r--r--usr/src/lib/libbc/libc/gen/common/jcsetpgrp.c41
-rw-r--r--usr/src/lib/libbc/libc/gen/common/l64a.c68
-rw-r--r--usr/src/lib/libbc/libc/gen/common/labeltostring.c45
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ldexp.c88
-rw-r--r--usr/src/lib/libbc/libc/gen/common/lfind.c57
-rw-r--r--usr/src/lib/libbc/libc/gen/common/localtime.c1421
-rw-r--r--usr/src/lib/libbc/libc/gen/common/lsearch.c58
-rw-r--r--usr/src/lib/libbc/libc/gen/common/madvise.c57
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mallint.h120
-rw-r--r--usr/src/lib/libbc/libc/gen/common/malloc.c1444
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mallopt.c88
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mbextern.h37
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mblib.c86
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mbstowcs.c101
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mbtowc.c132
-rw-r--r--usr/src/lib/libbc/libc/gen/common/memalign.c142
-rw-r--r--usr/src/lib/libbc/libc/gen/common/memccpy.c42
-rw-r--r--usr/src/lib/libbc/libc/gen/common/memchr.c41
-rw-r--r--usr/src/lib/libbc/libc/gen/common/memcmp.c43
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mkstemp.c35
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mktemp.c76
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mlock.c46
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mlockall.c42
-rw-r--r--usr/src/lib/libbc/libc/gen/common/mntent.c233
-rw-r--r--usr/src/lib/libbc/libc/gen/common/modf.c56
-rw-r--r--usr/src/lib/libbc/libc/gen/common/msync.c46
-rw-r--r--usr/src/lib/libbc/libc/gen/common/munlock.c42
-rw-r--r--usr/src/lib/libbc/libc/gen/common/munlockall.c42
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ndbm.c899
-rw-r--r--usr/src/lib/libbc/libc/gen/common/nl_cxtime.c52
-rw-r--r--usr/src/lib/libbc/libc/gen/common/nl_strncmp.c54
-rw-r--r--usr/src/lib/libbc/libc/gen/common/on_exit.c55
-rw-r--r--usr/src/lib/libbc/libc/gen/common/opendir.c74
-rw-r--r--usr/src/lib/libbc/libc/gen/common/optind.c31
-rw-r--r--usr/src/lib/libbc/libc/gen/common/pack_float.c455
-rw-r--r--usr/src/lib/libbc/libc/gen/common/perror.c45
-rw-r--r--usr/src/lib/libbc/libc/gen/common/plock.c319
-rw-r--r--usr/src/lib/libbc/libc/gen/common/popen.c98
-rw-r--r--usr/src/lib/libbc/libc/gen/common/posix_sig.c106
-rw-r--r--usr/src/lib/libbc/libc/gen/common/posix_tty.c226
-rw-r--r--usr/src/lib/libbc/libc/gen/common/psignal.c46
-rw-r--r--usr/src/lib/libbc/libc/gen/common/putenv.c122
-rw-r--r--usr/src/lib/libbc/libc/gen/common/pwdauth.c74
-rw-r--r--usr/src/lib/libbc/libc/gen/common/pwdnm.c47
-rw-r--r--usr/src/lib/libbc/libc/gen/common/qeconvert.c154
-rw-r--r--usr/src/lib/libbc/libc/gen/common/qsort.c223
-rw-r--r--usr/src/lib/libbc/libc/gen/common/random.c384
-rw-r--r--usr/src/lib/libbc/libc/gen/common/readdir.c67
-rw-r--r--usr/src/lib/libbc/libc/gen/common/realpath.c241
-rw-r--r--usr/src/lib/libbc/libc/gen/common/regex.c437
-rw-r--r--usr/src/lib/libbc/libc/gen/common/rindex.c44
-rw-r--r--usr/src/lib/libbc/libc/gen/common/scandir.c105
-rw-r--r--usr/src/lib/libbc/libc/gen/common/seconvert.c154
-rw-r--r--usr/src/lib/libbc/libc/gen/common/seekdir.c60
-rw-r--r--usr/src/lib/libbc/libc/gen/common/setlocale.c831
-rw-r--r--usr/src/lib/libbc/libc/gen/common/setrgid.c35
-rw-r--r--usr/src/lib/libbc/libc/gen/common/setruid.c34
-rw-r--r--usr/src/lib/libbc/libc/gen/common/sigfpe.c203
-rw-r--r--usr/src/lib/libbc/libc/gen/common/siglist.c48
-rw-r--r--usr/src/lib/libbc/libc/gen/common/sparc/alloca.s62
-rw-r--r--usr/src/lib/libbc/libc/gen/common/sparc/base_conv.c129
-rw-r--r--usr/src/lib/libbc/libc/gen/common/sparc/ffs.s47
-rw-r--r--usr/src/lib/libbc/libc/gen/common/sparc/insque.s47
-rw-r--r--usr/src/lib/libbc/libc/gen/common/sparc/isinf.c55
-rw-r--r--usr/src/lib/libbc/libc/gen/common/sparc/remque.s46
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ssignal.c93
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strchr.c44
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strftime.c531
-rw-r--r--usr/src/lib/libbc/libc/gen/common/stricmp.c89
-rw-r--r--usr/src/lib/libbc/libc/gen/common/string_decim.c64
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strncat.c50
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strpbrk.c49
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strptime.c483
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strrchr.c47
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strspn.c46
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strstr.c54
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strtod.c59
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strtok.c65
-rw-r--r--usr/src/lib/libbc/libc/gen/common/strtol.c79
-rw-r--r--usr/src/lib/libbc/libc/gen/common/swab.c54
-rw-r--r--usr/src/lib/libbc/libc/gen/common/syslog.c331
-rw-r--r--usr/src/lib/libbc/libc/gen/common/telldir.c40
-rw-r--r--usr/src/lib/libbc/libc/gen/common/tfind.c60
-rw-r--r--usr/src/lib/libbc/libc/gen/common/time.c42
-rw-r--r--usr/src/lib/libbc/libc/gen/common/tsearch.c159
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ttyslot.c83
-rw-r--r--usr/src/lib/libbc/libc/gen/common/ualarm.c36
-rw-r--r--usr/src/lib/libbc/libc/gen/common/unpack_float.c194
-rw-r--r--usr/src/lib/libbc/libc/gen/common/usleep.c71
-rw-r--r--usr/src/lib/libbc/libc/gen/common/valloc.c36
-rw-r--r--usr/src/lib/libbc/libc/gen/common/wcstombs.c101
-rw-r--r--usr/src/lib/libbc/libc/gen/common/wctomb.c103
-rw-r--r--usr/src/lib/libbc/libc/gen/common/xccs.multibyte.c342
193 files changed, 0 insertions, 31745 deletions
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_add.c b/usr/src/lib/libbc/libc/gen/common/_Q_add.c
deleted file mode 100644
index 1234196eb7..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_add.c
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-static double zero = 0.0, tiny = 1.0e-300, huge = 1.0e300;
-static void dummy(double);
-
-QUAD
-_Q_add(QUAD x, QUAD y)
-{
- unpacked px,py,pz;
- QUAD z;
- _fp_current_exceptions = 0;
- _Q_get_rp_rd(); /* get fp_precision, fp_direction */
- _fp_unpack(&px,(int *)&x,fp_op_extended);
- _fp_unpack(&py,(int *)&y,fp_op_extended);
- _fp_add(&px,&py,&pz);
- _fp_pack(&pz,(int *)&z,fp_op_extended);
- _Q_set_exception(_fp_current_exceptions);
- return (z);
-}
-
-void
-_Q_set_exception(unsigned ex)
-{
- /* simulate exceptions using double arithmetic */
- double t;
- if((ex&(1<<fp_invalid))!=0) t = (zero/zero);
- if((ex&(1<<fp_overflow))!=0) t = (huge*huge);
- if((ex&(1<<fp_underflow))!=0) t = (tiny*tiny);
- if((ex&(1<<fp_division))!=0) t = (tiny/zero);
- if((ex&(1<<fp_inexact))!=0) t = (huge+tiny);
- dummy(t); /* prevent optimizer eliminating previous expression */
-}
-
-static void
-dummy(double x)
-{
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_cmp.c b/usr/src/lib/libbc/libc/gen/common/_Q_cmp.c
deleted file mode 100644
index 79679ab61e..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_cmp.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-enum fcc_type
-_Q_cmp(QUAD x, QUAD y)
-{
- unpacked px,py,pz;
- enum fcc_type fcc;
- _fp_current_exceptions = 0;
- _fp_unpack(&px, (int *)&x,fp_op_extended);
- _fp_unpack(&py, (int *)&y,fp_op_extended);
- fcc = _fp_compare(&px,&py,0); /* quiet NaN unexceptional */
- _Q_set_exception(_fp_current_exceptions);
- return (fcc);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_cmpe.c b/usr/src/lib/libbc/libc/gen/common/_Q_cmpe.c
deleted file mode 100644
index ee1f16cd66..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_cmpe.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-enum fcc_type
-_Q_cmpe(QUAD x, QUAD y)
-{
- unpacked px,py,pz;
- enum fcc_type fcc;
- _fp_current_exceptions = 0;
- _fp_unpack(&px, (int *)&x,fp_op_extended);
- _fp_unpack(&py, (int *)&y,fp_op_extended);
- fcc = _fp_compare(&px,&py,1); /* quiet NaN exceptional */
- _Q_set_exception(_fp_current_exceptions);
- return (fcc);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_div.c b/usr/src/lib/libbc/libc/gen/common/_Q_div.c
deleted file mode 100644
index 3e8686426b..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_div.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-QUAD
-_Q_div(QUAD x, QUAD y)
-{
- unpacked px,py,pz;
- QUAD z;
- _fp_current_exceptions = 0;
- _Q_get_rp_rd();
- _fp_unpack(&px, (int *)&x,fp_op_extended);
- _fp_unpack(&py, (int *)&y,fp_op_extended);
- _fp_div(&px,&py,&pz);
- _fp_pack(&pz, (int *)&z,fp_op_extended);
- _Q_set_exception(_fp_current_exceptions);
- return (z);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_dtoq.c b/usr/src/lib/libbc/libc/gen/common/_Q_dtoq.c
deleted file mode 100644
index b07ca5757b..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_dtoq.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-QUAD
-_Q_dtoq(double x)
-{
- unpacked px;
- QUAD q;
- _fp_current_exceptions = 0;
- _fp_unpack(&px, (int *)&x,fp_op_double);
- _fp_pack(&px, (int *)&q,fp_op_extended);
- _Q_set_exception(_fp_current_exceptions);
- return (q);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_fcc.c b/usr/src/lib/libbc/libc/gen/common/_Q_fcc.c
deleted file mode 100644
index 4734b34881..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_fcc.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* integer function _Q_feq, _Q_fne, _Q_fgt, _Q_fge, _Q_flt, _Q_fle */
-
-#include "_Qquad.h"
-
-int
-_Q_feq(QUAD x, QUAD y)
-{
- enum fcc_type fcc;
- fcc = _Q_cmp(x,y);
- return (fcc_equal==fcc);
-}
-
-int
-_Q_fne(QUAD x, QUAD y)
-{
- enum fcc_type fcc;
- fcc = _Q_cmp(x,y);
- return (fcc_equal!=fcc);
-}
-
-int
-_Q_fgt(QUAD x, QUAD y)
-{
- enum fcc_type fcc;
- fcc = _Q_cmpe(x,y);
- return (fcc_greater==fcc);
-}
-
-int
-_Q_fge(QUAD x, QUAD y)
-{
- enum fcc_type fcc;
- fcc = _Q_cmpe(x,y);
- return (fcc_greater==fcc||fcc_equal==fcc);
-}
-
-int
-_Q_flt(QUAD x, QUAD y)
-{
- enum fcc_type fcc;
- fcc = _Q_cmpe(x,y);
- return (fcc_less==fcc);
-}
-
-int
-_Q_fle(QUAD x, QUAD y)
-{
- enum fcc_type fcc;
- fcc = _Q_cmpe(x,y);
- return (fcc_less==fcc||fcc_equal==fcc);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_get_rp_rd.S b/usr/src/lib/libbc/libc/gen/common/_Q_get_rp_rd.S
deleted file mode 100644
index b8409bed81..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_get_rp_rd.S
+++ /dev/null
@@ -1,55 +0,0 @@
-!
-! #ident "%Z%%M% %I% %E% SMI"
-!
-! Copyright 2005 Sun Microsystems, Inc. All rights reserved.
-! Use is subject to license terms.
-!
-! CDDL HEADER START
-!
-! The contents of this file are subject to the terms of the
-! Common Development and Distribution License, Version 1.0 only
-! (the "License"). You may not use this file except in compliance
-! with the License.
-!
-! You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-! or http://www.opensolaris.org/os/licensing.
-! See the License for the specific language governing permissions
-! and limitations under the License.
-!
-! When distributing Covered Code, include this CDDL HEADER in each
-! file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-! If applicable, add the following below this CDDL HEADER, with the
-! fields enclosed by brackets "[]" replaced with your own identifying
-! information: Portions Copyright [yyyy] [name of copyright owner]
-!
-! CDDL HEADER END
-!
-
-#include "SYS.h"
-
- ENTRY(_Q_get_rp_rd)
- .global fp_precision, fp_direction
-__Q_get_rp_rd:
-#ifdef PIC
- PIC_SETUP(o5)
- ld [%o5+fp_direction],%o3
-#else
- set fp_direction,%o3
-#endif
- set 0xc0000000,%o4 ! mask of rounding direction bits
- st %fsr,[%sp+0x44]
- ld [%sp+0x44],%o0 ! o0 = fsr
- and %o0,%o4,%o1
- srl %o1,30,%o1
- st %o1,[%o3]
-#ifdef PIC
- ld [%o5+fp_precision],%o3
-#else
- set fp_precision,%o3
-#endif
- set 0x30000000,%o4
- and %o0,%o4,%o1
- srl %o1,28,%o1
- retl
- st %o1,[%o3]
- SET_SIZE(_Q_get_rp_rd)
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_itoq.c b/usr/src/lib/libbc/libc/gen/common/_Q_itoq.c
deleted file mode 100644
index 31ca813b97..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_itoq.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-
-QUAD
-_Q_itoq(int x)
-{
- unpacked px;
- QUAD q;
- _fp_unpack(&px, (int *)&x,fp_op_integer);
- _fp_pack(&px, (int *)&q,fp_op_extended);
- return (q);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_mul.c b/usr/src/lib/libbc/libc/gen/common/_Q_mul.c
deleted file mode 100644
index 9b80392317..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_mul.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-QUAD
-_Q_mul(QUAD x, QUAD y)
-{
- unpacked px,py,pz;
- QUAD z;
- _fp_current_exceptions = 0;
- _Q_get_rp_rd();
- _fp_unpack(&px, (int *)&x,fp_op_extended);
- _fp_unpack(&py, (int *)&y,fp_op_extended);
- _fp_mul(&px,&py,&pz);
- _fp_pack(&pz, (int *)&z,fp_op_extended);
- _Q_set_exception(_fp_current_exceptions);
- return (z);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_neg.c b/usr/src/lib/libbc/libc/gen/common/_Q_neg.c
deleted file mode 100644
index 9c19c980eb..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_neg.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-
-QUAD
-_Q_neg(QUAD x)
-{
- QUAD z;
- int *pz = (int*) &z;
- double dummy = 1.0;
- z = x;
- if((*(int*)&dummy)!=0) {
- pz[0] ^= 0x80000000;
- } else {
- pz[3] ^= 0x80000000;
- }
- return (z);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_qtod.c b/usr/src/lib/libbc/libc/gen/common/_Q_qtod.c
deleted file mode 100644
index e10417e8b3..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_qtod.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-double
-_Q_qtod(QUAD x)
-{
- unpacked px;
- double d;
- _fp_current_exceptions = 0;
- _Q_get_rp_rd();
- _fp_unpack(&px, (int *)&x,fp_op_extended);
- _fp_pack(&px, (int *)&d,fp_op_double);
- _Q_set_exception(_fp_current_exceptions);
- return (d);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_qtoi.c b/usr/src/lib/libbc/libc/gen/common/_Q_qtoi.c
deleted file mode 100644
index 1858c29c34..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_qtoi.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1995 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-int
-_Q_qtoi(QUAD x)
-{
- unpacked px;
- int i;
- enum fp_direction_type saved_fp_direction = fp_direction;
-
- _fp_current_exceptions = 0;
- fp_direction = fp_tozero;
- _fp_unpack(&px, (int *)&x,fp_op_extended);
- _fp_pack(&px,&i,fp_op_integer);
- _Q_set_exception(_fp_current_exceptions);
- fp_direction = saved_fp_direction;
- return (i);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_qtos.c b/usr/src/lib/libbc/libc/gen/common/_Q_qtos.c
deleted file mode 100644
index f034e87aed..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_qtos.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-SINGLERESULT
-_Q_qtos(QUAD x)
-{
- unpacked px;
- float s;
- _fp_current_exceptions = 0;
- _Q_get_rp_rd();
- _fp_unpack(&px, (int *)&x,fp_op_extended);
- _fp_pack(&px, (int *)&s,fp_op_single);
- _Q_set_exception(_fp_current_exceptions);
- RETURNSINGLE(s);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_qtou.c b/usr/src/lib/libbc/libc/gen/common/_Q_qtou.c
deleted file mode 100644
index 599d0dfdc1..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_qtou.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1995 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-unsigned
-_Q_qtou(QUAD x)
-{
- unpacked px;
- QUAD c;
- unsigned u,*pc = (unsigned*)&c,r;
- enum fp_direction_type saved_fp_direction = fp_direction;
-
- pc[0] = 0x401e0000; pc[1]=pc[2]=pc[3]=0; /* c = 2^31 */
- r = 0;
- u = *(int*)&x; /* high part of x */
- if(u>=0x401e0000&&u<0x401f0000) {
- r = 0x80000000;
- x = _Q_sub(x,c);
- }
-
- _fp_current_exceptions = 0;
- fp_direction = fp_tozero;
- _fp_unpack(&px, (int *)&x,fp_op_extended);
- _fp_pack(&px, (int *)&u,fp_op_integer);
- _Q_set_exception(_fp_current_exceptions);
- fp_direction = saved_fp_direction;
- return (u|r);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_sqrt.c b/usr/src/lib/libbc/libc/gen/common/_Q_sqrt.c
deleted file mode 100644
index 15860abe8b..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_sqrt.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-QUAD
-_Q_sqrt(QUAD x)
-{
- unpacked px,pz;
- QUAD z;
- _fp_current_exceptions = 0;
- _Q_get_rp_rd();
- _fp_unpack(&px, (int *)&x,fp_op_extended);
- _fp_sqrt(&px,&pz);
- _fp_pack(&pz, (int *)&z,fp_op_extended);
- _Q_set_exception(_fp_current_exceptions);
- return (z);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_stoq.c b/usr/src/lib/libbc/libc/gen/common/_Q_stoq.c
deleted file mode 100644
index c33f328414..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_stoq.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-QUAD
-_Q_stoq(SINGLE x)
-{
- unpacked px;
- QUAD q;
- _fp_current_exceptions = 0;
- _fp_unpack(&px, (int *)&x,fp_op_single);
- _fp_pack(&px, (int *)&q,fp_op_extended);
- _Q_set_exception(_fp_current_exceptions);
- return (q);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_sub.c b/usr/src/lib/libbc/libc/gen/common/_Q_sub.c
deleted file mode 100644
index 71497dbccb..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_sub.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-QUAD
-_Q_sub(QUAD x, QUAD y)
-{
- unpacked px,py,pz;
- QUAD z;
- _fp_current_exceptions = 0;
- _Q_get_rp_rd();
- _fp_unpack(&px,(int *)&x,fp_op_extended);
- _fp_unpack(&py,(int *)&y,fp_op_extended);
- _fp_sub(&px,&py,&pz);
- _fp_pack(&pz,(int *)&z,fp_op_extended);
- _Q_set_exception(_fp_current_exceptions);
- return (z);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Q_utoq.c b/usr/src/lib/libbc/libc/gen/common/_Q_utoq.c
deleted file mode 100644
index 7779ee4c4f..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Q_utoq.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-QUAD
-_Q_utoq(unsigned x)
-{
- unpacked px;
- QUAD q,c;
- int *pc =(int*)&c;
- pc[0] = 0x401e0000; pc[1]=pc[2]=pc[3]=0; /* pc = 2^31 */
- if((x&0x80000000)!=0) {
- x ^= 0x80000000;
- _fp_unpack(&px, (int *)&x,fp_op_integer);
- _fp_pack(&px, (int *)&q,fp_op_extended);
- q = _Q_add(q,c);
- } else {
- _fp_unpack(&px, (int *)&x,fp_op_integer);
- _fp_pack(&px, (int *)&q,fp_op_extended);
- }
- return (q);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Qfaddsub.c b/usr/src/lib/libbc/libc/gen/common/_Qfaddsub.c
deleted file mode 100644
index c9bc64f49e..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Qfaddsub.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-PRIVATE void
-true_add(px, py, pz)
- unpacked *px, *py, *pz;
-
-{
- unsigned c;
- unpacked *pt;
-
- if ((int) px->fpclass < (int) py->fpclass) { /* Reverse. */
- pt = py;
- py = px;
- px = pt;
- }
- /* Now class(x) >= class(y). */
- switch (px->fpclass) {
- case fp_quiet: /* NaN + x -> NaN */
- case fp_signaling: /* NaN + x -> NaN */
- case fp_infinity: /* Inf + x -> Inf */
- case fp_zero: /* 0 + 0 -> 0 */
- *pz = *px;
- return;
- default:
- if (py->fpclass == fp_zero) {
- *pz = *px;
- return;
- }
- }
- /* Now z is normal or subnormal. */
- /* Now y is normal or subnormal. */
- if (px->exponent < py->exponent) { /* Reverse. */
- pt = py;
- py = px;
- px = pt;
- }
- /* Now class(x) >= class(y). */
- pz->fpclass = px->fpclass;
- pz->sign = px->sign;
- pz->exponent = px->exponent;
- pz->rounded = pz->sticky = 0;
-
- if (px->exponent != py->exponent) { /* pre-alignment required */
- fpu_rightshift(py, pz->exponent - py->exponent);
- pz->rounded = py->rounded;
- pz->sticky = py->sticky;
- }
- c = 0;
- c = fpu_add3wc(&(pz->significand[3]),px->significand[3],
- py->significand[3],c);
- c = fpu_add3wc(&(pz->significand[2]),px->significand[2],
- py->significand[2],c);
- c = fpu_add3wc(&(pz->significand[1]),px->significand[1],
- py->significand[1],c);
- c = fpu_add3wc(&(pz->significand[0]),px->significand[0],
- py->significand[0],c);
-
- /* Handle carry out of msb. */
- if(pz->significand[0]>=0x20000) {
- fpu_rightshift(pz, 1); /* Carried out bit. */
- pz->exponent ++; /* Renormalize. */
- }
- return;
-}
-
-PRIVATE void
-true_sub(px, py, pz)
- unpacked *px, *py, *pz;
-
-{
- unsigned *z,g,s,r,c;
- int n;
- unpacked *pt;
-
- if ((int) px->fpclass < (int) py->fpclass) { /* Reverse. */
- pt = py;
- py = px;
- px = pt;
- }
- /* Now class(x) >= class(y). */
- *pz = *px; /* Tentative difference: x. */
- switch (pz->fpclass) {
- case fp_quiet: /* NaN - x -> NaN */
- case fp_signaling: /* NaN - x -> NaN */
- return;
- case fp_infinity: /* Inf - x -> Inf */
- if (py->fpclass == fp_infinity) {
- fpu_error_nan(pz); /* Inf - Inf -> NaN */
- pz->fpclass = fp_quiet;
- }
- return;
- case fp_zero: /* 0 - 0 -> 0 */
- pz->sign = (fp_direction == fp_negative);
- return;
- default:
- if (py->fpclass == fp_zero)
- return;
- }
-
- /* x and y are both normal or subnormal. */
-
- if (px->exponent < py->exponent) { /* Reverse. */
- pt = py;
- py = px;
- px = pt;
- }
- /* Now exp(x) >= exp(y). */
- pz->fpclass = px->fpclass;
- pz->sign = px->sign;
- pz->exponent = px->exponent;
- pz->rounded = 0;
- pz->sticky = 0;
- z = pz->significand;
-
- if (px->exponent == py->exponent) { /* no pre-alignment required */
- c = 0;
- c = fpu_sub3wc(&z[3],px->significand[3],py->significand[3],c);
- c = fpu_sub3wc(&z[2],px->significand[2],py->significand[2],c);
- c = fpu_sub3wc(&z[1],px->significand[1],py->significand[1],c);
- c = fpu_sub3wc(&z[0],px->significand[0],py->significand[0],c);
- if((z[0]|z[1]|z[2]|z[3])==0) { /* exact zero result */
- pz->sign = (fp_direction == fp_negative);
- pz->fpclass = fp_zero;
- return;
- }
- if(z[0]>=0x20000) { /* sign reversal occurred */
- pz->sign = py->sign;
- c = 0;
- c = fpu_neg2wc(&z[3],z[3],c);
- c = fpu_neg2wc(&z[2],z[2],c);
- c = fpu_neg2wc(&z[1],z[1],c);
- c = fpu_neg2wc(&z[0],z[0],c);
- }
- fpu_normalize(pz);
- return;
- } else { /* pre-alignment required */
- fpu_rightshift(py, pz->exponent - py->exponent - 1);
- r = py->rounded; /* rounded bit */
- s = py->sticky; /* sticky bit */
- fpu_rightshift(py, 1);
- g = py->rounded; /* guard bit */
- if(s!=0) r = (r==0);
- if((r|s)!=0) g = (g==0);/* guard and rounded bits of z */
- c = ((g|r|s)!=0);
- c = fpu_sub3wc(&z[3],px->significand[3],py->significand[3],c);
- c = fpu_sub3wc(&z[2],px->significand[2],py->significand[2],c);
- c = fpu_sub3wc(&z[1],px->significand[1],py->significand[1],c);
- c = fpu_sub3wc(&z[0],px->significand[0],py->significand[0],c);
-
- if(z[0]>=0x10000) { /* don't need post-shifted */
- pz->sticky = s|r;
- pz->rounded = g;
- } else { /* post-shifted left 1 bit */
- pz->sticky = s;
- pz->rounded = r;
- pz->significand[0] = (z[0]<<1)|((z[1]&0x80000000)>>31);
- pz->significand[1] = (z[1]<<1)|((z[2]&0x80000000)>>31);
- pz->significand[2] = (z[2]<<1)|((z[3]&0x80000000)>>31);
- pz->significand[3] = (z[3]<<1)|g;
- pz->exponent -= 1;
- if(z[0]<0x10000) fpu_normalize(pz);
- }
- return;
- }
-}
-
-void
-_fp_add(px, py, pz)
- unpacked *px, *py, *pz;
-
-{
- if (px->sign == py->sign)
- true_add(px, py, pz);
- else
- true_sub(px, py, pz);
-}
-
-void
-_fp_sub(px, py, pz)
- unpacked *px, *py, *pz;
-
-{
- py->sign = 1 - py->sign;
- if (px->sign == py->sign)
- true_add(px, py, pz);
- else
- true_sub(px, py, pz);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Qfcompare.c b/usr/src/lib/libbc/libc/gen/common/_Qfcompare.c
deleted file mode 100644
index 7b1a3136eb..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Qfcompare.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-enum fcc_type
-_fp_compare(px, py, strict)
- unpacked *px, *py;
- int strict; /* 0 if quiet NaN unexceptional, 1 if
- * exceptional */
-
-{
- enum fcc_type cc;
- int k,n;
-
- if ((px->fpclass == fp_quiet) || (py->fpclass == fp_quiet) ||
- (px->fpclass == fp_signaling) || (py->fpclass == fp_signaling)) {
- if (strict) /* NaN */
- fpu_set_exception(fp_invalid);
- cc = fcc_unordered;
- } else if ((px->fpclass == fp_zero) && (py->fpclass == fp_zero))
- cc = fcc_equal;
- /* both zeros */
- else if (px->sign < py->sign)
- cc = fcc_greater;
- else if (px->sign > py->sign)
- cc = fcc_less;
- else { /* signs the same, compute magnitude cc */
- if ((int) px->fpclass > (int) py->fpclass)
- cc = fcc_greater;
- else if ((int) px->fpclass < (int) py->fpclass)
- cc = fcc_less;
- else
- /* same classes */ if (px->fpclass == fp_infinity)
- cc = fcc_equal; /* same infinity */
- else if (px->exponent > py->exponent)
- cc = fcc_greater;
- else if (px->exponent < py->exponent)
- cc = fcc_less;
- else { /* equal exponents */
- n = fpu_cmpli(px->significand,py->significand,4);
- if(n>0) cc = fcc_greater;
- else if(n<0) cc = fcc_less;
- else cc = fcc_equal;
- }
- if (px->sign)
- switch (cc) { /* negative numbers */
- case fcc_less:
- cc = fcc_greater;
- break;
- case fcc_greater:
- cc = fcc_less;
- break;
- }
- }
- return (cc);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Qfdiv.c b/usr/src/lib/libbc/libc/gen/common/_Qfdiv.c
deleted file mode 100644
index 90b408686b..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Qfdiv.c
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-void
-_fp_div(px, py, pz)
- unpacked *px, *py, *pz;
-
-{
- unsigned r[4],*y,q,c;
- int n;
-
- *pz = *px;
- pz->sign = px->sign ^ py->sign;
-
- if ((py->fpclass == fp_quiet) || (py->fpclass == fp_signaling)) {
- *pz = *py;
- return;
- }
- switch (px->fpclass) {
- case fp_quiet:
- case fp_signaling:
- return;
- case fp_zero:
- case fp_infinity:
- if (px->fpclass == py->fpclass) { /* 0/0 or inf/inf */
- fpu_error_nan(pz);
- pz->fpclass = fp_quiet;
- }
- return;
- case fp_normal:
- switch (py->fpclass) {
- case fp_zero: /* number/0 */
- fpu_set_exception(fp_division);
- pz->fpclass = fp_infinity;
- return;
- case fp_infinity: /* number/inf */
- pz->fpclass = fp_zero;
- return;
- }
- }
-
- /* Now x and y are both normal or subnormal. */
-
- r[0] = px->significand[0];
- r[1] = px->significand[1];
- r[2] = px->significand[2];
- r[3] = px->significand[3];
- y = py->significand;
-
- if(fpu_cmpli(r,y,4)>=0)
- pz->exponent = px->exponent - py->exponent;
- else
- pz->exponent = px->exponent - py->exponent - 1;
-
- q=0;
- while(q<0x10000) { /* generate quo[0] */
- q<<=1;
- if(fpu_cmpli(r,y,4)>=0) {
- q += 1; /* if r>y do r-=y and q+=1 */
- c = 0;
- c = fpu_sub3wc(&r[3],r[3],y[3],c);
- c = fpu_sub3wc(&r[2],r[2],y[2],c);
- c = fpu_sub3wc(&r[1],r[1],y[1],c);
- c = fpu_sub3wc(&r[0],r[0],y[0],c);
- }
- r[0] = (r[0]<<1)|((r[1]&0x80000000)>>31); /* r << 1 */
- r[1] = (r[1]<<1)|((r[2]&0x80000000)>>31);
- r[2] = (r[2]<<1)|((r[3]&0x80000000)>>31);
- r[3] = (r[3]<<1);
- }
- pz->significand[0]=q;
- q=0; /* generate quo[1] */
- n = 32;
- while(n--) {
- q<<=1;
- if(fpu_cmpli(r,y,4)>=0) {
- q += 1; /* if r>y do r-=y and q+=1 */
- c = 0;
- c = fpu_sub3wc(&r[3],r[3],y[3],c);
- c = fpu_sub3wc(&r[2],r[2],y[2],c);
- c = fpu_sub3wc(&r[1],r[1],y[1],c);
- c = fpu_sub3wc(&r[0],r[0],y[0],c);
- }
- r[0] = (r[0]<<1)|((r[1]&0x80000000)>>31); /* r << 1 */
- r[1] = (r[1]<<1)|((r[2]&0x80000000)>>31);
- r[2] = (r[2]<<1)|((r[3]&0x80000000)>>31);
- r[3] = (r[3]<<1);
- }
- pz->significand[1] = q;
- q=0; /* generate quo[2] */
- n = 32;
- while(n--) {
- q<<=1;
- if(fpu_cmpli(r,y,4)>=0) {
- q += 1; /* if r>y do r-=y and q+=1 */
- c = 0;
- c = fpu_sub3wc(&r[3],r[3],y[3],c);
- c = fpu_sub3wc(&r[2],r[2],y[2],c);
- c = fpu_sub3wc(&r[1],r[1],y[1],c);
- c = fpu_sub3wc(&r[0],r[0],y[0],c);
- }
- r[0] = (r[0]<<1)|((r[1]&0x80000000)>>31); /* r << 1 */
- r[1] = (r[1]<<1)|((r[2]&0x80000000)>>31);
- r[2] = (r[2]<<1)|((r[3]&0x80000000)>>31);
- r[3] = (r[3]<<1);
- }
- pz->significand[2] = q;
- q=0; /* generate quo[3] */
- n = 32;
- while(n--) {
- q<<=1;
- if(fpu_cmpli(r,y,4)>=0) {
- q += 1; /* if r>y do r-=y and q+=1 */
- c = 0;
- c = fpu_sub3wc(&r[3],r[3],y[3],c);
- c = fpu_sub3wc(&r[2],r[2],y[2],c);
- c = fpu_sub3wc(&r[1],r[1],y[1],c);
- c = fpu_sub3wc(&r[0],r[0],y[0],c);
- }
- r[0] = (r[0]<<1)|((r[1]&0x80000000)>>31); /* r << 1 */
- r[1] = (r[1]<<1)|((r[2]&0x80000000)>>31);
- r[2] = (r[2]<<1)|((r[3]&0x80000000)>>31);
- r[3] = (r[3]<<1);
- }
- pz->significand[3] = q;
- if((r[0]|r[1]|r[2]|r[3])==0) pz->sticky = pz->rounded = 0;
- else {
- pz->sticky = 1; /* half way case won't occur */
- if(fpu_cmpli(r,y,4)>=0) pz->rounded = 1;
- }
-}
-
-void
-_fp_sqrt(px, pz)
- unpacked *px, *pz;
-
-{ /* *pz gets sqrt(*px) */
-
- unsigned *x,r,c,q,t[4],s[4];
- *pz = *px;
- switch (px->fpclass) {
- case fp_quiet:
- case fp_signaling:
- case fp_zero:
- return;
- case fp_infinity:
- if (px->sign == 1) { /* sqrt(-inf) */
- fpu_error_nan(pz);
- pz->fpclass = fp_quiet;
- }
- return;
- case fp_normal:
- if (px->sign == 1) { /* sqrt(-norm) */
- fpu_error_nan(pz);
- pz->fpclass = fp_quiet;
- return;
- }
- }
-
- /* Now x is normal. */
- x = px->significand;
- if (px->exponent & 1) { /* sqrt(1.f * 2**odd) = sqrt (2.+2f) *
- * 2**(odd-1)/2 */
- pz->exponent = (px->exponent - 1) / 2;
- x[0] = (x[0]<<1)|((x[1]&0x80000000)>>31); /* x<<1 */
- x[1] = (x[1]<<1)|((x[2]&0x80000000)>>31);
- x[2] = (x[2]<<1)|((x[3]&0x80000000)>>31);
- x[3] = (x[3]<<1);
- } else { /* sqrt(1.f * 2**even) = sqrt (1.f) *
- * 2**(even)/2 */
- pz->exponent = px->exponent / 2;
- }
- s[0]=s[1]=s[2]=s[3]=t[0]=t[1]=t[2]=t[3]=0;
- q = 0;
- r = 0x00010000;
- while(r!=0) { /* compute sqrt[0] */
- t[0] = s[0]+r;
- if(t[0]<=x[0]) {
- s[0] = t[0]+r;
- x[0] -= t[0];
- q += r;
- }
- x[0] = (x[0]<<1)|((x[1]&0x80000000)>>31); /* x<<1 */
- x[1] = (x[1]<<1)|((x[2]&0x80000000)>>31);
- x[2] = (x[2]<<1)|((x[3]&0x80000000)>>31);
- x[3] = (x[3]<<1);
- r>>=1;
- }
- pz->significand[0] = q;
- q = 0;
- r = 0x80000000;
- while(r!=0) { /* compute sqrt[1] */
- t[1] = s[1]+r; /* no carry */
- t[0] = s[0];
- if(fpu_cmpli(t,x,2)<=0) {
- c = 0;
- c = fpu_add3wc(&s[1],t[1],r,c);
- c = fpu_add3wc(&s[0],t[0],0,c);
- c = 0;
- c = fpu_sub3wc(&x[1],x[1],t[1],c);
- c = fpu_sub3wc(&x[0],x[0],t[0],c);
- q += r;
- }
- x[0] = (x[0]<<1)|((x[1]&0x80000000)>>31); /* x<<1 */
- x[1] = (x[1]<<1)|((x[2]&0x80000000)>>31);
- x[2] = (x[2]<<1)|((x[3]&0x80000000)>>31);
- x[3] = (x[3]<<1);
- r>>=1;
- }
- pz->significand[1] = q;
- q = 0;
- r = 0x80000000;
- while(r!=0) { /* compute sqrt[2] */
- t[2] = s[2]+r; /* no carry */
- t[1] = s[1];
- t[0] = s[0];
- if(fpu_cmpli(t,x,3)<=0) {
- c = 0;
- c = fpu_add3wc(&s[2],t[2],r,c);
- c = fpu_add3wc(&s[1],t[1],0,c);
- c = fpu_add3wc(&s[0],t[0],0,c);
- c = 0;
- c = fpu_sub3wc(&x[2],x[2],t[2],c);
- c = fpu_sub3wc(&x[1],x[1],t[1],c);
- c = fpu_sub3wc(&x[0],x[0],t[0],c);
- q += r;
- }
- x[0] = (x[0]<<1)|((x[1]&0x80000000)>>31); /* x<<1 */
- x[1] = (x[1]<<1)|((x[2]&0x80000000)>>31);
- x[2] = (x[2]<<1)|((x[3]&0x80000000)>>31);
- x[3] = (x[3]<<1);
- r>>=1;
- }
- pz->significand[2] = q;
- q = 0;
- r = 0x80000000;
- while(r!=0) { /* compute sqrt[3] */
- t[3] = s[3]+r; /* no carry */
- t[2] = s[2];
- t[1] = s[1];
- t[0] = s[0];
- if(fpu_cmpli(t,x,4)<=0) {
- c = 0;
- c = fpu_add3wc(&s[3],t[3],r,c);
- c = fpu_add3wc(&s[2],t[2],0,c);
- c = fpu_add3wc(&s[1],t[1],0,c);
- c = fpu_add3wc(&s[0],t[0],0,c);
- c = 0;
- c = fpu_sub3wc(&x[3],x[3],t[3],c);
- c = fpu_sub3wc(&x[2],x[2],t[2],c);
- c = fpu_sub3wc(&x[1],x[1],t[1],c);
- c = fpu_sub3wc(&x[0],x[0],t[0],c);
- q += r;
- }
- x[0] = (x[0]<<1)|((x[1]&0x80000000)>>31); /* x<<1 */
- x[1] = (x[1]<<1)|((x[2]&0x80000000)>>31);
- x[2] = (x[2]<<1)|((x[3]&0x80000000)>>31);
- x[3] = (x[3]<<1);
- r>>=1;
- }
- pz->significand[3] = q;
- if((x[0]|x[1]|x[2]|x[3])==0) {
- pz->sticky = pz->rounded = 0;
- } else {
- pz->sticky = 1;
- if(fpu_cmpli(s,x,4)<0) pz->rounded=1; else pz->rounded = 0;
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Qfmul.c b/usr/src/lib/libbc/libc/gen/common/_Qfmul.c
deleted file mode 100644
index bd55bedd7c..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Qfmul.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-
-void
-_fp_mul(px, py, pz)
- unpacked *px, *py, *pz;
-
-{
- unpacked *pt;
- unsigned acc[4]; /* Product accumulator. */
- unsigned i,j,y,*x,s,r,c;
-
- if ((int) px->fpclass < (int) py->fpclass) {
- pt = px;
- px = py;
- py = pt;
- }
- /* Now class(x) >= class(y). */
-
- *pz = *px;
- pz->sign = px->sign ^ py->sign;
-
- switch (px->fpclass) {
- case fp_quiet:
- case fp_signaling:
- case fp_zero:
- return;
- case fp_infinity:
- if (py->fpclass == fp_zero) {
- fpu_error_nan(pz);
- pz->fpclass = fp_quiet;
- }
- return;
- case fp_normal:
- if (py->fpclass == fp_zero) {
- pz->fpclass = fp_zero;
- return;
- }
- }
-
- /* Now x and y are both normal or subnormal. */
-
- x = px->significand; /* save typing */
-
- s=r=acc[0]=acc[1]=acc[2]=acc[3]=0; /* intialize acc to zero */
-
- y = py->significand[3]; /* py->significand[3] * x */
- if(y!=0) {
- j=1;
- do {
- s |= r; /* shift acc right one bit */
- r = acc[3]&1;
- acc[3] = ((acc[2]&1)<<31)|(acc[3]>>1);
- acc[2] = ((acc[1]&1)<<31)|(acc[2]>>1);
- acc[1] = ((acc[0]&1)<<31)|(acc[1]>>1);
- acc[0] = (acc[0]>>1);
- if(j&y) { /* bit i of y != 0, add x to acc */
- c = 0;
- c = fpu_add3wc(&acc[3],acc[3],x[3],c);
- c = fpu_add3wc(&acc[2],acc[2],x[2],c);
- c = fpu_add3wc(&acc[1],acc[1],x[1],c);
- c = fpu_add3wc(&acc[0],acc[0],x[0],c);
- }
- j += j;
- } while (j!=0);
- }
-
- y = py->significand[2]; /* py->significand[2] * x */
- if(y!=0) {
- j=1;
- do {
- s |= r; /* shift acc right one bit */
- r = acc[3]&1;
- acc[3] = ((acc[2]&1)<<31)|(acc[3]>>1);
- acc[2] = ((acc[1]&1)<<31)|(acc[2]>>1);
- acc[1] = ((acc[0]&1)<<31)|(acc[1]>>1);
- acc[0] = (acc[0]>>1);
- if(j&y) { /* bit i of y != 0, add x to acc */
- c = 0;
- c = fpu_add3wc(&acc[3],acc[3],x[3],c);
- c = fpu_add3wc(&acc[2],acc[2],x[2],c);
- c = fpu_add3wc(&acc[1],acc[1],x[1],c);
- c = fpu_add3wc(&acc[0],acc[0],x[0],c);
- }
- j += j;
- } while (j!=0);
- } else {
- s |= r|(acc[3]&0x7fffffff);
- r = (acc[3]&0x80000000)>>31;
- acc[3]=acc[2];acc[2]=acc[1];acc[1]=acc[0];acc[0]=0;
- }
-
- y = py->significand[1]; /* py->significand[1] * x */
- if(y!=0) {
- j=1;
- do {
- s |= r; /* shift acc right one bit */
- r = acc[3]&1;
- acc[3] = ((acc[2]&1)<<31)|(acc[3]>>1);
- acc[2] = ((acc[1]&1)<<31)|(acc[2]>>1);
- acc[1] = ((acc[0]&1)<<31)|(acc[1]>>1);
- acc[0] = (acc[0]>>1);
- if(j&y) { /* bit i of y != 0, add x to acc */
- c = 0;
- c = fpu_add3wc(&acc[3],acc[3],x[3],c);
- c = fpu_add3wc(&acc[2],acc[2],x[2],c);
- c = fpu_add3wc(&acc[1],acc[1],x[1],c);
- c = fpu_add3wc(&acc[0],acc[0],x[0],c);
- }
- j += j;
- } while (j!=0);
- } else {
- s |= r|(acc[3]&0x7fffffff);
- r = (acc[3]&0x80000000)>>31;
- acc[3]=acc[2];acc[2]=acc[1];acc[1]=acc[0];acc[0]=0;
- }
-
- /* py->significand[0] * x */
- y = py->significand[0]; /* y is of form 0x0001???? */
- j=1;
- do {
- s |= r; /* shift acc right one bit */
- r = acc[3]&1;
- acc[3] = ((acc[2]&1)<<31)|(acc[3]>>1);
- acc[2] = ((acc[1]&1)<<31)|(acc[2]>>1);
- acc[1] = ((acc[0]&1)<<31)|(acc[1]>>1);
- acc[0] = (acc[0]>>1);
- if(j&y) { /* bit i of y != 0, add x to acc */
- c = 0;
- c = fpu_add3wc(&acc[3],acc[3],x[3],c);
- c = fpu_add3wc(&acc[2],acc[2],x[2],c);
- c = fpu_add3wc(&acc[1],acc[1],x[1],c);
- c = fpu_add3wc(&acc[0],acc[0],x[0],c);
- }
- j += j;
- } while (j<=y);
-
- if(acc[0]>=0x20000) { /* right shift one bit to normalize */
- pz->exponent = px->exponent + py->exponent + 1;
- pz->sticky = s|r;
- pz->rounded = acc[3]&1;
- pz->significand[3]=((acc[2]&1)<<31)|(acc[3]>>1);
- pz->significand[2]=((acc[1]&1)<<31)|(acc[2]>>1);
- pz->significand[1]=((acc[0]&1)<<31)|(acc[1]>>1);
- pz->significand[0]=(acc[0]>>1);
- } else {
- pz->exponent = px->exponent + py->exponent;
- pz->sticky = s;
- pz->rounded = r;
- pz->significand[3]=acc[3];
- pz->significand[2]=acc[2];
- pz->significand[1]=acc[1];
- pz->significand[0]=acc[0];
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Qfpack.c b/usr/src/lib/libbc/libc/gen/common/_Qfpack.c
deleted file mode 100644
index f7462d9fc2..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Qfpack.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-/* Pack procedures for Sparc FPU simulator. */
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-PRIVATE int
-overflow_to_infinity(sign)
- int sign;
-
-/* Returns 1 if overflow should go to infinity, 0 if to max finite. */
-
-{
- int inf;
-
- switch (fp_direction) {
- case fp_nearest:
- inf = 1;
- break;
- case fp_tozero:
- inf = 0;
- break;
- case fp_positive:
- inf = !sign;
- break;
- case fp_negative:
- inf = sign;
- break;
- }
- return (inf);
-}
-
-PRIVATE void
-round(pu)
- unpacked *pu;
-
-/* Round according to current rounding mode. */
-
-{
- int increment; /* boolean to indicate round up */
- int sr;
- sr = pu->sticky|pu->rounded;
-
- if (sr == 0)
- return;
- fpu_set_exception(fp_inexact);
- switch (fp_direction) {
- case fp_nearest:
- increment = pu->rounded;
- break;
- case fp_tozero:
- increment = 0;
- break;
- case fp_positive:
- increment = (pu->sign == 0) & (sr != 0);
- break;
- case fp_negative:
- increment = (pu->sign != 0) & (sr != 0);
- break;
- }
- if (increment) {
- pu->significand[3]++;
- if (pu->significand[3] == 0) {
- pu->significand[2]++;
- if (pu->significand[2] == 0) {
- pu->significand[1]++;
- if (pu->significand[1] == 0) {
- pu->significand[0]++; /* rounding carried out */
- if( pu->significand[0] == 0x20000) {
- pu->exponent++;
- pu->significand[0] = 0x10000;
- }
- }
- }
- }
- }
- if ((fp_direction == fp_nearest) &&
- (pu->sticky == 0) && increment!=0) { /* ambiguous case */
- pu->significand[3] &= 0xfffffffe; /* force round to even */
- }
-}
-
-PRIVATE void
-packinteger(pu, px)
- unpacked *pu; /* unpacked result */
- int *px; /* packed integer */
-{
- switch (pu->fpclass) {
- case fp_zero:
- *px = 0;
- break;
- case fp_normal:
- if (pu->exponent >= 32)
- goto overflow;
- fpu_rightshift(pu, 112 - pu->exponent);
- round(pu);
- if (pu->significand[3] >= 0x80000000)
- if ((pu->sign == 0)||(pu->significand[3] > 0x80000000))
- goto overflow;
- *px = pu->significand[3];
- if (pu->sign)
- *px = -*px;
- break;
- case fp_infinity:
- case fp_quiet:
- case fp_signaling:
-overflow:
- if (pu->sign)
- *px = 0x80000000;
- else
- *px = 0x7fffffff;
- _fp_current_exceptions &= ~(1 << (int) fp_inexact);
- fpu_set_exception(fp_invalid);
- break;
- }
-}
-
-PRIVATE void
-packsingle(pu, px)
- unpacked *pu; /* unpacked result */
- single_type *px; /* packed single */
-{
- px->sign = pu->sign;
- switch (pu->fpclass) {
- case fp_zero:
- px->exponent = 0;
- px->significand = 0;
- break;
- case fp_infinity:
-infinity:
- px->exponent = 0xff;
- px->significand = 0;
- break;
- case fp_quiet:
- case fp_signaling:
- fpu_rightshift(pu, 113-24);
- px->exponent = 0xff;
- px->significand = 0x400000|(0x3fffff&pu->significand[3]);
- break;
- case fp_normal:
- fpu_rightshift(pu, 113-24);
- pu->exponent += SINGLE_BIAS;
- if (pu->exponent <= 0) {
- px->exponent = 0;
- fpu_rightshift(pu, 1 - pu->exponent);
- round(pu);
- if (pu->significand[3] == 0x800000) { /* rounded
- * back up to
- * normal */
- px->exponent = 1;
- px->significand = 0;
- return;
- }
- if (_fp_current_exceptions & (1 << fp_inexact))
- fpu_set_exception(fp_underflow);
- px->significand = 0x7fffff & pu->significand[3];
- return;
- }
- round(pu);
- if (pu->significand[3] == 0x1000000) { /* rounding overflow */
- pu->significand[3] = 0x800000;
- pu->exponent += 1;
- }
- if (pu->exponent >= 0xff) {
- fpu_set_exception(fp_overflow);
- fpu_set_exception(fp_inexact);
- if (overflow_to_infinity(pu->sign))
- goto infinity;
- px->exponent = 0xfe;
- px->significand = 0x7fffff;
- return;
- }
- px->exponent = pu->exponent;
- px->significand = 0x7fffff & pu->significand[3];
- }
-}
-
-PRIVATE void
-packdouble(pu, px, py)
- unpacked *pu; /* unpacked result */
- double_type *px; /* packed double */
- unsigned *py;
-{
- px->sign = pu->sign;
- switch (pu->fpclass) {
- case fp_zero:
- px->exponent = 0;
- px->significand = 0;
- *py = 0;
- break;
- case fp_infinity:
-infinity:
- px->exponent = 0x7ff;
- px->significand = 0;
- *py = 0;
- break;
- case fp_quiet:
- case fp_signaling:
- fpu_rightshift(pu, 113-53);
- px->exponent = 0x7ff;
- px->significand = 0x80000 | (0x7ffff & pu->significand[2]);
- *py = pu->significand[3];
- break;
- case fp_normal:
- fpu_rightshift(pu, 113-53);
- pu->exponent += DOUBLE_BIAS;
- if (pu->exponent <= 0) { /* underflow */
- px->exponent = 0;
- fpu_rightshift(pu, 1 - pu->exponent);
- round(pu);
- if (pu->significand[2] == 0x100000) { /* rounded
- * back up to
- * normal */
- px->exponent = 1;
- px->significand = 0;
- *py = 0;
- return;
- }
- if (_fp_current_exceptions & (1 << fp_inexact))
- fpu_set_exception(fp_underflow);
- px->exponent = 0;
- px->significand = 0xfffff & pu->significand[2];
- *py = pu->significand[3];
- return;
- }
- round(pu);
- if (pu->significand[2] == 0x200000) { /* rounding overflow */
- pu->significand[2] = 0x100000;
- pu->exponent += 1;
- }
- if (pu->exponent >= 0x7ff) { /* overflow */
- fpu_set_exception(fp_overflow);
- fpu_set_exception(fp_inexact);
- if (overflow_to_infinity(pu->sign))
- goto infinity;
- px->exponent = 0x7fe;
- px->significand = 0xfffff;
- *py = 0xffffffff;
- return;
- }
- px->exponent = pu->exponent;
- px->significand = 0xfffff & pu->significand[2];
- *py = pu->significand[3];
- break;
- }
-}
-
-PRIVATE void
-packextended(pu, px, py, pz, pw)
- unpacked *pu; /* unpacked result */
- extended_type *px; /* packed extended */
- unsigned *py, *pz, *pw;
-{
- px->sign = pu->sign;
- switch (pu->fpclass) {
- case fp_zero:
- px->exponent = 0;
- px->significand = 0;
- *pz = 0;
- *py = 0;
- *pw = 0;
- break;
- case fp_infinity:
-infinity:
- px->exponent = 0x7fff;
- px->significand = 0;
- *pz = 0;
- *py = 0;
- *pw = 0;
- break;
- case fp_quiet:
- case fp_signaling:
- px->exponent = 0x7fff;
- px->significand = 0x8000 | pu->significand[0]; /* Insure quiet
- * nan. */
- *py = pu->significand[1];
- *pz = pu->significand[2];
- *pw = pu->significand[3];
- break;
- case fp_normal:
- pu->exponent += EXTENDED_BIAS;
- if (pu->exponent <= 0) { /* underflow */
- fpu_rightshift(pu, 1-pu->exponent);
- round(pu);
- if (pu->significand[0] < 0x00010000) { /* not rounded
- * back up
- * to normal */
- if (_fp_current_exceptions & (1 << fp_inexact))
- fpu_set_exception(fp_underflow);
- px->exponent = 0;
- } else
- px->exponent = 1;
- px->significand = pu->significand[0];
- *py = pu->significand[1];
- *pz = pu->significand[2];
- *pw = pu->significand[3];
- return;
- }
- round(pu); /* rounding overflow handled in round() */
- if (pu->exponent >= 0x7fff) { /* overflow */
- fpu_set_exception(fp_overflow);
- fpu_set_exception(fp_inexact);
- if (overflow_to_infinity(pu->sign))
- goto infinity;
- px->exponent = 0x7ffe; /* overflow to max norm */
- px->significand = 0xffff;
- *py = 0xffffffff;
- *pz = 0xffffffff;
- *pw = 0xffffffff;
- return;
- }
- px->exponent = pu->exponent;
- px->significand = pu->significand[0];
- *py = pu->significand[1];
- *pz = pu->significand[2];
- *pw = pu->significand[3];
- break;
- }
-}
-
-void
-_fp_pack(pu, n, type)
- unpacked *pu; /* unpacked operand */
- int *n; /* output result's address */
- enum fp_op_type type; /* type of datum */
-
-{
- switch (type) {
- case fp_op_integer:
- {
- packinteger(pu, n);
- break;
- }
- case fp_op_single:
- {
- single_type x;
- packsingle(pu, &x);
- n[0] = *(int*)&x;
- break;
- }
- case fp_op_double:
- {
- double_type x;
- double t=1.0;
- int i0,i1;
- if((*(int*)&t)!=0) {i0=0;i1=1;} else {i0=1;i1=0;}
- packdouble(pu, &x,&n[i1]);
- n[i0] = *(int*)&x;
- break;
- }
- case fp_op_extended:
- {
- extended_type x;
- unsigned y, z, w;
- unpacked u;
- int k;
- switch (fp_precision) { /* Implement extended
- * rounding precision mode. */
- case fp_single:
- {
- single_type tx;
- packsingle(pu, &tx);
- pu = &u;
- unpacksingle(pu, tx);
- break;
- }
- case fp_double:
- {
- double_type tx;
- unsigned ty;
- packdouble(pu, &tx, &ty);
- pu = &u;
- unpackdouble(pu, tx, ty);
- break;
- }
- case fp_precision_3: /* rounded to 64 bits */
- {
- k = pu->exponent+ EXTENDED_BIAS;
- if(k>=0) k = 113-64;
- else k = 113-64-k;
- fpu_rightshift(pu,113-64);
- round(pu);
- pu->sticky=pu->rounded=0;
- pu->exponent += k;
- fpu_normalize(pu);
- break;
- }
- }
- {
- int i0,i1,i2,i3;
- double t = 1.0;
- if((*(int*)&t)!=0) {i0=0;i1=1;i2=2;i3=3;}
- else {i0=3;i1=2;i2=1;i3=0;}
- packextended(pu, &x, &n[i1], &n[i2], &n[i3]);
- n[i0] = *(int*)&x;
- }
-
- break;
- }
- }
-}
-
diff --git a/usr/src/lib/libbc/libc/gen/common/_Qfunpack.c b/usr/src/lib/libbc/libc/gen/common/_Qfunpack.c
deleted file mode 100644
index 1e744d94ef..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Qfunpack.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-/* Unpack procedures for Sparc FPU simulator. */
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-PRIVATE void
-unpackinteger(pu, x)
- unpacked *pu; /* unpacked result */
- int x; /* packed integer */
-{
- unsigned ux;
- pu->sticky = pu->rounded = 0;
- if (x == 0) {
- pu->sign = 0;
- pu->fpclass = fp_zero;
- } else {
- (*pu).sign = x < 0;
- (*pu).fpclass = fp_normal;
- (*pu).exponent = INTEGER_BIAS;
- if(x<0) ux = -x; else ux = x;
- (*pu).significand[0] = ux>>15;
- (*pu).significand[1] = (ux&0x7fff)<<17;
- (*pu).significand[2] = 0;
- (*pu).significand[3] = 0;
- fpu_normalize(pu);
- }
-}
-
-void
-unpacksingle(pu, x)
- unpacked *pu; /* unpacked result */
- single_type x; /* packed single */
-{
- unsigned u;
- pu->sticky = pu->rounded = 0;
- u = x.significand;
- (*pu).sign = x.sign;
- pu->significand[1] = 0;
- pu->significand[2] = 0;
- pu->significand[3] = 0;
- if (x.exponent == 0) { /* zero or sub */
- if (x.significand == 0) { /* zero */
- pu->fpclass = fp_zero;
- return;
- } else { /* subnormal */
- pu->fpclass = fp_normal;
- pu->exponent = -SINGLE_BIAS-6;
- pu->significand[0]=u;
- fpu_normalize(pu);
- return;
- }
- } else if (x.exponent == 0xff) { /* inf or nan */
- if (x.significand == 0) { /* inf */
- pu->fpclass = fp_infinity;
- return;
- } else { /* nan */
- if ((u & 0x400000) != 0) { /* quiet */
- pu->fpclass = fp_quiet;
- } else {/* signaling */
- pu->fpclass = fp_signaling;
- fpu_set_exception(fp_invalid);
- }
- pu->significand[0] = 0x18000 | (u >> 7);
- (*pu).significand[1]=((u&0x7f)<<25);
- return;
- }
- }
- (*pu).exponent = x.exponent - SINGLE_BIAS;
- (*pu).fpclass = fp_normal;
- (*pu).significand[0]=0x10000|(u>>7);
- (*pu).significand[1]=((u&0x7f)<<25);
-}
-
-void
-unpackdouble(pu, x, y)
- unpacked *pu; /* unpacked result */
- double_type x; /* packed double */
- unsigned y;
-{
- unsigned u;
- pu->sticky = pu->rounded = 0;
- u = x.significand;
- (*pu).sign = x.sign;
- pu->significand[1] = y;
- pu->significand[2] = 0;
- pu->significand[3] = 0;
- if (x.exponent == 0) { /* zero or sub */
- if ((x.significand == 0) && (y == 0)) { /* zero */
- pu->fpclass = fp_zero;
- return;
- } else { /* subnormal */
- pu->fpclass = fp_normal;
- pu->exponent = -DOUBLE_BIAS-3;
- pu->significand[0] = u;
- fpu_normalize(pu);
- return;
- }
- } else if (x.exponent == 0x7ff) { /* inf or nan */
- if ((u|y) == 0) { /* inf */
- pu->fpclass = fp_infinity;
- return;
- } else { /* nan */
- if ((u & 0x80000) != 0) { /* quiet */
- pu->fpclass = fp_quiet;
- } else {/* signaling */
- pu->fpclass = fp_signaling;
- fpu_set_exception(fp_invalid);
- }
- pu->significand[0] = 0x18000 | (u >> 4);
- (*pu).significand[1]=((u&0xf)<<28)|(y>>4);
- (*pu).significand[2]=((y&0xf)<<28);
- return;
- }
- }
- (*pu).exponent = x.exponent - DOUBLE_BIAS;
- (*pu).fpclass = fp_normal;
- (*pu).significand[0]=0x10000|(u>>4);
- (*pu).significand[1]=((u&0xf)<<28)|(y>>4);
- (*pu).significand[2]=((y&0xf)<<28);
-}
-
-PRIVATE void
-unpackextended(pu, x, y, z, w)
- unpacked *pu; /* unpacked result */
- extended_type x; /* packed extended */
- unsigned y, z, w;
-{
- unsigned u;
- pu->sticky = pu->rounded = 0;
- u = x.significand;
- (*pu).sign = x.sign;
- (*pu).fpclass = fp_normal;
- (*pu).exponent = x.exponent - EXTENDED_BIAS;
- (*pu).significand[0] = (x.exponent==0)? u:0x10000|u;
- (*pu).significand[1] = y;
- (*pu).significand[2] = z;
- (*pu).significand[3] = w;
- if (x.exponent < 0x7fff) { /* zero, normal, or subnormal */
- if ((z|y|w|pu->significand[0]) == 0) { /* zero */
- pu->fpclass = fp_zero;
- return;
- } else { /* normal or subnormal */
- if(x.exponent==0) {
- fpu_normalize(pu);
- pu->exponent += 1;
- }
- return;
- }
- } else { /* inf or nan */
- if ((u|z|y|w) == 0) { /* inf */
- pu->fpclass = fp_infinity;
- return;
- } else { /* nan */
- if ((u & 0x00008000) != 0) { /* quiet */
- pu->fpclass = fp_quiet;
- } else {/* signaling */
- pu->fpclass = fp_signaling;
- fpu_set_exception(fp_invalid);
- }
- pu->significand[0] |= 0x8000; /* make quiet */
- return;
- }
-}
-}
-
-void
-_fp_unpack(pu, n, dtype)
- unpacked *pu; /* unpacked result */
- int *n; /* input array */
- enum fp_op_type dtype; /* type of datum */
-
-{
- switch ((int) dtype) {
- case fp_op_integer:
- unpackinteger(pu, n[0]);
- break;
- case fp_op_single:
- {
- single_type x;
- *(int*)&x = n[0];
- unpacksingle(pu, x);
- break;
- }
- case fp_op_double:
- {
- double_type x;
- double t=1.0; int i0,i1;
- if((*(int*)&t)!=0) {i0=0;i1=1;} else {i0=1;i1=0;}
- *(int*)&x = n[i0];
- unpackdouble(pu, x, n[i1]);
- break;
- }
- case fp_op_extended:
- {
- extended_type x;
- double t=1.0; int i0,i1,i2,i3;
- if((*(int*)&t)!=0) {i0=0;i1=1;i2=2;i3=3;}
- else {i0=3;i1=2;i2=1;i3=0;}
- *(int*)&x = n[i0];
- unpackextended(pu, x, n[i1], n[i2], n[i3]);
- break;
- }
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_Qfutility.c b/usr/src/lib/libbc/libc/gen/common/_Qfutility.c
deleted file mode 100644
index ea8503bdf2..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Qfutility.c
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-/* Utility functions for Sparc FPU simulator. */
-
-#include "_Qquad.h"
-#include "_Qglobals.h"
-
-
-void
-fpu_normalize(pu)
- unpacked *pu;
-
-/* Normalize a number. Does not affect zeros, infs, or NaNs. */
-/* The number will be normalized to 113 bit extended:
- * 0x0001####,0x########,0x########,0x########.
- */
-
-{
- unsigned u,u0,u1,u2,u3,m,n,k;
- u0 = pu->significand[0];
- u1 = pu->significand[1];
- u2 = pu->significand[2];
- u3 = pu->significand[3];
- if ((*pu).fpclass == fp_normal) {
- if ((u0|u1|u2|u3)==0) {
- (*pu).fpclass = fp_zero;
- return;
- }
- while (u0 == 0) {
- u0 = u1; u1=u2; u2=u3; u3=0;
- (*pu).exponent = (*pu).exponent - 32;
- }
- if (u0>=0x20000) { /* u3 should be zero */
- n=1; u = u0>>1;
- while(u>=0x20000) {u >>= 1; n += 1;}
- m = (1<<n)-1;
- k = 32-n;
- (*pu).exponent += n;
- u3 = ((u2&m)<<k)|(u3>>n);
- u2 = ((u1&m)<<k)|(u2>>n);
- u1 = ((u0&m)<<k)|(u1>>n);
- u0 = u;
- } else if(u0<0x10000) {
- n=1; u = u0<<1;
- while(u<0x10000) {u <<= 1; n += 1;}
- k = 32-n;
- m = -(1<<k);
- (*pu).exponent -= n;
- u0 = (u0<<n)|((u1&m)>>k);
- u1 = (u1<<n)|((u2&m)>>k);
- u2 = (u2<<n)|((u3&m)>>k);
- u3 = (u3<<n);
- }
- pu->significand[0] = u0;
- pu->significand[1] = u1;
- pu->significand[2] = u2;
- pu->significand[3] = u3;
- }
-}
-
-void
-fpu_rightshift(pu, n)
- unpacked *pu;
- int n;
-
-/* Right shift significand sticky by n bits. */
-
-{
- unsigned m,k,j,u0,u1,u2,u3;
- if (n > 113) { /* drastic */
- if (((*pu).significand[0] | (*pu).significand[1]
- | (*pu).significand[2] | (*pu).significand[3]) == 0){
- /* really zero */
- pu->fpclass = fp_zero;
- return;
- } else {
- pu->rounded = 0;
- pu->sticky = 1;
- pu->significand[3] = 0;
- pu->significand[2] = 0;
- pu->significand[1] = 0;
- pu->significand[0] = 0;
- return;
- }
- }
- while (n >= 32) { /* big shift */
- pu->sticky |= pu->rounded | (pu->significand[3]&0x7fffffff);
- pu->rounded = (*pu).significand[3]>>31;
- (*pu).significand[3] = (*pu).significand[2];
- (*pu).significand[2] = (*pu).significand[1];
- (*pu).significand[1] = (*pu).significand[0];
- (*pu).significand[0] = 0;
- n -= 32;
- }
- if (n > 0) { /* small shift */
- u0 = pu->significand[0];
- u1 = pu->significand[1];
- u2 = pu->significand[2];
- u3 = pu->significand[3];
- m = (1<<n)-1;
- k = 32 - n;
- j = (1<<(n-1))-1;
- pu->sticky |= pu->rounded | (u3&j);
- pu->rounded = (u3&m)>>(n-1);
- pu->significand[3] = ((u2&m)<<k)|(u3>>n);
- pu->significand[2] = ((u1&m)<<k)|(u2>>n);
- pu->significand[1] = ((u0&m)<<k)|(u1>>n);
- pu->significand[0] = u0>>n;
- }
-}
-
-void
-fpu_set_exception(ex)
- enum fp_exception_type ex;
-
-/* Set the exception bit in the current exception register. */
-
-{
- _fp_current_exceptions |= 1 << (int) ex;
-}
-
-void
-fpu_error_nan(pu)
- unpacked *pu;
-
-{ /* Set invalid exception and error nan in *pu */
-
- fpu_set_exception(fp_invalid);
- pu->significand[0] = 0x7fffffff|((pu->sign)<<31);
- pu->significand[1] = 0xffffffff;
- pu->significand[2] = 0xffffffff;
- pu->significand[3] = 0xffffffff;
-}
-
-/* the following fpu_add3wc should be inlined as
- * .inline _fpu_add3wc,3
- * ld [%o1],%o4 ! sum = x
- * addcc -1,%o3,%g0 ! restore last carry in cc reg
- * addxcc %o4,%o2,%o4 ! sum = sum + y + last carry
- * st %o4,[%o0] ! *z = sum
- * addx %g0,%g0,%o0 ! return new carry
- * .end
- */
-
-unsigned
-fpu_add3wc(z,x,y,carry)
- unsigned *z,x,y,carry;
-{ /* *z = x + y + carry, set carry; */
- if(carry==0) {
- *z = x+y;
- return (*z<y);
- } else {
- *z = x+y+1;
- return (*z<=y);
- }
-}
-
-/* the following fpu_sub3wc should be inlined as
- * .inline _fpu_sub3wc,3
- * ld [%o1],%o4 ! sum = *x
- * addcc -1,%o3,%g0 ! restore last carry in cc reg
- * subxcc %o4,%o2,%o4 ! sum = sum - y - last carry
- * st %o4,[%o0] ! *x = sum
- * addx %g0,%g0,%o0 ! return new carry
- * .end
- */
-
-unsigned
-fpu_sub3wc(z,x,y,carry)
- unsigned *z,x,y,carry;
-{ /* *z = x - y - carry, set carry; */
- if(carry==0) {
- *z = x-y;
- return (*z>x);
- } else {
- *z = x-y-1;
- return (*z>=x);
- }
-}
-
-/* the following fpu_neg2wc should be inlined as
- * .inline _fpu_neg2wc,2
- * ld [%o1],%o3 ! tmp = *x
- * addcc -1,%o2,%g0 ! restore last carry in cc reg
- * subxcc %g0,%o3,%o3 ! sum = 0 - tmp - last carry
- * st %o3,[%o0] ! *x = sum
- * addx %g0,%g0,%o0 ! return new carry
- * .end
- */
-
-unsigned
-fpu_neg2wc(z,x,carry)
- unsigned *z,x,carry;
-{ /* *x = 0 - *x - carry, set carry; */
- if(carry==0) {
- *z = -x;
- return ((*z)!=0);
- } else {
- *z = -x-1;
- return 1;
- }
-}
-
-int
-fpu_cmpli(x,y,n)
- unsigned x[],y[]; int n;
-{ /* compare two unsigned array */
- int i;
- i=0;
- while(i<n) {
- if(x[i]>y[i]) return 1;
- else if(x[i]<y[i]) return -1;
- i++;
- }
- return 0;
-}
-
-#ifdef DEBUG
-void
-display_unpacked(pu)
- unpacked *pu;
-
-/* Print out unpacked record. */
-
-{
- (void) printf(" unpacked ");
- if (pu->sign)
- (void) printf("-");
- else
- (void) printf("+");
-
- switch (pu->fpclass) {
- case fp_zero:
- (void) printf("0 ");
- break;
- case fp_normal:
- (void) printf("normal");
- break;
- case fp_infinity:
- (void) printf("Inf ");
- break;
- case fp_quiet:
- case fp_signaling:
- (void) printf("nan ");
- break;
- }
- (void) printf(" %X %X %X %X (%X,%X) exponent %X \n",
- pu->significand[0], pu->significand[1],pu->significand[2],
- pu->significand[3], (pu->rounded!=0),
- (pu->sticky!=0),pu->exponent);
-}
-#endif
-
diff --git a/usr/src/lib/libbc/libc/gen/common/_Qglobals.h b/usr/src/lib/libbc/libc/gen/common/_Qglobals.h
deleted file mode 100644
index f836353fe9..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Qglobals.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _qglobals_h
-#define _qglobals_h
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* Sparc floating-point simulator PRIVATE include file. */
-
-/* PRIVATE CONSTANTS */
-#define INTEGER_BIAS 31
-#define SINGLE_BIAS 127
-#define DOUBLE_BIAS 1023
-#define EXTENDED_BIAS 16383
-
-/* PRIVATE TYPES */
-#ifdef DEBUG
-#define PRIVATE
-#else
-#define PRIVATE static
-#endif
-
-typedef struct {
- int sign ;
- enum fp_class_type fpclass ;
- int exponent ; /* Unbiased exponent. */
- unsigned significand[4] ; /* Four significand word . */
- int rounded; /* rounded bit */
- int sticky; /* stick bit */
-} unpacked ;
-
-/* PRIVATE GLOBAL VARIABLES */
-
-enum fp_direction_type fp_direction ; /* Current rounding direction. */
-enum fp_precision_type fp_precision ; /* Current extended rounding precision. */
-
-unsigned _fp_current_exceptions ; /* Current floating-point exceptions. */
-
-extern void _fp_unpack(unpacked *, int *, enum fp_op_type);
-/* unpacked *pu ; */ /* unpacked result */
-/* int *n ; */ /* register where data starts */
-/* fp_op_type type ;*/ /* type of datum */
-
-extern void _fp_pack(unpacked *, int *, enum fp_op_type);
-/* unpacked *pu ; */ /* unpacked result */
-/* int *n ; */ /* register where data starts */
-/* fp_op_type type ; */ /* type of datum */
-
-extern void fpu_normalize(unpacked *);
-/* unpacked *pu ; */ /* unpacked operand and result */
-
-extern void fpu_rightshift(unpacked *, int);
-/* unpacked *pu ; unsigned n ; */
-/* Right shift significand sticky by n bits. */
-
-extern unsigned fpu_add3wc(unsigned *, unsigned, unsigned, unsigned);
-/* unsigned *z,x,y,c; */ /* *z = x+y+carry; return new carry */
-
-extern unsigned fpu_sub3wc(unsigned *, unsigned, unsigned, unsigned);
-/* unsigned *z,x,y,c; */ /* *z = x-y-carry; return new carry */
-
-extern unsigned fpu_neg2wc(unsigned *, unsigned, unsigned);
-/* unsigned *z,x,c; */ /* *z = 0-x-carry; return new carry */
-
-extern int fpu_cmpli(unsigned [], unsigned [], int);
-/* unsigned x[],y[],n; */ /* n-word compare */
-
-extern void fpu_set_exception(enum fp_exception_type);
-/* enum fp_exception_type ex ; */ /* exception to be set in curexcep */
-
-extern void fpu_error_nan(unpacked *);
-/* unpacked *pu ; */ /* Set invalid exception and error nan in *pu */
-
-extern void unpacksingle(unpacked *, single_type);
-/* unpacked *pu; */ /* packed result */
-/* single_type x; */ /* packed single */
-
-extern void unpackdouble(unpacked *, double_type, unsigned);
-/* unpacked *pu; */ /* unpacked result */
-/* double_type x; */ /* packed double */
-/* unsigned y; */
-
-extern enum fcc_type _fp_compare(unpacked *, unpacked *, int);
-
-extern void _fp_add(unpacked *, unpacked *, unpacked *);
-extern void _fp_sub(unpacked *, unpacked *, unpacked *);
-extern void _fp_mul(unpacked *, unpacked *, unpacked *);
-extern void _fp_div(unpacked *, unpacked *, unpacked *);
-extern void _fp_sqrt(unpacked *, unpacked *);
-
-#endif /* _qglobals_h */
diff --git a/usr/src/lib/libbc/libc/gen/common/_Qquad.h b/usr/src/lib/libbc/libc/gen/common/_Qquad.h
deleted file mode 100644
index d506e0ae70..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_Qquad.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _QUAD_INCLUDED_
-#define _QUAD_INCLUDED_ /* Render harmless multiple inclusions. */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Header file for long double == quadruple-precision run-time support. C
- * "long double" and Fortran "real*16" are implemented identically on all
- * architectures.
- *
- * Thus the quad run-time support is intentionally coded as C-callable routines
- * for portability.
- *
- * Mixed-case identifiers with leading _ are intentionally chosen to minimize
- * conflicts with user-defined C and Fortran identifiers.
- */
-
-#include <math.h> /* to get float macros */
-
-#ifdef __STDC__ /* are we there yet */
-
-#define QUAD long double
-#define SINGLE float
-#define SINGLERESULT float
-#define RETURNSINGLE(x) return x
-#define ASSIGNSINGLERESULT(x,y) x = y
-
-#else
-
-struct quadstruct {
- unsigned parts[4]
-};
-
-#define QUAD struct quadstruct
-
-#define SINGLE FLOATPARAMETER
-#define SINGLERESULT FLOATFUNCTIONTYPE
-#define RETURNSINGLE(x) RETURNFLOAT(x)
-#define ASSIGNSINGLERESULT(x,y) {SINGLERESULT _kug = y; *(int *)&x = *(int*)&_kug;}
-
-#endif
-
-/****** Phase I Quad support: C run-time in libc/crt *****/
-
-extern QUAD _Q_neg(QUAD); /* returns -x */
-extern QUAD _Q_add(QUAD, QUAD); /* returns x + y */
-extern QUAD _Q_sub(QUAD, QUAD); /* returns x - y */
-extern QUAD _Q_mul(QUAD, QUAD); /* returns x * y */
-extern QUAD _Q_div(QUAD, QUAD); /* returns x / y */
-extern QUAD _Q_sqrt(QUAD); /* return sqrt(x) */
-extern enum fcc_type
- _Q_cmp(QUAD, QUAD); /* x compare y , exception */
- /* only on signaling NaN */
-extern enum fcc_type
- _Q_cmpe(QUAD, QUAD); /* x compare y , exception */
- /* on quiet NaN */
-extern int _Q_feq(QUAD, QUAD); /* return TRUE if x == y */
-extern int _Q_fne(QUAD, QUAD); /* return TRUE if x != y */
-extern int _Q_fgt(QUAD, QUAD); /* return TRUE if x > y */
-extern int _Q_fge(QUAD, QUAD); /* return TRUE if x >= y */
-extern int _Q_flt(QUAD, QUAD); /* return TRUE if x < y */
-extern int _Q_fle(QUAD, QUAD); /* return TRUE if x <= y */
-
-/* Conversion routines are pretty straightforward. */
-
-extern QUAD _Q_stoq(SINGLE);
-extern QUAD _Q_dtoq(double);
-extern QUAD _Q_itoq(int);
-extern QUAD _Q_utoq(unsigned);
-extern SINGLERESULT _Q_qtos(QUAD);
-extern double _Q_qtod(QUAD);
-extern int _Q_qtoi(QUAD);
-extern unsigned _Q_qtou(QUAD);
-
-/******
- Phase I Quad support: scanf/printf support in libc/gen/common
-*****/
-
-enum fcc_type /* relationships for loading into cc */
- {
- fcc_equal = 0,
- fcc_less = 1,
- fcc_greater = 2,
- fcc_unordered = 3
- } ;
-
-typedef /* FPU register viewed as single components. */
- struct
- {
- unsigned sign : 1 ;
- unsigned exponent : 8 ;
- unsigned significand : 23 ;
- }
- single_type ;
-
-typedef /* FPU register viewed as double components. */
- struct
- {
- unsigned sign : 1 ;
- unsigned exponent : 11 ;
- unsigned significand : 20 ;
- }
- double_type ;
-typedef /* FPU register viewed as extended components. */
- struct
- {
- unsigned sign : 1 ;
- unsigned exponent : 15 ;
- unsigned significand : 16 ;
- }
- extended_type ;
-
-enum fp_op_type /* Type specifiers in FPU instructions. */
- {
- fp_op_integer = 0, /* Not in hardware, but convenient to define. */
- fp_op_single = 1,
- fp_op_double = 2,
- fp_op_extended = 3
- } ;
-
-
-extern void _Q_get_rp_rd(void);
-extern void _Q_set_exception(unsigned);
-
-#endif /* QUAD_INCLUDED */
diff --git a/usr/src/lib/libbc/libc/gen/common/_base_S.c b/usr/src/lib/libbc/libc/gen/common/_base_S.c
deleted file mode 100644
index ee7999d539..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_base_S.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "base_conversion.h"
-
-/* Fundamental utilities for base conversion that should be recoded as assembly language subprograms or as inline expansion templates. */
-
-/* Converts t < 10000 into four ascii digits at *pc. */
-void
-_fourdigitsquick(short unsigned t, char *d)
-{
- short i;
-
- i = 3;
- do {
- d[i] = '0' + t % 10;
- t = t / 10;
- }
- while (--i != -1);
-}
-
-void
-_multiply_base_two_vector(short unsigned n, _BIG_FLOAT_DIGIT *px,
- short unsigned *py, _BIG_FLOAT_DIGIT product[3])
-{
- /*
- * Given xi and yi, base 2**16 vectors of length n, computes dot
- * product
- *
- * sum (i=0,n-1) of x[i]*y[n-1-i]
- *
- * Product may fill as many as three short-unsigned buckets. Product[0]
- * is least significant, product[2] most.
- */
-
- unsigned long acc, p;
- short unsigned carry;
- int i;
-
- acc = 0;
- carry = 0;
- for (i = 0; i < n; i++) {
- p=_umac(px[i],py[n - 1 - i],acc);
- if (p < acc)
- carry++;
- acc = p;
- }
- product[0] = (_BIG_FLOAT_DIGIT) (acc & 0xffff);
- product[1] = (_BIG_FLOAT_DIGIT) (acc >> 16);
- product[2] = (_BIG_FLOAT_DIGIT) (carry);
-}
-
-void
-_multiply_base_ten_vector(short unsigned n, _BIG_FLOAT_DIGIT *px,
- short unsigned *py, _BIG_FLOAT_DIGIT product[3])
-{
- /*
- * Given xi and yi, base 10**4 vectors of length n, computes dot
- * product
- *
- * sum (i=0,n-1) of x[i]*y[n-1-i]
- *
- * Product may fill as many as three short-unsigned buckets. Product[0]
- * is least significant, product[2] most.
- */
-
-#define ABASE 3000000000U /* Base of accumulator. */
-
- unsigned long acc;
- short unsigned carry;
- int i;
-
- acc = 0;
- carry = 0;
- for (i = 0; i < n; i++) {
- acc=_umac(px[i],py[n - 1 - i],acc);
- if (acc >= (unsigned long) ABASE) {
- carry++;
- acc -= ABASE;
- }
- }
- /*
- NOTE: because
- acc * <= ABASE-1,
- acc/10000 <= 299999
- which would overflow a short unsigned
- */
- product[0] = (_BIG_FLOAT_DIGIT) (acc % 10000);
- acc /= 10000;
- product[1] = (_BIG_FLOAT_DIGIT) (acc % 10000);
- acc /= 10000;
- product[2] = (_BIG_FLOAT_DIGIT) (acc + (ABASE / 100000000) * carry);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_base_il.c b/usr/src/lib/libbc/libc/gen/common/_base_il.c
deleted file mode 100644
index 45a1b875da..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_base_il.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "base_conversion.h"
-
-/* The following should be coded as inline expansion templates. */
-
-/*
- * Fundamental utilities that multiply two shorts into a unsigned long, add
- * carry, compute quotient and remainder in underlying base, and return
- * quo<<16 | rem as a unsigned long.
- */
-
-/*
- * C compilers tend to generate bad code - forcing full unsigned long by
- * unsigned long multiplies when what is really wanted is the unsigned long
- * product of half-long operands. Similarly the quotient and remainder are
- * all half-long. So these functions should really be implemented by inline
- * expansion templates.
- */
-
-/* p = x * y + c ; return p */
-unsigned long
-_umac(_BIG_FLOAT_DIGIT x, _BIG_FLOAT_DIGIT y, unsigned long c)
-{
- return (x * (unsigned long) y + c);
-}
-
-/* p = x + c ; return (p/10000 << 16 | p%10000) */
-unsigned long
-_carry_in_b10000(_BIG_FLOAT_DIGIT x, long unsigned c)
-{
- unsigned long p = x + c ;
-
- return ((p / 10000) << 16) | (p % 10000);
-}
-
-void
-_carry_propagate_two(unsigned long carry, _BIG_FLOAT_DIGIT *psignificand)
-{
- /*
- * Propagate carries in a base-2**16 significand.
- */
-
- long unsigned p;
- int j;
-
- j = 0;
- while (carry != 0) {
- p = _carry_in_b65536(psignificand[j],carry);
- psignificand[j++] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
-}
-
-void
-_carry_propagate_ten(unsigned long carry, _BIG_FLOAT_DIGIT *psignificand)
-{
- /*
- * Propagate carries in a base-10**4 significand.
- */
-
- int j;
- unsigned long p;
-
- j = 0;
- while (carry != 0) {
- p = _carry_in_b10000(psignificand[j],carry);
- psignificand[j++] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_base_sup.c b/usr/src/lib/libbc/libc/gen/common/_base_sup.c
deleted file mode 100644
index e9995ab61f..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_base_sup.c
+++ /dev/null
@@ -1,307 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "base_conversion.h"
-
-#ifdef DEBUG
-
-void
-_display_big_float(_big_float *pbf, unsigned base)
-{
- int i;
-
- for (i = 0; i < pbf->blength; i++) {
- switch (base) {
- case 2:
- printf(" + %d * 2** %d", pbf->bsignificand[i], (16 * i + pbf->bexponent));
- break;
- case 10:
- printf(" + %d * 10** %d", pbf->bsignificand[i], (4 * i + pbf->bexponent));
- break;
- }
- if ((i % 4) == 3)
- printf("\n");
- }
- printf("\n");
-}
-
-#endif
-
-void
-_integerstring_to_big_decimal(char ds[], unsigned ndigs, unsigned nzin,
- unsigned *pnzout, _big_float *pd)
-{
- /*
- * Convert ndigs decimal digits from ds, and up to 3 trailing zeros,
- * into a decimal big_float in *pd. nzin tells how many implicit
- * trailing zeros may be used, while *pnzout tells how many were
- * actually absorbed. Up to 3 are used if available so that
- * (ndigs+*pnzout) % 4 = 0.
- */
-
- int extras, taken, id, ids;
-
-#ifdef DEBUG
- printf(" _integerstring_to_big_decimal: ndigs %d nzin %d ds %s \n", ndigs, nzin, ds);
-#endif
-
- /* Compute how many trailing zeros we're going to put in *pd. */
-
- extras = ndigs % 4;
- if ((extras > 0) && (nzin != 0)) {
- taken = 4 - extras;
- if (taken > nzin)
- taken = nzin;
- } else
- taken = 0;
-
- *pnzout = nzin - taken;
-
-#define IDIGIT(i) ((i < 0) ? 0 : ((i < ndigs) ? (ds[i] - '0') : 0))
-
- pd->bexponent = 0;
- pd->blength = (ndigs + taken + 3) / 4;
-
- ids = (ndigs + taken) - 4 * pd->blength;
- id = pd->blength - 1;
-
-#ifdef DEBUG
- printf(" _integerstring_to_big_decimal exponent %d ids %d id %d \n", pd->bexponent, ids, id);
-#endif
-
- pd->bsignificand[id] = 1000 * IDIGIT(ids) + 100 * IDIGIT(ids + 1) + 10 * IDIGIT(ids + 2) + IDIGIT(ids + 3);
- ids += 4;
-
- for (; ids < (int) (ndigs + taken - 4); ids += 4) { /* Additional digits to
- * be found. Main loop. */
- id--;
- pd->bsignificand[id] = 1000 * ds[ids] + 100 * ds[ids + 1] + 10 * ds[ids + 2] + ds[ids + 3] - 1111 * '0';
- }
-
-#ifdef DEBUG
- assert((id == 1) || (id == 0));
-#endif
- if (id != 0)
- pd->bsignificand[0] = 1000 * IDIGIT(ids) + 100 * IDIGIT(ids + 1) + 10 * IDIGIT(ids + 2) + IDIGIT(ids + 3);
-
-#ifdef DEBUG
- printf(" _integerstring_to_big_decimal: ");
- _display_big_float(pd, 10);
-#endif
-}
-
-void
-_fractionstring_to_big_decimal(char ds[], unsigned ndigs, unsigned nzin,
- _big_float *pbf)
-{
- /*
- * Converts a decimal string containing an implicit point, nzin
- * leading implicit zeros, and ndigs explicit digits, into a big
- * float.
- */
-
- int ids, ibf;
-
-#ifdef DEBUG
- printf(" _fractionstring_to_big_decimal ndigs %d nzin %d s %s \n", ndigs, nzin, ds);
-#endif
-
- pbf->bexponent = -(int) (nzin + ndigs);
- pbf->blength = (ndigs + 3) / 4;
-
- ids = nzin + ndigs - 4 * pbf->blength;
- ibf = pbf->blength - 1;
-
-#ifdef DEBUG
- printf(" _fractionstring_to_big_decimal exponent %d ids %d ibf %d \n", pbf->bexponent, ids, ibf);
-#endif
-
-#define FDIGIT(i) ((i < nzin) ? 0 : ((i < (nzin+ndigs)) ? (ds[i-nzin] - '0') : 0))
-
- pbf->bsignificand[ibf] = 1000 * FDIGIT(ids) + 100 * FDIGIT(ids + 1) + 10 * FDIGIT(ids + 2) + FDIGIT(ids + 3);
- ids += 4;
-
- for (; ids < (int) (nzin + ndigs - 4); ids += 4) { /* Additional digits to
- * be found. Main loop. */
- ibf--;
- pbf->bsignificand[ibf] = 1000 * ds[ids - nzin] + 100 * ds[ids + 1 - nzin] + 10 * ds[ids + 2 - nzin] + ds[ids + 3 - nzin] - 1111 * '0';
- }
-
- if (ibf > 0) {
-#ifdef DEBUG
- assert(ibf == 1);
-#endif
- pbf->bsignificand[0] = 1000 * FDIGIT(ids) + 100 * FDIGIT(ids + 1) + 10 * FDIGIT(ids + 2) + FDIGIT(ids + 3);
- } else {
-#ifdef DEBUG
- assert(ibf == 0);
-#endif
- }
-
-#ifdef DEBUG
- printf(" _fractionstring_to_big_decimal: ");
- _display_big_float(pbf, 10);
-#endif
-}
-
-void
-_mul_10000short(_big_float *pbf, long unsigned carry)
-{
- int j;
- long unsigned p;
-
- for (j = 0; j < pbf->blength; j++) {
- p = _prod_10000_b65536(pbf->bsignificand[j], carry);
- pbf->bsignificand[j] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- while (carry != 0) {
- p = _carry_out_b10000(carry);
- pbf->bsignificand[j++] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- pbf->blength = j;
-}
-
-void
-_big_decimal_to_big_binary(_big_float *pd, _big_float *pb)
-{
- /* Convert _big_float from decimal form to binary form. */
-
- int id, idbound;
- _BIG_FLOAT_DIGIT sticky, carry;
- _BIG_FLOAT_DIGIT multiplier;
-
-#ifdef DEBUG
- assert(pd->bexponent >= -3);
- assert(pd->bexponent <= 3);
-#endif
- pb->bexponent = 0;
- pb->blength = 1;
- id = pd->blength - 1;
- if ((id == 0) && (pd->bexponent < 0)) {
- pb->bsignificand[0] = 0;
- } else {
- pb->bsignificand[0] = pd->bsignificand[id--];
- idbound = (pd->bexponent < 0) ? 1 : 0; /* How far to carry next
- * for loop depends on
- * whether last digit
- * requires special
- * treatment. */
- for (; id >= idbound; id--) {
- _mul_10000short(pb, (long unsigned) pd->bsignificand[id]);
- }
- }
- if (pd->bexponent < 0) {/* Have to save some integer bits, discard
- * and stick some fraction bits at the end. */
-#ifdef DEBUG
- assert(id == 0);
-#endif
- sticky = 0;
- carry = pd->bsignificand[0];
- multiplier = 10000;
- switch (pd->bexponent) {
- case -1:
- sticky = carry % 10;
- carry /= 10;
- multiplier = 1000;
- break;
- case -2:
- sticky = carry % 100;
- carry /= 100;
- multiplier = 100;
- break;
- case -3:
- sticky = carry % 1000;
- carry /= 1000;
- multiplier = 10;
- break;
- }
- _multiply_base_two(pb, multiplier, (long unsigned) carry);
- if (sticky != 0)
- pb->bsignificand[0] |= 1; /* Save lost bits. */
- } else if (pd->bexponent > 0) { /* Have to append some zeros. */
- switch (pd->bexponent) {
- case 1:
- multiplier = 10;
- break;
- case 2:
- multiplier = 100;
- break;
- case 3:
- multiplier = 1000;
- break;
- }
- carry = 0;
- _multiply_base_two(pb, multiplier, (long unsigned) carry);
- }
-#ifdef DEBUG
- printf(" _big_decimal_to_big_binary ");
- _display_big_float(pb, 2);
-#endif
-}
-
-void
-_big_binary_to_unpacked(_big_float *pb, unpacked *pu)
-{
- /* Convert a binary big_float to a binary_unpacked. */
-
- int ib, iu;
-
-#ifdef DEBUG
- assert(pb->bsignificand[pb->blength - 1] != 0); /* Assert pb is
- * normalized. */
-#endif
-
- iu = 0;
- for (ib = pb->blength - 1; ((ib - 1) >= 0) && (iu < UNPACKED_SIZE); ib -= 2) {
- pu->significand[iu++] = pb->bsignificand[ib] << 16 | pb->bsignificand[ib - 1];
- }
- if (iu < UNPACKED_SIZE) { /* The big float fits in the unpacked
- * with no rounding. */
- if (ib == 0)
- pu->significand[iu++] = pb->bsignificand[ib] << 16;
- for (; iu < UNPACKED_SIZE; iu++)
- pu->significand[iu] = 0;
- } else { /* The big float is too big; chop, stick, and
- * normalize. */
- while (pb->bsignificand[ib] == 0)
- ib--;
- if (ib >= 0)
- pu->significand[UNPACKED_SIZE - 1] |= 1; /* Stick lsb if nonzero
- * found. */
- }
-
- pu->exponent = 16 * pb->blength + pb->bexponent - 1;
- _fp_normalize(pu);
-
-#ifdef DEBUG
- printf(" _big_binary_to_unpacked \n");
- _display_unpacked(pu);
-#endif
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_big_power.c b/usr/src/lib/libbc/libc/gen/common/_big_power.c
deleted file mode 100644
index 994bcdc092..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_big_power.c
+++ /dev/null
@@ -1,1772 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include "base_conversion.h"
-
-unsigned short _max_big_powers_ten = 1260;
-unsigned short _big_powers_ten[] = {1, /* begin powers of 10000 in
- * base 65536 */
- /* 10000**90 = 65536**22 * */ 24832, 26544, 2586, 53761, 57792, 53253, 29499, 56082,
- 11839, 41887, 40418, 25010, 56546, 10851, 1212, 37926,
- 54683, 24944, 9622, 49891, 30137, 5131, 11297, 7965,
- 27232, 47123, 15266, 35282, 32115, 24817, 55263, 50890,
- 57131, 1641, 34615, 9400, 1773, 26259, 28395, 6473,
- 56175, 37773, 33397, 24180, 39478, 50542, 46897, 13968,
- 17093, 51240, 31118, 9390, 3806, /* * 65536**74 */
- /* 10000**180 = 65536**45 * */ 33985, 7059, 50023, 49495, 50123, 42743, 46480, 57582,
- 11318, 19673, 45663, 3344, 38612, 23984, 46968, 53347,
- 1637, 11314, 39569, 11385, 46514, 18737, 254, 8488,
- 51985, 44900, 30372, 57670, 35, 2423, 21277, 52736,
- 17783, 36546, 57005, 52994, 11764, 34186, 38967, 29573,
- 31609, 52884, 35484, 5862, 37331, 46285, 3552, 17166,
- 23884, 16123, 63828, 64220, 40233, 60185, 35113, 44957,
- 62568, 31869, 62842, 20359, 37122, 26110, 39645, 20711,
- 5066, 62485, 7570, 43880, 25252, 32872, 25424, 17843,
- 18779, 28712, 52721, 12061, 37011, 17182, 18688, 41694,
- 9744, 49728, 27156, 3092, 40688, 48751, 18433, 52160,
- 33601, 24318, 57448, 65020, 26274, 17344, 47654, 41401,
- 62950, 31535, 27325, 4701, 11581, 64161, 47399, 3270,
- 221, /* * 65536**149 */
- /* 10000**270 = 65536**67 * */ 8448, 53501, 26337, 31473, 40957, 40631, 48909, 53457,
- 20735, 15028, 5789, 54161, 14411, 54948, 58612, 16703,
- 60933, 37416, 13759, 21647, 15992, 8158, 21322, 49916,
- 50899, 10500, 61546, 64808, 24885, 47894, 22543, 7780,
- 30293, 45924, 12217, 38801, 56975, 28948, 9918, 42159,
- 64774, 9810, 51572, 22988, 21827, 9461, 13137, 48930,
- 33891, 51044, 37035, 25332, 1280, 56459, 12584, 48754,
- 40019, 43829, 8962, 15530, 62271, 18344, 6657, 19593,
- 44745, 58787, 40668, 52192, 32657, 12973, 31749, 56817,
- 44085, 36894, 57738, 47056, 63832, 3276, 5478, 58665,
- 57346, 40249, 28227, 21581, 12301, 31946, 358, 8638,
- 19457, 56089, 7233, 5275, 49953, 53412, 34142, 32827,
- 37650, 65359, 31247, 34120, 46664, 57489, 20280, 30130,
- 28614, 21249, 30833, 40373, 44196, 8194, 36189, 58466,
- 2574, 44938, 8814, 109, 18128, 7521, 47937, 57918,
- 37532, 54663, 2577, 9044, 22665, 25537, 10764, 19087,
- 7004, 2179, 41422, 5651, 26207, 17993, 50256, 38597,
- 3449, 61115, 20807, 44005, 28834, 13215, 7913, 53059,
- 4484, 48600, 17162, 35297, 4759, 49174, 43511, 60182,
- 5836, 31015, 22479, 40680, 54915, 12, /* * 65536**224 */
- /* 10000**360 = 65536**90 * */ 39297, 28797, 19536, 11545, 64015, 52591, 13876, 58921,
- 23682, 1986, 56989, 18252, 21209, 33745, 52547, 51178,
- 2782, 19350, 6109, 37173, 53626, 3048, 1461, 55725,
- 51369, 18035, 53937, 17798, 33511, 50816, 46721, 45035,
- 58118, 27037, 24312, 45764, 42900, 63148, 16576, 11767,
- 46031, 6789, 47345, 858, 43692, 25905, 7147, 29400,
- 28424, 54349, 52149, 60542, 63221, 7749, 51852, 6952,
- 25762, 29494, 20486, 45960, 32833, 26932, 18753, 55669,
- 15583, 21202, 32441, 16038, 60580, 44361, 9748, 61294,
- 59477, 43384, 56673, 48473, 14732, 25204, 62875, 17232,
- 55644, 40058, 18129, 397, 49816, 27626, 60216, 25306,
- 38110, 10732, 35472, 39607, 16165, 62410, 7086, 27496,
- 50158, 41865, 47027, 43707, 3983, 64460, 53739, 28189,
- 875, 42538, 58391, 18282, 8861, 45795, 10907, 36476,
- 20935, 50159, 63428, 22377, 35199, 22005, 58273, 27559,
- 40171, 2536, 15354, 53038, 32599, 8294, 43881, 6890,
- 4104, 39477, 3416, 14231, 63716, 58698, 8871, 28387,
- 43094, 28276, 49866, 44118, 58895, 28174, 4918, 14393,
- 4723, 25333, 55124, 30906, 58587, 29493, 21770, 496,
- 22682, 20698, 63098, 29331, 42083, 17816, 23787, 43214,
- 2135, 41163, 59940, 47651, 37571, 35042, 16945, 53313,
- 47751, 5968, 61004, 51568, 25849, 56505, 61289, 33232,
- 55259, 50253, 35550, 46938, 19022, 14950, 37908, 18484,
- 19143, 12648, 11973, 7740, 15947, 57462, 5693, 21228,
- 11590, 15884, 57998, 31222, 14304, 59938, 39970, 1254,
- 5177, 25824, 46245, 44888, 46972, 27017, 60069, 4030,
- 48863, /* * 65536**298 */
- /* 10000**450 = 65536**112 * */ 57600, 1753, 64214, 10939, 52713, 57114, 47498, 12718,
- 65226, 52478, 17581, 45728, 40296, 17124, 22976, 7882,
- 59829, 9678, 48006, 42769, 33867, 59105, 40007, 33681,
- 62758, 12880, 7653, 19018, 42114, 60278, 48185, 24533,
- 7865, 16338, 28648, 55791, 6926, 17250, 39828, 40360,
- 3146, 9794, 29068, 10091, 31954, 10861, 174, 9952,
- 30118, 38130, 10042, 27126, 56412, 40935, 47114, 38430,
- 26489, 15830, 50460, 58142, 53729, 28445, 34585, 11908,
- 54573, 17947, 9765, 11260, 4075, 58984, 37064, 3346,
- 57974, 57633, 26781, 41340, 61062, 3241, 44773, 47277,
- 24897, 34071, 18673, 27883, 6091, 16551, 28150, 8364,
- 61856, 64804, 11090, 50777, 18722, 53215, 55972, 60192,
- 45393, 21503, 15047, 51201, 21232, 3696, 22906, 29678,
- 36725, 62961, 55329, 45203, 36089, 61516, 18075, 29511,
- 26330, 20863, 5232, 942, 52303, 1329, 7169, 16407,
- 23511, 28002, 27861, 39195, 36757, 29288, 52738, 31621,
- 59210, 51984, 42640, 5659, 47418, 7854, 11002, 58823,
- 59570, 36949, 22019, 59119, 41882, 20539, 877, 50827,
- 37562, 38614, 43945, 48560, 55615, 11703, 51736, 56400,
- 53305, 18317, 58518, 38512, 29906, 60122, 44314, 46596,
- 19166, 62123, 52578, 15091, 61001, 5047, 22701, 14755,
- 18755, 47468, 31041, 14196, 42158, 21968, 3373, 44915,
- 57195, 47466, 25892, 61074, 29817, 54, 64515, 27653,
- 57344, 1463, 29300, 40052, 16841, 42643, 59474, 15330,
- 16570, 6014, 44041, 19131, 29244, 50031, 55233, 44818,
- 47712, 45727, 952, 34593, 60454, 19073, 4703, 4072,
- 20111, 54979, 12176, 32868, 27943, 49668, 5088, 3807,
- 49956, 5296, 3481, 21434, 32644, 61933, 14474, 15724,
- 10598, 63757, 8203, 57593, 35835, 35825, 54421, 10282,
- 58911, 46419, 7408, 59548, 56341, 21421, 19169, 40562,
- 34398, 32643, 48732, 2508, 2467, 37998, 64620, 58696,
- 45958, 12921, 53097, 62410, 8256, 16357, 3350, 63594,
- 35148, 3705, 63330, 36057, 54181, 2837, /* * 65536**373 */
- /* 10000**540 = 65536**135 * */ 15937, 20970, 57308, 46022, 51974, 28228, 49601, 21388,
- 40296, 55589, 44307, 42834, 398, 65459, 29106, 36117,
- 58627, 55677, 12574, 29537, 16367, 36210, 27724, 17412,
- 18304, 13827, 20066, 27247, 827, 4058, 41496, 20247,
- 51620, 1082, 40533, 21160, 34685, 20554, 43988, 59273,
- 34265, 55478, 129, 12039, 16053, 54781, 10914, 47279,
- 59144, 13059, 239, 57141, 24079, 42596, 19598, 19025,
- 42888, 9118, 45324, 12662, 14300, 23767, 3983, 64928,
- 23773, 48090, 61417, 45026, 31449, 8952, 13451, 50205,
- 9133, 1606, 29283, 16751, 52783, 25986, 27202, 64448,
- 7976, 36045, 65419, 18289, 6687, 58459, 2696, 64771,
- 59103, 11898, 15922, 1849, 13696, 18721, 51962, 60276,
- 33088, 13618, 33835, 955, 54730, 30753, 42953, 7375,
- 61463, 55489, 54327, 58832, 30130, 14445, 27383, 2532,
- 60622, 8764, 27263, 20809, 29172, 10746, 27493, 19018,
- 21323, 2715, 51634, 13711, 18305, 64990, 61883, 29593,
- 30164, 37070, 50170, 17727, 64571, 25429, 8567, 42658,
- 41690, 25244, 38225, 58617, 37108, 46866, 41447, 12452,
- 41201, 46696, 36226, 58260, 6808, 60813, 3511, 42132,
- 2464, 20759, 17487, 10188, 15270, 14266, 25609, 58137,
- 57931, 2205, 6443, 37431, 12405, 58845, 33285, 16573,
- 14071, 5820, 16529, 58780, 31569, 52734, 18992, 50695,
- 46732, 20912, 5076, 48345, 22472, 23041, 64294, 52141,
- 22442, 392, 26740, 43057, 11860, 14356, 63434, 15374,
- 14772, 28670, 41433, 1974, 54122, 17046, 50870, 58582,
- 5398, 17662, 56622, 53433, 51651, 8826, 50675, 27415,
- 59006, 31726, 3039, 15225, 1797, 30657, 62118, 31964,
- 11409, 19519, 46289, 51026, 63766, 51506, 6721, 28612,
- 43824, 40432, 28241, 27448, 45638, 22197, 9841, 39482,
- 9863, 39609, 40744, 38597, 41001, 28616, 32806, 21219,
- 8559, 63020, 56887, 1918, 19985, 9540, 10554, 43907,
- 50615, 38633, 61885, 47235, 60236, 61683, 13384, 60276,
- 39709, 37164, 11604, 48681, 49626, 35185, 43726, 49403,
- 29356, 30785, 4575, 1193, 43617, 38640, 17416, 6671,
- 7232, 27443, 26406, 41752, 6566, 25930, 62643, 18778,
- 54032, 30217, 3010, 58389, 63320, 30362, 35000, 19530,
- 13024, 51771, 54380, 9543, 4082, 11961, 11867, 45471,
- 30275, 39318, 40920, 8938, 25475, 57521, 52508, 58089,
- 24296, 24154, 27196, 31838, 56076, 47056, 45743, 14112,
- 53271, 164, /* * 65536**448 */
- /* 10000**630 = 65536**157 * */ 41216, 46406, 59322, 61369, 51512, 20872, 33344, 41848,
- 43840, 47477, 17497, 55908, 2232, 55500, 37020, 51781,
- 22444, 37436, 7404, 2929, 57789, 15841, 61447, 35446,
- 61753, 33940, 20974, 40070, 32303, 24165, 35623, 37205,
- 10896, 16123, 6081, 4131, 29524, 1872, 8494, 27926,
- 37845, 23806, 62637, 1365, 6521, 39715, 46011, 60077,
- 9346, 51026, 41457, 9861, 44621, 22494, 64632, 15645,
- 7424, 61517, 4626, 23178, 34013, 8518, 49315, 57860,
- 32895, 17307, 57060, 28216, 27297, 61081, 36199, 59774,
- 44595, 28382, 55034, 12516, 60988, 3506, 50799, 38145,
- 54391, 63230, 20695, 45368, 10226, 3270, 24994, 56899,
- 31459, 18314, 32368, 51902, 33323, 63009, 59011, 29737,
- 29075, 49025, 4282, 31052, 15197, 60533, 9381, 32019,
- 50249, 61190, 24684, 34675, 46264, 42435, 53411, 31868,
- 38459, 40070, 61396, 19036, 30012, 23474, 3616, 19739,
- 9343, 27372, 23783, 53650, 37433, 59240, 38132, 41049,
- 45152, 8725, 51544, 34525, 36550, 16360, 27941, 7440,
- 35100, 54826, 64859, 13997, 4890, 53899, 54048, 35700,
- 10798, 26647, 1271, 49433, 25744, 53858, 31178, 14919,
- 937, 30111, 55552, 58717, 17286, 37081, 34938, 9745,
- 24865, 45841, 34340, 43224, 22583, 5991, 64792, 16894,
- 50876, 18240, 63281, 5032, 50942, 44113, 38789, 36691,
- 51395, 8802, 13454, 56366, 32520, 61447, 35750, 63344,
- 37142, 50639, 5722, 37943, 60442, 51591, 43337, 64200,
- 64641, 57845, 46520, 36321, 44691, 5976, 53935, 32798,
- 18551, 30652, 17368, 30219, 17859, 32537, 43934, 44612,
- 43162, 55927, 7118, 44489, 276, 17010, 19651, 59717,
- 37728, 13644, 63771, 16530, 51265, 23961, 51401, 39975,
- 37696, 39126, 60849, 22425, 21035, 9611, 64833, 55092,
- 17850, 19413, 53650, 61853, 22584, 14070, 18779, 41400,
- 29164, 23227, 47530, 25123, 4816, 10016, 33069, 3061,
- 50950, 15317, 22406, 5087, 51471, 51986, 21623, 53924,
- 56665, 20549, 54909, 13520, 40440, 5926, 58434, 18,
- 50925, 8063, 35498, 15845, 51871, 7543, 20521, 27848,
- 48972, 24508, 61119, 46506, 34938, 10016, 61223, 2437,
- 18604, 57378, 59677, 26266, 31802, 20692, 53429, 64574,
- 20518, 2425, 41617, 57694, 62360, 47901, 142, 34172,
- 5481, 48289, 53305, 12663, 37332, 46869, 144, 52762,
- 35315, 13067, 41549, 63950, 10274, 26507, 13044, 60707,
- 31640, 20218, 11020, 6092, 31125, 46895, 40706, 13301,
- 33249, 14254, 13694, 14182, 44179, 19002, 10953, 42206,
- 2912, 61112, 21006, 46700, 45041, 13788, 37984, 61123,
- 2920, 53910, 22103, 46791, 35691, 26534, 59183, 6629,
- 38284, 40141, 33801, 45081, 40582, 63304, 9780, 38978,
- 37040, 33628, 42029, 7586, 6756, 27120, 50939, 17873,
- 34198, 43080, 58421, 36335, 22204, 37477, 9, /* * 65536**523 */
- /* 10000**720 = 65536**180 * */ 29441, 9221, 44176, 26692, 60846, 31847, 29090, 25339,
- 35930, 20844, 8043, 17725, 25927, 13288, 32521, 8126,
- 50775, 44966, 15361, 9307, 64745, 7612, 24764, 29669,
- 13555, 50864, 44391, 48083, 58573, 42556, 61204, 64477,
- 11986, 42790, 52174, 42952, 53031, 54270, 20286, 8768,
- 22341, 61349, 63774, 14080, 60374, 62747, 7402, 25223,
- 28052, 46846, 46980, 8609, 9078, 33609, 53505, 34930,
- 32968, 30589, 32788, 43651, 14971, 17775, 57203, 12298,
- 62205, 17626, 9672, 31691, 63216, 49734, 40541, 6402,
- 22005, 30587, 13054, 10329, 31904, 3172, 13622, 45858,
- 46301, 10464, 15293, 17945, 17536, 61782, 57231, 38296,
- 45404, 38204, 18123, 28934, 2342, 37881, 10854, 32095,
- 4987, 56042, 25984, 9019, 45858, 6236, 46121, 45379,
- 18810, 26175, 50282, 21223, 50027, 12893, 65320, 5925,
- 50383, 43903, 42003, 15205, 5093, 41037, 60929, 42849,
- 11522, 14113, 15252, 27792, 31752, 2747, 32751, 24967,
- 11946, 51822, 33949, 61093, 54336, 61377, 44704, 51071,
- 52508, 36736, 35998, 31965, 32400, 38483, 30039, 39655,
- 12271, 53350, 3018, 27056, 52286, 4241, 2469, 12591,
- 57208, 5539, 59538, 57279, 51412, 4367, 51194, 63224,
- 42879, 57531, 5593, 36875, 3222, 36878, 8834, 58841,
- 50736, 22072, 2883, 64310, 30818, 10755, 8048, 27469,
- 32380, 287, 25978, 8932, 22638, 42123, 54687, 38020,
- 54046, 34026, 2495, 20815, 13295, 60567, 18045, 38166,
- 27324, 23540, 61061, 18019, 41556, 19312, 21205, 18355,
- 4165, 36131, 36155, 63114, 1178, 4578, 57389, 10680,
- 64688, 3879, 48569, 34056, 47861, 11495, 20055, 59999,
- 8785, 16819, 48092, 5275, 39435, 62427, 11880, 55745,
- 40370, 22261, 23222, 37349, 25595, 44199, 47928, 8827,
- 33878, 10592, 29893, 58929, 55559, 62526, 3540, 28795,
- 45772, 44601, 30551, 23900, 47810, 48207, 38046, 45993,
- 54951, 42424, 37459, 26441, 64051, 39949, 15873, 48249,
- 18153, 33377, 31324, 46745, 57720, 38661, 25484, 2856,
- 27871, 57992, 32210, 39775, 27415, 49689, 12774, 39695,
- 54026, 8851, 64076, 45346, 30440, 4954, 43827, 59588,
- 26458, 35245, 6276, 9866, 19606, 17051, 10101, 42987,
- 13096, 65041, 11754, 60180, 40909, 8317, 52670, 33992,
- 60144, 23815, 64633, 10803, 13953, 41749, 52611, 55862,
- 19561, 29527, 2011, 60830, 46093, 11917, 17017, 8948,
- 6256, 43842, 30373, 60280, 24957, 58414, 59183, 55358,
- 58102, 26713, 8531, 36657, 63486, 13580, 4866, 34860,
- 64464, 17306, 43397, 37920, 15862, 59273, 3367, 51941,
- 23330, 41718, 46765, 17746, 54707, 19066, 17076, 30414,
- 2252, 63321, 11865, 11828, 30996, 63021, 12032, 19445,
- 18188, 27359, 23050, 15348, 3491, 46691, 51491, 36848,
- 33160, 12581, 63320, 56725, 1821, 43960, 39997, 18740,
- 48805, 41842, 24120, 15890, 54968, 55258, 61757, 32921,
- 9505, 55385, 18647, 48173, 26532, 22866, 2391, 60301,
- 4042, 25640, 2549, 20478, 51618, 41943, 15933, 49899,
- 41880, 50809, 7605, 15053, 44692, 26691, 4504, 56850,
- 53475, 704, 51873, 61228, 29198, 50857, 6149, 26788,
- 1987, 17697, 41116, 7369, 23359, 53572, 17078, 54242,
- 56763, 36431, /* * 65536**597 */
- /* 10000**810 = 65536**202 * */ 24832, 34883, 19140, 51974, 19534, 493, 52319, 13085,
- 44094, 53939, 13943, 21197, 17741, 12809, 17083, 47879,
- 44152, 35922, 40786, 5096, 8680, 9278, 44616, 38504,
- 36424, 51297, 47600, 4593, 4526, 149, 59298, 44171,
- 44964, 25078, 37864, 13646, 63055, 58238, 37926, 35586,
- 10600, 3464, 53122, 28369, 17593, 3852, 29481, 59844,
- 27408, 27200, 56105, 64110, 48332, 50180, 19869, 47629,
- 55510, 63058, 63565, 15060, 30626, 63856, 56518, 46308,
- 39745, 24691, 36420, 55961, 36063, 63197, 60888, 53216,
- 16582, 21061, 31362, 31969, 40126, 63351, 10808, 40164,
- 30133, 43848, 10633, 38149, 14270, 53620, 35996, 7377,
- 31064, 14168, 27656, 8304, 9433, 48523, 18453, 35684,
- 59897, 45916, 24972, 15325, 2090, 26144, 25610, 31629,
- 32660, 38294, 23250, 17832, 48733, 50586, 41084, 47429,
- 31712, 34017, 19793, 62777, 45378, 44102, 8716, 29657,
- 11066, 8490, 21653, 65497, 54560, 34995, 45742, 29639,
- 47537, 31847, 50867, 52761, 21881, 37741, 50563, 52577,
- 19856, 51512, 7692, 58548, 21610, 63516, 13279, 10470,
- 25956, 22794, 15559, 37617, 47777, 14198, 59911, 38144,
- 48165, 43003, 1866, 15531, 29396, 63328, 5477, 46307,
- 7420, 63290, 9773, 16965, 24790, 59750, 55367, 43061,
- 40717, 39703, 31857, 13914, 10833, 9318, 46436, 41858,
- 33725, 2693, 48237, 15973, 39351, 1385, 60479, 8159,
- 36758, 43662, 65499, 30448, 36485, 14023, 16129, 56629,
- 11037, 14727, 56695, 61224, 10018, 61924, 17039, 58813,
- 51177, 7002, 14025, 34593, 12170, 14808, 16590, 42794,
- 54486, 23047, 40628, 57635, 49464, 47344, 56582, 36349,
- 43317, 39710, 36166, 49702, 43150, 50620, 52026, 12306,
- 14900, 24719, 32561, 23469, 56363, 58169, 29717, 62860,
- 5914, 30326, 36935, 6904, 10575, 39528, 43903, 45125,
- 45571, 20883, 10642, 49940, 49906, 46725, 33540, 15427,
- 54802, 23586, 6422, 34110, 28513, 24672, 55236, 59300,
- 18103, 8071, 343, 46748, 44955, 44719, 46329, 45518,
- 64515, 53685, 49458, 57239, 26923, 63817, 49998, 82,
- 48162, 49280, 36045, 52738, 55278, 52109, 36659, 28664,
- 54266, 36879, 7837, 33525, 38888, 43635, 3373, 31635,
- 39148, 20248, 61282, 48866, 43029, 19598, 35185, 15499,
- 29972, 51650, 46352, 17452, 27329, 41299, 61120, 41483,
- 63249, 41810, 38435, 63667, 39939, 54741, 6587, 14314,
- 2969, 13087, 5872, 55217, 56115, 62553, 44160, 49781,
- 42336, 33771, 30218, 31267, 4033, 42958, 21612, 41303,
- 34647, 1810, 28901, 41550, 40209, 11769, 4586, 22182,
- 26502, 5719, 30640, 11452, 12437, 21544, 2884, 63001,
- 2124, 35767, 51047, 27970, 13456, 60413, 51818, 58535,
- 47850, 36522, 31614, 53268, 52691, 2465, 9577, 57821,
- 34723, 14832, 5857, 29536, 54171, 49780, 47615, 47261,
- 30128, 62107, 57931, 31222, 38520, 25994, 3823, 15723,
- 16547, 17305, 49713, 43099, 51610, 41171, 23658, 34248,
- 13535, 21991, 43596, 26442, 58160, 23695, 3544, 34778,
- 18047, 45877, 18286, 24355, 51158, 26871, 58388, 26582,
- 47810, 41235, 7058, 10487, 40836, 51818, 20367, 52775,
- 5736, 33296, 60350, 61028, 33129, 22124, 2553, 40846,
- 49426, 30198, 41206, 31906, 2268, 23375, 26363, 25951,
- 25327, 21358, 4872, 53366, 58360, 57573, 39684, 22204,
- 14446, 39744, 2602, 5841, 58903, 33209, 16767, 10211,
- 61495, 8426, 33859, 133, 24228, 7746, 3317, 39266,
- 40762, 27964, 33156, 57057, 37827, 18835, 48966, 45870,
- 59270, 1291, 59568, 53631, 7193, 56246, 21395, 738,
- 4375, 22741, 15183, 23729, 51074, 56262, 2115, /* * 65536**672 */
- /* 10000**900 = 65536**225 * */ 14273, 7163, 46567, 51827, 50089, 10023, 55949, 245,
- 1159, 17037, 51278, 44226, 51648, 35729, 25509, 4403,
- 15277, 58952, 2800, 32557, 39271, 9423, 24984, 39140,
- 57089, 23151, 3062, 50830, 59291, 867, 53101, 7095,
- 19611, 35795, 41060, 9674, 47969, 12545, 38874, 29165,
- 11512, 41264, 63581, 29168, 53103, 21505, 38999, 33701,
- 54139, 9676, 37916, 53588, 50017, 6515, 42130, 2532,
- 36284, 38864, 44500, 4466, 55531, 50755, 15508, 146,
- 28502, 38791, 21688, 26877, 52133, 54811, 29308, 24528,
- 20734, 17408, 49222, 26459, 17409, 64821, 4200, 39238,
- 64979, 29921, 33627, 35459, 36916, 51567, 33008, 1628,
- 6279, 54380, 30133, 5936, 17139, 52719, 46819, 42853,
- 41752, 31544, 1462, 57857, 44269, 5290, 12763, 55500,
- 39832, 27225, 48368, 61922, 40176, 40270, 5222, 2985,
- 26859, 21907, 20962, 63398, 54831, 61348, 11462, 26890,
- 43826, 50193, 60034, 50174, 47495, 52289, 11971, 42857,
- 8385, 26684, 23657, 10379, 54996, 40463, 25724, 21824,
- 57970, 19757, 19307, 26592, 34085, 58605, 6778, 23721,
- 51260, 28842, 5296, 13158, 47821, 847, 16832, 60766,
- 40427, 3841, 28863, 20200, 1138, 3729, 22912, 46234,
- 33780, 41281, 39777, 35382, 6550, 55549, 44803, 54984,
- 41452, 20025, 49044, 15289, 39110, 28891, 12771, 9774,
- 12295, 20992, 36634, 40705, 61898, 9178, 25519, 22203,
- 50236, 10613, 5567, 27529, 13389, 798, 40083, 55933,
- 29668, 42166, 48813, 57826, 5693, 61199, 24917, 35398,
- 55081, 28044, 10934, 490, 44922, 45359, 60589, 21808,
- 6223, 60886, 55947, 15636, 18202, 12652, 47001, 33715,
- 1784, 10522, 3250, 23010, 53423, 13029, 14613, 14582,
- 65496, 51185, 8470, 26681, 63330, 65425, 32413, 51168,
- 32060, 54007, 60139, 17653, 53407, 8189, 34606, 61688,
- 13850, 35471, 27651, 37005, 61499, 55526, 56224, 41600,
- 60040, 857, 42303, 38156, 38085, 44751, 16609, 54544,
- 38471, 14234, 8060, 31105, 63558, 7269, 31069, 36939,
- 42433, 13862, 40368, 37119, 25856, 65017, 20549, 36357,
- 64397, 17712, 38575, 49805, 59582, 22005, 40440, 19428,
- 51467, 17010, 36430, 58855, 2452, 2695, 44580, 46065,
- 30873, 60279, 54935, 34216, 22695, 58545, 48440, 15018,
- 27887, 23637, 63051, 4534, 13378, 51603, 40257, 52604,
- 691, 51699, 15786, 21724, 13278, 55833, 44434, 30861,
- 51287, 5897, 10147, 58856, 38101, 14294, 17815, 47872,
- 28393, 15890, 20928, 62986, 42962, 56890, 979, 15681,
- 47673, 38922, 36092, 57686, 64599, 33633, 28338, 34918,
- 57465, 49865, 18528, 54552, 57036, 7276, 11198, 57630,
- 22789, 16017, 10059, 23237, 21681, 41524, 46643, 24961,
- 44147, 48940, 62394, 7143, 9385, 11046, 65044, 57878,
- 57160, 47316, 45445, 2750, 58598, 9603, 42454, 30694,
- 52059, 29206, 18204, 40173, 25648, 6014, 61497, 56963,
- 26048, 57723, 8838, 62072, 11570, 12733, 36026, 31434,
- 3840, 46987, 33053, 832, 52289, 60589, 40187, 10691,
- 45021, 57479, 35352, 44144, 11407, 18748, 20537, 37568,
- 37950, 36743, 62914, 48316, 55419, 772, 17111, 43564,
- 6290, 40888, 38291, 40921, 20680, 48207, 42217, 38503,
- 730, 2822, 22255, 43137, 41848, 58326, 23670, 15109,
- 5304, 37155, 44928, 50110, 44814, 1337, 31179, 31519,
- 53369, 16421, 43531, 23933, 45501, 33542, 14548, 41770,
- 5329, 24587, 36163, 13284, 26154, 26979, 58480, 55123,
- 27153, 35641, 19702, 30180, 24988, 59627, 49160, 35901,
- 53053, 26775, 49062, 44985, 39819, 25504, 32870, 50542,
- 63631, 62927, 32094, 334, 21162, 62179, 40136, 13124,
- 27741, 9876, 3165, 29681, 27682, 30484, 38671, 4766,
- 48626, 12961, 26759, 53270, 6514, 16672, 17944, 11173,
- 54309, 18987, 19908, 62166, 55133, 64931, 34429, 19375,
- 40200, 22618, 12904, 18863, 56035, 50621, 8647, 4914,
- 56531, 52460, 17908, 38068, 9533, 24082, 12137, 56181,
- 52161, 1403, 43630, 37617, 47129, 31272, 12184, 10307,
- 41534, 57868, 122, /* * 65536**747 */
- /* 10000**990 = 65536**247 * */ 8448, 11216, 5465, 5252, 13691, 62777, 24660, 63602,
- 11742, 63994, 26533, 6198, 64453, 64762, 15022, 11560,
- 57999, 1346, 43073, 12670, 29299, 41692, 40405, 12003,
- 9686, 58196, 51539, 5057, 17555, 47938, 13325, 47771,
- 18543, 44041, 7371, 42873, 64950, 38189, 47026, 40574,
- 537, 46950, 53263, 23417, 20499, 12622, 63037, 21674,
- 48336, 5244, 44671, 30812, 22163, 9040, 9255, 65488,
- 41576, 18286, 31279, 38058, 36504, 1777, 41531, 32231,
- 45969, 61787, 5163, 19977, 41699, 14970, 29550, 50366,
- 57333, 24146, 56484, 10557, 6318, 5085, 19553, 12503,
- 43553, 41906, 1510, 18184, 26688, 55056, 6458, 8707,
- 11358, 14113, 9658, 9531, 38165, 19586, 46404, 23885,
- 31549, 25819, 31379, 53700, 15570, 44506, 9573, 8610,
- 37474, 23712, 41571, 42241, 62359, 3173, 48388, 35115,
- 13886, 29265, 13202, 39660, 17261, 57603, 53509, 30252,
- 3049, 31534, 42061, 10178, 10072, 42133, 19531, 5512,
- 22011, 20317, 60832, 45754, 23861, 8803, 8024, 9300,
- 8189, 56661, 19449, 40072, 10395, 51816, 45325, 21642,
- 40617, 4397, 40831, 53612, 3720, 26816, 21980, 49486,
- 19775, 28607, 30907, 20380, 59273, 64398, 56231, 48013,
- 32960, 6029, 14723, 17302, 7319, 55312, 16409, 27905,
- 10307, 20664, 26193, 33375, 29613, 47129, 6833, 57131,
- 38357, 56322, 30287, 21069, 29634, 17545, 54322, 46630,
- 59448, 27103, 63182, 30298, 48945, 39899, 34349, 14202,
- 9978, 9256, 11625, 18019, 44700, 31588, 9709, 17067,
- 2480, 10551, 52262, 59626, 5719, 22611, 2829, 47524,
- 4751, 61315, 1190, 28590, 40756, 50116, 968, 39757,
- 59488, 152, 10598, 9539, 42089, 34440, 21330, 35753,
- 57353, 65382, 61232, 47818, 19428, 4893, 4284, 12072,
- 10649, 29127, 34573, 16717, 42170, 60771, 8829, 1181,
- 54700, 28796, 64820, 9014, 65265, 31595, 45949, 58747,
- 15945, 20377, 21475, 59780, 50806, 49411, 51255, 36905,
- 12430, 20303, 34553, 47326, 21884, 63330, 16073, 51001,
- 5581, 9735, 30854, 43394, 26578, 29424, 49994, 36100,
- 23634, 20809, 64072, 61243, 52060, 29913, 33631, 16296,
- 32437, 6349, 52749, 15700, 39620, 46399, 24489, 6483,
- 17702, 4372, 49283, 33988, 57337, 23019, 50643, 4364,
- 1804, 2490, 53301, 55512, 15361, 57965, 43339, 53049,
- 20703, 30461, 65186, 1853, 40917, 13989, 32509, 65014,
- 57041, 36741, 42577, 10428, 33201, 2351, 43760, 450,
- 18475, 4148, 40810, 1574, 45201, 54811, 9696, 18240,
- 4281, 814, 28703, 27646, 50507, 42975, 30223, 13460,
- 10852, 61914, 38691, 12727, 45042, 53605, 54025, 59128,
- 14779, 11283, 46064, 12505, 43685, 23386, 14520, 29358,
- 4627, 44117, 55001, 34108, 6241, 49319, 18776, 49487,
- 42437, 35867, 3921, 48818, 61712, 3800, 7816, 56515,
- 1495, 29296, 8713, 35840, 43635, 26808, 13132, 16233,
- 2497, 3233, 44848, 48144, 53724, 1894, 2759, 63597,
- 29964, 63225, 43350, 56438, 29890, 64077, 2120, 45261,
- 4371, 14786, 41470, 17466, 55157, 32471, 62494, 38002,
- 23407, 2940, 57644, 42903, 4020, 53587, 3318, 47999,
- 5161, 32029, 30737, 54071, 2557, 50689, 53234, 36175,
- 40961, 32172, 3909, 19016, 61625, 34111, 14144, 24936,
- 16896, 62818, 12372, 59457, 1887, 645, 63537, 17392,
- 1114, 50039, 2686, 34251, 9674, 21696, 13228, 40036,
- 54714, 47286, 2182, 22144, 44868, 31758, 23861, 11525,
- 21730, 3665, 26632, 58312, 32064, 33523, 30267, 40799,
- 36724, 54784, 38117, 5204, 9016, 64205, 17027, 48311,
- 33725, 42192, 59162, 43755, 36462, 12221, 8743, 63827,
- 16782, 28240, 33067, 53442, 64633, 16828, 53744, 17998,
- 37175, 47644, 57936, 1832, 6528, 14825, 46409, 1977,
- 17054, 36191, 14793, 17786, 41401, 29332, 13834, 6240,
- 59939, 25580, 16725, 50035, 43728, 33886, 35213, 22229,
- 24861, 38719, 3055, 3061, 58000, 6125, 41860, 31265,
- 49348, 46603, 9764, 35877, 30160, 49410, 7100, 47807,
- 10718, 5537, 45289, 36196, 32331, 64349, 61700, 5981,
- 6649, 6342, 2822, 52677, 22254, 39294, 58122, 35925,
- 22310, 1603, 14936, 42974, 12624, 31289, 1266, 10913,
- 8274, 37729, 49689, 38262, 24455, 55587, 6913, 50313,
- 30337, 55817, 64980, 41358, 51940, 10242, 19280, 13531,
- 23954, 15839, 46833, 1614, 46746, 42892, 58742, 44714,
- 44748, 23250, 2673, 2661, 56547, 21341, 8958, 7,
- /* * 65536**822 */
- /* 10000**1080 = 65536**270 * */ 35969, 65527, 20338, 12242, 57030, 27483, 20925, 34866,
- 37995, 62473, 1330, 16007, 26899, 34993, 53763, 13986,
- 26884, 65400, 55901, 12138, 53839, 8515, 45230, 37130,
- 30737, 40433, 16575, 47085, 45034, 5302, 28335, 57005,
- 22440, 10619, 59258, 6861, 41500, 62167, 57844, 4133,
- 35839, 22712, 27192, 42174, 46754, 26624, 61306, 60061,
- 12433, 10121, 6313, 37820, 6007, 61184, 13391, 25383,
- 49031, 38668, 43505, 15089, 64994, 4879, 11070, 22631,
- 6207, 65503, 28118, 36679, 35922, 20644, 38606, 32825,
- 9233, 56150, 1583, 51096, 45352, 60012, 2115, 41832,
- 60619, 29484, 25747, 59731, 50215, 33401, 9777, 33356,
- 4545, 41181, 60374, 15690, 35095, 63846, 4140, 8324,
- 13904, 48649, 35456, 8116, 42157, 50206, 40063, 45872,
- 7599, 18962, 48417, 39625, 19385, 7183, 39285, 25477,
- 31918, 34075, 2973, 20304, 3869, 40907, 6283, 53285,
- 21565, 54800, 3099, 63351, 19428, 2283, 59341, 9996,
- 48252, 48814, 54345, 22150, 21613, 40202, 43876, 38944,
- 64604, 6563, 30994, 2553, 44916, 42593, 29298, 37038,
- 45249, 11025, 48205, 9383, 16918, 37853, 32410, 31440,
- 29243, 60387, 34792, 54085, 7280, 64745, 6242, 42678,
- 55653, 7950, 56873, 4902, 52836, 43897, 639, 9280,
- 60008, 46619, 32011, 25081, 52076, 28983, 47306, 61838,
- 19535, 24464, 41653, 25843, 43561, 48725, 41247, 44966,
- 53302, 43814, 7367, 9458, 13869, 31476, 12767, 55594,
- 30824, 63935, 9696, 6667, 31999, 50893, 55234, 42913,
- 19496, 12880, 54616, 37680, 47181, 15774, 42091, 48571,
- 41189, 56906, 44069, 19494, 61417, 47627, 49626, 52385,
- 19434, 65511, 16820, 2643, 49943, 35149, 43140, 3439,
- 65423, 7246, 36543, 9896, 3582, 10149, 23496, 35541,
- 2582, 11269, 42535, 44767, 50152, 61980, 39561, 56609,
- 37061, 8334, 45130, 14096, 40278, 15114, 49471, 56808,
- 15632, 54413, 64099, 46435, 36467, 53419, 10772, 11521,
- 43612, 64772, 20299, 52506, 17748, 39569, 60365, 21251,
- 34284, 10636, 44072, 26904, 45857, 43639, 24318, 61907,
- 7878, 33513, 15616, 62983, 46136, 7313, 21547, 37227,
- 46503, 24860, 48549, 21798, 22342, 14131, 22033, 52279,
- 61857, 16311, 50989, 36484, 56525, 24361, 51738, 39047,
- 44213, 30533, 50080, 52323, 16437, 46793, 4846, 62968,
- 35862, 43889, 2791, 18111, 16134, 36985, 43534, 1666,
- 2970, 12365, 38432, 6777, 44929, 12920, 34750, 5142,
- 239, 43658, 42039, 14776, 35110, 9559, 45088, 53364,
- 38362, 42460, 43246, 8437, 16032, 36097, 55193, 24167,
- 59792, 8093, 36288, 38140, 6056, 32401, 1144, 16797,
- 24474, 23434, 37962, 30049, 52725, 56110, 58340, 36802,
- 24828, 48521, 19413, 25682, 45914, 55, 12190, 42713,
- 60387, 16852, 63593, 27607, 55260, 27802, 54479, 29187,
- 8748, 34352, 5241, 45524, 60050, 405, 46704, 41046,
- 26477, 45891, 60022, 51904, 33611, 44204, 30580, 60004,
- 18775, 32340, 28622, 45538, 49045, 63367, 23219, 51168,
- 42982, 41136, 63410, 31213, 43173, 37726, 19222, 29370,
- 44402, 19495, 23168, 12370, 17208, 15786, 47477, 27836,
- 19826, 28477, 5719, 24067, 5087, 35305, 16911, 20735,
- 54257, 4741, 23273, 14332, 37147, 18175, 45630, 40503,
- 24950, 18113, 9135, 9501, 21821, 12582, 11139, 62854,
- 464, 12572, 57428, 13531, 28477, 18522, 10541, 26505,
- 47692, 53471, 25747, 53782, 13544, 8182, 45875, 48127,
- 54948, 29352, 17720, 43079, 19041, 62187, 64838, 33792,
- 47137, 49136, 38397, 48247, 2603, 30425, 51397, 24949,
- 30697, 22370, 53700, 21914, 65294, 30144, 34466, 24897,
- 9592, 158, 24612, 13665, 38859, 58457, 23999, 40845,
- 19152, 14012, 21212, 22737, 36399, 8307, 28748, 2060,
- 7589, 17249, 362, 41692, 8612, 51819, 58869, 4455,
- 53139, 21737, 37335, 5624, 59010, 36579, 36223, 36932,
- 17544, 4121, 41032, 28204, 45035, 63366, 26317, 7171,
- 33739, 4399, 61606, 57877, 21760, 61384, 19819, 2133,
- 21109, 34777, 25708, 22613, 46696, 44052, 51710, 23536,
- 17871, 32203, 8966, 41282, 22625, 20237, 16347, 22565,
- 3942, 25598, 47178, 3759, 63556, 22918, 62263, 51106,
- 11270, 3902, 54133, 5238, 58847, 3357, 60086, 28063,
- 40717, 9011, 38024, 1066, 18471, 2339, 9331, 40412,
- 1959, 22572, 45730, 53351, 36637, 31458, 11444, 30555,
- 52969, 30098, 1350, 49651, 16400, 55522, 61620, 8113,
- 3029, 39240, 39252, 23947, 60404, 24211, 16221, 11621,
- 54989, 62562, 8457, 57734, 61481, 33303, 53947, 23929,
- 10226, 29099, 38390, 60716, 10264, 58142, 33253, 35683,
- 32668, 52365, 37839, 21035, 30530, 65294, 20410, 33214,
- 33927, 59639, 51510, 55225, 60899, 32713, 55680, 22427,
- 18934, 50901, 55499, 18342, 34273, 48413, 15059, 1856,
- 23957, 18148, 27163, /* * 65536**896 */
- /* 10000**1170 = 65536**292 * */ 57600, 19436, 30159, 40265, 63827, 34677, 48744, 35442,
- 44746, 27137, 10696, 50059, 49688, 55567, 48021, 27347,
- 12423, 52843, 52579, 6439, 46139, 58036, 63895, 50521,
- 2639, 35617, 15101, 35359, 52213, 33998, 64533, 60211,
- 25245, 54062, 27178, 8474, 26829, 10437, 19695, 1050,
- 25311, 10258, 7964, 35543, 40907, 25898, 18812, 4362,
- 32146, 61326, 31532, 50972, 12327, 46814, 65349, 13080,
- 49055, 60452, 4498, 43691, 45804, 4764, 48417, 10341,
- 49321, 56403, 59480, 9205, 62814, 39328, 32280, 35768,
- 7313, 28486, 27160, 31200, 26934, 46241, 57455, 24222,
- 15734, 51453, 37567, 57333, 38064, 48913, 61530, 26786,
- 43961, 12101, 40131, 46639, 11918, 42601, 32832, 61279,
- 40551, 44553, 26324, 59251, 53986, 50472, 36564, 36026,
- 57448, 33095, 56484, 52713, 37122, 10150, 7602, 12809,
- 1704, 30364, 65439, 11312, 44484, 9736, 64030, 3053,
- 58942, 31227, 6957, 3662, 46800, 22475, 19542, 51939,
- 50569, 63911, 48766, 59192, 23248, 58323, 8099, 33672,
- 20857, 60081, 54343, 36309, 14110, 31124, 35564, 44710,
- 59463, 54102, 32666, 52080, 35270, 27597, 2521, 7800,
- 15502, 15199, 31684, 15860, 43249, 35670, 23980, 26978,
- 1778, 59009, 47962, 37281, 9450, 60769, 8063, 64424,
- 36596, 53977, 5301, 15655, 13812, 53130, 42429, 16208,
- 12103, 19916, 37755, 53157, 63374, 6767, 46635, 50715,
- 33492, 18514, 53655, 37278, 6138, 29099, 17136, 6795,
- 51046, 43083, 31957, 8875, 46491, 32531, 18588, 6232,
- 53334, 14070, 5211, 29319, 34016, 52582, 9454, 15404,
- 39941, 14707, 54612, 25892, 17481, 984, 48580, 31799,
- 30800, 16827, 8558, 16278, 65451, 40259, 46308, 50697,
- 39993, 52045, 56233, 47481, 31161, 388, 53391, 37511,
- 60369, 8391, 34809, 36357, 458, 53784, 44568, 33556,
- 13954, 49150, 5041, 54584, 60304, 21022, 41788, 36261,
- 41549, 65179, 40541, 51127, 9883, 21359, 32861, 22699,
- 14405, 39846, 25772, 63294, 16861, 39665, 16819, 32781,
- 16146, 20361, 49368, 48805, 11794, 18538, 59056, 48282,
- 34943, 15871, 28426, 53226, 11855, 45462, 30124, 60860,
- 28055, 9267, 43021, 46094, 42638, 38870, 1321, 55408,
- 37034, 45963, 41870, 38539, 60271, 41848, 30287, 44532,
- 15544, 26752, 39819, 41330, 28662, 32340, 35342, 45264,
- 53173, 39672, 13627, 16487, 47378, 56815, 64338, 38261,
- 55537, 33663, 9483, 51506, 57269, 63848, 63177, 4795,
- 39218, 41025, 28259, 47624, 23486, 30665, 7272, 2830,
- 39617, 10425, 47029, 61323, 62933, 44477, 30007, 43020,
- 52077, 30725, 38435, 57638, 16462, 27056, 64988, 16566,
- 50537, 20493, 9906, 21492, 43895, 374, 44515, 56769,
- 8223, 48380, 40760, 14257, 39656, 34630, 41285, 15246,
- 62411, 47824, 48336, 36913, 6976, 16512, 57714, 42313,
- 13979, 48088, 60, 24912, 62211, 28151, 35752, 36701,
- 50052, 24618, 59132, 20255, 12497, 59698, 29577, 51569,
- 12798, 42198, 53790, 23570, 19875, 61970, 10800, 48176,
- 24589, 6893, 31612, 57636, 10610, 30282, 22215, 44024,
- 31263, 34518, 45043, 32436, 12262, 46765, 52624, 16321,
- 4114, 59087, 54751, 49164, 37820, 64012, 27438, 25871,
- 11204, 15290, 26961, 38400, 20759, 64316, 9621, 64020,
- 46909, 20691, 52647, 33348, 11576, 17066, 14015, 49566,
- 40538, 63664, 14944, 20687, 39074, 25856, 38268, 47873,
- 30505, 1498, 37095, 13677, 9292, 30643, 49306, 2970,
- 34675, 26586, 4470, 13882, 62018, 42647, 14650, 32179,
- 31724, 63540, 6422, 45588, 48883, 16175, 17479, 7982,
- 51335, 3705, 24447, 24326, 21497, 52371, 25062, 24894,
- 15989, 3109, 50876, 27200, 8648, 32174, 20005, 8719,
- 61318, 38490, 117, 58091, 45689, 24069, 39959, 30543,
- 2616, 64752, 62632, 16639, 3681, 44725, 9996, 35120,
- 41225, 47680, 31561, 303, 57460, 13392, 15823, 14403,
- 48491, 10280, 30164, 63874, 53006, 38217, 29855, 29272,
- 24594, 7725, 18809, 57474, 55413, 58819, 52259, 8574,
- 28330, 5615, 47921, 11575, 1337, 37725, 18350, 20197,
- 59722, 7403, 55547, 56424, 54478, 9683, 30498, 4876,
- 11569, 8650, 7196, 1998, 22300, 6472, 53770, 18940,
- 8345, 3191, 3892, 35925, 31490, 15746, 63659, 19136,
- 40591, 38919, 7939, 18832, 4632, 51547, 58229, 27339,
- 25497, 1691, 51106, 275, 61634, 48153, 48098, 6661,
- 63928, 58037, 26688, 5855, 11436, 61191, 44893, 42901,
- 60804, 42379, 26937, 11543, 23770, 16000, 49890, 22438,
- 57970, 3854, 64957, 3519, 40127, 20002, 45185, 39487,
- 35298, 55263, 46570, 8685, 55848, 35560, 19389, 27707,
- 13058, 28900, 15944, 7688, 37021, 39815, 30190, 44862,
- 23598, 35229, 62820, 2996, 20461, 46976, 9001, 27879,
- 48268, 46227, 49321, 49454, 63850, 61735, 54794, 42907,
- 23571, 26334, 53654, 65360, 25489, 6468, 53678, 42675,
- 52954, 59402, 4235, 63352, 24939, 48637, 61250, 26806,
- 49629, 9768, 42381, 54045, 9937, 12168, 37664, 4615,
- 55658, 1123, 65351, 60196, 45320, 56318, 30654, 20203,
- 33201, 41697, 44590, 23892, 65277, 21327, 25805, 61616,
- 58532, 8858, 28723, 13551, 44996, 22985, 48164, 17401,
- 48762, 63463, 10663, 40820, 44187, 7691, 37052, 1577,
- /* * 65536**971 */
-0}; /* end powers of 10000 in base 65536 */
-
-unsigned short _start_big_powers_ten[] = {
- 0, 1, 54, 159, 317, 526, 788, 1102,
- 1469, 1887, 2358, 2881, 3457, 4084, 4764,
-0}; /* end _start_big_powers_ten */
-
-unsigned short _leading_zeros_big_powers_ten[] = {
- 0, 22, 45, 67, 90, 112, 135, 157,
- 180, 202, 225, 247, 270, 292,
-0}; /* end _leading_zeros_big_powers_ten */
-
-unsigned short _max_big_powers_two = 1050;
-unsigned short _big_powers_two[] = {1, /* begin powers of 65536 in
- * base 10000 */
- /* 65536**70 = */ 4576, 5330, 2659, 2634, 2700, 241, 736, 6118,
- 2918, 4420, 4263, 834, 7879, 7750, 4507, 3089,
- 9485, 9709, 7384, 3707, 3230, 3352, 7721, 5033,
- 2406, 9107, 3228, 6941, 8819, 1325, 5084, 9353,
- 9449, 2435, 6704, 9445, 4261, 3162, 5528, 9548,
- 4853, 5551, 7153, 8634, 6800, 2062, 51, 2591,
- 4400, 2943, 1099, 5223, 667, 7222, 3974, 9347,
- 6550, 4000, 3007, 556, 1451, 904, 8812, 7639,
- 1900, 4787, 3415, 4511, 6120, 1037, 2997, 97,
- 403, 7164, 4093, 5216, 3246, 5134, 8480, 6291,
- 8881, 3964, 9238, 2427, 14, /* * 10000**84 */
- /* 65536**140 = */ 9776, 2253, 8946, 6582, 4366, 1230, 5988, 5994,
- 4986, 2332, 3133, 9676, 4549, 5629, 4568, 9179,
- 3036, 9197, 7169, 3119, 9828, 5638, 3796, 4617,
- 6421, 5990, 9499, 523, 5203, 2152, 7290, 6879,
- 9813, 4441, 5925, 798, 7236, 4019, 6307, 8398,
- 157, 2516, 6143, 8646, 7492, 9583, 9938, 5152,
- 6847, 8006, 683, 244, 8006, 1196, 3758, 9532,
- 452, 401, 5992, 7450, 1493, 753, 9827, 1126,
- 2835, 5738, 7741, 3443, 881, 2236, 1741, 4233,
- 5279, 3671, 2940, 5294, 7898, 9852, 7504, 8508,
- 3953, 2527, 3546, 2712, 2847, 3048, 7420, 3799,
- 6771, 8202, 4354, 7186, 8190, 4570, 6440, 5511,
- 8549, 5153, 5490, 7918, 620, 5243, 5543, 3873,
- 6356, 9078, 5386, 1591, 7111, 4159, 2320, 8196,
- 6569, 6064, 290, 9978, 187, 8976, 8722, 4655,
- 482, 8111, 4070, 76, 2883, 9619, 7217, 7027,
- 5806, 3289, 7545, 7242, 8353, 2644, 8452, 1680,
- 1123, 8161, 4848, 8635, 987, 5726, 9071, 3094,
- 2436, 6472, 1303, 2224, 7305, 1464, 2855, 9906,
- 1460, 1230, 6481, 9106, 631, 3182, 966, 9732,
- 3988, 7802, 5403, 4445, 2222, 2728, 3489, 8571,
- 202, /* * 10000**168 */
- /* 65536**210 = */ 4976, 281, 6012, 17, 8847, 4796, 3320, 9840,
- 359, 4031, 4266, 8224, 5040, 9010, 6606, 8362,
- 3870, 2803, 1299, 2790, 5573, 8496, 7425, 3329,
- 7000, 497, 2926, 2886, 5811, 7267, 4596, 9031,
- 6264, 3836, 4739, 2863, 3432, 4432, 9069, 2431,
- 2863, 4311, 2750, 4609, 1868, 9838, 8459, 363,
- 1809, 2581, 5504, 2024, 6298, 5674, 9180, 4725,
- 8486, 7668, 2709, 289, 3360, 275, 2585, 2205,
- 4105, 2770, 7940, 4706, 8653, 4347, 7154, 3676,
- 6577, 340, 6463, 2121, 2672, 6305, 8022, 7840,
- 5602, 9571, 4312, 3466, 8020, 1916, 4070, 2988,
- 3457, 6416, 9812, 2174, 8930, 9173, 6076, 8312,
- 857, 1096, 1180, 620, 4859, 152, 1092, 7491,
- 4745, 3889, 3900, 2599, 4401, 3692, 4364, 2736,
- 4341, 1761, 6723, 5419, 7347, 3190, 5989, 9396,
- 3021, 918, 8083, 7208, 5461, 1098, 6917, 8071,
- 5616, 7722, 7108, 9396, 2863, 1362, 9097, 9696,
- 5896, 164, 8909, 555, 434, 8445, 4953, 6921,
- 2368, 285, 1641, 6713, 6744, 9989, 6930, 9850,
- 2475, 71, 4925, 5299, 4396, 8984, 4026, 8373,
- 1527, 940, 5824, 5337, 6969, 4236, 2973, 2267,
- 2558, 6780, 186, 2173, 5244, 6671, 3833, 9623,
- 4375, 6327, 6339, 7965, 6106, 2682, 9003, 9739,
- 1314, 50, 4056, 4385, 7946, 1430, 6097, 9714,
- 449, 6659, 5844, 1707, 5755, 2108, 2981, 3824,
- 2297, 8807, 4920, 5469, 831, 2922, 9193, 2194,
- 8297, 6119, 2088, 3045, 6641, 4977, 2769, 7282,
- 4848, 6251, 1477, 1725, 9884, 3400, 123, 4489,
- 8747, 9422, 2934, 2294, 9954, 3692, 8377, 1570,
- 4011, 7220, 3419, 4810, 5449, 2242, 1, 507,
- 7969, 5364, 7835, 8911, 8206, 8810, 1515, 9401,
- 4940, 3087, 5588, 2520, 2889, /* * 10000**252 */
- /* 65536**280 = */ 176, 213, 2607, 9939, 341, 6807, 5102, 2207,
- 8576, 9910, 5541, 1756, 3100, 5881, 2766, 1754,
- 7165, 678, 8260, 2609, 5249, 4119, 911, 2853,
- 5944, 1955, 7766, 4398, 7425, 6034, 2902, 1670,
- 5261, 6752, 8696, 8901, 723, 2061, 1185, 4361,
- 1220, 6295, 9342, 3745, 2770, 2245, 9517, 8616,
- 519, 326, 4902, 2510, 240, 2817, 6116, 7267,
- 5696, 5673, 4758, 400, 7924, 2433, 2768, 7115,
- 9889, 8056, 4872, 3379, 6347, 188, 2900, 3628,
- 718, 2601, 569, 4493, 9471, 7751, 6734, 4229,
- 7350, 4570, 3539, 9964, 7318, 2925, 7285, 5044,
- 910, 1170, 6902, 9479, 5846, 4587, 2066, 9718,
- 2024, 9598, 9786, 6834, 9788, 878, 8515, 479,
- 3827, 7717, 2467, 4862, 6342, 6429, 1755, 8575,
- 9653, 7658, 6064, 8500, 3739, 6705, 9709, 8727,
- 7188, 3920, 643, 3538, 9196, 2044, 2512, 4030,
- 4742, 8858, 2798, 5421, 9449, 4493, 7923, 7811,
- 8000, 9466, 893, 2451, 2464, 595, 648, 4712,
- 9685, 1069, 6432, 5712, 9366, 2291, 8285, 9673,
- 963, 797, 3759, 8730, 9787, 3118, 6175, 6888,
- 7340, 5804, 1787, 4499, 9274, 5600, 8623, 2000,
- 3012, 7525, 3772, 5832, 8776, 8233, 8819, 4186,
- 8839, 1243, 3757, 6603, 38, 8988, 1689, 9475,
- 2656, 4308, 2757, 1617, 8483, 7419, 4432, 422,
- 3379, 9379, 7941, 4832, 6397, 4864, 132, 4744,
- 5018, 2249, 3186, 7947, 8711, 5661, 7136, 1949,
- 9827, 4135, 7566, 106, 1785, 6344, 6462, 5900,
- 9559, 1743, 8759, 9815, 2766, 2726, 8889, 1178,
- 6042, 1337, 2344, 758, 2262, 9853, 9870, 320,
- 3981, 2791, 3735, 1192, 7971, 6202, 2032, 4478,
- 7712, 7807, 4055, 1262, 7318, 4267, 551, 2405,
- 7480, 3657, 1175, 4133, 614, 4983, 3622, 729,
- 1553, 3186, 1015, 1134, 6445, 3169, 9873, 4821,
- 19, 2947, 3314, 1074, 2191, 3683, 9534, 9977,
- 1274, 6156, 5112, 1886, 5073, 7996, 4769, 5584,
- 4236, 2031, 7148, 3026, 7816, 3827, 5170, 7265,
- 7348, 9775, 6826, 6117, 8322, 5389, 723, 3879,
- 7766, 2144, 1642, 5480, 4291, 6302, 1317, 4356,
- 5214, 6696, 1438, 768, 8736, 6532, 2848, 9268,
- 1403, 1103, 9555, 2274, 4988, 1270, 6107, 5515,
- 8883, 2507, 275, 8187, 4670, 975, 165, 6868,
- 1973, 902, 9995, 1421, 78, 6534, 7688, 171,
- 1151, 4, /* * 10000**337 */
- /* 65536**350 = */ 5376, 2848, 3097, 7478, 9581, 4767, 564, 7416,
- 2894, 9542, 726, 2535, 6568, 6434, 5775, 8334,
- 6660, 8109, 768, 4381, 7948, 832, 9727, 6736,
- 4371, 7686, 8518, 332, 173, 8241, 8498, 4,
- 6562, 3493, 3112, 4998, 660, 1524, 6823, 6242,
- 6475, 8178, 7929, 8298, 9439, 9161, 2065, 5021,
- 3388, 6887, 6511, 6683, 4151, 1208, 8005, 4130,
- 3692, 6948, 2189, 805, 1154, 133, 4169, 6639,
- 1811, 990, 5508, 8629, 300, 2310, 3518, 5017,
- 5358, 5850, 8671, 6573, 49, 5520, 5528, 8064,
- 3441, 5935, 5356, 5963, 5632, 5922, 9287, 2478,
- 1595, 8827, 1212, 9835, 4848, 2573, 8854, 6317,
- 8300, 7144, 3193, 6224, 2297, 6291, 2094, 9274,
- 3829, 9250, 3608, 9224, 6286, 3559, 7081, 5126,
- 7724, 2849, 7390, 9500, 2307, 2908, 641, 5630,
- 1271, 2165, 7588, 4861, 9441, 7062, 2062, 3854,
- 259, 5391, 1477, 3176, 5832, 3351, 3779, 3495,
- 6085, 9743, 1068, 4149, 3738, 9737, 2761, 6395,
- 1575, 6136, 9570, 419, 8912, 4743, 139, 5106,
- 9429, 6354, 6639, 2016, 32, 6503, 2688, 253,
- 3072, 8438, 1809, 3605, 7429, 6407, 3523, 3194,
- 3301, 3415, 8083, 7442, 13, 6376, 3587, 9852,
- 3230, 915, 6344, 8098, 9192, 4127, 1359, 3713,
- 5754, 6880, 2667, 3981, 1681, 155, 2793, 6465,
- 6334, 7863, 2526, 4075, 2560, 5031, 1170, 77,
- 6463, 1877, 5427, 7978, 2699, 301, 4894, 2316,
- 6716, 9859, 235, 6316, 9834, 5965, 4481, 9083,
- 6291, 8558, 9362, 8075, 9932, 6405, 6902, 3829,
- 6056, 2529, 691, 6770, 1761, 3187, 8874, 7283,
- 6080, 7420, 5693, 4501, 1471, 9833, 6366, 4679,
- 4737, 3318, 5819, 5229, 5279, 6659, 9858, 424,
- 4410, 35, 645, 8191, 9263, 5668, 2513, 5232,
- 5091, 8185, 1986, 8716, 5718, 7585, 3116, 2732,
- 2118, 7247, 3777, 6391, 5165, 5421, 8223, 4033,
- 3829, 5689, 9637, 4867, 4761, 5856, 4362, 9352,
- 5900, 8005, 2560, 3264, 8131, 5834, 2535, 8375,
- 3975, 593, 6644, 5831, 1577, 4428, 8434, 1205,
- 8880, 3712, 4093, 5790, 74, 5755, 5356, 421,
- 1541, 652, 668, 5683, 1879, 3825, 122, 8887,
- 6501, 9684, 829, 1335, 1784, 3655, 6775, 3013,
- 7584, 8971, 8943, 4562, 3406, 4808, 2970, 4085,
- 7148, 5625, 5979, 2961, 1398, 3067, 2645, 2510,
- 1070, 2790, 850, 8698, 3506, 1221, 7240, 683,
- 2748, 3836, 5782, 3889, 4328, 8462, 5594, 6692,
- 2708, 6983, 5135, 6812, 3321, 5822, 1915, 2109,
- 500, 5493, 5883, 7103, 3947, 841, 8799, 7661,
- 617, 2921, 2247, 125, 6758, 8415, 1893, 2050,
- 9160, 7931, 7846, 8933, 827, 3462, 7938, 8842,
- 5671, 8291, 2242, 395, 8090, 1762, 8081, 8357,
- 6877, 1775, 3990, 2665, 4244, 3538, 9877, 5469,
- 4185, 7179, 1956, 8820, 4442, 1034, 950, 5064,
- 5290, 45, 4563, 1743, 7448, 4025, 9091, 9971,
- 5877, 7819, 3936, 3940, 6105, 58, /* * 10000**421 */
- /* 65536**420 = */ 576, 8988, 664, 3919, 9397, 8633, 7900, 5633,
- 778, 481, 1888, 1204, 5101, 7862, 7589, 9191,
- 9710, 2689, 4485, 1804, 6343, 4331, 3074, 8357,
- 5813, 3262, 9731, 3649, 2080, 2864, 5674, 77,
- 9082, 6281, 981, 3039, 4540, 5146, 1654, 4127,
- 3199, 1398, 5247, 1783, 9163, 5185, 706, 2750,
- 8430, 9896, 2547, 2815, 2509, 3404, 2669, 3713,
- 2722, 1799, 138, 926, 9118, 8525, 4454, 8668,
- 6336, 9770, 8685, 9548, 997, 5846, 7559, 9483,
- 8362, 1665, 2765, 9093, 8253, 1725, 9810, 213,
- 7885, 2853, 1411, 2276, 6384, 8329, 4969, 5285,
- 2251, 6643, 9833, 2982, 9239, 927, 6645, 1456,
- 7982, 8688, 6067, 7858, 2076, 6104, 5217, 644,
- 3517, 5939, 7126, 7571, 4858, 4602, 2878, 9362,
- 6694, 1240, 50, 8423, 6113, 5386, 9069, 6622,
- 2139, 1576, 1299, 3779, 4071, 6783, 4160, 4975,
- 1015, 3216, 5541, 4822, 2752, 7525, 532, 1015,
- 3436, 6112, 6964, 1057, 5338, 1449, 5575, 127,
- 7502, 6613, 7556, 5345, 1136, 4662, 1741, 2461,
- 5108, 8880, 4068, 7622, 9910, 1884, 6898, 3514,
- 5504, 3849, 4888, 1780, 9861, 1304, 3382, 2005,
- 7315, 1614, 7822, 5275, 9537, 1118, 3830, 1889,
- 3342, 8466, 6400, 254, 2618, 9653, 6474, 4960,
- 397, 2576, 7484, 9275, 8232, 199, 8566, 161,
- 6360, 6573, 5545, 1958, 3067, 5263, 559, 4958,
- 315, 1554, 8857, 7186, 8622, 3782, 7740, 3278,
- 1794, 7268, 2632, 5501, 9618, 8738, 3643, 6277,
- 6012, 3610, 288, 4206, 5796, 3475, 7174, 4912,
- 8758, 6323, 3905, 9152, 7953, 4361, 4463, 3095,
- 3554, 1683, 6030, 1929, 7375, 6258, 2152, 6562,
- 5846, 3295, 3906, 621, 3967, 5512, 6962, 5184,
- 8037, 2555, 6225, 7071, 7488, 1212, 4898, 2473,
- 7328, 3716, 5825, 9672, 9639, 7120, 443, 7612,
- 8465, 6114, 8131, 5825, 3200, 7748, 9274, 4311,
- 9358, 4668, 7300, 8736, 3949, 584, 9431, 5922,
- 6761, 5835, 1402, 9894, 7088, 2458, 2112, 5215,
- 1778, 6588, 9991, 9956, 9148, 6733, 5266, 3544,
- 6437, 9631, 1618, 5442, 3963, 2241, 6525, 5097,
- 6792, 8765, 5631, 4038, 1736, 3256, 8351, 5314,
- 9979, 6884, 6015, 1122, 5239, 8501, 5776, 6649,
- 5114, 6880, 460, 475, 1329, 2777, 8032, 6562,
- 7846, 7018, 9893, 9391, 3793, 9834, 4199, 3843,
- 627, 9689, 2149, 160, 1327, 9674, 8560, 9299,
- 8965, 7349, 8187, 6017, 7068, 8093, 5757, 7606,
- 2423, 135, 372, 6302, 4605, 2027, 9171, 1324,
- 5511, 9099, 8850, 8994, 8232, 4470, 7980, 8005,
- 7216, 4482, 6124, 297, 1049, 6980, 9621, 311,
- 8951, 8883, 5978, 4077, 9581, 2508, 4711, 4428,
- 3341, 3531, 523, 9142, 7401, 8003, 950, 3295,
- 419, 7685, 2793, 4628, 1466, 9344, 1694, 9744,
- 592, 3901, 7624, 5300, 607, 2830, 7331, 3324,
- 7412, 9343, 1002, 9334, 400, 485, 9954, 1257,
- 52, 7039, 3202, 2626, 5007, 3291, 4237, 9444,
- 6860, 5339, 7508, 1175, 9228, 4913, 9145, 1340,
- 306, 2129, 9924, 8112, 991, 7118, 5675, 6906,
- 6348, 2476, 1269, 8053, 650, 3578, 7757, 1877,
- 7566, 604, 1036, 8177, 8169, 1777, 7586, 4055,
- 1745, 2700, 8005, 1, 372, 843, 3229, 5851,
- 5704, 3752, 2409, 8356, 4838, 930, 4075, 8149,
- 2620, 6567, 3302, 6988, 8270, 757, 3275, 3899,
- 7832, 488, 7302, 9455, 2508, 8718, 7517, 8654,
- 6925, 3559, 8617, 5973, 8089, 9073, 5897, 6014,
- 3039, 4038, 3131, 8979, 8916, 7739, 2464, 4424,
- 7777, 834, /* * 10000**505 */
- /* 65536**490 = */ 5776, 9431, 507, 3988, 8799, 5719, 9020, 3099,
- 7523, 4041, 2773, 7913, 8546, 6090, 6505, 6324,
- 678, 5416, 5566, 9267, 5891, 2562, 106, 1954,
- 5018, 2963, 9753, 1086, 574, 9248, 8457, 7833,
- 5151, 9537, 3506, 9829, 7272, 920, 8588, 5032,
- 9739, 9592, 8917, 8333, 8413, 7860, 3589, 8574,
- 3040, 7813, 4386, 28, 1593, 4394, 1358, 4985,
- 8871, 9096, 7462, 836, 3458, 9265, 9262, 3279,
- 912, 290, 1497, 4428, 5919, 4146, 4003, 5874,
- 8647, 167, 8364, 2483, 6932, 5005, 6519, 2592,
- 536, 2731, 193, 7398, 2945, 7802, 785, 4094,
- 4184, 1213, 8852, 1686, 4541, 6405, 3357, 6423,
- 1506, 6089, 1213, 1133, 5118, 3415, 1077, 1958,
- 6675, 7423, 6153, 7034, 5831, 1338, 1066, 1935,
- 583, 96, 8781, 3076, 4800, 7302, 1310, 6858,
- 6070, 9182, 3912, 3432, 5149, 677, 7501, 1001,
- 3691, 1492, 2816, 7033, 4083, 5163, 3022, 2024,
- 5952, 3985, 8572, 2595, 5985, 5333, 212, 4524,
- 2671, 5416, 7327, 8839, 2754, 6826, 8335, 6676,
- 5653, 9426, 1185, 1908, 1677, 7014, 9493, 6814,
- 2015, 4170, 7520, 9097, 2581, 7181, 8159, 8204,
- 1452, 6864, 9467, 5347, 9830, 4403, 5856, 3087,
- 6043, 7312, 4115, 990, 889, 8356, 7923, 7708,
- 3107, 8295, 8873, 4976, 5777, 3831, 4188, 835,
- 8231, 3690, 3524, 9390, 7023, 1876, 7236, 4427,
- 514, 6350, 5016, 519, 151, 1119, 1920, 7165,
- 137, 5736, 9277, 2526, 8000, 4638, 7675, 3197,
- 8010, 7236, 9027, 3052, 429, 4251, 621, 4687,
- 580, 9670, 8660, 7852, 6291, 8441, 4969, 2407,
- 460, 7339, 6761, 6500, 9983, 805, 915, 8696,
- 4445, 56, 9303, 6908, 3917, 8292, 6104, 9779,
- 3567, 692, 1259, 292, 833, 3190, 9406, 3740,
- 275, 1099, 1482, 6853, 1080, 8559, 8139, 1396,
- 4902, 2874, 9613, 5810, 236, 8443, 5416, 8393,
- 8751, 3616, 102, 6320, 4005, 809, 2349, 7262,
- 1060, 927, 6212, 1845, 2309, 6601, 234, 7023,
- 1037, 8076, 4278, 8787, 1111, 2785, 5347, 9174,
- 4866, 8543, 1979, 9701, 8951, 2955, 1607, 317,
- 508, 4607, 9658, 4672, 6840, 1896, 1259, 9832,
- 7398, 176, 317, 3185, 5585, 2848, 1431, 545,
- 8514, 9260, 9054, 4691, 4722, 2396, 4080, 1438,
- 7161, 38, 2373, 2081, 359, 5634, 8412, 7366,
- 1617, 1042, 9842, 492, 426, 5456, 9432, 5831,
- 6293, 3455, 895, 9218, 307, 3951, 18, 7350,
- 1858, 1805, 352, 8085, 3566, 9921, 3839, 8974,
- 7501, 3634, 8467, 8370, 4209, 3242, 617, 38,
- 5947, 3376, 6638, 1543, 4303, 6258, 2008, 8965,
- 5607, 4777, 5725, 4908, 4312, 5484, 6276, 4939,
- 2969, 1989, 8160, 2323, 3613, 5872, 6195, 1051,
- 2368, 5130, 5114, 4157, 8861, 3505, 8475, 5251,
- 1312, 9694, 9803, 6432, 350, 7092, 8507, 6429,
- 4896, 4256, 953, 5869, 4820, 6006, 5260, 8523,
- 905, 2152, 7727, 2873, 4262, 9943, 2468, 6602,
- 299, 1975, 3745, 9332, 4535, 4221, 4273, 7144,
- 297, 4009, 8535, 451, 3773, 2948, 5922, 5956,
- 4079, 5527, 687, 9259, 9230, 6868, 4982, 8161,
- 1559, 5930, 8859, 3745, 9346, 3511, 3694, 1580,
- 6169, 323, 5558, 3735, 8840, 8377, 6888, 1528,
- 3427, 9648, 7158, 7572, 8821, 3085, 1542, 5127,
- 4430, 6826, 7402, 9291, 562, 1246, 8624, 2794,
- 6256, 7655, 1083, 8826, 4414, 1460, 2278, 7861,
- 8341, 3677, 2984, 4691, 451, 3560, 1580, 7583,
- 6509, 4045, 7972, 321, 4512, 1662, 9186, 371,
- 7919, 1240, 8982, 997, 1836, 9492, 5360, 5448,
- 6025, 4174, 4995, 3474, 7970, 2139, 1951, 7419,
- 8942, 6697, 4438, 3559, 2076, 8885, 2256, 6627,
- 543, 164, 5853, 4856, 7906, 2129, 1724, 3786,
- 8533, 3135, 3539, 2300, 6945, 7244, 4342, 4067,
- 890, 7697, 9580, 7680, 61, 6007, 8870, 7700,
- 8996, 6715, 3370, 1992, 889, 3860, 6590, 5603,
- 2020, 9641, 1761, 2911, 576, 4742, 4317, 2007,
- 5876, 2778, 8887, 2860, 2104, 1998, 8765, 3094,
- 540, 3195, 9389, 5556, 3538, 4926, 3190, 7472,
- 609, 5522, 9966, 9799, 5660, 1889, 1, /* * 10000**590 */
- /* 65536**560 = */ 976, 4979, 3040, 9206, 955, 4391, 2817, 938,
- 1112, 5523, 5387, 1306, 5954, 1973, 9036, 8492,
- 5961, 9057, 4333, 4301, 583, 4235, 3509, 9051,
- 920, 2693, 5406, 961, 5945, 2876, 5973, 8416,
- 1345, 265, 9047, 1241, 3361, 9657, 5675, 7186,
- 6284, 4664, 9707, 5178, 8714, 3055, 9424, 8160,
- 3540, 2285, 3000, 83, 4995, 4114, 2049, 3255,
- 8318, 6178, 1394, 1626, 8128, 5450, 1000, 7325,
- 954, 3111, 9095, 6175, 1638, 7210, 4996, 5422,
- 2210, 9768, 129, 952, 7035, 3095, 2545, 68,
- 2121, 5895, 5840, 8038, 6233, 8454, 4819, 41,
- 9659, 756, 5166, 4451, 6171, 828, 6973, 381,
- 5405, 8524, 5788, 8040, 5624, 9949, 4079, 8021,
- 9909, 5434, 9374, 9549, 4519, 3315, 9843, 3053,
- 936, 2227, 1563, 8987, 4406, 3206, 3672, 5667,
- 4927, 3654, 3143, 8371, 3840, 3751, 6085, 6065,
- 7371, 2891, 5391, 340, 2817, 4181, 8243, 2568,
- 4276, 5037, 5579, 4087, 9881, 3156, 7618, 738,
- 4561, 1917, 5475, 356, 8296, 541, 939, 4009,
- 4945, 7654, 9014, 5190, 1958, 8762, 8536, 2515,
- 6041, 1430, 8447, 7896, 4976, 5974, 1848, 2061,
- 848, 2128, 9096, 8336, 5768, 1268, 2744, 2445,
- 1997, 547, 5266, 2066, 2785, 6457, 7035, 5368,
- 7618, 1389, 1304, 4119, 899, 4551, 3877, 3140,
- 3879, 3564, 3844, 3066, 2279, 7763, 4159, 3714,
- 7863, 6139, 516, 4075, 3813, 411, 6837, 7570,
- 863, 6397, 2306, 9709, 5957, 1883, 2460, 1164,
- 7907, 8462, 6278, 2391, 1205, 9618, 8604, 7140,
- 5742, 5884, 9887, 3539, 9756, 6773, 1783, 3234,
- 7128, 2285, 7327, 5364, 9023, 4212, 1005, 1827,
- 4830, 6992, 6679, 2761, 8465, 8923, 6697, 2139,
- 8041, 1978, 8857, 3050, 3862, 4736, 7727, 9356,
- 7020, 8064, 840, 7255, 2415, 925, 5770, 8623,
- 8843, 1722, 7152, 5061, 1193, 5878, 4483, 8654,
- 5757, 9025, 998, 8067, 6265, 832, 4047, 3221,
- 6466, 2287, 9674, 5520, 1293, 7456, 3458, 5767,
- 755, 3752, 6416, 7411, 6410, 1693, 3423, 9206,
- 7864, 5888, 8614, 4425, 4627, 5663, 5784, 6655,
- 643, 3172, 1929, 8595, 420, 6586, 6985, 3036,
- 6496, 6346, 5234, 1163, 9945, 300, 800, 7684,
- 8060, 6753, 6778, 4600, 6518, 2929, 5468, 4077,
- 5824, 431, 7782, 841, 2968, 1032, 7716, 9390,
- 9987, 2069, 2135, 4678, 113, 7300, 3384, 8798,
- 4109, 1841, 6669, 6689, 5687, 795, 4836, 8859,
- 9130, 1137, 557, 3551, 4205, 4030, 2660, 5896,
- 2006, 6595, 1224, 6297, 2619, 5306, 4522, 550,
- 2776, 5836, 9778, 1076, 3355, 6338, 8670, 7630,
- 3713, 7476, 1252, 6054, 9540, 5558, 2803, 8396,
- 3948, 5582, 105, 3026, 9555, 138, 1654, 7788,
- 9819, 9821, 3618, 582, 6614, 1325, 7741, 530,
- 2492, 3387, 950, 3424, 4823, 7442, 9865, 9714,
- 1796, 5099, 2964, 4613, 3652, 4807, 6659, 7494,
- 4223, 8782, 8155, 1636, 2192, 1810, 2642, 3661,
- 9096, 8284, 7796, 9482, 9920, 6951, 6355, 8988,
- 350, 3480, 1984, 768, 5747, 4435, 2898, 8288,
- 967, 1866, 4451, 8747, 7626, 3684, 6476, 4752,
- 6604, 558, 2385, 9001, 2462, 5150, 5259, 6616,
- 2390, 4184, 9526, 5941, 3138, 3861, 3482, 19,
- 6341, 7036, 6369, 227, 5578, 9777, 4200, 538,
- 6718, 2752, 1338, 4237, 2048, 5785, 5899, 4648,
- 2755, 2819, 9492, 9450, 9570, 1581, 954, 3311,
- 3691, 9510, 4695, 9790, 4907, 2502, 6597, 8365,
- 4396, 3170, 92, 3169, 9407, 870, 9168, 7108,
- 90, 5103, 4276, 5344, 4920, 7045, 1679, 1520,
- 7051, 8893, 6973, 6818, 2512, 574, 6179, 5618,
- 225, 1644, 2951, 1314, 9901, 1499, 2582, 3814,
- 2485, 8706, 3433, 9669, 3891, 469, 6359, 8382,
- 5455, 5542, 6754, 4380, 271, 4014, 867, 8095,
- 6721, 914, 2408, 2133, 7283, 9336, 5715, 9709,
- 2233, 3472, 3873, 9891, 5910, 5471, 6346, 222,
- 8177, 9547, 1543, 7347, 1126, 4978, 2536, 6994,
- 5877, 8981, 9413, 1542, 9992, 7496, 7307, 6635,
- 831, 6332, 3769, 394, 1877, 37, 4545, 2982,
- 5374, 7892, 9053, 6562, 2197, 6380, 8510, 2259,
- 1952, 2956, 8378, 1486, 6599, 3860, 1054, 381,
- 653, 3946, 8672, 8801, 9960, 5721, 3028, 6761,
- 5872, 1570, 2165, 2319, 6451, 7788, 265, 5408,
- 5369, 67, 8748, 2202, 6405, 5114, 2663, 4433,
- 6258, 3883, 9615, 4072, 7588, 4059, 2415, 4238,
- 8235, 2561, 9582, 4274, 4141, 5656, 1887, 8922,
- 8452, 1792, 498, 6663, 2697, 5907, 6270, 9502,
- 7239, 988, 5148, 5593, 9033, 6819, 2688, 7212,
- 8656, 4307, 2183, 8071, 4878, 895, 5360, 6555,
- 225, 6796, 7011, 1301, 1281, 7342, 1056, 6924,
- 6214, 9340, 16, /* * 10000**674 */
- /* 65536**630 = */ 6176, 6430, 7092, 4105, 8720, 5723, 5981, 9910,
- 5297, 4110, 3651, 4988, 5821, 4616, 4727, 5734,
- 8042, 9496, 1397, 4266, 7433, 391, 738, 3945,
- 4598, 4271, 7578, 529, 472, 6685, 9791, 6802,
- 3226, 7385, 7662, 6806, 1919, 9525, 6729, 7962,
- 5888, 9669, 2636, 7607, 7516, 8780, 6202, 3965,
- 112, 1209, 5491, 2643, 2462, 5963, 2515, 1230,
- 4121, 4054, 2940, 582, 5240, 8210, 1080, 9217,
- 1033, 602, 7441, 2065, 6998, 3379, 489, 658,
- 7501, 6167, 3242, 2737, 9556, 1554, 242, 2323,
- 3353, 779, 5274, 3089, 6341, 24, 1328, 8441,
- 1217, 2901, 9907, 9097, 3783, 3841, 3212, 1283,
- 5332, 7926, 4527, 4103, 1597, 7221, 5369, 9156,
- 4301, 8902, 3951, 9950, 6527, 2132, 6719, 2566,
- 5427, 2526, 4888, 1869, 1785, 3119, 5644, 9918,
- 1783, 5055, 2971, 6210, 2536, 6963, 3318, 1938,
- 1884, 5924, 8977, 2428, 8311, 3225, 1210, 2846,
- 4884, 7409, 5288, 5889, 3103, 3776, 3574, 7832,
- 1546, 680, 9682, 9901, 1161, 4236, 893, 9012,
- 9788, 3335, 620, 6581, 941, 8694, 462, 3523,
- 6654, 1481, 9845, 7439, 7476, 5821, 3819, 9038,
- 1144, 6471, 9971, 5535, 9048, 3965, 9361, 1496,
- 3009, 6969, 2693, 5755, 2330, 6810, 2352, 1512,
- 2523, 9719, 7464, 7771, 8431, 3033, 751, 7904,
- 7402, 4660, 2761, 5357, 2617, 5937, 2788, 5153,
- 4719, 8910, 4078, 2261, 8892, 8638, 523, 6944,
- 2764, 4273, 8230, 3796, 8416, 6433, 7600, 6223,
- 3477, 9222, 8330, 8551, 61, 9175, 7442, 4076,
- 8823, 9894, 4097, 8187, 9873, 9573, 3391, 4457,
- 2092, 2354, 9874, 6178, 6230, 8587, 583, 4119,
- 2196, 8390, 9503, 8332, 9211, 1596, 3306, 7433,
- 9397, 231, 7884, 9555, 83, 4747, 4305, 5408,
- 3811, 4850, 1772, 2406, 1877, 3578, 6173, 7833,
- 14, 8328, 2596, 5975, 5184, 5562, 387, 5768,
- 3222, 1877, 2477, 8064, 5842, 6208, 4771, 6956,
- 5542, 7513, 9381, 7844, 3531, 2747, 5733, 713,
- 2053, 2655, 7472, 5000, 4903, 8819, 4211, 9930,
- 4030, 1341, 2835, 1622, 12, 8582, 5178, 8384,
- 6232, 4624, 9277, 1178, 7232, 4849, 887, 1037,
- 4858, 8575, 6772, 5980, 7295, 7449, 9758, 9866,
- 709, 3994, 799, 1400, 2397, 7707, 7902, 1208,
- 3204, 8039, 8612, 7645, 1835, 8956, 5657, 2088,
- 189, 2316, 6271, 218, 6153, 5436, 1, 194,
- 2726, 9535, 4441, 3603, 3399, 9412, 4862, 8591,
- 9976, 1486, 2073, 3543, 2316, 841, 5016, 4073,
- 6014, 6689, 3912, 7333, 9067, 9942, 8796, 7745,
- 9452, 8145, 2207, 5872, 3731, 9353, 9948, 9187,
- 6536, 8425, 8829, 6688, 6100, 4022, 9374, 4893,
- 5752, 13, 5691, 2233, 4334, 5630, 6246, 434,
- 1221, 7461, 2426, 5642, 4710, 2812, 1033, 4356,
- 3089, 1587, 1993, 6607, 4931, 7635, 1098, 4997,
- 23, 2333, 5751, 7215, 2503, 5703, 293, 1194,
- 1899, 427, 5631, 1081, 3676, 556, 9765, 5256,
- 7616, 7431, 8935, 5493, 652, 6013, 9659, 3691,
- 6652, 1760, 4298, 2524, 758, 6723, 9665, 3205,
- 9325, 9890, 7705, 8841, 3106, 4116, 3348, 2963,
- 7234, 63, 3671, 4198, 1691, 5227, 9985, 6405,
- 8748, 830, 6348, 5353, 3024, 5032, 7552, 7653,
- 1768, 2704, 6335, 4599, 243, 8332, 3602, 9120,
- 9092, 4163, 1618, 9591, 9048, 5124, 6084, 9117,
- 6114, 4589, 462, 745, 7286, 6528, 7139, 6347,
- 1825, 932, 1067, 293, 443, 6679, 65, 3780,
- 4351, 751, 9603, 8711, 5504, 8908, 7748, 8541,
- 4250, 7889, 9317, 7250, 2112, 3173, 4267, 5986,
- 4804, 1066, 4792, 7231, 1488, 661, 9538, 4177,
- 9074, 656, 2338, 5296, 1871, 4347, 8386, 8313,
- 2884, 5370, 5220, 7582, 2797, 8578, 8049, 5674,
- 3977, 9693, 2366, 545, 869, 6824, 8706, 3830,
- 2164, 5089, 2472, 2628, 1004, 2701, 1638, 7113,
- 8101, 4748, 929, 8775, 9272, 1560, 8789, 5664,
- 8258, 9613, 5486, 4613, 9863, 9005, 5112, 1799,
- 4345, 8645, 570, 9967, 6500, 832, 8592, 838,
- 9031, 7856, 5907, 381, 2763, 8153, 8398, 995,
- 5801, 6346, 1214, 5007, 5316, 6928, 416, 4825,
- 5944, 1297, 7549, 1499, 839, 1928, 5878, 5745,
- 3272, 2572, 5248, 1460, 3905, 4288, 6818, 2388,
- 7859, 9256, 1185, 2181, 3363, 8050, 8380, 9891,
- 439, 5568, 8003, 5852, 1229, 9602, 7847, 5969,
- 9057, 5525, 970, 1188, 372, 4928, 2344, 9662,
- 9190, 1151, 8943, 5226, 1228, 2502, 8609, 9922,
- 8201, 8724, 7651, 4046, 9691, 9904, 1535, 8250,
- 4015, 5963, 9786, 6581, 8264, 4230, 7914, 2186,
- 9235, 6295, 4350, 2794, 3271, 3552, 7515, 6223,
- 2140, 4314, 2250, 1975, 627, 4462, 5690, 3413,
- 3619, 4409, 8546, 2810, 6451, 8042, 6981, 5847,
- 6670, 8620, 6057, 2985, 520, 3854, 5227, 9175,
- 7632, 2479, 2790, 9594, 8713, 9800, 6204, 804,
- 8244, 513, 650, 8472, 3103, 8833, 3041, 1162,
- 1267, 7884, 8114, 5632, 7241, 3921, 9695, 2345,
- 756, 9724, 9477, 2820, 7004, 2987, 1515, 6371,
- 7318, 7495, 8174, 1492, 1502, 2107, 9841, 9638,
- 7642, 9871, 8621, 6991, 2350, 4862, 9372, 1741,
- 9751, 3844, 4708, 9941, 942, 865, 2781, 5447,
- 15, 528, 3632, 5878, 351, 0, 1393, 8028,
- 4688, 8018, 7552, 5798, 3137, 1883, 241, /* * 10000**758 */
- /* 65536**700 = */ 1376, 4586, 3110, 8109, 813, 2413, 7374, 4459,
- 7631, 8946, 4454, 2451, 688, 5867, 8242, 3361,
- 8832, 4437, 5519, 3061, 364, 4012, 8341, 4231,
- 8360, 5724, 6055, 1955, 7486, 8472, 2328, 9617,
- 1395, 8211, 2562, 3881, 804, 5684, 1580, 5622,
- 253, 2116, 7361, 6279, 8846, 9490, 3076, 6714,
- 859, 4921, 470, 1568, 3914, 3534, 5861, 68,
- 2260, 9838, 1745, 6725, 9675, 3197, 369, 9299,
- 6927, 6882, 1999, 4319, 1994, 6604, 8141, 2440,
- 2345, 7443, 449, 202, 4032, 490, 5338, 8768,
- 7265, 5012, 8672, 5900, 5541, 4891, 6096, 4383,
- 6323, 5870, 1524, 7638, 3400, 6366, 6213, 428,
- 1872, 5107, 6186, 2421, 5576, 1881, 8804, 9572,
- 7734, 3881, 9595, 2628, 7760, 5058, 7924, 5553,
- 5156, 4098, 9186, 269, 8189, 3581, 8233, 6224,
- 2891, 7680, 3446, 8138, 7568, 9843, 8204, 1986,
- 6126, 3468, 9198, 8388, 1316, 8387, 9313, 3728,
- 6889, 9813, 4372, 1967, 8561, 6099, 8106, 4100,
- 5281, 3861, 9375, 9097, 9704, 7224, 1961, 2569,
- 3683, 6468, 2169, 2345, 5718, 8692, 5385, 7056,
- 3147, 1978, 9445, 4762, 5390, 6541, 6663, 8522,
- 8775, 8245, 1022, 4, 7451, 1623, 4426, 5431,
- 2700, 3478, 216, 8713, 9146, 9152, 9543, 2348,
- 201, 5303, 5894, 5551, 3564, 1811, 148, 5018,
- 5783, 3415, 2654, 4387, 5930, 7241, 822, 304,
- 5280, 4874, 8619, 3871, 6573, 1810, 8121, 6109,
- 1252, 8884, 9457, 3422, 7107, 4752, 5692, 3659,
- 2111, 406, 6917, 6654, 9902, 5175, 1115, 7073,
- 5448, 9436, 637, 3031, 4610, 2213, 8584, 6608,
- 8221, 6999, 5789, 9499, 119, 4379, 8719, 2495,
- 9433, 5245, 6219, 6585, 1470, 7864, 17, 8133,
- 1623, 4331, 9120, 7601, 2788, 4753, 1113, 3304,
- 9695, 2285, 9289, 9894, 6930, 3596, 3553, 8327,
- 3702, 8520, 952, 6437, 1794, 9348, 2373, 8042,
- 9623, 4687, 852, 7710, 2830, 712, 6949, 4962,
- 7564, 845, 325, 8598, 5915, 7846, 134, 4092,
- 8320, 2594, 3361, 3486, 2148, 3874, 1167, 7721,
- 2997, 4766, 7956, 2990, 3706, 6230, 7158, 2270,
- 7383, 7156, 220, 461, 4389, 6761, 3391, 7669,
- 3533, 4179, 4452, 1983, 96, 4861, 4969, 1955,
- 1730, 5804, 2690, 480, 5521, 8307, 9407, 5267,
- 5224, 5589, 354, 8171, 1931, 9270, 5338, 6469,
- 3134, 2294, 7509, 6092, 7856, 4817, 9694, 9938,
- 1734, 183, 3086, 8839, 1378, 1696, 6749, 5189,
- 6701, 1425, 6429, 2989, 6291, 4557, 2441, 8383,
- 3238, 4712, 9405, 2934, 2351, 5480, 7183, 2544,
- 7983, 7358, 4167, 1710, 3735, 3718, 8737, 7750,
- 2985, 1040, 7766, 2755, 6766, 6331, 9095, 6047,
- 5580, 5501, 6305, 1682, 9474, 461, 3990, 4426,
- 8734, 2562, 3942, 9748, 6939, 150, 6359, 7682,
- 3379, 1328, 8128, 5972, 6892, 4860, 2107, 3330,
- 3704, 1205, 115, 5648, 8256, 3308, 374, 9011,
- 8758, 5046, 5154, 5092, 5698, 6810, 7156, 9533,
- 3113, 3809, 4000, 4964, 7395, 6816, 1282, 9606,
- 9471, 9830, 9937, 3567, 8703, 2376, 6893, 5218,
- 7293, 3215, 3398, 8549, 2494, 1587, 3804, 2858,
- 9019, 5968, 7835, 5821, 7483, 7121, 544, 9024,
- 8399, 7510, 4571, 2094, 3538, 1577, 7130, 5822,
- 1996, 1483, 1700, 5527, 570, 791, 2578, 3080,
- 4903, 4771, 7320, 1545, 9454, 7539, 4331, 3864,
- 9802, 6872, 8528, 3996, 7125, 5732, 9571, 790,
- 7470, 9665, 219, 7307, 2199, 2311, 8669, 5264,
- 8130, 5497, 6322, 7105, 571, 2920, 8273, 7186,
- 9789, 3904, 5074, 2746, 1540, 9054, 395, 3472,
- 3313, 2272, 5600, 1972, 5374, 5315, 7487, 3887,
- 8919, 1379, 4867, 9911, 159, 1775, 2502, 5278,
- 8189, 1751, 649, 4827, 5636, 5922, 8085, 7978,
- 3876, 953, 91, 5265, 586, 8369, 1331, 3073,
- 5441, 2656, 756, 3750, 5065, 3432, 5601, 2925,
- 4324, 3109, 1584, 4244, 9847, 6788, 5544, 6780,
- 875, 2974, 1407, 5026, 2485, 3708, 2179, 5846,
- 6041, 6243, 9491, 4441, 8586, 1275, 6189, 8674,
- 40, 4704, 5642, 9795, 88, 3425, 6010, 8541,
- 5143, 7969, 9303, 6803, 2653, 5277, 1220, 2598,
- 1511, 617, 5980, 8438, 428, 2439, 9102, 4813,
- 534, 1182, 9186, 8299, 9546, 6675, 1047, 6804,
- 1680, 2682, 3261, 8008, 6770, 7586, 2977, 4414,
- 9460, 434, 7519, 615, 9068, 5178, 7915, 2666,
- 3944, 4924, 7855, 2223, 8572, 5298, 1552, 8389,
- 4271, 7406, 6363, 7646, 8398, 8160, 2069, 539,
- 5033, 7604, 1436, 5275, 482, 4351, 9141, 7999,
- 6490, 1856, 3788, 4972, 5139, 4359, 6807, 1250,
- 8357, 3359, 3649, 6754, 7053, 8789, 3562, 3793,
- 4146, 60, 5998, 7979, 8575, 592, 4584, 4106,
- 3404, 7617, 6881, 2697, 3152, 8488, 6329, 3043,
- 6970, 9232, 1885, 3130, 4859, 6188, 3885, 1044,
- 822, 8498, 6408, 1921, 6737, 8743, 431, 6405,
- 7340, 7105, 1238, 6695, 9100, 4467, 5128, 4391,
- 4528, 5406, 1064, 8420, 754, 3135, 359, 634,
- 5146, 7439, 1807, 1138, 5941, 52, 1554, 8214,
- 8509, 3041, 4027, 4222, 1102, 2485, 3258, 3872,
- 7554, 6844, 3183, 3660, 6015, 2150, 1179, 4086,
- 3006, 5648, 1070, 7839, 9394, 417, 4476, 5914,
- 3153, 8151, 8754, 4566, 7354, 2266, 2595, 9675,
- 9849, 2561, 3843, 3783, 4417, 1091, 6860, 7239,
- 776, 8822, 6599, 1796, 4964, 6626, 1710, 4832,
- 1737, 4985, 9724, 500, 8824, 4870, 4557, 3357,
- 2631, 1898, 8659, 6055, 6063, 1360, 3880, 6129,
- 6219, 2248, 3427, 3819, 9834, 529, 8694, 5071,
- 4713, 9682, 7120, 1400, 1385, 3033, 9416, 7959,
- 232, 7154, 1288, 5060, 4686, 6550, 9634, 4993,
- 3244, 3205, 2668, 4768, 7732, 5099, 1453, 8980,
- 281, 144, 5597, 4066, 5746, 2220, 2838, 9818,
- 910, 3708, 5565, 8463, 8273, 2742, 3946, 304,
- 6406, 1028, 9203, 2140, 3691, 2406, 1882, 426,
- 2922, 1953, 3435, /* * 10000**842 */
- /* 65536**770 = */ 6576, 245, 6356, 5875, 2422, 9666, 6333, 951,
- 150, 2145, 7477, 5966, 1410, 2763, 307, 9452,
- 5802, 5729, 1339, 3258, 2063, 9970, 6176, 1754,
- 4757, 3297, 966, 8543, 8894, 117, 6213, 2274,
- 4313, 8739, 3420, 691, 5977, 4505, 2536, 2997,
- 3881, 3568, 1510, 5728, 6781, 9126, 7767, 1593,
- 9017, 7864, 1976, 3746, 7862, 5273, 5257, 3301,
- 8551, 2783, 2395, 7645, 315, 6447, 7429, 2440,
- 943, 3567, 1927, 4649, 8911, 9014, 7172, 1994,
- 6157, 4143, 8757, 2551, 3648, 9689, 5687, 6387,
- 9358, 3878, 3632, 3984, 7237, 2547, 9700, 993,
- 2278, 5799, 2100, 1748, 7385, 9669, 7791, 8150,
- 6319, 2225, 9870, 9690, 884, 2677, 3804, 2903,
- 2175, 5452, 7358, 8961, 7445, 515, 9507, 2931,
- 7139, 9066, 276, 3657, 4963, 1907, 2044, 603,
- 5124, 7175, 7031, 7712, 4449, 9865, 5262, 5849,
- 9041, 3705, 6218, 4092, 1255, 2007, 9678, 3624,
- 5180, 3538, 8771, 8142, 5087, 8757, 6817, 3082,
- 3769, 7244, 4883, 4619, 4167, 1699, 9115, 9182,
- 1348, 2906, 6991, 5382, 3461, 8628, 7028, 9325,
- 3587, 7188, 4383, 9966, 7798, 105, 2955, 7538,
- 2950, 3988, 9142, 6793, 5340, 3555, 1117, 5218,
- 6349, 7006, 3785, 9480, 9839, 4795, 7464, 9682,
- 7006, 4058, 4110, 4069, 1190, 4288, 2430, 8454,
- 3076, 1395, 6594, 9163, 7479, 8065, 4755, 4874,
- 647, 6200, 3270, 4761, 1485, 8860, 4861, 2395,
- 1448, 8327, 776, 9899, 8277, 9220, 3382, 2782,
- 3123, 5194, 3714, 4997, 1538, 2611, 9158, 9311,
- 8857, 2483, 4214, 3062, 4880, 7846, 8772, 8092,
- 3695, 7541, 9097, 667, 7806, 5727, 2261, 5090,
- 5471, 9091, 3406, 422, 3994, 6902, 5228, 1216,
- 1965, 375, 2757, 996, 4155, 1371, 5076, 7668,
- 940, 2295, 8732, 9059, 8808, 6358, 2737, 8179,
- 5344, 4418, 7027, 3631, 7129, 1789, 96, 7192,
- 1246, 891, 8740, 2336, 4936, 2213, 1414, 7793,
- 3041, 8231, 6528, 7078, 299, 7293, 1683, 8208,
- 8097, 1670, 6643, 7366, 5146, 9629, 9972, 2977,
- 9684, 1445, 2334, 7490, 1104, 6613, 6778, 2262,
- 517, 4530, 4411, 8052, 2891, 5782, 3582, 7797,
- 2650, 7112, 9324, 6077, 1036, 217, 980, 5753,
- 9082, 1275, 6766, 2989, 6223, 2611, 2289, 9995,
- 0, 7007, 3794, 3507, 9401, 7170, 8065, 7505,
- 5429, 8108, 57, 4816, 6308, 795, 5172, 9799,
- 514, 8369, 6605, 2125, 8482, 4855, 5695, 7116,
- 2726, 6596, 5449, 1018, 7187, 8663, 6383, 5434,
- 5472, 111, 1133, 7483, 572, 2642, 7374, 3672,
- 6578, 1601, 5038, 1935, 8108, 8112, 219, 5137,
- 9883, 1208, 4391, 872, 4997, 9658, 6156, 4152,
- 247, 7022, 1720, 3435, 3669, 892, 3328, 3906,
- 9750, 9679, 3130, 1096, 2598, 8077, 5644, 9251,
- 4790, 7079, 4824, 248, 6992, 13, 4271, 385,
- 2690, 2875, 7987, 6637, 9248, 6579, 9888, 4147,
- 5376, 4578, 8170, 9261, 7266, 9739, 5526, 3243,
- 1271, 6280, 134, 2294, 1169, 6079, 629, 2541,
- 571, 1074, 4067, 6219, 6141, 4059, 7791, 6269,
- 4370, 504, 2106, 4204, 12, 396, 8296, 6851,
- 5299, 1980, 2205, 6099, 7526, 8617, 1275, 7304,
- 4306, 3079, 7189, 7371, 5846, 1884, 1101, 8229,
- 73, 4440, 531, 5649, 4927, 9063, 6529, 6352,
- 1199, 4855, 1212, 9365, 1939, 4630, 8322, 1252,
- 9242, 2296, 6277, 3508, 6969, 8655, 5338, 8780,
- 7263, 603, 9464, 7296, 5563, 9966, 3937, 7009,
- 529, 8557, 2752, 5988, 9040, 1872, 541, 8295,
- 4144, 2418, 3603, 269, 8858, 9362, 2376, 1882,
- 225, 7448, 2381, 1931, 426, 2059, 3337, 7981,
- 6221, 8665, 5603, 2085, 651, 6853, 1798, 5910,
- 8799, 3888, 1917, 5075, 7299, 2087, 4433, 5613,
- 437, 8893, 3374, 5536, 8180, 2413, 3805, 4782,
- 5355, 7634, 833, 828, 4318, 6069, 1943, 6953,
- 3331, 9719, 1055, 7989, 8882, 7868, 3167, 1941,
- 5715, 9354, 8646, 6553, 8643, 2581, 3241, 6665,
- 3936, 5677, 776, 8961, 2596, 1404, 8448, 3466,
- 8374, 6407, 9540, 3608, 8614, 6021, 573, 949,
- 8416, 7147, 8621, 2691, 6429, 8691, 7634, 772,
- 89, 2786, 7169, 6823, 9486, 7807, 1554, 1429,
- 8278, 3688, 5352, 4658, 8852, 9013, 9163, 5624,
- 2363, 8992, 7480, 9099, 5429, 8079, 1235, 1177,
- 8441, 9443, 8841, 1526, 899, 4690, 7947, 9598,
- 210, 8061, 5363, 8632, 8660, 3791, 7135, 5744,
- 3939, 5190, 4819, 8291, 1515, 7886, 3114, 6952,
- 2498, 5758, 245, 1104, 6047, 2056, 3379, 7991,
- 6993, 7720, 1746, 4440, 7800, 3194, 2512, 4296,
- 3072, 8662, 1929, 7680, 4080, 4999, 7253, 6706,
- 65, 8144, 5567, 3131, 3500, 8032, 3210, 8721,
- 9733, 246, 3335, 8139, 2564, 2307, 5130, 7685,
- 6143, 2690, 4963, 9028, 3967, 8385, 6454, 3020,
- 3844, 1893, 2889, 5541, 8504, 374, 7689, 2068,
- 4199, 6632, 6003, 4161, 7427, 5366, 3837, 7481,
- 4184, 4059, 6669, 2982, 6572, 7942, 6892, 3090,
- 9143, 4052, 988, 8996, 7508, 2430, 3054, 6349,
- 4014, 4949, 6171, 2648, 9933, 1038, 3046, 8955,
- 3754, 4123, 3175, 3938, 2682, 3831, 9513, 1213,
- 394, 783, 5094, 8043, 4966, 3131, 6018, 9166,
- 7031, 7139, 5518, 4981, 5179, 8622, 2757, 9262,
- 3635, 2899, 5093, 9238, 8975, 2374, 4244, 8814,
- 31, 6851, 2453, 7638, 528, 6045, 3521, 4686,
- 5415, 6689, 4342, 4629, 1928, 2182, 968, 3344,
- 7654, 6088, 5259, 9531, 2122, 8346, 4173, 735,
- 9159, 4533, 7493, 6745, 2635, 6334, 7907, 7916,
- 2572, 478, 8063, 2679, 4777, 1168, 5397, 5514,
- 1663, 2579, 6615, 1964, 8593, 5498, 6036, 7463,
- 8815, 1208, 5069, 5234, 609, 8966, 4552, 1157,
- 2099, 44, 1001, 9393, 8254, 196, 1517, 113,
- 3557, 5894, 6684, 6020, 2640, 3565, 672, 5834,
- 8844, 3245, 3912, 4242, 480, 3940, 3700, 9274,
- 4416, 2558, 4846, 4828, 5599, 9101, 6419, 1439,
- 5164, 5219, 3056, 2619, 5510, 7513, 2339, 2952,
- 7539, 2728, 6880, 2140, 406, 3032, 5314, 2592,
- 6889, 4490, 2748, 8871, 3996, 3202, 6519, 2460,
- 7927, 8324, 2242, 7373, 9534, 7626, 7641, 4965,
- 3972, 5369, 3904, 2053, 8744, 8630, 124, 1431,
- 1643, 5368, 7730, 1757, 2613, 7414, 225, 9158,
- 7726, 197, 2648, 9531, 7062, 2318, 8972, 433,
- 458, 7883, 8832, 2662, 3314, 8091, 6748, 5703,
- 5124, 7447, 8008, 9237, 6696, 7880, 28, 8663,
- 525, 2906, 7521, 2442, 7245, 7738, 8926, 4,
- /* * 10000**927 */
- /* 65536**840 = */ 1776, 4209, 107, 8907, 5829, 8291, 3792, 7140,
- 8690, 5729, 1980, 8333, 6343, 4729, 4891, 6613,
- 1876, 7120, 2857, 4433, 4445, 5275, 7171, 48,
- 9321, 7844, 7123, 2851, 7177, 8795, 9744, 9639,
- 2481, 2561, 4398, 8938, 6005, 3603, 9539, 4851,
- 6380, 6376, 5478, 9062, 2258, 8093, 4242, 3610,
- 6371, 1120, 9049, 432, 8580, 9844, 443, 4598,
- 4973, 845, 5958, 5061, 7948, 9512, 9145, 8386,
- 7212, 126, 1672, 1176, 9349, 4654, 4602, 814,
- 7191, 2008, 4459, 5745, 7526, 646, 5999, 9963,
- 8550, 9791, 7786, 277, 6598, 7600, 901, 3352,
- 8074, 3157, 3661, 6470, 905, 3657, 4173, 4804,
- 6683, 9857, 4353, 1123, 8293, 669, 6879, 594,
- 353, 1428, 3387, 5667, 8085, 1175, 4243, 393,
- 6238, 449, 5931, 3907, 1424, 3236, 205, 3023,
- 6171, 188, 7723, 9095, 1359, 1890, 1791, 8386,
- 444, 162, 2509, 3757, 3354, 2757, 231, 6664,
- 6929, 6426, 9025, 937, 1175, 7815, 5138, 5412,
- 9050, 8921, 9895, 949, 2682, 909, 9622, 5279,
- 1797, 7274, 4291, 3764, 3575, 9282, 6469, 2980,
- 3245, 4850, 6847, 3690, 5293, 5479, 8362, 264,
- 8983, 2738, 1503, 6814, 1557, 2719, 9253, 5235,
- 9351, 1013, 8631, 7562, 7326, 2565, 5343, 3416,
- 3876, 2749, 5448, 9776, 3548, 2345, 8095, 5557,
- 5994, 1001, 201, 6028, 4903, 5273, 4875, 3387,
- 9854, 5952, 8239, 532, 4892, 4540, 9787, 1357,
- 2935, 7540, 7254, 295, 3020, 4145, 9693, 3272,
- 4423, 6528, 7824, 9108, 8383, 6625, 3156, 5428,
- 8091, 1867, 6682, 7034, 7554, 883, 4275, 763,
- 4093, 692, 7649, 4523, 2587, 8443, 2065, 5289,
- 9385, 6198, 7308, 5388, 4113, 3746, 2214, 4397,
- 4402, 6210, 4346, 199, 1021, 9899, 5375, 5990,
- 9027, 7089, 3338, 5270, 1537, 9622, 1888, 1494,
- 9477, 8020, 3438, 4614, 5382, 9984, 8216, 4446,
- 3556, 3442, 1354, 3210, 5823, 5800, 6798, 3366,
- 2968, 1726, 7017, 5620, 5685, 7769, 1878, 7500,
- 6906, 3901, 6414, 5479, 2752, 711, 1004, 8708,
- 4338, 9854, 8760, 1031, 3150, 743, 967, 684,
- 7982, 5422, 6089, 7801, 1017, 3190, 1700, 5919,
- 5483, 6599, 7922, 2498, 3262, 4877, 2088, 1374,
- 4022, 8151, 1697, 2456, 6997, 7997, 7193, 4662,
- 7068, 6463, 3470, 8660, 3199, 7435, 5453, 1076,
- 419, 2619, 1406, 6533, 9911, 5996, 9877, 4978,
- 7672, 1304, 822, 4811, 7474, 9591, 1426, 9125,
- 9955, 1525, 5834, 5706, 5982, 3518, 5423, 6252,
- 1064, 2787, 605, 1021, 4464, 1705, 4838, 9614,
- 319, 2323, 8396, 3547, 53, 6057, 9843, 4142,
- 9535, 8053, 2223, 5879, 8446, 8236, 5036, 8137,
- 9073, 2448, 8498, 6342, 6345, 9231, 4639, 9982,
- 1217, 5858, 1892, 9155, 8981, 1331, 5526, 8429,
- 7349, 9100, 8885, 3800, 9082, 5906, 8711, 8499,
- 5398, 2333, 2499, 1358, 5396, 4550, 5870, 8484,
- 5564, 9294, 9792, 6786, 1836, 6702, 1679, 9666,
- 135, 7422, 5626, 6295, 7828, 7080, 3345, 185,
- 3703, 6082, 2495, 8876, 5184, 3822, 7532, 8564,
- 2685, 1624, 5515, 9775, 308, 9383, 8733, 3077,
- 7284, 7302, 35, 9581, 4927, 7462, 4845, 3331,
- 5693, 4714, 8522, 2192, 964, 8033, 2145, 732,
- 5792, 9066, 856, 2601, 577, 8527, 5526, 5967,
- 8391, 3060, 4344, 853, 3311, 6918, 8370, 5791,
- 6755, 9258, 1964, 3862, 7326, 2755, 1576, 1675,
- 119, 386, 2571, 8189, 3370, 701, 3281, 710,
- 8885, 6139, 9961, 8922, 8174, 8375, 6138, 9847,
- 4854, 5777, 8551, 7930, 7401, 3457, 3143, 1508,
- 5753, 3694, 5993, 5228, 5480, 2515, 6763, 8335,
- 9088, 4979, 7987, 5760, 3039, 5766, 5868, 1932,
- 3435, 8274, 1667, 8305, 9678, 5741, 5193, 9322,
- 9946, 2433, 928, 3582, 8437, 5169, 7521, 9860,
- 9741, 840, 26, 7364, 2620, 7373, 1114, 7601,
- 7048, 5289, 8616, 2816, 9703, 3595, 2060, 5086,
- 2673, 3530, 1359, 1861, 4220, 3700, 899, 1352,
- 5551, 1020, 5759, 8483, 992, 8250, 9411, 3180,
- 6634, 856, 6254, 6194, 3917, 9296, 9035, 2348,
- 9174, 7872, 3374, 8845, 3908, 3210, 8206, 3901,
- 1083, 2442, 6626, 7538, 1519, 2002, 5375, 1211,
- 4597, 1027, 8913, 2970, 5316, 2039, 3828, 9530,
- 8672, 1290, 6243, 8398, 7670, 584, 8554, 9782,
- 4689, 2322, 3891, 5570, 2441, 3620, 2995, 7453,
- 7493, 7524, 9193, 1840, 8562, 7087, 8880, 1692,
- 9390, 2120, 6310, 1186, 3800, 4528, 2717, 3715,
- 4188, 848, 3877, 973, 8688, 171, 3610, 1814,
- 4226, 8168, 4374, 640, 1652, 9149, 1983, 7776,
- 5724, 8085, 7642, 4732, 4416, 6266, 5192, 6489,
- 4151, 5721, 1778, 2708, 6310, 8698, 8896, 1888,
- 8171, 3950, 4756, 4292, 2005, 4487, 6940, 3027,
- 8680, 4280, 8169, 7400, 8615, 848, 4686, 4370,
- 1307, 1776, 7336, 6208, 5860, 6436, 695, 2444,
- 2655, 2326, 4144, 5741, 3920, 5873, 4979, 7768,
- 5503, 7203, 2283, 7788, 2037, 9131, 2916, 8724,
- 4754, 8308, 2395, 6739, 485, 8073, 7861, 1191,
- 981, 1998, 4277, 2306, 5509, 2861, 676, 5039,
- 4515, 6900, 2085, 7407, 2948, 4810, 7243, 8107,
- 6124, 3955, 3517, 1027, 1467, 8102, 4121, 3754,
- 9510, 2956, 3027, 944, 8889, 8388, 2269, 8781,
- 8941, 503, 1588, 7452, 9731, 7045, 9086, 8895,
- 90, 3144, 5569, 1415, 3996, 8866, 4640, 3533,
- 3634, 4686, 8961, 5342, 8259, 8604, 9081, 9368,
- 7927, 6117, 7509, 8903, 3256, 7008, 3099, 3508,
- 3273, 9709, 9373, 1374, 8944, 3639, 8505, 4042,
- 12, 530, 9273, 4801, 761, 4913, 6606, 6739,
- 5605, 5637, 719, 6984, 1130, 1078, 8796, 4411,
- 7204, 8668, 5225, 1596, 8800, 8083, 5620, 910,
- 8022, 8753, 5414, 3163, 9797, 2492, 2109, 9440,
- 9737, 3659, 2952, 913, 4297, 3855, 6891, 6867,
- 5392, 9757, 9361, 4312, 5415, 3533, 5994, 513,
- 3224, 3486, 346, 4150, 2752, 5895, 3247, 2275,
- 5137, 5424, 6854, 9918, 2273, 7434, 6655, 2269,
- 9720, 3915, 9785, 8604, 3799, 6065, 4070, 2204,
- 2145, 4721, 6743, 8533, 4504, 4512, 8547, 8199,
- 8506, 3184, 2829, 8578, 5963, 9629, 3319, 1411,
- 784, 9160, 3925, 2117, 8216, 8156, 5230, 1021,
- 8468, 9979, 199, 6132, 4556, 3388, 4447, 1503,
- 9203, 4028, 4633, 4537, 9846, 7104, 966, 9786,
- 2402, 6280, 8393, 3514, 3675, 5066, 45, 5484,
- 8185, 6376, 6151, 3773, 8101, 8363, 7257, 2164,
- 3548, 1215, 4667, 559, 511, 5707, 5787, 7552,
- 6589, 8935, 2179, 1088, 2297, 2033, 1133, 574,
- 8896, 3265, 2681, 3424, 2090, 7972, 4505, 1357,
- 7108, 8543, 9500, 3580, 1116, 5400, 236, 7512,
- 4229, 8918, 1198, 544, 6951, 1621, 3290, 8406,
- 6135, 1400, 78, 9094, 1289, 9849, 4254, 3557,
- 696, 483, 5400, 2399, 2703, 409, 1518, 1043,
- 8505, 1877, 6060, 3483, 9219, 914, 4416, 2185,
- 6440, 7397, 2019, 4889, 9143, 6834, 3063, 8356,
- 3821, 7035, 1972, 8312, 1494, 4774, 9537, 8837,
- 5645, 2248, 9105, 2307, 8597, 8588, 1190, 7930,
- 8253, 8822, 6853, 69, /* * 10000**1011 */
- /* 65536**910 = */ 6976, 7276, 8858, 1221, 9753, 5084, 4453, 1746,
- 2564, 5306, 1580, 9569, 1433, 6440, 9350, 1312,
- 163, 2607, 7092, 9083, 4624, 8203, 8919, 7749,
- 3440, 6823, 6182, 2031, 7548, 5547, 4636, 5050,
- 5758, 7923, 4655, 1010, 9987, 772, 7430, 7397,
- 8813, 2398, 8251, 2488, 2603, 118, 1294, 227,
- 9376, 9951, 3868, 1075, 5311, 7911, 4461, 8224,
- 274, 2903, 9270, 3359, 2746, 3671, 2503, 7591,
- 6718, 4357, 8995, 4873, 2301, 2009, 7763, 4513,
- 4937, 3992, 1217, 3614, 7118, 5669, 5378, 1265,
- 1379, 7102, 7925, 1319, 1768, 3234, 8757, 2335,
- 3113, 1722, 6896, 563, 7461, 4313, 9102, 1117,
- 9118, 9666, 6719, 1369, 4573, 3534, 3090, 3498,
- 7834, 2943, 8466, 9411, 6501, 9251, 2604, 892,
- 466, 4658, 6553, 3949, 377, 2602, 284, 99,
- 2675, 9445, 2191, 5520, 5423, 3134, 7131, 8653,
- 4866, 284, 5986, 9313, 3557, 1286, 1602, 1116,
- 2596, 5249, 6799, 8663, 1549, 7218, 8045, 5368,
- 8620, 85, 8305, 8144, 6653, 4913, 796, 5668,
- 471, 8853, 7640, 5428, 3341, 4658, 7712, 5801,
- 3405, 3699, 207, 6821, 3089, 3959, 5917, 1322,
- 7214, 438, 7617, 1547, 4391, 183, 4965, 5172,
- 8933, 4752, 479, 9733, 950, 7810, 5681, 3581,
- 4162, 4049, 3572, 3884, 1211, 7627, 6099, 4410,
- 7572, 7868, 229, 3452, 1679, 6516, 782, 9064,
- 5097, 4056, 5308, 424, 847, 8447, 1214, 4563,
- 763, 7166, 8506, 1912, 4796, 2775, 3847, 35,
- 5471, 2069, 3525, 3321, 4709, 8304, 3015, 3633,
- 1027, 9475, 4081, 15, 9395, 7495, 5293, 1385,
- 707, 4543, 4533, 15, 2282, 6080, 6456, 7843,
- 8776, 2104, 5874, 3666, 3846, 6178, 7517, 9013,
- 1282, 5177, 3730, 5068, 2562, 1258, 266, 4640,
- 9320, 2217, 1078, 8299, 3147, 5444, 2258, 6110,
- 5603, 4852, 4268, 8378, 1360, 7766, 3834, 2833,
- 2966, 498, 1814, 5324, 8535, 3968, 4782, 6038,
- 5348, 5378, 8407, 7004, 3934, 5886, 6509, 4476,
- 2518, 942, 387, 7880, 310, 2194, 789, 9524,
- 3994, 6498, 4676, 2194, 7029, 1471, 7694, 9214,
- 4989, 807, 9958, 2955, 1408, 9697, 9369, 4043,
- 690, 8441, 3288, 8437, 1376, 4984, 1291, 8808,
- 8585, 9792, 8599, 7985, 2883, 8551, 9600, 8612,
- 8145, 8093, 5364, 7581, 6825, 892, 9161, 7353,
- 5283, 6962, 4767, 4665, 8637, 8511, 8351, 9611,
- 3276, 9081, 4325, 3128, 7232, 9014, 9828, 7083,
- 2200, 3406, 4976, 3646, 4736, 5100, 1263, 7919,
- 1368, 83, 7397, 8019, 626, 1181, 8554, 9738,
- 9409, 5766, 9788, 6858, 6925, 6625, 9783, 5868,
- 6651, 3983, 8582, 2528, 9149, 186, 7976, 295,
- 4158, 4110, 3783, 1155, 1983, 4097, 2663, 3665,
- 5049, 8310, 2361, 5778, 8997, 1458, 2437, 3930,
- 1459, 3258, 8915, 5745, 9011, 1080, 8782, 2896,
- 4877, 3522, 7368, 8059, 9387, 4871, 3417, 9118,
- 6149, 5578, 2863, 325, 4461, 7766, 3619, 6858,
- 6849, 1017, 9989, 7450, 1635, 5741, 6046, 8153,
- 1705, 7337, 1343, 4508, 2940, 2177, 8291, 3668,
- 3988, 7230, 9741, 9276, 1492, 9060, 5831, 1915,
- 4323, 3327, 5156, 7634, 5667, 93, 1615, 7146,
- 384, 1403, 7450, 648, 397, 3380, 8248, 1488,
- 8379, 2229, 9203, 481, 9153, 8241, 705, 9533,
- 7505, 3015, 9070, 125, 4603, 8425, 5131, 8879,
- 2839, 4140, 6128, 5688, 1555, 2700, 6136, 9704,
- 8254, 4678, 981, 264, 9401, 7255, 3538, 8116,
- 2324, 280, 7020, 4111, 5298, 9315, 3155, 4012,
- 8476, 2668, 2959, 543, 8033, 1389, 3592, 5881,
- 3970, 1845, 1091, 1032, 5505, 9360, 7060, 667,
- 6498, 9986, 6028, 6059, 2489, 6376, 6771, 8583,
- 4217, 3978, 6537, 2508, 9228, 9830, 2933, 2459,
- 8427, 1706, 8995, 5630, 4841, 5215, 6392, 6342,
- 5770, 4998, 9239, 6236, 9028, 5774, 6114, 3192,
- 5621, 2678, 2250, 3881, 2567, 9124, 9573, 1676,
- 2312, 1368, 6964, 3234, 4195, 9740, 5063, 9313,
- 8299, 611, 4657, 6404, 1343, 7887, 8822, 8197,
- 5746, 7804, 5463, 2033, 3102, 6063, 2280, 6637,
- 1051, 2474, 4788, 2287, 7937, 9814, 3499, 7309,
- 1637, 7193, 6908, 5451, 3257, 2935, 3737, 3206,
- 8537, 9857, 2923, 667, 1218, 3142, 9336, 5960,
- 8995, 7527, 2049, 7522, 8223, 5862, 1222, 9496,
- 2180, 3866, 8448, 6658, 9447, 819, 9613, 5574,
- 9317, 1802, 3131, 3030, 8763, 4072, 4076, 7598,
- 8667, 3937, 1660, 5038, 187, 5592, 840, 8447,
- 9967, 4635, 9237, 7598, 9848, 2653, 3049, 3750,
- 5699, 501, 3604, 2456, 8654, 9459, 3750, 2733,
- 7222, 5883, 5306, 5175, 8727, 2434, 4666, 8910,
- 7732, 2483, 1128, 8416, 8276, 4920, 5230, 732,
- 264, 4622, 4744, 4607, 1765, 7218, 6301, 5284,
- 5847, 9294, 9827, 7152, 5212, 7979, 7615, 346,
- 9431, 9390, 6846, 4592, 3987, 9010, 6105, 7017,
- 2309, 1668, 8732, 7920, 4915, 189, 4196, 2592,
- 6493, 6397, 7470, 8439, 500, 7208, 5090, 7817,
- 3410, 1055, 3293, 8207, 7000, 3912, 627, 465,
- 5905, 6474, 2596, 2542, 778, 300, 5879, 416,
- 4448, 209, 6162, 8063, 3755, 7192, 5775, 3507,
- 2520, 9838, 7927, 343, 7467, 8024, 3848, 1883,
- 5174, 5680, 8899, 7719, 4619, 5499, 6810, 6724,
- 7123, 6290, 1740, 8554, 5207, 1737, 757, 8732,
- 1574, 1745, 1252, 107, 5059, 759, 6479, 2507,
- 9607, 6267, 6763, 9485, 1818, 1684, 8360, 6300,
- 4553, 7822, 2597, 1854, 1975, 4238, 7314, 8224,
- 6705, 8199, 4727, 7715, 2855, 6660, 1739, 3406,
- 6535, 43, 1242, 296, 7753, 2009, 5291, 821,
- 18, 1348, 6704, 5226, 437, 3221, 1962, 4528,
- 1858, 284, 7106, 560, 2332, 416, 6562, 6435,
- 2683, 5055, 1485, 3514, 9627, 1215, 6205, 1477,
- 6555, 4687, 3258, 3747, 9818, 9762, 1986, 7259,
- 28, 2493, 9870, 9052, 1720, 8645, 1800, 5327,
- 7511, 658, 2621, 7002, 8181, 8866, 1088, 5519,
- 209, 1740, 7793, 3014, 1175, 5203, 4023, 6554,
- 2270, 5199, 858, 1103, 1175, 9769, 833, 2917,
- 7007, 2643, 2767, 8226, 4073, 6218, 6074, 1207,
- 6949, 4017, 6636, 5655, 8096, 9055, 2536, 9186,
- 8843, 1363, 5220, 3307, 2440, 6009, 9620, 6050,
- 1115, 4676, 3791, 977, 9909, 7363, 8927, 6256,
- 62, 559, 5329, 6245, 5692, 5519, 2414, 5324,
- 8526, 6190, 9466, 3871, 6430, 5570, 8518, 3076,
- 4532, 8548, 1161, 3916, 9511, 356, 1491, 1877,
- 5183, 6069, 4894, 9405, 3707, 6403, 8855, 6093,
- 6422, 9704, 8695, 3494, 2905, 1988, 3599, 945,
- 635, 4691, 3183, 3024, 9662, 835, 6925, 3011,
- 3908, 2017, 5279, 8224, 4096, 9738, 901, 1320,
- 2166, 1263, 9773, 1622, 5610, 5924, 4911, 7663,
- 5610, 524, 6658, 5441, 179, 749, 4203, 4005,
- 5667, 9337, 33, 8313, 262, 2359, 9623, 8540,
- 7893, 8663, 7047, 8786, 4550, 3678, 3447, 1408,
- 7314, 8285, 3199, 1835, 5737, 7556, 7294, 8703,
- 8128, 9057, 8403, 4123, 6700, 6751, 1483, 9449,
- 473, 4244, 8907, 6359, 5562, 1974, 3050, 8446,
- 8917, 251, 6614, 7901, 1243, 9635, 3181, 8615,
- 5248, 5140, 9350, 5142, 76, 6633, 8022, 4730,
- 1918, 6607, 7956, 7681, 8077, 1116, 271, 5575,
- 3878, 500, 2472, 7001, 5866, 7249, 1797, 9779,
- 6083, 6938, 6244, 6041, 5725, 4592, 9808, 346,
- 7514, 8583, 4325, 4357, 2303, 7553, 2057, 7873,
- 731, 3634, 4935, 6612, 993, 341, 4071, 9185,
- 9884, 4686, 1924, 487, 2122, 3551, 8157, 4261,
- 5804, 9007, 3999, 7058, 2929, 3813, 6266, 9248,
- 3732, 7720, 2932, 4846, 9009, 5513, 386, 5866,
- 6709, 1187, 3069, 5947, 1009, 1673, 5145, 992,
- /* * 10000**1095 */
- /* 65536**980 = */ 2176, 248, 1520, 1891, 317, 4171, 757, 8470,
- 652, 7083, 8338, 6493, 4307, 8339, 1485, 8274,
- 9486, 5402, 7939, 165, 7113, 9646, 2927, 6165,
- 5955, 9620, 9187, 4373, 6839, 1506, 6488, 8229,
- 4865, 6749, 5419, 1020, 7004, 8972, 3246, 7404,
- 935, 2842, 1856, 9433, 2067, 6350, 9296, 492,
- 9336, 8036, 7456, 4970, 3370, 6744, 9291, 1339,
- 3023, 9520, 6938, 491, 7452, 8359, 9349, 6900,
- 9125, 4234, 4245, 4886, 8311, 2065, 9189, 8952,
- 303, 5958, 7274, 6088, 2313, 4527, 7803, 2173,
- 3259, 8336, 7826, 2669, 367, 1056, 4270, 5660,
- 9691, 4897, 3869, 7976, 41, 1111, 2781, 7089,
- 4609, 8652, 164, 7944, 9031, 1555, 5491, 3585,
- 2999, 3852, 8420, 7772, 969, 8120, 5102, 4406,
- 1136, 1437, 3008, 2149, 599, 7074, 9892, 5579,
- 9743, 5835, 8891, 5006, 5570, 2243, 384, 6609,
- 1133, 7279, 8904, 2863, 3066, 2014, 8748, 4461,
- 2650, 1866, 288, 6998, 5516, 3897, 1166, 9797,
- 8531, 8250, 7831, 3696, 870, 7023, 389, 7558,
- 1999, 8258, 2046, 7513, 2811, 8238, 1173, 5128,
- 122, 4675, 7237, 8182, 9434, 3240, 8220, 7546,
- 8358, 9730, 9714, 8782, 2992, 8324, 9009, 9726,
- 7008, 9997, 5661, 2033, 1192, 761, 4021, 7857,
- 8964, 6300, 3078, 4631, 3885, 8829, 5412, 8533,
- 4943, 9925, 503, 4646, 296, 8615, 1814, 2856,
- 7475, 6102, 8949, 418, 9540, 2480, 2129, 7414,
- 9899, 4415, 2420, 2374, 8697, 8448, 8389, 7107,
- 1253, 1244, 5943, 7751, 5903, 2021, 1474, 7634,
- 7301, 718, 3185, 8741, 2753, 2589, 7111, 6699,
- 2626, 2326, 3628, 9551, 9923, 2100, 4313, 7508,
- 9937, 857, 1179, 1855, 629, 1816, 5015, 4599,
- 2703, 2364, 5149, 2416, 7588, 8446, 9864, 9747,
- 852, 1958, 6390, 9211, 613, 3992, 2800, 79,
- 6870, 5815, 7821, 8733, 9913, 4655, 3430, 5757,
- 986, 8621, 7406, 8629, 7657, 9176, 9632, 1725,
- 1371, 2317, 8136, 3049, 6937, 4684, 9733, 1710,
- 5797, 5178, 3269, 189, 2095, 3335, 4981, 5396,
- 4385, 4817, 1469, 2289, 4091, 2694, 7790, 8184,
- 3667, 4975, 6886, 9264, 718, 8665, 388, 712,
- 2259, 1874, 3031, 5644, 9660, 8683, 8488, 5076,
- 9643, 9501, 1888, 5081, 1651, 4604, 4374, 8112,
- 2414, 6612, 9929, 6241, 5596, 1128, 2103, 4114,
- 6934, 3602, 1823, 2207, 5530, 2980, 2658, 5633,
- 6674, 7776, 5101, 8530, 1935, 7744, 1424, 8220,
- 8128, 4931, 1355, 7845, 6170, 9867, 6584, 6935,
- 6795, 5163, 7645, 7867, 4345, 344, 1026, 2615,
- 2625, 8149, 5050, 6811, 7299, 8987, 7386, 8553,
- 7549, 2918, 4748, 950, 8418, 2389, 7522, 2261,
- 255, 8942, 7767, 6011, 820, 8949, 5517, 490,
- 5373, 781, 9901, 6177, 3439, 4703, 1761, 5121,
- 7534, 7327, 4637, 4787, 4313, 3097, 3202, 1610,
- 2764, 3750, 4394, 8205, 1931, 1077, 5151, 1179,
- 4549, 5279, 8522, 4711, 3315, 4642, 5964, 6940,
- 6983, 6916, 5068, 9367, 1156, 9702, 6608, 670,
- 195, 1247, 328, 7188, 4002, 5834, 5307, 684,
- 8962, 2762, 7862, 5007, 9687, 9931, 7972, 6337,
- 4225, 5619, 4964, 8533, 6248, 7185, 4312, 6265,
- 5874, 6340, 5018, 6652, 8458, 5872, 770, 554,
- 1302, 4058, 8248, 4358, 4652, 6024, 890, 4875,
- 2705, 5584, 7538, 976, 5571, 360, 1820, 3412,
- 6038, 6315, 9315, 6561, 4197, 4690, 9422, 9752,
- 3733, 7172, 9556, 3042, 4647, 5338, 6505, 5121,
- 2219, 6640, 8273, 1078, 8827, 2091, 623, 6853,
- 6117, 9542, 8504, 5937, 2070, 8902, 4059, 8539,
- 8624, 8109, 4590, 1628, 6268, 9461, 7165, 9491,
- 4033, 4220, 8426, 396, 2679, 1851, 8628, 3905,
- 1106, 4994, 2277, 6769, 4436, 3506, 5218, 8859,
- 7428, 7126, 4193, 6588, 1522, 6658, 2167, 4533,
- 2632, 8226, 468, 5175, 8409, 9024, 9564, 1863,
- 4504, 9182, 2197, 8657, 8529, 1546, 4264, 9014,
- 6824, 106, 5357, 8213, 8963, 3340, 638, 1656,
- 9952, 4541, 1058, 8801, 9759, 2222, 2920, 1735,
- 5882, 321, 1602, 2695, 8764, 2383, 9357, 6416,
- 6598, 2886, 4225, 3840, 2473, 2140, 3062, 7970,
- 8073, 9445, 2112, 8917, 2596, 171, 5587, 524,
- 8222, 6139, 3895, 9767, 2438, 2422, 2005, 5505,
- 4947, 4718, 5294, 2535, 7980, 951, 8984, 1407,
- 1440, 3542, 2134, 3317, 4770, 128, 8450, 1947,
- 1460, 3424, 5633, 2582, 649, 519, 8207, 6121,
- 6139, 9894, 9980, 1710, 9769, 5225, 284, 7703,
- 2624, 8299, 8939, 3596, 6656, 2936, 4770, 147,
- 2739, 1940, 8867, 4694, 9518, 867, 3069, 9403,
- 9348, 2490, 1169, 8508, 853, 8050, 131, 3801,
- 3028, 6506, 5448, 2260, 8910, 5919, 670, 1208,
- 1218, 228, 6106, 2550, 9642, 6253, 1298, 6945,
- 9839, 7653, 3981, 9028, 4597, 4675, 4894, 9260,
- 6700, 9025, 5944, 4541, 5170, 3888, 2026, 1647,
- 8420, 4215, 2651, 1370, 5805, 7668, 9641, 8292,
- 4721, 5231, 8320, 3, 8444, 2102, 1581, 3061,
- 1034, 5466, 910, 9717, 9852, 6767, 317, 2826,
- 4926, 9635, 1398, 9416, 1139, 6713, 1096, 9345,
- 6737, 548, 7124, 4403, 2439, 8806, 9365, 5021,
- 9528, 9613, 6181, 4633, 9610, 2617, 9828, 3195,
- 3306, 9236, 1650, 1103, 5701, 2131, 2941, 5509,
- 5556, 1853, 1247, 2983, 5129, 8837, 2623, 9853,
- 8119, 5778, 9731, 5106, 6842, 7995, 301, 6820,
- 2110, 7373, 8539, 3599, 6848, 5821, 5314, 3069,
- 9753, 5159, 8600, 7729, 5936, 924, 3160, 4973,
- 3849, 5006, 3502, 9551, 5341, 1601, 1092, 433,
- 1572, 5946, 6038, 3545, 5322, 2411, 9889, 7641,
- 8900, 6192, 9858, 1043, 4811, 3308, 7779, 2545,
- 7963, 6558, 74, 8987, 5722, 5026, 2881, 4719,
- 5084, 9274, 5489, 1330, 1686, 9460, 4437, 8446,
- 2075, 4792, 6219, 9685, 612, 5747, 4490, 3931,
- 5705, 3583, 4775, 5449, 1695, 6443, 8344, 8509,
- 9209, 6503, 2965, 6959, 2726, 1628, 296, 2447,
- 1438, 1914, 5386, 8362, 4148, 4979, 9400, 8414,
- 9300, 8354, 7531, 9950, 5125, 8849, 2939, 1847,
- 7962, 1124, 851, 2943, 9872, 5655, 797, 4552,
- 7777, 7723, 8476, 5346, 977, 3644, 9120, 7364,
- 4835, 8669, 9157, 9672, 7818, 8654, 9068, 7482,
- 1642, 6578, 7998, 1898, 9438, 1015, 8315, 7132,
- 1764, 8202, 5622, 1460, 8768, 3457, 111, 8793,
- 6904, 8641, 1212, 6691, 5575, 2788, 7815, 646,
- 3034, 3167, 1541, 3614, 162, 7023, 3217, 8610,
- 4669, 346, 9747, 4128, 7411, 53, 1844, 2454,
- 5512, 4377, 5549, 9197, 2988, 5800, 7230, 6270,
- 9887, 4439, 1073, 2705, 9696, 4646, 7107, 9250,
- 4806, 9598, 6577, 1310, 9339, 8418, 8519, 5917,
- 2358, 1093, 9989, 8004, 3372, 6136, 4321, 4657,
- 6000, 5693, 2462, 3856, 4089, 2522, 6144, 8267,
- 3376, 9923, 9328, 5582, 2740, 8429, 3047, 511,
- 9284, 6246, 5686, 7135, 4976, 1175, 4120, 9157,
- 8525, 7158, 4119, 8361, 1810, 4566, 666, 6241,
- 3896, 4733, 3696, 9610, 5365, 9852, 8767, 1301,
- 5871, 8539, 682, 4994, 1086, 7813, 851, 5979,
- 2648, 3138, 9995, 4591, 263, 5236, 8753, 7364,
- 3999, 461, 2585, 7108, 306, 5152, 2741, 1754,
- 4543, 9288, 1672, 2058, 6221, 4785, 1733, 909,
- 6084, 7208, 7617, 673, 3060, 8661, 4417, 2233,
- 8342, 9571, 6460, 6889, 2706, 3929, 5167, 967,
- 6966, 9916, 6571, 6214, 6145, 9200, 1010, 2198,
- 9079, 2821, 7049, 6905, 8235, 6461, 4953, 8649,
- 905, 407, 9711, 2323, 2666, 2091, 1025, 5391,
- 1241, 6737, 9248, 9298, 8450, 9319, 1462, 9150,
- 1607, 4170, 6541, 7781, 1467, 8420, 5376, 194,
- 6651, 7415, 513, 3578, 2889, 6835, 4776, 4085,
- 538, 8155, 3194, 9467, 2105, 8505, 7369, 4793,
- 4217, 9718, 8891, 3626, 1771, 8721, 116, 5540,
- 7326, 3918, 6894, 8012, 4180, 7138, 5236, 5303,
- 2602, 3564, 9007, 5662, 4729, 6969, 4493, 4929,
- 1502, 5857, 8687, 97, 3912, 4519, 8216, 5498,
- 4214, 8063, 1746, 8592, 9702, 9017, 1531, 1223,
- 4247, 820, 4218, 1186, 3587, 9973, 1734, 1297,
- 8275, 2024, 9920, 6071, 5908, 4298, 895, 3902,
- 2619, 2039, 8559, 2462, 332, 8129, 2696, 7156,
- 5009, 5726, 4366, 8780, 2654, 2723, 4871, 244,
- 1015, 9987, 1781, 4136, 1, /* * 10000**1180 */
-0}; /* end powers of 65536 in base 10000 */
-
-unsigned short _start_big_powers_two[] = {
- 0, 1, 86, 255, 508, 846, 1268, 1774,
- 2365, 3040, 3799, 4642, 5570, 6582, 7678, 8859,
-
-0}; /* end _start_big_powers_two */
diff --git a/usr/src/lib/libbc/libc/gen/common/_crypt.c b/usr/src/lib/libbc/libc/gen/common/_crypt.c
deleted file mode 100644
index 4a4edca281..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_crypt.c
+++ /dev/null
@@ -1,470 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984,1988 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*LINTLIBRARY*/
-/*
- * This program implements the
- * Proposed Federal Information Processing
- * Data Encryption Standard.
- * See Federal Register, March 17, 1975 (40FR12134)
- */
-
-/*
- * Initial permutation,
- */
-static char IP[] = {
- 58,50,42,34,26,18,10, 2,
- 60,52,44,36,28,20,12, 4,
- 62,54,46,38,30,22,14, 6,
- 64,56,48,40,32,24,16, 8,
- 57,49,41,33,25,17, 9, 1,
- 59,51,43,35,27,19,11, 3,
- 61,53,45,37,29,21,13, 5,
- 63,55,47,39,31,23,15, 7,
-};
-
-/*
- * Final permutation, FP = IP^(-1)
- */
-static char FP[] = {
- 40, 8,48,16,56,24,64,32,
- 39, 7,47,15,55,23,63,31,
- 38, 6,46,14,54,22,62,30,
- 37, 5,45,13,53,21,61,29,
- 36, 4,44,12,52,20,60,28,
- 35, 3,43,11,51,19,59,27,
- 34, 2,42,10,50,18,58,26,
- 33, 1,41, 9,49,17,57,25,
-};
-
-/*
- * Permuted-choice 1 from the key bits
- * to yield C and D.
- * Note that bits 8,16... are left out:
- * They are intended for a parity check.
- */
-static char PC1_C[] = {
- 57,49,41,33,25,17, 9,
- 1,58,50,42,34,26,18,
- 10, 2,59,51,43,35,27,
- 19,11, 3,60,52,44,36,
-};
-
-static char PC1_D[] = {
- 63,55,47,39,31,23,15,
- 7,62,54,46,38,30,22,
- 14, 6,61,53,45,37,29,
- 21,13, 5,28,20,12, 4,
-};
-
-/*
- * Sequence of shifts used for the key schedule.
- */
-static char shifts[] = {
- 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1,
-};
-
-/*
- * Permuted-choice 2, to pick out the bits from
- * the CD array that generate the key schedule.
- */
-static char PC2_C[] = {
- 14,17,11,24, 1, 5,
- 3,28,15, 6,21,10,
- 23,19,12, 4,26, 8,
- 16, 7,27,20,13, 2,
-};
-
-static char PC2_D[] = {
- 41,52,31,37,47,55,
- 30,40,51,45,33,48,
- 44,49,39,56,34,53,
- 46,42,50,36,29,32,
-};
-
-static struct _crypt {
- /*
- * The C and D arrays used to calculate the key schedule.
- */
- char _C[28];
- char _D[28];
- /*
- * The key schedule.
- * Generated from the key.
- */
- char _KS[16][48];
- /*
- * The E bit-selection table.
- */
- char _E[48];
- /*
- * The current block, divided into 2 halves.
- */
- char _L[32], _R[32];
- char _tempL[32];
- char _f[32];
- /*
- * The combination of the key and the input, before selection.
- */
- char _preS[48];
- /*
- * Temps for crypt
- */
- char _ablock[66], _iobuf[16];
-} *__crypt;
-#define C (_c->_C)
-#define D (_c->_D)
-#define KS (_c->_KS)
-#define E (_c->_E)
-#define L (_c->_L)
-#define R (_c->_R)
-#define tempL (_c->_tempL)
-#define f (_c->_f)
-#define preS (_c->_preS)
-#define ablock (_c->_ablock)
-#define iobuf (_c->_iobuf)
-
-static void _cryptinit(void);
-
-/*
- * Set up the key schedule from the key.
- */
-
-#ifndef CRYPT
-static
-#endif
-void
-setkey(char *key)
-{
- int i, j, k;
- int t;
- struct _crypt *_c = __crypt;
-
- if (!_c) {
- _cryptinit();
- _c = __crypt;
- }
- /*
- * First, generate C and D by permuting
- * the key. The low order bit of each
- * 8-bit char is not used, so C and D are only 28
- * bits apiece.
- */
- for (i=0; i<28; i++) {
- C[i] = key[PC1_C[i]-1];
- D[i] = key[PC1_D[i]-1];
- }
- /*
- * To generate Ki, rotate C and D according
- * to schedule and pick up a permutation
- * using PC2.
- */
- for (i=0; i<16; i++) {
- /*
- * rotate.
- */
- for (k=0; k<shifts[i]; k++) {
- t = C[0];
- for (j=0; j<28-1; j++)
- C[j] = C[j+1];
- C[27] = t;
- t = D[0];
- for (j=0; j<28-1; j++)
- D[j] = D[j+1];
- D[27] = t;
- }
- /*
- * get Ki. Note C and D are concatenated.
- */
- for (j=0; j<24; j++) {
- KS[i][j] = C[PC2_C[j]-1];
- KS[i][j+24] = D[PC2_D[j]-28-1];
- }
- }
-}
-
-/*
- * The E bit-selection table.
- */
-static char e[] = {
- 32, 1, 2, 3, 4, 5,
- 4, 5, 6, 7, 8, 9,
- 8, 9,10,11,12,13,
- 12,13,14,15,16,17,
- 16,17,18,19,20,21,
- 20,21,22,23,24,25,
- 24,25,26,27,28,29,
- 28,29,30,31,32, 1,
-};
-
-/*
- * The 8 selection functions.
- * For some reason, they give a 0-origin
- * index, unlike everything else.
- */
-static char S[8][64] = {
- 14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
- 0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8,
- 4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0,
- 15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13,
-
- 15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10,
- 3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5,
- 0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15,
- 13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9,
-
- 10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8,
- 13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1,
- 13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7,
- 1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12,
-
- 7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15,
- 13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9,
- 10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4,
- 3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14,
-
- 2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9,
- 14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6,
- 4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14,
- 11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3,
-
- 12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11,
- 10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8,
- 9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6,
- 4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13,
-
- 4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1,
- 13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6,
- 1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2,
- 6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12,
-
- 13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7,
- 1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2,
- 7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8,
- 2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11,
-};
-
-/*
- * P is a permutation on the selected combination
- * of the current L and key.
- */
-static char P[] = {
- 16, 7,20,21,
- 29,12,28,17,
- 1,15,23,26,
- 5,18,31,10,
- 2, 8,24,14,
- 32,27, 3, 9,
- 19,13,30, 6,
- 22,11, 4,25,
-};
-
-
-/*
- * The payoff: encrypt a block.
- */
-
-void
-encrypt(char *block, int edflag)
-{
- int i, ii;
- int t, j, k;
- struct _crypt *_c = __crypt;
-
- if (!_c) {
- _cryptinit();
- _c = __crypt;
- }
- /*
- * First, permute the bits in the input
- */
- for (j=0; j<64; j++)
- L[j] = block[IP[j]-1];
- /*
- * Perform an encryption operation 16 times.
- */
- for (ii=0; ii<16; ii++) {
- /*
- * Set direction
- */
-#ifdef CRYPT
- if (edflag)
- i = 15-ii;
- else
-#endif
- i = ii;
- /*
- * Save the R array,
- * which will be the new L.
- */
- for (j=0; j<32; j++)
- tempL[j] = R[j];
- /*
- * Expand R to 48 bits using the E selector;
- * exclusive-or with the current key bits.
- */
- for (j=0; j<48; j++)
- preS[j] = R[E[j]-1] ^ KS[i][j];
- /*
- * The pre-select bits are now considered
- * in 8 groups of 6 bits each.
- * The 8 selection functions map these
- * 6-bit quantities into 4-bit quantities
- * and the results permuted
- * to make an f(R, K).
- * The indexing into the selection functions
- * is peculiar; it could be simplified by
- * rewriting the tables.
- */
- for (j=0; j<8; j++) {
- t = 6*j;
- k = S[j][(preS[t+0]<<5)+
- (preS[t+1]<<3)+
- (preS[t+2]<<2)+
- (preS[t+3]<<1)+
- (preS[t+4]<<0)+
- (preS[t+5]<<4)];
- t = 4*j;
- f[t+0] = (k>>3)&01;
- f[t+1] = (k>>2)&01;
- f[t+2] = (k>>1)&01;
- f[t+3] = (k>>0)&01;
- }
- /*
- * The new R is L ^ f(R, K).
- * The f here has to be permuted first, though.
- */
- for (j=0; j<32; j++)
- R[j] = L[j] ^ f[P[j]-1];
- /*
- * Finally, the new L (the original R)
- * is copied back.
- */
- for (j=0; j<32; j++)
- L[j] = tempL[j];
- }
- /*
- * The output L and R are reversed.
- */
- for (j=0; j<32; j++) {
- t = L[j];
- L[j] = R[j];
- R[j] = t;
- }
- /*
- * The final output
- * gets the inverse permutation of the very original.
- */
- for (j=0; j<64; j++)
- block[j] = L[FP[j]-1];
-}
-
-char *
-_crypt(char *pw, char *salt)
-{
- int i, j, c;
- int temp;
- struct _crypt *_c = __crypt;
-
- if (!_c) {
- _cryptinit();
- _c = __crypt;
- }
- for(i=0; i<66; i++)
- ablock[i] = 0;
- for(i=0; (c= *pw) && i<64; pw++){
- for(j=0; j<7; j++, i++)
- ablock[i] = (c>>(6-j)) & 01;
- i++;
- }
-
- setkey(ablock);
-
- for(i=0; i<66; i++)
- ablock[i] = 0;
-
- for(i=0;i<48;i++)
- E[i] = e[i];
-
- for(i=0;i<2;i++){
- c = *salt++;
- iobuf[i] = c;
- if(c > 'Z')
- c -= 6;
- if(c > '9')
- c -= 7;
- c -= '.';
- for(j=0;j<6;j++){
- if((c>>j) & 01){
- temp = E[6*i+j];
- E[6*i+j] = E[6*i+j+24];
- E[6*i+j+24] = temp;
- }
- }
- }
-
- for(i=0; i<25; i++)
- encrypt(ablock,0);
-
- for(i=0; i < 11; i++) {
- c = 0;
- for(j=0; j<6; j++){
- c <<= 1;
- c |= ablock[6*i+j];
- }
- c += '.';
- if(c > '9')
- c += 7;
- if(c > 'Z')
- c += 6;
- iobuf[i+2] = c;
- }
- iobuf[i+2] = 0;
- if(iobuf[1]==0)
- iobuf[1] = iobuf[0];
- return(iobuf);
-}
-
-static void
-_cryptinit(void)
-{
- struct _crypt *_c = __crypt;
- int i;
-
- if (_c)
- return;
- _c = __crypt = (struct _crypt *)calloc(1, sizeof (struct _crypt));
- if (_c == 0)
- abort();
-
- for(i=0;i<48;i++)
- E[i] = e[i];
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_nlist.c b/usr/src/lib/libbc/libc/gen/common/_nlist.c
deleted file mode 100644
index a865401729..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_nlist.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include <sys/param.h>
-#include <a.out.h>
-
-#define BSIZ 8*1024 /* size of local buffers */
-
-/*
- * _nlist - retreive attributes from name list (string table version)
- *
- * Note: This is a modified form of the original nlist() function.
- * It takes a file descriptor instead of a filename argument
- * and is intended to be called by nlist(3) and kvmnlist(3K).
- * The algorithm has been modified from the original to use local
- * (rather than stdio) buffering and issues considerably fewer lseeks.
- */
-int
-_nlist(int fd, struct nlist *list)
-{
- struct nlist *p, *q;
- char *s1, *s2;
- int soff;
- int stroff = 0;
- int n, m;
- int maxlen, nreq;
- long sa; /* symbol address */
- long ss; /* start of strings */
- struct exec buf;
- struct nlist space[BSIZ/sizeof (struct nlist)];
- char strs[BSIZ];
-
- maxlen = 0;
- for (q = list, nreq = 0; q->n_un.n_name && q->n_un.n_name[0];
- q++, nreq++) {
- q->n_type = 0;
- q->n_value = 0;
- q->n_desc = 0;
- q->n_other = 0;
- n = strlen(q->n_un.n_name);
- if (n > maxlen)
- maxlen = n;
- }
- if ((fd == -1) || (lseek(fd, 0L, 0) == -1) ||
- (read(fd, (char*)&buf, sizeof buf) != sizeof buf) || N_BADMAG(buf))
- return (-1);
- sa = N_SYMOFF(buf);
- ss = sa + buf.a_syms;
- n = buf.a_syms;
- while (n) {
- m = MIN(n, sizeof (space));
- lseek(fd, sa, 0);
- if (read(fd, (char *)space, m) != m)
- break;
- sa += m;
- n -= m;
- for (q = space; (m -= sizeof (struct nlist)) >= 0; q++) {
- soff = q->n_un.n_strx;
- if (soff == 0 || q->n_type & N_STAB)
- continue;
- if ((soff + maxlen + 1) >= stroff) {
- /*
- * Read strings into local cache.
- * Assumes (maxlen < sizeof (strs)).
- */
- lseek(fd, ss+soff, 0);
- read(fd, strs, sizeof strs);
- stroff = soff + sizeof (strs);
- }
- for (p = list;
- p->n_un.n_name && p->n_un.n_name[0];
- p++) {
- if (p->n_type != 0)
- continue;
- s1 = p->n_un.n_name;
- s2 = &strs[soff-(stroff-sizeof (strs))];
- while (*s1) {
- if (*s1++ != *s2++)
- goto cont;
- }
- if (*s2)
- goto cont;
- p->n_value = q->n_value;
- p->n_type = q->n_type;
- p->n_desc = q->n_desc;
- p->n_other = q->n_other;
- if (--nreq == 0)
- goto alldone;
- break;
-cont: ;
- }
- }
- }
-alldone:
- return (nreq);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_perror.c b/usr/src/lib/libbc/libc/gen/common/_perror.c
deleted file mode 100644
index ea9cac5cb5..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_perror.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 4.2 83/06/30 */
-/*
- * Print the error indicated
- * in the cerror cell.
- */
-#include <sys/types.h>
-#include <sys/uio.h>
-
-extern int errno;
-extern int sys_nerr;
-extern char *sys_errlist[];
-extern int strlen();
-extern int writev();
-
-void
-_perror(s)
- char *s;
-{
- struct iovec iov[4];
- register struct iovec *v = iov;
-
- if (s && *s) {
- v->iov_base = s;
- v->iov_len = strlen(s);
- v++;
- v->iov_base = ": ";
- v->iov_len = 2;
- v++;
- }
- v->iov_base =
- (unsigned)errno < sys_nerr ? sys_errlist[errno] : "Unknown error";
- v->iov_len = strlen(v->iov_base);
- v++;
- v->iov_base = "\n";
- v->iov_len = 1;
- writev(2, iov, (v - iov) + 1);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_psignal.c b/usr/src/lib/libbc/libc/gen/common/_psignal.c
deleted file mode 100644
index d28a9be0ea..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_psignal.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 4.1 83/02/10 */
-
-/*
- * Print the name of the signal indicated
- * along with the supplied message.
- */
-#include <sys/types.h>
-#include <sys/uio.h>
-#include <signal.h>
-
-extern char *sys_siglist[];
-extern int strlen();
-extern int writev();
-
-void
-_psignal(sig, s)
- unsigned sig;
- char *s;
-{
- struct iovec iov[4];
- register struct iovec *v = iov;
-
- if (s && *s) {
- v->iov_base = s;
- v->iov_len = strlen(s);
- v++;
- v->iov_base = ": ";
- v->iov_len = 2;
- v++;
- }
- v->iov_base =
- (unsigned)sig < NSIG ? sys_siglist[sig] : "Unknown signal";
- v->iov_len = strlen(v->iov_base);
- v++;
- v->iov_base = "\n";
- v->iov_len = 1;
- writev(2, iov, (v - iov) + 1);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_small_power.c b/usr/src/lib/libbc/libc/gen/common/_small_power.c
deleted file mode 100644
index 1cb4f32a61..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_small_power.c
+++ /dev/null
@@ -1,878 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include "base_conversion.h"
-
-unsigned short _max_tiny_powers_ten = 4;
-unsigned short _tiny_powers_ten[] = {1, /* begin powers of 10 in
- * base 65536 */
- /* 10**1 = */ 10, /* * 65536**0 */
- /* 10**2 = */ 100, /* * 65536**1 */
- /* 10**3 = */ 1000, /* * 65536**1 */
-0 } ;
-
-unsigned short _start_tiny_powers_ten[] = {
- 0, 1, 2, 3, 4,
-0}; /* end _start_tiny_powers_ten */
-
-unsigned short _leading_zeros_tiny_powers_ten[] = {
- 0, 0, 0, 0,
-0}; /* end _leading_zeros_tiny_powers_ten */
-
-unsigned short _max_tiny_powers_two = 16;
-unsigned short _tiny_powers_two[] = {1, /* begin powers of 2 in
- * base 10000 */
- /* 2**1 = */ 2, /* * 10000**0 */
- /* 2**2 = */ 4, /* * 10000**0 */
- /* 2**3 = */ 8, /* * 10000**0 */
- /* 2**4 = */ 16, /* * 10000**0 */
- /* 2**5 = */ 32, /* * 10000**0 */
- /* 2**6 = */ 64, /* * 10000**0 */
- /* 2**7 = */ 128, /* * 10000**0 */
- /* 2**8 = */ 256, /* * 10000**0 */
- /* 2**9 = */ 512, /* * 10000**0 */
- /* 2**10 = */ 1024, /* * 10000**0 */
- /* 2**11 = */ 2048, /* * 10000**0 */
- /* 2**12 = */ 4096, /* * 10000**0 */
- /* 2**13 = */ 8192, /* * 10000**0 */
- /* 2**14 = */ 6384, 1, /* * 10000**1 */
- /* 2**15 = */ 2768, 3, /* * 10000**1 */
-0};
-
-unsigned short _start_tiny_powers_two[] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 18,
-0}; /* end _start_tiny_powers_two */
-
-unsigned short _max_small_powers_ten = 90;
-unsigned short _small_powers_ten[] = {1, /* begin powers of 10000 in
- * base 65536 */
- /* 10000**1 = */ 10000, /* * 65536**0 */
- /* 10000**2 = */ 57600, 1525, /* * 65536**1 */
- /* 10000**3 = */ 4096, 54437, 232, /* * 65536**2 */
- /* 10000**4 = 65536**1 * */ 28609, 34546, 35, /* * 65536**3 */
- /* 10000**5 = 65536**1 * */ 25360, 24109, 27591, 5, /* * 65536**4 */
- /* 10000**6 = 65536**1 * */ 41216, 52461, 7118, 54210, /* * 65536**4 */
- /* 10000**7 = 65536**1 * */ 4096, 609, 15909, 52830, 8271, /* * 65536**5 */
- /* 10000**8 = 65536**2 * */ 61313, 34220, 16731, 11629, 1262, /* * 65536**6 */
- /* 10000**9 = 65536**2 * */ 40720, 45899, 1813, 31689, 38862, 192, /* * 65536**7 */
- /* 10000**10 = 65536**2 * */ 24832, 47605, 49067, 23716, 61891, 25385, 29, /* * 65536**8 */
- /* 10000**11 = 65536**2 * */ 4096, 285, 9232, 58239, 57170, 38515, 31729, 4,
- /* * 65536**9 */
- /* 10000**12 = 65536**3 * */ 32577, 45355, 38512, 38358, 3651, 36101, 44841, /* * 65536**9 */
- /* 10000**13 = 65536**3 * */ 56080, 45850, 37384, 3668, 12301, 38269, 18196, 6842,
- /* * 65536**10 */
- /* 10000**14 = 65536**3 * */ 8448, 18701, 29652, 51080, 65023, 27172, 37903, 3192,
- 1044, /* * 65536**11 */
- /* 10000**15 = 65536**3 * */ 4096, 37081, 37989, 16940, 55138, 17665, 39458, 9751,
- 20263, 159, /* * 65536**12 */
- /* 10000**16 = 65536**4 * */ 7937, 49002, 60772, 28216, 38893, 55975, 63988, 59711,
- 20227, 24, /* * 65536**13 */
- /* 10000**17 = 65536**4 * */ 5904, 8539, 12149, 36793, 43681, 12958, 60573, 21267,
- 35015, 46478, 3, /* * 65536**14 */
- /* 10000**18 = 65536**4 * */ 57600, 63028, 53094, 12749, 18174, 21993, 48265, 14922,
- 59933, 4030, 37092, /* * 65536**14 */
- /* 10000**19 = 65536**4 * */ 4096, 29077, 42481, 30581, 10617, 59493, 46251, 1892,
- 5557, 4505, 52391, 5659,/* * 65536**15 */
- /* 10000**20 = 65536**5 * */ 52929, 10084, 25506, 6346, 61348, 31525, 52689, 61296,
- 27615, 15903, 40426, 863, /* * 65536**16 */
- /* 10000**21 = 65536**5 * */ 21264, 53708, 60962, 25043, 64008, 31200, 50906, 9831,
- 56185, 43877, 36378, 50952, 131, /* * 65536**17 */
- /* 10000**22 = 65536**5 * */ 41216, 15724, 12323, 26246, 59245, 58406, 46648, 13767,
- 11372, 15053, 61895, 48686, 7054, 20, /* * 65536**18 */
- /* 10000**23 = 65536**5 * */ 4096, 25425, 24719, 55736, 8564, 12208, 3664, 51518,
- 17140, 61079, 30312, 2500, 30693, 4468, 3, /* * 65536**19 */
- /* 10000**24 = 65536**6 * */ 36481, 57623, 45627, 58488, 53274, 7238, 2063, 31221,
- 62631, 25319, 35409, 25293, 54667, 30681, /* * 65536**19 */
- /* 10000**25 = 65536**6 * */ 36624, 43054, 17160, 43698, 6780, 36385, 52800, 62346,
- 52747, 33988, 2855, 31979, 38083, 44325, 4681, /* * 65536**20 */
- /* 10000**26 = 65536**6 * */ 24832, 39604, 33321, 54106, 42443, 60698, 47535, 24088,
- 45785, 18352, 47026, 40291, 5183, 35843, 24059, 714,
- /* * 65536**21 */
- /* 10000**27 = 65536**6 * */ 4096, 9741, 31019, 65404, 27119, 57580, 26653, 42453,
- 19179, 26186, 42000, 1847, 62708, 14406, 12813, 247,
- 109, /* * 65536**22 */
- /* 10000**28 = 65536**7 * */ 24129, 9598, 60989, 12011, 4842, 3874, 57395, 38141,
- 46606, 49307, 60792, 31833, 21440, 9318, 47123, 41461,
- 16, /* * 65536**23 */
- /* 10000**29 = 65536**7 * */ 51984, 38977, 13448, 57354, 56264, 8962, 51839, 64773,
- 39323, 49783, 15587, 30924, 36601, 56615, 27581, 36454,
- 35254, 2, /* * 65536**24 */
- /* 10000**30 = 65536**7 * */ 8448, 35340, 6075, 36516, 22191, 40873, 1607, 45622,
- 23883, 24544, 32988, 43530, 61694, 55616, 43150, 32976,
- 27418, 25379, /* * 65536**24 */
- /* 10000**31 = 65536**7 * */ 4096, 31177, 3520, 59871, 10675, 50890, 19916, 24149,
- 23777, 11324, 41057, 14921, 56274, 30917, 19462, 54968,
- 47943, 38791, 3872, /* * 65536**25 */
- /* 10000**32 = 65536**8 * */ 15873, 11925, 39177, 991, 14589, 3861, 58415, 9076,
- 62956, 54223, 56328, 50180, 45274, 48333, 32537, 42547,
- 9731, 59679, 590, /* * 65536**26 */
- /* 10000**33 = 65536**8 * */ 1808, 42438, 63147, 20041, 7015, 11522, 28221, 1553,
- 22569, 60278, 6353, 64979, 24968, 8908, 56671, 15252,
- 61068, 20668, 10866, 90,/* * 65536**27 */
- /* 10000**34 = 65536**8 * */ 57600, 34675, 37115, 10547, 29538, 8782, 13742, 2274,
- 49789, 48851, 34813, 1529, 63291, 20385, 21567, 26375,
- 17879, 54310, 4465, 49690, 13, /* * 65536**28 */
- /* 10000**35 = 65536**8 * */ 4096, 7813, 24923, 28239, 10857, 6267, 57884, 1104,
- 13355, 12253, 10222, 25424, 29081, 42697, 59670, 36426,
- 11816, 5896, 28271, 6729, 6510, 2, /* * 65536**29 */
- /* 10000**36 = 65536**9 * */ 11713, 63320, 64714, 46692, 19240, 27004, 38784, 53336,
- 45253, 51245, 27415, 30647, 7397, 1235, 20017, 4150,
- 44939, 54131, 54377, 23778, 20993, /* * 65536**29 */
- /* 10000**37 = 65536**9 * */ 17168, 58491, 47197, 51410, 58964, 34615, 2072, 33950,
- 12058, 30921, 20731, 27847, 50068, 30360, 23244, 18766,
- 10281, 55033, 26067, 23689, 21820, 3203, /* * 65536**30 */
- /* 10000**38 = 65536**9 * */ 41216, 3819, 54189, 42817, 20452, 63381, 15905, 23836,
- 64476, 12991, 24350, 10699, 54745, 44887, 53976, 33978,
- 52415, 25776, 41725, 46873, 34270, 51761, 488, /* * 65536**31 */
- /* 10000**39 = 65536**9 * */ 4096, 54337, 38934, 31580, 54213, 14464, 3799, 7995,
- 20469, 27486, 35742, 38963, 29424, 22289, 12353, 49612,
- 63792, 14909, 51757, 22894, 19408, 11901, 38234, 74,
- /* * 65536**32 */
- /* 10000**40 = 65536**10 * */ 11649, 64451, 53492, 21026, 10320, 46863, 62195, 22291,
- 5139, 56386, 23933, 54841, 6553, 63577, 14364, 146,
- 5334, 34483, 30649, 31397, 65121, 4791, 24938, 11,
- /* * 65536**33 */
- /* 10000**41 = 65536**10 * */ 32528, 30753, 25002, 28674, 49544, 49174, 20510, 31554,
- 13177, 54576, 1131, 8404, 2368, 6264, 60325, 20399,
- 59254, 45917, 48925, 57236, 49094, 13120, 16251, 48269,
- 1, /* * 65536**34 */
- /* 10000**42 = 65536**10 * */ 24832, 40051, 4852, 23815, 57751, 30951, 45359, 52825,
- 47454, 43738, 46135, 23020, 22786, 53481, 57611, 51172,
- 32136, 33825, 30766, 41577, 18557, 4419, 48258, 19839,
- 17365, /* * 65536**34 */
- /* 10000**43 = 65536**10 * */ 4096, 23293, 29471, 58452, 10401, 57820, 20066, 36761,
- 1884, 65513, 48769, 44607, 60376, 39716, 56720, 23702,
- 44800, 23607, 39177, 14310, 43928, 21567, 39106, 19891,
- 48163, 2649, /* * 65536**35 */
- /* 10000**44 = 65536**11 * */ 15681, 63698, 8912, 13287, 42995, 63126, 21637, 36777,
- 32431, 46620, 39425, 49174, 21052, 57516, 50478, 65056,
- 16163, 64930, 40889, 59911, 63262, 9978, 14207, 8971,
- 20805, 404, /* * 65536**36 */
- /* 10000**45 = 65536**11 * */ 47888, 38008, 759, 29888, 35867, 23808, 45296, 50805,
- 43483, 47380, 58073, 29407, 25871, 19276, 30504, 57366,
- 28150, 37314, 20803, 51663, 10133, 43861, 55010, 58919,
- 40104, 45478, 61, /* * 65536**37 */
- /* 10000**46 = 65536**11 * */ 8448, 44043, 59159, 35955, 61568, 58720, 44336, 21839,
- 6392, 46891, 22733, 18829, 43895, 22571, 38397, 28046,
- 31633, 47847, 24429, 12886, 19227, 44634, 63044, 29753,
- 34206, 31815, 27115, 9, /* * 65536**38 */
- /* 10000**47 = 65536**11 * */ 4096, 29369, 3248, 28531, 40302, 6834, 17920, 30813,
- 25732, 895, 58307, 8540, 58281, 10713, 63556, 37314,
- 57543, 62026, 44628, 19951, 54878, 42773, 56026, 6179,
- 32156, 43475, 32422, 28601, 1, /* * 65536**39 */
- /* 10000**48 = 65536**12 * */ 23809, 44161, 32287, 43489, 57637, 25618, 47998, 30365,
- 41030, 61880, 15488, 65191, 53068, 59042, 53249, 29613,
- 36076, 54840, 25225, 50116, 50437, 64798, 63636, 41326,
- 54618, 20041, 15843, 14364, /* * 65536**39 */
- /* 10000**49 = 65536**12 * */ 63248, 32064, 46402, 63566, 53051, 8570, 63781, 29035,
- 49273, 15348, 27874, 25771, 44955, 14273, 19009, 46477,
- 54374, 256, 10304, 10057, 12591, 33264, 15327, 65230,
- 9281, 9246, 32546, 53041, 2191, /* * 65536**40 */
- /* 10000**50 = 65536**12 * */ 57600, 47538, 30012, 33416, 5779, 52543, 14955, 35252,
- 34782, 2206, 17734, 26701, 42508, 64987, 37777, 57124,
- 60435, 12392, 17447, 39348, 16878, 46721, 51907, 22530,
- 20977, 55656, 9634, 32118, 29069, 334, /* * 65536**41 */
- /* 10000**51 = 65536**12 * */ 4096, 56181, 37909, 62051, 57882, 28769, 4865, 4138,
- 25827, 45211, 65456, 19041, 17578, 21510, 30412, 33988,
- 51260, 645, 15059, 4518, 30804, 6431, 32009, 60688,
- 58237, 31488, 10572, 55070, 42740, 2099, 51, /* * 65536**42 */
- /* 10000**52 = 65536**13 * */ 36033, 38348, 20936, 15516, 61328, 26677, 27526, 58791,
- 46612, 58866, 37907, 15353, 13530, 36242, 14944, 48130,
- 35293, 53906, 27993, 21489, 23884, 13157, 21524, 26364,
- 53942, 15236, 2605, 48147, 25001, 51568, 7, /* * 65536**43 */
- /* 10000**53 = 65536**13 * */ 13072, 34362, 43867, 39482, 62015, 47837, 12870, 56280,
- 36938, 22760, 18758, 50472, 36038, 7984, 23450, 5896,
- 25984, 31785, 33969, 1727, 30095, 42892, 21783, 57492,
- 62742, 62566, 34532, 42941, 63042, 46566, 12332, 1,
- /* * 65536**44 */
- /* 10000**54 = 65536**13 * */ 41216, 16746, 42795, 37829, 54392, 32198, 60131, 44331,
- 27691, 64644, 19440, 30126, 5237, 22651, 13410, 46714,
- 56195, 4364, 21762, 39215, 8951, 57008, 60416, 41531,
- 52644, 62917, 20362, 23397, 35768, 36339, 53889, 11881,
- /* * 65536**44 */
- /* 10000**55 = 65536**13 * */ 4096, 21809, 2475, 22738, 42508, 9931, 22113, 33671,
- 27164, 62657, 30087, 59510, 11332, 18383, 16800, 1438,
- 51464, 1598, 41146, 51432, 59343, 49237, 57850, 17586,
- 61185, 32432, 9248, 9587, 53618, 63873, 58552, 1454,
- 1813, /* * 65536**45 */
- /* 10000**56 = 65536**14 * */ 52353, 46255, 35993, 16973, 29446, 13051, 54942, 63953,
- 49984, 3784, 37711, 17336, 3249, 34037, 30179, 51547,
- 62604, 25235, 65286, 9367, 7087, 21241, 35739, 8587,
- 57208, 13652, 57779, 31446, 24325, 31122, 65478, 42285,
- 276, /* * 65536**46 */
- /* 10000**57 = 65536**14 * */ 28432, 4900, 13346, 62788, 9341, 32317, 33703, 38095,
- 6686, 33355, 16433, 23034, 52325, 42047, 1913, 33965,
- 47993, 45952, 59754, 29017, 27013, 8905, 25433, 23293,
- 17566, 17241, 26707, 27088, 50702, 58783, 14572, 21719,
- 13940, 42, /* * 65536**47 */
- /* 10000**58 = 65536**14 * */ 24832, 48946, 29451, 47156, 30780, 13409, 48819, 59910,
- 19092, 38316, 36337, 49003, 14090, 64544, 65439, 42739,
- 15054, 54427, 55299, 51245, 60571, 56233, 51678, 18936,
- 27074, 53000, 13430, 23787, 37637, 45352, 42441, 5919,
- 8242, 28911, 6, /* * 65536**48 */
- /* 10000**59 = 65536**14 * */ 4096, 40941, 64220, 32973, 50139, 8040, 14382, 42873,
- 22773, 39457, 44262, 22872, 5077, 43622, 22888, 39729,
- 10329, 61353, 5536, 32454, 34107, 40362, 37220, 34381,
- 13673, 14499, 24823, 41905, 381, 16623, 5784, 17468,
- 42151, 31961, 64411, /* * 65536**48 */
- /* 10000**60 = 65536**15 * */ 7233, 18983, 28183, 44631, 60514, 35242, 61218, 64477,
- 46754, 61412, 6113, 48626, 13158, 34944, 14260, 11326,
- 49080, 56977, 6572, 25608, 54516, 27214, 13823, 27150,
- 26454, 47380, 16603, 15306, 30762, 39784, 27442, 50649,
- 62895, 27068, 9828, /* * 65536**49 */
- /* 10000**61 = 65536**15 * */ 43792, 38847, 28096, 14140, 52922, 42161, 13601, 36173,
- 16014, 54814, 59818, 49348, 56667, 4055, 64532, 15967,
- 2624, 7505, 61622, 31850, 35459, 42846, 18728, 51997,
- 40846, 44292, 34541, 35973, 61887, 41173, 26838, 31979,
- 8736, 25917, 45666, 1499, /* * 65536**50 */
- /* 10000**62 = 65536**15 * */ 8448, 44810, 13095, 43135, 18957, 24987, 29233, 38891,
- 41071, 64875, 41291, 3047, 53274, 57398, 53162, 34150,
- 28036, 11680, 51673, 4442, 45100, 56578, 50185, 10233,
- 47582, 33944, 42038, 8166, 19041, 42291, 16362, 43951,
- 5391, 41989, 9106, 54760, 228, /* * 65536**51 */
- /* 10000**63 = 65536**15 * */ 4096, 31657, 15909, 59582, 46469, 49660, 43252, 23836,
- 1822, 15403, 43099, 2060, 63857, 23840, 726, 16,
- 2203, 19126, 45958, 60012, 47461, 14593, 49481, 35961,
- 30201, 36316, 37275, 8558, 29166, 9097, 48597, 28080,
- 46114, 1670, 36903, 48109, 60131, 34, /* * 65536**52 */
- /* 10000**64 = 65536**16 * */ 31745, 38958, 34651, 48851, 40818, 55513, 12167, 4629,
- 20678, 27614, 28272, 53066, 55311, 54677, 29038, 9906,
- 26288, 44486, 13860, 7445, 54106, 15426, 21518, 25599,
- 29632, 52309, 61207, 26105, 10482, 21948, 51191, 32988,
- 60892, 62574, 61390, 24540, 21495, 5, /* * 65536**53 */
- /* 10000**65 = 65536**16 * */ 59152, 38859, 27112, 9943, 29246, 46308, 43654, 23440,
- 14626, 39987, 1909, 19322, 59793, 11591, 63863, 39534,
- 16615, 5643, 63684, 3218, 61456, 62047, 27665, 9667,
- 35650, 51705, 37277, 29451, 31919, 1535, 11653, 45123,
- 30057, 11563, 33836, 42583, 61200, 53279, /* * 65536**53 */
- /* 10000**66 = 65536**16 * */ 57600, 36081, 3497, 16025, 39885, 7086, 11770, 49925,
- 52760, 37095, 25125, 20163, 48020, 51475, 48984, 36592,
- 22272, 6039, 27549, 11541, 29419, 50065, 32011, 8621,
- 51171, 41935, 9121, 62440, 34173, 19446, 7226, 16418,
- 28789, 29082, 64932, 47770, 31329, 57194, 8129, /* * 65536**54 */
- /* 10000**67 = 65536**16 * */ 4096, 43109, 44817, 15013, 349, 21670, 63961, 64083,
- 42817, 24290, 56172, 45097, 20804, 37583, 31790, 39986,
- 34255, 34742, 43113, 5307, 657, 24985, 39815, 35044,
- 6227, 58480, 55822, 39919, 34823, 19902, 42295, 13422,
- 58393, 41160, 59285, 18003, 35209, 12108, 34087, 1240,
- /* * 65536**55 */
- /* 10000**68 = 65536**17 * */ 60353, 41409, 59398, 18882, 38037, 47482, 28751, 33090,
- 30117, 14650, 25355, 35617, 49750, 56134, 29714, 64965,
- 18890, 39493, 57954, 17209, 26868, 22612, 25083, 16147,
- 23222, 58811, 18741, 43323, 58017, 49228, 8725, 6288,
- 42830, 17624, 11654, 33355, 40380, 19111, 18897, 189,
- /* * 65536**56 */
- /* 10000**69 = 65536**17 * */ 8976, 42761, 33550, 19847, 1937, 17484, 10813, 13123,
- 37129, 31635, 58987, 51244, 21658, 31751, 8341, 61702,
- 35160, 12946, 11178, 1307, 50562, 24899, 27178, 58659,
- 28415, 59015, 51549, 39899, 51938, 47956, 29095, 32307,
- 23199, 20231, 19681, 39074, 37793, 13185, 32628, 57875,
- 28, /* * 65536**57 */
- /* 10000**70 = 65536**17 * */ 41216, 54505, 27740, 32111, 39908, 55783, 63803, 28577,
- 30562, 13393, 50827, 23016, 56875, 56920, 53052, 65368,
- 8774, 31765, 43095, 30041, 9959, 26451, 6007, 46947,
- 60390, 2655, 58365, 14697, 13288, 41013, 43013, 47495,
- 63025, 3907, 8479, 17371, 55386, 62870, 43803, 6562,
- 26687, 4, /* * 65536**58 */
- /* 10000**71 = 65536**17 * */ 4096, 58913, 59964, 53368, 36195, 59193, 45551, 42775,
- 29992, 44615, 40363, 5323, 32104, 28518, 14765, 32031,
- 62806, 63882, 55646, 65087, 45399, 8223, 43060, 36548,
- 58459, 17134, 52325, 47193, 40770, 7739, 23490, 17171,
- 63071, 20160, 52548, 40893, 17914, 21603, 62505, 25147,
- 8409, 44072, /* * 65536**58 */
- /* 10000**72 = 65536**18 * */ 27521, 60125, 29501, 2815, 14371, 43832, 3478, 33791,
- 51024, 583, 20927, 45484, 37762, 1743, 37821, 33399,
- 50191, 3571, 40475, 32059, 54783, 29734, 57834, 14456,
- 37816, 13190, 13248, 7745, 63741, 20156, 9264, 59692,
- 20887, 15428, 58914, 36351, 26077, 36464, 17905, 11149,
- 57219, 6724, /* * 65536**59 */
- /* 10000**73 = 65536**18 * */ 24336, 26935, 41638, 39557, 55517, 17424, 52608, 6914,
- 47396, 5081, 13641, 23353, 8508, 3186, 2010, 24315,
- 40408, 538, 209, 59600, 19467, 11527, 54873, 61944,
- 19485, 47338, 33756, 54005, 8045, 46526, 40707, 19525,
- 15876, 11443, 39250, 56333, 7802, 1675, 11212, 15996,
- 62421, 8794, 1026, /* * 65536**60 */
- /* 10000**74 = 65536**18 * */ 24832, 753, 33902, 1057, 20580, 53783, 25186, 7547,
- 4703, 26832, 30359, 27313, 17835, 10802, 46470, 11746,
- 54270, 12213, 58466, 15647, 37174, 60682, 64366, 2100,
- 20924, 16445, 56823, 38510, 45568, 21163, 33003, 24467,
- 34787, 6566, 6642, 54069, 40755, 39510, 53695, 53870,
- 47576, 212, 37726, 156, /* * 65536**61 */
- /* 10000**75 = 65536**18 * */ 4096, 62685, 2386, 23877, 17121, 44724, 13358, 41907,
- 41839, 16333, 31342, 46120, 30711, 19393, 51408, 26578,
- 63712, 44712, 15207, 44489, 22195, 27848, 40203, 38301,
- 49408, 23368, 35389, 19134, 14068, 21209, 59469, 29147,
- 8645, 63772, 33033, 19013, 55402, 55210, 19580, 2273,
- 42396, 30107, 34816, 58428, 23, /* * 65536**62 */
- /* 10000**76 = 65536**19 * */ 64321, 14460, 22716, 33611, 24948, 24456, 34854, 14570,
- 20672, 29340, 27950, 15341, 13662, 18575, 39364, 48599,
- 43129, 33302, 33952, 51892, 20922, 36425, 23750, 9940,
- 51699, 64701, 45815, 42663, 17650, 19572, 40482, 12463,
- 56039, 38290, 15104, 47093, 33189, 52392, 57531, 7962,
- 4085, 37362, 31872, 42307, 3, /* * 65536**63 */
- /* 10000**77 = 65536**19 * */ 39696, 37398, 14430, 44858, 55112, 48990, 23283, 18790,
- 21679, 64018, 58972, 60024, 45316, 23060, 33618, 46566,
- 4999, 38165, 48601, 11132, 37006, 4104, 3094, 51048,
- 43548, 46496, 63232, 63166, 18061, 32197, 7114, 52241,
- 59101, 47238, 50898, 56144, 22881, 30280, 42986, 2538,
- 22287, 65423, 24132, 39983, 36455, /* * 65536**63 */
- /* 10000**78 = 65536**19 * */ 8448, 37641, 60970, 53817, 34620, 26809, 53603, 11840,
- 65315, 27659, 36840, 4774, 53255, 51266, 49374, 31849,
- 58673, 34634, 847, 47288, 45442, 20110, 7634, 20568,
- 1069, 54261, 35766, 33680, 2422, 59924, 38352, 23629,
- 14323, 5530, 34632, 854, 32391, 27171, 13996, 24127,
- 47987, 53048, 26430, 64082, 44868, 5562, /* * 65536**64 */
- /* 10000**79 = 65536**19 * */ 4096, 38041, 24335, 63207, 47059, 53042, 15146, 50163,
- 20030, 38046, 26364, 35413, 5192, 45534, 65134, 58109,
- 56587, 56728, 21140, 37889, 591, 42486, 59164, 29196,
- 10770, 37619, 38327, 15953, 42355, 44721, 12471, 38572,
- 37445, 55337, 28619, 25604, 31218, 2686, 44786, 34119,
- 19089, 38938, 1406, 13025, 30322, 52318, 848, /* * 65536**65 */
- /* 10000**80 = 65536**20 * */ 39681, 20636, 44529, 51164, 44332, 14397, 19767, 29638,
- 26576, 60013, 43014, 20891, 62200, 50179, 57762, 41042,
- 9018, 55056, 29609, 17541, 55738, 53010, 6147, 28807,
- 15003, 21212, 21224, 58802, 64334, 1815, 42543, 48717,
- 55265, 2731, 60751, 35938, 60539, 52921, 16417, 54374,
- 33536, 41237, 30182, 52451, 10738, 33839, 129, /* * 65536**66 */
- /* 10000**81 = 65536**20 * */ 55056, 58726, 41564, 7242, 42303, 59708, 15620, 29224,
- 16042, 20903, 36389, 53331, 1011, 55875, 58888, 42381,
- 8726, 58976, 6752, 40182, 64532, 53336, 5320, 40218,
- 22491, 47793, 37668, 34246, 47596, 6344, 36101, 47403,
- 57881, 55456, 57232, 55381, 39451, 16037, 10395, 55849,
- 20584, 22605, 33012, 29997, 40035, 29270, 49979, 19,
- /* * 65536**67 */
- /* 10000**82 = 65536**20 * */ 57600, 304, 19649, 9062, 61761, 53494, 36822, 17359,
- 57867, 38143, 37317, 49120, 25593, 55754, 47565, 63209,
- 38050, 2867, 26919, 19814, 58675, 37878, 58442, 51915,
- 62120, 44919, 51900, 40147, 42793, 8414, 38680, 13620,
- 3281, 3200, 2574, 39533, 57266, 9427, 12351, 59330,
- 65481, 19476, 18617, 16765, 60689, 22332, 16930, 1018,
- 3, /* * 65536**68 */
- /* 10000**83 = 65536**20 * */ 4096, 34133, 13118, 52246, 118, 44592, 46914, 56290,
- 55304, 19309, 13836, 13374, 19415, 29153, 63755, 2537,
- 7629, 36574, 34085, 28779, 9215, 56409, 41267, 48261,
- 57713, 15734, 27270, 4383, 51582, 63841, 7811, 22094,
- 44078, 18932, 50376, 17240, 12464, 37970, 41614, 4476,
- 48877, 62535, 50731, 11752, 29198, 48108, 23919, 24503,
- 30155, /* * 65536**68 */
- /* 10000**84 = 65536**21 * */ 19137, 47672, 9009, 8324, 13074, 40116, 18454, 55821,
- 29382, 16450, 48671, 34408, 28834, 20240, 17296, 6483,
- 50284, 2844, 26625, 10775, 23054, 63951, 9192, 27348,
- 62406, 7104, 56113, 52348, 31694, 829, 19336, 53771,
- 58757, 53192, 48006, 58694, 51853, 57729, 5261, 3195,
- 12946, 5366, 21693, 18913, 50215, 56476, 60081, 22602,
- 4601, /* * 65536**69 */
- /* 10000**85 = 65536**21 * */ 4880, 14056, 50810, 10654, 62486, 16138, 62281, 42703,
- 30629, 9123, 42174, 23426, 52386, 29231, 13584, 17535,
- 48797, 5048, 43202, 12878, 51532, 13229, 48286, 65210,
- 30380, 8498, 11852, 52530, 15891, 37300, 28926, 55606,
- 47964, 38789, 16916, 6909, 18124, 56824, 58936, 34770,
- 26887, 53527, 6658, 61950, 16053, 43950, 50105, 61039,
- 7176, 702, /* * 65536**70 */
- /* 10000**86 = 65536**21 * */ 41216, 51560, 1536, 51753, 41401, 39902, 23854, 6927,
- 46788, 8561, 17232, 40771, 34326, 27433, 53868, 43272,
- 57155, 24725, 7458, 8352, 12397, 46215, 58306, 24167,
- 50590, 49979, 32208, 30768, 58751, 37048, 55323, 56989,
- 56036, 55270, 17502, 17637, 34014, 45645, 3422, 40513,
- 46633, 41590, 3591, 54744, 41788, 18033, 33986, 60877,
- 7393, 8743, 107, /* * 65536**71 */
- /* 10000**87 = 65536**21 * */ 4096, 34577, 32443, 57978, 26984, 43149, 60584, 2087,
- 19553, 27123, 27162, 13173, 54189, 1541, 43802, 59547,
- 17146, 56929, 3804, 28274, 42698, 57555, 58795, 47664,
- 31303, 20183, 43722, 58930, 49990, 13956, 46277, 62921,
- 35895, 43462, 47313, 15294, 10851, 62486, 17172, 52506,
- 47541, 15659, 2618, 18340, 30817, 46840, 58591, 11281,
- 14681, 6104, 22758, 16, /* * 65536**72 */
- /* 10000**88 = 65536**22 * */ 2689, 32076, 53494, 37134, 5093, 31800, 38796, 36430,
- 45015, 42954, 6784, 40362, 17308, 43147, 16587, 26910,
- 46920, 37806, 18276, 17274, 19363, 35326, 5643, 37337,
- 49432, 32423, 6959, 384, 41484, 22433, 5925, 18929,
- 56261, 32247, 51731, 50253, 41431, 25214, 53724, 19867,
- 31750, 33525, 30671, 22526, 18910, 25307, 31484, 11081,
- 28224, 39939, 32400, 2, /* * 65536**73 */
- /* 10000**89 = 65536**22 * */ 20240, 27226, 40062, 21186, 14194, 20105, 57268, 56831,
- 54310, 23924, 16794, 50347, 5582, 49153, 4967, 11715,
- 31882, 55511, 51400, 55428, 39291, 23914, 8894, 12269,
- 53185, 30950, 61251, 39973, 62714, 6601, 8879, 22936,
- 51864, 41464, 39272, 7845, 64612, 29329, 45255, 38581,
- 46647, 38204, 6635, 17448, 32077, 38389, 8917, 58964,
- 43674, 17922, 61646, 24943, /* * 65536**73 */
-0}; /* end powers of 10000 in base 65536 */
-
-unsigned short _start_small_powers_ten[] = {
- 0, 1, 2, 4, 7, 10, 14, 18,
- 23, 28, 34, 41, 49, 56, 64, 73,
- 83, 93, 104, 115, 127, 139, 152, 166,
- 181, 195, 210, 226, 243, 260, 278, 296,
- 315, 334, 354, 375, 397, 418, 440, 463,
- 487, 511, 536, 561, 587, 613, 640, 668,
- 697, 725, 754, 784, 815, 846, 878, 910,
- 943, 976, 1010, 1045, 1080, 1115, 1151, 1188,
- 1226, 1264, 1302, 1341, 1381, 1421, 1462, 1504,
- 1546, 1588, 1631, 1675, 1720, 1765, 1810, 1856,
- 1903, 1950, 1998, 2047, 2096, 2145, 2195, 2246,
- 2298, 2350, 2402,
-0}; /* end _start_small_powers_ten */
-
-unsigned short _leading_zeros_small_powers_ten[] = {
- 0, 0, 0, 0, 1, 1, 1, 1,
- 2, 2, 2, 2, 3, 3, 3, 3,
- 4, 4, 4, 4, 5, 5, 5, 5,
- 6, 6, 6, 6, 7, 7, 7, 7,
- 8, 8, 8, 8, 9, 9, 9, 9,
- 10, 10, 10, 10, 11, 11, 11, 11,
- 12, 12, 12, 12, 13, 13, 13, 13,
- 14, 14, 14, 14, 15, 15, 15, 15,
- 16, 16, 16, 16, 17, 17, 17, 17,
- 18, 18, 18, 18, 19, 19, 19, 19,
- 20, 20, 20, 20, 21, 21, 21, 21,
- 22, 22,
-0}; /* end _leading_zeros_small_powers_ten */
-
-unsigned short _max_small_powers_two = 70;
-unsigned short _small_powers_two[] = {1, /* begin powers of 65536 in
- * base 10000 */
- /* 65536**1 = */ 5536, 6, /* * 10000**1 */
- /* 65536**2 = */ 7296, 9496, 42, /* * 10000**2 */
- /* 65536**3 = */ 656, 7671, 4749, 281, /* * 10000**3 */
- /* 65536**4 = */ 1616, 955, 737, 6744, 1844, /* * 10000**4 */
- /* 65536**5 = */ 6176, 7470, 6291, 9614, 2581, 2089, 1, /* * 10000**6 */
- /* 65536**6 = */ 336, 4395, 5935, 4337, 1426, 1625, 9228, 7,
- /* * 10000**7 */
- /* 65536**7 = */ 96, 2922, 4963, 8530, 2762, 5348, 6858, 9229,
- 51, /* * 10000**8 */
- /* 65536**8 = */ 1456, 6821, 4317, 4607, 6337, 4634, 938, 6692,
- 2823, 340, /* * 10000**9 */
- /* 65536**9 = */ 416, 598, 3615, 2648, 1827, 5357, 3141, 3062,
- 1985, 745, 2230, /* * 10000**10 */
- /* 65536**10 = */ 2976, 3254, 6559, 3019, 1628, 8327, 3684, 1820,
- 9029, 7330, 163, 4615, 1, /* * 10000**12 */
- /* 65536**11 = */ 5136, 3647, 1951, 6171, 2397, 8943, 9196, 9668,
- 6473, 8053, 411, 9713, 5780, 9, /* * 10000**13 */
- /* 65536**12 = */ 2896, 3451, 4640, 5444, 235, 4161, 7666, 2320,
- 7894, 3835, 8076, 3866, 1735, 7710, 62, /* * 10000**14 */
- /* 65536**13 = */ 2256, 3715, 9658, 8394, 6640, 6839, 6245, 3762,
- 6393, 2295, 3874, 5105, 301, 3933, 3761, 411,
- /* * 10000**15 */
- /* 65536**14 = */ 9216, 1024, 1036, 2481, 4057, 4225, 7144, 7363,
- 6306, 7019, 1508, 6670, 9794, 5063, 6671, 9946,
- 2695, /* * 10000**16 */
- /* 65536**15 = */ 9776, 9261, 2012, 1606, 5812, 6189, 6875, 8389,
- 8274, 8515, 4291, 5007, 3297, 2958, 3843, 4778,
- 4706, 7668, 1, /* * 10000**18 */
- /* 65536**16 = */ 9936, 2963, 9131, 4007, 5758, 394, 564, 6564,
- 9846, 3269, 785, 6879, 5008, 7098, 4235, 6195,
- 3731, 892, 5792, 11, /* * 10000**19 */
- /* 65536**17 = */ 5696, 8284, 8640, 2594, 2554, 8922, 4889, 2000,
- 474, 1715, 7190, 7290, 9370, 7352, 1480, 3279,
- 5418, 2567, 360, 8855, 75, /* * 10000**20 */
- /* 65536**18 = */ 3056, 7553, 5333, 7012, 5949, 8931, 3976, 4046,
- 7174, 7347, 5079, 4561, 100, 2084, 1468, 2248,
- 5538, 6421, 9786, 3640, 3232, 497, /* * 10000**21 */
- /* 65536**19 = */ 8016, 3435, 2989, 3387, 9621, 1007, 9670, 4718,
- 1782, 10, 5498, 2986, 3494, 7682, 505, 4550,
- 3101, 2951, 7380, 5177, 6213, 2575, 3259, /* * 10000**22 */
- /* 65536**20 = */ 6576, 8693, 9620, 22, 4055, 7806, 9725, 2221,
- 6078, 7041, 6994, 6527, 2356, 452, 6027, 2114,
- 6955, 7061, 5021, 8239, 9100, 5920, 8703, 1359,
- 2, /* * 10000**24 */
- /* 65536**21 = */ 4736, 7544, 3294, 4843, 8630, 590, 8760, 9194,
- 2369, 8810, 4931, 9312, 5595, 7716, 8435, 2602,
- 6738, 5277, 2535, 4014, 1598, 2763, 8611, 463,
- 9984, 13, /* * 10000**25 */
- /* 65536**22 = */ 8496, 4621, 5027, 2440, 7421, 2800, 9232, 5393,
- 5043, 7691, 5754, 3553, 4950, 2449, 6731, 9956,
- 8625, 7631, 8347, 8120, 2835, 6443, 8604, 9602,
- 4463, 7399, 91, /* * 10000**26 */
- /* 65536**23 = */ 3856, 7535, 9761, 787, 8650, 9435, 6706, 6152,
- 3397, 429, 4551, 7122, 6488, 106, 8869, 529,
- 3252, 1747, 9008, 7027, 7780, 7032, 3970, 3063,
- 101, 119, 2269, 601, /* * 10000**27 */
- /* 65536**24 = */ 6816, 9030, 6279, 806, 1564, 8849, 6254, 1426,
- 6114, 7210, 7149, 7217, 4245, 9340, 9482, 6667,
- 6544, 2704, 9739, 507, 6138, 143, 4010, 2790,
- 9212, 9447, 1963, 2006, 3940, /* * 10000**28 */
- /* 65536**25 = */ 3376, 4749, 9727, 3171, 3590, 8314, 137, 5328,
- 6453, 4629, 4119, 168, 7622, 4064, 3565, 659,
- 1283, 2235, 2829, 579, 3297, 1874, 301, 1720,
- 5919, 8965, 9085, 8086, 4987, 5822, 2, /* * 10000**30 */
- /* 65536**26 = */ 9536, 2588, 9797, 8405, 5027, 9833, 2920, 6711,
- 8725, 8437, 3124, 7045, 6495, 8255, 2478, 1590,
- 7009, 1368, 5992, 3885, 5988, 6071, 8619, 3893,
- 8856, 9031, 3316, 3641, 1030, 3280, 9230, 16,
- /* * 10000**31 */
- /* 65536**27 = */ 1296, 9663, 3158, 4287, 4561, 8438, 9564, 1238,
- 5583, 4416, 9762, 1598, 2492, 2250, 2312, 8485,
- 2245, 9183, 681, 6630, 5032, 8301, 4574, 8137,
- 2334, 3657, 6567, 8313, 5943, 4832, 8776, 9067,
- 110, /* * 10000**32 */
- /* 65536**28 = */ 4656, 2861, 6016, 3534, 7793, 2661, 1606, 6252,
- 5607, 3565, 1376, 507, 6191, 2332, 3979, 8113,
- 3928, 1806, 199, 8149, 602, 7318, 6068, 6413,
- 4353, 453, 8880, 3807, 4932, 8905, 5606, 2429,
- 8387, 726, /* * 10000**33 */
- /* 65536**29 = */ 5616, 9009, 3328, 3652, 5212, 2370, 8260, 1598,
- 1326, 2590, 903, 5772, 6699, 525, 3031, 9646,
- 8579, 3763, 3502, 4169, 6077, 6398, 407, 2140,
- 240, 6340, 2651, 3748, 8507, 404, 3179, 3689,
- 6354, 4102, 4763, /* * 10000**34 */
- /* 65536**30 = */ 176, 629, 2853, 9288, 7567, 4479, 2895, 662,
- 1214, 6931, 5982, 9711, 3491, 306, 3061, 120,
- 6562, 8197, 1738, 2537, 9596, 9156, 5085, 9711,
- 2664, 9814, 7485, 6305, 9316, 2297, 1597, 3138,
- 9922, 315, 4855, 1217, 3, /* * 10000**36 */
- /* 65536**31 = */ 4336, 3297, 8330, 7065, 1783, 5341, 6078, 3807,
- 5044, 7972, 1775, 9304, 9821, 6900, 7703, 4380,
- 8020, 1596, 5292, 6227, 83, 506, 571, 3427,
- 1549, 7769, 1278, 3540, 4701, 7249, 6051, 2435,
- 8758, 8866, 9350, 9129, 4586, 20, /* * 10000**37 */
- /* 65536**32 = */ 4096, 608, 6490, 6433, 6994, 9465, 2811, 5388,
- 8537, 6050, 8648, 8581, 31, 2769, 9034, 8166,
- 7429, 8018, 6976, 7354, 300, 1764, 4372, 5614,
- 7723, 9337, 5923, 5820, 7936, 1274, 5846, 9820,
- 249, 9574, 9709, 9425, 7929, 780, 134, /* * 10000**38 */
- /* 65536**33 = */ 5456, 2731, 2627, 5621, 947, 4080, 3730, 6396,
- 6144, 8751, 4982, 1095, 7858, 9392, 370, 6183,
- 466, 6340, 1687, 7467, 8999, 7474, 4952, 7757,
- 1322, 249, 924, 8343, 1841, 4877, 1810, 1833,
- 2824, 3302, 1768, 435, 6718, 49, 6941, 878,
- /* * 10000**39 */
- /* 65536**34 = */ 4416, 4572, 973, 5074, 9431, 3089, 6019, 2703,
- 5103, 5805, 7706, 4575, 9067, 5610, 9876, 1518,
- 297, 1298, 782, 8372, 7400, 5044, 3259, 5210,
- 9431, 7132, 6896, 2903, 6453, 1142, 2123, 9353,
- 5677, 8380, 9289, 9748, 3699, 5291, 5701, 6096,
- 5758, /* * 10000**40 */
- /* 65536**35 = */ 6976, 9532, 6493, 6043, 3269, 2514, 1434, 3256,
- 7926, 9924, 8462, 7705, 4899, 6384, 307, 8375,
- 4146, 7675, 7658, 2517, 1267, 2086, 4885, 3921,
- 4162, 4562, 3002, 6206, 2837, 4404, 416, 2122,
- 9169, 8890, 8826, 5809, 1554, 5224, 5413, 4821,
- 6242, 7739, 3, /* * 10000**42 */
- /* 65536**36 = */ 9136, 4869, 7721, 6606, 6791, 8931, 5101, 4615,
- 9675, 1209, 675, 343, 1365, 3935, 1393, 6016,
- 7142, 5976, 4989, 4304, 612, 6401, 7031, 8671,
- 6531, 2510, 8972, 6092, 6305, 9140, 1839, 121,
- 3491, 5131, 9003, 6471, 1019, 252, 605, 4534,
- 7310, 4014, 7330, 24, /* * 10000**43 */
- /* 65536**37 = */ 6896, 4657, 5371, 1419, 8274, 6525, 7670, 2075,
- 1048, 6433, 4729, 3272, 8888, 3105, 7437, 3707,
- 7539, 9945, 8272, 9643, 6241, 9949, 5565, 8738,
- 2446, 8167, 5445, 4112, 4410, 364, 608, 1914,
- 6970, 8094, 4236, 2461, 3598, 1754, 932, 4189,
- 7874, 9413, 5190, 904, 162, /* * 10000**44 */
- /* 65536**38 = */ 6256, 6345, 4380, 786, 4167, 6625, 3887, 7470,
- 5331, 9957, 1903, 4788, 5414, 7530, 1586, 693,
- 203, 4930, 8972, 7865, 3377, 8571, 3045, 45,
- 8325, 8547, 7044, 9721, 711, 4008, 8276, 9888,
- 8463, 4063, 3545, 1862, 4659, 3725, 1049, 6413,
- 7917, 1973, 3534, 8563, 2759, 1062, /* * 10000**45 */
- /* 65536**39 = */ 3216, 6919, 9266, 4, 3666, 3309, 1852, 9398,
- 1373, 6894, 265, 8846, 3283, 1564, 9448, 6846,
- 8350, 3810, 1301, 9442, 6621, 1192, 3293, 9081,
- 7496, 750, 1603, 1625, 9808, 2953, 2203, 4208,
- 5975, 8237, 1752, 1267, 4429, 2134, 1679, 9245,
- 540, 4417, 7159, 7929, 9944, 7318, 6961, /* * 10000**46 */
- /* 65536**40 = */ 3776, 4660, 1922, 2874, 5008, 2649, 4360, 9467,
- 2519, 4188, 2221, 3197, 2661, 9825, 4379, 1375,
- 472, 6887, 7310, 9440, 5735, 2309, 7864, 3997,
- 7371, 1131, 9128, 6505, 7738, 2086, 5167, 9927,
- 5178, 9192, 3057, 5599, 7248, 2850, 8932, 1324,
- 29, 6057, 1171, 1864, 1952, 7622, 4061, 5624,
- 4, /* * 10000**48 */
- /* 65536**41 = */ 3936, 2506, 734, 3063, 3124, 7686, 4323, 7887,
- 7229, 1282, 2904, 3150, 2249, 8641, 6534, 704,
- 2006, 9526, 3294, 7751, 830, 215, 240, 8931,
- 2055, 9525, 24, 1502, 205, 8812, 8187, 9735,
- 468, 853, 3796, 6104, 1623, 5104, 6234, 8202,
- 9226, 1742, 2351, 6782, 8488, 8185, 1648, 1083,
- 9004, 29, /* * 10000**49 */
- /* 65536**42 = */ 9696, 9010, 9849, 1579, 4538, 171, 2501, 768,
- 1435, 4533, 4950, 7432, 1109, 1317, 8855, 170,
- 9834, 9082, 8014, 1129, 5679, 5684, 49, 3589,
- 5010, 3873, 5288, 5235, 4723, 4576, 982, 6620,
- 4652, 5281, 246, 6622, 4933, 6384, 4874, 7130,
- 8892, 4180, 6558, 560, 4016, 7791, 6974, 6293,
- 3242, 9553, 195, /* * 10000**50 */
- /* 65536**43 = */ 7056, 2903, 3118, 5896, 2722, 6397, 6659, 8038,
- 9194, 4092, 2908, 5995, 8133, 8184, 9911, 9152,
- 2143, 2400, 5030, 2670, 6348, 3842, 8518, 9028,
- 8880, 3763, 9753, 5617, 839, 3692, 6344, 4758,
- 6857, 6107, 6468, 1007, 2486, 4157, 4305, 3626,
- 2842, 8759, 2487, 3141, 6250, 7295, 9125, 3757,
- 8958, 6658, 2128, 1284, /* * 10000**51 */
- /* 65536**44 = */ 2016, 7250, 277, 692, 7634, 1634, 6149, 2012,
- 666, 3571, 5511, 7380, 3578, 9928, 935, 430,
- 3633, 450, 1810, 4086, 29, 916, 831, 4834,
- 8851, 169, 7275, 9631, 1521, 4414, 4580, 1866,
- 1538, 3293, 6875, 7144, 9099, 9444, 9724, 1751,
- 7078, 8451, 5436, 4880, 586, 6082, 3812, 8558,
- 6115, 7397, 4247, 2174, 8416, /* * 10000**52 */
- /* 65536**45 = */ 576, 9212, 986, 2732, 6359, 5854, 1577, 8731,
- 165, 3422, 2299, 1799, 6177, 4861, 1226, 6614,
- 5106, 5009, 3111, 1958, 7323, 1168, 6419, 6470,
- 816, 3593, 5513, 4893, 3378, 5878, 3808, 194,
- 6600, 128, 1582, 4242, 8887, 1619, 3962, 7269,
- 5289, 1123, 9085, 1310, 6081, 3795, 3091, 2074,
- 8728, 9872, 9872, 3101, 5226, 5156, 5, /* * 10000**54 */
- /* 65536**46 = */ 8736, 1406, 8868, 819, 1329, 9420, 8640, 5154,
- 660, 5279, 9690, 4332, 7663, 978, 8997, 3141,
- 162, 3291, 5326, 9879, 2961, 4041, 3243, 9988,
- 9781, 6199, 3515, 3780, 2678, 2749, 9612, 8943,
- 8873, 1861, 8795, 4079, 6233, 1028, 4248, 7150,
- 7544, 1594, 1923, 1700, 3007, 8973, 6650, 1923,
- 1802, 8593, 6094, 1839, 1465, 7867, 1473, 36,
- /* * 10000**55 */
- /* 65536**47 = */ 2496, 868, 2468, 2102, 2717, 7830, 2775, 9173,
- 7542, 8872, 8436, 5459, 764, 4431, 3806, 7539,
- 7422, 39, 6304, 5050, 6842, 387, 9733, 4823,
- 3075, 1771, 9672, 9119, 182, 6017, 49, 1443,
- 9543, 651, 1322, 8984, 2625, 1859, 3669, 240,
- 445, 3829, 6179, 3803, 7894, 4235, 3207, 9315,
- 8478, 2658, 2700, 647, 2296, 1314, 6086, 8954,
- 236, /* * 10000**56 */
- /* 65536**48 = */ 7856, 1605, 8538, 2846, 5089, 4687, 3716, 9919,
- 2629, 4825, 9844, 6315, 5285, 5026, 9055, 849,
- 7602, 4549, 9204, 8113, 411, 7275, 4428, 3914,
- 4814, 4411, 5800, 6171, 7320, 1310, 697, 8773,
- 9504, 6477, 2864, 4088, 878, 8633, 3768, 2686,
- 5095, 260, 2038, 3905, 6111, 6696, 1711, 8860,
- 5256, 255, 4625, 9488, 4897, 9351, 708, 9230,
- 5180, 1552, /* * 10000**57 */
- /* 65536**49 = */ 816, 6765, 6891, 1411, 1361, 585, 2496, 5940,
- 9151, 8435, 8006, 4356, 9152, 8575, 1421, 9410,
- 241, 3085, 3161, 3890, 8471, 7098, 1085, 6928,
- 5957, 847, 7711, 669, 3966, 136, 7182, 1896,
- 1639, 8963, 7557, 9941, 7400, 8044, 6225, 4395,
- 3525, 2752, 4075, 1436, 6089, 9107, 5982, 177,
- 5282, 6131, 5674, 5878, 1975, 9235, 773, 1926,
- 6970, 5825, 174, 1, /* * 10000**59 */
- /* 65536**50 = */ 7376, 6387, 2911, 6461, 3747, 7480, 1690, 198,
- 8866, 6135, 6501, 7289, 4024, 1181, 2859, 3078,
- 5846, 145, 9514, 5757, 951, 46, 3083, 523,
- 3356, 8036, 3650, 4119, 165, 8888, 445, 3324,
- 5934, 9910, 4292, 2907, 1554, 87, 4322, 1521,
- 3207, 8176, 7237, 6403, 8117, 6257, 6039, 9081,
- 2315, 5832, 1447, 7797, 2125, 7907, 9851, 7407,
- 8542, 2879, 1443, 6680, 6, /* * 10000**60 */
- /* 65536**51 = */ 3536, 6771, 7158, 7177, 5736, 3840, 4863, 7208,
- 3474, 1464, 9748, 4512, 4637, 4392, 5166, 8545,
- 3629, 1034, 458, 3103, 2471, 892, 7790, 5532,
- 2245, 9290, 9066, 6709, 436, 5052, 1768, 4586,
- 2408, 651, 5462, 1286, 1998, 1818, 7163, 8580,
- 3922, 3354, 7616, 4441, 7679, 1951, 2915, 1997,
- 5357, 1129, 8814, 3678, 5099, 7083, 6956, 9716,
- 7060, 4129, 7321, 9938, 6994, 43, /* * 10000**61 */
- /* 65536**52 = */ 5296, 7429, 1064, 8787, 1535, 5836, 6737, 5360,
- 9305, 7475, 4524, 2317, 8, 4504, 7762, 8978,
- 6147, 8012, 2266, 1210, 9792, 4307, 1287, 6205,
- 4579, 4156, 260, 445, 7670, 733, 757, 9686,
- 743, 9720, 1899, 5092, 9359, 7542, 6283, 5824,
- 8426, 3452, 4159, 5290, 53, 1064, 231, 4497,
- 9441, 5252, 1706, 9172, 2173, 4907, 4838, 3367,
- 7839, 4418, 6120, 4749, 3918, 3890, 286, /* * 10000**62 */
- /* 65536**53 = */ 8656, 1651, 8994, 1809, 5347, 8161, 4279, 7115,
- 7611, 2584, 3858, 6565, 9475, 4197, 9949, 3079,
- 8635, 4722, 7087, 3415, 6443, 7725, 3064, 9317,
- 9, 7629, 6599, 5226, 4036, 8154, 5560, 6657,
- 6726, 4795, 6565, 1763, 4796, 3850, 2121, 2845,
- 4508, 5496, 6852, 2698, 8079, 654, 5789, 6906,
- 4847, 6947, 8841, 7375, 9838, 9398, 5327, 1421,
- 8773, 9423, 9278, 574, 1175, 720, 8792, 1876,
- /* * 10000**63 */
- /* 65536**54 = */ 9616, 6663, 1609, 3568, 2853, 4339, 2031, 6688,
- 1127, 4908, 4827, 9125, 6626, 6691, 5175, 548,
- 3545, 7584, 4583, 1888, 833, 7827, 2934, 8997,
- 885, 4209, 2061, 4388, 7549, 6997, 3600, 9595,
- 8766, 9203, 5268, 2995, 2214, 5032, 7090, 3822,
- 4934, 5401, 8693, 1036, 3030, 3492, 2195, 9555,
- 8254, 361, 9307, 5944, 1506, 1807, 1869, 1573,
- 6644, 3223, 4768, 8474, 8567, 3620, 7231, 3155,
- 2300, 1, /* * 10000**65 */
- /* 65536**55 = */ 4176, 9387, 1096, 2997, 7592, 9403, 2053, 8081,
- 2903, 8078, 4437, 7637, 1340, 4806, 2654, 7647,
- 8714, 8256, 1192, 2008, 3864, 5732, 3919, 6625,
- 8324, 6829, 7280, 5477, 22, 4868, 5460, 1517,
- 1460, 5263, 3966, 4850, 6335, 1663, 3219, 5060,
- 9676, 2273, 9847, 2269, 875, 1570, 4407, 867,
- 6765, 2595, 5923, 6978, 6176, 3425, 8627, 377,
- 1494, 6071, 6774, 3313, 2450, 6470, 4545, 3471,
- 3481, 611, 8, /* * 10000**66 */
- /* 65536**56 = */ 8336, 3799, 8977, 8580, 8953, 4764, 7036, 9876,
- 3968, 8838, 6173, 7515, 8292, 4802, 4041, 1188,
- 821, 2329, 3024, 4105, 4264, 7676, 3151, 1687,
- 5084, 9900, 6839, 8386, 7690, 9395, 8462, 3897,
- 2505, 5537, 268, 5595, 2347, 7888, 1286, 3257,
- 9499, 6743, 7894, 5718, 8876, 7255, 7441, 8594,
- 6724, 255, 6739, 9026, 6070, 1279, 1522, 3612,
- 3260, 8847, 651, 5166, 4916, 3978, 3523, 5246,
- 3566, 5311, 8294, 52, /* * 10000**67 */
- /* 65536**57 = */ 8096, 5894, 1574, 7714, 43, 2184, 2523, 9650,
- 1575, 3179, 1651, 3501, 3766, 8219, 2451, 3254,
- 2844, 8725, 6127, 5099, 2408, 2283, 4244, 9887,
- 6081, 9719, 5587, 9722, 6802, 1122, 7208, 9254,
- 3224, 9251, 9936, 5679, 9659, 3352, 992, 9185,
- 7809, 1502, 5381, 6586, 5014, 1853, 928, 5154,
- 390, 5752, 8779, 2100, 2677, 330, 4178, 6007,
- 1032, 8359, 1917, 3248, 8832, 4428, 9401, 4946,
- 5758, 5069, 392, 2231, 346, /* * 10000**68 */
- /* 65536**58 = */ 9456, 2241, 2296, 5023, 8603, 910, 1641, 8936,
- 2443, 9272, 770, 2358, 1521, 5067, 2602, 212,
- 5711, 240, 6254, 8223, 4108, 4472, 9747, 2246,
- 9214, 4242, 3330, 7613, 9589, 5975, 845, 7383,
- 8715, 4670, 6325, 4066, 9448, 9976, 3685, 4663,
- 819, 6255, 9064, 5361, 669, 1072, 9555, 8626,
- 2817, 5631, 8240, 3137, 3640, 4425, 1572, 2133,
- 2522, 2191, 7294, 3496, 5239, 1291, 2961, 2669,
- 8708, 9722, 3335, 3388, 77, 2269, /* * 10000**69 */
- /* 65536**59 = */ 8416, 8146, 5348, 2376, 9128, 4143, 545, 451,
- 3012, 5808, 3486, 8940, 5709, 881, 7880, 687,
- 7487, 6067, 3720, 3514, 5782, 3919, 8702, 7736,
- 3429, 4098, 2686, 7394, 4598, 447, 7084, 7829,
- 4625, 239, 5811, 830, 779, 9057, 5544, 8524,
- 4545, 3050, 9297, 7901, 8723, 8979, 3505, 6156,
- 1449, 1683, 3545, 437, 1604, 657, 1594, 8593,
- 5771, 5905, 3944, 1659, 6020, 1312, 560, 4990,
- 4981, 8062, 6279, 7830, 8477, 1690, 4870, 1,
- /* * 10000**71 */
- /* 65536**60 = */ 976, 1411, 9919, 8589, 8182, 5470, 4277, 310,
- 7388, 2827, 6561, 4689, 3615, 4636, 9457, 4874,
- 2539, 5979, 3685, 7887, 2183, 3479, 9959, 3527,
- 3648, 9005, 6554, 789, 2987, 4730, 9956, 7769,
- 5312, 3419, 1265, 2963, 7987, 4657, 940, 5203,
- 6986, 4591, 8183, 866, 2314, 4916, 2530, 2592,
- 2010, 6588, 6150, 2465, 2610, 7664, 8690, 1294,
- 4572, 7906, 2686, 75, 7595, 2685, 8762, 8310,
- 7518, 3878, 3382, 8035, 9990, 1399, 1401, 7453,
- 9, /* * 10000**72 */
- /* 65536**61 = */ 3136, 7692, 831, 3710, 1847, 5547, 3325, 4193,
- 2002, 8690, 227, 1304, 3374, 8590, 4336, 4444,
- 7852, 6386, 9345, 6585, 6778, 4055, 5825, 741,
- 8449, 5589, 1961, 862, 1207, 4856, 7416, 4434,
- 8153, 2401, 5450, 1460, 5451, 3497, 4365, 9971,
- 8594, 1562, 1180, 7807, 5984, 141, 8299, 5895,
- 4348, 4342, 9576, 6548, 5118, 5010, 8068, 539,
- 9078, 7579, 1511, 2808, 6413, 3934, 4033, 1584,
- 4114, 7883, 8171, 3926, 7300, 339, 5111, 8990,
- 8668, 63, /* * 10000**73 */
- /* 65536**62 = */ 896, 3464, 828, 4011, 9306, 298, 3554, 4242,
- 553, 963, 3624, 437, 7010, 6352, 393, 406,
- 7799, 4357, 5776, 5807, 6169, 2904, 3779, 353,
- 8524, 6075, 2729, 4887, 7602, 726, 6801, 5228,
- 4071, 5370, 6940, 8278, 6307, 5116, 7561, 8064,
- 1732, 3560, 2722, 7286, 8588, 9797, 4191, 9108,
- 9166, 5810, 1194, 2488, 6167, 8905, 7284, 6781,
- 9345, 6837, 4571, 4995, 771, 654, 2474, 5457,
- 5487, 7250, 6320, 7890, 8534, 4547, 6722, 2135,
- 4968, 5580, 418, /* * 10000**74 */
- /* 65536**63 = */ 256, 2576, 6510, 324, 4303, 718, 6903, 7003,
- 9210, 4794, 8775, 2982, 226, 613, 7281, 195,
- 7925, 1463, 4495, 5408, 9644, 6976, 9579, 8975,
- 1179, 7063, 7562, 2320, 6701, 8959, 5098, 6779,
- 1322, 5003, 5035, 2493, 9807, 3514, 1228, 1859,
- 1205, 9516, 2323, 3137, 919, 2479, 5587, 9360,
- 2668, 4236, 8066, 1396, 6818, 8497, 2587, 7358,
- 8364, 879, 9869, 2280, 994, 5600, 350, 6166,
- 1796, 1963, 5037, 463, 5936, 8125, 2796, 3416,
- 6844, 3439, 620, 2743, /* * 10000**75 */
- /* 65536**64 = */ 7216, 2413, 6242, 6329, 3535, 3048, 9716, 3847,
- 2459, 9947, 9823, 5862, 684, 5051, 1633, 7237,
- 4082, 1105, 3913, 8147, 4628, 2342, 5068, 8381,
- 5768, 8500, 9520, 3082, 1945, 941, 1246, 1960,
- 3022, 5276, 6548, 4248, 7893, 7776, 1243, 9474,
- 3063, 8474, 2492, 1662, 8144, 9768, 5878, 3576,
- 1393, 7987, 1138, 1120, 3602, 4075, 7322, 847,
- 1327, 963, 550, 6758, 7732, 8115, 4300, 7273,
- 3065, 8942, 7697, 6179, 4733, 8902, 1907, 9305,
- 772, 3159, 4862, 9313, 7976, 1, /* * 10000**77 */
- /* 65536**65 = */ 7776, 5658, 1530, 8253, 1241, 6899, 7753, 668,
- 8242, 2709, 5318, 6414, 5047, 6822, 3390, 4737,
- 5381, 4036, 9612, 7436, 4002, 5647, 1799, 431,
- 6577, 3806, 8429, 4347, 7724, 2124, 4024, 8726,
- 2637, 7742, 4306, 9844, 3491, 9666, 2213, 6215,
- 8857, 2143, 1249, 7169, 6077, 9021, 4628, 5264,
- 5087, 5163, 2312, 7783, 8012, 2806, 1300, 6980,
- 1827, 9865, 1111, 5893, 8641, 5316, 7987, 1513,
- 5507, 3003, 9196, 7392, 2387, 2494, 5495, 4983,
- 4774, 3289, 6735, 8633, 6172, 7813, 11, /* * 10000**78 */
- /* 65536**66 = */ 7936, 3648, 7165, 8638, 4263, 1002, 5822, 8862,
- 2094, 1039, 8207, 2757, 2230, 9672, 1751, 6253,
- 262, 8564, 8485, 8691, 3810, 8024, 6274, 7809,
- 3097, 3119, 7891, 234, 8558, 9086, 788, 3509,
- 5621, 6999, 8755, 4608, 692, 3861, 4517, 749,
- 3084, 1697, 8514, 5770, 9255, 86, 9732, 1839,
- 6133, 5709, 3071, 1843, 5440, 6528, 5194, 9801,
- 16, 4618, 5148, 935, 5197, 6009, 876, 8315,
- 6672, 699, 8740, 2380, 2882, 2432, 6666, 1901,
- 1524, 9194, 6517, 6428, 4773, 3222, 2103, 77,
- /* * 10000**79 */
- /* 65536**67 = */ 3696, 7337, 9352, 6926, 6582, 5015, 7161, 8187,
- 465, 5633, 762, 6538, 3353, 8808, 6923, 8089,
- 1412, 2025, 9085, 8988, 9122, 5838, 5452, 1746,
- 6173, 7085, 5018, 7140, 8626, 6181, 1919, 994,
- 853, 3304, 3552, 7269, 1116, 9034, 1415, 6069,
- 7935, 4803, 4627, 8518, 3499, 6753, 6921, 4483,
- 4346, 5218, 8474, 2977, 7920, 4660, 6769, 2379,
- 2811, 5359, 9592, 9900, 6722, 9883, 8919, 7584,
- 685, 3395, 9225, 2958, 355, 2441, 8916, 7623,
- 9326, 7972, 8366, 8123, 5458, 8276, 3326, 56,
- 506, /* * 10000**80 */
- /* 65536**68 = */ 1056, 1854, 758, 3630, 3348, 6180, 6166, 165,
- 7899, 7340, 5348, 9365, 5055, 3066, 3454, 6080,
- 9848, 9658, 7831, 7108, 8301, 8955, 537, 1590,
- 5174, 3016, 6084, 9930, 331, 4552, 4097, 5364,
- 8723, 6534, 5525, 4464, 5816, 9542, 2645, 7263,
- 7934, 1414, 6554, 5974, 6290, 7544, 8914, 3249,
- 8840, 5332, 6263, 6210, 4635, 9666, 3728, 4508,
- 7291, 5847, 6434, 9265, 7878, 6347, 357, 3482,
- 1868, 9214, 1849, 5947, 4671, 5704, 4973, 9361,
- 8699, 4115, 6427, 3760, 8728, 1710, 6977, 1818,
- 1585, 3316, /* * 10000**81 */
- /* 65536**69 = */ 6016, 664, 8439, 648, 8318, 4423, 5479, 3853,
- 9949, 6006, 4636, 9693, 5857, 6510, 1440, 1518,
- 8376, 1231, 5717, 1215, 924, 9286, 1524, 5765,
- 3684, 485, 793, 2354, 7497, 2047, 824, 1957,
- 5684, 9394, 9226, 8916, 6634, 2630, 5258, 5308,
- 224, 9905, 2215, 5017, 595, 4810, 7348, 4887,
- 9538, 5887, 6917, 9608, 61, 1356, 1558, 726,
- 2522, 6777, 6947, 3209, 3331, 8627, 7952, 8695,
- 4067, 948, 6450, 4715, 7631, 7959, 7912, 5090,
- 9015, 7655, 6845, 7482, 2853, 3762, 5884, 173,
- 6479, 7764, 1732, 2, /* * 10000**83 */
-0}; /* end powers of 65536 in base 10000 */
-
-unsigned short _start_small_powers_two[] = {
- 0, 1, 3, 6, 10, 15, 22, 30,
- 39, 49, 60, 73, 87, 102, 118, 135,
- 154, 174, 195, 217, 240, 265, 291, 318,
- 346, 375, 406, 438, 471, 505, 540, 577,
- 615, 654, 694, 735, 778, 822, 867, 913,
- 960, 1009, 1059, 1110, 1162, 1215, 1270, 1326,
- 1383, 1441, 1501, 1562, 1624, 1687, 1751, 1817,
- 1884, 1952, 2021, 2091, 2163, 2236, 2310, 2385,
- 2461, 2539, 2618, 2698, 2779, 2861, 2945,
-0}; /* end _start_small_powers_two */
diff --git a/usr/src/lib/libbc/libc/gen/common/_sprintf_sup.c b/usr/src/lib/libbc/libc/gen/common/_sprintf_sup.c
deleted file mode 100644
index 676e7e342d..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_sprintf_sup.c
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "base_conversion.h"
-
-/*
- * Fundamental utilities of base conversion required for sprintf - but too
- * complex or too seldom used to be worth assembly language coding.
- */
-
-/* p = x * y + c ; return (p/10000 << 16 | p%10000) */
-unsigned long
-_prodc_b10000(_BIG_FLOAT_DIGIT x, _BIG_FLOAT_DIGIT y, unsigned long c)
-{
- unsigned long p = x * (unsigned long) y + c;
-
- return ((p / 10000) << 16) | (p % 10000);
-}
-
-/* p = x * y ; return p */
-unsigned long
-_prod_b65536(_BIG_FLOAT_DIGIT x, _BIG_FLOAT_DIGIT y)
-{
- return (x * (unsigned long)y);
-}
-
-/* p = x * y ; return (p/10000 << 16 | p%10000) */
-unsigned long
-_prod_b10000(_BIG_FLOAT_DIGIT x, _BIG_FLOAT_DIGIT y)
-{
- unsigned long p = x * (unsigned long) y;
-
- return ((p / 10000) << 16) | (p % 10000);
-}
-
-/* p = x << n + c ; return (p/10000 << 16 | p%10000) */
-unsigned long
-_lshift_b10000(_BIG_FLOAT_DIGIT x, short unsigned n, long unsigned c)
-{
- unsigned long p = (((unsigned long) x) << n) + c;
-
- return ((p / 10000) << 16) | (p % 10000);
-}
-
-/* p = x * 10000 + c ; return p */
-unsigned long
-_prod_10000_b65536(_BIG_FLOAT_DIGIT x, long unsigned c)
-{
- return (x * (unsigned long) 10000 + c);
-}
-
-/* p = x << 16 + c ; return (p/10000 << 16 | p%10000) */
-unsigned long
-_prod_65536_b10000(_BIG_FLOAT_DIGIT x, long unsigned c)
-{
- unsigned long p = (((unsigned long) x) << 16) + c;
-
- return ((p / 10000) << 16) | (p % 10000);
-}
-
-/* p = c ; return (p/10000 << 16 | p%10000) */
-unsigned long
-_carry_out_b10000(unsigned long c)
-{
- return ((c / 10000) << 16) | (c % 10000);
-}
-
-void
-_left_shift_base_ten(_big_float *pbf, short unsigned multiplier)
-{
- /*
- * Multiply a base-10**4 significand by 2<<multiplier. Extend length
- * as necessary to accommodate carries.
- */
-
- short unsigned length = pbf->blength;
- int j;
- unsigned long carry;
- long p;
-
- carry = 0;
- for (j = 0; j < length; j++) {
- p = _lshift_b10000((_BIG_FLOAT_DIGIT) pbf->bsignificand[j], multiplier, carry);
- pbf->bsignificand[j] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- while (carry != 0) {
- p = _carry_out_b10000(carry);
- pbf->bsignificand[j++] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- pbf->blength = j;
-}
-
-void
-_left_shift_base_two(_big_float *pbf, short unsigned multiplier)
-{
- /*
- * Multiply a base-2**16 significand by 2<<multiplier. Extend length
- * as necessary to accommodate carries.
- */
-
- short unsigned length = pbf->blength;
- long unsigned p;
- int j;
- unsigned long carry;
-
- carry = 0;
- for (j = 0; j < length; j++) {
- p = _lshift_b65536(pbf->bsignificand[j], multiplier, carry);
- pbf->bsignificand[j] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- if (carry != 0) {
- pbf->bsignificand[j++] = (_BIG_FLOAT_DIGIT) (_carry_out_b65536(carry) & 0xffff);
- }
- pbf->blength = j;
-}
-
-void
-_right_shift_base_two(_big_float *pbf, short unsigned multiplier,
- _BIG_FLOAT_DIGIT *sticky)
-{
- /* *pb = *pb / 2**multiplier to normalize. 15 <= multiplier <= 1 */
- /* Any bits shifted out got to *sticky. */
-
- long unsigned p;
- int j;
- unsigned long carry;
-
- carry = 0;
- for (j = pbf->blength - 1; j >= 0; j--) {
- p = _rshift_b65536(pbf->bsignificand[j], multiplier, carry);
- pbf->bsignificand[j] = (_BIG_FLOAT_DIGIT) (p >> 16);
- carry = p & 0xffff;
- }
- *sticky = (_BIG_FLOAT_DIGIT) carry;
-}
-
-void
-_multiply_base_ten(_big_float *pbf, _BIG_FLOAT_DIGIT multiplier)
-{
- /*
- * Multiply a base-10**4 significand by multiplier. Extend length as
- * necessary to accommodate carries.
- */
-
- int j;
- unsigned long carry;
- long p;
-
- carry = 0;
- for (j = 0; j < pbf->blength; j++) {
- p = _prodc_b10000((_BIG_FLOAT_DIGIT) pbf->bsignificand[j], multiplier, carry);
- pbf->bsignificand[j] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- while (carry != 0) {
- p = _carry_out_b10000(carry);
- pbf->bsignificand[j++] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- pbf->blength = j;
-}
-
-void
-_multiply_base_two(_big_float *pbf, _BIG_FLOAT_DIGIT multiplier,
- long unsigned carry)
-{
- /*
- * Multiply a base-2**16 significand by multiplier. Extend length as
- * necessary to accommodate carries.
- */
-
- short unsigned length = pbf->blength;
- long unsigned p;
- int j;
-
- for (j = 0; j < length; j++) {
- p = _prodc_b65536(pbf->bsignificand[j], multiplier, carry);
- pbf->bsignificand[j] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- if (carry != 0) {
- pbf->bsignificand[j++] = (_BIG_FLOAT_DIGIT) (_carry_out_b65536(carry) & 0xffff);
- }
- pbf->blength = j;
-}
-
-void
-_multiply_base_ten_by_two(_big_float *pbf, short unsigned multiplier)
-{
- /*
- * Multiply a base-10**4 significand by 2**multiplier. Extend length
- * as necessary to accommodate carries.
- */
-
- short unsigned length = pbf->blength;
- int j;
- long unsigned carry, p;
-
- carry = 0;
- for (j = 0; j < length; j++) {
- p = _lshift_b10000(pbf->bsignificand[j], multiplier, carry);
- pbf->bsignificand[j] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- while (carry != 0) {
- p = _carry_out_b10000(carry);
- pbf->bsignificand[j++] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- pbf->blength = j;
-}
-
-void
-_unpacked_to_big_float(unpacked *pu, _big_float *pb, int *pe)
-{
- /*
- * Converts pu into a bigfloat *pb of minimal length; exponent *pe
- * such that pu = *pb * 2 ** *pe
- */
-
- int iz, it;
-
- for (iz = (UNPACKED_SIZE - 2); pu->significand[iz] == 0; iz--); /* Find lsw. */
-
- for (it = 0; it <= iz; it++) {
- pb->bsignificand[2 * (iz - it)] = pu->significand[it] & 0xffff;
- pb->bsignificand[2 * (iz - it) + 1] = pu->significand[it] >> 16;
- }
-
- pb->blength = 2 * iz + 2;
- if (pb->bsignificand[0] == 0) {
- for (it = 1; it < pb->blength; it++)
- pb->bsignificand[it - 1] = pb->bsignificand[it];
- pb->blength--;
- }
- *pe = pu->exponent + 1 - 16 * pb->blength;
- pb->bexponent = 0;
-
-#ifdef DEBUG
- printf(" unpacked to big float 2**%d * ", *pe);
- _display_big_float(pb, 2);
-#endif
-}
-
-void
-_mul_65536short(_big_float *pbf, unsigned long carry)
-{
- /* *pbf *= 65536 ; += carry ; */
-
- long unsigned p;
- int j;
-
- for (j = 0; j < pbf->blength; j++) {
- p = _prod_65536_b10000(pbf->bsignificand[j], carry);
- pbf->bsignificand[j] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- while (carry != 0) {
- p = _carry_out_b10000(carry);
- pbf->bsignificand[j++] = (_BIG_FLOAT_DIGIT) (p & 0xffff);
- carry = p >> 16;
- }
- pbf->blength = j;
-}
-
-void
-_big_binary_to_big_decimal(_big_float *pb, _big_float *pd)
-{
- /* Convert _big_float from binary form to decimal form. */
-
- int i;
-
- pd->bsignificand[0] = pb->bsignificand[pb->blength - 1] % 10000;
- if (pd->bsignificand[0] == pb->bsignificand[pb->blength - 1]) {
- pd->blength = 1;
- } else {
- pd->blength = 2;
- pd->bsignificand[1] = pb->bsignificand[pb->blength - 1] / 10000;
- }
- for (i = pb->blength - 2; i >= 0; i--) { /* Multiply by 2**16 and
- * add next significand. */
- _mul_65536short(pd, (unsigned long) pb->bsignificand[i]);
- }
- for (i = 0; i <= (pb->bexponent - 16); i += 16) { /* Multiply by 2**16 for
- * each trailing zero. */
- _mul_65536short(pd, (unsigned long) 0);
- }
- if (pb->bexponent > i)
- _left_shift_base_ten(pd, (short unsigned) (pb->bexponent - i));
- pd->bexponent = 0;
-
-#ifdef DEBUG
- printf(" _big_binary_to_big_decimal ");
- _display_big_float(pd, 10);
-#endif
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_times_power.c b/usr/src/lib/libbc/libc/gen/common/_times_power.c
deleted file mode 100644
index e0fb6ae9f1..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_times_power.c
+++ /dev/null
@@ -1,454 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1995 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include "base_conversion.h"
-#include <malloc.h>
-
-void
-_copy_big_float_digits(_BIG_FLOAT_DIGIT *p1, _BIG_FLOAT_DIGIT *p2,
- short unsigned n)
-{ /* Copies p1[n] = p2[n] */
- short unsigned i;
-
- for (i = 0; i < n; i++)
- *p1++ = *p2++;
-}
-
-void
-_free_big_float(_big_float *p)
-{
- /* Central routine to call free for base conversion. */
-
- char *freearg = (char *) p;
-
- (void) free(freearg);
-#ifdef DEBUG
- printf(" free called with %X \n", freearg);
-#endif
-}
-
-void
-_base_conversion_abort(int ern, char *bcastring)
-{
- char pstring[160];
-
- errno = ern;
- (void) sprintf(pstring, " libc base conversion file %s line %d: %s", __FILE__, __LINE__, bcastring);
- perror(pstring);
- abort();
-}
-
-/*
- * function to multiply a big_float times a positive power of two or ten.
- *
- * Arguments
- * pbf: Operand x, to be replaced by the product x * mult ** n.
- * mult: if mult is two, x is base 10**4;
- * if mult is ten, x is base 2**16
- * n:
- * precision: Number of bits of precision ultimately required
- * (mult=10) or number of digits of precision ultimately
- * required (mult=2).
- * Extra bits are allowed internally to permit correct
- * rounding.
- * pnewbf: Return result *pnewbf is set to: pbf if uneventful
- * BIG_FLOAT_TIMES_TOOBIG if n is bigger than the tables
- * permit ;
- * BIG_FLOAT_TIMES_NOMEM if pbf->blength was
- * insufficient to hold the product, and malloc failed to
- * produce a new block ;
- * &newbf if pbf->blength was
- * insufficient to hold the product, and a new _big_float
- * was allocated by malloc. newbf holds the product.
- * It's the caller's responsibility to free this space
- * when no longer needed.
- *
- * if precision is < 0, then -pfb->bexponent/{4 or 16} digits are discarded
- * on the last product.
- */
- void
-_big_float_times_power(_big_float *pbf, int mult, int n, int precision,
- _big_float **pnewbf)
-{
- short unsigned base, sumlz = 0;
- unsigned short productsize, trailing_zeros_to_delete, needed_precision, *pp, *table[3], max[3], *start[3], *lz[3], tablepower[3];
- int i, j, itlast;
- _big_float *pbfold = pbf;
- int discard;
-
- if (precision >= 0)
- discard = -1;
- else {
- precision = -precision;
- discard = 0;
- }
- switch (mult) {
- case 2: /* *pbf is in base 10**4 so multiply by a
- * power of two */
- base = 10;
- max[0] = _max_tiny_powers_two;
- max[1] = _max_small_powers_two;
- max[2] = _max_big_powers_two;
- table[0] = _tiny_powers_two;
- table[1] = _small_powers_two;
- table[2] = _big_powers_two;
- lz[0] = 0;
- lz[1] = 0;
- lz[2] = 0;
- start[0] = _start_tiny_powers_two;
- start[1] = _start_small_powers_two;
- start[2] = _start_big_powers_two;
- needed_precision = 2 + (precision + 1) / 4; /* Precision is in base
- * ten; counts round and
- * sticky. */
- break;
- case 10: /* *pbf is in base 2**16 so multiply by a
- * power of ten */
- base = 2;
- max[0] = _max_tiny_powers_ten;
- max[1] = _max_small_powers_ten;
- max[2] = _max_big_powers_ten;
- table[0] = _tiny_powers_ten;
- table[1] = _small_powers_ten;
- table[2] = _big_powers_ten;
- start[0] = _start_tiny_powers_ten;
- start[1] = _start_small_powers_ten;
- start[2] = _start_big_powers_ten;
- lz[0] = _leading_zeros_tiny_powers_ten;
- lz[1] = _leading_zeros_small_powers_ten;
- lz[2] = _leading_zeros_big_powers_ten;
- needed_precision = 2 + (precision + 1) / 16; /* Precision is in base
- * two; counts round and
- * sticky. */
- break;
- }
- for (i = 0; i < 3; i++) {
- tablepower[i] = n % max[i];
- n = n / max[i];
- }
- for (itlast = 2; (itlast >= 0) && (tablepower[itlast] == 0); itlast--);
- /* Determine last i; could be 0, 1, or 2. */
- if (n > 0) { /* The tables aren't big enough to accomodate
- * mult**n, but it doesn't matter since the
- * result would undoubtedly overflow even
- * binary quadruple precision format. Return
- * an error code. */
- (void) printf("\n _times_power failed due to exponent %d %d %d leftover: %d \n", tablepower[0], tablepower[1], tablepower[2], n);
- *pnewbf = BIG_FLOAT_TIMES_TOOBIG;
- goto ret;
- }
- productsize = pbf->blength;
- for (i = 0; i < 3; i++)
- productsize += (start[i])[tablepower[i] + 1] - (start[i])[tablepower[i]];
-
- if (productsize < needed_precision)
- needed_precision = productsize;
-
- if (productsize <= pbf->bsize) {
- *pnewbf = pbf; /* Work with *pnewbf from now on. */
- } else { /* Need more significance than *pbf can hold. */
- char *mallocresult;
- int mallocarg;
-
- mallocarg = sizeof(_big_float) + sizeof(_BIG_FLOAT_DIGIT) * (productsize - _BIG_FLOAT_SIZE);
- mallocresult = malloc(mallocarg);
-#ifdef DEBUG
- printf(" malloc arg %X result %X \n", mallocarg, (int) mallocresult);
-#endif
- if (mallocresult == (char *) 0) { /* Not enough memory
- * left, bail out. */
- *pnewbf = BIG_FLOAT_TIMES_NOMEM;
- goto ret;
- }
- *pnewbf = (_big_float *) mallocresult;
- _copy_big_float_digits((*pnewbf)->bsignificand, pbf->bsignificand, pbf->blength);
- (*pnewbf)->blength = pbf->blength;
- (*pnewbf)->bexponent = pbf->bexponent;
- pbf = *pnewbf;
- pbf->bsize = productsize;
- }
-
- /* pbf now points to the input and the output big_floats. */
-
- for (i = 0; i <= itlast; i++)
- if (tablepower[i] != 0) { /* Step through each of the
- * tables. */
- unsigned lengthx, lengthp;
-
- /* Powers of 10**4 have leading zeros in base 2**16. */
- lengthp = (start[i])[tablepower[i] + 1] - (start[i])[tablepower[i]];
- lengthx = pbf->blength;
-
- if (discard >= 0)
- switch (base) {
- case 2:
- discard = (-pbf->bexponent) / 16;
- break;
- case 10:
- discard = (-pbf->bexponent) / 4;
- break;
- }
-
-#ifdef DEBUG
- {
- long basexp;
- int id;
-
- printf(" step %d x operand length %d \n", i, lengthx);
- _display_big_float(pbf, base);
- printf(" step %d p operand length %d power %d \n", i, lengthp, tablepower[i]);
- basexp = (base == 2) ? (lz[i])[tablepower[i]] : 0;
- for (id = 0; id < lengthp; id++) {
- printf("+ %d * ", (table[i])[id + (start[i])[tablepower[i]]]);
- if (base == 2)
- printf("2**%d", 16 * (basexp + id));
- if (base == 10)
- printf("10**%d", 4 * (basexp + id));
- if ((id % 4) == 3)
- printf("\n");
- }
- printf("\n");
- }
- if ((i == itlast) && (discard >= 0))
- printf(" alternative discard %d digits \n", discard);
-#endif
-
- if (base == 2) {
- sumlz += (lz[i])[tablepower[i]];
- pbf->bexponent += 16 * (lz[i])[tablepower[i]];
- }
- if (lengthp == 1) { /* Special case - multiply by
- * <= 10**4 or 2**13 */
- switch (base) {
- case 10:
- _multiply_base_ten_by_two(pbf, tablepower[i]);
- break;
- case 2:
- _multiply_base_two(pbf, (_BIG_FLOAT_DIGIT) ((table[i])[tablepower[i]]), (unsigned long) 0);
- break;
- }
-#ifdef DEBUG
- assert(pbf->blength <= pbf->bsize);
-#endif
- } else if (lengthx == 1) { /* Special case of short
- * multiplicand. */
- _BIG_FLOAT_DIGIT multiplier = pbf->bsignificand[0];
-
- _copy_big_float_digits(pbf->bsignificand, (unsigned short *) &((table[i])[(start[i])[tablepower[i]]]), lengthp);
- pbf->blength = lengthp;
- switch (base) {
- case 10:
- _multiply_base_ten(pbf, multiplier);
- break;
- case 2:
- _multiply_base_two(pbf, multiplier, (unsigned long) 0);
- break;
- }
-#ifdef DEBUG
- assert(pbf->blength <= pbf->bsize);
-#endif
- } else {/* General case. */
- short unsigned canquit;
- short unsigned excess;
-
- /*
- * The result will be accumulated in *pbf
- * from most significant to least
- * significant.
- */
-
- /* Generate criterion for early termination. */
- switch (base) {
- case 2:
- canquit = (short unsigned)65536;
- break;
- case 10:
- canquit = 10000;
- break;
- }
- canquit -= 3 + ((lengthx < lengthp) ? lengthx : lengthp);
-
- pbf->bsignificand[lengthx + lengthp - 1] = 0; /* Only gets filled by
- * carries. */
- for (j = lengthx + lengthp - 2; j >= 0; j--) {
- int istart = j - lengthp + 1, istop = lengthx - 1;
- short unsigned lengthprod;
- _BIG_FLOAT_DIGIT product[3];
-
- pp = (unsigned short *) &((table[i])[(start[i])[tablepower[i]]]);
- if (j < istop)
- istop = j;
- if (0 > istart)
- istart = 0;
-
- switch (base) {
- case 2:
- _multiply_base_two_vector((short unsigned) (istop - istart + 1), &(pbf->bsignificand[istart]), &(pp[j - istop]), product);
- if (product[2] != 0)
- _carry_propagate_two((unsigned long) product[2], &(pbf->bsignificand[j + 2]));
- if (product[1] != 0)
- _carry_propagate_two((unsigned long) product[1], &(pbf->bsignificand[j + 1]));
- break;
- case 10:
- _multiply_base_ten_vector((short unsigned) (istop - istart + 1), &(pbf->bsignificand[istart]), &(pp[j - istop]), product);
- if (product[2] != 0)
- _carry_propagate_ten((unsigned long) product[2], &(pbf->bsignificand[j + 2]));
- if (product[1] != 0)
- _carry_propagate_ten((unsigned long) product[1], &(pbf->bsignificand[j + 1]));
- break;
- }
- pbf->bsignificand[j] = product[0];
- lengthprod = lengthx + lengthp;
- if (pbf->bsignificand[lengthprod - 1] == 0)
- lengthprod--;
- if (lengthprod > needed_precision)
- excess = lengthprod - needed_precision;
- else
- excess = 0;
- if ((i == itlast) && ((j + 2) <= excess) && (pbf->bsignificand[j + 1] <= canquit)
- && ((pbf->bsignificand[j + 1] | pbf->bsignificand[j]) != 0)) {
- /*
- * On the last
- * multiplication, it's not
- * necessary to develop the
- * entire product, if further
- * digits can't possibly
- * affect significant digits,
- * unless there's a chance
- * the product might be
- * exact!
- */
- /*
- * Note that the product
- * might be exact if the j
- * and j+1 terms are zero; if
- * they are non-zero, then it
- * won't be after they're
- * discarded.
- */
-
- excess = j + 2; /* Can discard j+1, j,
- * ... 0 */
-#ifdef DEBUG
- printf(" decided to quit early at j %d since s[j+1] is %d <= %d \n", j, pbf->bsignificand[j + 1], canquit);
- printf(" s[j+2..j] are %d %d %d \n", pbf->bsignificand[j + 2], pbf->bsignificand[j + 1], pbf->bsignificand[j]);
- printf(" requested precision %d needed_precision %d big digits out of %d \n", precision, needed_precision, lengthprod);
-#endif
- if ((discard >= 0) && ((j + 2) > (discard - (int) sumlz))) {
-#ifdef DEBUG
- printf(" early quit rejected because j+2 = %d > %d = discard \n", j + 2, discard);
-#endif
- goto pastdiscard;
- }
- pbf->bsignificand[excess] |= 1; /* Sticky bit on. */
-#ifdef DEBUG
- printf(" discard %d digits - last gets %d \n", excess, pbf->bsignificand[excess]);
-#endif
- trailing_zeros_to_delete = excess;
- goto donegeneral;
- }
- pastdiscard: ;
-#ifdef DEBUG
- /*
- * else { printf(" early termination
- * rejected at j %d since s[j+1] =
- * %d, canquit = %d \n", j,
- * pbf->bsignificand[j + 1],
- * canquit); printf(" s[j+2..j] are
- * %d %d %d \n", pbf->bsignificand[j
- * + 2], pbf->bsignificand[j + 1],
- * pbf->bsignificand[j]); printf("
- * requested precision %d
- * needed_precision %d big digits out
- * of %d \n", precision,
- * needed_precision, lengthprod); }
- */
-#endif
- }
- trailing_zeros_to_delete = 0;
- donegeneral:
- pbf->blength = lengthx + lengthp;
- if (pbf->bsignificand[pbf->blength - 1] == 0)
- pbf->blength--;
- for (; pbf->bsignificand[trailing_zeros_to_delete] == 0; trailing_zeros_to_delete++);
- /*
- * Look for additional trailing zeros to
- * delete.
- */
-
- /*
- * fix for bug 1070565; if too many trailing
- * zeroes are deleted, we'll violate the
- * assertion that bexponent is in [-3,+4]
- */
- if (base == 10) {
- int deletelimit=(1-((pbf->bexponent+3)/4));
-
- if ((int)trailing_zeros_to_delete > deletelimit) {
-#ifdef DEBUG
- printf("\n __x_power trailing zeros delete count lowered from %d to "
- "%d \n", trailing_zeros_to_delete,deletelimit);
-#endif
-
- trailing_zeros_to_delete = deletelimit;
- }
- }
-
-
- if (trailing_zeros_to_delete != 0) {
-#ifdef DEBUG
- printf(" %d trailing zeros deleted \n", trailing_zeros_to_delete);
-#endif
- _copy_big_float_digits(pbf->bsignificand, &(pbf->bsignificand[trailing_zeros_to_delete]), pbf->blength - trailing_zeros_to_delete);
- pbf->blength -= trailing_zeros_to_delete;
- switch (base) {
- case 2:
- pbf->bexponent += 16 * trailing_zeros_to_delete;
- break;
- case 10:
- pbf->bexponent += 4 * trailing_zeros_to_delete;
- break;
- }
- }
- }
- }
- if ((pbfold != pbf) && (pbf->blength <= pbfold->bsize)) { /* Don't need that huge
- * buffer after all! */
-#ifdef DEBUG
- printf(" free called from times_power because final length %d <= %d original size \n", pbf->blength, pbfold->bsize);
-#endif
-
- /* Copy product to original buffer. */
- pbfold->blength = pbf->blength;
- pbfold->bexponent = pbf->bexponent;
- _copy_big_float_digits(pbfold->bsignificand, pbf->bsignificand, pbf->blength);
- _free_big_float(*pnewbf); /* Free new buffer. */
- *pnewbf = pbfold; /* New buffer pointer now agrees with
- * original. */
- }
-ret:
- return;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/_unpack_dble.c b/usr/src/lib/libbc/libc/gen/common/_unpack_dble.c
deleted file mode 100644
index 6860502073..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/_unpack_dble.c
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "base_conversion.h"
-
-/* Normalize a number. Does not affect zeros, infs, or NaNs. */
-void
-_fp_normalize(unpacked *pu)
-{
- int i;
- short unsigned nlzwords, nlzbits;
- long unsigned t;
-
- if ((*pu).fpclass == fp_normal) {
- for (nlzwords = 0; (pu->significand[nlzwords] == 0) && (nlzwords < UNPACKED_SIZE); nlzwords++);
- if (nlzwords >= UNPACKED_SIZE) {
- (*pu).fpclass = fp_zero;
- return;
- }
- if (nlzwords > 0) {
- for (i = 0; i < UNPACKED_SIZE - nlzwords; i++)
- pu->significand[i] = pu->significand[i + nlzwords];
- for (; i < UNPACKED_SIZE; i++)
- pu->significand[i] = 0;
- pu->exponent -= 32 * nlzwords;
- }
- for (; pu->significand[UNPACKED_SIZE - 1 - nlzwords] == 0; nlzwords++);
- /* nlzwords is now the count of trailing zero words. */
-
- nlzbits = 0;
- t = pu->significand[0];
- /* TESTS to determine normalize count. */
-
-#define SHIFTMACRO(n) if (t <= (((unsigned long) 0xffffffff) >> n)) { t = t<<n ; nlzbits += n ; }
- SHIFTMACRO(16);
- SHIFTMACRO(8);
- SHIFTMACRO(4);
- SHIFTMACRO(2);
- SHIFTMACRO(1);
- pu->exponent -= nlzbits;
- if (nlzbits >= 1) { /* small shift */
- unsigned long high, low, shiftout = 0;
- for (i = UNPACKED_SIZE - 1 - nlzwords; i >= 0; i--) {
- high = pu->significand[i] << nlzbits;
- low = pu->significand[i] >> (32 - nlzbits);
- pu->significand[i] = shiftout | high;
- shiftout = low;
- }
- }
- }
-}
-
-/* Set the exception bit in the current exception register. */
-void
-_fp_set_exception(enum fp_exception_type ex)
-{
- _fp_current_exceptions |= 1 << (int) ex;
-}
-
-enum fp_class_type
-_class_double(double *x)
-{
- double_equivalence kluge;
-
- kluge.x = *x;
- if (kluge.f.msw.exponent == 0) { /* 0 or sub */
- if ((kluge.f.msw.significand == 0) && (kluge.f.significand2 == 0))
- return fp_zero;
- else
- return fp_subnormal;
- } else if (kluge.f.msw.exponent == 0x7ff) { /* inf or nan */
- if ((kluge.f.msw.significand == 0) && (kluge.f.significand2 == 0))
- return fp_infinity;
- else if (kluge.f.msw.significand >= 0x40000)
- return fp_quiet;
- else
- return fp_signaling;
- } else
- return fp_normal;
-}
-
-
-/* Left shift significand by 11 <= n <= 16 bits. Affect all classes. */
-void
-_fp_leftshift(unpacked *pu, unsigned n)
-{
- int i;
-
- unsigned long high, low, shiftout = 0;
- for (i = UNPACKED_SIZE - 1; i >= 0; i--) {
- high = pu->significand[i] << n;
- low = pu->significand[i] >> (32 - n);
- pu->significand[i] = shiftout | high;
- shiftout = low;
- }
-}
-
-
-void
-_unpack_double(unpacked *pu, double *px)
-{
- double_equivalence x;
- int i;
-
- x.x = *px;
- (*pu).sign = x.f.msw.sign;
- pu->significand[1] = x.f.significand2;
- for (i = 2; i < UNPACKED_SIZE; i++)
- pu->significand[i] = 0;
- if (x.f.msw.exponent == 0) { /* zero or sub */
- if ((x.f.msw.significand == 0) && (x.f.significand2 == 0)) { /* zero */
- pu->fpclass = fp_zero;
- return;
- } else { /* subnormal */
- pu->fpclass = fp_normal;
- pu->exponent = 12 - DOUBLE_BIAS;
- pu->significand[0] = x.f.msw.significand;
- _fp_normalize(pu);
- return;
- }
- } else if (x.f.msw.exponent == 0x7ff) { /* inf or nan */
- if ((x.f.msw.significand == 0) && (x.f.significand2 == 0)) { /* inf */
- pu->fpclass = fp_infinity;
- return;
- } else { /* nan */
- if ((x.f.msw.significand & 0x80000) != 0) { /* quiet */
- pu->fpclass = fp_quiet;
- } else {/* signaling */
- pu->fpclass = fp_quiet;
- _fp_set_exception(fp_invalid);
- }
- pu->significand[0] = 0x80000 | x.f.msw.significand;
- _fp_leftshift(pu, 11);
- return;
- }
- }
- (*pu).exponent = x.f.msw.exponent - DOUBLE_BIAS;
- (*pu).fpclass = fp_normal;
- (*pu).significand[0] = 0x100000 | x.f.msw.significand;
- _fp_leftshift(pu, 11);
-}
-
-enum fp_class_type
-_class_quadruple(quadruple *x)
-{
- quadruple_equivalence kluge;
- int i;
-
- for (i = 0; i < 4; i++)
-#ifdef __STDC__
- kluge.x = *x;
-#else
- kluge.x.u[i] = x->u[i];
-#endif
- if (kluge.f.msw.exponent == 0) { /* 0 or sub */
- if ((kluge.f.msw.significand == 0) && (kluge.f.significand2 == 0) && (kluge.f.significand3 == 0) && (kluge.f.significand4 == 0))
- return fp_zero;
- else
- return fp_subnormal;
- } else if (kluge.f.msw.exponent == 0x7fff) { /* inf or nan */
- if ((kluge.f.msw.significand == 0) && (kluge.f.significand2 == 0) && (kluge.f.significand3 == 0) && (kluge.f.significand4 == 0))
- return fp_infinity;
- else if ((kluge.f.msw.significand & 0xffff) >= 0x8000)
- return fp_quiet;
- else
- return fp_signaling;
- } else
- return fp_normal;
-}
-
-void
-_unpack_quadruple(unpacked *pu, quadruple *px)
-{
- quadruple_equivalence x;
- int i;
-
- for (i = 0; i < 4; i++)
-#ifdef __STDC__
- x.x = *px;
-#else
- x.x.u[i] = px->u[i];
-#endif
- (*pu).sign = x.f.msw.sign;
- pu->significand[1] = x.f.significand2;
- pu->significand[2] = x.f.significand3;
- pu->significand[3] = x.f.significand4;
- for (i = 4; i < UNPACKED_SIZE; i++)
- pu->significand[i] = 0;
- if (x.f.msw.exponent == 0) { /* zero or sub */
- if ((x.f.msw.significand | x.f.significand2 | x.f.significand3 | x.f.significand4) == 0) { /* zero */
- pu->fpclass = fp_zero;
- goto ret;
- } else { /* subnormal */
- pu->fpclass = fp_normal;
- pu->exponent = 16 - QUAD_BIAS;
- pu->significand[0] = x.f.msw.significand;
- _fp_normalize(pu);
- goto ret;
- }
- } else if (x.f.msw.exponent == 0x7fff) { /* inf or nan */
- if ((x.f.msw.significand | x.f.significand2 | x.f.significand3 | x.f.significand4) == 0) { /* inf */
- pu->fpclass = fp_infinity;
- goto ret;
- } else { /* nan */
- if ((x.f.msw.significand & 0x8000) != 0) { /* quiet */
- pu->fpclass = fp_quiet;
- } else {/* signaling */
- pu->fpclass = fp_quiet;
- _fp_set_exception(fp_invalid);
- }
- pu->significand[0] = 0x8000 | x.f.msw.significand;
- _fp_leftshift(pu, 16);
- goto ret;
- }
- }
- (*pu).exponent = x.f.msw.exponent - QUAD_BIAS;
- (*pu).fpclass = fp_normal;
- (*pu).significand[0] = 0x10000 | x.f.msw.significand;
- _fp_leftshift(pu, 15);
-ret:
- /*
- * printf("/n _unpack_quadruple ") ; _display_unpacked(pu);
- */
- return;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/a64l.c b/usr/src/lib/libbc/libc/gen/common/a64l.c
deleted file mode 100644
index 86c694169f..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/a64l.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.5 */
-
-/*LINTLIBRARY*/
-/*
- * convert base 64 ascii to long int
- * char set is [./0-9A-Za-z]
- *
- */
-
-#define BITSPERCHAR 6 /* to hold entire character set */
-
-long
-a64l(s)
-register char *s;
-{
- register int i, c;
- long lg = 0;
-
- for (i = 0; (c = *s++) != '\0'; i += BITSPERCHAR) {
- if (c > 'Z')
- c -= 'a' - 'Z' - 1;
- if (c > '9')
- c -= 'A' - '9' - 1;
- lg |= (long)(c - ('0' - 2)) << i;
- }
- return (lg);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/abs.c b/usr/src/lib/libbc/libc/gen/common/abs.c
deleted file mode 100644
index dde5f1b6cb..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/abs.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-
-int
-abs(arg)
-register int arg;
-{
- return (arg >= 0 ? arg : -arg);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/alarm.c b/usr/src/lib/libbc/libc/gen/common/alarm.c
deleted file mode 100644
index b16d671fde..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/alarm.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Backwards compatible alarm.
- */
-#include <sys/time.h>
-
-unsigned int
-alarm(unsigned int secs)
-{
- struct itimerval it, oitv;
- struct itimerval *itp = &it;
-
- timerclear(&itp->it_interval);
- itp->it_value.tv_sec = secs;
- itp->it_value.tv_usec = 0;
- if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
- return (-1);
- if (oitv.it_value.tv_usec)
- oitv.it_value.tv_sec++;
- return (oitv.it_value.tv_sec);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/asctime.c b/usr/src/lib/libbc/libc/gen/common/asctime.c
deleted file mode 100644
index 92c9332531..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/asctime.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*LINTLIBRARY*/
-
-#include <time.h>
-#include <tzfile.h>
-
-static char cbuf[26];
-
-static char *ct_numb(char *, int);
-
-char *
-asctime(struct tm *t)
-{
- char *cp, *ncp;
- int *tp;
-
- cp = cbuf;
- for (ncp = "Day Mon 00 00:00:00 1900\n"; *cp++ = *ncp++;);
- ncp = &"SunMonTueWedThuFriSat"[3*t->tm_wday];
- cp = cbuf;
- *cp++ = *ncp++;
- *cp++ = *ncp++;
- *cp++ = *ncp++;
- cp++;
- tp = &t->tm_mon;
- ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[(*tp)*3];
- *cp++ = *ncp++;
- *cp++ = *ncp++;
- *cp++ = *ncp++;
- cp = ct_numb(cp, *--tp);
- cp = ct_numb(cp, *--tp+100);
- cp = ct_numb(cp, *--tp+100);
- cp = ct_numb(cp, *--tp+100);
- cp = ct_numb(cp, (t->tm_year + TM_YEAR_BASE)/100);
- cp--;
- cp = ct_numb(cp, t->tm_year+100);
- return (cbuf);
-}
-
-static char *
-ct_numb(char *cp, int n)
-{
- cp++;
- if (n>=10)
- *cp++ = (n/10)%10 + '0';
- else
- *cp++ = ' ';
- *cp++ = n%10 + '0';
- return (cp);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/atof.c b/usr/src/lib/libbc/libc/gen/common/atof.c
deleted file mode 100644
index bfad17cd09..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/atof.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1986 by Sun Microsystems, Inc.
- */
-
-#include <stdio.h>
-
-extern double
-strtod();
-
-double
-atof(cp)
- char *cp;
-{
- return strtod(cp, (char **) NULL);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/atoi.c b/usr/src/lib/libbc/libc/gen/common/atoi.c
deleted file mode 100644
index 0ace01d68b..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/atoi.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 2.1 */
-
-/*LINTLIBRARY*/
-#include <ctype.h>
-
-#define ATOI
-
-#ifdef ATOI
-typedef int TYPE;
-#define NAME atoi
-#else
-typedef long TYPE;
-#define NAME atol
-#endif
-
-TYPE
-NAME(p)
-register char *p;
-{
- register TYPE n;
- register int c, neg = 0;
-
- if (!isdigit(c = *p)) {
- while (isspace(c))
- c = *++p;
- switch (c) {
- case '-':
- neg++;
- case '+': /* fall-through */
- c = *++p;
- }
- if (!isdigit(c))
- return (0);
- }
- for (n = '0' - c; isdigit(c = *++p); ) {
- n *= 10; /* two steps to avoid unnecessary overflow */
- n += '0' - c; /* accum neg to avoid surprises at MAX */
- }
- return (neg ? n : -n);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/atol.c b/usr/src/lib/libbc/libc/gen/common/atol.c
deleted file mode 100644
index 5a2f88fab5..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/atol.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 2.1 */
-
-/*LINTLIBRARY*/
-#include <ctype.h>
-
-#define ATOL
-
-#ifdef ATOI
-typedef int TYPE;
-#define NAME atoi
-#else
-typedef long TYPE;
-#define NAME atol
-#endif
-
-TYPE
-NAME(p)
-register char *p;
-{
- register TYPE n;
- register int c, neg = 0;
-
- if (!isdigit(c = *p)) {
- while (isspace(c))
- c = *++p;
- switch (c) {
- case '-':
- neg++;
- case '+': /* fall-through */
- c = *++p;
- }
- if (!isdigit(c))
- return (0);
- }
- for (n = '0' - c; isdigit(c = *++p); ) {
- n *= 10; /* two steps to avoid unnecessary overflow */
- n += '0' - c; /* accum neg to avoid surprises at MAX */
- }
- return (neg ? n : -n);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/base_conversion.h b/usr/src/lib/libbc/libc/gen/common/base_conversion.h
deleted file mode 100644
index b506e69143..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/base_conversion.h
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1995 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _base_conversion_h
-#define _base_conversion_h
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <errno.h>
-
-#include <floatingpoint.h>
-
-#ifdef DEBUG
-#include <stdio.h>
-#include <assert.h>
-#endif
-
-/* Sun floating-point PRIVATE include file. */
-
-/* PRIVATE MACROS */
-
-#ifdef DEBUG
-#define PRIVATE
-#else
-#define PRIVATE static
-#endif
-
-/* PRIVATE CONSTANTS */
-
-#define SINGLE_BIAS 127
-#define DOUBLE_BIAS 1023
-#define EXTENDED_BIAS 16383
-#define QUAD_BIAS 16383
-
-#define SINGLE_MAXE 97 /* Maximum decimal exponent we need to
- * consider. */
-#define DOUBLE_MAXE 771 /* Maximum decimal exponent we need to
- * consider. */
-#define EXTENDED_MAXE 12330 /* Maximum decimal exponent we need to
- * consider. */
-#define QUAD_MAXE 12330 /* Maximum decimal exponent we need to
- * consider. */
-
-#define UNPACKED_SIZE 5 /* Size of unpacked significand. */
-
-/* PRIVATE TYPES */
-
-/*
- * Unpack floating-point internal format.
- * Value is 0.s0s1..sn * 2**(1+exponent)
- */
-typedef struct {
- int sign;
- enum fp_class_type fpclass;
- int exponent; /* Unbiased exponent. */
- unsigned significand[UNPACKED_SIZE]; /* Last word is round */
- /* and sticky. */
-} unpacked;
-
-#ifdef i386
-typedef struct { /* Most significant word formats. */
- unsigned significand:23;
- unsigned exponent:8;
- unsigned sign:1;
-} single_msw;
-
-typedef struct {
- unsigned significand:20;
- unsigned exponent:11;
- unsigned sign:1;
-} double_msw;
-
-typedef struct {
- unsigned exponent:15;
- unsigned sign:1;
- unsigned unused:16;
-} extended_msw;
-
-typedef struct {
- unsigned significand:16;
- unsigned exponent:15;
- unsigned sign:1;
-} quadruple_msw;
-
-typedef struct { /* Floating-point formats in detail. */
- single_msw msw;
-} single_formatted;
-
-typedef struct {
- unsigned significand2;
- double_msw msw;
-} double_formatted;
-
-typedef struct {
- unsigned significand2;
- unsigned significand;
- extended_msw msw;
-} extended_formatted;
-
-typedef struct {
- unsigned significand4;
- unsigned significand3;
- unsigned significand2;
- quadruple_msw msw;
-} quadruple_formatted;
-#else
-typedef struct { /* Most significant word formats. */
- unsigned sign:1;
- unsigned exponent:8;
- unsigned significand:23;
-} single_msw;
-
-typedef struct {
- unsigned sign:1;
- unsigned exponent:11;
- unsigned significand:20;
-} double_msw;
-
-typedef struct {
- unsigned sign:1;
- unsigned exponent:15;
- unsigned unused:16;
-} extended_msw;
-
-typedef struct {
- unsigned sign:1;
- unsigned exponent:15;
- unsigned significand:16;
-} quadruple_msw;
-
-typedef struct { /* Floating-point formats in detail. */
- single_msw msw;
-} single_formatted;
-
-typedef struct {
- double_msw msw;
- unsigned significand2;
-} double_formatted;
-
-typedef struct {
- extended_msw msw;
- unsigned significand;
- unsigned significand2;
-} extended_formatted;
-
-typedef struct {
- quadruple_msw msw;
- unsigned significand2;
- unsigned significand3;
- unsigned significand4;
-} quadruple_formatted;
-#endif
-
-typedef union { /* Floating-point formats equivalenced. */
- single_formatted f;
- single x;
-} single_equivalence;
-
-typedef union {
- double_formatted f;
- double x;
-} double_equivalence;
-
-typedef union {
- extended_formatted f;
- extended x;
-} extended_equivalence;
-
-typedef union {
- quadruple_formatted f;
- quadruple x;
-} quadruple_equivalence;
-
-/* PRIVATE GLOBAL VARIABLES */
-
-/* Current floating-point exceptions. */
-fp_exception_field_type _fp_current_exceptions;
-
-/* Current rounding direction. */
-enum fp_direction_type _fp_current_direction;
-
-/* Current rounding precision. */
-enum fp_precision_type _fp_current_precision;
-
-/* PRIVATE FUNCTIONS */
-
-extern void _fp_set_exception(enum fp_exception_type);
-/* enum fp_exception_type ex ; */ /* exception to be set in curexcep */
-
-/*
- * Default size for _big_float - suitable for single and double precision.
- */
-
-#define _BIG_FLOAT_SIZE (DECIMAL_STRING_LENGTH/2)
-#define _BIG_FLOAT_DIGIT short unsigned /* big_float significand type */
-
-/* Maximum number of integer digits in a representable extended or quad. */
-#define _INTEGER_SIZE 4932
-
-typedef struct { /* Variable-precision floating-point type */
- /* used for intermediate results. */
- unsigned short bsize; /* Maximum allowable logical length of */
- /* significand. */
- unsigned short blength; /* Logical length of significand. */
- short int bexponent; /*
- * Exponent to be attached to least
- * significant word of significand.
- * exponent >= 0 implies all integer,
- * with decimal point to right of
- * least significant word of
- * significand, and is equivalent to
- * number of omitted trailing zeros
- * of significand. -length < exponent
- * < 0 implies decimal point within
- * significand. exponent = -length
- * implies decimal point to left of
- * most significand word. exponent <
- * -length implies decimal point to
- * left of most significant word with
- * -length-exponent leading zeros.
- */
- /*
- * NOTE: bexponent represents a power of 2 or 10, even though big
- * digits are powers of 2**16 or 10**4.
- */
- _BIG_FLOAT_DIGIT bsignificand[_BIG_FLOAT_SIZE];
- /*
- * Significand of digits in base 10**4 or 2**16. significand[0] is
- * least significant, significand[length-1] is most significant.
- */
-} _big_float;
-
-#define BIG_FLOAT_TIMES_NOMEM (_big_float *)0
-#define BIG_FLOAT_TIMES_TOOBIG (_big_float *)1
-
-/* Internal functions defined in base conversion support routines. */
-
-extern void _multiply_base_ten(_big_float *, _BIG_FLOAT_DIGIT);
-extern void _multiply_base_ten_by_two(_big_float *, short unsigned);
-extern void _multiply_base_two(_big_float *, _BIG_FLOAT_DIGIT,
- long unsigned);
-extern void _carry_propagate_two(unsigned long, _BIG_FLOAT_DIGIT *);
-extern void _carry_propagate_ten(unsigned long, _BIG_FLOAT_DIGIT *);
-extern void _multiply_base_two_vector(short unsigned, _BIG_FLOAT_DIGIT *,
- short unsigned *, _BIG_FLOAT_DIGIT []);
-extern void _multiply_base_ten_vector(short unsigned, _BIG_FLOAT_DIGIT *,
- short unsigned *, _BIG_FLOAT_DIGIT []);
-extern void _fourdigitsquick(short unsigned, char*);
-extern void _unpacked_to_big_float(unpacked *, _big_float *, int *);
-extern void _big_binary_to_big_decimal(_big_float *, _big_float *);
-extern void _left_shift_base_ten(_big_float *, short unsigned);
-extern void _left_shift_base_two(_big_float *, short unsigned);
-extern void _right_shift_base_two(_big_float *, short unsigned,
- _BIG_FLOAT_DIGIT *);
-extern void _free_big_float(_big_float *);
-extern void _base_conversion_abort(int, char *);
-extern void _display_big_float(_big_float *, unsigned);
-extern void _integerstring_to_big_decimal(char [], unsigned, unsigned,
- unsigned *, _big_float *);
-extern void _fractionstring_to_big_decimal(char [], unsigned, unsigned,
- _big_float *);
-extern void _big_decimal_to_big_binary(_big_float *, _big_float *);
-extern void _fp_rightshift(unpacked *, int);
-extern void _fp_leftshift(unpacked *, unsigned);
-extern void _fp_normalize(unpacked *);
-extern void _pack_single(unpacked *, single *);
-extern void _pack_double(unpacked *, double *);
-extern void _pack_extended(unpacked *, extended *);
-extern void _pack_quadruple(unpacked *, quadruple *);
-extern void _unpack_single(unpacked *, single *);
-extern void _unpack_double(unpacked *, double *);
-extern void _unpack_extended(unpacked *, extended *);
-extern void _unpack_quadruple(unpacked *, quadruple *);
-extern void _unpacked_to_decimal(unpacked *, decimal_mode *,
- decimal_record *, fp_exception_field_type *);
-extern enum fp_class_type _class_single(single *);
-extern enum fp_class_type _class_double(double *);
-extern enum fp_class_type _class_extended(extended *);
-extern enum fp_class_type _class_quadruple(quadruple *);
-
-/*
- * Fundamental utilities that multiply or add two shorts into a unsigned long,
- * sometimes add an unsigned long carry,
- * compute quotient and remainder in underlying base, and return
- * quo<<16 | rem as a unsigned long.
- */
-
-extern unsigned long _umac(_BIG_FLOAT_DIGIT, _BIG_FLOAT_DIGIT, unsigned long);
- /* p = x * y + c ; return p */
-
-#define _prodc_b65536(x,y,c) (_umac((x),(y),(c)))
-
-extern unsigned long _prodc_b10000(_BIG_FLOAT_DIGIT, _BIG_FLOAT_DIGIT,
- unsigned long);
-/* p = x * y + c ; return (p/10000 << */
-
-extern unsigned long _prod_b10000(_BIG_FLOAT_DIGIT, _BIG_FLOAT_DIGIT);
-/* p = x * y ; return (p/10000 << 16 | p%10000) */
-
-extern unsigned long _prod_10000_b65536(_BIG_FLOAT_DIGIT, long unsigned);
-/* p = x * 10000 + c ; return p */
-
-extern unsigned long _prod_65536_b10000(_BIG_FLOAT_DIGIT, long unsigned);
-/* p = x * 65536 + c ; return (p/10000 << 16 | p%10000) */
-
-#define _rshift_b65536(x,n,c) ((((unsigned long) (x)) << (16-(n))) + ((c)<<16))
-
-#define _lshift_b65536(x,n,c) ((((unsigned long) (x)) << (n)) + (c))
-
-extern unsigned long _lshift_b10000(_BIG_FLOAT_DIGIT, _BIG_FLOAT_DIGIT,
- long unsigned);
-/* p = x << n + c ; return (p/10000 << 16 | p%10000) */
-
-#define _carry_in_b65536(x,c) ((x) + (c))
-
-extern unsigned long _carry_in_b10000(_BIG_FLOAT_DIGIT, long unsigned);
-/* p = x + c ; return (p/10000 << 16 | p%10000) */
-
-#define _carry_out_b65536(c) (c)
-
-extern unsigned long _carry_out_b10000(unsigned long);
-/* p = c ; return (p/10000 << 16 | p%10000) */
-
-/*
- * Header file for revised "fast" base conversion based upon table look-up
- * methods.
- */
-
-extern void
-_big_float_times_power(_big_float *, int, int, int, _big_float **);
-
-/* Variables defined in _small_powers.c and _big_powers.c */
-/* Used in base conversion. */
-
-/*
- * The run-time structure consists of two large tables of powers - either
- * powers of 10**4 in base 2**16 or vice versa.
- *
- * Suppose it's powers of T in base B. Then
- *
- * _tiny_powers_T contains TTINY entries, T**0, T**1, ... T**TTINY-1 where
- * T is 2 or 10, TTINY is 16 or 4 _small_powers_T contains TSMALL
- * entries, T**0, T**1, ... T**TSMALL-1 where T is 2**TTINY or 10**TTINY
- * _big_powers_T contains TBIG entries, T**0, T**1, ... T**TBIG-1
- * where T is (2**TTINY)**TSMALL or (10**TTINY)**TSMALL
- *
- * so that any power of T from 0 to T**(TTINY*TSMALL*TBIG-1) can be represented
- * as a product of just two table entries. Since the powers vary greatly in
- * size, the tables are condensed to exclude leading and trailing zeros. The
- * following tables
- *
- * _max_tiny_powers_T contains one entry, TTINY
- * _start_tiny_powers_T contains TTINY entries
- * _leading_zeros_tiny_powers_T contains TTINY entries
- * _max_small_powers_T contains one entry, TSMALL
- * _start_small_powers_T contains TSMALL entries
- * _leading_zeros_small_powers_T contains TSMALL entries
- * _max_big_powers_T contains one entry, TBIG
- * _start_big_powers_T contains TBIG entries
- * _leading_zeros_big_powers_T contains TBIG entries
- *
- * The powers are maintained with x[start] less significant than x[start+1], so
- *
- * The powers are maintained with x[start] less significant than x[start+1], so
- * that the interpretation of a _small_powers_T entry is that
- *
- * T**i = (B**leading_zeros[i]) * (x[start[i]] + x[start[i]+1] * B + ...
- * x[start[i+1]-1] * B**(start[i+1]-start[i]) )
- *
- * where B = (2 or 10)**TTINY
- *
- * The powers are listed consecutively in the tables, with start index and
- * leading zero information retained and printed out at the end.
- *
- */
-
-extern unsigned short _max_tiny_powers_ten;
-extern unsigned short _tiny_powers_ten[];
-extern unsigned short _start_tiny_powers_ten[];
-extern unsigned short _leading_zeros_tiny_powers_ten[];
-extern unsigned short _max_tiny_powers_two;
-extern unsigned short _tiny_powers_two[];
-extern unsigned short _start_tiny_powers_two[];
-
-extern unsigned short _max_small_powers_ten;
-extern unsigned short _small_powers_ten[];
-extern unsigned short _start_small_powers_ten[];
-extern unsigned short _leading_zeros_small_powers_ten[];
-extern unsigned short _max_small_powers_two;
-extern unsigned short _small_powers_two[];
-extern unsigned short _start_small_powers_two[];
-
-extern unsigned short _max_big_powers_ten;
-extern unsigned short _big_powers_ten[];
-extern unsigned short _start_big_powers_ten[];
-extern unsigned short _leading_zeros_big_powers_ten[];
-extern unsigned short _max_big_powers_two;
-extern unsigned short _big_powers_two[];
-extern unsigned short _start_big_powers_two[];
-
-#endif /* _base_conversion_h */
diff --git a/usr/src/lib/libbc/libc/gen/common/bcmp.c b/usr/src/lib/libbc/libc/gen/common/bcmp.c
deleted file mode 100644
index fd31198d17..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/bcmp.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-int
-bcmp(char *s1, char *s2, int len)
-{
-
- while (len--)
- if (*s1++ != *s2++)
- return (1);
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/bsearch.c b/usr/src/lib/libbc/libc/gen/common/bsearch.c
deleted file mode 100644
index d5ee461163..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/bsearch.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.5 */
-
-/*LINTLIBRARY*/
-/*
- * Binary search algorithm, generalized from Knuth (6.2.1) Algorithm B.
- *
- */
-
-typedef char *POINTER;
-
-POINTER
-bsearch(key, base, nel, width, compar)
-POINTER key; /* Key to be located */
-POINTER base; /* Beginning of table */
-unsigned nel; /* Number of elements in the table */
-unsigned width; /* Width of an element (bytes) */
-int (*compar)(); /* Comparison function */
-{
- int two_width = width + width;
- POINTER last = base + width * (nel - 1); /* Last element in table */
-
- while (last >= base) {
-
- register POINTER p = base + width * ((last - base)/two_width);
- register int res = (*compar)(key, p);
-
- if (res == 0)
- return (p); /* Key found */
- if (res < 0)
- last = p - width;
- else
- base = p + width;
- }
- return ((POINTER) 0); /* Key not found */
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/calloc.c b/usr/src/lib/libbc/libc/gen/common/calloc.c
deleted file mode 100644
index 0fb54ebb80..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/calloc.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <malloc.h>
-
-/*
- * calloc - allocate and clear memory block
- */
-#define CHARPERINT (sizeof(int)/sizeof(char))
-
-#ifdef S5EMUL
-#define ptr_t void*
-#define free_t void
-#define free_return(x) (x)
-#else
-#define ptr_t char*
-#define free_t int
-#define free_return(x) return (x)
-#endif
-
-ptr_t
-calloc(unsigned num, unsigned size)
-{
- ptr_t mp;
- ptr_t malloc();
-
- num *= size;
- mp = malloc(num);
- if (mp == NULL)
- return(NULL);
- bzero(mp, num);
- return ((ptr_t)(mp));
-}
-
-free_t
-cfree(ptr_t p, unsigned num, unsigned size)
-{
- free_return(free(p));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/char_to_decimal.h b/usr/src/lib/libbc/libc/gen/common/char_to_decimal.h
deleted file mode 100644
index e08f177d39..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/char_to_decimal.h
+++ /dev/null
@@ -1,532 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright (c) 1990-1995, by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * This file contains the common part of string_to_decimal, func_to_decimal,
- * and file_to_decimal. NEXT must be defined to cause CURRENT to contain the
- * next input character. ATEOF must be defined to be == EOF if an input
- * file is at EOF, != EOF otherwise.
- */
-
-{
- int sigfound;
- int ids = 0;
- int i;
- int nzbp = 0, nzap = 0; /* Length of zero substring
- * before point, after point. */
- char decpt;
- int nfast, nfastlimit;
- char *pfast;
-
- *pform = invalid_form; /* Invalid until we find something. */
- *pechar = NULL; /* No exponent field assumed. */
- pd->fpclass = fp_normal;/* Defaults. */
- pd->sign = 0; /* Positive. */
- pd->exponent = 0;
- pd->more = 0; /* Assume no overflow of digits on NaN
- * string. */
- if (fortran_conventions != 0)
- decpt = '.';
- else
-#ifdef PRE41
- decpt = '.';
-#else
- decpt = *(localeconv()->decimal_point);
-#endif
- while (isspace(CURRENT)) {
- NEXT;
- } /* Skip white space. */
- if (fortran_conventions >= 2) {
- /*
- * All white space - valid zero for Fortran formatted input.
- */
- *pform = whitespace_form;
- if (isspace(*cp))
- good = cp;
- else
- good = cp - 1;
- if ((nread >= nmax) && (CURRENT == NULL)) { /* Used up field width. */
- pd->fpclass = fp_zero;
- goto done;
- }
- }
- if (CURRENT == '+') {
- NEXT;
- } else if (CURRENT == '-') { /* Negative. */
- pd->sign = 1;
- NEXT;
- }
- sigfound = -1; /* -1 = no digits found yet. */
-
- if (('1' <= CURRENT) && (CURRENT <= '9')) {
- good = cp;
- *pform = fixed_int_form;
- sigfound = 1; /* 1 = significant digits found. */
- pd->ds[ids++] = CURRENT;
- NEXT;
- goto number;
- } else
- switch (CURRENT) {
- case ' ':
- if (fortran_conventions < 2)
- goto firstdefault;
- case '0':
- *pform = fixed_int_form;
- while ((CURRENT == '0') || ((fortran_conventions >= 2) && (CURRENT == ' '))) {
- NEXT;
- } /* Ignore leading zeros. */
- if ((*cp == '0') || ((fortran_conventions >= 2) && (*cp == ' ')))
- good = cp;
- else
- good = cp - 1;
- sigfound = 0; /* 0 = only zeros found yet. */
- goto number;
- case 'i':
- case 'I':
- { /* Try infinity. */
- static char *infstring = "INFINITY";
- int is, iagree;
-
-#define UCASE(c) ( (('a' <= c) && (c <= 'z')) ? c - 32 : c )
-
- NEXT;
- is = 1;
- while (is <= 7 &&
- UCASE(CURRENT) == infstring[is]) {
- NEXT;
- is++;
- }
- iagree = is;
- if (CURRENT != NULL) {
- is++; /* To account for infstring
- * indexing starting at 0.
- */
- }
- if (iagree >= 3) { /* Found syntactically
- * valid infinity. */
- if (iagree < 8) { /* INFxxxx */
- if (iagree > 3) {
- nmax++; /* 1083219 */
- CURRENT = EOF; /* 1083219 */
- }
- good = cp - (is - 3);
- *pform = inf_form;
- } else { /* INFINITYxxx */
- good = cp - (is - 8);
- *pform = infinity_form;
- }
- pd->fpclass = fp_infinity;
- sigfound = iagree;
- }
- else {
- nmax++; /* 1083219 */
- CURRENT = EOF; /* 1083219 */
- }
- goto done;
- }
- case 'n':
- case 'N':
- { /* Try NaN. */
- static char *nanstring = "NAN(";
- int is;
-
- NEXT;
- is = 1;
- while (is <= 3 &&
- UCASE(CURRENT) == nanstring[is]) {
- NEXT;
- is++;
- }
- if ((is == 3)) { /* Found syntactically
- * valid NaN. */
- *pform = nan_form;
- good = CURRENT == NULL ? cp : cp - 1;
- pd->fpclass = fp_quiet;
- sigfound = 1;
- }
- else if (is == 4) { /* Found NaN followed by
- * parenthesis. */
- good = CURRENT == NULL ? cp - 1 : cp - 2;
- *pform = nan_form;
- pd->fpclass = fp_quiet;
- sigfound = 1;
- while ((CURRENT != 0) && (CURRENT != ')') && (ids < (DECIMAL_STRING_LENGTH - 1))) {
- pd->ds[ids++] = CURRENT;
- NEXT;
- }
- while ((CURRENT != 0) && (CURRENT != ')') && (ATEOF != EOF)) { /* Pick up rest of
- * string. */
- pd->more = 1;
- NEXT;
- }
- if (CURRENT == ')') {
- good = cp;
- NEXT;
- *pform = nanstring_form;
- }
- else {
- nmax++; /* 1083219 */
- CURRENT = EOF; /* 1083219 */
- }
- }
- else {
- nmax++; /* 1083219 */
- CURRENT = EOF; /* 1083219 */
- }
- goto done;
- }
- default:
- if (CURRENT == decpt) {
- NEXT; /* Try number. */
- goto afterpoint;
- }
- firstdefault:
- goto done;
- }
-
-number:
-
-nextnumber:
- if (('1' <= CURRENT) && (CURRENT <= '9')) {
- if ((ids + nzbp + 2) >= DECIMAL_STRING_LENGTH) { /* Not enough room to
- * store it all: fake
- * end of string. */
- pd->exponent += nzbp + 1;
- pd->more = 1;
- pd->ds[ids] = 0; /* Actual string termination. */
- ids = DECIMAL_STRING_LENGTH - 1; /* To allow end of
- * program to terminate
- * again. */
- } else {
- for (i = 0; (i < nzbp); i++)
- pd->ds[ids++] = '0';
- pd->ds[ids++] = CURRENT;
- }
- *pform = fixed_int_form;
- sigfound = 1;
- nzbp = 0;
- NEXT;
- nfastlimit = DECIMAL_STRING_LENGTH - 3 - ids;
- if ((0 < nfastlimit) && ('1' <= CURRENT) && (CURRENT <= '9')) { /* Special handling for
- * common case. */
- nfast = 0;
- pfast = &(pd->ds[ids]);
- do {
- pfast[nfast++] = CURRENT;
- NEXT;
- }
- while (('1' <= CURRENT) && (CURRENT <= '9') && (nfast < nfastlimit));
- ids += nfast;
- }
- if (CURRENT == '0')
- goto nextnumberzero; /* common case */
- good = cp;
- if (('1' > *good) || (*good > '9'))
- good--; /* look out if we fell off end */
- goto nextnumber;
- } else
- switch (CURRENT) {
- case ' ':
- if (fortran_conventions < 2)
- goto numberdefault;
- if (fortran_conventions == 2) {
- NEXT;
- goto nextnumber;
- }
- case '0':
- *pform = fixed_int_form;
- nextnumberzero:
- while ((CURRENT == '0') || (CURRENT == ' ')) { /* Accumulate zero
- * substring. */
- if (CURRENT == ' ') {
- if (fortran_conventions < 2) {
- good = cp - 1;
- goto numberdefault;
- }
- if (fortran_conventions == 2) {
- nzbp--; /* Undo effect of
- * following nzbp++ */
- }
- }
- good = cp;
- nzbp++;
- NEXT;
- }
- goto nextnumber;
-
- case 'E':
- case 'e':
- efound:
- *pechar = cp;
- if (sigfound == -1) /* exp following no digits?
- * bad format */
- goto done;
- if (sigfound > 0)
- pd->exponent += nzbp;
- goto exponent;
- case '+':
- case '-':
- case 'D':
- case 'd':
- case 'Q':
- case 'q':
- if (fortran_conventions != 0)
- goto efound;
- default:
- if (CURRENT == decpt) {
- NEXT;
- goto afterpoint;
- }
- numberdefault:
- if (sigfound > 0)
- pd->exponent += nzbp;
- goto done;
- }
-
-afterpoint:
- if (sigfound >= 0) { /* Better accept the point as good, but don't
- * accept the next character after. */
- good = cp - 1; /* Assume cp points past. */
- if (*good != decpt) /* If not, bump good. */
- good++;
- }
- switch (*pform) { /* Revise *pform now that point has been
- * found. */
- case invalid_form:
- case whitespace_form:
- *pform = fixed_dotfrac_form;
- break;
- case fixed_int_form:
- *pform = fixed_intdot_form;
- break;
- }
-switchafterpoint:
- if (('1' <= CURRENT) && (CURRENT <= '9')) {
- if (*pform == fixed_intdot_form)
- *pform = fixed_intdotfrac_form;
- good = cp;
- if (sigfound < 1) { /* No significant digits found so
- * far. */
- sigfound = 1;
- pd->ds[ids++] = CURRENT;
- pd->exponent = -(nzap + 1);
- } else { /* Significant digits have begun. */
- if ((ids + nzbp + nzap + 2) >= DECIMAL_STRING_LENGTH) { /* Not enough room to
- * store it all: fake
- * end of string. */
- pd->exponent += nzbp;
- pd->more = 1;
- pd->ds[ids] = 0; /* Actual string
- * termination. */
- ids = DECIMAL_STRING_LENGTH - 1; /* To allow end of
- * program to terminate
- * again. */
- } else {
- for (i = 0; (i < (nzbp + nzap)); i++)
- pd->ds[ids++] = '0';
- pd->ds[ids++] = CURRENT;
- pd->exponent -= nzap + 1;
- }
- }
- nzbp = 0;
- nzap = 0;
- NEXT;
- nfastlimit = DECIMAL_STRING_LENGTH - 3 - ids;
- if ((0 < nfastlimit) && ('1' <= CURRENT) && (CURRENT <= '9')) { /* Special handling for
- * common case. */
- nfast = 0;
- pfast = &(pd->ds[ids]);
- do {
- pfast[nfast++] = CURRENT;
- NEXT;
- }
- while (('1' <= CURRENT) && (CURRENT <= '9') && (nfast < nfastlimit));
- good = cp;
- if (('1' > *good) || (*good > '9'))
- good--; /* look out if we fell off end */
- ids += nfast;
- pd->exponent -= nfast;
- }
- if (CURRENT == '0')
- goto zeroafterpoint;
- goto switchafterpoint;
- } else
- switch (CURRENT) {
- case ' ':
- if (fortran_conventions < 2)
- goto afterpointdefault;
- if (fortran_conventions == 2) {
- /*
- * To pass FCVS, all blanks after point must
- * count as if zero seen.
- */
- if (sigfound == -1)
- sigfound = 0;
- NEXT;
- goto switchafterpoint;
- }
- case '0':
- if (*pform == fixed_intdot_form)
- *pform = fixed_intdotfrac_form;
- if (sigfound == -1)
- sigfound = 0;
- zeroafterpoint:
- good = cp;
- nzap++;
- NEXT;
- while ((CURRENT == '0') || (CURRENT == ' ')) {
- if (CURRENT == ' ') { /* Handle blanks and
- * Fortran. */
- if (fortran_conventions < 2) {
- good = cp - 1;
- goto afterpointdefault;
- }
- if (fortran_conventions == 2) {
- nzap--; /* Undo following nzap++ */
- }
- }
- nzap++;
- NEXT;
- }
- good = cp;
- if (*good != '0')
- good--;
- goto switchafterpoint;
-
- case 'E':
- case 'e':
- efound2:
- *pechar = cp;
- if (sigfound == -1) /* exp following no digits?
- * bad! */
- goto done;
- if (sigfound > 0)
- pd->exponent += nzbp;
- goto exponent;
- case '+':
- case '-':
- case 'D':
- case 'd':
- case 'Q':
- case 'q':
- if (fortran_conventions != 0)
- goto efound2;
-
- default:
- afterpointdefault:
- if (sigfound > 0)
- pd->exponent += nzbp;
- goto done;
- }
-exponent:
- {
- unsigned explicitsign = 0, explicitexponent = 0;
-
- if ((CURRENT != '+') && (CURRENT != '-')) { /* Skip EeDd and
- * following blanks. */
- NEXT; /* Pass the EeDd. */
- if (fortran_conventions >= 2)
- while (CURRENT == ' ') {
- NEXT;
- }
- }
- if (CURRENT == '+') {
- NEXT;
- } else if (CURRENT == '-') { /* Negative explicit
- * exponent. */
- NEXT;
- explicitsign = 1;
- }
- while ((('0' <= CURRENT) && (CURRENT <= '9')) || (CURRENT == ' ')) { /* Accumulate explicit
- * exponent. */
- if (CURRENT == ' ') { /* Handle blanks and Fortran. */
- if (fortran_conventions < 2)
- goto doneexp;
- if (fortran_conventions == 2) {
- NEXT;
- goto exploop;
- }
- CURRENT = '0';
- }
- good = cp;
- if (explicitexponent <= 400000000) {
- explicitexponent = 10 * explicitexponent + CURRENT - '0';
- }
- NEXT;
- switch (*pform) {
- case whitespace_form:
- case fixed_int_form:
- *pform = floating_int_form;
- break;
- case fixed_intdot_form:
- *pform = floating_intdot_form;
- break;
- case fixed_dotfrac_form:
- *pform = floating_dotfrac_form;
- break;
- case fixed_intdotfrac_form:
- *pform = floating_intdotfrac_form;
- break;
- }
- exploop: ;
- }
-doneexp:
- if (explicitsign == 1)
- pd->exponent -= explicitexponent;
- else
- pd->exponent += explicitexponent;
- }
-
-done:
- if (fortran_conventions >= 2) { /* Fill up field width with extra
- * blanks found. */
- if (good == (cp - 1))
- good = NULL; /* Flag that whole field was good up
- * to now. */
- while (CURRENT == ' ') {
- NEXT;
- }
- if (good == NULL) {
- good = CURRENT == NULL ? cp : cp - 1;
- }
- }
- if (sigfound < 1)
- pd->fpclass = fp_zero; /* True zero found. */
-
- pd->ds[ids] = 0; /* Terminate decimal string. */
- pd->ndigits = ids; /* Save string length in ndigits. */
- if (good >= cp0) { /* Valid token found. */
- *ppc = good + 1;/* token found - point one past. */
- } else { /* No valid token found. */
- *pform = invalid_form;
- *ppc = cp0; /* No token found - revert to original value. */
- pd->sign = 0;
- pd->fpclass = fp_signaling; /* If anyone looks, x will be
- * nan. */
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/clock.c b/usr/src/lib/libbc/libc/gen/common/clock.c
deleted file mode 100644
index 9045962263..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/clock.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.1 */
-
-/*LINTLIBRARY*/
-
-#include <sys/types.h>
-#include <sys/times.h>
-#include <sys/param.h> /* for HZ (clock frequency in Hz) */
-#define TIMES(B) (B.tms_utime+B.tms_stime+B.tms_cutime+B.tms_cstime)
-
-extern long times();
-static long first;
-
-long
-clock()
-{
- struct tms buffer;
-
- if (times(&buffer) == -1L)
- return (0L);
- if (first == 0L)
- first = TIMES(buffer);
- return ((TIMES(buffer) - first) * (1000000L/HZ));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/closedir.c b/usr/src/lib/libbc/libc/gen/common/closedir.c
deleted file mode 100644
index 5aa8c21e0c..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/closedir.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/param.h>
-#include <dirent.h>
-
-/*
- * close a directory.
- */
-int
-closedir(dirp)
- register DIR *dirp;
-{
- int fd;
- extern void free();
- extern int close();
-
- fd = dirp->dd_fd;
- dirp->dd_fd = -1;
- dirp->dd_loc = 0;
- free(dirp->dd_buf);
- free((char *)dirp);
- return (close(fd));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/codeset.h b/usr/src/lib/libbc/libc/gen/common/codeset.h
deleted file mode 100644
index 9199780307..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/codeset.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * codeset information
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifndef lint
-/* static char *sccsid = "%Z%%M% %I% %E% SMI"; */
-#endif
-
-#include <stdio.h>
-#define NAME_SIZE 14 /* Length of the code set name */
-
-struct _code_header {
- char code_name[NAME_SIZE+1]; /* code set name */
- int code_id; /* code set id */
- int code_info_size; /* size of code set info */
-};
-
-struct _code_set_info {
- char code_name[NAME_SIZE+1]; /* code set name */
- int code_id; /* code ID */
- char *code_info; /* code information */
- int open_flag; /* Am I open library ? */
-};
-
-#define EUC_SET "euc"
-#define XCCS_SET "xccs"
-#define ISO2022_SET "iso2022"
-
-#define CODESET_NONE 0
-#define CODESET_EUC 2
-#define CODESET_XCCS 3
-#define CODESET_ISO2022 4
-#define CODESET_USER 100
-
-#define ERROR -1
-#define ERROR_NO_LIB -2 /* dlopen failed */
-#define ERROR_NO_SYM -3 /* dlsym failed */
-
-#ifdef DEBUG
-#define LIBRARY_PATH "/tmp/"
-#else
-#define LIBRARY_PATH "/usr/lib/"
-#endif
-
-void *_ml_open_library();
diff --git a/usr/src/lib/libbc/libc/gen/common/crypt.c b/usr/src/lib/libbc/libc/gen/common/crypt.c
deleted file mode 100644
index 037b9527b4..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/crypt.c
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.3 */
-
-/*LINTLIBRARY*/
-/* The real crypt is now _crypt. This version performs automatic
- * authentication via pwauth for special password entries, or simply
- * calls _crypt for the usual case.
- */
-
-char *
-crypt(pw, salt)
-char *pw, *salt;
-{
- static char *iobuf;
- extern char *_crypt();
- extern char *malloc();
-
- if (iobuf == 0) {
- iobuf = malloc((unsigned)16);
- if (iobuf == 0)
- return (0);
- }
- /* handle the case where the password is really in passwd.adjunct.
- * In this case, the salt will start with "##". We should call
- * passauth to determine if pw is valid. If so, we should return
- * the salt, and otherwise return NULL. If salt does not start with
- * "##", crypt will act in the normal fashion.
- */
- if (salt[0] == '#' && salt[1] == '#') {
- if (pwdauth(salt+2, pw) == 0)
- strcpy(iobuf, salt);
- else
- iobuf[0] = '\0';
- return(iobuf);
- }
- /* handle the case where the password is really in group.adjunct.
- * In this case, the salt will start with "#$". We should call
- * grpauth to determine if pw is valid. If so, we should return
- * the salt, and otherwise return NULL. If salt does not start with
- * "#$", crypt will act in the normal fashion.
- */
- if (salt[0] == '#' && salt[1] == '$') {
- if (grpauth(salt+2, pw) == 0)
- strcpy(iobuf, salt);
- else
- iobuf[0] = '\0';
- return(iobuf);
- }
- return (_crypt(pw, salt));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/ctime.c b/usr/src/lib/libbc/libc/gen/common/ctime.c
deleted file mode 100644
index 4ff04654ae..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ctime.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Arthur Olson.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from Arthur Olson's 3.1 */
-
-/*LINTLIBRARY*/
-
-#include <sys/types.h>
-#include <time.h>
-
-char *
-ctime(timep)
-time_t * timep;
-{
- return asctime(localtime(timep));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/ctype_.c b/usr/src/lib/libbc/libc/gen/common/ctype_.c
deleted file mode 100644
index a46c969f72..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ctype_.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 4.2 83/07/08 */
-
-#include <ctype.h>
-#include <stdlib.h>
-
-
-char _ctype_[] = { 0,
-
-/* 0 1 2 3 4 5 6 7 */
-
-/* 0*/ _C, _C, _C, _C, _C, _C, _C, _C,
-/* 10*/ _C, _S|_C, _S|_C, _S|_C, _S|_C, _S|_C, _C, _C,
-/* 20*/ _C, _C, _C, _C, _C, _C, _C, _C,
-/* 30*/ _C, _C, _C, _C, _C, _C, _C, _C,
-/* 40*/ (char)(_S|_B), _P, _P, _P, _P, _P, _P, _P,
-/* 50*/ _P, _P, _P, _P, _P, _P, _P, _P,
-/* 60*/ _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X, _N|_X,
-/* 70*/ _N|_X, _N|_X, _P, _P, _P, _P, _P, _P,
-/*100*/ _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U,
-/*110*/ _U, _U, _U, _U, _U, _U, _U, _U,
-/*120*/ _U, _U, _U, _U, _U, _U, _U, _U,
-/*130*/ _U, _U, _U, _P, _P, _P, _P, _P,
-/*140*/ _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L,
-/*150*/ _L, _L, _L, _L, _L, _L, _L, _L,
-/*160*/ _L, _L, _L, _L, _L, _L, _L, _L,
-/*170*/ _L, _L, _L, _P, _P, _P, _P, _C,
-/*200*/ 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0
-};
-
-unsigned int _mb_cur_max;
-
-/* Now we also supply the functions in libc as well as the macros in
- * ctype.h
- */
-
-#undef isalpha
-#undef isupper
-#undef islower
-#undef isdigit
-#undef isxdigit
-#undef isspace
-#undef ispunct
-#undef isalnum
-#undef isprint
-#undef isgraph
-#undef iscntrl
-#undef isascii
-#undef toascii
-
-extern int mbtowc();
-
-int isalpha(c)
-register int c;
-{
- return((_ctype_+1)[c]&(_U|_L));
-}
-
-int isupper(c)
-register int c;
-{
- return((_ctype_+1)[c]&_U);
-}
-
-int islower(c)
-register int c;
-{
- return((_ctype_+1)[c]&_L);
-}
-
-int isdigit(c)
-register int c;
-{
- return((_ctype_+1)[c]&_N);
-}
-
-int isxdigit(c)
-register int c;
-{
- return((_ctype_+1)[c]&_X);
-}
-
-
-int isspace(c)
-register int c;
-{
- return((_ctype_+1)[c]&_S);
-}
-
-
-int ispunct(c)
-register int c;
-{
- return((_ctype_+1)[c]&_P);
-}
-
-
-int isalnum(c)
-register int c;
-{
- return((_ctype_+1)[c]&(_U|_L|_N));
-}
-
-
-int isprint(c)
-register int c;
-{
- return((_ctype_+1)[c]&(_P|_U|_L|_N|_B));
-}
-
-
-int isgraph(c)
-register int c;
-{
- return((_ctype_+1)[c]&(_P|_U|_L|_N));
-}
-
-
-int iscntrl(c)
-register int c;
-{
- return((_ctype_+1)[c]&_C);
-}
-
-int isascii(c)
-register int c;
-{
- return((unsigned)(c)<=0177);
-}
-
-int toascii(c)
-register int c;
-{
- return((c)&0177);
-}
-
diff --git a/usr/src/lib/libbc/libc/gen/common/decimal_bin.c b/usr/src/lib/libbc/libc/gen/common/decimal_bin.c
deleted file mode 100644
index c398f592b7..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/decimal_bin.c
+++ /dev/null
@@ -1,694 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright (c) 1988-1995, by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* Conversion between binary and decimal floating point. */
-
-#include "base_conversion.h"
-
-void
-decimal_to_binary_integer(ds, ndigs, nzeros, nsig, pb)
- char ds[]; /* Input decimal integer string. */
-unsigned ndigs; /* Input number of explicit digits in ds. */
-unsigned nzeros; /* Input number of implicit trailing zeros. */
-unsigned nsig; /* Input number of significant bits required. */
-_big_float *pb; /* Pointer to big_float to receive result. */
-
-/*
- * Converts a decimal integer string ds with ndigs explicit leading digits
- * and nzeros implicit trailing zeros to a _big_float **pb, which only
- * requires nsig significand bits.
- */
-/* Inexactness is indicated by pb->bsignificand[0] |= 1. */
-/*
- * If the input is too big for a big_float, pb->bexponent is set to 0x7fff.
- */
-
-{
- unsigned nzout;
- _big_float d, *pbout;
-
- d.bsize = _BIG_FLOAT_SIZE;
- _integerstring_to_big_decimal(ds, ndigs, nzeros, &nzout, &d);
- _big_decimal_to_big_binary(&d, pb);
- if (nzout != 0) {
- _big_float_times_power(pb, 10, (int) nzout, (int) nsig, &pbout);
- switch ((unsigned int)pbout) {
- case ((unsigned int)BIG_FLOAT_TIMES_TOOBIG):
-#ifdef DEBUG
- (void) printf(" decimal_to_binary_integer: decimal exponent %d too large for tables ", nzout);
-#endif
- pb->bexponent = 0x7fff;
- break;
- case ((unsigned int)BIG_FLOAT_TIMES_NOMEM):
- {
- char bcastring[80];
-
- (void) sprintf(bcastring, " decimal exponent %d ", nzout);
- _base_conversion_abort(ENOMEM, bcastring);
- break;
- }
- default:
-#ifdef DEBUG
- if (pbout != pb)
- (void) printf(" decimal_to_binary_integer: large decimal exponent %d needs heap buffer \n", nzout);
- printf(" decimal_to_binary_integer: product ");
- _display_big_float(pb, 2);
-#endif
- if (pbout != pb) { /* We don't really need such
- * a large product; the
- * target can't be more than
- * a quad! */
- int i, allweneed;
-
- allweneed = 2 + (nsig + 2) / 16;
- for (i = 0; i < allweneed; i++)
- pb->bsignificand[i] = pbout->bsignificand[i + pbout->blength - allweneed];
- for (i = 0; (pbout->bsignificand[i] == 0); i++);
- if (i < (pbout->blength - allweneed))
- pb->bsignificand[0] |= 1; /* Stick discarded bits. */
-
- pb->blength = allweneed;
- pb->bexponent = pbout->bexponent + 16 * (pbout->blength - allweneed);
-#ifdef DEBUG
- printf(" decimal_to_binary_integer: removed %d excess digits from product \n", pbout->blength - allweneed);
- _display_big_float(pb, 2);
-#endif
- _free_big_float(pbout);
- }
- break;
- }
- }
-}
-
-void
-decimal_to_binary_fraction(ds, ndigs, nzeros, nsig, pb)
- char ds[]; /* Decimal integer string input. */
-unsigned ndigs; /* Number of explicit digits to read. */
-unsigned nzeros; /* Number of implicit leading zeros before
- * digits. */
-unsigned nsig; /* Number of significant bits needed. */
-_big_float *pb; /* Pointer to intended big_float result. */
-
-/*
- * Converts an explicit decimal string *ds[0]..*ds[ndigs-1] preceded by
- * nzeros implicit leading zeros after the point into a big_float at *pb. If
- * the input does not fit exactly in a big_float, the least significant bit
- * of pbout->significand is stuck on. If the input is too big for the base
- * conversion tables, pb->bexponent is set to 0x7fff.
- */
-
-{
- unsigned twopower, twosig;
- int i, excess;
- _big_float d, *pdout;
-
- d.bsize = _BIG_FLOAT_SIZE;
- _fractionstring_to_big_decimal(ds, ndigs, nzeros, &d);
-
- twopower = nsig + 3 + (((nzeros + 1) * (unsigned long) 217706) >> 16);
- twosig = 1 + (((nsig + 2) * (unsigned long) 19729) >> 16);
-
-#ifdef DEBUG
- printf(" decimal_to_binary_fraction sigbits %d twopower %d twosig %d \n",
- nsig, twopower, twosig);
-#endif
- _big_float_times_power(&d, 2, (int) twopower, (int) twosig, &pdout);
- switch ((unsigned int)pdout) {
- case ((unsigned int)BIG_FLOAT_TIMES_TOOBIG):
-#ifdef DEBUG
- (void) printf(" decimal_to_binary_fraction binary exponent %d too large for tables ", twopower);
-#endif
- pb->bexponent = 0x7fff;
- goto ret;
- case ((unsigned int)BIG_FLOAT_TIMES_NOMEM):
- {
- char bcastring[80];
-
- (void) sprintf(bcastring, " binary exponent %d ", twopower);
- _base_conversion_abort(ENOMEM, bcastring);
- break;
- }
- default:
-#ifdef DEBUG
- if (&d != pdout)
- printf(" decimal_to_binary_fraction large binary exponent %d needs heap buffer \n", twopower);
- printf(" product ");
- _display_big_float(pdout, 10);
-#endif
- break;
- }
-
-
- if (pdout->bexponent <= -4) {
- /* Have computed appropriate decimal part; now toss fraction. */
- excess = (-pdout->bexponent) / 4;
-#ifdef DEBUG
- printf(" discard %d excess fraction digits \n", 4 * excess);
-#endif
- for (i = 0; (i < excess) && ((pdout)->bsignificand[i] == 0); i++);
- if (i < excess)
- (pdout)->bsignificand[excess] |= 1; /* Sticky bit for
- * discarded fraction. */
- for (i = excess; i < (pdout)->blength; i++)
- (pdout)->bsignificand[i - excess] = (pdout)->bsignificand[i];
-
- (pdout)->blength -= excess;
- (pdout)->bexponent += 4 * excess;
- }
- _big_decimal_to_big_binary(pdout, pb);
- if (pdout != &d)
- _free_big_float(pdout);
- pb->bexponent = -twopower;
-
-ret:
- return;
-}
-
-void
-decimal_to_unpacked(px, pd, significant_bits)
- unpacked *px;
- decimal_record *pd;
- unsigned significant_bits;
-
-/*
- * Converts *pd to *px so that *px can be correctly rounded. significant_bits
- * tells how many bits will be significant in the final result to avoid
- * superfluous computation. Inexactness is communicated by sticking on the
- * lsb of px->significand[UNPACKED_SIZE-1]. Integer buffer overflow is
- * indicated with a huge positive exponent.
- */
-
-{
- int frac_bits, sigint;
- unsigned length, ndigs, ntz, nlz, ifrac, nfrac;
- _big_float bi, bf, *ptounpacked = &bi;
-
- px->sign = pd->sign;
- px->fpclass = pd->fpclass;
- if ((px->fpclass != fp_normal) && (px->fpclass != fp_subnormal))
- goto ret;
- for (length = 0; pd->ds[length] != 0; length++);
- if (length == 0) { /* A zero significand slipped by. */
- px->fpclass = fp_zero;
- goto ret;
- }
- /* Length contains the number of explicit digits in string. */
- if (pd->exponent >= 0) {/* All integer digits. */
- ndigs = length;
- ntz = pd->exponent; /* Trailing zeros. */
- ifrac = 0;
- nfrac = 0; /* No fraction digits. */
- nlz = 0;
- } else if (length <= -pd->exponent) { /* No integer digits. */
- ndigs = 0;
- ntz = 0;
- ifrac = 0;
- nfrac = length;
- nlz = -pd->exponent - length; /* Leading zeros. */
- } else { /* Some integer digits, some fraction digits. */
- ndigs = length + pd->exponent;
- ntz = 0;
- ifrac = ndigs;
- nfrac = -pd->exponent;
- nlz = 0;
- while ((pd->ds[ifrac] == '0') && (nfrac != 0)) {
- ifrac++;
- nfrac--;
- nlz++;
- } /* Remove leading zeros. */
- }
- if (ndigs != 0) { /* Convert integer digits. */
-
- bi.bsize = _BIG_FLOAT_SIZE;
- decimal_to_binary_integer(pd->ds, ndigs, ntz, significant_bits, &bi);
- if (bi.bexponent == 0x7fff) { /* Too big for buffer. */
- px->exponent = 0x000fffff;
- px->significand[0] = 0x80000000;
- goto ret;
- }
- sigint = 16 * (bi.blength + bi.bexponent - 1);
- if (sigint < 0)
- sigint = 0;
- } else { /* No integer digits. */
- bi.blength = 0;
- bi.bsignificand[0] = 0;
- bi.bexponent = 0;
- sigint = 0;
- }
- frac_bits = significant_bits - sigint + 2;
- bf.blength = 0;
- if ((nfrac != 0) && (frac_bits > 0)) { /* Convert fraction digits,
- * even if we only need a
- * round or sticky. */
-
- bf.bsize = _BIG_FLOAT_SIZE;
- decimal_to_binary_fraction(&(pd->ds[ifrac]), nfrac, nlz, (unsigned) frac_bits, &bf);
- } else { /* Only need fraction bits for sticky. */
- if (nfrac != 0)
- bi.bsignificand[0] |= 1; /* Stick for fraction. */
- }
- if (bi.blength == 0) { /* No integer digits; all fraction. */
- if (bf.bexponent == 0x7fff) { /* Buffer overflowed. */
- px->exponent = -0x000fffff;
- px->significand[0] = 0x80000000;
- goto ret;
- }
- ptounpacked = &bf; /* Exceptional case - all fraction. */
- goto punpack;
- }
- if (bf.blength != 0) { /* Combine integer and fraction bits. */
- int expdiff = bi.bexponent - (bf.bexponent + 16 * (bf.blength - 1)); /* Exponent difference. */
- int uneeded = 2 + (significant_bits + 2) / 16; /* Number of big float
- * digits needed. */
- int nmove, leftshift, i, if0;
-
-#ifdef DEBUG
- printf(" bi+bf exponent diff is %d \n", expdiff);
- printf(" need %d big float digits \n", uneeded);
- assert(bi.blength != 0);
- assert(bf.blength != 0);
- assert(bi.bsignificand[bi.blength - 1] != 0); /* Normalized bi. */
- assert(bf.bsignificand[bf.blength - 1] != 0); /* Normalized bf. */
- assert(bi.bexponent >= 0); /* bi is all integer */
- assert(((-bf.bexponent - 16 * (bf.blength - 1)) >= 16) ||
- ((bf.bsignificand[bf.blength - 1] >> (-bf.bexponent - 16 * (bf.blength - 1))) == 0));
- /* assert either bf << 1 or bf < 1 */
- /*
- * Assert that integer and fraction parts don't overlap by
- * more than one big digit.
- */
- assert(expdiff > 0);
- assert(uneeded <= (2 * UNPACKED_SIZE));
-#endif
-
-
- if (bi.blength >= uneeded) { /* bi will overflow unpacked,
- * so bf is just a sticky. */
- bi.bsignificand[0] |= 1;
- goto punpack;
- }
- leftshift = 16 - (expdiff % 16);
- if (leftshift > 0) { /* shift bf to align with bi. */
- expdiff += 16 * bf.blength;
- _left_shift_base_two(&bf, (short unsigned) leftshift);
- expdiff -= 16 * bf.blength; /* If bf.blength is
- * longer, adjust
- * expdiff. */
- }
- expdiff += leftshift;
- expdiff /= 16; /* Remaining expdiff in _BIG_FLOAT_DIGITS. */
- expdiff--;
-#ifdef DEBUG
- assert(expdiff >= 0); /* expdiff is now equal to the size
- * of the hole between bi and bf. */
-#endif
- nmove = uneeded - bi.blength;
- /* nmove is the number of words to add to bi. */
- if (nmove < 0)
- nmove = 0;
- if (nmove > (expdiff + bf.blength))
- nmove = (expdiff + bf.blength);
-#ifdef DEBUG
- printf(" increase bi by %d words to merge \n", nmove);
-#endif
- if (nmove == 0)
- i = -1;
- else
- for (i = (bi.blength - 1 + nmove); i >= nmove; i--)
- bi.bsignificand[i] = bi.bsignificand[i - nmove];
- for (; (i >= 0) && (expdiff > 0); i--) { /* Fill hole with zeros. */
- expdiff--;
- bi.bsignificand[i] = 0;
- }
- if0 = i;
- for (; i >= 0; i--)
- bi.bsignificand[i] = bf.bsignificand[i + bf.blength - 1 - if0];
- for (i = (bf.blength - 2 - if0); bf.bsignificand[i] == 0; i--);
- /* Find first non-zero. */
- if (i >= 0)
- bi.bsignificand[0] |= 1; /* If non-zero found,
- * stick it. */
- bi.blength += nmove;
- bi.bexponent -= 16 * nmove;
- goto punpack;
- }
-punpack:
- ptounpacked->bsignificand[0] |= pd->more; /* Stick in any lost
- * digits. */
-
-#ifdef DEBUG
- printf(" merged bi and bf: ");
- _display_big_float(ptounpacked, 2);
-#endif
-
- _big_binary_to_unpacked(ptounpacked, px);
-
-ret:
- return;
-}
-
-/* PUBLIC FUNCTIONS */
-
-/*
- * decimal_to_floating routines convert the decimal record at *pd to the
- * floating type item at *px, observing the modes specified in *pm and
- * setting exceptions in *ps.
- *
- * pd->sign and pd->fpclass are always taken into account.
- *
- * pd->exponent, pd->ds and pd->ndigits are used when pd->fpclass is
- * fp_normal or fp_subnormal. In these cases pd->ds is expected to
- * contain one or more ascii digits followed by a null and pd->ndigits
- * is assumed to be the length of the string pd->ds. Notice that for
- * efficiency reasons, the assumption that pd->ndigits == strlen(pd->ds)
- * is NEVER verified.
- *
- * px is set to a correctly rounded approximation to
- * (sign)*(ds)*10**(exponent) If pd->more != 0 then additional nonzero digits
- * are assumed to follow those in ds; fp_inexact is set accordingly.
- *
- * Thus if pd->exponent == -2 and pd->ds = "1234", *px will get 12.34 rounded to
- * storage precision.
- *
- * px is correctly rounded according to the IEEE rounding modes in pm->rd. *ps
- * is set to contain fp_inexact, fp_underflow, or fp_overflow if any of these
- * arise.
- *
- * pm->df and pm->ndigits are never used.
- *
- */
-
-void
-decimal_to_single(px, pm, pd, ps)
- single *px;
- decimal_mode *pm;
- decimal_record *pd;
- fp_exception_field_type *ps;
-{
- single_equivalence kluge;
- unpacked u;
-
- *ps = 0; /* Initialize to no floating-point
- * exceptions. */
- kluge.f.msw.sign = pd->sign ? 1 : 0;
- switch (pd->fpclass) {
- case fp_zero:
- kluge.f.msw.exponent = 0;
- kluge.f.msw.significand = 0;
- break;
- case fp_infinity:
- kluge.f.msw.exponent = 0xff;
- kluge.f.msw.significand = 0;
- break;
- case fp_quiet:
- kluge.f.msw.exponent = 0xff;
- kluge.f.msw.significand = 0x7fffff;
- break;
- case fp_signaling:
- kluge.f.msw.exponent = 0xff;
- kluge.f.msw.significand = 0x3fffff;
- break;
- default:
- if (pd->exponent > SINGLE_MAXE) { /* Guaranteed overflow. */
- u.sign = pd->sign == 0 ? 0 : 1;
- u.fpclass = fp_normal;
- u.exponent = 0x000fffff;
- u.significand[0] = 0x80000000;
- } else if (pd->exponent >= -SINGLE_MAXE) { /* Guaranteed in range. */
- goto inrange;
- } else if (pd->exponent <= (-SINGLE_MAXE - DECIMAL_STRING_LENGTH)) { /* Guaranteed deep
- * underflow. */
- goto underflow;
- } else { /* Deep underflow possible, depending on
- * string length. */
- int i;
-
- for (i = 0; (pd->ds[i] != 0) && (i < (-pd->exponent - SINGLE_MAXE)); i++);
- if (i < (-pd->exponent - SINGLE_MAXE)) { /* Deep underflow */
- underflow:
- u.sign = pd->sign == 0 ? 0 : 1;
- u.fpclass = fp_normal;
- u.exponent = -0x000fffff;
- u.significand[0] = 0x80000000;
- } else {/* In range. */
- inrange:
- decimal_to_unpacked(&u, pd, 24);
- }
- }
- _fp_current_exceptions = 0;
- _fp_current_direction = pm->rd;
- _pack_single(&u, &kluge.x);
- *ps = _fp_current_exceptions;
- }
- *px = kluge.x;
-}
-
-void
-decimal_to_double(px, pm, pd, ps)
- double *px;
- decimal_mode *pm;
- decimal_record *pd;
- fp_exception_field_type *ps;
-{
- double_equivalence kluge;
- unpacked u;
-
- *ps = 0; /* Initialize to no floating-point
- * exceptions. */
- kluge.f.msw.sign = pd->sign ? 1 : 0;
- switch (pd->fpclass) {
- case fp_zero:
- kluge.f.msw.exponent = 0;
- kluge.f.msw.significand = 0;
- kluge.f.significand2 = 0;
- break;
- case fp_infinity:
- kluge.f.msw.exponent = 0x7ff;
- kluge.f.msw.significand = 0;
- kluge.f.significand2 = 0;
- break;
- case fp_quiet:
- kluge.f.msw.exponent = 0x7ff;
- kluge.f.msw.significand = 0xfffff;
- kluge.f.significand2 = 0xffffffff;
- break;
- case fp_signaling:
- kluge.f.msw.exponent = 0x7ff;
- kluge.f.msw.significand = 0x7ffff;
- kluge.f.significand2 = 0xffffffff;
- break;
- default:
- if (pd->exponent > DOUBLE_MAXE) { /* Guaranteed overflow. */
- u.sign = pd->sign == 0 ? 0 : 1;
- u.fpclass = fp_normal;
- u.exponent = 0x000fffff;
- u.significand[0] = 0x80000000;
- } else if (pd->exponent >= -DOUBLE_MAXE) { /* Guaranteed in range. */
- goto inrange;
- } else if (pd->exponent <= (-DOUBLE_MAXE - DECIMAL_STRING_LENGTH)) { /* Guaranteed deep
- * underflow. */
- goto underflow;
- } else { /* Deep underflow possible, depending on
- * string length. */
- int i;
-
- for (i = 0; (pd->ds[i] != 0) && (i < (-pd->exponent - DOUBLE_MAXE)); i++);
- if (i < (-pd->exponent - DOUBLE_MAXE)) { /* Deep underflow */
- underflow:
- u.sign = pd->sign == 0 ? 0 : 1;
- u.fpclass = fp_normal;
- u.exponent = -0x000fffff;
- u.significand[0] = 0x80000000;
- } else {/* In range. */
- inrange:
- decimal_to_unpacked(&u, pd, 53);
- }
- }
- _fp_current_exceptions = 0;
- _fp_current_direction = pm->rd;
- _pack_double(&u, &kluge.x);
- *ps = _fp_current_exceptions;
- }
- *px = kluge.x;
-}
-
-void
-decimal_to_extended(px, pm, pd, ps)
- extended *px;
- decimal_mode *pm;
- decimal_record *pd;
- fp_exception_field_type *ps;
-{
- extended_equivalence kluge;
- unpacked u;
-
- *ps = 0; /* Initialize to no floating-point
- * exceptions. */
- kluge.f.msw.sign = pd->sign ? 1 : 0;
- switch (pd->fpclass) {
- case fp_zero:
- kluge.f.msw.exponent = 0;
- kluge.f.significand = 0;
- kluge.f.significand2 = 0;
- break;
- case fp_infinity:
- kluge.f.msw.exponent = 0x7fff;
- kluge.f.significand = 0;
- kluge.f.significand2 = 0;
- break;
- case fp_quiet:
- kluge.f.msw.exponent = 0x7fff;
- kluge.f.significand = 0xffffffff;
- kluge.f.significand2 = 0xffffffff;
- break;
- case fp_signaling:
- kluge.f.msw.exponent = 0x7fff;
- kluge.f.significand = 0x3fffffff;
- kluge.f.significand2 = 0xffffffff;
- break;
- default:
- if (pd->exponent > EXTENDED_MAXE) { /* Guaranteed overflow. */
- u.sign = pd->sign == 0 ? 0 : 1;
- u.fpclass = fp_normal;
- u.exponent = 0x000fffff;
- u.significand[0] = 0x80000000;
- } else if (pd->exponent >= -EXTENDED_MAXE) { /* Guaranteed in range. */
- goto inrange;
- } else if (pd->exponent <= (-EXTENDED_MAXE - DECIMAL_STRING_LENGTH)) { /* Guaranteed deep
- * underflow. */
- goto underflow;
- } else { /* Deep underflow possible, depending on
- * string length. */
- int i;
-
- for (i = 0; (pd->ds[i] != 0) && (i < (-pd->exponent - EXTENDED_MAXE)); i++);
- if (i < (-pd->exponent - EXTENDED_MAXE)) { /* Deep underflow */
- underflow:
- u.sign = pd->sign == 0 ? 0 : 1;
- u.fpclass = fp_normal;
- u.exponent = -0x000fffff;
- u.significand[0] = 0x80000000;
- } else {/* In range. */
- inrange:
- decimal_to_unpacked(&u, pd, 64);
- }
- }
- _fp_current_exceptions = 0;
- _fp_current_direction = pm->rd;
- _fp_current_precision = fp_extended;
- _pack_extended(&u, px);
- *ps = _fp_current_exceptions;
- return;
- }
- (*px)[0] = kluge.x[0];
- (*px)[1] = kluge.x[1];
- (*px)[2] = kluge.x[2];
-}
-
-void
-decimal_to_quadruple(px, pm, pd, ps)
- quadruple *px;
- decimal_mode *pm;
- decimal_record *pd;
- fp_exception_field_type *ps;
-{
- quadruple_equivalence kluge;
- unpacked u;
- int i;
-
- *ps = 0; /* Initialize to no floating-point
- * exceptions. */
- kluge.f.msw.sign = pd->sign ? 1 : 0;
- switch (pd->fpclass) {
- case fp_zero:
- kluge.f.msw.exponent = 0;
- kluge.f.msw.significand = 0;
- kluge.f.significand2 = 0;
- kluge.f.significand3 = 0;
- kluge.f.significand4 = 0;
- break;
- case fp_infinity:
- kluge.f.msw.exponent = 0x7fff;
- kluge.f.msw.significand = 0;
- kluge.f.significand2 = 0;
- kluge.f.significand3 = 0;
- kluge.f.significand4 = 0;
- break;
- case fp_quiet:
- kluge.f.msw.exponent = 0x7fff;
- kluge.f.msw.significand = 0xffff;
- kluge.f.significand2 = 0xffffffff;
- kluge.f.significand3 = 0xffffffff;
- kluge.f.significand4 = 0xffffffff;
- break;
- case fp_signaling:
- kluge.f.msw.exponent = 0x7fff;
- kluge.f.msw.significand = 0x7fff;
- kluge.f.significand2 = 0xffffffff;
- kluge.f.significand3 = 0xffffffff;
- kluge.f.significand4 = 0xffffffff;
- break;
- default:
- if (pd->exponent > QUAD_MAXE) { /* Guaranteed overflow. */
- u.sign = pd->sign == 0 ? 0 : 1;
- u.fpclass = fp_normal;
- u.exponent = 0x000fffff;
- u.significand[0] = 0x80000000;
- } else if (pd->exponent >= -QUAD_MAXE) { /* Guaranteed in range. */
- goto inrange;
- } else if (pd->exponent <= (-QUAD_MAXE - DECIMAL_STRING_LENGTH)) { /* Guaranteed deep
- * underflow. */
- goto underflow;
- } else { /* Deep underflow possible, depending on
- * string length. */
-
- for (i = 0; (pd->ds[i] != 0) && (i < (-pd->exponent - QUAD_MAXE)); i++);
- if (i < (-pd->exponent - QUAD_MAXE)) { /* Deep underflow */
- underflow:
- u.sign = pd->sign == 0 ? 0 : 1;
- u.fpclass = fp_normal;
- u.exponent = -0x000fffff;
- u.significand[0] = 0x80000000;
- } else {/* In range. */
- inrange:
- decimal_to_unpacked(&u, pd, 113);
- }
- }
- _fp_current_exceptions = 0;
- _fp_current_direction = pm->rd;
- _pack_quadruple(&u, px);
- *ps = _fp_current_exceptions;
- return;
- }
-#ifdef __STDC__
- *px = kluge.x;
-#else
- for (i = 0; i < 4; i++)
- px->u[i] = kluge.x.u[i];
-#endif
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/double_decim.c b/usr/src/lib/libbc/libc/gen/common/double_decim.c
deleted file mode 100644
index 53be17331b..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/double_decim.c
+++ /dev/null
@@ -1,697 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* Conversion between binary and decimal floating point. */
-
-#include "base_conversion.h"
-
-/* PRIVATE FUNCTIONS */
-
-/*
- * Rounds decimal record *pd according to modes in *pm, recording exceptions
- * for inexact or overflow in *ps. round is the round digit and sticky is 0
- * or non-zero to indicate exact or inexact. pd->ndigits is expected to be
- * correctly set.
- */
-void
-decimal_round(decimal_mode *pm, decimal_record *pd, fp_exception_field_type *ps,
- char round, unsigned sticky)
-{
- int lsd, i;
-
- if ((round == '0') && (sticky == 0)) { /* Exact. */
- goto done;
- }
- *ps |= 1 << fp_inexact;
-
- switch (pm->rd) {
- case fp_nearest:
- if (round < '5')
- goto done;
- if (round > '5')
- goto roundup;
- if (sticky != 0)
- goto roundup;
- /* Now in ambiguous case; round up if lsd is odd. */
- if (pd->ndigits <= 0)
- goto done; /* Presumed 0. */
- lsd = pd->ds[pd->ndigits - 1] - '0';
- if ((lsd % 2) == 0)
- goto done;
- goto roundup;
- case fp_positive:
- if (pd->sign != 0)
- goto done;
- goto roundup;
- case fp_negative:
- if (pd->sign == 0)
- goto done;
- goto roundup;
- case fp_tozero:
- goto done;
- }
-roundup:
- for (i = (pd->ndigits - 1); (pd->ds[i] == '9') && (i >= 0); i--)
- pd->ds[i] = '0';
- if (i >= 0)
- (pd->ds[i])++;
- else { /* Rounding carry out has occurred. */
- pd->ds[0] = '1';
- if (pm->df == floating_form) { /* For E format, simply
- * adjust exponent. */
- pd->exponent++;
- } else { /* For F format, increase length of string. */
- if (pd->ndigits > 0)
- pd->ds[pd->ndigits] = '0';
- pd->ndigits++;
- }
- }
- goto ret;
-done:
- if (pd->ndigits <= 0) { /* Create zero string. */
- pd->ds[0] = '0';
- pd->ndigits = 1;
- }
-ret:
- pd->ds[pd->ndigits] = 0;/* Terminate string. */
- return;
-}
-
-/*
- * Converts an unpacked integer value *pu into a decimal string in *ds, of
- * length returned in *ndigs. Inexactness is indicated by setting
- * ds[ndigs-1] odd.
- *
- * Arguments
- * pu: Input unpacked integer value input.
- * nsig: Input number of significant digits required.
- * ds: Output decimal integer string output
- * must be large enough.
- * nzeros: Output number of implicit trailing zeros
- * produced.
- * ndigs: Output number of explicit digits produced
- * in ds.
- */
-void
-binary_to_decimal_integer(unpacked *pu, unsigned nsig, char ds[],
- unsigned *nzeros, unsigned *ndigs)
-{
-
- _big_float *pd, b, d;
- int e, i, is;
- _BIG_FLOAT_DIGIT stickyshift;
- char s[4];
-
- b.bsize = _BIG_FLOAT_SIZE; /* Initialize sizes of big floats. */
- d.bsize = _BIG_FLOAT_SIZE;
- _unpacked_to_big_float(pu, &b, &e);
- if (e < 0) {
- _right_shift_base_two(&b, (short unsigned) -e, &stickyshift);
-#ifdef DEBUG
- assert(stickyshift == 0);
-#endif
- }
- _big_binary_to_big_decimal(&b, &d);
- if (e <= 0)
- pd = &d;
- else {
- _big_float_times_power(&d, 2, e, (int) nsig, &pd);
- switch ((unsigned int)pd) {
- case ((unsigned int)BIG_FLOAT_TIMES_TOOBIG):
- {
- char bcastring[80];
-
- (void) sprintf(bcastring, " binary exponent %d ", e);
- _base_conversion_abort(ERANGE, bcastring);
- break;
- }
- case ((unsigned int)BIG_FLOAT_TIMES_NOMEM):
- {
- char bcastring[80];
-
- (void) sprintf(bcastring, " binary exponent %d ", e);
- _base_conversion_abort(ENOMEM, bcastring);
- break;
- }
- default:
-#ifdef DEBUG
- if (pd != &d)
- (void) printf(" large binary exponent %d needs heap buffer \n", e);
- printf(" product ");
- _display_big_float(pd, 10);
-#endif
- break;
- }
- }
- _fourdigitsquick((short unsigned) pd->bsignificand[pd->blength - 1], s);
- for (i = 0; s[i] == '0'; i++); /* Find first non-zero digit. */
- for (is = 0; i <= 3;)
- ds[is++] = s[i++]; /* Copy subsequent digits. */
-
- for (i = (pd->blength - 2); i >= 0; i--) { /* Convert powers of
- * 10**4 to decimal
- * digits. */
- _fourdigitsquick((short unsigned) pd->bsignificand[i], &(ds[is]));
- is += 4;
- }
-
- ds[is] = 0;
- *ndigs = is;
- *nzeros = pd->bexponent;
- if (pd != &d)
- _free_big_float(pd);
-
-#ifdef DEBUG
- printf(" binary to decimal integer result %s * 10**%d \n", ds, *nzeros);
-#endif
-}
-
-/*
- * Converts an unpacked fraction value *pu into a decimal string consisting
- * of a) an implicit '.' b) *nzeros implicit leading zeros c) *ndigs explicit
- * digits in ds ds contains at least nsig significant digits. nzeros + *
- * *ndigs is at least nfrac digits after the point. Inexactness is indicated
- * by sticking to the lsb.
- *
- * Arguments
- *
- * pu: Input unpacked fraction value output < 1
- * in magnitude.
- * nsig: Input number of significant digits
- * required.
- * nfrac: Input number of digits after point
- * required.
- * ds: Output decimal integer string output -
- * must be large enough.
- * nzeros: Output number of implicit leading zeros
- * produced.
- * ndigs: Output number of explicit digits produced
- * in ds.
- */
- void
-binary_to_decimal_fraction(unpacked *pu, unsigned nsig, unsigned nfrac,
- char ds[], int *nzeros, int *ndigs)
-{
- _big_float *pb, b, d;
- int e, i, j, is, excess;
- char s[4];
- int tensig, tenpower;
- _BIG_FLOAT_DIGIT stickyshift;
-
- *nzeros = 0;
- if (pu->fpclass == fp_zero) { /* Exact zero. */
- for (i = 0; i <= nfrac; i++)
- ds[i] = '0';
- for (; i <= nsig; i++)
- ds[i] = '0';
- *ndigs = i;
- return;
- }
- b.bsize = _BIG_FLOAT_SIZE; /* Initialize sizes of big floats. */
- d.bsize = _BIG_FLOAT_SIZE;
- _unpacked_to_big_float(pu, &b, &e);
- /*
- * e < 0 always
- */
- b.bexponent = e;
- tenpower = nsig + (int) (((17 - e - 16 * b.blength) * (unsigned long) 19729) >> 16);
- if (tenpower < nfrac)
- tenpower = nfrac;
- tensig = nfrac;
- if (nsig > tensig)
- tensig = nsig;
- tensig = 1 + (((tensig + 2) * 217706) >> 16);
- tensig = -tensig;
-
-#ifdef DEBUG
- printf(" binary to decimal fraction exponent 2**%d \n", e);
- printf(" binary to decimal fraction nsig %d nfrac %d tenpower %d tensig %d \n", nsig, nfrac, tenpower, tensig);
-#endif
- _big_float_times_power(&b, 10, tenpower, tensig, &pb);
- switch ((unsigned int)pb) {
- case ((unsigned int)BIG_FLOAT_TIMES_TOOBIG):
- {
- char bcastring[80];
-
- (void) sprintf(bcastring, " decimal exponent %d ", tenpower);
- _base_conversion_abort(ERANGE, bcastring);
- break;
- }
- case ((unsigned int)BIG_FLOAT_TIMES_NOMEM):
- {
- char bcastring[80];
-
- (void) sprintf(bcastring, " decimal exponent %d ", tenpower);
- _base_conversion_abort(ENOMEM, bcastring);
- break;
- }
- default:
-#ifdef DEBUG
- if (pb != &b)
- printf(" large decimal exponent %d needs heap buffer \n", tenpower);
- printf(" product ");
- _display_big_float(pb, 2);
-#endif
- break;
- }
-
- if (pb->bexponent <= -16) {
- /* Have computed appropriate decimal part; now toss fraction. */
- excess = (-pb->bexponent) / 16;
-#ifdef DEBUG
- printf(" discard %d excess fraction bits \n", 16 * excess);
-#endif
- for (i = 0; (i < excess) && (pb->bsignificand[i] == 0); i++);
- if (i < excess)
- pb->bsignificand[excess] |= 1; /* Sticky bit for
- * discarded fraction. */
- for (i = excess; i < pb->blength; i++)
- pb->bsignificand[i - excess] = pb->bsignificand[i];
-
- pb->blength -= excess;
- pb->bexponent += 16 * excess;
- }
- if (pb->bexponent < 0) {
- _right_shift_base_two(pb, (short unsigned) -pb->bexponent, &stickyshift);
- if (stickyshift != 0)
- pb->bsignificand[0] |= 1; /* Stick to lsb. */
- }
- _big_binary_to_big_decimal(pb, &d);
-
- i = d.blength - 1;
- while (d.bsignificand[i] == 0)
- i--;
- _fourdigitsquick((short unsigned) d.bsignificand[i], s);
- for (j = 0; s[j] == '0'; j++); /* Find first non-zero digit. */
- for (is = 0; j <= 3;)
- ds[is++] = s[j++]; /* Copy subsequent digits. */
-
- for (i--; i >= 0; i--) {/* Convert powers of 10**4 to decimal digits. */
- _fourdigitsquick((short unsigned) d.bsignificand[i], &(ds[is]));
- is += 4;
- }
-
- ds[is] = 0;
- *ndigs = is;
-#ifdef DEBUG
- assert(tenpower >= is);
-#endif
- *nzeros = tenpower - is;/* There were supposed to be tenpower leading
- * digits, and is were found. */
-
- if (pb != &b)
- _free_big_float(pb);
-
-#ifdef DEBUG
- printf(" binary to decimal fraction result .%s * 10**%d \n", ds, -(*nzeros));
-#endif
-
-}
-
-void
-_unpacked_to_decimal(unpacked *px, decimal_mode *pm, decimal_record *pd,
- fp_exception_field_type *ps)
-{
- unpacked fx, ix;
- unsigned fmask, imask;
- int i, intdigs, fracdigs, fraczeros, fracsigs, ids, idsbound, lzbound;
- unsigned nsig, nfrac, intzeros, intsigs;
- char is[_INTEGER_SIZE], fs[DECIMAL_STRING_LENGTH];
- char round = '0';
- unsigned sticky = 0;
-
- pd->sign = px->sign;
- pd->fpclass = px->fpclass;
- if ((px->fpclass != fp_normal) && (px->fpclass != fp_subnormal))
- return;
- if ((pm->ndigits >= DECIMAL_STRING_LENGTH) ||
- ((pm->df == floating_form) && (pm->ndigits < 1))) { /* Gross overflow or bad
- * spec. */
-overflow:
- *ps |= 1 << fp_overflow;
- return;
- }
- /* Divide x up into integer part ix and fraction part fx. */
-
- ix = *px;
- fx = ix;
- if (ix.exponent <= -1) {/* All fraction. */
- ix.fpclass = fp_zero;
- } else if (ix.exponent >= 159) { /* All integer. */
- fx.fpclass = fp_zero;
- } else if ((ix.exponent % 32) == 31) { /* Integer/fraction boundary
- * is conveniently on a word
- * boundary. */
- imask = (ix.exponent + 1) / 32; /* Words 0..imask-1 are
- * integer; imask..SIZE are
- * fraction. */
- for (i = 0; i < imask; i++)
- fx.significand[i] = 0;
- for (; i < UNPACKED_SIZE; i++)
- ix.significand[i] = 0;
- _fp_normalize(&fx);
- } else { /* Integer/fraction boundary falls in the
- * middle of a word. */
- imask = (ix.exponent + 1) / 32; /* Words 0..imask-1 are
- * integer; imask is integer
- * and fraction ;
- * imask+1..SIZE are
- * fraction. */
- for (i = 0; i < imask; i++)
- fx.significand[i] = 0;
- fmask = (1 << (31 - (ix.exponent % 32))) - 1;
- fx.significand[imask] &= fmask;
- ix.significand[imask] &= ~fmask;
- for (i = (imask + 1); i < UNPACKED_SIZE; i++)
- ix.significand[i] = 0;
- _fp_normalize(&fx);
- }
- if (ix.fpclass != fp_zero) { /* Compute integer part of result. */
- if (pm->df == floating_form)
- nsig = pm->ndigits + 1; /* Significant digits wanted
- * for E format, plus one for
- * rounding. */
- else
- nsig = _INTEGER_SIZE; /* Significant digits wanted
- * for F format == all. */
-
- binary_to_decimal_integer(&ix, nsig, is, &intzeros, &intsigs);
- } else {
- intsigs = 0;
- intzeros = 0;
- }
- intdigs = intsigs + intzeros;
- fracdigs = 0;
- if (((pm->df == fixed_form) && (pm->ndigits >= 0)) ||
- ((pm->df == floating_form) && ((pm->ndigits + 1) > intdigs))) { /* Need to compute
- * fraction part. */
- if (pm->df == floating_form) { /* Need more significant
- * digits. */
- nsig = pm->ndigits + 2 - intdigs; /* Add two for rounding,
- * sticky. */
- if (nsig > DECIMAL_STRING_LENGTH)
- nsig = DECIMAL_STRING_LENGTH;
- nfrac = 1;
- } else { /* Need fraction digits. */
- nsig = 0;
- nfrac = pm->ndigits + 2; /* Add two for rounding,
- * sticky. */
- if (nfrac > DECIMAL_STRING_LENGTH)
- nfrac = DECIMAL_STRING_LENGTH;
- }
- binary_to_decimal_fraction(&fx, nsig, nfrac, fs, &fraczeros, &fracsigs);
- fracdigs = fraczeros + fracsigs;
- }
- if (pm->df == floating_form) { /* Combine integer and fraction for E
- * format. */
- idsbound = intsigs;
- if (idsbound > pm->ndigits)
- idsbound = pm->ndigits;
- for (ids = 0; ids < idsbound; ids++)
- pd->ds[ids] = is[ids];
- /* Put integer into output string. */
- idsbound = intsigs + intzeros;
- if (idsbound > pm->ndigits)
- idsbound = pm->ndigits;
- for (; ids < idsbound; ids++)
- pd->ds[ids] = '0';
- if (ids == pm->ndigits) { /* Integer part had enough
- * significant digits. */
- pd->ndigits = ids;
- pd->exponent = intdigs - ids;
- if (ids < intdigs) { /* Gather rounding info. */
- if (ids < intsigs)
- round = is[ids++];
- else
- round = '0';
- for (; (is[ids] == '0') && (ids < intsigs); ids++);
- if (ids < intsigs)
- sticky = 1;
- if (fx.fpclass != fp_zero)
- sticky = 1;
- } else {/* Integer part is exact - round from
- * fraction. */
- if (fx.fpclass != fp_zero) {
- int stickystart;
- /* Fraction non-zero. */
- if (fraczeros > 0) { /* Round digit is zero. */
- round = '0';
- stickystart = 0; /* Stickies start with
- * fs[0]. */
- } else { /* Round digit is fs[0]. */
- round = fs[0];
- stickystart = 1; /* Stickies start with
- * fs[1]. */
- }
- if (sticky == 0) { /* Search for sticky
- * bits. */
- for (ids = stickystart; (fs[ids] == '0') && (ids < fracdigs); ids++);
- if (ids < fracdigs)
- sticky = 1;
- }
- }
- }
- } else { /* Need more significant digits from fraction
- * part. */
- idsbound = pm->ndigits - ids;
- if (ids == 0) { /* No integer part - find first
- * significant digit. */
- for (i = 0; fs[i] == '0'; i++);
- idsbound = i + idsbound + fraczeros;
- i += fraczeros; /* Point i at first
- * significant digit. */
- } else
- i = 0;
- if (idsbound > fracdigs)
- idsbound = fracdigs;
- pd->exponent = -idsbound;
-
- if (fraczeros < idsbound) /* Compute number of
- * leading zeros
- * required. */
- lzbound = fraczeros;
- else
- lzbound = idsbound;
- for (; (i < lzbound); i++)
- pd->ds[ids++] = '0';
- for (; (i < idsbound); i++)
- pd->ds[ids++] = fs[i - fraczeros];
- i -= fraczeros; /* Don't worry about leading zeros
- * from now on, we're just rounding */
- if (i < fracsigs) { /* Gather rounding info. */
- if (i < 0)
- round = '0';
- else
- round = fs[i];
- i++;
- if (sticky == 0) { /* Find out if remainder
- * is exact. */
- if (i < 0)
- i = 0;
- for (; (fs[i] == '0') && (i < fracsigs); i++);
- if (i < fracsigs)
- sticky = 1;
- }
- } else {/* Fraction part is exact - add zero digits
- * if required. */
- for (; ids < pm->ndigits; ids++)
- pd->ds[ids] = '0';
- }
- pd->ndigits = ids;
- }
- decimal_round(pm, pd, ps, round, sticky);
- } else { /* Combine integer and fraction for F format. */
- if (pm->ndigits >= 0) { /* Normal F format. */
- if ((intdigs + pm->ndigits) >= DECIMAL_STRING_LENGTH)
- goto overflow;
- for (ids = 0; ids < intsigs; ids++)
- pd->ds[ids] = is[ids];
- for (; ids < intdigs; ids++)
- pd->ds[ids] = '0';
- /* Copy integer digits. */
- idsbound = fracdigs;
- if (idsbound > pm->ndigits)
- idsbound = pm->ndigits;
- if (fraczeros < idsbound) /* Compute number of
- * leading zeros
- * required. */
- lzbound = fraczeros;
- else
- lzbound = idsbound;
- for (i = 0; (i < lzbound); i++)
- pd->ds[ids++] = '0';
- for (; (i < idsbound); i++)
- pd->ds[ids++] = fs[i - fraczeros]; /* Copy fraction digits. */
- for (; i < pm->ndigits; i++)
- pd->ds[ids++] = '0';
- /* Copy trailing zeros if necessary. */
- pd->ndigits = ids;
- pd->exponent = intdigs - ids;
- i -= fraczeros; /* Don't worry about leading zeros
- * from now on, we're just rounding */
- if (i < fracsigs) { /* Gather rounding info. */
- if (i < 0)
- round = '0';
- else
- round = fs[i];
- i++;
- if (sticky == 0) { /* Find out if remainder
- * is exact. */
- if (i < 0)
- i = 0;
- for (; (fs[i] == '0') && (i < fracsigs); i++);
- if (i < fracsigs)
- sticky = 1;
- }
- }
- decimal_round(pm, pd, ps, round, sticky);
- } else { /* Bizarre F format - round to left of point. */
- int roundpos = -pm->ndigits;
-
- if (intdigs >= DECIMAL_STRING_LENGTH)
- goto overflow;
- if (roundpos >= DECIMAL_STRING_LENGTH)
- goto overflow;
- if (intdigs <= roundpos) { /* Not enough integer
- * digits. */
- if (intdigs == roundpos) {
- round = is[0];
- i = 1;
- } else {
- round = '0';
- i = 0;
- }
- for (; (is[i] == '0') && (i < intsigs); i++);
- /* Search for sticky bits. */
- if (i < intsigs)
- sticky = 1;
- pd->ndigits = 0;
- } else {/* Some integer digits do not get rounded
- * away. */
-#ifdef _NO_GOOD
- for (ids = 0; ids < (intsigs - roundpos); ids++)
- pd->ds[ids] = is[ids];
- for (ids = 0; ids < (intdigs - roundpos); ids++)
- pd->ds[ids] = '0';
-#else
- {
- int ncopy = intsigs - roundpos;
- if (ncopy > 0) {
- /* Copy integer digits. */
- (void) memcpy(&(pd->ds[0]), &(is[0]), ncopy);
- ids = ncopy;
- }
- }
- {
- int ncopy = intdigs - roundpos - ids ;
- if (ncopy > 0) {
- (void) memset(&(pd->ds[ids]), '0', ncopy);
- ids += ncopy;
- }
- }
-#endif /* _NO_GOOD */
- /* Copy integer digits. */
- pd->ndigits = ids;
- if (ids < intsigs) { /* Inexact. */
- round = is[ids++];
- for (; (is[ids] == '0') && (ids < intsigs); ids++);
- /* Search for non-zero digits. */
- if (ids < intsigs)
- sticky = 1;
- }
- }
- if (fx.fpclass != fp_zero)
- sticky = 1;
- decimal_round(pm, pd, ps, round, sticky);
- for (i = pd->ndigits; i < (pd->ndigits + roundpos); i++)
- pd->ds[i] = '0'; /* Blank out rounded
- * away digits. */
- pd->exponent = 0;
- pd->ndigits = i;
- pd->ds[i] = 0; /* Terminate string. */
- }
- }
-}
-
-void
-double_to_decimal(double *px, decimal_mode *pm, decimal_record *pd,
- fp_exception_field_type *ps)
-{
- double_equivalence kluge;
- unpacked u;
-
- *ps = 0; /* Initialize *ps. */
- kluge.x = *px;
- pd->sign = kluge.f.msw.sign;
- pd->fpclass = _class_double(px);
- switch (pd->fpclass) {
- case fp_zero:
- break;
- case fp_infinity:
- break;
- case fp_quiet:
- break;
- case fp_signaling:
- break;
- default:
- _unpack_double(&u, &kluge.x);
- _unpacked_to_decimal(&u, pm, pd, ps);
- }
-}
-
-void
-quadruple_to_decimal(quadruple *px, decimal_mode *pm, decimal_record *pd,
- fp_exception_field_type *ps)
-{
- quadruple_equivalence kluge;
- unpacked u;
- int i;
-
- *ps = 0; /* Initialize *ps - no exceptions. */
- for (i = 0; i < 4; i++)
-#ifdef __STDC__
- kluge.x = *px;
-#else
- kluge.x.u[i] = px->u[i];
-#endif
- pd->sign = kluge.f.msw.sign;
- pd->fpclass = _class_quadruple(px);
- switch (pd->fpclass) {
- case fp_zero:
- break;
- case fp_infinity:
- break;
- case fp_quiet:
- break;
- case fp_signaling:
- break;
- default:
- _unpack_quadruple(&u, px);
- _unpacked_to_decimal(&u, pm, pd, ps);
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/drand48.c b/usr/src/lib/libbc/libc/gen/common/drand48.c
deleted file mode 100644
index 13d0895991..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/drand48.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1996 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*LINTLIBRARY*/
-/*
- * drand48, etc. pseudo-random number generator
- * This implementation assumes unsigned short integers of at least
- * 16 bits, long integers of at least 32 bits, and ignores
- * overflows on adding or multiplying two unsigned integers.
- * Two's-complement representation is assumed in a few places.
- * Some extra masking is done if unsigneds are exactly 16 bits
- * or longs are exactly 32 bits, but so what?
- * An assembly-language implementation would run significantly faster.
- */
-#define N 16
-#define MASK ((unsigned)(1 << (N - 1)) + (1 << (N - 1)) - 1)
-#define LOW(x) ((unsigned)(x) & MASK)
-#define HIGH(x) LOW((x) >> N)
-#define MUL(x, y, z) { long l = (long)(x) * (long)(y); \
- (z)[0] = LOW(l); (z)[1] = HIGH(l); }
-#define CARRY(x, y) ((long)(x) + (long)(y) > MASK)
-#define ADDEQU(x, y, z) (z = CARRY(x, (y)), x = LOW(x + (y)))
-#define X0 0x330E
-#define X1 0xABCD
-#define X2 0x1234
-#define A0 0xE66D
-#define A1 0xDEEC
-#define A2 0x5
-#define C 0xB
-#define SET3(x, x0, x1, x2) ((x)[0] = (x0), (x)[1] = (x1), (x)[2] = (x2))
-#define SETLOW(x, y, n) SET3(x, LOW((y)[n]), LOW((y)[(n)+1]), LOW((y)[(n)+2]))
-#define SEED(x0, x1, x2) (SET3(x, x0, x1, x2), SET3(a, A0, A1, A2), c = C)
-#define REST(v) \
- for (i = 0; i < 3; i++) { \
- xsubi[i] = x[i]; \
- x[i] = temp[i]; \
- } \
- return (v)
-
-#define NEST(TYPE, f, F) \
- TYPE f(xsubi) \
- register unsigned short *xsubi; \
- { \
- register int i; \
- register TYPE v; \
- unsigned temp[3]; \
- \
- for (i = 0; i < 3; i++) { \
- temp[i] = x[i]; \
- x[i] = LOW(xsubi[i]); \
- } \
- v = F(); \
- REST(v); \
- }
-
-static unsigned x[3] = { X0, X1, X2 }, a[3] = { A0, A1, A2 }, c = C;
-static unsigned short lastx[3];
-static void next();
-
-double
-drand48()
-{
- static double two16m = 1.0 / (1L << N);
-
- next();
- return (two16m * (two16m * (two16m * x[0] + x[1]) + x[2]));
-}
-
-NEST(double, erand48, drand48)
-
-long
-lrand48()
-{
- next();
- return (((long)x[2] << (N - 1)) + (x[1] >> 1));
-}
-
-long
-mrand48()
-{
- next();
- return (((long)x[2] << N) + x[1]);
-}
-
-static void
-next()
-{
- unsigned p[2], q[2], r[2], carry0, carry1;
-
- MUL(a[0], x[0], p);
- ADDEQU(p[0], c, carry0);
- ADDEQU(p[1], carry0, carry1);
- MUL(a[0], x[1], q);
- ADDEQU(p[1], q[0], carry0);
- MUL(a[1], x[0], r);
- x[2] = LOW(carry0 + carry1 + CARRY(p[1], r[0]) + q[1] + r[1] +
- a[0] * x[2] + a[1] * x[1] + a[2] * x[0]);
- x[1] = LOW(p[1] + r[0]);
- x[0] = LOW(p[0]);
-}
-
-void
-srand48(seedval)
-long seedval;
-{
- SEED(X0, LOW(seedval), HIGH(seedval));
-}
-
-unsigned short *
-seed48(seed16v)
-unsigned short seed16v[3];
-{
- SETLOW(lastx, x, 0);
- SEED(LOW(seed16v[0]), LOW(seed16v[1]), LOW(seed16v[2]));
- return (lastx);
-}
-
-void
-lcong48(param)
-unsigned short param[7];
-{
- SETLOW(x, param, 0);
- SETLOW(a, param, 3);
- c = LOW(param[6]);
-}
-
-NEST(long, nrand48, lrand48)
-
-NEST(long, jrand48, mrand48)
-
-#ifdef DRIVER
-/*
- * This should print the sequences of integers in Tables 2
- * and 1 of the TM:
- * 1623, 3442, 1447, 1829, 1305, ...
- * 657EB7255101, D72A0C966378, 5A743C062A23, ...
- */
-#include <stdio.h>
-
-main()
-{
- int i;
-
- for (i = 0; i < 80; i++) {
- printf("%4d ", (int)(4096 * drand48()));
- printf("%.4X%.4X%.4X\n", x[2], x[1], x[0]);
- }
-}
-#endif
diff --git a/usr/src/lib/libbc/libc/gen/common/dysize.c b/usr/src/lib/libbc/libc/gen/common/dysize.c
deleted file mode 100644
index 98d8c1b10e..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/dysize.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*LINTLIBRARY*/
-
-#include <tzfile.h>
-
-int
-dysize(int y)
-{
- /*
- * The 4.[0123]BSD version of dysize behaves as if the return statement
- * below read
- * return ((y % 4) == 0) ? DAYS_PER_LYEAR : DAYS_PER_NYEAR;
- * but since we'd rather be right than (strictly) compatible. . .
- */
- return (isleap(y) ? DAYS_PER_LYEAR : DAYS_PER_NYEAR);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/econvert.c b/usr/src/lib/libbc/libc/gen/common/econvert.c
deleted file mode 100644
index a82ad20f61..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/econvert.c
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include "base_conversion.h"
-
-static char *nanstring = "NaN";
-static char *infstring = "Infinity";
-
-char *
-econvert(arg, ndigits, decpt, sign, buf)
- double arg;
- int ndigits, *decpt, *sign;
- char *buf;
-{
- decimal_mode dm;
- decimal_record dr;
- fp_exception_field_type ef;
- int i;
- char *pc;
- int nc;
-
- dm.rd = fp_direction; /* Rounding direction. */
- dm.df = floating_form; /* E format. */
- dm.ndigits = ndigits; /* Number of significant digits. */
- double_to_decimal(&arg, &dm, &dr, &ef);
- *sign = dr.sign;
- switch (dr.fpclass) {
- case fp_normal:
- case fp_subnormal:
- *decpt = dr.exponent + ndigits;
- for (i = 0; i < ndigits; i++)
- buf[i] = dr.ds[i];
- buf[ndigits] = 0;
- break;
- case fp_zero:
- *decpt = 1;
- for (i = 0; i < ndigits; i++)
- buf[i] = '0';
- buf[ndigits] = 0;
- break;
- case fp_infinity:
- *decpt = 0;
- pc = infstring;
- if (ndigits < 8)
- nc = 3;
- else
- nc = 8;
- goto movestring;
- case fp_quiet:
- case fp_signaling:
- *decpt = 0;
- pc = nanstring;
- nc = 3;
-movestring:
- for (i = 0; i < nc; i++)
- buf[i] = pc[i];
- buf[nc] = 0;
- break;
- }
- return buf; /* For compatibility with ecvt. */
-}
-
-char *
-fconvert(arg, ndigits, decpt, sign, buf)
- double arg;
- int ndigits, *decpt, *sign;
- char *buf;
-{
- decimal_mode dm;
- decimal_record dr;
- fp_exception_field_type ef;
- int i;
- char *pc;
- int nc;
-
- dm.rd = fp_direction; /* Rounding direction. */
- dm.df = fixed_form; /* F format. */
- dm.ndigits = ndigits; /* Number of digits after point. */
- double_to_decimal(&arg, &dm, &dr, &ef);
- *sign = dr.sign;
- switch (dr.fpclass) {
- case fp_normal:
- case fp_subnormal:
- if (ndigits >= 0)
- *decpt = dr.ndigits - ndigits;
- else
- *decpt = dr.ndigits;
- for (i = 0; i < dr.ndigits; i++)
- buf[i] = dr.ds[i];
- buf[dr.ndigits] = 0;
- break;
- case fp_zero:
- *decpt = 0;
- buf[0] = '0';
- for (i = 1; i < ndigits; i++)
- buf[i] = '0';
- buf[i] = 0;
- break;
- case fp_infinity:
- *decpt = 0;
- pc = infstring;
- if (ndigits < 8)
- nc = 3;
- else
- nc = 8;
- goto movestring;
- case fp_quiet:
- case fp_signaling:
- *decpt = 0;
- pc = nanstring;
- nc = 3;
-movestring:
- for (i = 0; i < nc; i++)
- buf[i] = pc[i];
- buf[nc] = 0;
- break;
- }
- return buf; /* For compatibility with fcvt. */
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/ecvt.c b/usr/src/lib/libbc/libc/gen/common/ecvt.c
deleted file mode 100644
index 6215866bb1..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ecvt.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1986 by Sun Microsystems, Inc.
- */
-
-#include <stdio.h>
-extern char *
-econvert(), *fconvert();
-
-static char *efcvtbuffer;
-
-char *
-ecvt(arg, ndigits, decpt, sign)
- double arg;
- int ndigits, *decpt, *sign;
-{
- if (efcvtbuffer == NULL)
- efcvtbuffer = (char *)calloc(1,1024);
- return econvert(arg, ndigits, decpt, sign, efcvtbuffer);
-}
-
-char *
-fcvt(arg, ndigits, decpt, sign)
- double arg;
- int ndigits, *decpt, *sign;
-{
- if (efcvtbuffer == NULL)
- efcvtbuffer = (char *)calloc(1,1024);
- return fconvert(arg, ndigits, decpt, sign, efcvtbuffer);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/errlst.c b/usr/src/lib/libbc/libc/gen/common/errlst.c
deleted file mode 100644
index e660fc56c7..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/errlst.c
+++ /dev/null
@@ -1,114 +0,0 @@
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 5.1 85/05/30 */
-
-/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-char *sys_errlist[] = {
- "Error 0",
- "Not owner", /* 1 - EPERM */
- "No such file or directory", /* 2 - ENOENT */
- "No such process", /* 3 - ESRCH */
- "Interrupted system call", /* 4 - EINTR */
- "I/O error", /* 5 - EIO */
- "No such device or address", /* 6 - ENXIO */
- "Arg list too long", /* 7 - E2BIG */
- "Exec format error", /* 8 - ENOEXEC */
- "Bad file number", /* 9 - EBADF */
- "No children", /* 10 - ECHILD */
- "No more processes", /* 11 - EAGAIN */
- "Not enough memory", /* 12 - ENOMEM */
- "Permission denied", /* 13 - EACCES */
- "Bad address", /* 14 - EFAULT */
- "Block device required", /* 15 - ENOTBLK */
- "Device busy", /* 16 - EBUSY */
- "File exists", /* 17 - EEXIST */
- "Cross-device link", /* 18 - EXDEV */
- "No such device", /* 19 - ENODEV */
- "Not a directory", /* 20 - ENOTDIR */
- "Is a directory", /* 21 - EISDIR */
- "Invalid argument", /* 22 - EINVAL */
- "File table overflow", /* 23 - ENFILE */
- "Too many open files", /* 24 - EMFILE */
- "Inappropriate ioctl for device", /* 25 - ENOTTY */
- "Text file busy", /* 26 - ETXTBSY */
- "File too large", /* 27 - EFBIG */
- "No space left on device", /* 28 - ENOSPC */
- "Illegal seek", /* 29 - ESPIPE */
- "Read-only file system", /* 30 - EROFS */
- "Too many links", /* 31 - EMLINK */
- "Broken pipe", /* 32 - EPIPE */
-
-/* math software */
- "Argument too large", /* 33 - EDOM */
- "Result too large", /* 34 - ERANGE */
-
-/* non-blocking and interrupt i/o */
- "Operation would block", /* 35 - EWOULDBLOCK */
- "Operation now in progress", /* 36 - EINPROGRESS */
- "Operation already in progress", /* 37 - EALREADY */
-
-/* ipc/network software */
-
- /* argument errors */
- "Socket operation on non-socket", /* 38 - ENOTSOCK */
- "Destination address required", /* 39 - EDESTADDRREQ */
- "Message too long", /* 40 - EMSGSIZE */
- "Protocol wrong type for socket", /* 41 - EPROTOTYPE */
- "Option not supported by protocol", /* 42 - ENOPROTOOPT */
- "Protocol not supported", /* 43 - EPROTONOSUPPORT */
- "Socket type not supported", /* 44 - ESOCKTNOSUPPORT */
- "Operation not supported on socket", /* 45 - EOPNOTSUPP */
- "Protocol family not supported", /* 46 - EPFNOSUPPORT */
- "Address family not supported by protocol family",
- /* 47 - EAFNOSUPPORT */
- "Address already in use", /* 48 - EADDRINUSE */
- "Can't assign requested address", /* 49 - EADDRNOTAVAIL */
-
- /* operational errors */
- "Network is down", /* 50 - ENETDOWN */
- "Network is unreachable", /* 51 - ENETUNREACH */
- "Network dropped connection on reset", /* 52 - ENETRESET */
- "Software caused connection abort", /* 53 - ECONNABORTED */
- "Connection reset by peer", /* 54 - ECONNRESET */
- "No buffer space available", /* 55 - ENOBUFS */
- "Socket is already connected", /* 56 - EISCONN */
- "Socket is not connected", /* 57 - ENOTCONN */
- "Can't send after socket shutdown", /* 58 - ESHUTDOWN */
- "Too many references: can't splice", /* 59 - ETOOMANYREFS */
- "Connection timed out", /* 60 - ETIMEDOUT */
- "Connection refused", /* 61 - EREFUSED */
- "Too many levels of symbolic links", /* 62 - ELOOP */
- "File name too long", /* 63 - ENAMETOOLONG */
- "Host is down", /* 64 - EHOSTDOWN */
- "Host is unreachable", /* 65 - EHOSTUNREACH */
- "Directory not empty", /* 66 - ENOTEMPTY */
- "Too many processes", /* 67 - EPROCLIM */
- "Too many users", /* 68 - EUSERS */
- "Disc quota exceeded", /* 69 - EDQUOT */
- "Stale NFS file handle", /* 70 - ESTALE */
- "Too many levels of remote in path", /* 71 - EREMOTE */
- "Not a stream device", /* 72 - ENOSTR */
- "Timer expired", /* 73 - ETIME */
- "Out of stream resources", /* 74 - ENOSR */
- "No message of desired type", /* 75 - ENOMSG */
- "Not a data message", /* 76 - EBADMSG */
- "Identifier removed", /* 77 - EIDRM */
- "Deadlock situation detected/avoided", /* 78 - EDEADLK */
- "No record locks available", /* 79 - ENOLCK */
- "Machine is not on the network", /* 80 - ENONET */
- "Object is remote", /* 81 - ERREMOTE */
- "Link has been severed", /* 82 - ENOLINK */
- "Advertise error ", /* 83 - EADV */
- "Srmount error ", /* 84 - ESRMNT */
- "Communication error on send", /* 85 - ECOMM */
- "Protocol error", /* 86 - EPROTO */
- "Multihop attempted", /* 87 - EMULTIHOP */
- "EDOTDOT!!!!", /* 88 - EDOTDOT -can't happen */
- "Remote address changed", /* 89 - EREMCHG */
- "Function not implemented", /* 90 - ENOSYS */
-};
-int sys_nerr = { sizeof sys_errlist/sizeof sys_errlist[0] };
diff --git a/usr/src/lib/libbc/libc/gen/common/euc.h b/usr/src/lib/libbc/libc/gen/common/euc.h
deleted file mode 100644
index 201fb17fbf..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/euc.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-
-/* This module is created for NLS on Jan.07.87 */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* static char *sccsid = "%Z%%M% %I% %E% SMI"; */
-
-#define SS2 0x008e
-#define SS3 0x008f
-
-typedef struct {
- short int _eucw1, _eucw2, _eucw3; /* EUC width */
-} eucwidth_t;
-
-#define csetno(c) (((c)&0x80)?((c)==SS2)?2:(((c)==SS3)?3:1):0)
- /* Returns code set number for the first byte of an EUC char. */
diff --git a/usr/src/lib/libbc/libc/gen/common/euc.multibyte.c b/usr/src/lib/libbc/libc/gen/common/euc.multibyte.c
deleted file mode 100644
index f1f538adbd..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/euc.multibyte.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include "codeset.h"
-#include "mbextern.h"
-#include "euc.h"
-#include <limits.h>
-
-#define EUCMASK 0x8080 /* All id bits */
-#define MASK0 0x0000 /* Code Set 0 */
-#define MASK1 0x8080 /* Code Set 1 */
-#define MASK2 0x0080 /* Code Set 2 */
-#define MASK3 0x8000 /* Code Set 3 */
-
-#define EUCWID1 eucinfo->_eucw1
-#define EUCWID2 eucinfo->_eucw2
-#define EUCWID3 eucinfo->_eucw3
-
-int _wctomb_euc(char *, wchar_t);
-
-int
-_mbtowc_euc(wchar_t *wchar, char *s, size_t n)
-{
- int length;
- wchar_t intcode;
- int c;
- char *olds = (char *)s;
- wchar_t mask;
- eucwidth_t * eucinfo = (eucwidth_t *)_code_set_info.code_info;
-
- if(n <= 0)
- return(-1);
- if(s == (char *)0)
- return (0);
- c = (unsigned char)*s++;
- if(c < 0200) {
- if(wchar)
- *wchar = c;
- return (c ? 1 : 0);
- }
- intcode = 0;
- if (c == SS2) {
- if(!(length = EUCWID2)) {
- if(wchar)
- *wchar = c;
- return (1);
- }
- mask = MASK2;
- } else if(c == SS3) {
- if(!(length = EUCWID3)) {
- if(wchar)
- *wchar = c;
- return (1);
- }
- mask = MASK3;
- } else {
- if(iscntrl(c)) {
- if(wchar)
- *wchar = c;
- return (1);
- }
- length = EUCWID1 - 1;
- mask = MASK1;
- intcode = c & 0177;
- }
- if(length + 1 > n)
- return (-1);
- while(length--) {
- if((c = (unsigned char)*s++) < 0200 || iscntrl(c))
- return (-1);
- intcode = (intcode << 8) | (c & 0177);
- }
- if(wchar)
- *wchar = intcode | mask;
- return ((char *)s - olds);
-}
-
-
-size_t
-_mbstowcs_euc(wchar_t *pwcs, char *s, size_t n)
-{
- int i, j;
-
- j=0;
- while(*s) {
- if(j>=n)
- break;
- i=_mbtowc_euc(pwcs+j, s, MB_LEN_MAX);
- if(i==-1)
- return (-1);
- s+=i;
- ++j;
- }
- if(j<n)
- pwcs[j]=0;
- return (j);
-}
-
-
-size_t
-_wcstombs_euc(char *s, wchar_t *pwcs, size_t n)
-{
- wchar_t wc;
- int i;
- int r=n; /* Rest of bytes. */
- char *t;
- char mbbuf[MB_LEN_MAX+1];
-
- while(wc=(*pwcs++)) {
- i=_wctomb_euc(mbbuf, wc);
-
- if (i>r)
- break;
- if (i==-1) return (-1);
-
- r-=i;
- for (t=mbbuf;i>0;--i){
- /* Copy each byte. */
- *(s++)=*(t++);
- }
- }
- if (r>0)
- /* Has enough room for NUL. */
- *s=0;
- return (n-r);
-}
-
-int
-_wctomb_euc(char *s, wchar_t wchar)
-{
- eucwidth_t * eucinfo = (eucwidth_t *)_code_set_info.code_info;
- char *olds = s;
- int size, index;
- unsigned char d;
- if(!s)
- return(0);
- if( wchar <= 0177 || wchar <= 0377 && iscntrl(wchar)) {
- *s++ = wchar;
- return (wchar ? 1 : 0);
- }
- switch(wchar & EUCMASK) {
-
- case MASK1:
- size = EUCWID1;
- break;
-
- case MASK2:
- *s++ = SS2;
- size = EUCWID2;
- break;
-
- case MASK3:
- *s++ = SS3;
- size = EUCWID3;
- break;
-
- default:
- return (-1);
- }
- index = size;
- while(index--) {
- d = wchar | 0200;
- wchar >>= 8;
- if(iscntrl(d))
- return (-1);
- s[index] = d;
- }
- return (s + size - olds);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/execvp.c b/usr/src/lib/libbc/libc/gen/common/execvp.c
deleted file mode 100644
index d2dc473eb2..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/execvp.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*LINTLIBRARY*/
-/*
- * execlp(name, arg,...,0) (like execl, but does path search)
- * execvp(name, argv) (like execv, but does path search)
- */
-#include <errno.h>
-#include <sys/param.h>
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-static char *execat(char *, char *, char *);
-static char *shell = "/bin/sh";
-
-int
-execlp(char *name, ...)
-{
- va_list args;
- int r;
-
- va_start(args, name);
- r = execvp(name, (char **)args);
- va_end(args);
-
- return (r);
-}
-
-int
-execvp(char *name, char **argv)
-{
- char *pathstr;
- char fname[MAXPATHLEN];
- char *newargs[256];
- int i;
- char *cp;
- unsigned etxtbsy = 1;
- int eacces = 0;
-
- if ((pathstr = getenv("PATH")) == NULL)
- pathstr = ":/usr/ucb:/bin:/usr/bin";
- cp = strchr(name, '/') ? "": pathstr;
-
- do {
- cp = execat(cp, name, fname);
- retry:
- (void) execv(fname, argv);
- switch (errno) {
- case ENOEXEC:
- newargs[0] = "sh";
- newargs[1] = fname;
- for (i = 1; (newargs[i+1] = argv[i]) != NULL; ++i) {
- if (i >= 254) {
- errno = E2BIG;
- return(-1);
- }
- }
- (void) execv(shell, newargs);
- return (-1);
- case ETXTBSY:
- if (++etxtbsy > 5)
- return (-1);
- (void) sleep(etxtbsy);
- goto retry;
- case EACCES:
- ++eacces;
- break;
- case ENOMEM:
- case E2BIG:
- case EFAULT:
- return (-1);
- }
- } while (cp);
- if (eacces)
- errno = EACCES;
- return (-1);
-}
-
-static char *
-execat(char *s1, char *s2, char *si)
-{
- char *s;
- char *end;
-
- s = si;
- end = s + MAXPATHLEN;
- while (*s1 && *s1 != ':' && s < end)
- *s++ = *s1++;
- if (si != s && s < end)
- *s++ = '/';
- while (*s2 && s < end)
- *s++ = *s2++;
- *s = '\0';
- return (*s1 ? ++s1: 0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/exit.c b/usr/src/lib/libbc/libc/gen/common/exit.c
deleted file mode 100644
index 44aae2fe47..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/exit.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-
-/*
- * Copyright (c) 1987 by Sun Microsystems, Inc.
- */
-
-struct handlers {
- void (*handler)();
- caddr_t arg;
- struct handlers *next;
-};
-
-extern void _cleanup();
-
-/* the list of handlers and their arguments */
-struct handlers *_exit_handlers;
-
-/*
- * exit -- do termination processing, then evaporate process
- */
-void
-exit(code)
- int code;
-{
- register struct handlers *h;
-
- while (h = _exit_handlers) {
- _exit_handlers = h->next;
- (*h->handler)(code, h->arg);
- }
- _cleanup();
- _exit(code);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/exportent.c b/usr/src/lib/libbc/libc/gen/common/exportent.c
deleted file mode 100644
index d45520e3ef..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/exportent.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 1995 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Exported file system table manager. Reads/writes "/etc/xtab".
- */
-
-#include <stdio.h>
-#include <exportent.h>
-#include <sys/file.h>
-#include <ctype.h>
-
-extern char *strtok();
-extern char *strcpy();
-
-#define LINESIZE 4096
-
-static char *TMPFILE = "/tmp/xtabXXXXXX";
-
-static char *skipwhite(char *);
-static char *skipnonwhite(char *);
-
-FILE *
-setexportent(void)
-{
- FILE *f;
- int fd;
-
- /*
- * Create the tab file if it does not exist already
- */
- if (access(TABFILE, F_OK) < 0) {
- fd = open(TABFILE, O_CREAT, 0644);
- close(fd);
- }
- if (access(TABFILE, W_OK) == 0) {
- f = fopen(TABFILE, "r+");
- } else {
- f = fopen(TABFILE, "r");
- }
- if (f == NULL) {
- return (NULL);
- }
- if (flock(fileno(f), LOCK_EX) < 0) {
- (void)fclose(f);
- return (NULL);
- }
- return (f);
-}
-
-
-void
-endexportent(FILE *f)
-{
- (void) fclose(f);
-}
-
-
-struct exportent *
-getexportent(FILE *f)
-{
- static char *line = NULL;
- static struct exportent xent;
- int len;
- char *p;
-
- if (line == NULL) {
- line = (char *)malloc(LINESIZE + 1);
- }
- if (fgets(line, LINESIZE, f) == NULL) {
- return (NULL);
- }
- len = strlen(line);
- if (line[len-1] == '\n') {
- line[len-1] = 0;
- }
- xent.xent_dirname = line;
- xent.xent_options = NULL;
- p = skipnonwhite(line);
- if (*p == 0) {
- return (&xent);
- }
- *p++ = 0;
- p = skipwhite(p);
- if (*p == 0) {
- return (&xent);
- }
- if (*p == '-') {
- p++;
- }
- xent.xent_options = p;
- return (&xent);
-}
-
-int
-remexportent(FILE *f, char *dirname)
-{
- char buf[LINESIZE];
- FILE *f2;
- int len;
- char *fname;
- int fd;
- long pos;
- long rempos;
- int remlen;
- int res;
-
- fname = (char *) malloc(strlen(TMPFILE) + 1);
- pos = ftell(f);
- rempos = 0;
- remlen = 0;
- (void)strcpy(fname, TMPFILE);
- fd = mkstemp(fname);
- if (fd < 0) {
- return (-1);
- }
- if (unlink(fname) < 0) {
- (void)close(fd);
- return (-1);
- }
- f2 = fdopen(fd, "r+");
- if (f2 == NULL) {
- (void)close(fd);
- return (-1);
- }
- len = strlen(dirname);
- rewind(f);
- while (fgets(buf, sizeof(buf), f)) {
- if (strncmp(buf, dirname,
- len) != 0 || ! isspace((unsigned char)buf[len])) {
- if (fputs(buf, f2) <= 0) {
- (void)fclose(f2);
- return (-1);
- }
- } else {
- remlen = strlen(buf);
- rempos = ftell(f) - remlen;
- }
- }
- rewind(f);
- if (ftruncate(fileno(f), 0L) < 0) {
- (void)fclose(f2);
- return (-1);
- }
- rewind(f2);
- while (fgets(buf, sizeof(buf), f2)) {
- if (fputs(buf, f) <= 0) {
- (void)fclose(f2);
- return (-1);
- }
- }
- (void)fclose(f2);
- if (remlen == 0) {
- /* nothing removed */
- (void) fseek(f, pos, L_SET);
- res = -1;
- } else if (pos <= rempos) {
- res = fseek(f, pos, L_SET);
- } else if (pos > rempos + remlen) {
- res = fseek(f, pos - remlen, L_SET);
- } else {
- res = fseek(f, rempos, L_SET);
- }
- return (res < 0 ? -1 : 0);
-}
-
-int
-addexportent(FILE *f, char *dirname, char *options)
-{
- long pos;
-
- pos = ftell(f);
- if (fseek(f, 0L, L_XTND) >= 0 &&
- fprintf(f, "%s", dirname) > 0 &&
- (options == NULL || fprintf(f, " -%s", options) > 0) &&
- fprintf(f, "\n") > 0 &&
- fseek(f, pos, L_SET) >= 0) {
- return (0);
- }
- return (-1);
-}
-
-
-char *
-getexportopt(struct exportent *xent, char *opt)
-{
- static char *tokenbuf = NULL;
- char *lp;
- char *tok;
- int len;
-
- if (tokenbuf == NULL) {
- tokenbuf = (char *)malloc(LINESIZE);
- }
- if (xent->xent_options == NULL) {
- return (NULL);
- }
- (void)strcpy(tokenbuf, xent->xent_options);
- lp = tokenbuf;
- len = strlen(opt);
- while ((tok = strtok(lp, ",")) != NULL) {
- lp = NULL;
- if (strncmp(opt, tok, len) == 0) {
- if (tok[len] == '=') {
- return (&tok[len + 1]);
- } else if (tok[len] == 0) {
- return ("");
- }
- }
- }
- return (NULL);
-}
-
-
-#define iswhite(c) ((c) == ' ' || c == '\t')
-
-static char *
-skipwhite(char *str)
-{
- while (*str && iswhite(*str)) {
- str++;
- }
- return (str);
-}
-
-static char *
-skipnonwhite(char *str)
-{
- while (*str && ! iswhite(*str)) {
- str++;
- }
- return (str);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/fabs.c b/usr/src/lib/libbc/libc/gen/common/fabs.c
deleted file mode 100644
index d570aa4017..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/fabs.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-double
-fabs(x)
- double x;
-{
- long *px = (long *) &x;
-#ifdef i386
- px[1] &= 0x7fffffff;
-#else
- px[0] &= 0x7fffffff;
-#endif
- return x;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/file_decim.c b/usr/src/lib/libbc/libc/gen/common/file_decim.c
deleted file mode 100644
index a12b272fb6..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/file_decim.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include <ctype.h>
-#include <stdio.h>
-#ifndef PRE41
-#include <locale.h>
-#endif
-#include "base_conversion.h"
-
-void
-file_to_decimal(ppc, nmax, fortran_conventions, pd, pform, pechar, pf, pnread)
- char **ppc;
- int nmax;
- int fortran_conventions;
- decimal_record *pd;
- enum decimal_string_form *pform;
- char **pechar;
- FILE *pf;
- int *pnread;
-
-{
- register char *cp = *ppc;
- register int current;
- register int nread = 1; /* Number of characters read so far. */
- char *good = cp - 1; /* End of known good token. */
- char *cp0 = cp;
-
- current = getc(pf); /* Initialize buffer. */
- *cp = current;
-
-#define ATEOF current
-#define CURRENT current
-#define NEXT \
- if (nread < nmax) \
- { cp++ ; current = getc(pf) ; *cp = current ; nread++ ;} \
- else \
- { current = NULL ; } ;
-
-#include "char_to_decimal.h"
-#undef CURRENT
-#undef NEXT
-
- if (nread < nmax) {
- while (cp >= *ppc) { /* Push back as many excess
- * characters as possible. */
- if (*cp != EOF) { /* Can't push back EOF. */
- if (ungetc(*cp, pf) == EOF)
- break;
- } cp--;
- nread--;
- }
- }
- cp++;
- *cp = 0; /* Terminating null. */
- *pnread = nread;
-
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/float_decim.c b/usr/src/lib/libbc/libc/gen/common/float_decim.c
deleted file mode 100644
index f532e8b2c5..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/float_decim.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-/*
- * Conversion between single, and extended binary and decimal
- * floating point - separated from double_to_decimal to minimize impact on
- * main(){printf("Hello");}
- */
-
-#include "base_conversion.h"
-
-void
-single_to_decimal(px, pm, pd, ps)
- single *px;
- decimal_mode *pm;
- decimal_record *pd;
- fp_exception_field_type *ps;
-{
- single_equivalence kluge;
- unpacked u;
-
- *ps = 0; /* Initialize *ps - no exceptions. */
- kluge.x = *px;
- pd->sign = kluge.f.msw.sign;
- pd->fpclass = _class_single(px);
- switch (pd->fpclass) {
- case fp_zero:
- break;
- case fp_infinity:
- break;
- case fp_quiet:
- break;
- case fp_signaling:
- break;
- default:
- _unpack_single(&u, &kluge.x);
- _unpacked_to_decimal(&u, pm, pd, ps);
- }
-}
-
-void
-extended_to_decimal(px, pm, pd, ps)
- extended *px;
- decimal_mode *pm;
- decimal_record *pd;
- fp_exception_field_type *ps;
-{
- extended_equivalence kluge;
- unpacked u;
-
- *ps = 0; /* Initialize *ps - no exceptions. */
- kluge.x[0] = (*px)[0];
- kluge.x[1] = (*px)[1];
- kluge.x[2] = (*px)[2];
- pd->sign = kluge.f.msw.sign;
- pd->fpclass = _class_extended(px);
- switch (pd->fpclass) {
- case fp_zero:
- break;
- case fp_infinity:
- break;
- case fp_quiet:
- break;
- case fp_signaling:
- break;
- default:
- _unpack_extended(&u, px);
- _unpacked_to_decimal(&u, pm, pd, ps);
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/fmod.c b/usr/src/lib/libbc/libc/gen/common/fmod.c
deleted file mode 100644
index 4692f54609..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/fmod.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* Special version adapted from libm for use in libc. */
-
-static int n0 = 0, n1 = 1;
-
-static double two52 = 4.503599627370496000E+15;
-static double twom52 = 2.220446049250313081E-16;
-
-static double
-setexception(int n, double x)
-{
- return (0.0);
-}
-
-double
-copysign(double x, double y)
-{
- long *px = (long *) &x;
- long *py = (long *) &y;
- px[n0] = (px[n0] & 0x7fffffff) | (py[n0] & 0x80000000);
- return (x);
-}
-
-static double
-fabs(double x)
-{
- long *px = (long *) &x;
- px[0] &= 0x7fffffff;
-
- return (x);
-}
-
-static int
-finite(double x)
-{
- long *px = (long *) &x;
- return ((px[n0] & 0x7ff00000) != 0x7ff00000);
-}
-
-static int
-ilogb(double x)
-{
- long *px = (long *) &x, k;
- k = px[n0] & 0x7ff00000;
- if (k == 0) {
- if ((px[n1] | (px[n0] & 0x7fffffff)) == 0)
- return (0x80000001);
- else {
- x *= two52;
- return ((px[n0] & 0x7ff00000) >> 20) - 1075;
- }
- } else if (k != 0x7ff00000)
- return (k >> 20) - 1023;
- else
- return (0x7fffffff);
-}
-
-static double
-scalbn(double x, int n)
-{
- long *px = (long *) &x, k;
- double twom54 = twom52 * 0.25;
- k = (px[n0] & 0x7ff00000) >> 20;
- if (k == 0x7ff)
- return (x + x);
- if ((px[n1] | (px[n0] & 0x7fffffff)) == 0)
- return (x);
- if (k == 0) {
- x *= two52;
- k = ((px[n0] & 0x7ff00000) >> 20) - 52;
- }
- k = k + n;
- if (n > 5000)
- return (setexception(2, x));
- if (n < -5000)
- return (setexception(1, x));
- if (k > 0x7fe)
- return (setexception(2, x));
- if (k <= -54)
- return (setexception(1, x));
- if (k > 0) {
- px[n0] = (px[n0] & 0x800fffff) | (k << 20);
- return (x);
- }
- k += 54;
- px[n0] = (px[n0] & 0x800fffff) | (k << 20);
- return (x * twom54);
-}
-
-double
-fmod(double x, double y)
-{
- int ny, nr;
- double r, z, w;
-
- int finite(), ilogb();
- double fabs(), scalbn(), copysign();
-
- /* purge off exception values */
- if (!finite(x) || y != y || y == 0.0) {
- return ((x * y) / (x * y));
- }
- /* scale and subtract to get the remainder */
- r = fabs(x);
- y = fabs(y);
- ny = ilogb(y);
- while (r >= y) {
- nr = ilogb(r);
- if (nr == ny)
- w = y;
- else {
- z = scalbn(y, nr - ny - 1);
- w = z + z;
- }
- if (r >= w)
- r -= w;
- else
- r -= z;
- }
-
- /* restore sign */
- return (copysign(r, x));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/frexp.c b/usr/src/lib/libbc/libc/gen/common/frexp.c
deleted file mode 100644
index ffc75618b1..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/frexp.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI" /* from UCB 5.2 3/9/86 */
-
-/*
- * the call
- * x = frexp(arg,&exp);
- * must return a double fp quantity x which is <1.0
- * and the corresponding binary exponent "exp".
- * such that
- * arg = x*2^exp
- */
-double
-frexp(x, i)
- double x;
- int *i;
-{
- int neg, j;
-
- j = 0;
- neg = 0;
- if (x<0) {
- x = -x;
- neg = 1;
- }
- if (x>=1.0)
- while (x>=1.0) {
- j = j+1;
- x = x/2;
- }
- else if (x < 0.5 && x != 0.0)
- while(x<0.5) {
- j = j-1;
- x = 2*x;
- }
- *i = j;
- if(neg)
- x = -x;
- return (x);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/fstab.c b/usr/src/lib/libbc/libc/gen/common/fstab.c
deleted file mode 100644
index 7fa88f0a5b..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/fstab.c
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <fstab.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <mntent.h>
-
-static struct fstab *pfs;
-static FILE *fs_file;
-
-static int
-fstabscan(struct fstab *fs)
-{
- struct mntent *mnt;
-
- /* skip over all filesystem types except '4.2', 'swap' & 'ignore' */
- while (((mnt = getmntent(fs_file)) != NULL) &&
- !((strcmp(mnt->mnt_type, MNTTYPE_42) == 0) ||
- (strcmp(mnt->mnt_type, MNTTYPE_SWAP) == 0) ||
- (strcmp(mnt->mnt_type, MNTTYPE_IGNORE) == 0)))
- continue;
- if (mnt == NULL)
- return (EOF);
- fs->fs_spec = mnt->mnt_fsname;
- fs->fs_file = mnt->mnt_dir;
- if (strcmp(mnt->mnt_type, MNTTYPE_IGNORE) == 0) {
- strcpy(mnt->mnt_opts, FSTAB_XX);
- } else if (strcmp(mnt->mnt_type, MNTTYPE_SWAP) == 0) {
- strcpy(mnt->mnt_opts, FSTAB_SW);
- } else if (hasmntopt(mnt, MNTOPT_RO)) {
- strcpy(mnt->mnt_opts, FSTAB_RO);
- } else if (hasmntopt(mnt, MNTOPT_QUOTA)) {
- strcpy(mnt->mnt_opts, FSTAB_RQ);
- } else {
- strcpy(mnt->mnt_opts, FSTAB_RW);
- }
- fs->fs_type = mnt->mnt_opts;
- fs->fs_freq = mnt->mnt_freq;
- fs->fs_passno = mnt->mnt_passno;
- return (5);
-}
-
-int
-setfsent(void)
-{
-
- if (fs_file)
- endfsent();
- if ((fs_file = setmntent(FSTAB, "r")) == NULL) {
- fs_file = 0;
- return (0);
- }
- return (1);
-}
-
-int
-endfsent(void)
-{
-
- if (fs_file) {
- endmntent(fs_file);
- fs_file = 0;
- }
- return (1);
-}
-
-struct fstab *
-getfsent(void)
-{
- int nfields;
-
- if ((fs_file == 0) && (setfsent() == 0))
- return ((struct fstab *)0);
- if (pfs == 0) {
- pfs = (struct fstab *)malloc(sizeof (struct fstab));
- if (pfs == 0)
- return (0);
- }
- nfields = fstabscan(pfs);
- if (nfields == EOF || nfields != 5)
- return ((struct fstab *)0);
- return (pfs);
-}
-
-struct fstab *
-getfsspec(char *name)
-{
- struct fstab *fsp;
-
- if (setfsent() == 0) /* start from the beginning */
- return ((struct fstab *)0);
- while((fsp = getfsent()) != 0)
- if (strcmp(fsp->fs_spec, name) == 0)
- return (fsp);
- return ((struct fstab *)0);
-}
-
-struct fstab *
-getfsfile(char *name)
-{
- struct fstab *fsp;
-
- if (setfsent() == 0) /* start from the beginning */
- return ((struct fstab *)0);
- while ((fsp = getfsent()) != 0)
- if (strcmp(fsp->fs_file, name) == 0)
- return (fsp);
- return ((struct fstab *)0);
-}
-
-struct fstab *
-getfstype(char *type)
-{
- struct fstab *fs;
-
- if (setfsent() == 0)
- return ((struct fstab *)0);
- while ((fs = getfsent()) != 0)
- if (strcmp(fs->fs_type, type) == 0)
- return (fs);
- return ((struct fstab *)0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/ftok.c b/usr/src/lib/libbc/libc/gen/common/ftok.c
deleted file mode 100644
index ae0724c487..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ftok.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/sysmacros.h>
-
-key_t
-ftok(path, id)
-char *path;
-char id;
-{
- struct stat st;
-
- return(stat(path, &st) < 0 ? (key_t)-1 :
- (key_t)((key_t)id << 24 | ((long)(unsigned)minor(st.st_dev)) << 16 |
- (unsigned)st.st_ino));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/ftw.c b/usr/src/lib/libbc/libc/gen/common/ftw.c
deleted file mode 100644
index 6ac2cade21..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ftw.c
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-/***************************************************************
- * ftw - file tree walk
- *
- * int ftw (path, fn, depth) char *path; int (*fn)(); int depth;
- *
- * Given a path name, ftw starts from the file given by that path
- * name and visits each file and directory in the tree beneath
- * that file. If a single file has multiple links within the
- * structure, it will be visited once for each such link.
- * For each object visited, fn is called with three arguments.
- * The first contains the path name of the object, the second
- * contains a pointer to a stat buffer which will usually hold
- * appropriate information for the object and the third will
- * contain an integer value giving additional information about
- *
- * FTW_F The object is a file for which stat was
- * successful. It does not guarantee that the
- * file can actually be read.
- *
- * FTW_D The object is a directory for which stat and
- * open for read were both successful.
- *
- * FTW_DNR The object is a directory for which stat
- * succeeded, but which cannot be read. Because
- * the directory cannot be read, fn will not be
- * called for any descendants of this directory.
- *
- * FTW_NS Stat failed on the object because of lack of
- * appropriate permission, or because the object is a
- * symbolic link that points to a non-existent file.
- * This indication will be given, for example, for each
- * file in a directory with read but no execute
- * permission. Because stat failed, it is not
- * possible to determine whether this object is a file
- * or a directory. The stat buffer passed to fn will
- * contain garbage. Stat failure for any reason
- * other than lack of permission will be
- * considered an error and will cause ftw to stop
- * and return -1 to its caller.
- *
- * If fn returns nonzero, ftw stops and returns the same value
- * to its caller. If ftw gets into other trouble along the way,
- * it returns -1 and leaves an indication of the cause in errno.
- *
- * The third argument to ftw does not limit the depth to which
- * ftw will go. Rather, it limits the depth to which ftw will
- * go before it starts recycling file descriptors. In general,
- * it is necessary to use a file descriptor for each level of the
- * tree, but they can be recycled for deep trees by saving the
- * position, closing, re-opening, and seeking. It is possible
- * to start recycling file descriptors by sensing when we have
- * run out, but in general this will not be terribly useful if
- * fn expects to be able to open files. We could also figure out
- * how many file descriptors are available and guarantee a certain
- * number to fn, but we would not know how many to guarantee,
- * and we do not want to impose the extra overhead on a caller who
- * knows how many are available without having to figure it out.
- *
- * It is possible for ftw to die with a memory fault in the event
- * of a file system so deeply nested that the stack overflows.
- **************************************************************/
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/dir.h>
-#include <errno.h>
-#include <ftw.h>
-
-#define NULL 0
-
-extern char *malloc(), *strcpy();
-extern void free();
-extern int errno;
-
-int
-ftw(path, fn, depth)
-char *path;
-int (*fn)();
-int depth;
-{
- int rc, n;
- DIR *dirp;
- char *subpath, *component;
- struct stat sb;
- struct direct *dp;
-
- /* Try to get file status.
- If unsuccessful, errno will say why. */
- if(stat(path, &sb) < 0) {
- if (errno == EACCES) {
- return((*fn)(path, &sb, FTW_NS));
- } else if (errno == ENOENT) {
- /* Check if symbolic link points to non-existent file */
- if (lstat(path, &sb) < 0) {
- return(-1);
- }
- else if ((sb.st_mode & S_IFMT) == S_IFLNK) {
- errno = ENOENT;
- return((*fn)(path, &sb, FTW_NS));
- }
- else {
- return(-1);
- }
- } else {
- return(-1);
- }
- }
-
- /*
- * The stat succeeded, so we know the object exists.
- * If not a directory, call the user function and return.
- */
- if((sb.st_mode & S_IFMT) != S_IFDIR)
- return((*fn)(path, &sb, FTW_F));
-
- /*
- * The object was a directory.
- *
- * Open a file to read the directory
- */
- dirp = opendir(path);
-
- /*
- * Call the user function, telling it whether
- * the directory can be read. If it can't be read
- * call the user function or indicate an error,
- * depending on the reason it couldn't be read.
- */
- if(dirp == NULL)
- return(errno == EACCES? (*fn)(path, &sb, FTW_DNR): -1);
-
- /* We could read the directory. Call user function. */
- rc = (*fn)(path, &sb, FTW_D);
- if(rc != 0)
- return(rc);
-
- /* Allocate a buffer to hold generated pathnames. */
- n = strlen(path);
- subpath = malloc((unsigned)(n+MAXNAMLEN+2));
- if(subpath == NULL) {
- closedir(dirp);
- errno = ENOMEM;
- return(-1);
- }
-
- /* Create a prefix to which we will append component names */
- (void)strcpy(subpath, path);
- if(subpath[0] != '\0' && subpath[n-1] != '/')
- subpath[n++] = '/';
- component = &subpath[n];
-
- /*
- * Read the directory one component at a time.
- * We must ignore "." and "..", but other than that,
- * just create a path name and call self to check it out.
- */
- while((dp = readdir(dirp)) != NULL) {
- if(strcmp(dp->d_name, ".") != 0 &&
- strcmp(dp->d_name, "..") != 0) {
- long here;
-
- /* Append component name to the working path */
- (void)strcpy(component, dp->d_name);
-
- /*
- * If we are about to exceed our depth,
- * remember where we are and close a file.
- */
- if(depth <= 1) {
- here = telldir(dirp);
- closedir(dirp);
- }
-
- /*
- * Do a recursive call to process the file.
- * (watch this, sports fans)
- */
- rc = ftw(subpath, fn, depth-1);
- if(rc != 0) {
- free(subpath);
- if(depth > 1)
- closedir(dirp);
- return(rc);
- }
-
- /*
- * If we closed the file, try to reopen it.
- */
- if(depth <= 1) {
- dirp = opendir(path);
- if(dirp == NULL) {
- free(subpath);
- return(-1);
- }
- seekdir(dirp, here);
- }
- }
- }
-
- /*
- * We got out of the subdirectory loop. The return from
- * the final readdir is in dp. Clean up.
- */
- free(subpath);
- closedir(dirp);
- return(0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/func_decim.c b/usr/src/lib/libbc/libc/gen/common/func_decim.c
deleted file mode 100644
index a42a3c80ca..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/func_decim.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include <ctype.h>
-#include <stdio.h>
-#ifndef PRE41
-#include <locale.h>
-#endif
-#include "base_conversion.h"
-
-void
-func_to_decimal(ppc, nmax, fortran_conventions, pd, pform, pechar, pget, pnread, punget)
- char **ppc;
- int nmax;
- int fortran_conventions;
- decimal_record *pd;
- enum decimal_string_form *pform;
- char **pechar;
- int (*pget) ();
-int *pnread;
-int (*punget) ();
-
-{
- register char *cp = *ppc;
- register int current;
- register int nread = 1; /* Number of characters read so far. */
- char *good = cp - 1; /* End of known good token. */
- char *cp0 = cp;
-
- current = (*pget) (); /* Initialize buffer. */
- *cp = current;
-
-#define ATEOF current
-#define CURRENT current
-#define NEXT \
- if (nread < nmax) \
- { cp++ ; current = (*pget)() ; *cp = current ; nread++ ;} \
- else \
- { current = NULL ; } ;
-
-#include "char_to_decimal.h"
-#undef CURRENT
-#undef NEXT
-
- if ((nread < nmax) && (punget != NULL)) {
- while (cp >= *ppc) { /* Push back as many excess
- * characters as possible. */
- if (*cp != EOF) { /* Can't push back EOF. */
- if ((*punget) (*cp) == EOF)
- break;
- }
- cp--;
- nread--;
- }
- }
- cp++;
- *cp = 0; /* Terminating null. */
- *pnread = nread;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/gconvert.c b/usr/src/lib/libbc/libc/gen/common/gconvert.c
deleted file mode 100644
index 885889855d..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/gconvert.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-/*
- * gcvt - Floating output conversion to minimal length string
- */
-
-#include "base_conversion.h"
-#ifndef PRE41
-#include <locale.h>
-#endif
-
-void
-_gcvt(ndigit, pd, trailing, buf)
- int ndigit;
- decimal_record *pd;
- char *buf;
-{
- char *p, *pstring;
- int i;
- static char *inf8 = "Infinity";
- static char *inf3 = "Inf";
- static char *nan = "NaN";
-#ifdef PRE41
- char decpt = '.';
-#else
- char decpt = *(localeconv()->decimal_point);
-#endif
-
- p = buf;
- if (pd->sign)
- *(p++) = '-';
- switch (pd->fpclass) {
- case fp_zero:
- *(p++) = '0';
- if (trailing != 0) {
- *(p++) = decpt;
- for (i = 0; i < ndigit - 1; i++)
- *(p++) = '0';
- }
- break;
- case fp_infinity:
- if (ndigit < 8)
- pstring = inf3;
- else
- pstring = inf8;
- goto copystring;
- case fp_quiet:
- case fp_signaling:
- pstring = nan;
-copystring:
- for (i = 0; *pstring != 0;)
- *(p++) = *(pstring++);
- break;
- default:
- if ((pd->exponent > 0) || (pd->exponent < -(ndigit + 3))) { /* E format. */
- char estring[4];
- int n;
-
- i = 0;
- *(p++) = pd->ds[0];
- *(p++) = decpt;
- for (i = 1; pd->ds[i] != 0;)
- *(p++) = pd->ds[i++];
- if (trailing == 0) { /* Remove trailing zeros and . */
- p--;
- while (*p == '0')
- p--;
- if (*p != decpt)
- p++;
- }
- *(p++) = 'e';
- n = pd->exponent + i - 1;
- if (n >= 0)
- *(p++) = '+';
- else {
- *(p++) = '-';
- n = -n;
- }
- _fourdigitsquick((short unsigned) n, estring);
- for (i = 0; estring[i] == '0'; i++); /* Find end of zeros. */
- if (i > 2)
- i = 2; /* Guarantee two zeros. */
- for (; i <= 3;)
- *(p++) = estring[i++]; /* Copy exp digits. */
- } else { /* F format. */
- if (pd->exponent >= (1 - ndigit)) { /* x.xxx */
- for (i = 0; i < (ndigit + pd->exponent);)
- *(p++) = pd->ds[i++];
- *(p++) = decpt;
- if (pd->ds[i] != 0) { /* More follows point. */
- for (; i < ndigit;)
- *(p++) = pd->ds[i++];
- }
- } else {/* 0.00xxxx */
- *(p++) = '0';
- *(p++) = decpt;
- for (i = 0; i < -(pd->exponent + ndigit); i++)
- *(p++) = '0';
- for (i = 0; pd->ds[i] != 0;)
- *(p++) = pd->ds[i++];
- }
- if (trailing == 0) { /* Remove trailing zeros and point. */
- p--;
- while (*p == '0')
- p--;
- if (*p != decpt)
- p++;
- }
- }
- }
- *(p++) = 0;
-}
-
-char *
-gconvert(number, ndigit, trailing, buf)
- double number;
- int ndigit, trailing;
- char *buf;
-{
- decimal_mode dm;
- decimal_record dr;
- fp_exception_field_type fef;
-
- dm.rd = fp_direction;
- dm.df = floating_form;
- dm.ndigits = ndigit;
- double_to_decimal(&number, &dm, &dr, &fef);
- _gcvt(ndigit, &dr, trailing, buf);
- return (buf);
-}
-
-char *
-gcvt(number, ndigit, buf)
- double number;
- int ndigit;
- char *buf;
-{
- return (gconvert(number, ndigit, 0, buf));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getauditflags.c b/usr/src/lib/libbc/libc/gen/common/getauditflags.c
deleted file mode 100644
index 62c8d63463..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getauditflags.c
+++ /dev/null
@@ -1,495 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/label.h>
-#include <sys/audit.h>
-#include <auevents.h>
-
-#define ON 1
-#define OK 0
-#define OFF -1
-#define COMMA ','
-#define COMMASTR ","
-
-#define COMMON 0
-#define SUCCESS 1
-#define FAILURE 2
-
-#define MAXFLDLEN 25
-#define MAXSTRLEN 360
-#define MAXEVENT 11
-
-/* GLOBALS */
-
-static int length;
-static int pos = 0;
-
-struct list {
- short count;
- short on[MAXEVENT+1];
- short off;
-};
-typedef struct list list_t;
-
-struct exception {
- short type;
- short exception;
-};
-typedef struct exception except_t;
-
-static int stringcopy(char *, char *, int);
-
-/*
- * getauditflagschar() - convert bit flag to character string
- *
- * input: masks->as_success - audit on success
- * masks->as_failure - audit on failure
- * verbose - string format. 0 if short name; 1 if long name;
- *
- * output: auditstring - resultant audit string
- *
- * returns: 0 - entry read ok
- * -1 - error
- */
-
-int
-getauditflagschar(char *auditstring, audit_state_t *masks, int verbose)
-{
- int i, j, k, mask_num;
- int list = -1, retstat = 0;
- int except_list[3];
- char *prefix = " ";
- except_t except[2];
- list_t lists[3];
-
- /*
- * initialize input buffer
- */
- strcpy(auditstring, "");
- /*
- * initialize lists struct
- */
- for (mask_num = COMMON; mask_num <= FAILURE; mask_num++) {
- lists[mask_num].count = 0;
- lists[mask_num].off = -1;
- for (i=0;i<MAXEVENT+1;i++)
- lists[mask_num].on[i] = -1;
- }
- /*
- * initialize exception lists
- */
- for (i = 0; i < 2; i++) {
- except[i].type = -1;
- except[i].exception = -1;
- }
-
- for (i = 0; i < 3; i++)
- except_list[i] = 0;
-
- /*
- * set length global
- */
- length = verbose;
- pos = 0;
-
- /*
- * find turned-on events - if on, store index of event
- * in one of the three event lists, common, success, failure.
- */
- for ( i = 0; i < MAXEVENT; i++) {
- if (((event_class[i].event_mask & masks->as_success) > 0) ||
- ((event_class[i].event_mask & masks->as_failure) > 0)) {
-
- /*
- * check for events in common
- */
- if (((event_class[i].event_mask & masks->as_success) >
- 0) &&
- ((event_class[i].event_mask & masks->as_failure) > 0))
- lists[COMMON].on[lists[COMMON].count++] = i;
-
- /*
- * check for success events
- */
- if ((event_class[i].event_mask & masks->as_success) > 0)
- lists[SUCCESS].on[lists[SUCCESS].count++] = i;
- else {
- except_list[SUCCESS]++;
- if (lists[SUCCESS].off == -1)
- lists[SUCCESS].off = i;
- }
- /*
- * check for failure events
- */
- if ((event_class[i].event_mask & masks->as_failure) > 0)
- lists[FAILURE].on[lists[FAILURE].count++] = i;
- else {
- except_list[FAILURE]++;
- if (lists[FAILURE].off == -1)
- lists[FAILURE].off = i;
- }
- } else {
- except_list[COMMON]++;
- if (lists[COMMON].off == -1)
- lists[COMMON].off = i;
- }
- }
- /*
- * check for all set or all-1 set - output all and common exceptions.
- * the all or common state is exclusive; only one of the
- * three, (+-)all, allowed
- */
- /*
- * no exceptions
- */
- if (lists[COMMON].count >= MAXEVENT-2) {
- if (lists[COMMON].count == MAXEVENT)
- list = COMMON;
-
- /*
- * one exception
- */
- else if (lists[COMMON].count == MAXEVENT-1) {
- for (i=COMMON;i<=FAILURE && (list == -1);i++) {
- if (except_list[i] == 1) {
- list = COMMON;
- except[0].type = i;
- except[0].exception = lists[i].off;
- }
- }
- }
- /*
- * two exceptions
- */
- else if (lists[COMMON].count == MAXEVENT-2) {
- if (except_list[COMMON] == 1) {
- list = COMMON;
- except[0].type = COMMON;
- except[0].exception = lists[COMMON].off;
- for (i=SUCCESS;i<=FAILURE;i++) {
- if (except_list[i] == 1) {
- except[1].type = i;
- except[1].exception = lists[i].off;
- }
- }
-
- } else if (except_list[COMMON] == 0) {
- for (i=SUCCESS,j=0;i<=FAILURE;i++) {
- if (except_list[i] == 1) {
- list = COMMON;
- except[j].type = i;
- except[j++].exception = lists[i].off;
- }
- }
- }
- }
- } else {
- /*
- * check for +all or -all
- */
- for (i=SUCCESS,j=0;i<=FAILURE;i++) {
- if (lists[i].count >= MAXEVENT-1) {
- list = i;
- except[j].type = i;
- if (lists[i].count != MAXEVENT) {
- if (lists[i].off != -1)
- except[j++].exception =
- lists[i].off;
- else
- except[j++].exception =
- lists[COMMON].off;
- }
- }
- }
- }
- /*
- * output all and exceptions
- */
- if (list != -1) {
- if(list==SUCCESS) {
- if ((stringcopy(auditstring, "+", 0)) == -1)
- retstat = -1;
- }
- if(list==FAILURE) {
- if ((stringcopy(auditstring, "-", 0)) == -1)
- retstat = -1;
- }
-
- if (retstat == 0) {
- if (length) {
- if
- ((stringcopy(auditstring,event_class[11].event_lname,1)) == -1)
- retstat = -1;
- } else
- if ((stringcopy(auditstring, event_class[11].event_sname,1)) == -1)
- retstat = -1;
- }
-
- if (retstat == 0) {
- /*
- * output exceptions
- */
- for (i=0;i<2 && except[i].exception != -1; i++) {
- if ((stringcopy(auditstring, "^", 0)) == -1)
- retstat = -1;
- if(except[i].type==SUCCESS) {
- if ((stringcopy(auditstring, "+", 0)) == -1)
- retstat = -1;
- }
- if (except[i].type==FAILURE) {
- if ((stringcopy(auditstring, "-", 0)) == -1)
- retstat = -1;
- }
- if (length == 1 && retstat == 0) {
- if ((stringcopy(auditstring,
- event_class[except[i].exception].event_lname, 1))==-1)
- retstat = -1;
- } else if (retstat == 0) {
- if ((stringcopy(auditstring,
- event_class[except[i].exception].event_sname, 1))==-1)
- retstat = -1;
- }
- }
- }
- } /* end of " all " processing */
-
- /*
- * process common events if no "all" was output
- */
- if (list == -1 && (lists[COMMON].count > 0) && retstat == 0) {
- /*
- * output common events first
- */
- for (j=0;j<lists[COMMON].count;j++) {
- if (length == 1) {
- if ((stringcopy(auditstring,
- event_class[lists[COMMON].on[j]].event_lname, 1)) == -1)
- retstat = -1;
- } else if ((stringcopy(auditstring,
- event_class[lists[COMMON].on[j]].event_sname, 1)) == -1)
- retstat = -1;
- }
- /*
- * remove common events from individual lists
- */
- if (retstat == 0) {
- for (i=SUCCESS;i<=FAILURE;i++) {
- for(j=0;j<lists[COMMON].count;j++) {
- for(k=0;k < lists[i].count;k++) {
- if (lists[COMMON].on[j] ==
- lists[i].on[k])
- lists[i].on[k] = -1;
- }
- }
- }
- }
- }
-
- /*
- * start processing individual event flags in success
- * and failure lists
- */
- if (list != COMMON && retstat == 0) {
- for (i=SUCCESS;i<=FAILURE;i++) {
- if(list != i) {
- if (i==SUCCESS) strcpy(prefix, "+");
- if (i==FAILURE) strcpy(prefix, "-");
- for (j=0;j<MAXEVENT && j<lists[i].count;j++) {
- if (lists[i].on[j] != -1) {
- if ((stringcopy(auditstring, prefix, 0)) == -1)
- retstat = -1;
- if (length == 1 &&
- retstat == 0) {
- if ((stringcopy(auditstring,
- event_class[lists[i].on[j]].event_lname, 1))==-1)
- retstat = -1;
- } else if (retstat == 0) {
- if ((stringcopy(auditstring,
- event_class[lists[i].on[j]].event_sname, 1))==-1)
- retstat = -1;
- }
- }
- }
- }
- }
- }
- if ((stringcopy(auditstring, "\0", 2)) == -1)
- retstat = -1;
-
- return (retstat);
-}
-
-static int
-stringcopy(char *auditstring, char *event,
- int flag) /* if set, output comma after event */
-{
- int retstat = 0;
-
- /*
- * check size
- */
- if (pos >= MAXSTRLEN) {
- fprintf(stderr,"getauditflagschar: Inputted buffer too small.\n");
- retstat = -1;
- } else if (flag != 2) {
- strcpy(auditstring+pos, event);
- pos += strlen(event);
- if(flag) {
- strcpy(auditstring+pos, COMMASTR);
- pos += strlen(COMMASTR);
- }
- } else {
- /*
- * add null terminator only
- */
- if (pos)
- strcpy(auditstring+(pos-1), event);
-
- }
- return (retstat);
-}
-
-/*
- * getauditflagsbin() - converts character string to success and
- * failure bit masks
- *
- * input: auditstring - audit string
- * cnt - number of elements in the masks array
- *
- * output: masks->as_success - audit on success
- * masks->as_failure - audit on failure
- *
- * returns: 0 - ok
- * -1 - error - string contains characters which do
- * not match event flag names
- */
-
-int
-getauditflagsbin(char *auditstring, audit_state_t *masks)
-{
- int i, gotone, done = 0, invert = 0, tryagain;
- int retstat = 0, succ_event, fail_event;
- char *ptr, tmp_buff[MAXFLDLEN];
-
- /*
- * process character string
- */
- do {
- gotone = 0;
- /*
- * read through string storing chars. until a comma
- */
- for (ptr=tmp_buff; !gotone;) {
- if(*auditstring!=COMMA && *auditstring!='\0' &&
- *auditstring!='\n' && *auditstring!=' ')
- *ptr++ = *auditstring++;
- else if (*auditstring == ' ')
- *auditstring++;
- else {
- if (*auditstring == '\0' ||
- *auditstring == '\n') {
- done = 1;
- if (ptr == tmp_buff)
- done = 2;
- }
- gotone = 1;
- }
- }
- /*
- * process audit state
- */
- if(gotone && done != 2) {
- if(!done) auditstring++;
- *ptr++ = '\0';
- ptr = tmp_buff;
- gotone = 0;
- succ_event = ON;
- fail_event = ON;
- tryagain = 1;
- invert = 0;
-
- /*
- * get flags
- */
- do {
- switch (*ptr++) {
- case '^':
- invert = 1;
- succ_event = OFF;
- fail_event = OFF;
- break;
- case '+':
- if (invert)
- fail_event = OK;
- else {
- succ_event = ON;
- fail_event = OK;
- }
- break;
- case '-':
- if (invert)
- succ_event = OK;
- else {
- fail_event = ON;
- succ_event = OK;
- }
- break;
- default:
- tryagain = 0;
- ptr--;
- break;
- }
- } while(tryagain);
-
- /* add audit state to mask */
- for (i=0;i<MAXEVENT+1 && !gotone;i++) {
- if ((!(strcmp(ptr, event_class[i].event_sname))) ||
- (!(strcmp(ptr, event_class[i].event_lname)))) {
- if (succ_event == ON)
- masks->as_success |= event_class[i].event_mask;
- else if (succ_event == OFF)
- masks->as_success &= ~(event_class[i].event_mask);
- if (fail_event == ON)
- masks->as_failure |= event_class[i].event_mask;
- else if (fail_event == OFF)
- masks->as_failure &= ~(event_class[i].event_mask);
- gotone = 1;
- }
- }
- if(!gotone) {
- retstat = -1;
- done = 1;
- }
- }
- } while (!done);
-
- return (retstat);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getauid.c b/usr/src/lib/libbc/libc/gen/common/getauid.c
deleted file mode 100644
index 8dc4df8cc2..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getauid.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright (c) 1987 by Sun Microsystems, Inc.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-int
-getauid(void)
-{
- return (0);
-}
-
-int
-setauid(int auid)
-{
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getcwd.c b/usr/src/lib/libbc/libc/gen/common/getcwd.c
deleted file mode 100644
index 3f3f46b067..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getcwd.c
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-/*
- * Library routine to GET the Current Working Directory.
- * arg1 is a pointer to a character buffer into which the
- * path name of the current directory is placed by the
- * subroutine. arg1 may be zero, in which case the
- * subroutine will call malloc to get the required space.
- * arg2 is the length of the buffer space for the path-name.
- * If the actual path-name is longer than (arg2-2), or if
- * the value of arg2 is not at least 3, the subroutine will
- * return a value of zero, with errno set as appropriate.
- */
-
-#include <stdio.h>
-#include <sys/errno.h>
-
-extern FILE *popen();
-extern char *malloc(), *fgets(), *strchr();
-extern int errno, pclose();
-
-char *
-getcwd(arg1, arg2)
-char *arg1;
-int arg2;
-{
- FILE *pipe;
- char *trm;
-
- if(arg2 <= 0) {
- errno = EINVAL;
- return(0);
- }
- if(arg1 == 0)
- if((arg1 = malloc((unsigned)arg2)) == 0) {
- errno = ENOMEM;
- return(0);
- }
- errno = 0;
- if((pipe = popen("pwd", "r")) == 0)
- return(0);
- (void) fgets(arg1, arg2, pipe);
- (void) pclose(pipe);
- trm = strchr(arg1, '\0');
- if(*(trm-1) != '\n') {
- errno = ERANGE;
- return(0);
- }
- *(trm-1) = '\0';
- return(arg1);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getenv.c b/usr/src/lib/libbc/libc/gen/common/getenv.c
deleted file mode 100644
index e6c4fb2062..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getenv.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-/*
- * getenv(name)
- * returns ptr to value associated with name, if any, else NULL
- */
-#define NULL 0
-extern char **environ;
-static char *nvmatch();
-
-char *
-getenv(name)
-register char *name;
-{
- register char *v, **p=environ;
-
- if(p == NULL)
- return(NULL);
- while(*p != NULL)
- if((v = nvmatch(name, *p++)) != NULL)
- return(v);
- return(NULL);
-}
-
-/*
- * s1 is either name, or name=value
- * s2 is name=value
- * if names match, return value of s2, else NULL
- * used for environment searching: see getenv
- */
-
-static char *
-nvmatch(s1, s2)
-register char *s1, *s2;
-{
- while(*s1 == *s2++)
- if(*s1++ == '=')
- return(s2);
- if(*s1 == '\0' && *(s2-1) == '=')
- return(s2);
- return(NULL);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getgraent.c b/usr/src/lib/libbc/libc/gen/common/getgraent.c
deleted file mode 100644
index 006a30355a..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getgraent.c
+++ /dev/null
@@ -1,462 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <grp.h>
-#include <grpadj.h>
-#include <rpcsvc/ypclnt.h>
-#include <string.h>
-#include <malloc.h>
-
-extern void rewind();
-extern long strtol();
-extern int fclose();
-
-void setgraent(void);
-void endgraent(void);
-
-static struct gradata {
- char *domain;
- FILE *grfa;
- char *yp;
- int yplen;
- char *oldyp;
- int oldyplen;
- struct list {
- char *name;
- struct list *nxt;
- } *minuslist; /* list of - items */
- struct group_adjunct interpgra;
- char interpline[BUFSIZ+1];
- struct group_adjunct *sv;
-} *gradata, *_gradata(void);
-
-static char *GROUPADJ = "/etc/security/group.adjunct";
-
-static struct group_adjunct *interpret(char *, int);
-static struct group_adjunct *interpretwithsave(char *, int,
- struct group_adjunct *);
-static struct group_adjunct *save(struct group_adjunct *);
-static struct group_adjunct *getnamefromyellow(char *,
- struct group_adjunct *);
-static int onminuslist(struct group_adjunct *);
-static int matchname(char [], struct group_adjunct **, char *);
-static void freeminuslist(void);
-static void getnextfromyellow(void);
-static void getfirstfromyellow(void);
-static void addtominuslist(char *);
-
-
-static struct gradata *
-_gradata(void)
-{
- struct gradata *g = gradata;
-
- if (g == 0) {
- g = (struct gradata *)calloc(1, sizeof (struct gradata));
- gradata = g;
- }
- return (g);
-}
-
-struct group_adjunct *
-getgranam(char *name)
-{
- struct gradata *g = _gradata();
- struct group_adjunct *gra;
- char line[BUFSIZ+1];
-
- setgraent();
- if (g == 0)
- return (0);
- if (!g->grfa)
- return (NULL);
- while (fgets(line, BUFSIZ, g->grfa) != NULL) {
- if ((gra = interpret(line, strlen(line))) == NULL)
- continue;
- if (matchname(line, &gra, name)) {
- endgraent();
- return (gra);
- }
- }
- endgraent();
- return (NULL);
-}
-
-void
-setgraent(void)
-{
- struct gradata *g = _gradata();
-
- if (g == NULL)
- return;
- if (g->domain == NULL)
- (void) yp_get_default_domain(&g->domain);
- if (!g->grfa)
- g->grfa = fopen(GROUPADJ, "r");
- else
- rewind(g->grfa);
- if (g->yp)
- free(g->yp);
- g->yp = NULL;
- freeminuslist();
-}
-
-void
-endgraent(void)
-{
- struct gradata *g = _gradata();
-
- if (g == 0)
- return;
- if (g->grfa) {
- (void) fclose(g->grfa);
- g->grfa = NULL;
- }
- if (g->yp)
- free(g->yp);
- g->yp = NULL;
- freeminuslist();
-}
-
-struct group_adjunct *
-fgetgraent(FILE *f)
-{
- char line1[BUFSIZ+1];
-
- if(fgets(line1, BUFSIZ, f) == NULL)
- return (NULL);
- return (interpret(line1, strlen(line1)));
-}
-
-static char *
-grskip(char *p, int c)
-{
- while(*p && *p != c && *p != '\n') ++p;
- if (*p == '\n')
- *p = '\0';
- else if (*p != '\0')
- *p++ = '\0';
- return (p);
-}
-
-struct group_adjunct *
-getgraent(void)
-{
- struct gradata *g = _gradata();
- char line1[BUFSIZ+1];
- static struct group_adjunct *savegra;
- struct group_adjunct *gra;
-
- if (g == 0)
- return (0);
- if (g->domain == NULL) {
- (void) yp_get_default_domain(&g->domain);
- }
- if(!g->grfa && !(g->grfa = fopen(GROUPADJ, "r")))
- return (NULL);
- again:
- if (g->yp) {
- gra = interpretwithsave(g->yp, g->yplen, savegra);
- free(g->yp);
- if (gra == NULL)
- return (NULL);
- getnextfromyellow();
- if (onminuslist(gra))
- goto again;
- else
- return (gra);
- }
- else if (fgets(line1, BUFSIZ, g->grfa) == NULL)
- return (NULL);
- if ((gra = interpret(line1, strlen(line1))) == NULL)
- return (NULL);
- switch(line1[0]) {
- case '+':
- if (strcmp(gra->gra_name, "+") == 0) {
- getfirstfromyellow();
- savegra = save(gra);
- goto again;
- }
- /*
- * else look up this entry in NIS
- */
- savegra = save(gra);
- gra = getnamefromyellow(gra->gra_name+1, savegra);
- if (gra == NULL)
- goto again;
- else if (onminuslist(gra))
- goto again;
- else
- return (gra);
- break;
- case '-':
- addtominuslist(gra->gra_name+1);
- goto again;
- break;
- default:
- if (onminuslist(gra))
- goto again;
- return (gra);
- break;
- }
- /* NOTREACHED */
-}
-
-static struct group_adjunct *
-interpret(char *val, int len)
-{
- struct gradata *g = _gradata();
- char *p;
-
- if (g == 0)
- return (0);
- strncpy(g->interpline, val, len);
- p = g->interpline;
- g->interpline[len] = '\n';
- g->interpline[len+1] = 0;
- g->interpgra.gra_name = p;
- p = grskip(p,':');
- if (strcmp(g->interpgra.gra_name, "+") == 0) {
- /* we are going to the NIS - fix the
- * rest of the struct as much as is needed
- */
- g->interpgra.gra_passwd = "";
- return (&g->interpgra);
- }
- g->interpgra.gra_passwd = p;
- while(*p && *p != '\n') p++;
- *p = '\0';
- return (&g->interpgra);
-}
-
-static void
-freeminuslist(void)
-{
- struct gradata *g = _gradata();
- struct list *ls;
-
- if (g == 0)
- return;
- for (ls = g->minuslist; ls != NULL; ls = ls->nxt) {
- free(ls->name);
- free(ls);
- }
- g->minuslist = NULL;
-}
-
-static struct group_adjunct *
-interpretwithsave(char *val, int len, struct group_adjunct *savegra)
-{
- struct gradata *g = _gradata();
- struct group_adjunct *gra;
-
- if (g == 0)
- return (0);
- if ((gra = interpret(val, len)) == NULL)
- return (NULL);
- if (savegra->gra_passwd && *savegra->gra_passwd)
- gra->gra_passwd = savegra->gra_passwd;
- return (gra);
-}
-
-static int
-onminuslist(struct group_adjunct *gra)
-{
- struct gradata *g = _gradata();
- struct list *ls;
- char *nm;
-
- if (g == 0)
- return (0);
- nm = gra->gra_name;
- for (ls = g->minuslist; ls != NULL; ls = ls->nxt)
- if (strcmp(ls->name, nm) == 0)
- return (1);
- return (0);
-}
-
-static void
-getnextfromyellow(void)
-{
- struct gradata *g = _gradata();
- int reason;
- char *key = NULL;
- int keylen;
-
- if (g == 0)
- return;
- if (reason = yp_next(g->domain, "group.adjunct.byname",
- g->oldyp, g->oldyplen, &key, &keylen,
- &g->yp, &g->yplen)) {
-#ifdef DEBUG
-fprintf(stderr, "reason yp_next failed is %d\n", reason);
-#endif
- g->yp = NULL;
- }
- if (g->oldyp)
- free(g->oldyp);
- g->oldyp = key;
- g->oldyplen = keylen;
-}
-
-static void
-getfirstfromyellow(void)
-{
- struct gradata *g = _gradata();
- int reason;
- char *key = NULL;
- int keylen;
-
- if (g == 0)
- return;
- if (reason = yp_first(g->domain, "group.adjunct.byname",
- &key, &keylen, &g->yp, &g->yplen)) {
-#ifdef DEBUG
-fprintf(stderr, "reason yp_first failed is %d\n", reason);
-#endif
- g->yp = NULL;
- }
- if (g->oldyp)
- free(g->oldyp);
- g->oldyp = key;
- g->oldyplen = keylen;
-}
-
-static struct group_adjunct *
-getnamefromyellow(char *name, struct group_adjunct *savegra)
-{
- struct gradata *g = _gradata();
- struct group_adjunct *gra;
- int reason;
- char *val;
- int vallen;
-
- if (g == 0)
- return (NULL);
- if (reason = yp_match(g->domain, "group.adjunct.byname",
- name, strlen(name), &val, &vallen)) {
-#ifdef DEBUG
-fprintf(stderr, "reason yp_next failed is %d\n", reason);
-#endif
- return (NULL);
- }
- else {
- gra = interpret(val, vallen);
- free(val);
- if (gra == NULL)
- return (NULL);
- if (savegra->gra_passwd && *savegra->gra_passwd)
- gra->gra_passwd = savegra->gra_passwd;
- return (gra);
- }
-}
-
-static void
-addtominuslist(char *name)
-{
- struct gradata *g = _gradata();
- struct list *ls;
- char *buf;
-
- if (g == 0)
- return;
- ls = (struct list *)malloc(sizeof(struct list));
- buf = (char *)malloc(strlen(name) + 1);
- (void) strcpy(buf, name);
- ls->name = buf;
- ls->nxt = g->minuslist;
- g->minuslist = ls;
-}
-
-/*
- * save away psswd field, which is the only
- * one which can be specified in a local + entry to override the
- * value in the NIS
- */
-static struct group_adjunct *
-save(struct group_adjunct *gra)
-{
- struct gradata *g = _gradata();
-
- if (g == 0)
- return (0);
- /*
- * free up stuff from last time around
- */
- if (g->sv) {
- free(g->sv->gra_passwd);
- free(g->sv);
- }
- g->sv = (struct group_adjunct *)calloc(1, sizeof(struct group_adjunct));
- g->sv->gra_passwd = (char *)malloc(strlen(gra->gra_passwd) + 1);
- (void) strcpy(g->sv->gra_passwd, gra->gra_passwd);
- return (g->sv);
-}
-
-static int
-matchname(char line1[], struct group_adjunct **grap, char *name)
-{
- struct group_adjunct *savegra;
- struct group_adjunct *gra = *grap;
-
- switch (line1[0]) {
- case '+':
- if (strcmp(gra->gra_name, "+") == 0) {
- savegra = save(gra);
- gra = getnamefromyellow(name, savegra);
- if (gra) {
- *grap = gra;
- return (1);
- }
- else
- return (0);
- }
- if (strcmp(gra->gra_name+1, name) == 0) {
- savegra = save(gra);
- gra = getnamefromyellow(gra->gra_name+1, savegra);
- if (gra) {
- *grap = gra;
- return (1);
- }
- else
- return (0);
- }
- break;
- case '-':
- if (strcmp(gra->gra_name+1, name) == 0) {
- *grap = NULL;
- return (1);
- }
- break;
- default:
- if (strcmp(gra->gra_name, name) == 0)
- return (1);
- }
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getlogin.c b/usr/src/lib/libbc/libc/gen/common/getlogin.c
deleted file mode 100644
index d5c0dd2baf..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getlogin.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1992 by Sun Microsystems, Inc.
- */
-
-#include <pwd.h>
-#include <stdio.h>
-
-char *
-getlogin()
-{
- char *lgn;
-
- if ((lgn = (char *)_getlogin()) == NULL) {
- struct passwd *pwd;
- if ((pwd = (struct passwd *)_getpwuid(_getuid())) != NULL)
- return (pwd->pw_name);
- }
- return (lgn);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getopt.c b/usr/src/lib/libbc/libc/gen/common/getopt.c
deleted file mode 100644
index 84d33cdc25..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getopt.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-
-/* LINTLIBRARY */
-
-#include <stdio.h>
-#include <string.h>
-
-/*
- * get option letter from argument vector
- */
-/* See lib/libc/gen/common/optind.c for next 3 definitions. */
-extern char *optarg; /* argument associated with option */
-extern int opterr; /* if error message should be printed */
-extern int optind; /* index into parent argv vector */
-int optopt; /* character checked for validity */
-
-
-#define BADCH (int)'?'
-#define EMSG ""
-
-int
-getopt(int nargc, char **nargv, char *ostr)
-{
- static char *place = EMSG; /* option letter processing */
- char *oli; /* option letter list index */
- char *p;
-
- if (!*place) { /* update scanning pointer */
- if (optind >= nargc || *(place = nargv[optind]) != '-') {
- place = EMSG;
- return (EOF);
- }
- if (place[1] && *++place == '-') { /* found "--" */
- ++optind;
- place = EMSG;
- return (EOF);
- }
- } /* option letter okay? */
- if ((optopt = (int)*place++) == (int)':' ||
- !(oli = strchr(ostr, optopt))) {
-
- /*
- * For backwards compatibility: don't treat '-' as an
- * option letter unless caller explicitly asked for it.
- */
- if (optopt == (int)'-')
- return (EOF);
- if (!*place)
- ++optind;
- if (opterr) {
- if (!(p = strrchr(*nargv, '/')))
- p = *nargv;
- else
- ++p;
- (void)fprintf(stderr, "%s: illegal option -- %c\n",
- p, optopt);
- }
- return (BADCH);
- }
- if (*++oli != ':') { /* don't need argument */
- optarg = NULL;
- if (!*place)
- ++optind;
- } else { /* need an argument */
- if (*place) /* no white space */
- optarg = place;
- else if (nargc <= ++optind) { /* no arg */
- place = EMSG;
- if (!(p = strrchr(*nargv, '/')))
- p = *nargv;
- else
- ++p;
- if (opterr)
- (void)fprintf(stderr,
- "%s: option requires an argument -- %c\n",
- p, optopt);
- return (BADCH);
- } else /* white space */
- optarg = nargv[optind];
- place = EMSG;
- ++optind;
- }
- return (optopt); /* dump back option letter */
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getpass.c b/usr/src/lib/libbc/libc/gen/common/getpass.c
deleted file mode 100644
index 302afa7d3f..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getpass.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*LINTLIBRARY*/
-#include <stdio.h>
-#include <signal.h>
-#include <termios.h>
-#include <unistd.h>
-
-extern void setbuf();
-extern int fclose(FILE *);
-extern int fprintf(FILE *, char *, ...);
-extern int findiop();
-extern int ioctl();
-static int intrupt;
-
-static void catch(void);
-
-#define MAXPASSWD 8 /* max significant characters in password */
-
-char *
-getpass(char *prompt)
-{
- struct termios ttyb;
- long flags;
- char *p;
- int c;
- FILE *fi;
- static char pbuf[ MAXPASSWD + 1 ];
- struct sigvec osv, sv;
-
- if((fi = fopen("/dev/tty", "r")) == NULL)
-#ifdef S5EMUL
- return((char*)NULL);
-#else
- fi = stdin;
-#endif
- else
- setbuf(fi, (char*)NULL);
- sv.sv_handler = catch;
- sv.sv_mask = 0;
- sv.sv_flags = SV_INTERRUPT;
- (void) sigvec(SIGINT, &sv, &osv);
- intrupt = 0;
- (void) ioctl(fileno(fi), TCGETS, &ttyb);
- flags = ttyb.c_lflag;
- ttyb.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHONL);
- (void) ioctl(fileno(fi), TCSETSF, &ttyb);
- (void) fputs(prompt, stderr);
- p = pbuf;
- while( !intrupt &&
- (c = getc(fi)) != '\n' && c != '\r' && c != EOF ) {
- if(p < &pbuf[ MAXPASSWD ])
- *p++ = c;
- }
- *p = '\0';
- ttyb.c_lflag = flags;
- (void) ioctl(fileno(fi), TCSETSW, &ttyb);
- (void) putc('\n', stderr);
- (void) sigvec(SIGINT, &osv, (struct sigvec *)NULL);
- if(fi != stdin)
- (void) fclose(fi);
-#ifdef S5EMUL /* XXX - BOTH versions should probably do this! */
- if(intrupt)
- (void) kill(getpid(), SIGINT);
-#endif
- return(pbuf);
-}
-
-static void
-catch(void)
-{
- ++intrupt;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getpwaent.c b/usr/src/lib/libbc/libc/gen/common/getpwaent.c
deleted file mode 100644
index fa3e1c5b64..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getpwaent.c
+++ /dev/null
@@ -1,557 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1991 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/label.h>
-#include <sys/audit.h>
-#include <pwdadj.h>
-#include <pwd.h>
-#include <rpcsvc/ypclnt.h>
-#include <string.h>
-#include <malloc.h>
-
-extern void rewind();
-extern long strtol();
-extern int fclose();
-
-void setpwaent(void);
-void endpwaent(void);
-
-static struct _pwajunk {
- struct passwd _NULLPW;
- FILE *_pwfadj;
- char *_yp;
- int _yplen;
- char *_oldyp;
- int _oldyplen;
- struct list {
- char *name;
- struct list *nxt;
- } *_minuslist;
- struct passwd _interppasswd;
- struct passwd_adjunct _apwadj;
- char _interpline[BUFSIZ+1];
- char *_domain;
-} *__pwajunk, *_pwajunk(void);
-
-#define NULLPW (_pwa->_NULLPW)
-#define pwfadj (_pwa->_pwfadj)
-#define yp (_pwa->_yp)
-#define yplen (_pwa->_yplen)
-#define oldyp (_pwa->_oldyp)
-#define oldyplen (_pwa->_oldyplen)
-#define minuslist (_pwa->_minuslist)
-#define interppasswd (_pwa->_interppasswd)
-#define apwadj (_pwa->_apwadj)
-#define interpline (_pwa->_interpline)
-#define domain (_pwa->_domain)
-
-static char *PASSWDADJ = "/etc/security/passwd.adjunct";
-
-static struct passwd_adjunct *interpret(char *, int);
-static struct passwd_adjunct *interpretwithsave(char *, int,
- struct passwd_adjunct *);
-static struct passwd_adjunct *save(struct passwd_adjunct *);
-static struct passwd_adjunct *getnamefromyellow(char *,
- struct passwd_adjunct *);
-static int matchname(char [], struct passwd_adjunct **, char *);
-static int onminuslist(struct passwd_adjunct *);
-static void getnextfromyellow(void);
-static void getfirstfromyellow(void);
-static void freeminuslist(void);
-static void addtominuslist(char *);
-
-
-
-static struct _pwajunk *
-_pwajunk(void)
-{
-
- if (__pwajunk == 0)
- __pwajunk = (struct _pwajunk *)calloc(1, sizeof (*__pwajunk));
- return (__pwajunk);
-}
-
-struct passwd_adjunct *
-getpwanam(char *name)
-{
- struct _pwajunk *_pwa = _pwajunk();
- struct passwd_adjunct *pwadj;
- char line[BUFSIZ+1];
-
- if (_pwa == 0)
- return (NULL);
- setpwaent();
- if (!pwfadj)
- return (NULL);
- while (fgets(line, BUFSIZ, pwfadj) != NULL) {
- if ((pwadj = interpret(line, strlen(line))) == NULL)
- continue;
- if (matchname(line, &pwadj, name)) {
- endpwaent();
- return (pwadj);
- }
- }
- endpwaent();
- return (NULL);
-}
-
-
-void
-setpwaent(void)
-{
- struct _pwajunk *_pwa = _pwajunk();
-
- if (_pwa == 0)
- return;
- if (domain == NULL) {
- (void) yp_get_default_domain(&domain );
- }
- if (pwfadj == NULL)
- pwfadj = fopen(PASSWDADJ, "r");
- else
- rewind(pwfadj);
- if (yp)
- free(yp);
- yp = NULL;
- freeminuslist();
-}
-
-
-
-void
-endpwaent(void)
-{
- struct _pwajunk *_pwa = _pwajunk();
-
- if (_pwa == 0)
- return;
- if (pwfadj != NULL) {
- (void) fclose(pwfadj);
- pwfadj = NULL;
- }
- if (yp)
- free(yp);
- yp = NULL;
- freeminuslist();
- endnetgrent();
-}
-
-
-
-struct passwd_adjunct *
-getpwaent(void)
-{
- struct _pwajunk *_pwa = _pwajunk();
- char line[BUFSIZ+1];
- static struct passwd_adjunct *savepwadj;
- struct passwd_adjunct *pwadj;
- char *user;
- char *mach;
- char *dom;
-
- if (_pwa == 0)
- return (NULL);
- if (domain == NULL) {
- (void) yp_get_default_domain(&domain );
- }
- if (pwfadj == NULL && (pwfadj = fopen(PASSWDADJ, "r")) == NULL) {
- return (NULL);
- }
-
- for (;;) {
- if (yp) {
- pwadj = interpretwithsave(yp, yplen, savepwadj);
- free(yp);
- if (pwadj == NULL)
- return (NULL);
- getnextfromyellow();
- if (!onminuslist(pwadj)) {
- return (pwadj);
- }
- } else if (getnetgrent(&mach,&user,&dom)) {
- if (user) {
- pwadj = getnamefromyellow(user, savepwadj);
- if (pwadj != NULL && !onminuslist(pwadj)) {
- return (pwadj);
- }
- }
- } else {
- endnetgrent();
- if (fgets(line, BUFSIZ, pwfadj) == NULL) {
- return (NULL);
- }
- if ((pwadj = interpret(line, strlen(line))) == NULL)
- return (NULL);
- switch(line[0]) {
- case '+':
- if (strcmp(pwadj->pwa_name, "+") == 0) {
- getfirstfromyellow();
- savepwadj = save(pwadj);
- } else if (line[1] == '@') {
- savepwadj = save(pwadj);
- if (innetgr(pwadj->pwa_name+2,(char *) NULL,"*",domain)) {
- /* include the whole NIS database */
- getfirstfromyellow();
- } else {
- setnetgrent(pwadj->pwa_name+2);
- }
- } else {
- /*
- * else look up this entry in NIS
- */
- savepwadj = save(pwadj);
- pwadj = getnamefromyellow(pwadj->pwa_name+1, savepwadj);
- if (pwadj != NULL && !onminuslist(pwadj)) {
- return (pwadj);
- }
- }
- break;
- case '-':
- if (line[1] == '@') {
- if (innetgr(pwadj->pwa_name+2,(char *) NULL,"*",domain)) {
- /* everybody was subtracted */
- return (NULL);
- }
- setnetgrent(pwadj->pwa_name+2);
- while (getnetgrent(&mach,&user,&dom)) {
- if (user) {
- addtominuslist(user);
- }
- }
- endnetgrent();
- } else {
- addtominuslist(pwadj->pwa_name+1);
- }
- break;
- default:
- if (!onminuslist(pwadj)) {
- return (pwadj);
- }
- break;
- }
- }
- }
-}
-
-static int
-matchname(char line1[], struct passwd_adjunct **pwadjp, char *name)
-{
- struct _pwajunk *_pwa = _pwajunk();
- struct passwd_adjunct *savepwadj;
- struct passwd_adjunct *pwadj = *pwadjp;
-
- if (_pwa == 0)
- return (0);
- switch(line1[0]) {
- case '+':
- if (strcmp(pwadj->pwa_name, "+") == 0) {
- savepwadj = save(pwadj);
- pwadj = getnamefromyellow(name, savepwadj);
- if (pwadj) {
- *pwadjp = pwadj;
- return (1);
- }
- else
- return (0);
- }
- if (line1[1] == '@') {
- if (innetgr(pwadj->pwa_name+2,(char *) NULL,name,domain)) {
- savepwadj = save(pwadj);
- pwadj = getnamefromyellow(name,savepwadj);
- if (pwadj) {
- *pwadjp = pwadj;
- return (1);
- }
- }
- return (0);
- }
- if (strcmp(pwadj->pwa_name+1, name) == 0) {
- savepwadj = save(pwadj);
- pwadj = getnamefromyellow(pwadj->pwa_name+1, savepwadj);
- if (pwadj) {
- *pwadjp = pwadj;
- return (1);
- }
- else
- return (0);
- }
- break;
- case '-':
- if (line1[1] == '@') {
- if (innetgr(pwadj->pwa_name+2,(char *) NULL,name,domain)) {
- *pwadjp = NULL;
- return (1);
- }
- }
- else if (strcmp(pwadj->pwa_name+1, name) == 0) {
- *pwadjp = NULL;
- return (1);
- }
- break;
- default:
- if (strcmp(pwadj->pwa_name, name) == 0)
- return (1);
- }
- return (0);
-}
-
-static void
-getnextfromyellow(void)
-{
- struct _pwajunk *_pwa = _pwajunk();
- int reason;
- char *key;
- int keylen;
-
- if (_pwa == 0)
- return;
- reason = yp_next(domain, "passwd_adjunct",oldyp, oldyplen, &key
- ,&keylen,&yp,&yplen);
- if (reason) {
-#ifdef DEBUG
-fprintf(stderr, "reason yp_next failed is %d\n", reason);
-#endif
- yp = NULL;
- }
- if (oldyp)
- free(oldyp);
- oldyp = key;
- oldyplen = keylen;
-}
-
-static void
-getfirstfromyellow(void)
-{
- struct _pwajunk *_pwa = _pwajunk();
- int reason;
- char *key;
- int keylen;
-
- if (_pwa == 0)
- return;
- reason = yp_first(domain, "passwd_adjunct", &key, &keylen, &yp, &yplen);
- if (reason) {
-#ifdef DEBUG
-fprintf(stderr, "reason yp_first failed is %d\n", reason);
-#endif
- yp = NULL;
- }
- if (oldyp)
- free(oldyp);
- oldyp = key;
- oldyplen = keylen;
-}
-
-static struct passwd_adjunct *
-getnamefromyellow(char *name, struct passwd_adjunct *savepwadj)
-{
- struct _pwajunk *_pwa = _pwajunk();
- struct passwd_adjunct *pwadj;
- int reason;
- char *val;
- int vallen;
-
- if (_pwa == 0)
- return (NULL);
- reason = yp_match(domain, "passwd.adjunct.byname", name, strlen(name)
- , &val, &vallen);
- if (reason) {
-#ifdef DEBUG
-fprintf(stderr, "reason yp_match failed is %d\n", reason);
-#endif
- return (NULL);
- } else {
- pwadj = interpret(val, vallen);
- free(val);
- if (pwadj == NULL)
- return (NULL);
- if (savepwadj->pwa_passwd && *savepwadj->pwa_passwd)
- pwadj->pwa_passwd = savepwadj->pwa_passwd;
- return (pwadj);
- }
-}
-
-static struct passwd_adjunct *
-interpretwithsave(char *val, int len, struct passwd_adjunct *savepwadj)
-{
- struct _pwajunk *_pwa = _pwajunk();
- struct passwd_adjunct *pwadj;
-
- if (_pwa == 0)
- return (NULL);
- if ((pwadj = interpret(val, len)) == NULL)
- return (NULL);
- if (savepwadj->pwa_passwd && *savepwadj->pwa_passwd)
- pwadj->pwa_passwd = savepwadj->pwa_passwd;
- return (pwadj);
-}
-
-static char *
-pwskip(char *p)
-{
- while(*p && *p != ':' && *p != '\n')
- ++p;
- if (*p == '\n')
- *p = '\0';
- else if (*p != '\0')
- *p++ = '\0';
- return (p);
-}
-
-static struct passwd_adjunct *
-interpret(char *val, int len)
-{
- struct _pwajunk *_pwa = _pwajunk();
- char *p;
- char *field;
-
- if (_pwa == 0)
- return (NULL);
- (void) strncpy(interpline, val, len);
- p = interpline;
- interpline[len] = '\n';
- interpline[len+1] = 0;
-
- apwadj.pwa_name = p;
- p = pwskip(p);
- if (strcmp(apwadj.pwa_name, "+") == 0) {
- /* we are going to the NIS - fix the
- * rest of the struct as much as is needed
- */
- apwadj.pwa_passwd = "";
- return (&apwadj);
- }
- apwadj.pwa_passwd = p;
- p = pwskip(p);
- field = p;
- p = pwskip(p);
- labelfromstring(0, field, &apwadj.pwa_minimum);
- field = p;
- p = pwskip(p);
- labelfromstring(0, field, &apwadj.pwa_maximum);
- field = p;
- p = pwskip(p);
- labelfromstring(0, field, &apwadj.pwa_def);
- field = p;
- p = pwskip(p);
- apwadj.pwa_au_always.as_success = 0;
- apwadj.pwa_au_always.as_failure = 0;
- if (getauditflagsbin(field, &apwadj.pwa_au_always) != 0)
- return (NULL);
- field = p;
- (void) pwskip(p);
- p = apwadj.pwa_passwd;
- while (*p && *p != ',')
- p++;
- if (*p)
- *p = '\0';
- apwadj.pwa_age = p;
- apwadj.pwa_au_never.as_success = 0;
- apwadj.pwa_au_never.as_failure = 0;
- if (getauditflagsbin(field, &apwadj.pwa_au_never) != 0)
- return (NULL);
- return (&apwadj);
-}
-
-static void
-freeminuslist(void) {
- struct _pwajunk *_pwa = _pwajunk();
- struct list *ls;
-
- if (_pwa == 0)
- return;
- for (ls = minuslist; ls != NULL; ls = ls->nxt) {
- free(ls->name);
- free((char *) ls);
- }
- minuslist = NULL;
-}
-
-static void
-addtominuslist(char *name)
-{
- struct _pwajunk *_pwa = _pwajunk();
- struct list *ls;
- char *buf;
-
- if (_pwa == 0)
- return;
- ls = (struct list *) malloc(sizeof(struct list));
- buf = malloc((unsigned) strlen(name) + 1);
- (void) strcpy(buf, name);
- ls->name = buf;
- ls->nxt = minuslist;
- minuslist = ls;
-}
-
-/*
- * save away the psswd field, which is the only one which can be
- * specified in a local + entry to override the value in the NIS
- * for passwd.adjunct
- */
-static struct passwd_adjunct *
-save(struct passwd_adjunct *pwadj)
-{
- struct _pwajunk *_pwa = _pwajunk();
- static struct passwd_adjunct *sv;
-
- if (_pwa == 0)
- return (NULL);
- /* free up stuff from last call */
- if (sv) {
- free(sv->pwa_passwd);
- free((char *) sv);
- }
- sv = (struct passwd_adjunct *) malloc(sizeof(struct passwd_adjunct));
-
- sv->pwa_passwd = malloc((unsigned) strlen(pwadj->pwa_passwd) + 1);
- (void) strcpy(sv->pwa_passwd, pwadj->pwa_passwd);
-
- return (sv);
-}
-
-static int
-onminuslist(struct passwd_adjunct *pwadj)
-{
- struct _pwajunk *_pwa = _pwajunk();
- struct list *ls;
- char *nm;
-
- if (_pwa == 0)
- return (0);
- nm = pwadj->pwa_name;
- for (ls = minuslist; ls != NULL; ls = ls->nxt) {
- if (strcmp(ls->name,nm) == 0) {
- return (1);
- }
- }
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getsubopt.c b/usr/src/lib/libbc/libc/gen/common/getsubopt.c
deleted file mode 100644
index c41bcca34b..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getsubopt.c
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* created from scratch */
-
-/*
- * getsubopt - parse suboptions from a flag argument.
- */
-#include <string.h>
-#include <stdio.h>
-
-int
-getsubopt(optionsp, tokens, valuep)
- char **optionsp;
- char *tokens[];
- char **valuep;
-{
- register char *s = *optionsp, *p;
- register int i, optlen;
-
- *valuep = NULL;
- if (*s == '\0')
- return (-1);
- p = strchr(s, ','); /* find next option */
- if (p == NULL) {
- p = s + strlen(s);
- } else {
- *p++ = '\0'; /* mark end and point to next */
- }
- *optionsp = p; /* point to next option */
- p = strchr(s, '='); /* find value */
- if (p == NULL) {
- optlen = strlen(s);
- *valuep = NULL;
- } else {
- optlen = p - s;
- *valuep = ++p;
- }
- for (i = 0; tokens[i] != NULL; i++) {
- if ((optlen == strlen(tokens[i])) &&
- (strncmp(s, tokens[i], optlen) == 0))
- return (i);
- }
- /* no match, point value at option and return error */
- *valuep = s;
- return (-1);
-}
-
diff --git a/usr/src/lib/libbc/libc/gen/common/getttyent.c b/usr/src/lib/libbc/libc/gen/common/getttyent.c
deleted file mode 100644
index ddea7093df..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getttyent.c
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-
-#include <stdio.h>
-#include <strings.h>
-#include <ttyent.h>
-
-static char *TTYFILE = "/etc/ttytab";
-#define LINE 256
-static struct _ttyentjunk {
- char zapchar;
- FILE *tf;
- char line[LINE];
- struct ttyent tty;
-} *__ttyentjunk, *_ttyentjunk(void);
-
-static struct _ttyentjunk *
-_ttyentjunk(void)
-{
-
- if (__ttyentjunk == 0)
- __ttyentjunk = (struct _ttyentjunk *)calloc(1, sizeof (struct _ttyentjunk));
- return (__ttyentjunk);
-}
-
-void
-setttyent(void)
-{
- struct _ttyentjunk *t = _ttyentjunk();
-
- if (t == 0)
- return;
- if (t->tf == NULL)
- t->tf = fopen(TTYFILE, "r");
- else
- rewind(t->tf);
-}
-
-void
-endttyent(void)
-{
- struct _ttyentjunk *t = _ttyentjunk();
-
- if (t == 0)
- return;
- if (t->tf != NULL) {
- (void) fclose(t->tf);
- t->tf = NULL;
- }
-}
-
-#define QUOTED 1
-
-/*
- * Skip over the current field, removing quotes,
- * and return a pointer to the next field.
- */
-static char *
-skip(char *p)
-{
- struct _ttyentjunk *t = _ttyentjunk();
- char *cp = p;
- int c;
- int q = 0;
-
- if (t == 0)
- return (0);
- for (; (c = *p) != '\0'; p++) {
- if (c == '"') {
- q ^= QUOTED; /* obscure, but nice */
- continue;
- }
- if (q == QUOTED && *p == '\\' && *(p+1) == '"')
- p++;
- *cp++ = *p;
- if (q == QUOTED)
- continue;
- if (c == '#') {
- t->zapchar = c;
- *p = 0;
- break;
- }
- if (c == '\t' || c == ' ' || c == '\n') {
- t->zapchar = c;
- *p++ = 0;
- while ((c = *p) == '\t' || c == ' ' || c == '\n')
- p++;
- break;
- }
- }
- *--cp = '\0';
- return (p);
-}
-
-static char *
-value(char *p)
-{
- if ((p = index(p,'=')) == 0)
- return (NULL);
- p++; /* get past the = sign */
- return (p);
-}
-
-struct ttyent *
-getttyent(void)
-{
- struct _ttyentjunk *t = _ttyentjunk();
- char *p;
- int c;
-
- if (t == 0)
- return (NULL);
- if (t->tf == NULL) {
- if ((t->tf = fopen(TTYFILE, "r")) == NULL)
- return (NULL);
- }
- do {
- p = fgets(t->line, LINE, t->tf);
- if (p == NULL)
- return (NULL);
- while ((c = *p) == '\t' || c == ' ' || c == '\n')
- p++;
- } while (c == '\0' || c == '#');
- t->zapchar = 0;
- t->tty.ty_name = p;
- p = skip(p);
- t->tty.ty_getty = p;
- p = skip(p);
- t->tty.ty_type = p;
- p = skip(p);
- t->tty.ty_status = 0;
- t->tty.ty_window = NULL;
- for (; *p; p = skip(p)) {
-#define space(x) ((c = p[x]) == ' ' || c == '\t' || c == '\n')
- if (strncmp(p, "on", 2) == 0 && space(2))
- t->tty.ty_status |= TTY_ON;
- else if (strncmp(p, "off", 3) == 0 && space(3))
- t->tty.ty_status &= ~TTY_ON;
- else if (strncmp(p, "secure", 6) == 0 && space(6))
- t->tty.ty_status |= TTY_SECURE;
- else if (strncmp(p, "local", 5) == 0 && space(5))
- t->tty.ty_status |= TTY_LOCAL;
- else if (strncmp(p, "window=", 7) == 0)
- t->tty.ty_window = value(p);
- else
- break;
- }
- if (t->zapchar == '#' || *p == '#')
- while ((c = *++p) == ' ' || c == '\t')
- ;
- t->tty.ty_comment = p;
- if (*p == 0)
- t->tty.ty_comment = 0;
- if (p = index(p, '\n'))
- *p = '\0';
- return (&t->tty);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getttynam.c b/usr/src/lib/libbc/libc/gen/common/getttynam.c
deleted file mode 100644
index b61ba7b1cc..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getttynam.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 5.2 3/9/86 */
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#include <ttyent.h>
-
-struct ttyent *
-getttynam(tty)
- char *tty;
-{
- register struct ttyent *t;
-
- setttyent();
- while (t = getttyent()) {
- if (strcmp(tty, t->ty_name) == 0)
- break;
- }
- endttyent();
- return (t);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/getusershell.c b/usr/src/lib/libbc/libc/gen/common/getusershell.c
deleted file mode 100644
index f164bea8e4..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/getusershell.c
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/param.h>
-#include <sys/file.h>
-#include <sys/stat.h>
-#include <ctype.h>
-#include <stdio.h>
-#include <malloc.h>
-
-#define SHELLS "/etc/shells"
-
-/*
- * Do not add local shells here. They should be added in /etc/shells
- */
-static char *okshells[] =
- { "/bin/sh", "/bin/csh", "/usr/bin/sh", "/usr/bin/csh", 0 };
-
-static char **shells, *strings;
-static char **curshell;
-
-static char **initshells(void);
-
-/*
- * Get a list of shells from SHELLS, if it exists.
- */
-char *
-getusershell(void)
-{
- char *ret;
-
- if (curshell == NULL)
- curshell = initshells();
- ret = *curshell;
- if (ret != NULL)
- curshell++;
- return (ret);
-}
-
-void
-endusershell(void)
-{
-
- if (shells != NULL)
- free((char *)shells);
- shells = NULL;
- if (strings != NULL)
- free(strings);
- strings = NULL;
- curshell = NULL;
-}
-
-void
-setusershell(void)
-{
-
- curshell = initshells();
-}
-
-static char **
-initshells(void)
-{
- char **sp, *cp;
- FILE *fp;
- struct stat statb;
-
- if (shells != NULL)
- free((char *)shells);
- shells = NULL;
- if (strings != NULL)
- free(strings);
- strings = NULL;
- if ((fp = fopen(SHELLS, "r")) == (FILE *)0)
- return (okshells);
- if (fstat(fileno(fp), &statb) == -1) {
- (void)fclose(fp);
- return (okshells);
- }
- if ((strings = malloc((unsigned)statb.st_size + 1)) == NULL) {
- (void)fclose(fp);
- return (okshells);
- }
- shells = (char **)calloc((unsigned)statb.st_size / 3, sizeof (char *));
- if (shells == NULL) {
- (void)fclose(fp);
- free(strings);
- strings = NULL;
- return (okshells);
- }
- sp = shells;
- cp = strings;
- while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
- while (*cp != '#' && *cp != '/' && *cp != '\0')
- cp++;
- if (*cp == '#' || *cp == '\0')
- continue;
- *sp++ = cp;
- while (!isspace(*cp) && *cp != '#' && *cp != '\0')
- cp++;
- *cp++ = '\0';
- }
- *sp = (char *)0;
- (void)fclose(fp);
- return (shells);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/grpauth.c b/usr/src/lib/libbc/libc/gen/common/grpauth.c
deleted file mode 100644
index 3532ae959e..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/grpauth.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <signal.h>
-#include <grp.h>
-#include <sys/time.h>
-#include <errno.h>
-
-/*
- * Version to go in the BCP compatibility library in SVr4 version of
- * SunOS. This does not bother talking to rpc.pwdauthd or looking for the
- * password.adjunct file on the system since they do not exist anymore.
- * They have been effectively replaced by a more robust aging security provided
- * by the combination of /etc/shadow file, shadow support in the NIS+
- * passwd table and the use of secure RPC in NIS+.
- */
-
-int
-grpauth(char *name, char *password)
-{
-
- /*
- * this routine authenticates a password for the named user.
- * Assumes the adjunct file does not exist.
- * and therefore checks the group "source" using the standard
- * getgrnam(3C) routine that uses /etc/nsswitch.conf(4).
- */
- struct group gr;
- struct group *grp;
-
- if ((grp = getgrnam(name)) == NULL)
- /* group is not in main password system */
- return (-1);
- gr = *grp;
- if (gr.gr_passwd[0] == '#' && gr.gr_passwd[1] == '$') {
- /* this means that /etc/group has problems */
- fprintf(stderr, "grpauth: bad group entry for %s\n",
- gr.gr_name);
- return (-1);
- }
- if (strcmp(crypt(password, gr.gr_passwd), gr.gr_passwd) == 0)
- return (0);
- else
- return (-1);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/hsearch.c b/usr/src/lib/libbc/libc/gen/common/hsearch.c
deleted file mode 100644
index 8a98c709de..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/hsearch.c
+++ /dev/null
@@ -1,545 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1996 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*LINTLIBRARY*/
-/* Compile time switches:
-
- MULT - use a multiplicative hashing function.
- DIV - use the remainder mod table size as a hashing function.
- CHAINED - use a linked list to resolve collisions.
- OPEN - use open addressing to resolve collisions.
- BRENT - use Brent's modification to improve the OPEN algorithm.
- SORTUP - CHAINED list is sorted in increasing order.
- SORTDOWN - CHAINED list is sorted in decreasing order.
- START - CHAINED list with entries appended at front.
- DRIVER - compile in a main program to drive the tests.
- DEBUG - compile some debugging printout statements.
- USCR - user supplied comparison routine.
-*/
-
-#include <stdio.h>
-#include <limits.h>
-#include <malloc.h>
-#include <string.h>
-
-#define SUCCEED 0
-#define FAIL 1
-#define TRUE 1
-#define FALSE 0
-#define repeat for(;;)
-#define until(A) if(A) break;
-
-#ifdef OPEN
-# undef CHAINED
-#else
-#ifndef CHAINED
-# define OPEN
-#endif
-#endif
-
-#ifdef MULT
-# undef DIV
-#else
-#ifndef DIV
-# define MULT
-#endif
-#endif
-
-#ifdef START
-# undef SORTUP
-# undef SORTDOWN
-#else
-#ifdef SORTUP
-# undef SORTDOWN
-#endif
-#endif
-
-#ifdef USCR
-# define COMPARE(A, B) (* hcompar)((A), (B))
- extern int (* hcompar)();
-#else
-# define COMPARE(A, B) strcmp((A), (B))
-#endif
-
-#ifdef MULT
-# define SHIFT ((bitsper * sizeof(int)) - m) /* Shift factor */
-# define FACTOR 035761254233 /* Magic multiplication factor */
-# define HASH hashm /* Multiplicative hash function */
-# define HASH2 hash2m /* Secondary hash function */
-static unsigned int bitsper; /* Bits per byte */
-static unsigned int hashm();
-static unsigned int hash2m();
-#else
-#ifdef DIV
-# define HASH hashd /* Division hashing routine */
-# define HASH2(A) 1 /* Secondary hash function */
-static unsigned int hashd();
-#endif
-#endif
-
-typedef enum {
- FIND, /* Find, if present */
- ENTER /* Find; enter if not present */
-} ACTION;
-typedef char *POINTER;
-typedef struct entry { /* Hash table entry */
- POINTER key;
- POINTER data;
-} ENTRY;
-
-#ifdef CHAINED
-typedef struct node { /* Part of the linked list of entries */
- ENTRY item;
- struct node *next;
-} NODE;
-typedef NODE *TABELEM;
-static NODE **table; /* The address of the hash table */
-static ENTRY *build();
-#else
-#ifdef OPEN
-typedef ENTRY TABELEM; /* What the table contains (TABle ELEMents) */
-static TABELEM *table; /* The address of the hash table */
-static unsigned int count = 0; /* Number of entries in hash table */
-#endif
-#endif
-
-static unsigned int length; /* Size of the hash table */
-static unsigned int m; /* Log base 2 of length */
-static unsigned int prcnt; /* Number of probes this item */
-
-int hcreate();
-void hdestroy();
-ENTRY *hsearch();
-static unsigned int crunch();
-
-#ifdef DRIVER
-static void hdump();
-
-main()
-{
- char line[80]; /* Room for the input line */
- int i = 0; /* Data generator */
- ENTRY *res; /* Result of hsearch */
- ENTRY *new; /* Test entry */
-
- if(hcreate(5))
- printf("Length = %u, m = %u\n", length, m);
- else {
- fprintf(stderr, "Out of core\n");
- exit(FAIL);
- }
-
- repeat {
- hdump();
- printf("Enter a probe: ");
- until (EOF == scanf("%s", line));
-#ifdef DEBUG
- printf("%s, ", line);
- printf("division: %d, ", hashd(line));
- printf("multiplication: %d\n", hashm(line));
-#endif
- new = (ENTRY *) malloc(sizeof(ENTRY));
- if(new == NULL) {
- fprintf(stderr, "Out of core \n");
- exit(FAIL);
- }
- else {
- new->key = malloc((unsigned) strlen(line) + 1);
- if(new->key == NULL) {
- fprintf(stderr, "Out of core \n");
- exit(FAIL);
- }
- strcpy(new->key, line);
- new->data = malloc(sizeof(int));
- if(new->data == NULL) {
- fprintf(stderr, "Out of core \n");
- exit(FAIL);
- }
- *new->data = i++;
- }
- res = hsearch(*new, ENTER);
- printf("The number of probes required was %d\n", prcnt);
- if(res == (ENTRY *) 0)
- printf("Table is full\n");
- else {
- printf("Success: ");
- printf("Key = %s, Value = %d\n", res->key, *res->data);
- }
- }
- exit(SUCCEED);
-}
-#endif
-
-/*
- * Create a hash table no smaller than size
- *
- * size: Minimum size for hash table
- */
-int
-hcreate(int size)
-{
- unsigned int unsize; /* Holds the shifted size */
-
- if(size <= 0)
- return(FALSE);
-
- unsize = size; /* +1 for empty table slot; -1 for ceiling */
- length = 1; /* Maximum entries in tabbe */
- m = 0; /* Log2 length */
- while(unsize) {
- unsize >>= 1;
- length <<= 1;
- m++;
- }
-
- table = (TABELEM *) calloc(length, sizeof(TABELEM));
- return (table != NULL);
-}
-
-void
-hdestroy(void) /* Reset the module to its initial state */
-{
- free((POINTER) table);
-#ifdef OPEN
- count = 0;
-#endif
-}
-
-#ifdef OPEN
-/* Hash search of a fixed-capacity table. Open addressing used to
- resolve collisions. Algorithm modified from Knuth, Volume 3,
- section 6.4, algorithm D. Labels flag corresponding actions.
-*/
-
-/*
- * Find or insert the item into the table
- *
- * item: Item to be inserted or found
- * action: FIND or ENTER
- */
-ENTRY *
-hsearch(ENTRY item, ACTION action)
-{
- unsigned int i; /* Insertion index */
- unsigned int c; /* Secondary probe displacement */
-
- prcnt = 1;
-
-/* D1: */
- i = HASH(item.key); /* Primary hash on key */
-#ifdef DEBUG
- if(action == ENTER)
- printf("hash = %o\n", i);
-#endif
-
-/* D2: */
- if(table[i].key == NULL) /* Empty slot? */
- goto D6;
- else if(COMPARE(table[i].key, item.key) == 0) /* Match? */
- return(&table[i]);
-
-/* D3: */
- c = HASH2(item.key); /* No match => compute secondary hash */
-#ifdef DEBUG
- if(action == ENTER)
- printf("hash2 = %o\n", c);
-#endif
-
-D4:
- i = (i + c) % length; /* Advance to next slot */
- prcnt++;
-
-/* D5: */
- if(table[i].key == NULL) /* Empty slot? */
- goto D6;
- else if(COMPARE(table[i].key, item.key) == 0) /* Match? */
- return(&table[i]);
- else
- goto D4;
-
-D6: if(action == FIND) /* Insert if requested */
- return((ENTRY *) NULL);
- if(count == (length - 1)) /* Table full? */
- return((ENTRY *) 0);
-
-#ifdef BRENT
-/* Brent's variation of the open addressing algorithm. Do extra
- work during insertion to speed retrieval. May require switching
- of previously placed items. Adapted from Knuth, Volume 3, section
- 4.6 and Brent's article in CACM, volume 10, #2, February 1973.
-*/
-
- { unsigned int p0 = HASH(item.key); /* First probe index */
- unsigned int c0 = HASH2(item.key); /* Main branch increment */
- unsigned int r = prcnt - 1; /* Current minimum distance */
- unsigned int j; /* Counts along main branch */
- unsigned int k; /* Counts along secondary branch */
- unsigned int curj; /* Current best main branch site */
- unsigned int curpos; /* Current best table index */
- unsigned int pj; /* Main branch indices */
- unsigned int cj; /* Secondary branch increment distance*/
- unsigned int pjk; /* Secondary branch probe indices */
-
- if(prcnt >= 3) {
- for(j = 0; j < prcnt; j++) { /* Count along main branch */
- pj = (p0 + j * c0) % length; /* New main branch index */
- cj = HASH2(table[pj].key); /* Secondary branch incr. */
- for(k=1; j+k <= r; k++) { /* Count on secondary branch*/
- pjk = (pj + k * cj) % length; /* Secondary probe */
- if(table[pjk].key == NULL) { /* Improvement found */
- r = j + k; /* Decrement upper bound */
- curj = pj; /* Save main probe index */
- curpos = pjk; /* Save secondeary index */
- }
- }
- }
- if(r != prcnt - 1) { /* If an improvement occurred */
- table[curpos] = table[curj]; /* Old key to new site */
-#ifdef DEBUG
- printf("Switch curpos = %o, curj = %o, oldi = %o\n",
- curj, curpos, i);
-#endif
- i = curj;
- }
- }
- }
-#endif
- count++; /* Increment table occupancy count */
- table[i] = item; /* Save item */
- return(&table[i]); /* Address of item is returned */
-}
-#endif
-
-#ifdef USCR
-# ifdef DRIVER
-static int
-compare(POINTER a, POINTER b)
-{
- return (strcmp(a, b));
-}
-
-int (* hcompar)() = compare;
-# endif
-#endif
-
-#ifdef CHAINED
-# ifdef SORTUP
-# define STRCMP(A, B) (COMPARE((A), (B)) > 0)
-# else
-# ifdef SORTDOWN
-# define STRCMP(A, B) (COMPARE((A), (B)) < 0)
-# else
-# define STRCMP(A, B) (COMPARE((A), (B)) != 0)
-# endif
-# endif
-
-/*
- * Chained search with sorted lists
- *
- * item: Item to be inserted or found
- * action: FIND or ENTER
- */
-ENTRY *
-hsearch(ENTRY item, ACTION action)
-{
- NODE *p; /* Searches through the linked list */
- NODE **q; /* Where to store the pointer to a new NODE */
- unsigned int i; /* Result of hash */
- int res; /* Result of string comparison */
-
- prcnt = 1;
-
- i = HASH(item.key); /* Table[i] contains list head */
-
- if(table[i] == (NODE*)NULL) { /* List has not yet been begun */
- if(action == FIND)
- return((ENTRY *) NULL);
- else
- return(build(&table[i], (NODE *) NULL, item));
- }
- else { /* List is not empty */
- q = &table[i];
- p = table[i];
- while(p != NULL && (res = STRCMP(item.key, p->item.key))) {
- prcnt++;
- q = &(p->next);
- p = p->next;
- }
-
- if(p != NULL && res == 0) /* Item has been found */
- return(&(p->item));
- else { /* Item is not yet on list */
- if(action == FIND)
- return((ENTRY *) NULL);
- else
-#ifdef START
- return(build(&table[i], table[i], item));
-#else
- return(build(q, p, item));
-#endif
- }
- }
-}
-
-/*
- * last: Where to store in last list item
- * next: Link to next list item
- * item: Item to be kept in node
- */
-static ENTRY *
-build(NODE **last, NODE *next, ENTRY item)
-{
- NODE *p = (NODE *) malloc(sizeof(NODE));
-
- if(p != NULL) {
- p->item = item;
- *last = p;
- p->next = next;
- return(&(p->item));
- }
- else
- return(NULL);
-}
-#endif
-
-#ifdef DIV
-/*
- * Division hashing scheme
- *
- * key: Key to be hashed
- */
-static unsigned int
-hashd(POINTER key)
-{
- return (crunch(key) % length);
-}
-#else
-#ifdef MULT
-/*
- * NOTE: The following algorithm only works on machines where
- * the results of multiplying two integers is the least
- * significant part of the double word integer required to hold
- * the result. It is adapted from Knuth, Volume 3, section 6.4.
- */
-
-/*
- * Multiplication hashing scheme
- *
- * key: Key to be hashed
- */
-static unsigned int
-hashm(POINTER key)
-{
- static int first = TRUE; /* TRUE on the first call only */
-
- if(first) { /* Compute the number of bits in a byte */
- unsigned char c = UCHAR_MAX; /* A byte full of 1's */
- bitsper = 0;
- while(c) { /* Shift until no more 1's */
- c >>= 1;
- bitsper++; /* Count number of shifts */
- }
- first = FALSE;
- }
- return ((int) (((unsigned) (crunch(key) * FACTOR)) >> SHIFT));
-}
-
-/*
- * Secondary hashing, for use with multiplicitive hashing scheme.
- * Adapted from Knuth, Volume 3, section 6.4.
- */
-
-/*
- * Secondary hashing routine
- *
- * key: String to be hashed
- */
-static unsigned int
-hash2m(POINTER key)
-{
- return ((int) (((unsigned) ((crunch(key) * FACTOR) << m) >> SHIFT) | 1));
-}
-#endif
-#endif
-
-/* Convert multicharacter key to unsigned int */
-static unsigned int
-crunch(POINTER key)
-{
- unsigned int sum = 0; /* Results */
- int s; /* Length of the key */
-
- for(s = 0; *key; s++) /* Simply add up the bytes */
- sum += *key++;
-
- return (sum + s);
-}
-
-#ifdef DRIVER
-static void
-hdump() /* Dumps loc, data, probe count, key */
-{
- unsigned int i; /* Counts table slots */
-#ifdef OPEN
- unsigned int sum = 0; /* Counts probes */
-#else
-#ifdef CHAINED
- NODE *a; /* Current Node on list */
-#endif
-#endif
-
- for(i = 0; i < length; i++)
-#ifdef OPEN
- if(table[i].key == NULL)
- printf("%o.\t-,\t-,\t(NULL)\n", i);
- else {
- unsigned int oldpr = prcnt; /* Save current probe count */
- hsearch(table[i], FIND);
- sum += prcnt;
- printf("%o.\t%d,\t%d,\t%s\n", i,
- *table[i].data, prcnt, table[i].key);
- prcnt = oldpr;
- }
- printf("Total probes = %d\n", sum);
-#else
-#ifdef CHAINED
- if(table[i] == NULL)
- printf("%o.\t-,\t-,\t(NULL)\n", i);
- else {
- printf("%o.", i);
- for(a = table[i]; a != NULL; a = a->next)
- printf("\t%d,\t%#0.4x,\t%s\n",
- *a->item.data, a, a->item.key);
- }
-#endif
-#endif
-}
-#endif
diff --git a/usr/src/lib/libbc/libc/gen/common/ieee_globals.c b/usr/src/lib/libbc/libc/gen/common/ieee_globals.c
deleted file mode 100644
index 101eeffa5c..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ieee_globals.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1987 by Sun Microsystems, Inc.
- */
-
-/*
- * contains definitions for variables for IEEE floating-point arithmetic
- * modes; IEEE floating-point arithmetic exception handling;
- */
-
-#include <floatingpoint.h>
-
-enum fp_direction_type fp_direction;
-/*
- * Current rounding direction. Updated by ieee_flags.
- */
-
-enum fp_precision_type fp_precision;
-/*
- * Current rounding precision. Updated by ieee_flags.
- */
-
-sigfpe_handler_type ieee_handlers[N_IEEE_EXCEPTION];
-/*
- * Array of pointers to functions to handle SIGFPE's corresponding to IEEE
- * fp_exceptions. sigfpe_default means do not generate SIGFPE. An invalid
- * address such as sigfpe_abort will cause abort on that SIGFPE. Updated by
- * ieee_handler.
- */
-fp_exception_field_type fp_accrued_exceptions;
-/*
- * Sticky accumulated exceptions, updated by ieee_flags. In hardware
- * implementations this variable is not automatically updated as the hardware
- * changes and should therefore not be relied on directly.
- */
diff --git a/usr/src/lib/libbc/libc/gen/common/index.c b/usr/src/lib/libbc/libc/gen/common/index.c
deleted file mode 100644
index 9b5e0a5766..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/index.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 4.1 80/12/21 */
-
-/*
- * Return the ptr in sp at which the character c appears;
- * NULL if not found
- */
-
-#define NULL 0
-
-char *
-index(sp, c)
- register char *sp, c;
-{
-
- do {
- if (*sp == c)
- return (sp);
- } while (*sp++);
- return (NULL);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/isatty.c b/usr/src/lib/libbc/libc/gen/common/isatty.c
deleted file mode 100644
index 689f9e5e2a..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/isatty.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R3 1.7 */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-
-/*LINTLIBRARY*/
-/*
- * Returns 1 iff file is a tty
- */
-#include <sys/termio.h>
-
-extern int ioctl();
-extern int errno;
-
-int
-isatty(f)
-int f;
-{
- struct termio tty;
- int err ;
-
- err = errno;
- if(ioctl(f, TCGETA, &tty) < 0)
- {
- errno = err;
- return(0);
- }
- return(1);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/iso.multibyte.c b/usr/src/lib/libbc/libc/gen/common/iso.multibyte.c
deleted file mode 100644
index fb1f1c607f..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/iso.multibyte.c
+++ /dev/null
@@ -1,923 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include "codeset.h"
-#include "mbextern.h"
-#include "iso2022.h"
-
-#define TO_MULTI 2
-#define TO_SINGLE 1
-
-#define BIT7ENV 7 /* 7bit enviornment */
-#define BIT8ENV 8 /* 8bit environment */
-#define NUM_OF_STATES 4 /* G0, G1, G2, G3 */
-#define BIT8(_ch) (_ch & 0x80)
-#define MAXSIZE 100 /* ESC LOCK upper lower */
-
-#define USE_STATE 0 /* use the actual _state info */
-#define USE_CONTROL 1 /* use C0 or C1 */
-#define USE_SS2 2 /* use Single shift 2 */
-#define USE_SS3 3 /* use Single shift 3 */
-
-#define G0MASK 0x0000
-#define G1MASK 0x0080
-#define G2MASK 0x8000
-#define G3MASK 0x8080
-#define FINAL 0x33 /* Temporary final character */
-
-#define MMB_CUR_MAX 128
-
-/*
- * Keep state informations
- */
-struct state {
- char width; /* 1 or 2 */
- char final; /* final character */
-};
-
-static char _my_env = BIT7ENV; /* default 7bits environment */
-static struct state Invoked_G0, Invoked_G1;
-static char _currentG0 = G0;
-static char _currentG1 = G1;
-static struct state _des_states[NUM_OF_STATES] = {
- {-1, 0}, {-1, 0}, {-1, 0}, {01, 0}
-};
-
-void _savestates(void); /* save states */
-void _restorestates(void); /* restore states */
-void _initializestates(void);/* Initialize states */
-
-
-/*
- * Variables for wc*tomb*()
- */
-static char _currentOUT = G0; /* G0, G1, G2 or G3 */
-static int prevcsize = 1;
-
-/*
- * mbtowc - subroutine for most iso codeset sequences
- */
-int
-_mbtowc_iso(wchar_t *pwc, char *s, size_t n)
-{
- unsigned char ch;
- unsigned char tch; /* temporary use */
- unsigned char *us = (unsigned char *)s;
- int gen_wide_state = USE_STATE; /* used in gen_wide: */
- int length = 0;
- int len = 0;
- wchar_t wide;
- int mask;
- int i;
-
- isowidth_t * isoinfo = (isowidth_t *) _code_set_info.code_info;
-
- /*
- * initialize _g0_stuff
- */
- if (_des_states[G0].width == -1) {
- _des_states[G0].width = isoinfo->g0_len;
- _des_states[G1].width = isoinfo->g1_len;
- _des_states[G2].width = isoinfo->g2_len;
- _des_states[G3].width = isoinfo->g3_len;
- _my_env = isoinfo->bit_env;
-
- Invoked_G0 = _des_states[G0];
- Invoked_G1 = _des_states[G1];
- }
-
- /*
- * get character and proceed
- */
-loop:
- ch = *us++;
- if (++length > n) return (-1); /* too long */
- switch (ch) { /* get a character */
- /* escape sequence or locking shifts */
- case ESC: /* escape sequence */
- gen_wide_state = USE_STATE; /* used in gen_wide: */
- ch = *us++;
- if (++length > n) return (-1); /* too long */
- switch (ch) {
- /* DESIGNATE */
- case 0x24: /* designate */
- ch = *us++;
- if (++length > n) return (-1); /* too long */
- switch (ch) {
- case 0x28: case 0x29:
- case 0x2A: case 0x2B:
- case 0x2D: case 0x2E:
- case 0x2F:
- tch = ch; /* save this to decide _des_state */
- /* Skip intermidiates */
- do {
- ch = *us++;
- if (++length > n) return (-1); /* too long */
- } while (ch >= 0x20 && ch <= 0x2F);
- if (ch < 0x30) /* ch should be a final character */
- return (-1); /* error */
- if (tch == 0x28)
- i = G0;
- else if (tch == 0x29 || tch == 0x2D)
- i = G1;
- else if (tch == 0x2A || tch == 0x2E)
- i = G2;
- else /* (tch == 0x2B || tch == 0x2F) */
- i = G3;
- /* updates state info */
- _des_states[i].width = TO_MULTI;
- _des_states[i].final = ch;
-
- goto loop;
- break;
- default:
- /* This is an illegal sequence */
- return (-1);
- break;
- }
- break;
- case 0x28: /* designate */
- case 0x29: case 0x2A: case 0x2B:
- case 0x2D: case 0x2E: case 0x2F:
- tch = ch; /* save this to decide _des_state */
- /* Skip intermidiates */
- do {
- ch = *us++;
- if (++length > n) return (-1); /* too long */
- } while (ch >= 0x20 && ch <= 0x2F);
- if (ch < 0x30) /* ch should be a final character */
- return (-1); /* error */
- if (tch == 0x28)
- i = G0;
- else if (tch == 0x29 || tch == 0x2D)
- i = G1;
- else if (tch == 0x2A || tch == 0x2E)
- i = G2;
- else /* (tch == 0x2B || tch == 0x2F) */
- i = G3;
- /* updates state info */
- _des_states[i].width = TO_SINGLE;
- _des_states[i].final = ch;
-
- goto loop;
- break;
-
- /* LOCKING SHIFTS */
- case LS1R: /* locking shift LS1R */;
- Invoked_G1 = _des_states[G1];
- _currentG1 = G1;
- goto loop;
- break;
- case LS2: /* locking shift LS2 */
- Invoked_G0 = _des_states[G2];
- _currentG0 = G2;
- goto loop;
- break;
- case LS2R: /* locking shift LS2R */
- Invoked_G1 = _des_states[G2];
- _currentG1 = G2;
- goto loop;
- break;
- case LS3: /* locking shift LS3 */
- Invoked_G0 = _des_states[G3];
- _currentG0 = G3;
- goto loop;
- break;
- case LS3R: /* locking shift LS3R */
- Invoked_G1 = _des_states[G3];
- _currentG1 = G3;
- goto loop;
- break;
-
- /* CONTROL FUNCTIONS */
- case 0x21: /* C0 sets */
- case 0x22: /* C1 sets */
- do {
- ch = *us++;
- if (++length > n) return (-1); /* too long */
- } while (ch >= 0x20 && ch <= 0x2F);
- if (ch < 0x30) /* ch should be a final character */
- return (-1); /* error */
- goto loop;
- break;
-
- /* SINGLE SHIFT for 7bit environment */
- case SS2_7B: /* Single shift SS2 for 7bits */
- case SS3_7B: /* Single shoft SS3 for 7bits */
- if (ch == SS2_7B)
- gen_wide_state = USE_SS2;
- else
- gen_wide_state = USE_SS3;
- goto loop;
- break;
-
- default: /* should be an error */
- return (-1);
- break;
- }
- /* locking shifts */
- case LS0:
- gen_wide_state = USE_STATE; /* used in gen_wide: */
- Invoked_G0 = _des_states[G0];
- _currentG0 = G0;
- goto loop;
- break;
-
- case LS1:
- gen_wide_state = USE_STATE; /* used in gen_wide: */
- Invoked_G0 = _des_states[G1];
- _currentG0 = G1;
- goto loop;
- break;
-
- /* Single shift SS3 and SS2 for 8bits */
- case SS2_8B:
- case SS3_8B:
- if (ch == SS2_8B)
- gen_wide_state = USE_SS2;
- else
- gen_wide_state = USE_SS3;
- goto loop;
- break;
-
- /* This character is not any special character/
- * It does not change any state.
- * Goto where it generates wide character.
- */
- default:
- /*
- * Use this ch to generate pwc.
- */
- if (ch == 0) { /* end of string or 0 */
- wide = 0;
- mask = 0;
- goto gen_wide;
- }
- break;
- }
-
-
- /*
- * Generate pwc here.
- * The information here is
- * current state and length. If the length is two, you need to
- * read one more character.
- */
- switch (gen_wide_state) {
- case USE_STATE:
- if (BIT8(ch)) { /* 8bit environment ? */
- /* current mode is G1 mode */
- if (Invoked_G1.width == 2) {
- tch = *us++;
- if (++length > n) return (-1);
- wide = ch;
- wide = (wide << 8 | tch);
- }
- else {
- wide = ch;
- }
- if (_currentG1 == G0) mask = G0MASK;
- else if (_currentG1 == G1) mask = G1MASK;
- else if (_currentG1 == G2) mask = G2MASK;
- else mask = G3MASK;
- }
- else {
- /* current mode is G0 mode */
- if (Invoked_G0.width == 2) {
- tch = *us++;
- if (++length > n) return (-1);
- wide = ch;
- wide = (wide << 8 | tch);
- }
- else {
- wide = ch;
- }
- if (_currentG0 == G0) mask = G0MASK;
- else if (_currentG0 == G1) mask = G1MASK;
- else if (_currentG0 == G2) mask = G2MASK;
- else mask = G3MASK;
- }
- break;
- case USE_SS2:
- if (_des_states[G2].width == 2) {
- tch = *us++;
- if (++length > n) return (-1);
- wide = ch;
- wide = (wide << 8 | tch);
- }
- else {
- wide = ch;
- }
- mask = G2MASK;
- break;
- case USE_SS3:
- if (_des_states[G3].width == 2) {
- tch = *us++;
- if (++length > n) return (-1);
- wide = ch;
- wide = (wide << 8 | tch);
- }
- else {
- wide = ch;
- }
- mask = G3MASK;
- break;
- default:
- /* shoult be internal error */
- return (-1);
- break;
- }
-gen_wide:
- wide &= 0x7F7F; /* strip off the top bit */
- wide = wide | mask;
- if (pwc != NULL)
- *pwc = wide;
- return (length);
-}
-
-
-#define MAXMBSIZE 128
-/*
- * mbstowcs()
- */
-size_t
-_mbstowcs_iso(wchar_t *pwcs, unsigned char *s, size_t n)
-{
- int ret1;
- int accsum = 0;
- wchar_t pwc;
-
- /*
- * If pwcs == 0, do nothing.
- */
- if (pwcs == 0)
- return (0);
- /*
- * States things
- */
- _savestates(); _initializestates();
- while (accsum < n) {
- ret1 = _mbtowc_iso (&pwc, (char *)s, MAXMBSIZE);
- if (ret1 < 0)
- return (-1); /* error */
- if (ret1 == 0 || pwc == 0) {
- if (pwcs == 0)
- *pwcs = 0;
- /*
- * Restore states
- */
- _restorestates();
- return (accsum);
- }
- s = s + ret1; /* increment the pointer */
- *pwcs++ = pwc;
- ++accsum;
- }
- /*
- * Restore states
- */
- _restorestates();
- return (accsum);
-}
-
-/*
- * wctomb -
- */
-int
-_wctomb_iso(unsigned char *s, wchar_t pwc)
-{
- unsigned char ch;
- unsigned char tch; /* temporary use */
- unsigned char *us = (unsigned char *)s;
- int gen_wide_state = USE_STATE; /* used in gen_wide: */
- int length = 0;
- int len = 0;
- wchar_t wide;
- unsigned short mode;
- unsigned char buf[MAXSIZE];
- unsigned char *bp;
- int csize, i;
- int n = MMB_CUR_MAX;
-
- isowidth_t * isoinfo = (isowidth_t *) _code_set_info.code_info;
-
- /*
- * If pwc is 0, do this first.
- */
- if (pwc == 0) {
- if (s != 0) {
- *s = 0;
- return (1);
- }
- else {
- return (0);
- }
- }
-
- mode = pwc & G3MASK; /* The mode of this character */
- if (((pwc >> 8) & 0x007f) == 0)
- csize = 1;
- else
- csize = 2;
- bp = buf;
- length = 0;
-#ifdef DDDebug
- if (_my_env == BIT7ENV)
- printf ("7b ");
- else
- printf ("8b ");
- printf ("csize = %d, prevcsize = %d, (%x,%x) ",csize, prevcsize, (pwc>>8)&0x00ff, pwc&0x00ff);
- switch (mode) {
- case G0MASK:
- printf ("G0"); break;
- case G1MASK:
- printf ("G1"); break;
- case G2MASK:
- printf ("G2"); break;
- case G3MASK:
- printf ("G3"); break;
- default:
- printf ("XXXX"); break;
- }
-#endif
-
- switch (_my_env) {
- case BIT7ENV: /* 7 bit environment */
- switch (mode) {
- case G0MASK:
- if (_currentOUT != G0 || prevcsize != csize) {
- _currentOUT = G0;
- if (csize == 2) {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x24;
- *bp++ = 0x28;
- *bp++ = FINAL;
- length += 4;
- }
- else {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x28;
- *bp++ = FINAL;
- length += 3;
- }
- *bp++ = SI;
- ++length;
- }
- if (csize == 1) {
- *bp++ = pwc & 0x007f;
- ++length;
- }
- else {
- *bp++ = (pwc & 0x7f00) >> 8;
- ++length;
- *bp++ = pwc & 0x007f;
- ++length;
- }
- break;
- case G1MASK:
- if (_currentOUT != G1 || prevcsize != csize) {
- _currentOUT = G1;
- if (csize == 2) {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x24;
- *bp++ = 0x29;
- *bp++ = FINAL;
- length += 4;
- }
- else {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x29;
- *bp++ = FINAL;
- length += 3;
- }
- *bp++ = SO;
- ++length;
- }
- if (csize == 1) {
- *bp++ = pwc & 0x007f;
- ++length;
- }
- else {
- *bp++ = (pwc & 0x7f00) >> 8;
- ++length;
- *bp++ = pwc & 0x007f;
- ++length;
- }
- break;
- case G2MASK:
- if (_currentOUT != G2 || prevcsize != csize) {
- _currentOUT = G2;
- if (csize == 2) {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x24;
- *bp++ = 0x2A;
- *bp++ = FINAL;
- length += 4;
- }
- else {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x2A;
- *bp++ = FINAL;
- length += 3;
- }
- *bp++ = ESC; *bp++ = LS2;
- length += 2;
- }
- if (csize == 1) {
- *bp++ = pwc & 0x007f;
- ++length;
- }
- else {
- *bp++ = (pwc & 0x7f00) >> 8;
- ++length;
- *bp++ = pwc & 0x007f;
- ++length;
- }
- break;
- case G3MASK:
- if (_currentOUT != G3 || prevcsize != csize) {
- _currentOUT = G3;
- if (csize == 2) {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x24;
- *bp++ = 0x2B;
- *bp++ = FINAL;
- length += 4;
- }
- else {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x2B;
- *bp++ = FINAL;
- length += 3;
- }
- *bp++ = ESC; *bp++ = LS3;
- length += 2;
- }
- if (csize == 1) {
- *bp++ = pwc & 0x007f;
- ++length;
- }
- else {
- *bp++ = (pwc & 0x7f00) >> 8;
- ++length;
- *bp++ = pwc & 0x007f;
- ++length;
- }
- break;
- }
- break;
- case BIT8ENV: /* 8 bit environment */
- switch (mode) {
- case G0MASK:
- if (_currentOUT != G0 || prevcsize != csize) {
- _currentOUT = G0;
- if (csize == 2) {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x24;
- *bp++ = 0x28;
- *bp++ = FINAL;
- length += 4;
- }
- else {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x28;
- *bp++ = FINAL;
- length += 3;
- }
- *bp++ = LS0;
- ++length;
- }
- if (csize == 1) {
- *bp++ = pwc & 0x007f;
- ++length;
- }
- else {
- *bp++ = (pwc & 0x7f00) >> 8;
- ++length;
- *bp++ = pwc & 0x007f;
- ++length;
- }
- break;
- case G1MASK:
- if (_currentOUT != G1 || prevcsize != csize) {
- _currentOUT = G1;
- if (csize == 2) {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x24;
- *bp++ = 0x29;
- *bp++ = FINAL;
- length += 4;
- }
- else {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x29;
- *bp++ = FINAL;
- length += 3;
- }
- *bp++ = ESC; *bp++ = LS1R;
- length += 2;
- }
-
- /*
- * If state is G1 or G2, or G3, assume that
- * this is 8bit characters. To do this more
- * accurately, wide character needs to be
- * larger than 16 bits to keep more information.
- */
- pwc |= 0x8080;
- if (csize == 1) {
- *bp++ = pwc & 0x00ff;
- ++length;
- }
- else {
- *bp++ = (pwc & 0xff00) >> 8;
- ++length;
- *bp++ = pwc & 0x00ff;
- ++length;
- }
- break;
- case G2MASK:
- if (_currentOUT != G2 || prevcsize != csize) {
- _currentOUT = G2;
- if (csize == 2) {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x24;
- *bp++ = 0x2A;
- *bp++ = FINAL;
- length += 4;
- }
- else {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x2A;
- *bp++ = FINAL;
- length += 3;
- }
- *bp++ = ESC; *bp++ = LS2R;
- length += 2;
- }
- /*
- * If state is G1 or G2, or G3, assume that
- * this is 8bit characters. To do this more
- * accurately, wide character needs to be
- * larger than 16 bits to keep more information.
- */
- pwc |= 0x8080;
- if (csize == 1) {
- *bp++ = pwc & 0x00ff;
- ++length;
- }
- else {
- *bp++ = (pwc & 0xff00) >> 8;
- ++length;
- *bp++ = pwc & 0x00ff;
- ++length;
- }
- break;
- case G3MASK:
- if (_currentOUT != G3 || prevcsize != csize) {
- _currentOUT = G3;
- if (csize == 2) {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x24;
- *bp++ = 0x2B;
- *bp++ = FINAL;
- length += 4;
- }
- else {
- /*
- * Emit escape sequences
- */
- *bp++ = ESC;
- *bp++ = 0x2B;
- *bp++ = FINAL;
- length += 3;
- }
- *bp++ = ESC; *bp++ = LS3R;
- length += 2;
- }
- /*
- * If state is G1 or G2, or G3, assume that
- * this is 8bit characters. To do this more
- * accurately, wide character needs to be
- * larger than 16 bits to keep more information.
- */
- pwc |= 0x8080;
- if (csize == 1) {
- *bp++ = pwc & 0x00ff;
- ++length;
- }
- else {
- *bp++ = (pwc & 0xff00) >> 8;
- ++length;
- *bp++ = pwc & 0x00ff;
- ++length;
- }
- break;
- }
- break;
- default: /* Should never happens */
- return (-1);
- break;
- }
-
- prevcsize = csize;
-
- if (length > n) {
- return (-1); /* buffer too small */
- }
- for (i = 0; i < length; i++) {
- *s++ = buf[i];
- }
-#ifdef DDDebug
- printf ("\t(");
- for (i = 0; i < length; i++) {
- printf ("%x,", buf[i]);
- }
- printf (")\n");
-#endif
- return (length);
-}
-
-/*
- * wcstombs
- */
-size_t
-_wcstombs_iso(char *s, wchar_t *pwcs, int n)
-{
- int acclen = 0;
- char buf[MMB_CUR_MAX];
- int ret1;
- int i;
-
- if (n < 0)
- return (-1);
- /*
- * Initialize State
- */
- _savestates(); _initializestates();
- while (acclen < n) {
- ret1 = _wctomb_iso ((unsigned char *)buf, *pwcs);
- /*
- * end of string ?
- */
- if (ret1 == 1 && buf[0] == 0) {
- *s = 0;
- /*
- * restore states
- */
- _restorestates();
- return (acclen);
- }
- /*
- * Error ?
- */
- if (ret1 < 0)
- return (-1);
- acclen += ret1;
- for (i = 0; i < ret1; i++)
- *s++ = buf[i];
- ++pwcs;
- }
-
- /*
- * restore states
- */
- _restorestates();
-
- /*
- * return the length
- */
- return (acclen);
-}
-
-
-/*
- * Supplementary routines
- */
-
-void
-_initializestates(void)
-{
- _currentG0 = G0;
- _currentG1 = G1;
-
- _des_states[G0].width = -1; /* This makes it Initialize */
-
- _currentOUT = G0;
- prevcsize = 1;
-}
-
-static char SAVED_currentG0;
-static char SAVED_currentG1;
-static struct state SAVED_des_states[NUM_OF_STATES];
-static struct state SAVED_Invoked_G0, SAVED_Invoked_G1;
-static char SAVED_currentOUT = G0; /* G0, G1, G2 or G3 */
-static int SAVED_prevcsize = 1;
-
-void
-_savestates(void)
-{
-
- SAVED_currentG0 = _currentG0;
- SAVED_currentG1 = _currentG1;
-
- SAVED_des_states[G0] = _des_states[G0];
- SAVED_des_states[G1] = _des_states[G1];
- SAVED_des_states[G2] = _des_states[G2];
- SAVED_des_states[G3] = _des_states[G3];
-
- SAVED_Invoked_G0 = Invoked_G0;
- SAVED_Invoked_G1 = Invoked_G1;
-
- SAVED_currentOUT = _currentOUT;
- SAVED_prevcsize = prevcsize;
-}
-
-void
-_restorestates(void)
-{
- _currentG0 = SAVED_currentG0;
- _currentG1 = SAVED_currentG1;
-
- _des_states[G0] = SAVED_des_states[G0];
- _des_states[G1] = SAVED_des_states[G1];
- _des_states[G2] = SAVED_des_states[G2];
- _des_states[G3] = SAVED_des_states[G3];
-
- Invoked_G0 = SAVED_Invoked_G0;
- Invoked_G1 = SAVED_Invoked_G1;
-
- _currentOUT = SAVED_currentOUT;
- prevcsize = SAVED_prevcsize;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/iso2022.h b/usr/src/lib/libbc/libc/gen/common/iso2022.h
deleted file mode 100644
index 5e7e63abe7..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/iso2022.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * ISO2022 generic escape sequence handler for graphical characters
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* static char *sccsid = "%Z%%M% %I% %E% SMI"; */
-
-/*
- * single control characters
- */
-#define SI 0x0F
-#define SO 0x0E
-
-#define ESC 0x1B
-
-#define LS0 0x0F
-#define LS1 0x0E
-#define LS1R 0x7E /* need ESC */
-#define LS2 0x6E /* need ESC */
-#define LS2R 0x7D /* need ESC */
-#define LS3 0x6F /* need ESC */
-#define LS3R 0x7C /* need ESC */
-#define SS2_7B 0x4E /* need ESC */
-#define SS2_8B 0x8E
-#define SS3_7B 0x4F /* need ESC */
-#define SS3_8B 0x8F
-
-#define C_C0 0
-#define C_C1 1
-
-#define G0 0
-#define G1 1
-#define G2 2
-#define G3 3
-
-#define CONT 0
-#define SING 1
-#define MULT 2
-/*
- * code info
- */
-typedef struct {
- char g0_len; /* 1 or 2 */
- char g1_len; /* 1 or 2 */
- char g2_len; /* 1 or 2 */
- char g3_len; /* 1 or 2 */
- char bit_env;/* 7 or 8 */
-
-} isowidth_t;
diff --git a/usr/src/lib/libbc/libc/gen/common/issecure.c b/usr/src/lib/libbc/libc/gen/common/issecure.c
deleted file mode 100644
index 9e27fb2dc5..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/issecure.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/file.h>
-
-#define PWDADJ "/etc/security/passwd.adjunct"
-
-/*
- * Is this a secure system ?
- */
-int
-issecure(void)
-{
- static int securestate = -1;
-
- if (securestate == -1)
- securestate = (access(PWDADJ, F_OK) == 0);
- return (securestate);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/jcsetpgrp.c b/usr/src/lib/libbc/libc/gen/common/jcsetpgrp.c
deleted file mode 100644
index 50c6eb8175..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/jcsetpgrp.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/syscall.h>
-
-/*
- * POSIX call to set job control process group of current process.
- * Use 4BSD "setpgrp" call, but don't call "setpgrp" since that may refer
- * to SVID "setpgrp" call in System V environment.
- */
-int
-jcsetpgrp(pgrp)
- int pgrp;
-{
- return (setpgid(0,pgrp));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/l64a.c b/usr/src/lib/libbc/libc/gen/common/l64a.c
deleted file mode 100644
index 5115b998ba..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/l64a.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.5 */
-
-/*LINTLIBRARY*/
-/*
- * convert long int to base 64 ascii
- * char set is [./0-9A-Za-z]
- * two's complement negatives are assumed,
- * but no assumptions are made about sign propagation on right shift
- *
- */
-
-#include <values.h>
-#define BITSPERCHAR 6 /* to hold entire character set */
-#define BITSPERLONG (BITSPERBYTE * sizeof(long))
-#define NMAX ((BITSPERLONG + BITSPERCHAR - 1)/BITSPERCHAR)
-#define SIGN (-(1L << (BITSPERLONG - BITSPERCHAR - 1)))
-#define CHARMASK ((1 << BITSPERCHAR) - 1)
-#define WORDMASK ((1L << ((NMAX - 1) * BITSPERCHAR)) - 1)
-
-static char buf[NMAX + 1];
-
-char *
-l64a(lg)
-register long lg;
-{
- register char *s = buf;
-
- while (lg != 0) {
-
- register int c = ((int)lg & CHARMASK) + ('0' - 2);
-
- if (c > '9')
- c += 'A' - '9' - 1;
- if (c > 'Z')
- c += 'a' - 'Z' - 1;
- *s++ = c;
- /* fill high-order CHAR if negative */
- /* but suppress sign propagation */
- lg = ((lg < 0) ? (lg >> BITSPERCHAR) | SIGN :
- lg >> BITSPERCHAR) & WORDMASK;
- }
- *s = '\0';
- return (buf);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/labeltostring.c b/usr/src/lib/libbc/libc/gen/common/labeltostring.c
deleted file mode 100644
index 76e996abe0..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/labeltostring.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/label.h>
-
-char *
-labeltostring(int part, blabel_t *value, int verbose)
-{
- char *string;
-
- string = (char *)malloc(sizeof(char));
- strcpy(string, "");
- return (string);
-}
-
-void
-labelfromstring(int part, char *label_string, blabel_t *value)
-{
- bzero(value, sizeof(value));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/ldexp.c b/usr/src/lib/libbc/libc/gen/common/ldexp.c
deleted file mode 100644
index d7d83183b1..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ldexp.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 2.7 */
-
-/*LINTLIBRARY*/
-/*
- * double ldexp (value, exp)
- * double value;
- * int exp;
- *
- * Ldexp returns value * 2**exp, if that result is in range.
- * If underflow occurs, it returns zero. If overflow occurs,
- * it returns a value of appropriate sign and largest single-
- * precision magnitude. In case of underflow or overflow,
- * the external int "errno" is set to ERANGE. Note that errno is
- * not modified if no error occurs, so if you intend to test it
- * after you use ldexp, you had better set it to something
- * other than ERANGE first (zero is a reasonable value to use).
- */
-
-#include <values.h>
-#include <errno.h>
-/* Largest signed long int power of 2 */
-#define MAXSHIFT (BITSPERBYTE * sizeof(long) - 2)
-
-extern double frexp();
-
-double
-ldexp(value, exp)
-register double value;
-register int exp;
-{
- int old_exp;
-
- if (exp == 0 || value == 0.0) /* nothing to do for zero */
- return (value);
-#if !(pdp11 || u3b5) /* pdp11 "cc" can't handle cast of
- double to void on pdp11 or 3b5 */
- (void)
-#endif
- frexp(value, &old_exp);
- if (exp > 0) {
- if (exp + old_exp > MAXBEXP) { /* overflow */
- errno = ERANGE;
- return ((double)(value < 0 ? MINDOUBLE : MAXDOUBLE));
-/*
- return ((double)(value < 0 ? -1.0e999 : 1.0e999));
-*/
- }
- for ( ; exp > MAXSHIFT; exp -= MAXSHIFT)
- value *= (1L << MAXSHIFT);
- return (value * (1L << exp));
- }
- if (exp + old_exp < MINBEXP) { /* underflow */
- errno = ERANGE;
- return (0.0);
- }
- for ( ; exp < -MAXSHIFT; exp += MAXSHIFT)
- value *= 1.0/(1L << MAXSHIFT); /* mult faster than div */
- return (value / (1L << -exp));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/lfind.c b/usr/src/lib/libbc/libc/gen/common/lfind.c
deleted file mode 100644
index 63aa525cf7..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/lfind.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.1 */
-
-/*LINTLIBRARY*/
-/*
- * Linear search algorithm, generalized from Knuth (6.1) Algorithm Q.
- *
- * This version no longer has anything to do with Knuth's Algorithm Q,
- * which first copies the new element into the table, then looks for it.
- * The assumption there was that the cost of checking for the end of the
- * table before each comparison outweighed the cost of the comparison, which
- * isn't true when an arbitrary comparison function must be called and when the
- * copy itself takes a significant number of cycles.
- * Actually, it has now reverted to Algorithm S, which is "simpler."
- */
-
-typedef char *POINTER;
-extern POINTER memcpy();
-
-POINTER
-lfind(key, base, nelp, width, compar)
-register POINTER key; /* Key to be located */
-register POINTER base; /* Beginning of table */
-unsigned *nelp; /* Pointer to current table size */
-register unsigned width; /* Width of an element (bytes) */
-int (*compar)(); /* Comparison function */
-{
- register POINTER next = base + *nelp * width; /* End of table */
-
- for ( ; base < next; base += width)
- if ((*compar)(key, base) == 0)
- return (base); /* Key found */
- return (POINTER)0;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/localtime.c b/usr/src/lib/libbc/libc/gen/common/localtime.c
deleted file mode 100644
index ba4278f37e..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/localtime.c
+++ /dev/null
@@ -1,1421 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from Arthur Olson's 6.1 */
-
-/*LINTLIBRARY*/
-
-#include <tzfile.h>
-#include <time.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdio.h> /* for NULL */
-#include <fcntl.h>
-
-#include <sys/param.h> /* for MAXPATHLEN */
-
-#undef FILENAME_MAX
-#define FILENAME_MAX MAXPATHLEN
-
-#ifdef __STDC__
-
-#define P(s) s
-
-#else /* !defined __STDC__ */
-
-/*
-** Memory management functions
-*/
-
-extern char * calloc();
-extern char * malloc();
-
-/*
-** Communication with the environment
-*/
-
-extern char * getenv();
-
-#define ASTERISK *
-#define P(s) (/ASTERISK s ASTERISK/)
-
-#define const
-
-#endif /* !defined __STDC__ */
-
-#ifndef TRUE
-#define TRUE 1
-#define FALSE 0
-#endif /* !defined TRUE */
-
-#define ACCESS_MODE O_RDONLY
-
-#define OPEN_MODE O_RDONLY
-
-/*
-** Someone might make incorrect use of a time zone abbreviation:
-** 1. They might reference tzname[0] before calling tzset (explicitly
-** or implicitly).
-** 2. They might reference tzname[1] before calling tzset (explicitly
-** or implicitly).
-** 3. They might reference tzname[1] after setting to a time zone
-** in which Daylight Saving Time is never observed.
-** 4. They might reference tzname[0] after setting to a time zone
-** in which Standard Time is never observed.
-** 5. They might reference tm.TM_ZONE after calling offtime.
-** What's best to do in the above cases is open to debate;
-** for now, we just set things up so that in any of the five cases
-** WILDABBR is used. Another possibility: initialize tzname[0] to the
-** string "tzname[0] used before set", and similarly for the other cases.
-** And another: initialize tzname[0] to "ERA", with an explanation in the
-** manual page of what this "time zone abbreviation" means (doing this so
-** that tzname[0] has the "normal" length of three characters).
-*/
-static const char *WILDABBR = " ";
-
-static const char *GMT = "GMT";
-
-struct ttinfo { /* time type information */
- long tt_gmtoff; /* GMT offset in seconds */
- int tt_isdst; /* used to set tm_isdst */
- int tt_abbrind; /* abbreviation list index */
- int tt_ttisstd; /* TRUE if transition is std time */
-};
-
-struct state {
- int timecnt;
- int typecnt;
- int charcnt;
- time_t *ats;
- unsigned char *types;
- struct ttinfo *ttis;
- char *chars;
- char *last_tzload; /* name of file tzload() last opened */
-};
-
-struct rule {
- int r_type; /* type of rule--see below */
- int r_day; /* day number of rule */
- int r_week; /* week number of rule */
- int r_mon; /* month number of rule */
- long r_time; /* transition time of rule */
-};
-
-#define JULIAN_DAY 0 /* Jn - Julian day */
-#define DAY_OF_YEAR 1 /* n - day of year */
-#define MONTH_NTH_DAY_OF_WEEK 2 /* Mm.n.d - month, week, day of week */
-
-/*
-** Prototypes for static functions.
-*/
-
-static int allocall P((register struct state * sp));
-static long detzcode P((const char * codep));
-static void freeall P((register struct state * sp));
-static const char * getzname P((const char * strp, const int i));
-static const char * getnum P((const char * strp, int * nump, int min,
- int max));
-static const char * getsecs P((const char * strp, long * secsp));
-static const char * getoffset P((const char * strp, long * offsetp));
-static const char * getrule P((const char * strp, struct rule * rulep));
-static void gmtload P((struct state * sp));
-static void gmtsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static void localsub P((const time_t * timep, long offset,
- struct tm * tmp));
-static void normalize P((int * tensptr, int * unitsptr, int base));
-static void settzname P((void));
-static time_t time1 P((struct tm * tmp, void (* funcp)(),
- long offset));
-static time_t time2 P((struct tm *tmp, void (* funcp)(),
- long offset, int * okayp));
-static void timesub P((const time_t * timep, long offset,
- struct tm * tmp));
-static int tmcomp P((const struct tm * atmp,
- const struct tm * btmp));
-static time_t transtime P((time_t janfirst, int year,
- const struct rule * rulep, long offset));
-static int tzload P((const char * name, struct state * sp));
-static int tzparse P((const char * name, struct state * sp,
- int lastditch));
-
-static struct state * lclptr;
-static struct state * gmtptr;
-
-static int lcl_is_set;
-static int gmt_is_set;
-
-#ifdef S5EMUL
-char * tzname[2] = {
- "GMT",
- " ",
-};
-
-time_t timezone = 0;
-time_t altzone = 0;
-int daylight = 0;
-#endif /* defined S5EMUL */
-
-static long
-detzcode(codep)
-const char * const codep;
-{
- register long result;
- register int i;
-
- result = 0;
- for (i = 0; i < 4; ++i)
- result = (result << 8) | (codep[i] & 0xff);
- return result;
-}
-
-/*
-** Free up existing items pointed to by the specified "state" structure,
-** and allocate new ones of sizes specified by that "state" structure.
-** Return 0 on success; return -1 and free all previously-allocated items
-** on failure.
-*/
-static int
-allocall(sp)
-register struct state * const sp;
-{
- freeall(sp);
-
- if (sp->timecnt != 0) {
- sp->ats = (time_t *)calloc((unsigned)sp->timecnt,
- (unsigned)sizeof (time_t));
- if (sp->ats == NULL)
- return -1;
- sp->types =
- (unsigned char *)calloc((unsigned)sp->timecnt,
- (unsigned)sizeof (unsigned char));
- if (sp->types == NULL) {
- freeall(sp);
- return -1;
- }
- }
- sp->ttis =
- (struct ttinfo *)calloc((unsigned)sp->typecnt,
- (unsigned)sizeof (struct ttinfo));
- if (sp->ttis == NULL) {
- freeall(sp);
- return -1;
- }
- sp->chars = (char *)calloc((unsigned)sp->charcnt + 1,
- (unsigned)sizeof (char));
- if (sp->chars == NULL) {
- freeall(sp);
- return -1;
- }
- return 0;
-}
-
-/*
-** Free all the items pointed to by the specified "state" structure (except for
-** "chars", which might have other references to it), and zero out all the
-** pointers to those items.
-*/
-static void
-freeall(sp)
-register struct state * const sp;
-{
- if (sp->ttis) {
- free((char *)sp->ttis);
- sp->ttis = 0;
- }
- if (sp->types) {
- free((char *)sp->types);
- sp->types = 0;
- }
- if (sp->ats) {
- free((char *)sp->ats);
- sp->ats = 0;
- }
-}
-
-#ifdef S5EMUL
-static void
-settzname()
-{
- register const struct state * const sp = lclptr;
- register int i;
-
- tzname[0] = (char *)GMT;
- tzname[1] = (char *)WILDABBR;
- daylight = 0;
- timezone = 0;
- altzone = 0;
- if (sp == NULL)
- return;
- for (i = 0; i < sp->typecnt; ++i) {
- register const struct ttinfo * const ttisp = &sp->ttis[i];
-
- tzname[ttisp->tt_isdst] =
- (char *) &sp->chars[ttisp->tt_abbrind];
- if (ttisp->tt_isdst)
- daylight = 1;
- if (i == 0 || !ttisp->tt_isdst)
- timezone = -(ttisp->tt_gmtoff);
- if (i == 0 || ttisp->tt_isdst)
- altzone = -(ttisp->tt_gmtoff);
- }
- /*
- ** And to get the latest zone names into tzname. . .
- */
- for (i = 0; i < sp->timecnt; ++i) {
- register const struct ttinfo * const ttisp =
- &sp->ttis[sp->types[i]];
-
- tzname[ttisp->tt_isdst] =
- (char *) &sp->chars[ttisp->tt_abbrind];
- }
-}
-#endif
-
-/*
-** Maximum size of a time zone file.
-*/
-#define MAX_TZFILESZ (sizeof (struct tzhead) + \
- TZ_MAX_TIMES * (4 + sizeof (char)) + \
- TZ_MAX_TYPES * (4 + 2 * sizeof (char)) + \
- TZ_MAX_CHARS * sizeof (char) + \
- TZ_MAX_LEAPS * 2 * 4 + \
- TZ_MAX_TYPES * sizeof (char))
-
-static int
-tzload(name, sp)
-register const char * name;
-register struct state * const sp;
-{
- register const char * p;
- register int i;
- register int fid;
-
- if (name == NULL && (name = (const char *)TZDEFAULT) == NULL)
- return -1;
- {
- register int doaccess;
- char fullname[FILENAME_MAX + 1];
-
- if (name[0] == ':')
- ++name;
- doaccess = name[0] == '/';
- if (!doaccess) {
- if ((p = TZDIR) == NULL)
- return -1;
- if ((strlen(p) + strlen(name) + 1) >= sizeof fullname)
- return -1;
- (void) strcpy(fullname, p);
- (void) strcat(fullname, "/");
- (void) strcat(fullname, name);
- /*
- ** Set doaccess if '.' (as in "../") shows up in name.
- */
- if (strchr(name, '.') != NULL)
- doaccess = TRUE;
- name = fullname;
- }
- if (sp->last_tzload && strcmp(sp->last_tzload, name) == 0)
- return (0);
- if (doaccess && access(name, ACCESS_MODE) != 0)
- return -1;
- if ((fid = open(name, OPEN_MODE)) == -1)
- return -1;
- }
- {
- register const struct tzhead * tzhp;
- char buf[MAX_TZFILESZ];
- int leapcnt;
- int ttisstdcnt;
-
- i = read(fid, buf, sizeof buf);
- if (close(fid) != 0 || i < sizeof *tzhp)
- return -1;
- tzhp = (struct tzhead *) buf;
- ttisstdcnt = (int) detzcode(tzhp->tzh_ttisstdcnt);
- leapcnt = (int) detzcode(tzhp->tzh_leapcnt);
- sp->timecnt = (int) detzcode(tzhp->tzh_timecnt);
- sp->typecnt = (int) detzcode(tzhp->tzh_typecnt);
- sp->charcnt = (int) detzcode(tzhp->tzh_charcnt);
- if (leapcnt < 0 || leapcnt > TZ_MAX_LEAPS ||
- sp->typecnt <= 0 || sp->typecnt > TZ_MAX_TYPES ||
- sp->timecnt < 0 || sp->timecnt > TZ_MAX_TIMES ||
- sp->charcnt < 0 || sp->charcnt > TZ_MAX_CHARS ||
- (ttisstdcnt != sp->typecnt && ttisstdcnt != 0))
- return -1;
- if (i < sizeof *tzhp +
- sp->timecnt * (4 + sizeof (char)) +
- sp->typecnt * (4 + 2 * sizeof (char)) +
- sp->charcnt * sizeof (char) +
- leapcnt * 2 * 4 +
- ttisstdcnt * sizeof (char))
- return -1;
- if (allocall(sp) < 0)
- return -1;
- p = buf + sizeof *tzhp;
- for (i = 0; i < sp->timecnt; ++i) {
- sp->ats[i] = detzcode(p);
- p += 4;
- }
- for (i = 0; i < sp->timecnt; ++i) {
- sp->types[i] = (unsigned char) *p++;
- if (sp->types[i] >= sp->typecnt)
- return -1;
- }
- for (i = 0; i < sp->typecnt; ++i) {
- register struct ttinfo * ttisp;
-
- ttisp = &sp->ttis[i];
- ttisp->tt_gmtoff = detzcode(p);
- p += 4;
- ttisp->tt_isdst = (unsigned char) *p++;
- if (ttisp->tt_isdst != 0 && ttisp->tt_isdst != 1)
- return -1;
- ttisp->tt_abbrind = (unsigned char) *p++;
- if (ttisp->tt_abbrind < 0 ||
- ttisp->tt_abbrind > sp->charcnt)
- return -1;
- }
- for (i = 0; i < sp->charcnt-1; ++i)
- sp->chars[i] = *p++;
- sp->chars[i] = '\0'; /* ensure '\0' at end */
- p += (4 + 4) * leapcnt; /* skip leap seconds list */
- for (i = 0; i < sp->typecnt; ++i) {
- register struct ttinfo * ttisp;
-
- ttisp = &sp->ttis[i];
- if (ttisstdcnt == 0)
- ttisp->tt_ttisstd = FALSE;
- else {
- ttisp->tt_ttisstd = *p++;
- if (ttisp->tt_ttisstd != TRUE &&
- ttisp->tt_ttisstd != FALSE)
- return -1;
- }
- }
- }
- if (sp->last_tzload)
- free(sp->last_tzload);
- sp->last_tzload = strdup(name);
- return 0;
-}
-
-static const int mon_lengths[2][MONSPERYEAR] = {
- 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31,
- 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
-
-static const int year_lengths[2] = {
- DAYSPERNYEAR, DAYSPERLYEAR
-};
-
-/*
-** Given a pointer into a time zone string, scan until a character that is not
-** a valid character in a zone name is found. Return a pointer to that
-** character.
-** Support both quoted and unquoted timezones.
-*/
-
-static const char *
-getzname(strp, quoted)
-const char * strp;
-int quoted;
-{
- unsigned char c;
-
- if (quoted) {
- while ((c = (unsigned char)*strp) != '\0' &&
- (isalnum(c) || (c == '+') || (c == '-')))
- ++strp;
- } else {
- while ((c = (unsigned char)*strp) != '\0' && !isdigit(c)
- && (c != ',') && (c != '-') && (c != '+'))
- ++strp;
- }
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract a number from that string.
-** Check that the number is within a specified range; if it is not, return
-** NULL.
-** Otherwise, return a pointer to the first character not part of the number.
-*/
-
-static const char *
-getnum(strp, nump, min, max)
-register const char * strp;
-int * const nump;
-const int min;
-const int max;
-{
- register char c;
- register int num;
-
- if (strp == NULL || !isdigit(*strp))
- return NULL;
- num = 0;
- while ((c = *strp) != '\0' && isdigit(c)) {
- num = num * 10 + (c - '0');
- if (num > max)
- return NULL; /* illegal value */
- ++strp;
- }
- if (num < min)
- return NULL; /* illegal value */
- *nump = num;
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract a number of seconds,
-** in hh[:mm[:ss]] form, from the string.
-** If any error occurs, return NULL.
-** Otherwise, return a pointer to the first character not part of the number
-** of seconds.
-*/
-
-static const char *
-getsecs(strp, secsp)
-register const char * strp;
-long * const secsp;
-{
- int num;
-
- strp = getnum(strp, &num, 0, HOURSPERDAY);
- if (strp == NULL)
- return NULL;
- *secsp = num * SECSPERHOUR;
- if (*strp == ':') {
- ++strp;
- strp = getnum(strp, &num, 0, MINSPERHOUR - 1);
- if (strp == NULL)
- return NULL;
- *secsp += num * SECSPERMIN;
- if (*strp == ':') {
- ++strp;
- strp = getnum(strp, &num, 0, SECSPERMIN - 1);
- if (strp == NULL)
- return NULL;
- *secsp += num;
- }
- }
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract an offset, in
-** [+-]hh[:mm[:ss]] form, from the string.
-** If any error occurs, return NULL.
-** Otherwise, return a pointer to the first character not part of the time.
-*/
-
-static const char *
-getoffset(strp, offsetp)
-register const char * strp;
-long * const offsetp;
-{
- register int neg;
-
- if (*strp == '-') {
- neg = 1;
- ++strp;
- } else if (isdigit(*strp) || *strp++ == '+')
- neg = 0;
- else return NULL; /* illegal offset */
- strp = getsecs(strp, offsetp);
- if (strp == NULL)
- return NULL; /* illegal time */
- if (neg)
- *offsetp = -*offsetp;
- return strp;
-}
-
-/*
-** Given a pointer into a time zone string, extract a rule in the form
-** date[/time]. See POSIX section 8 for the format of "date" and "time".
-** If a valid rule is not found, return NULL.
-** Otherwise, return a pointer to the first character not part of the rule.
-*/
-
-static const char *
-getrule(strp, rulep)
-const char * strp;
-register struct rule * const rulep;
-{
- if (*strp == 'J') {
- /*
- ** Julian day.
- */
- rulep->r_type = JULIAN_DAY;
- ++strp;
- strp = getnum(strp, &rulep->r_day, 1, DAYSPERNYEAR);
- } else if (*strp == 'M') {
- /*
- ** Month, week, day.
- */
- rulep->r_type = MONTH_NTH_DAY_OF_WEEK;
- ++strp;
- strp = getnum(strp, &rulep->r_mon, 1, MONSPERYEAR);
- if (strp == NULL)
- return NULL;
- if (*strp++ != '.')
- return NULL;
- strp = getnum(strp, &rulep->r_week, 1, 5);
- if (strp == NULL)
- return NULL;
- if (*strp++ != '.')
- return NULL;
- strp = getnum(strp, &rulep->r_day, 0, DAYSPERWEEK - 1);
- } else if (isdigit(*strp)) {
- /*
- ** Day of year.
- */
- rulep->r_type = DAY_OF_YEAR;
- strp = getnum(strp, &rulep->r_day, 0, DAYSPERLYEAR - 1);
- } else return NULL; /* invalid format */
- if (strp == NULL)
- return NULL;
- if (*strp == '/') {
- /*
- ** Time specified.
- */
- ++strp;
- strp = getsecs(strp, &rulep->r_time);
- } else rulep->r_time = 2 * SECSPERHOUR; /* default = 2:00:00 */
- return strp;
-}
-
-/*
-** Given the Epoch-relative time of January 1, 00:00:00 GMT, in a year, the
-** year, a rule, and the offset from GMT at the time that rule takes effect,
-** calculate the Epoch-relative time that rule takes effect.
-*/
-
-static time_t
-transtime(janfirst, year, rulep, offset)
-const time_t janfirst;
-const int year;
-register const struct rule * const rulep;
-const long offset;
-{
- register int leapyear;
- register time_t value;
- register int i;
- int d, m1, yy0, yy1, yy2, dow;
-
- leapyear = isleap(year);
- switch (rulep->r_type) {
-
- case JULIAN_DAY:
- /*
- ** Jn - Julian day, 1 == January 1, 60 == March 1 even in leap
- ** years.
- ** In non-leap years, or if the day number is 59 or less, just
- ** add SECSPERDAY times the day number-1 to the time of
- ** January 1, midnight, to get the day.
- */
- value = janfirst + (rulep->r_day - 1) * SECSPERDAY;
- if (leapyear && rulep->r_day >= 60)
- value += SECSPERDAY;
- break;
-
- case DAY_OF_YEAR:
- /*
- ** n - day of year.
- ** Just add SECSPERDAY times the day number to the time of
- ** January 1, midnight, to get the day.
- */
- value = janfirst + rulep->r_day * SECSPERDAY;
- break;
-
- case MONTH_NTH_DAY_OF_WEEK:
- /*
- ** Mm.n.d - nth "dth day" of month m.
- */
- value = janfirst;
- for (i = 0; i < rulep->r_mon - 1; ++i)
- value += mon_lengths[leapyear][i] * SECSPERDAY;
-
- /*
- ** Use Zeller's Congruence to get day-of-week of first day of
- ** month.
- */
- m1 = (rulep->r_mon + 9) % 12 + 1;
- yy0 = (rulep->r_mon <= 2) ? (year - 1) : year;
- yy1 = yy0 / 100;
- yy2 = yy0 % 100;
- dow = ((26 * m1 - 2) / 10 +
- 1 + yy2 + yy2 / 4 + yy1 / 4 - 2 * yy1) % 7;
- if (dow < 0)
- dow += DAYSPERWEEK;
-
- /*
- ** "dow" is the day-of-week of the first day of the month. Get
- ** the day-of-month (zero-origin) of the first "dow" day of the
- ** month.
- */
- d = rulep->r_day - dow;
- if (d < 0)
- d += DAYSPERWEEK;
- for (i = 1; i < rulep->r_week; ++i) {
- if (d + DAYSPERWEEK >=
- mon_lengths[leapyear][rulep->r_mon - 1])
- break;
- d += DAYSPERWEEK;
- }
-
- /*
- ** "d" is the day-of-month (zero-origin) of the day we want.
- */
- value += d * SECSPERDAY;
- break;
- }
-
- /*
- ** "value" is the Epoch-relative time of 00:00:00 GMT on the day in
- ** question. To get the Epoch-relative time of the specified local
- ** time on that day, add the transition time and the current offset
- ** from GMT.
- */
- return value + rulep->r_time + offset;
-}
-
-/*
-** Given a POSIX section 8-style TZ string, fill in the rule tables as
-** appropriate.
-*/
-
-static int
-tzparse(name, sp, lastditch)
-const char * name;
-struct state * const sp;
-const int lastditch;
-{
- const char * stdname;
- const char * dstname;
- int stdlen;
- int dstlen;
- long stdoffset;
- long dstoffset;
- time_t * atp;
- unsigned char * typep;
- char * cp;
-
- freeall(sp); /* */
- stdname = name;
- if (lastditch) {
- stdlen = strlen(name); /* length of standard zone name */
- name += stdlen;
- if (stdlen >= sizeof sp->chars)
- stdlen = (sizeof sp->chars) - 1;
- } else {
- if (*name == '<') {
- name++;
- stdname++;
- name = getzname(name, 1);
- if (*name != '>') {
- return (-1);
- }
- stdlen = name - stdname;
- name++;
- } else {
- name = getzname(name, 0);
- stdlen = name - stdname;
- }
- if (stdlen < 3)
- return -1;
- }
- if (*name == '\0')
- stdoffset = 0;
- else {
- name = getoffset(name, &stdoffset);
- if (name == NULL)
- return -1;
- }
- if (*name != '\0') {
- dstname = name;
- if (*name == '<') {
- name++;
- dstname++;
- name = getzname(name, 1);
- if (*name != '>') {
- return (-1);
- }
- dstlen = name - dstname;
- name++;
- } else {
- name = getzname(name, 0);
- dstlen = name - dstname;
- }
- if (dstlen < 3)
- return -1;
- if (*name != '\0' && *name != ',' && *name != ';') {
- name = getoffset(name, &dstoffset);
- if (name == NULL)
- return -1;
- } else dstoffset = stdoffset - SECSPERHOUR;
- if (*name == ',' || *name == ';') {
- struct rule start;
- struct rule end;
- register int year;
- register time_t janfirst;
- time_t starttime;
- time_t endtime;
-
- ++name;
- if ((name = getrule(name, &start)) == NULL)
- return -1;
- if (*name++ != ',')
- return -1;
- if ((name = getrule(name, &end)) == NULL)
- return -1;
- if (*name != '\0')
- return -1;
- sp->typecnt = 2; /* standard time and DST */
- /*
- ** Two transitions per year, from EPOCH_YEAR to 2037.
- */
- sp->timecnt = 2 * (2037 - EPOCH_YEAR + 1);
- if (sp->timecnt > TZ_MAX_TIMES)
- return -1;
- sp->charcnt = stdlen + 1 + dstlen + 1;
- if (allocall(sp) < 0)
- return -1;
- sp->ttis[0].tt_gmtoff = -dstoffset;
- sp->ttis[0].tt_isdst = 1;
- sp->ttis[0].tt_abbrind = stdlen + 1;
- sp->ttis[1].tt_gmtoff = -stdoffset;
- sp->ttis[1].tt_isdst = 0;
- sp->ttis[1].tt_abbrind = 0;
- atp = sp->ats;
- typep = sp->types;
- janfirst = 0;
- for (year = EPOCH_YEAR; year <= 2037; ++year) {
- starttime = transtime(janfirst, year, &start,
- stdoffset);
- endtime = transtime(janfirst, year, &end,
- dstoffset);
- if (starttime > endtime) {
- *atp++ = endtime;
- *typep++ = 1; /* DST ends */
- *atp++ = starttime;
- *typep++ = 0; /* DST begins */
- } else {
- *atp++ = starttime;
- *typep++ = 0; /* DST begins */
- *atp++ = endtime;
- *typep++ = 1; /* DST ends */
- }
- janfirst +=
- year_lengths[isleap(year)] * SECSPERDAY;
- }
- } else {
- int sawstd;
- int sawdst;
- long stdfix;
- long dstfix;
- long oldfix;
- int isdst;
- register int i;
-
- if (*name != '\0')
- return -1;
- if (tzload(TZDEFRULES, sp) != 0) {
- freeall(sp);
- return -1;
- }
- /*
- ** Discard zone abbreviations from file, and allocate
- ** space for the ones from TZ.
- */
- free(sp->chars);
- sp->charcnt = stdlen + 1 + dstlen + 1;
- sp->chars = (char *)calloc((unsigned)sp->charcnt,
- (unsigned)sizeof (char));
- /*
- ** Compute the difference between the real and
- ** prototype standard and summer time offsets
- ** from GMT, and put the real standard and summer
- ** time offsets into the rules in place of the
- ** prototype offsets.
- */
- sawstd = FALSE;
- sawdst = FALSE;
- stdfix = 0;
- dstfix = 0;
- for (i = 0; i < sp->typecnt; ++i) {
- if (sp->ttis[i].tt_isdst) {
- oldfix = dstfix;
- dstfix =
- sp->ttis[i].tt_gmtoff + dstoffset;
- if (sawdst && (oldfix != dstfix))
- return -1;
- sp->ttis[i].tt_gmtoff = -dstoffset;
- sp->ttis[i].tt_abbrind = stdlen + 1;
- sawdst = TRUE;
- } else {
- oldfix = stdfix;
- stdfix =
- sp->ttis[i].tt_gmtoff + stdoffset;
- if (sawstd && (oldfix != stdfix))
- return -1;
- sp->ttis[i].tt_gmtoff = -stdoffset;
- sp->ttis[i].tt_abbrind = 0;
- sawstd = TRUE;
- }
- }
- /*
- ** Make sure we have both standard and summer time.
- */
- if (!sawdst || !sawstd)
- return -1;
- /*
- ** Now correct the transition times by shifting
- ** them by the difference between the real and
- ** prototype offsets. Note that this difference
- ** can be different in standard and summer time;
- ** the prototype probably has a 1-hour difference
- ** between standard and summer time, but a different
- ** difference can be specified in TZ.
- */
- isdst = FALSE; /* we start in standard time */
- for (i = 0; i < sp->timecnt; ++i) {
- register const struct ttinfo * ttisp;
-
- /*
- ** If summer time is in effect, and the
- ** transition time was not specified as
- ** standard time, add the summer time
- ** offset to the transition time;
- ** otherwise, add the standard time offset
- ** to the transition time.
- */
- ttisp = &sp->ttis[sp->types[i]];
- sp->ats[i] +=
- (isdst && !ttisp->tt_ttisstd) ?
- dstfix : stdfix;
- isdst = ttisp->tt_isdst;
- }
- }
- } else {
- dstlen = 0;
- sp->typecnt = 1; /* only standard time */
- sp->timecnt = 0;
- sp->charcnt = stdlen + 1;
- if (allocall(sp) < 0)
- return -1;
- sp->ttis[0].tt_gmtoff = -stdoffset;
- sp->ttis[0].tt_isdst = 0;
- sp->ttis[0].tt_abbrind = 0;
- }
- cp = sp->chars;
- (void) strncpy(cp, stdname, stdlen);
- cp += stdlen;
- *cp++ = '\0';
- if (dstlen != 0) {
- (void) strncpy(cp, dstname, dstlen);
- *(cp + dstlen) = '\0';
- }
- return 0;
-}
-
-static void
-gmtload(sp)
-struct state * const sp;
-{
- if (tzload(GMT, sp) != 0)
- (void) tzparse(GMT, sp, TRUE);
-}
-
-void
-tzsetwall()
-{
- lcl_is_set = TRUE;
- if (lclptr == NULL) {
- lclptr = (struct state *) calloc(1, (unsigned)sizeof *lclptr);
- if (lclptr == NULL) {
-#ifdef S5EMUL
- settzname(); /* all we can do */
-#endif
- return;
- }
- }
- if (tzload((char *) NULL, lclptr) != 0)
- gmtload(lclptr);
-#ifdef S5EMUL
- settzname();
-#endif
-}
-
-void
-tzset()
-{
- register const char * name;
-
- name = (const char *)getenv("TZ");
- if (name == NULL) {
- tzsetwall();
- return;
- }
- lcl_is_set = TRUE;
- if (lclptr == NULL) {
- lclptr = (struct state *) calloc(1, (unsigned)sizeof *lclptr);
- if (lclptr == NULL) {
-#ifdef S5EMUL
- settzname(); /* all we can do */
-#endif
- return;
- }
- }
- if (*name == '\0') {
- /*
- ** User wants it fast rather than right.
- */
- lclptr->timecnt = 0;
- lclptr->typecnt = 1;
- lclptr->charcnt = sizeof GMT;
- if (allocall(lclptr) < 0)
- return;
- lclptr->ttis[0].tt_gmtoff = 0;
- lclptr->ttis[0].tt_abbrind = 0;
- (void) strcpy(lclptr->chars, GMT);
- } else if (tzload(name, lclptr) != 0)
- if (name[0] == ':' || tzparse(name, lclptr, FALSE) != 0)
- (void) tzparse(name, lclptr, TRUE);
-#ifdef S5EMUL
- settzname();
-#endif
-}
-
-/*
-** The easy way to behave "as if no library function calls" localtime
-** is to not call it--so we drop its guts into "localsub", which can be
-** freely called. (And no, the PANS doesn't require the above behavior--
-** but it *is* desirable.)
-**
-** The unused offset argument is for the benefit of mktime variants.
-*/
-
-static struct tm tm;
-
-/*ARGSUSED*/
-static void
-localsub(timep, offset, tmp)
-const time_t * const timep;
-const long offset;
-struct tm * const tmp;
-{
- register const struct state * sp;
- register const struct ttinfo * ttisp;
- register int i;
- const time_t t = *timep;
-
- if (!lcl_is_set)
- tzset();
- sp = lclptr;
- if (sp == NULL) {
- gmtsub(timep, offset, tmp);
- return;
- }
- if (sp->timecnt == 0 || t < sp->ats[0]) {
- i = 0;
- while (sp->ttis[i].tt_isdst)
- if (++i >= sp->typecnt) {
- i = 0;
- break;
- }
- } else {
- for (i = 1; i < sp->timecnt; ++i)
- if (t < sp->ats[i])
- break;
- i = sp->types[i - 1];
- }
- ttisp = &sp->ttis[i];
- timesub(&t, ttisp->tt_gmtoff, tmp);
- tmp->tm_isdst = ttisp->tt_isdst;
-#ifdef S5EMUL
- tzname[tmp->tm_isdst] = (char *) &sp->chars[ttisp->tt_abbrind];
-#endif /* S5EMUL */
- tmp->tm_zone = &sp->chars[ttisp->tt_abbrind];
-}
-
-struct tm *
-localtime(timep)
-const time_t * const timep;
-{
- time_t temp_time = *(const time_t*)timep;
-
- _ltzset(&temp_time); /*
- * base localtime calls this to initialize
- * some things, so we'll do it here, too.
- */
- localsub(timep, 0L, &tm);
- return &tm;
-}
-
-/*
-** gmtsub is to gmtime as localsub is to localtime.
-*/
-
-static void
-gmtsub(timep, offset, tmp)
-const time_t * const timep;
-const long offset;
-struct tm * const tmp;
-{
- if (!gmt_is_set) {
- gmt_is_set = TRUE;
- gmtptr = (struct state *) calloc(1, (unsigned)sizeof *gmtptr);
- if (gmtptr != NULL)
- gmtload(gmtptr);
- }
- timesub(timep, offset, tmp);
- /*
- ** Could get fancy here and deliver something such as
- ** "GMT+xxxx" or "GMT-xxxx" if offset is non-zero,
- ** but this is no time for a treasure hunt.
- */
- if (offset != 0)
- tmp->tm_zone = (char *)WILDABBR;
- else {
- if (gmtptr == NULL)
- tmp->tm_zone = (char *)GMT;
- else tmp->tm_zone = gmtptr->chars;
- }
-}
-
-struct tm *
-gmtime(timep)
-const time_t * const timep;
-{
- gmtsub(timep, 0L, &tm);
- return &tm;
-}
-
-struct tm *
-offtime(timep, offset)
-const time_t * const timep;
-const long offset;
-{
- gmtsub(timep, offset, &tm);
- return &tm;
-}
-
-static void
-timesub(timep, offset, tmp)
-const time_t * const timep;
-const long offset;
-register struct tm * const tmp;
-{
- register long days;
- register long rem;
- register int y;
- register int yleap;
- register const int * ip;
-
- days = *timep / SECSPERDAY;
- rem = *timep % SECSPERDAY;
- rem += offset;
- while (rem < 0) {
- rem += SECSPERDAY;
- --days;
- }
- while (rem >= SECSPERDAY) {
- rem -= SECSPERDAY;
- ++days;
- }
- tmp->tm_hour = (int) (rem / SECSPERHOUR);
- rem = rem % SECSPERHOUR;
- tmp->tm_min = (int) (rem / SECSPERMIN);
- tmp->tm_sec = (int) (rem % SECSPERMIN);
- tmp->tm_wday = (int) ((EPOCH_WDAY + days) % DAYSPERWEEK);
- if (tmp->tm_wday < 0)
- tmp->tm_wday += DAYSPERWEEK;
- y = EPOCH_YEAR;
- if (days >= 0)
- for ( ; ; ) {
- yleap = isleap(y);
- if (days < (long) year_lengths[yleap])
- break;
- ++y;
- days = days - (long) year_lengths[yleap];
- }
- else do {
- --y;
- yleap = isleap(y);
- days = days + (long) year_lengths[yleap];
- } while (days < 0);
- tmp->tm_year = y - TM_YEAR_BASE;
- tmp->tm_yday = (int) days;
- ip = mon_lengths[yleap];
- for (tmp->tm_mon = 0; days >= (long) ip[tmp->tm_mon]; ++(tmp->tm_mon))
- days = days - (long) ip[tmp->tm_mon];
- tmp->tm_mday = (int) (days + 1);
- tmp->tm_isdst = 0;
- tmp->tm_gmtoff = offset;
-}
-
-/*
-** Adapted from code provided by Robert Elz, who writes:
-** The "best" way to do mktime I think is based on an idea of Bob
-** Kridle's (so its said...) from a long time ago. (mtxinu!kridle now).
-** It does a binary search of the time_t space. Since time_t's are
-** just 32 bits, its a max of 32 iterations (even at 64 bits it
-** would still be very reasonable).
-*/
-
-#ifndef WRONG
-#define WRONG (-1)
-#endif /* !defined WRONG */
-
-static void
-normalize(tensptr, unitsptr, base)
-int * const tensptr;
-int * const unitsptr;
-const int base;
-{
- int tmp;
-
- if (*unitsptr >= base) {
- *tensptr += *unitsptr / base;
- *unitsptr %= base;
- } else if (*unitsptr < 0) {
- /* tmp has the range 0 to abs(*unitptr) -1 */
- tmp = -1 - (*unitsptr);
- *tensptr -= (tmp/base + 1);
- *unitsptr = (base - 1) - (tmp % base);
- }
-}
-
-static int
-tmcomp(atmp, btmp)
-register const struct tm * const atmp;
-register const struct tm * const btmp;
-{
- register int result;
-
- if ((result = (atmp->tm_year - btmp->tm_year)) == 0 &&
- (result = (atmp->tm_mon - btmp->tm_mon)) == 0 &&
- (result = (atmp->tm_mday - btmp->tm_mday)) == 0 &&
- (result = (atmp->tm_hour - btmp->tm_hour)) == 0 &&
- (result = (atmp->tm_min - btmp->tm_min)) == 0)
- result = atmp->tm_sec - btmp->tm_sec;
- return result;
-}
-
-static time_t
-time2(tmp, funcp, offset, okayp)
-struct tm * const tmp;
-void (* const funcp)();
-const long offset;
-int * const okayp;
-{
- register const struct state * sp;
- register int dir;
- register int bits;
- register int i, j ;
- register int saved_seconds;
- time_t newt;
- time_t t;
- struct tm yourtm, mytm;
-
- *okayp = FALSE;
- yourtm = *tmp;
- if (yourtm.tm_sec >= SECSPERMIN + 2 || yourtm.tm_sec < 0)
- normalize(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN);
- normalize(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR);
- normalize(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY);
- normalize(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR);
- while (yourtm.tm_mday <= 0) {
- if (yourtm.tm_mon == 0) {
- yourtm.tm_mon = 12;
- --yourtm.tm_year;
- }
- yourtm.tm_mday +=
- mon_lengths[isleap(yourtm.tm_year +
- TM_YEAR_BASE)][--yourtm.tm_mon];
- if (yourtm.tm_mon >= MONSPERYEAR) {
- yourtm.tm_mon = 0;
- --yourtm.tm_year;
- }
- }
- for ( ; ; ) {
- i = mon_lengths[isleap(yourtm.tm_year +
- TM_YEAR_BASE)][yourtm.tm_mon];
- if (yourtm.tm_mday <= i)
- break;
- yourtm.tm_mday -= i;
- if (++yourtm.tm_mon >= MONSPERYEAR) {
- yourtm.tm_mon = 0;
- ++yourtm.tm_year;
- }
- }
- saved_seconds = yourtm.tm_sec;
- yourtm.tm_sec = 0;
- /*
- ** Calculate the number of magnitude bits in a time_t
- ** (this works regardless of whether time_t is
- ** signed or unsigned, though lint complains if unsigned).
- */
- for (bits = 0, t = 1; t > 0; ++bits, t <<= 1)
- ;
- /*
- ** If time_t is signed, then 0 is the median value,
- ** if time_t is unsigned, then 1 << bits is median.
- */
- t = (t < 0) ? 0 : ((time_t) 1 << bits);
- for ( ; ; ) {
- (*funcp)(&t, offset, &mytm);
- dir = tmcomp(&mytm, &yourtm);
- if (dir != 0) {
- if (bits-- < 0)
- return WRONG;
- if (bits < 0)
- --t;
- else if (dir > 0)
- t -= (time_t) 1 << bits;
- else t += (time_t) 1 << bits;
- continue;
- }
- if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst)
- break;
- /*
- ** Right time, wrong type.
- ** Hunt for right time, right type.
- ** It's okay to guess wrong since the guess
- ** gets checked.
- */
- sp = (const struct state *)
- ((funcp == localsub) ? lclptr : gmtptr);
- if (sp == NULL)
- return WRONG;
- for (i = 0; i < sp->typecnt; ++i) {
- if (sp->ttis[i].tt_isdst != yourtm.tm_isdst)
- continue;
- for (j = 0; j < sp->typecnt; ++j) {
- if (sp->ttis[j].tt_isdst == yourtm.tm_isdst)
- continue;
- newt = t + sp->ttis[j].tt_gmtoff -
- sp->ttis[i].tt_gmtoff;
- (*funcp)(&newt, offset, &mytm);
- if (tmcomp(&mytm, &yourtm) != 0)
- continue;
- if (mytm.tm_isdst != yourtm.tm_isdst)
- continue;
- /*
- ** We have a match.
- */
- t = newt;
- goto label;
- }
- }
- return WRONG;
- }
-label:
- t += saved_seconds;
- (*funcp)(&t, offset, tmp);
- *okayp = TRUE;
- return t;
-}
-
-static time_t
-time1(tmp, funcp, offset)
-struct tm * const tmp;
-void (* const funcp)();
-const long offset;
-{
- register time_t t;
- register const struct state * sp;
- register int samei, otheri;
- int okay;
-
-
- if (tmp->tm_isdst > 1)
- tmp->tm_isdst = 1;
- t = time2(tmp, funcp, offset, &okay);
- if (okay || tmp->tm_isdst < 0)
- return t;
- /*
- ** We're supposed to assume that somebody took a time of one type
- ** and did some math on it that yielded a "struct tm" that's bad.
- ** We try to divine the type they started from and adjust to the
- ** type they need.
- */
- sp = (const struct state *) ((funcp == localsub) ? lclptr : gmtptr);
- if (sp == NULL)
- return WRONG;
- for (samei = 0; samei < sp->typecnt; ++samei) {
- if (sp->ttis[samei].tt_isdst != tmp->tm_isdst)
- continue;
- for (otheri = 0; otheri < sp->typecnt; ++otheri) {
- if (sp->ttis[otheri].tt_isdst == tmp->tm_isdst)
- continue;
- tmp->tm_sec += sp->ttis[otheri].tt_gmtoff -
- sp->ttis[samei].tt_gmtoff;
- tmp->tm_isdst = !tmp->tm_isdst;
- t = time2(tmp, funcp, offset, &okay);
- if (okay)
- return t;
- tmp->tm_sec -= sp->ttis[otheri].tt_gmtoff -
- sp->ttis[samei].tt_gmtoff;
- tmp->tm_isdst = !tmp->tm_isdst;
- }
- }
- return WRONG;
-}
-
-time_t
-mktime(tmp)
-struct tm * const tmp;
-{
- return time1(tmp, localsub, 0L);
-}
-
-time_t
-timelocal(tmp)
-struct tm * const tmp;
-{
- tmp->tm_isdst = -1;
- return mktime(tmp);
-}
-
-time_t
-timegm(tmp)
-struct tm * const tmp;
-{
- return time1(tmp, gmtsub, 0L);
-}
-
-time_t
-timeoff(tmp, offset)
-struct tm * const tmp;
-const long offset;
-{
-
- return time1(tmp, gmtsub, offset);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/lsearch.c b/usr/src/lib/libbc/libc/gen/common/lsearch.c
deleted file mode 100644
index adcb72b0d7..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/lsearch.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.8 */
-
-/*LINTLIBRARY*/
-/*
- * Linear search algorithm, generalized from Knuth (6.1) Algorithm Q.
- *
- * This version no longer has anything to do with Knuth's Algorithm Q,
- * which first copies the new element into the table, then looks for it.
- * The assumption there was that the cost of checking for the end of the
- * table before each comparison outweighed the cost of the comparison, which
- * isn't true when an arbitrary comparison function must be called and when the
- * copy itself takes a significant number of cycles.
- * Actually, it has now reverted to Algorithm S, which is "simpler."
- */
-
-typedef char *POINTER;
-extern POINTER memcpy();
-
-POINTER
-lsearch(key, base, nelp, width, compar)
-register POINTER key; /* Key to be located */
-register POINTER base; /* Beginning of table */
-unsigned *nelp; /* Pointer to current table size */
-register unsigned width; /* Width of an element (bytes) */
-int (*compar)(); /* Comparison function */
-{
- register POINTER next = base + *nelp * width; /* End of table */
-
- for ( ; base < next; base += width)
- if ((*compar)(key, base) == 0)
- return (base); /* Key found */
- ++*nelp; /* Not found, add to table */
- return (memcpy(base, key, (int)width)); /* base now == next */
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/madvise.c b/usr/src/lib/libbc/libc/gen/common/madvise.c
deleted file mode 100644
index 7ecf45b868..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/madvise.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <errno.h>
-
-/*
- * Function to provide advise to vm system to optimize it's
- * characteristics for a particular application
- */
-
-/*LINTLIBRARY*/
-int
-madvise(caddr_t addr, u_int len, int advice)
-{
- if (len == 0) {
- errno = EINVAL;
- return (-1);
- }
- return (mctl(addr, len, MC_ADVISE, advice));
-}
-
-/*
- * This is only here so programs that use vadvise will not fail
- * because it is not in the bcp libc.
- */
-int
-vadvise(int param)
-{
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/mallint.h b/usr/src/lib/libbc/libc/gen/common/mallint.h
deleted file mode 100644
index d516393191..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mallint.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1986 by Sun Microsystems, Inc.
- */
-
-/*
- * file: mallint.h
- * description:
- *
- * Definitions for malloc.c and friends (realloc.c, memalign.c)
- *
- * The node header structure. Header info never overlaps with user
- * data space, in order to accommodate the following atrocity:
- * free(p);
- * realloc(p, newsize);
- * ... which was historically used to obtain storage compaction as
- * a side effect of the realloc() call, when the block referenced
- * by p was coalesced with another free block by the call to free().
- *
- * To reduce storage consumption, a header block is associated with
- * free blocks only, not allocated blocks.
- * When a free block is allocated, its header block is put on
- * a free header block list.
- *
- * This creates a header space and a free block space.
- * The left pointer of a header blocks is used to chain free header
- * blocks together. New header blocks are allocated in chunks of
- * NFREE_HDRS.
- */
-#include <malloc.h>
-
-typedef enum {false,true} bool;
-typedef struct freehdr *Freehdr;
-typedef struct dblk *Dblk;
-typedef unsigned int uint;
-
-/*
- * Description of a header for a free block
- * Only free blocks have such headers.
- */
-struct freehdr {
- Freehdr left; /* Left tree pointer */
- Freehdr right; /* Right tree pointer */
- Dblk block; /* Ptr to the data block */
- uint size;
-};
-
-#define NIL ((Freehdr) 0)
-#define NFREE_HDRS 512 /* Get this many headers at a time */
-#define SMALLEST_BLK sizeof(struct dblk) /* Size of smallest block */
-#define NULL 0
-
-/*
- * Description of a data block.
- * A data block consists of a length word, possibly followed by
- * a filler word for alignment, followed by the user's data.
- * To back up from the user's data to the length word, use
- * (address of data) - ALIGNSIZ;
- */
-
-#ifdef sparc
-#define ALIGNSIZ sizeof(double)
-struct dblk {
- uint size; /* Size of the block */
- uint filler; /* filler, for double alignment */
- char data[ALIGNSIZ]; /* Addr returned to the caller */
-};
-#endif
-
-#ifdef mc68000
-#define ALIGNSIZ sizeof(uint)
-struct dblk {
- uint size; /* Size of the block */
- char data[ALIGNSIZ]; /* Addr returned to the caller */
-};
-#endif
-
-
-/*
- * weight(x) is the size of a block, in bytes; or 0 if and only if x
- * is a null pointer. Note that malloc() and free() should be
- * prepared to deal with things like zero-length blocks, which
- * can be introduced by errant programs.
- */
-
-#define weight(x) ((x) == NIL? 0: (x->size))
-#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-#define nextblk(p, size) ((Dblk) ((char *) (p) + (size)))
-#define max(a, b) ((a) < (b)? (b): (a))
-#define min(a, b) ((a) < (b)? (a): (b))
-#define heapsize() (_ubound - _lbound)
-#define misaligned(p) ((unsigned)(p)&3)
-
-extern Freehdr _root;
-extern char *_lbound, *_ubound;
-extern int malloc_debug();
-
-extern struct mallinfo __mallinfo;
diff --git a/usr/src/lib/libbc/libc/gen/common/malloc.c b/usr/src/lib/libbc/libc/gen/common/malloc.c
deleted file mode 100644
index 2d5891dd18..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/malloc.c
+++ /dev/null
@@ -1,1444 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1986 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * file: malloc.c
- * description:
- * Yet another memory allocator, this one based on a method
- * described in C.J. Stephenson, "Fast Fits"
- *
- * The basic data structure is a "Cartesian" binary tree, in which
- * nodes are ordered by ascending addresses (thus minimizing free
- * list insertion time) and block sizes decrease with depth in the
- * tree (thus minimizing search time for a block of a given size).
- *
- * In other words: for any node s, let D(s) denote the set of
- * descendents of s; for all x in D(left(s)) and all y in
- * D(right(s)), we have:
- *
- * a. addr(x) < addr(s) < addr(y)
- * b. len(x) <= len(s) >= len(y)
- */
-
-#include "mallint.h"
-#include <errno.h>
-#include <stdlib.h>
-#include <stdarg.h>
-
-/* system interface */
-
-extern char *sbrk();
-extern int getpagesize();
-
-static int nbpg = 0; /* set by calling getpagesize() */
-static bool morecore(uint); /* get more memory into free space */
-
-#ifdef S5EMUL
-#define ptr_t void * /* ANSI C says these are voids */
-#define free_t void /* ANSI says void free(ptr_t ptr) */
-#define free_return(x) return
-#else
-#define ptr_t char * /* BSD still (4.3) wants char*'s */
-#define free_t int /* BSD says int free(ptr_t ptr) */
-#define free_return(x) return(x)
-#endif
-
-/* SystemV-compatible information structure */
-#define INIT_MXFAST 0
-#define INIT_NLBLKS 100
-#define INIT_GRAIN ALIGNSIZ
-
-struct mallinfo __mallinfo = {
- 0,0,0,0,0,0,0,0,0,0, /* basic info */
- INIT_MXFAST, INIT_NLBLKS, INIT_GRAIN, /* mallopt options */
- 0,0,0
-};
-
-/* heap data structures */
-
-Freehdr _root = NIL; /* root of free space list */
-char *_lbound = NULL; /* lower bound of heap */
-char *_ubound = NULL; /* upper bound of heap */
-
-/* free header list management */
-
-static Freehdr getfreehdr(void);
-static void putfreehdr(Freehdr);
-static Freehdr freehdrptr = NIL; /* ptr to block of available headers */
-static int nfreehdrs = 0; /* # of headers in current block */
-static Freehdr freehdrlist = NIL; /* List of available headers */
-
-/* error checking */
-static void error(char *, ...);
-/* sets errno; prints msg and aborts if DEBUG is on */
-
-static int reclaim(Dblk, uint, int);
-
-#ifdef DEBUG /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
-
-int malloc_debug(int);
-int malloc_verify(void);
-static int debug_level = 1;
-
-/*
- * A block with a negative size, a size that is not a multiple
- * of ALIGNSIZ, a size greater than the current extent of the
- * heap, or a size which extends beyond the end of the heap is
- * considered bad.
- */
-
-#define badblksize(p,size)\
-( (size) < SMALLEST_BLK \
- || (size) & (ALIGNSIZ-1) \
- || (size) > heapsize() \
- || ((char*)(p))+(size) > _ubound )
-
-#else /* !DEBUG ================================================= */
-
-#define malloc_debug(level) 0
-#define malloc_verify() 1
-#define debug_level 0
-#define badblksize(p,size) 0
-
-#endif /* !DEBUG <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
-
-
-/*
- * insert (newblk, len)
- * Inserts a new node in the free space tree, placing it
- * in the correct position with respect to the existing nodes.
- *
- * algorithm:
- * Starting from the root, a binary search is made for the new
- * node. If this search were allowed to continue, it would
- * eventually fail (since there cannot already be a node at the
- * given address); but in fact it stops when it reaches a node in
- * the tree which has a length less than that of the new node (or
- * when it reaches a null tree pointer).
- *
- * The new node is then inserted at the root of the subtree for
- * which the shorter node forms the old root (or in place of the
- * null pointer).
- *
- * Arguments
- * newblk: Ptr to the block to insert
- * len: Length of new node
- */
-
-static void
-insert(Dblk newblk, uint len)
-{
- Freehdr *fpp; /* Address of ptr to subtree */
- Freehdr x;
- Freehdr *left_hook; /* Temp for insertion */
- Freehdr *right_hook; /* Temp for insertion */
- Freehdr newhdr;
-
- /*
- * check for bad block size.
- */
- if ( badblksize(newblk,len) ) {
- error("insert: bad block size (%d) at %#x\n", len, newblk);
- return;
- }
-
- /*
- * Search for the first node which has a weight less
- * than that of the new node; this will be the
- * point at which we insert the new node.
- */
- fpp = &_root;
- x = *fpp;
- while (weight(x) >= len) {
- if (newblk < x->block)
- fpp = &x->left;
- else
- fpp = &x->right;
- x = *fpp;
- }
-
- /*
- * Perform root insertion. The variable x traces a path through
- * the fpp, and with the help of left_hook and right_hook,
- * rewrites all links that cross the territory occupied
- * by newblk.
- */
-
- if ((newhdr = getfreehdr()) == NIL) {
- /* Error message returned by getfreehdr() */
- return;
- }
- *fpp = newhdr;
-
- newhdr->left = NIL;
- newhdr->right = NIL;
- newhdr->block = newblk;
- newhdr->size = len;
-
- /*
- * set length word in the block for consistency with the header.
- */
-
- newblk->size = len;
-
- left_hook = &newhdr->left;
- right_hook = &newhdr->right;
-
- while (x != NIL) {
- /*
- * Remark:
- * The name 'left_hook' is somewhat confusing, since
- * it is always set to the address of a .right link
- * field. However, its value is always an address
- * below (i.e., to the left of) newblk. Similarly
- * for right_hook. The values of left_hook and
- * right_hook converge toward the value of newblk,
- * as in a classical binary search.
- */
- if (x->block < newblk) {
- /*
- * rewrite link crossing from the left
- */
- *left_hook = x;
- left_hook = &x->right;
- x = x->right;
- } else {
- /*
- * rewrite link crossing from the right
- */
- *right_hook = x;
- right_hook = &x->left;
- x = x->left;
- } /*else*/
- } /*while*/
-
- *left_hook = *right_hook = NIL; /* clear remaining hooks */
-
-} /*insert*/
-
-/*
- * delete(p)
- * deletes a node from a cartesian tree. p is the address of
- * a pointer to the node which is to be deleted.
- *
- * algorithm:
- * The left and right branches of the node to be deleted define two
- * subtrees which are to be merged and attached in place of the
- * deleted node. Each node on the inside edges of these two
- * subtrees is examined and longer nodes are placed above the
- * shorter ones.
- *
- * On entry:
- * *p is assumed to be non-null.
- */
-static void
-delete(Freehdr *p)
-{
- Freehdr x;
- Freehdr left_branch; /* left subtree of deleted node */
- Freehdr right_branch; /* right subtree of deleted node */
- uint left_weight;
- uint right_weight;
-
- x = *p;
- left_branch = x->left;
- left_weight = weight(left_branch);
- right_branch = x->right;
- right_weight = weight(right_branch);
-
- while (left_branch != right_branch) {
- /*
- * iterate until left branch and right branch are
- * both NIL.
- */
- if ( left_weight >= right_weight ) {
- /*
- * promote the left branch
- */
- if (left_branch != NIL) {
- if (left_weight == 0) {
- /* zero-length block */
- error("blocksize=0 at %#x\n",
- (int)left_branch->block->data);
- break;
- }
- *p = left_branch;
- p = &left_branch->right;
- left_branch = *p;
- left_weight = weight(left_branch);
- }
- } else {
- /*
- * promote the right branch
- */
- if (right_branch != NIL) {
- if (right_weight == 0) {
- /* zero-length block */
- error("blocksize=0 at %#x\n",
- (int)right_branch->block->data);
- break;
- }
- *p = right_branch;
- p = &right_branch->left;
- right_branch = *p;
- right_weight = weight(right_branch);
- }
- }/*else*/
- }/*while*/
- *p = NIL;
- putfreehdr(x);
-} /*delete*/
-
-
-/*
- * demote(p)
- * Demotes a node in a cartesian tree, if necessary, to establish
- * the required vertical ordering.
- *
- * algorithm:
- * The left and right subtrees of the node to be demoted are to
- * be partially merged and attached in place of the demoted node.
- * The nodes on the inside edges of these two subtrees are
- * examined and the longer nodes are placed above the shorter
- * ones, until a node is reached which has a length no greater
- * than that of the node being demoted (or until a null pointer
- * is reached). The node is then attached at this point, and
- * the remaining subtrees (if any) become its descendants.
- *
- * on entry:
- * a. All the nodes in the tree, including the one to be demoted,
- * must be correctly ordered horizontally;
- * b. All the nodes except the one to be demoted must also be
- * correctly positioned vertically. The node to be demoted
- * may be already correctly positioned vertically, or it may
- * have a length which is less than that of one or both of
- * its progeny.
- * c. *p is non-null
- */
-
-static void
-demote(Freehdr *p)
-{
- Freehdr x; /* addr of node to be demoted */
- Freehdr left_branch;
- Freehdr right_branch;
- uint left_weight;
- uint right_weight;
- uint x_weight;
-
- x = *p;
- x_weight = weight(x);
- left_branch = x->left;
- right_branch = x->right;
- left_weight = weight(left_branch);
- right_weight = weight(right_branch);
-
- while (left_weight > x_weight || right_weight > x_weight) {
- /*
- * select a descendant branch for promotion
- */
- if (left_weight >= right_weight) {
- /*
- * promote the left branch
- */
- *p = left_branch;
- p = &left_branch->right;
- left_branch = *p;
- left_weight = weight(left_branch);
- } else {
- /*
- * promote the right branch
- */
- *p = right_branch;
- p = &right_branch->left;
- right_branch = *p;
- right_weight = weight(right_branch);
- } /*else*/
- } /*while*/
-
- *p = x; /* attach demoted node here */
- x->left = left_branch;
- x->right = right_branch;
-
-} /*demote*/
-
-
-/*
- * char*
- * malloc(nbytes)
- * Allocates a block of length specified in bytes. If nbytes is
- * zero, a valid pointer (that should not be dereferenced) is returned.
- *
- * algorithm:
- * The freelist is searched by descending the tree from the root
- * so that at each decision point the "better fitting" branch node
- * is chosen (i.e., the shorter one, if it is long enough, or
- * the longer one, otherwise). The descent stops when both
- * branch nodes are too short.
- *
- * function result:
- * Malloc returns a pointer to the allocated block. A null
- * pointer indicates an error.
- *
- * diagnostics:
- *
- * ENOMEM: storage could not be allocated.
- *
- * EINVAL: either the argument was invalid, or the heap was found
- * to be in an inconsistent state. More detailed information may
- * be obtained by enabling range checks (cf., malloc_debug()).
- *
- * Note: In this implementation, each allocated block includes a
- * length word, which occurs before the address seen by the caller.
- * Allocation requests are rounded up to a multiple of wordsize.
- */
-
-ptr_t
-malloc(uint nbytes)
-{
- Freehdr allocp; /* ptr to node to be allocated */
- Freehdr *fpp; /* for tree modifications */
- Freehdr left_branch;
- Freehdr right_branch;
- uint left_weight;
- uint right_weight;
- Dblk retblk; /* block returned to the user */
-
- /*
- * if rigorous checking was requested, do it.
- */
- if (debug_level >= 2) {
- malloc_verify();
- }
-
- /*
- * add the size of a length word to the request, and
- * guarantee at least one word of usable data.
- */
- nbytes += ALIGNSIZ;
- if (nbytes < SMALLEST_BLK) {
- nbytes = SMALLEST_BLK;
- } else {
- nbytes = roundup(nbytes, ALIGNSIZ);
- }
-
- /*
- * ensure that at least one block is big enough to satisfy
- * the request.
- */
-
- if (weight(_root) < nbytes) {
- /*
- * the largest block is not enough.
- */
- if(!morecore(nbytes))
- return 0;
- }
-
- /*
- * search down through the tree until a suitable block is
- * found. At each decision point, select the better
- * fitting node.
- */
-
- fpp = &_root;
- allocp = *fpp;
- left_branch = allocp->left;
- right_branch = allocp->right;
- left_weight = weight(left_branch);
- right_weight = weight(right_branch);
-
- while (left_weight >= nbytes || right_weight >= nbytes) {
- if (left_weight <= right_weight) {
- if (left_weight >= nbytes) {
- fpp = &allocp->left;
- allocp = left_branch;
- } else {
- fpp = &allocp->right;
- allocp = right_branch;
- }
- } else {
- if (right_weight >= nbytes) {
- fpp = &allocp->right;
- allocp = right_branch;
- } else {
- fpp = &allocp->left;
- allocp = left_branch;
- }
- }
- left_branch = allocp->left;
- right_branch = allocp->right;
- left_weight = weight(left_branch);
- right_weight = weight(right_branch);
- } /*while*/
-
- /*
- * allocate storage from the selected node.
- */
-
- if (allocp->size - nbytes <= SMALLEST_BLK) {
- /*
- * not big enough to split; must leave at least
- * a dblk's worth of space.
- */
- retblk = allocp->block;
- delete(fpp);
- } else {
-
- /*
- * Split the selected block n bytes from the top. The
- * n bytes at the top are returned to the caller; the
- * remainder of the block goes back to free space.
- */
- Dblk nblk;
-
- retblk = allocp->block;
- nblk = nextblk(retblk, nbytes); /* ^next block */
- nblk->size = allocp->size = retblk->size - nbytes;
- __mallinfo.ordblks++; /* count fragments */
-
- /*
- * Change the selected node to point at the newly split
- * block, and move the node to its proper place in
- * the free space list.
- */
- allocp->block = nblk;
- demote(fpp);
-
- /*
- * set the length field of the allocated block; we need
- * this because free() does not specify a length.
- */
- retblk->size = nbytes;
- }
- /* maintain statistics */
- __mallinfo.uordbytes += retblk->size; /* bytes allocated */
- __mallinfo.allocated++; /* frags allocated */
- if (nbytes < __mallinfo.mxfast)
- __mallinfo.smblks++; /* kludge to pass the SVVS */
-
- return((ptr_t)retblk->data);
-
-} /*malloc*/
-
-/*
- * free(p)
- * return a block to the free space tree.
- *
- * algorithm:
- * Starting at the root, search for and coalesce free blocks
- * adjacent to one given. When the appropriate place in the
- * tree is found, insert the given block.
- *
- * Some sanity checks to avoid total confusion in the tree.
- * If the block has already been freed, return.
- * If the ptr is not from the sbrk'ed space, return.
- * If the block size is invalid, return.
- */
-free_t
-free(ptr_t ptr)
-{
- uint nbytes; /* Size of node to be released */
- Freehdr *fpp; /* For deletion from free list */
- Freehdr neighbor; /* Node to be coalesced */
- Dblk neighbor_blk; /* Ptr to potential neighbor */
- uint neighbor_size; /* Size of potential neighbor */
- Dblk oldblk; /* Ptr to block to be freed */
-
- /*
- * if rigorous checking was requested, do it.
- */
- if (debug_level >= 2) {
- malloc_verify();
- }
-
- /*
- * Check the address of the old block.
- */
- if ( misaligned(ptr) ) {
- error("free: illegal address (%#x)\n", ptr);
- free_return(0);
- }
-
- /*
- * Freeing something that wasn't allocated isn't
- * exactly kosher, but fclose() does it routinely.
- */
- if( ptr < (ptr_t)_lbound || ptr > (ptr_t)_ubound ) {
- errno = EINVAL;
- free_return(0);
- }
-
- /*
- * Get node length by backing up by the size of a header.
- * Check for a valid length. It must be a positive
- * multiple of ALIGNSIZ, at least as large as SMALLEST_BLK,
- * no larger than the extent of the heap, and must not
- * extend beyond the end of the heap.
- */
- oldblk = (Dblk)((char*)ptr - ALIGNSIZ);
- nbytes = oldblk->size;
- if (badblksize(oldblk,nbytes)) {
- error("free: bad block size (%d) at %#x\n",
- (int)nbytes, (int)oldblk );
- free_return(0);
- }
-
- /* maintain statistics */
- __mallinfo.uordbytes -= nbytes; /* bytes allocated */
- __mallinfo.allocated--; /* frags allocated */
-
- /*
- * Search the tree for the correct insertion point for this
- * node, coalescing adjacent free blocks along the way.
- */
- fpp = &_root;
- neighbor = *fpp;
- while (neighbor != NIL) {
- neighbor_blk = neighbor->block;
- neighbor_size = neighbor->size;
- if (oldblk < neighbor_blk) {
- Dblk nblk = nextblk(oldblk,nbytes);
- if (nblk == neighbor_blk) {
- /*
- * Absorb and delete right neighbor
- */
- nbytes += neighbor_size;
- __mallinfo.ordblks--;
- delete(fpp);
- } else if (nblk > neighbor_blk) {
- /*
- * The block being freed overlaps
- * another block in the tree. This
- * is bad news. Return to avoid
- * further fouling up the the tree.
- */
- error("free: blocks %#x, %#x overlap\n",
- (int)oldblk, (int)neighbor_blk);
- free_return(0);
- } else {
- /*
- * Search to the left
- */
- fpp = &neighbor->left;
- }
- } else if (oldblk > neighbor_blk) {
- Dblk nblk = nextblk(neighbor_blk, neighbor_size);
- if (nblk == oldblk) {
- /*
- * Absorb and delete left neighbor
- */
- oldblk = neighbor_blk;
- nbytes += neighbor_size;
- __mallinfo.ordblks--;
- delete(fpp);
- } else if (nblk > oldblk) {
- /*
- * This block has already been freed
- */
- error("free: block %#x was already free\n",
- (int)ptr);
- free_return(0);
- } else {
- /*
- * search to the right
- */
- fpp = &neighbor->right;
- }
- } else {
- /*
- * This block has already been freed
- * as "oldblk == neighbor_blk"
- */
- error("free: block %#x was already free\n", (int)ptr);
- free_return(0);
- } /*else*/
-
- /*
- * Note that this depends on a side effect of
- * delete(fpp) in order to terminate the loop!
- */
- neighbor = *fpp;
-
- } /*while*/
-
- /*
- * Insert the new node into the free space tree
- */
- insert( oldblk, nbytes );
- free_return(1);
-
-} /*free*/
-
-
-/*
- * char*
- * shrink(oldblk, oldsize, newsize)
- * Decreases the size of an old block to a new size.
- * Returns the remainder to free space. Returns the
- * truncated block to the caller.
- */
-
-static char *
-shrink(Dblk oldblk, uint oldsize, uint newsize)
-{
- Dblk remainder;
- if (oldsize - newsize >= SMALLEST_BLK) {
- /*
- * Block is to be contracted. Split the old block
- * and return the remainder to free space.
- */
- remainder = nextblk(oldblk, newsize);
- remainder->size = oldsize - newsize;
- oldblk->size = newsize;
-
- /* maintain statistics */
- __mallinfo.ordblks++; /* count fragments */
- __mallinfo.allocated++; /* negate effect of free() */
-
- free(remainder->data);
- }
- return(oldblk->data);
-}
-
-/*
- * char*
- * realloc(ptr, nbytes)
- *
- * Reallocate an old block with a new size, returning the old block
- * if possible. The block returned is guaranteed to preserve the
- * contents of the old block up to min(size(old block), newsize).
- *
- * For backwards compatibility, ptr is allowed to reference
- * a block freed since the LAST call of malloc(). Thus the old
- * block may be busy, free, or may even be nested within a free
- * block.
- *
- * Some old programs have been known to do things like the following,
- * which is guaranteed not to work:
- *
- * free(ptr);
- * free(dummy);
- * dummy = malloc(1);
- * ptr = realloc(ptr,nbytes);
- *
- * This atrocity was found in the source for diff(1).
- */
-ptr_t
-realloc(ptr_t ptr, uint nbytes)
-{
- Freehdr *fpp;
- Freehdr fp;
- Dblk oldblk;
- Dblk freeblk;
- Dblk oldneighbor;
- uint oldsize;
- uint newsize;
- uint oldneighborsize;
-
- /*
- * Add SVR4 semantics for OS 5.x so /usr/lib librarys
- * work correctly when running in BCP mode
- */
- if (ptr == NULL) {
- return (malloc(nbytes));
- }
-
- /*
- * if rigorous checking was requested, do it.
- */
- if (debug_level >= 2) {
- malloc_verify();
- }
-
- /*
- * Check the address of the old block.
- */
- if ( misaligned(ptr) ||
- ptr < (ptr_t)_lbound ||
- ptr > (ptr_t)_ubound ) {
- error("realloc: illegal address (%#x)\n", ptr);
- return(NULL);
- }
-
- /*
- * check location and size of the old block and its
- * neighboring block to the right. If the old block is
- * at end of memory, the neighboring block is undefined.
- */
- oldblk = (Dblk)((char*)ptr - ALIGNSIZ);
- oldsize = oldblk->size;
- if (badblksize(oldblk,oldsize)) {
- error("realloc: bad block size (%d) at %#x\n",
- oldsize, oldblk);
- return(NULL);
- }
- oldneighbor = nextblk(oldblk,oldsize);
-
- /* *** tree search code pulled into separate subroutine *** */
- if (reclaim(oldblk, oldsize, 1) == -1) {
- return(NULL); /* internal error */
- }
-
- /*
- * At this point, we can guarantee that oldblk is out of free
- * space. What we do next depends on a comparison of the size
- * of the old block and the requested new block size. To do
- * this, first round up the new size request.
- */
- newsize = nbytes + ALIGNSIZ; /* add size of a length word */
- if (newsize < SMALLEST_BLK) {
- newsize = SMALLEST_BLK;
- } else {
- newsize = roundup(newsize, ALIGNSIZ);
- }
-
- /*
- * Next, examine the size of the old block, and compare it
- * with the requested new size.
- */
-
- if (oldsize >= newsize) {
- /*
- * Block is to be made smaller.
- */
- return(shrink(oldblk, oldsize, newsize));
- }
-
- /*
- * Block is to be expanded. Look for adjacent free memory.
- */
- if ( oldneighbor < (Dblk)_ubound ) {
- /*
- * Search for the adjacent block in the free
- * space tree. Note that the tree may have been
- * modified in the earlier loop.
- */
- fpp = &_root;
- fp = *fpp;
- oldneighborsize = oldneighbor->size;
- if ( badblksize(oldneighbor, oldneighborsize) ) {
- error("realloc: bad blocksize(%d) at %#x\n",
- oldneighborsize, oldneighbor);
- return(NULL);
- }
- while ( weight(fp) >= oldneighborsize ) {
- freeblk = fp->block;
- if (oldneighbor < freeblk) {
- /*
- * search to the left
- */
- fpp = &(fp->left);
- fp = *fpp;
- }
- else if (oldneighbor > freeblk) {
- /*
- * search to the right
- */
- fpp = &(fp->right);
- fp = *fpp;
- }
- else { /* oldneighbor == freeblk */
- /*
- * neighboring block is free; is it big enough?
- */
- if (oldsize + oldneighborsize >= newsize) {
- /*
- * Big enough. Delete freeblk, join
- * oldblk to neighbor, return newsize
- * bytes to the caller, and return the
- * remainder to free storage.
- */
- delete(fpp);
-
- /* maintain statistics */
- __mallinfo.ordblks--;
- __mallinfo.uordbytes += oldneighborsize;
-
- oldsize += oldneighborsize;
- oldblk->size = oldsize;
- return(shrink(oldblk, oldsize, newsize));
- } else {
- /*
- * Not big enough. Stop looking for a
- * free lunch.
- */
- break;
- } /*else*/
- } /*else*/
- }/*while*/
- } /*if*/
-
- /*
- * At this point, we know there is no free space in which to
- * expand. Malloc a new block, copy the old block to the new,
- * and free the old block, IN THAT ORDER.
- */
- ptr = malloc(nbytes);
- if (ptr != NULL) {
- bcopy(oldblk->data, ptr, oldsize-ALIGNSIZ);
- free(oldblk->data);
- }
- return(ptr);
-
-} /* realloc */
-
-
-/*
- * *** The following code was pulled out of realloc() ***
- *
- * int
- * reclaim(oldblk, oldsize, flag)
- * If a block containing 'oldsize' bytes from 'oldblk'
- * is in the free list, remove it from the free list.
- * 'oldblk' and 'oldsize' are assumed to include the free block header.
- *
- * Returns 1 if block was successfully removed.
- * Returns 0 if block was not in free list.
- * Returns -1 if block spans a free/allocated boundary (error() called
- * if 'flag' == 1).
- */
-static int
-reclaim(Dblk oldblk, uint oldsize, int flag)
-{
- Dblk oldneighbor;
- Freehdr *fpp;
- Freehdr fp;
- Dblk freeblk;
- uint size;
-
- /*
- * Search the free space list for a node describing oldblk,
- * or a node describing a block containing oldblk. Assuming
- * the size of blocks decreases monotonically with depth in
- * the tree, the loop may terminate as soon as a block smaller
- * than oldblk is encountered.
- */
-
- oldneighbor = nextblk(oldblk, oldsize);
-
- fpp = &_root;
- fp = *fpp;
- while ( (size = weight(fp)) >= oldsize ) {
- freeblk = fp->block;
- if (badblksize(freeblk,size)) {
- error("realloc: bad block size (%d) at %#x\n",
- size, freeblk);
- return(-1);
- }
- if ( oldblk == freeblk ) {
- /*
- * |<-- freeblk ...
- * _________________________________
- * |<-- oldblk ...
- * ---------------------------------
- * Found oldblk in the free space tree; delete it.
- */
- delete(fpp);
-
- /* maintain statistics */
- __mallinfo.uordbytes += oldsize;
- __mallinfo.allocated++;
- return(1);
- }
- else if (oldblk < freeblk) {
- /*
- * |<-- freeblk ...
- * _________________________________
- * |<--oldblk ...
- * ---------------------------------
- * Search to the left for oldblk
- */
- fpp = &fp->left;
- fp = *fpp;
- }
- else {
- /*
- * |<-- freeblk ...
- * _________________________________
- * | |<--oldblk--->|<--oldneighbor
- * ---------------------------------
- * oldblk is somewhere to the right of freeblk.
- * Check to see if it lies within freeblk.
- */
- Dblk freeneighbor;
- freeneighbor = nextblk(freeblk, freeblk->size);
- if (oldblk >= freeneighbor) {
- /*
- * |<-- freeblk--->|<--- freeneighbor ...
- * _________________________________
- * | |<--oldblk--->|
- * ---------------------------------
- * no such luck; search to the right.
- */
- fpp = &fp->right;
- fp = *fpp;
- }
- else {
- /*
- * freeblk < oldblk < freeneighbor;
- * i.e., oldblk begins within freeblk.
- */
- if (oldneighbor > freeneighbor) {
- /*
- * |<-- freeblk--->|<--- freeneighbor
- * _________________________________
- * | |<--oldblk--->|<--oldneighbor
- * ---------------------------------
- * oldblk straddles a block boundary!
- */
- if (flag) {
- error("realloc: block %#x straddles free block boundary\n", oldblk);
- }
- return(-1);
- }
- else if ( oldneighbor == freeneighbor ) {
- /*
- * |<-------- freeblk------------->|
- * _________________________________
- * | |<--oldblk--->|
- * ---------------------------------
- * Oldblk is on the right end of
- * freeblk. Delete freeblk, split
- * into two fragments, and return
- * the one on the left to free space.
- */
- delete(fpp);
-
- /* maintain statistics */
- __mallinfo.ordblks++;
- __mallinfo.uordbytes += oldsize;
- __mallinfo.allocated += 2;
-
- freeblk->size -= oldsize;
- free(freeblk->data);
- return(1);
- }
- else {
- /*
- * |<-------- freeblk------------->|
- * _________________________________
- * | |oldblk | oldneighbor |
- * ---------------------------------
- * Oldblk is in the middle of freeblk.
- * Delete freeblk, split into three
- * fragments, and return the ones on
- * the ends to free space.
- */
- delete(fpp);
-
- /* maintain statistics */
- __mallinfo.ordblks += 2;
- __mallinfo.uordbytes += freeblk->size;
- __mallinfo.allocated += 3;
-
- /*
- * split the left fragment by
- * subtracting the size of oldblk
- * and oldblk's neighbor
- */
- freeblk->size -=
- ( (char*)freeneighbor
- - (char*)oldblk );
- /*
- * split the right fragment by
- * setting oldblk's neighbor's size
- */
- oldneighbor->size =
- (char*)freeneighbor
- - (char*)oldneighbor;
- /*
- * return the fragments to free space
- */
- free(freeblk->data);
- free(oldneighbor->data);
- return(1);
- } /*else*/
- } /*else*/
- } /* else */
- } /*while*/
-
- return(0); /* free block not found */
-}
-
-/*
- * bool
- * morecore(nbytes)
- * Add a block of at least nbytes from end-of-memory to the
- * free space tree.
- *
- * return value:
- * true if at least n bytes can be allocated
- * false otherwise
- *
- * remarks:
- *
- * -- free space (delimited by the extern variable _ubound) is
- * extended by an amount determined by rounding nbytes up to
- * a multiple of the system page size.
- *
- * -- The lower bound of the heap is determined the first time
- * this routine is entered. It does NOT necessarily begin at
- * the end of static data space, since startup code (e.g., for
- * profiling) may have invoked sbrk() before we got here.
- */
-
-static bool
-morecore(uint nbytes)
-{
- Dblk p;
- Freehdr newhdr;
-
- if (nbpg == 0) {
- nbpg = getpagesize();
- /* hack to avoid fragmenting the heap with the first
- freehdr page */
- if ((newhdr = getfreehdr()) == NIL) {
- /* Error message returned by getfreehdr() */
- return(false);
- }
- (void)putfreehdr(newhdr);
- }
- nbytes = roundup(nbytes, nbpg);
- p = (Dblk) sbrk((int)nbytes);
- if (p == (Dblk) -1) {
- if (errno == EAGAIN) errno = ENOMEM;
- return(false); /* errno = ENOMEM */
- }
- if (_lbound == NULL) /* set _lbound the first time through */
- _lbound = (char*) p;
- _ubound = (char *) p + nbytes;
- p->size = nbytes;
-
- /* maintain statistics */
- __mallinfo.arena = _ubound - _lbound;
- __mallinfo.uordbytes += nbytes;
- __mallinfo.ordblks++;
- __mallinfo.allocated++;
-
- free(p->data);
- return(true);
-
-} /*morecore*/
-
-
-/*
- * Get a free block header from the free header list.
- * When the list is empty, allocate an array of headers.
- * When the array is empty, allocate another one.
- * When we can't allocate another array, we're in deep weeds.
- */
-static Freehdr
-getfreehdr(void)
-{
- Freehdr r;
- Dblk blk;
- uint size;
-
- if (freehdrlist != NIL) {
- r = freehdrlist;
- freehdrlist = freehdrlist->left;
- return(r);
- }
- if (nfreehdrs <= 0) {
- size = NFREE_HDRS*sizeof(struct freehdr) + ALIGNSIZ;
- blk = (Dblk) sbrk(size);
- if ((int)blk == -1) {
- malloc_debug(1);
- error("getfreehdr: out of memory");
- if (errno == EAGAIN) errno = ENOMEM;
- return(NIL);
- }
- if (_lbound == NULL) /* set _lbound on first allocation */
- _lbound = (char*)blk;
- blk->size = size;
- freehdrptr = (Freehdr)blk->data;
- nfreehdrs = NFREE_HDRS;
- _ubound = (char*) nextblk(blk,size);
-
- /* maintain statistics */
- __mallinfo.arena = _ubound - _lbound;
- __mallinfo.treeoverhead += size;
- }
- nfreehdrs--;
- return(freehdrptr++);
-}
-
-/*
- * Free a free block header
- * Add it to the list of available headers.
- */
-static void
-putfreehdr(Freehdr p)
-{
- p->left = freehdrlist;
- freehdrlist = p;
-}
-
-#ifndef DEBUG /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
-
-/*
- * stubs for error handling and diagnosis routines. These are what
- * you get in the standard C library; for non-placebo diagnostics
- * load /usr/lib/malloc.debug.o with your program.
- */
-/*ARGSUSED*/
-static void
-error(char *fmt, ...)
-{
- errno = EINVAL;
-}
-
-#endif /* !DEBUG <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
-
-
-#ifdef DEBUG /* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
-
-/*
- * malloc_debug(level)
- *
- * description:
- *
- * Controls the level of error diagnosis and consistency checking
- * done by malloc() and free(). level is interpreted as follows:
- *
- * 0: malloc() and free() return 0 if error detected in arguments
- * (errno is set to EINVAL)
- * 1: malloc() and free() abort if errors detected in arguments
- * 2: same as 1, but scan entire heap for errors on every call
- * to malloc() or free()
- *
- * function result:
- * returns the previous level of error reporting.
- */
-int
-malloc_debug(int level)
-{
- int old_level;
- old_level = debug_level;
- debug_level = level;
- return (old_level);
-}
-
-/*
- * check a free space tree pointer. Should be in
- * the static free pool or somewhere in the heap.
- */
-
-#define chkblk(p)\
- if ( misaligned(p)\
- || ((Dblk)(p) < (Dblk)_lbound || (Dblk)(p) > (Dblk)_ubound)){\
- blkerror(p);\
- return 0;\
- }
-
-#define chkhdr(p) chkblk(p)
-
-static
-blkerror(Freehdr p)
-{
- error("Illegal block address (%#x)\n", (p));
-}
-
-/*
- * cartesian(p)
- * returns 1 if free space tree p satisfies internal consistency
- * checks.
- */
-
-static int
-cartesian(Freehdr p)
-{
- Freehdr probe;
- Dblk db,pdb;
-
- if (p == NIL) /* no tree to test */
- return 1;
- /*
- * check that root has a data block
- */
- chkhdr(p);
- pdb = p->block;
- chkblk(pdb);
-
- /*
- * check that the child blocks are no larger than the parent block.
- */
- probe = p->left;
- if (probe != NIL) {
- chkhdr(probe);
- db = probe->block;
- chkblk(db);
- if (probe->size > p->size) /* child larger than parent */
- return 0;
- }
- probe = p->right;
- if (probe != NIL) {
- chkhdr(probe);
- db = probe->block;
- chkblk(db);
- if (probe->size > p->size) /* child larger than parent */
- return 0;
- }
- /*
- * test data addresses in the left subtree,
- * starting at the left subroot and probing to
- * the right. All data addresses must be < p->block.
- */
- probe = p->left;
- while (probe != NIL) {
- chkhdr(probe);
- db = probe->block;
- chkblk(db);
- if ( nextblk(db, probe->size) >= pdb ) /* overlap */
- return 0;
- probe = probe->right;
- }
- /*
- * test data addresses in the right subtree,
- * starting at the right subroot and probing to
- * the left. All addresses must be > nextblk(p->block).
- */
- pdb = nextblk(pdb, p->size);
- probe = p->right;
- while (probe != NIL) {
- chkhdr(probe);
- db = probe->block;
- chkblk(db);
- if (db == NULL || db <= pdb) /* overlap */
- return 0;
- probe = probe->left;
- }
- return (cartesian(p->left) && cartesian(p->right));
-}
-
-/*
- * malloc_verify()
- *
- * This is a verification routine. It walks through all blocks
- * in the heap (both free and busy) and checks for bad blocks.
- * malloc_verify returns 1 if the heap contains no detectably bad
- * blocks; otherwise it returns 0.
- */
-
-int
-malloc_verify(void)
-{
- int maxsize;
- int hdrsize;
- int size;
- Dblk p;
- uint lb,ub;
-
- extern char end[];
-
- if (_lbound == NULL) /* no allocation yet */
- return 1;
-
- /*
- * first check heap bounds pointers
- */
- lb = (uint)end;
- ub = (uint)sbrk(0);
-
- if ((uint)_lbound < lb || (uint)_lbound > ub) {
- error("malloc_verify: illegal heap lower bound (%#x)\n",
- _lbound);
- return 0;
- }
- if ((uint)_ubound < lb || (uint)_ubound > ub) {
- error("malloc_verify: illegal heap upper bound (%#x)\n",
- _ubound);
- return 0;
- }
- maxsize = heapsize();
- p = (Dblk)_lbound;
- while (p < (Dblk) _ubound) {
- size = p->size;
- if ( (size) < SMALLEST_BLK
- || (size) & (ALIGNSIZ-1)
- || (size) > heapsize()
- || ((char*)(p))+(size) > _ubound ) {
- error("malloc_verify: bad block size (%d) at %#x\n",
- size, p);
- return(0); /* Badness */
- }
- p = nextblk(p, size);
- }
- if (p > (Dblk) _ubound) {
- error("malloc_verify: heap corrupted\n");
- return(0);
- }
- if (!cartesian(_root)){
- error("malloc_verify: free space tree corrupted\n");
- return(0);
- }
- return(1);
-}
-
-/*
- * The following is a kludge to avoid dependency on stdio, which
- * uses malloc() and free(), one of which probably got us here in
- * the first place.
- */
-
-#define putchar(c) (*buf++ = (c))
-extern int fileno(); /*bletch*/
-#define stderr 2 /*bletch*/
-#define LBUFSIZ 256
-
-static char stderrbuf[LBUFSIZ];
-
-/*
- * Error routine.
- * If debug_level == 0, does nothing except set errno = EINVAL.
- * Otherwise, prints an error message to stderr and generates a
- * core image.
- */
-static void
-error(char *fmt, ...)
-{
- static int n = 0; /* prevents infinite recursion when using stdio */
- int nbytes;
- va_list ap;
-
- errno = EINVAL;
- if (debug_level == 0)
- return;
- if (!n++) {
- va_start(ap, fmt);
- nbytes = vsprintf(stderrbuf, fmt, ap);
- va_end(ap);
- stderrbuf[nbytes++] = '\n';
- stderrbuf[nbytes] = '\0';
- write(fileno(stderr), stderrbuf, nbytes);
- }
- abort();
-}
-
-#endif /* DEBUG <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
diff --git a/usr/src/lib/libbc/libc/gen/common/mallopt.c b/usr/src/lib/libbc/libc/gen/common/mallopt.c
deleted file mode 100644
index 2d78e18333..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mallopt.c
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1986 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "mallint.h"
-#include <errno.h>
-
-/*
- * mallopt -- System V-compatible malloc "optimizer"
- */
-int
-mallopt(int cmd, int value)
-{
- if (__mallinfo.smblks != 0)
- return (-1); /* small block has been allocated */
-
- switch (cmd) {
- case M_MXFAST: /* small block size */
- if (value < 0)
- return (-1);
- __mallinfo.mxfast = value;
- break;
-
- case M_NLBLKS: /* # small blocks per holding block */
- if (value <= 0)
- return (-1);
- __mallinfo.nlblks = value;
- break;
-
- case M_GRAIN: /* small block rounding factor */
- if (value <= 0)
- return (-1);
- /* round up to multiple of minimum alignment */
- __mallinfo.grain = roundup(value, ALIGNSIZ);
- break;
-
- case M_KEEP: /* Sun algorithm always preserves data */
- break;
-
- default:
- return (-1);
- }
-
- /* make sure that everything is consistent */
- __mallinfo.mxfast = roundup(__mallinfo.mxfast, __mallinfo.grain);
-
- return (0);
-}
-
-
-/*
- * mallinfo -- System V-compatible malloc information reporter
- */
-struct mallinfo
-mallinfo(void)
-{
- struct mallinfo mi;
-
- mi = __mallinfo;
- mi.uordblks = mi.uordbytes - (mi.allocated * sizeof(uint));
- mi.fordblks = mi.arena - (mi.treeoverhead + mi.uordblks +
- (mi.ordblks * sizeof(uint)));
- return (mi);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/mbextern.h b/usr/src/lib/libbc/libc/gen/common/mbextern.h
deleted file mode 100644
index b858e7e321..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mbextern.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifndef lint
-/* static char *sccsid = "%Z%%M% %I% %E% SMI"; */
-#endif
-
-/*
- * external declaration for mb* routines
- */
-
-extern struct _code_set_info _code_set_info;
diff --git a/usr/src/lib/libbc/libc/gen/common/mblib.c b/usr/src/lib/libbc/libc/gen/common/mblib.c
deleted file mode 100644
index c28860d83a..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mblib.c
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * misc routines
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include "codeset.h"
-#include "mbextern.h"
-#include <dlfcn.h>
-
-static void *handle = (void *)NULL; /* initialize it with NULL */
-
-/*
- * Close current library library
- */
-int
-_ml_close_library(void)
-{
- if (handle == (void *)NULL) {
- _code_set_info.open_flag = NULL;
- return (-1);
- }
-
- dlclose(handle);
- _code_set_info.open_flag = NULL;
- handle = (void *)NULL;
- return (0);
-}
-
-/*
- * Open the given library
- */
-void *
-_ml_open_library(void)
-{
- char buf[BUFSIZ];
-
- if (handle != (void *)NULL) /* This library is already opened */
- return (handle);
-
- /*
- * Open the given library
- */
- strcpy(buf, LIBRARY_PATH);
- strcat(buf, _code_set_info.code_name);
- strcat(buf, ".so");
-#ifdef DEBUG
- printf ("ml_open_library: buf = '%s'\n", buf);
-#endif
- handle = dlopen(buf, 1);
- if (handle != (void *)NULL)
- _code_set_info.open_flag = 1;
-#ifdef DEBUG
- else
- printf ("_ml_open_library: dlopen failed\n");
-#endif
- return (handle);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/mbstowcs.c b/usr/src/lib/libbc/libc/gen/common/mbstowcs.c
deleted file mode 100644
index 1216ccbd45..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mbstowcs.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * mbstowcs
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#if !defined(lint) && defined(SCCSIDS)
-static char *sccsid = "%Z%%M% %I% %E% SMI";
-#endif
-
-#include <sys/types.h>
-#include "codeset.h"
-#include "mbextern.h"
-
-int
-mbstowcs(pwcs, s, n)
- wchar_t * pwcs;
- char *s;
- size_t n;
-{
- char *handle; /* handle */
- int (*p)();
- int num = 0;
- int ret;
-
- switch (_code_set_info.code_id) {
- case CODESET_NONE:
- /*
- * default code set,
- */
- while (*s && num < n) {
- *pwcs++ = (wchar_t)*s++;
- num++;
- }
- if (num < n)
- *pwcs = 0;
- return (num);
- break;
- case CODESET_EUC:
- /*
- * EUC code set
- */
- return(_mbstowcs_euc(pwcs, s, n));
- break;
-
- case CODESET_XCCS:
- /*
- * XCCS code set
- */
- return(_mbstowcs_xccs(pwcs, s, n));
- break;
-
- case CODESET_ISO2022:
- /*
- * ISO family
- */
- return(_mbstowcs_iso(pwcs, s, n));
- break;
-
- default:
- /*
- * User defined code set
- */
- handle = _ml_open_library();
- if (handle == (void *)NULL)
- return(ERROR_NO_LIB); /* No user library */
- p = (int (*)()) dlsym(handle, "_mbstowcs");
- if (p == (int (*)()) NULL)
- return(ERROR_NO_SYM);
- ret = (*p)(pwcs, s, n);
- return (ret);
- break;
- }
- /* NOTREACHED */
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/mbtowc.c b/usr/src/lib/libbc/libc/gen/common/mbtowc.c
deleted file mode 100644
index 9fbedb48c9..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mbtowc.c
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * mbtowc
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#if !defined(lint) && defined(SCCSIDS)
-static char *sccsid = "%Z%%M% %I% %E% SMI";
-#endif
-
-#include <stdlib.h>
-#include "codeset.h"
-#include "mbextern.h"
-
-#undef mblen
-
-int
-mbtowc(pwc, s, n)
- wchar_t * pwc;
- char *s;
- size_t n;
-{
- char *handle; /* handle */
- int (*p)();
- int ret;
-
- switch (_code_set_info.code_id) {
- case CODESET_NONE:
-#ifdef DEBUG
- printf ("DEFAULT: mbtowc invoked\n");
-#endif
- /*
- * This is a default code set
- */
- if (s == NULL)
- return (1);
- else {
- if (pwc != NULL)
- *pwc = (unsigned char)*s;
- return (1);
- }
- break;
- case CODESET_EUC:
-#ifdef DEBUG
- printf ("EUC: mbtowc invoked\n");
-#endif
- /*
- * EUC code set
- */
- return(_mbtowc_euc(pwc, s, n));
- break;
-
- case CODESET_XCCS:
-#ifdef DEBUG
- printf ("XCCS: mbtowc invoked\n");
-#endif
- /*
- * XCCS code set
- */
- return(_mbtowc_xccs(pwc, s, n));
- break;
-
- case CODESET_ISO2022:
-#ifdef DEBUG
- printf ("ISO2022: mbtowc invoked\n");
-#endif
- /*
- * ISO family
- */
- return(_mbtowc_iso(pwc, s, n));
- break;
-
- default:
- /*
- * User defined code set
- */
- handle = _ml_open_library();
- if (handle == (char *)NULL)
- return(ERROR_NO_LIB); /* No user library */
- p = (int (*)()) dlsym(handle, "_mbtowc");
- if (p == (int (*)()) NULL)
- return(ERROR_NO_SYM);
- ret = (*p)(pwc, s, n);
- return (ret);
- break;
- }
- /* NOTREACHED */
-}
-
-int mblen(s, n)
-register char *s; int n;
-{
- int val;
-
- if (_code_set_info.code_id != CODESET_ISO2022)
- return (mbtowc((wchar_t *)0, s, n));
- else {
- /*
- * ISO's mbtowc() changes 'states'.
- */
- _savestates();
- val = mbtowc((wchar_t *)0, s, n);
- _restorestates();
- return (val);
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/memalign.c b/usr/src/lib/libbc/libc/gen/common/memalign.c
deleted file mode 100644
index a71c2a06f8..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/memalign.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "mallint.h"
-#include <errno.h>
-
-extern int errno;
-
-/*
- * memalign(align,nbytes)
- *
- * Description:
- * Returns a block of specified size on a specified alignment boundary.
- *
- * Algorithm:
- * Malloc enough to ensure that a block can be aligned correctly.
- * Find the alignment point and return the fragments
- * before and after the block.
- *
- * Errors:
- * Returns NULL and sets errno as follows:
- * [EINVAL]
- * if nbytes = 0,
- * or if alignment is misaligned,
- * or if the heap has been detectably corrupted.
- * [ENOMEM]
- * if the requested memory could not be allocated.
- */
-
-char *
-memalign(align, nbytes)
- uint align;
- uint nbytes;
-{
- uint reqsize; /* Num of bytes to get from malloc() */
- register char *p; /* Ptr returned from malloc() */
- register Dblk blk; /* For addressing fragment blocks */
- register uint blksize; /* Current (shrinking) block size */
- register char *alignedp; /* Ptr to properly aligned boundary */
- register Dblk aligned_blk; /* The block to be returned */
- register uint frag_size; /* size of fragments fore and aft */
- uint x; /* ccom can't do (char*)(uint/uint) */
-
- /*
- * check for valid size and alignment parameters
- */
- if (nbytes == 0 || misaligned(align)) {
- errno = EINVAL;
- return NULL;
- }
-
- /*
- * Malloc enough memory to guarantee that the result can be
- * aligned correctly. The worst case is when malloc returns
- * a block so close to the next alignment boundary that a
- * fragment of minimum size cannot be created.
- */
- nbytes = roundup(nbytes, ALIGNSIZ);
- reqsize = nbytes + align + SMALLEST_BLK;
- p = malloc(reqsize);
- if (p == NULL) {
- return NULL;
- }
-
- /*
- * get size of the entire block (overhead and all)
- */
- blk = (Dblk)(p - ALIGNSIZ); /* back up to get length word */
- blksize = blk->size;
-
- /*
- * locate the proper alignment boundary within the block.
- */
- x = roundup((uint)p, align); /* ccom work-around */
- alignedp = (char *)x;
- aligned_blk = (Dblk)(alignedp - ALIGNSIZ);
-
- /*
- * Check out the space to the left of the alignment
- * boundary, and split off a fragment if necessary.
- */
- frag_size = (uint)aligned_blk - (uint)blk;
- if (frag_size != 0) {
- /*
- * Create a fragment to the left of the aligned block.
- */
- if ( frag_size < SMALLEST_BLK ) {
- /*
- * Not enough space. So make the split
- * at the other end of the alignment unit.
- */
- frag_size += align;
- aligned_blk = nextblk(aligned_blk,align);
- }
- blk->size = frag_size;
- blksize -= frag_size;
- aligned_blk->size = blksize;
- free(blk->data);
- }
-
- /*
- * Is there a (sufficiently large) fragment to the
- * right of the aligned block?
- */
- nbytes += ALIGNSIZ;
- frag_size = blksize - nbytes;
- if (frag_size > SMALLEST_BLK) {
- /*
- * split and free a fragment on the right
- */
- blk = nextblk(aligned_blk, nbytes);
- blk->size = frag_size;
- aligned_blk->size -= frag_size;
- free(blk->data);
- }
- return(aligned_blk->data);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/memccpy.c b/usr/src/lib/libbc/libc/gen/common/memccpy.c
deleted file mode 100644
index cbdc8b0db2..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/memccpy.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.1 */
-
-/*LINTLIBRARY*/
-/*
- * Copy s2 to s1, stopping if character c is copied. Copy no more than n bytes.
- * Return a pointer to the byte after character c in the copy,
- * or NULL if c is not found in the first n bytes.
- */
-char *
-memccpy(s1, s2, c, n)
-register char *s1, *s2;
-register int c, n;
-{
- while (--n >= 0)
- if ((*s1++ = *s2++) == c)
- return (s1);
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/memchr.c b/usr/src/lib/libbc/libc/gen/common/memchr.c
deleted file mode 100644
index 89754259dd..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/memchr.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.1 */
-
-/*LINTLIBRARY*/
-/*
- * Return the ptr in sp at which the character c appears;
- * NULL if not found in n chars; don't stop at \0.
- */
-char *
-memchr(sp, c, n)
-register char *sp, c;
-register int n;
-{
- while (--n >= 0)
- if (*sp++ == c)
- return (--sp);
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/memcmp.c b/usr/src/lib/libbc/libc/gen/common/memcmp.c
deleted file mode 100644
index f4439d8005..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/memcmp.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.1 */
-
-/*LINTLIBRARY*/
-/*
- * Compare n bytes: s1>s2: >0 s1==s2: 0 s1<s2: <0
- */
-int
-memcmp(s1, s2, n)
-register char *s1, *s2;
-register int n;
-{
- int diff;
-
- if (s1 != s2)
- while (--n >= 0)
- if (diff = *s1++ - *s2++)
- return (diff);
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/mkstemp.c b/usr/src/lib/libbc/libc/gen/common/mkstemp.c
deleted file mode 100644
index 579044ff80..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mkstemp.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/file.h>
-
-int
-mkstemp(char *as)
-{
- char *s;
- unsigned int pid;
- int fd, i;
-
- pid = getpid();
- s = as;
- while (*s++)
- /* void */;
- s--;
- while (*--s == 'X') {
- *s = (pid % 10) + '0';
- pid /= 10;
- }
- s++;
- i = 'a';
- while ((fd = open(as, O_CREAT|O_EXCL|O_RDWR, 0600)) == -1) {
- if (i == 'z')
- return (-1);
- *s = i++;
- }
- return (fd);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/mktemp.c b/usr/src/lib/libbc/libc/gen/common/mktemp.c
deleted file mode 100644
index 8373996607..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mktemp.c
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R3 1.11 */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-
-/*LINTLIBRARY*/
-/****************************************************************
- * Routine expects a string of length at least 6, with
- * six trailing 'X's. These will be overlaid with a
- * letter and the last (5) digigts of the proccess ID.
- * If every letter (a thru z) thus inserted leads to
- * an existing file name, your string is shortened to
- * length zero upon return (first character set to '\0').
- ***************************************************************/
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#define XCNT 6
-
-extern int strlen(), access(), getpid();
-
-char *
-mktemp(as)
-char *as;
-{
- register char *s=as;
- register unsigned pid;
- register unsigned xcnt=0; /* keeps track of number of X's seen */
- struct stat buf;
-
- pid = getpid();
- s += strlen(as); /* point at the terminal null */
- while(*--s == 'X' && ++xcnt <= XCNT) {
- *s = (pid%10) + '0';
- pid /= 10;
- }
- if(*++s) { /* maybe there were no 'X's */
- *s = 'a';
- while (stat(as, &buf) == 0) {
- if(++*s > 'z') {
- *as = '\0';
- break;
- }
- }
- } else
- if (stat(as, &buf) == 0)
- *as = '\0';
- return(as);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/mlock.c b/usr/src/lib/libbc/libc/gen/common/mlock.c
deleted file mode 100644
index 1e9e1b1a12..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mlock.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <errno.h>
-
-/*
- * Function to lock address range in memory.
- */
-
-/*LINTLIBRARY*/
-int
-mlock(caddr_t addr, u_int len)
-{
- if((int)len <= 0) {
- errno = EINVAL;
- return (-1);
- }
- return (mctl(addr, len, MC_LOCK, 0));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/mlockall.c b/usr/src/lib/libbc/libc/gen/common/mlockall.c
deleted file mode 100644
index 8bb08dc047..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mlockall.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-
-/*
- * Function to lock address space in memory.
- */
-
-/*LINTLIBRARY*/
-int
-mlockall(int flags)
-{
-
- return (mctl(0, 0, MC_LOCKAS, flags));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/mntent.c b/usr/src/lib/libbc/libc/gen/common/mntent.c
deleted file mode 100644
index 8a0b8ac375..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/mntent.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <mntent.h>
-#include <sys/file.h>
-#include <malloc.h>
-
-static int mntprtent(FILE *, struct mntent *);
-
-static struct mntent *mntp;
-
-struct mntent *
-_mnt(void)
-{
-
- if (mntp == 0)
- mntp = (struct mntent *)calloc(1, sizeof (struct mntent));
- return (mntp);
-}
-
-static char *
-mntstr(char **p)
-{
- unsigned char *cp = (unsigned char *) *p;
- unsigned char *retstr;
-
- while (*cp && isspace(*cp))
- cp++;
- retstr = cp;
- while (*cp && !isspace(*cp))
- cp++;
- if (*cp) {
- *cp = '\0';
- cp++;
- }
- *p = (char *) cp;
- return ((char *)retstr);
-}
-
-static int
-mntdigit(char **p)
-{
- int value = 0;
- unsigned char *cp = (unsigned char *) *p;
-
- while (*cp && isspace(*cp))
- cp++;
- for (; *cp && isdigit(*cp); cp++) {
- value *= 10;
- value += *cp - '0';
- }
- while (*cp && !isspace(*cp))
- cp++;
- if (*cp) {
- *cp = '\0';
- cp++;
- }
- *p = (char *) cp;
- return (value);
-}
-
-static int
-mnttabscan(FILE *mnttabp, struct mntent *mnt)
-{
- static char *line = NULL;
- char *cp;
-
- if (line == NULL)
- line = (char *)malloc(BUFSIZ+1);
- do {
- cp = fgets(line, BUFSIZ, mnttabp);
- if (cp == NULL) {
- return (EOF);
- }
- } while (*cp == '#');
- mnt->mnt_fsname = mntstr(&cp);
- if (*cp == '\0')
- return (1);
- mnt->mnt_dir = mntstr(&cp);
- if (*cp == '\0')
- return (2);
- mnt->mnt_type = mntstr(&cp);
- if (*cp == '\0')
- return (3);
- mnt->mnt_opts = mntstr(&cp);
- if (*cp == '\0')
- return (4);
- mnt->mnt_freq = mntdigit(&cp);
- if (*cp == '\0')
- return (5);
- mnt->mnt_passno = mntdigit(&cp);
- return (6);
-}
-
-FILE *
-setmntent(char *fname, char *flag)
-{
- FILE *mnttabp;
-
- if ((mnttabp = fopen(fname, flag)) == NULL) {
- return (NULL);
- }
- for (; *flag ; flag++) {
- if (*flag == 'w' || *flag == 'a' || *flag == '+') {
- if (flock(fileno(mnttabp), LOCK_EX) < 0) {
- fclose(mnttabp);
- return (NULL);
- }
- break;
- }
- }
- return (mnttabp);
-}
-
-int
-endmntent(FILE *mnttabp)
-{
-
- if (mnttabp) {
- fclose(mnttabp);
- }
- return (1);
-}
-
-struct mntent *
-getmntent(FILE *mnttabp)
-{
- int nfields;
-
- if (mnttabp == 0)
- return ((struct mntent *)0);
- if (_mnt() == 0)
- return ((struct mntent *)0);
- nfields = mnttabscan(mnttabp, mntp);
- if (nfields == EOF || nfields != 6)
- return ((struct mntent *)0);
- return (mntp);
-}
-
-int
-addmntent(FILE *mnttabp, struct mntent *mnt)
-{
- if (fseek(mnttabp, 0L, 2) < 0)
- return (1);
- if (mnt == (struct mntent *)0)
- return (1);
- if (mnt->mnt_fsname == NULL || mnt->mnt_dir == NULL ||
- mnt->mnt_type == NULL || mnt->mnt_opts == NULL)
- return (1);
-
- mntprtent(mnttabp, mnt);
- return (0);
-}
-
-static char *
-mntopt(char **p)
-{
- unsigned char *cp = (unsigned char *) *p;
- unsigned char *retstr;
-
- while (*cp && isspace(*cp))
- cp++;
- retstr = cp;
- while (*cp && *cp != ',')
- cp++;
- if (*cp) {
- *cp = '\0';
- cp++;
- }
- *p = (char *) cp;
- return ((char *)retstr);
-}
-
-char *
-hasmntopt(struct mntent *mnt, char *opt)
-{
- char *f, *opts;
- static char *tmpopts;
-
- if (tmpopts == 0) {
- tmpopts = (char *)calloc(256, sizeof (char));
- if (tmpopts == 0)
- return (0);
- }
- strcpy(tmpopts, mnt->mnt_opts);
- opts = tmpopts;
- f = mntopt(&opts);
- for (; *f; f = mntopt(&opts)) {
- if (strncmp(opt, f, strlen(opt)) == 0)
- return (f - tmpopts + mnt->mnt_opts);
- }
- return (NULL);
-}
-
-static int
-mntprtent(FILE *mnttabp, struct mntent *mnt)
-{
- fprintf(mnttabp, "%s %s %s %s %d %d\n",
- mnt->mnt_fsname,
- mnt->mnt_dir,
- mnt->mnt_type,
- mnt->mnt_opts,
- mnt->mnt_freq,
- mnt->mnt_passno);
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/modf.c b/usr/src/lib/libbc/libc/gen/common/modf.c
deleted file mode 100644
index 3ce1bb8256..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/modf.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI" /* from ATT S5R3 */
-
-/* The following is extracted from... */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-
-/*
- * modf(value, iptr) returns the signed fractional part of value
- * and stores the integer part indirectly through iptr.
- *
- */
-
-#define MAXPOWTWO 4.503599627370496000E+15
- /* doubles >= MAXPOWTWO are already integers */
-double
-modf(value, iptr)
-double value;
-register double *iptr;
-{
- register double absvalue;
-
- if ((absvalue = (value >= 0.0) ? value : -value) >= MAXPOWTWO)
- *iptr = value; /* it must be an integer */
- else {
- *iptr = absvalue + MAXPOWTWO; /* shift fraction off right */
- *iptr -= MAXPOWTWO; /* shift back without fraction */
- while (*iptr > absvalue) /* above arithmetic might round */
- *iptr -= 1.0; /* test again just to be sure */
- if (value < 0.0)
- *iptr = -*iptr;
- }
- return (value - *iptr); /* signed fractional part */
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/msync.c b/usr/src/lib/libbc/libc/gen/common/msync.c
deleted file mode 100644
index f96b5bd811..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/msync.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <errno.h>
-
-/*
- * Function to synchronize address range with backing store.
- */
-
-/*LINTLIBRARY*/
-int
-msync(caddr_t addr, u_int len, int flags)
-{
- if ((int)len <= 0) {
- errno = EINVAL;
- return (-1);
- }
- return (mctl(addr, len, MC_SYNC, flags));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/munlock.c b/usr/src/lib/libbc/libc/gen/common/munlock.c
deleted file mode 100644
index 3576de146f..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/munlock.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-
-/*
- * Function to unlock address range from memory.
- */
-
-/*LINTLIBRARY*/
-int
-munlock(caddr_t addr, u_int len)
-{
-
- return (mctl(addr, len, MC_UNLOCK, 0));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/munlockall.c b/usr/src/lib/libbc/libc/gen/common/munlockall.c
deleted file mode 100644
index 0141c40306..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/munlockall.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include <sys/mman.h>
-
-/*
- * Function to unlock address space from memory.
- */
-
-/*LINTLIBRARY*/
-int
-munlockall(void)
-{
-
- return (mctl(0, 0, MC_UNLOCKAS, 0));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/ndbm.c b/usr/src/lib/libbc/libc/gen/common/ndbm.c
deleted file mode 100644
index 78676d16eb..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ndbm.c
+++ /dev/null
@@ -1,899 +0,0 @@
-/*
- * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- * Copyright (c) 2016 by Delphix. All rights reserved.
- */
-
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/file.h>
-#include <stdio.h>
-#include <errno.h>
-#include <ndbm.h>
-#include <stdlib.h>
-#include <string.h>
-
-datum dbm_do_nextkey(DBM *, datum);
-
-
-/*add support for batched writing for NIS*/
-
-#define _DBM_DEFWRITE 0x4
-#define _DBM_DIRTY 0x8
-#define _DBM_DIRDIRTY 0x10
-#define dbm_dirty(db) ((db)->dbm_flags & _DBM_DIRTY)
-#define dbm_dirdirty(db) ((db)->dbm_flags & _DBM_DIRDIRTY)
-#define dbm_defwrite(db) ((db)->dbm_flags & _DBM_DEFWRITE)
-#define dbm_setdirty(db) (db)->dbm_flags |= _DBM_DIRTY
-#define dbm_clrdirty(db) (db)->dbm_flags &= ~_DBM_DIRTY
-#define dbm_setdirdirty(db) (db)->dbm_flags |= _DBM_DIRDIRTY
-#define dbm_clrdirdirty(db) (db)->dbm_flags &= ~_DBM_DIRDIRTY
-
-
-static void dbm_access(DBM *, long);
-static int getbit(DBM *);
-static int setbit(DBM *);
-static int cmpdatum(datum, datum);
-static int finddatum(char [PBLKSIZ], datum);
-static int delitem(char [PBLKSIZ], int);
-static int additem(char [PBLKSIZ], datum, datum);
-static datum makdatum(char [PBLKSIZ], int);
-static long dcalchash(datum);
-
-/*used to make a dbm file all at once instead of incrementally*/
-void
-dbm_setdefwrite(DBM *db)
-{
- db->dbm_flags |= _DBM_DEFWRITE;
-}
-
-int
-dbm_flush(DBM *db)
-{
- int ok=0;
- if (dbm_flushpag(db)<0) ok= -1;
- if (dbm_flushdir(db)<0) ok= -1;
- return(ok);
-}
-
-int
-dbm_flushpag(DBM *db)
-{
- int ok=0;
- if (dbm_dirty(db)){ /*must page out the page*/
- (void) lseek(db->dbm_pagf, (long)(db->dbm_pagbno*PBLKSIZ), L_SET);
- if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
- db->dbm_flags |= _DBM_IOERR;
- ok= -1;
- }
- dbm_clrdirty(db);
- }
- return(ok);
-}
-
-int
-dbm_flushdir(DBM *db)
-{
- int ok=0;
- if (dbm_dirdirty(db)){ /*must page out the dir*/
- (void) lseek(db->dbm_dirf, (long)(db->dbm_dirbno*DBLKSIZ), L_SET);
- if (write(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ) {
- ok= -1;
- }
- dbm_clrdirdirty(db);
- }
- return(ok);
-}
-#define BYTESIZ 8
-#undef setbit
-
-DBM *
-dbm_open(char *file, int flags, int mode)
-{
- struct stat statb;
- DBM *db;
- int serrno;
-
- if ((db = (DBM *)malloc(sizeof *db)) == 0) {
- errno = ENOMEM;
- return ((DBM *)0);
- }
- db->dbm_flags = (flags & 03) == O_RDONLY ? _DBM_RDONLY : 0;
- if ((flags & 03) == O_WRONLY)
- flags = (flags & ~03) | O_RDWR;
- if (strlcpy(db->dbm_pagbuf, file, sizeof (db->dbm_pagbuf)) >=
- sizeof (db->dbm_pagbuf) ||
- strlcat(db->dbm_pagbuf, ".pag", sizeof (db->dbm_pagbuf)) >=
- sizeof (db->dbm_pagbuf)) {
- /*
- * file.pag does not fit into dbm_pagbuf.
- * fails with ENAMETOOLONG.
- */
- serrno = ENAMETOOLONG;
- goto bad;
- }
- db->dbm_pagf = open(db->dbm_pagbuf, flags, mode);
- if (db->dbm_pagf < 0) {
- serrno = errno;
- goto bad;
- }
- /*
- * We know this won't overflow so it is safe to ignore the
- * return value; we use strl* to prevent false hits in
- * code sweeps.
- */
- (void) strlcpy(db->dbm_pagbuf, file, sizeof (db->dbm_pagbuf));
- (void) strlcat(db->dbm_pagbuf, ".dir", sizeof (db->dbm_pagbuf));
- db->dbm_dirf = open(db->dbm_pagbuf, flags, mode);
- if (db->dbm_dirf < 0) {
- serrno = errno;
- goto bad1;
- }
- (void) fstat(db->dbm_dirf, &statb);
- db->dbm_maxbno = statb.st_size*BYTESIZ-1;
- db->dbm_pagbno = db->dbm_dirbno = -1;
- return (db);
-bad1:
- (void) close(db->dbm_pagf);
-bad:
- free((char *)db);
- errno = serrno;
- return ((DBM *)0);
-}
-
-void
-dbm_close(DBM *db)
-{
- (void) dbm_close_status(db);
-}
-
-/*close with return code*/
-int
-dbm_close_status(DBM *db)
-{
- int ok;
- ok=0;
-
- if (dbm_flush(db) <0) ok = -1;
- if (close(db->dbm_dirf)<0) ok= -1;
- if ( close(db->dbm_pagf)<0) ok= -1;
- free((char *)db);
- return (ok);
-}
-
-long
-dbm_forder(DBM *db, datum key)
-{
- long hash;
-
- hash = dcalchash(key);
- for (db->dbm_hmask=0;; db->dbm_hmask=(db->dbm_hmask<<1)+1) {
- db->dbm_blkno = hash & db->dbm_hmask;
- db->dbm_bitno = db->dbm_blkno + db->dbm_hmask;
- if (getbit(db) == 0)
- break;
- }
- return (db->dbm_blkno);
-}
-
-datum
-dbm_fetch(DBM *db, datum key)
-{
- int i;
- datum item;
-
- if (dbm_error(db))
- goto err;
- dbm_access(db, dcalchash(key));
- if ((i = finddatum(db->dbm_pagbuf, key)) >= 0) {
- item = makdatum(db->dbm_pagbuf, i+1);
- if (item.dptr != NULL)
- return (item);
- }
-err:
- item.dptr = NULL;
- item.dsize = 0;
- return (item);
-}
-
-int
-dbm_delete(DBM *db, datum key)
-{
- int i;
-
- if (dbm_error(db))
- return (-1);
- if (dbm_rdonly(db)) {
- errno = EPERM;
- return (-1);
- }
- dbm_access(db, dcalchash(key));
- if ((i = finddatum(db->dbm_pagbuf, key)) < 0)
- return (-1);
- if (!delitem(db->dbm_pagbuf, i))
- goto err;
- db->dbm_pagbno = db->dbm_blkno;
- if (dbm_defwrite(db)) {
- dbm_setdirty(db);
- }
- else {
- (void) lseek(db->dbm_pagf, (long)(db->dbm_blkno*PBLKSIZ), L_SET);
- if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
- err:
- db->dbm_flags |= _DBM_IOERR;
- return (-1);
- }
- }
- return (0);
-}
-
-int
-dbm_store(DBM *db, datum key, datum dat, int replace)
-{
- int i;
- datum item, item1;
- char ovfbuf[PBLKSIZ];
-
- if (dbm_error(db))
- return (-1);
- if (dbm_rdonly(db)) {
- errno = EPERM;
- return (-1);
- }
-loop:
- dbm_access(db, dcalchash(key));
- if ((i = finddatum(db->dbm_pagbuf, key)) >= 0) {
- if (!replace)
- return (1);
- if (!delitem(db->dbm_pagbuf, i)) {
- db->dbm_flags |= _DBM_IOERR;
- return (-1);
- }
- }
- if (!additem(db->dbm_pagbuf, key, dat))
- goto split;
- db->dbm_pagbno = db->dbm_blkno;
- if (dbm_defwrite(db)) {
- dbm_setdirty(db);
- }
- else {
-
- (void) lseek(db->dbm_pagf, (long)(db->dbm_blkno*PBLKSIZ), L_SET);
- if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
- db->dbm_flags |= _DBM_IOERR;
- return (-1);
- }
- }
- return (0);
-
-split:
- if (key.dsize+dat.dsize+3*sizeof(short) >= PBLKSIZ) {
- db->dbm_flags |= _DBM_IOERR;
- errno = ENOSPC;
- return (-1);
- }
- bzero(ovfbuf, PBLKSIZ);
- for (i=0;;) {
- item = makdatum(db->dbm_pagbuf, i);
- if (item.dptr == NULL)
- break;
- if (dcalchash(item) & (db->dbm_hmask+1)) {
- item1 = makdatum(db->dbm_pagbuf, i+1);
- if (item1.dptr == NULL) {
- /*(void) fprintf(stderr, "ndbm: split not paired\n");*/
- db->dbm_flags |= _DBM_IOERR;
- break;
- }
- if (!additem(ovfbuf, item, item1) ||
- !delitem(db->dbm_pagbuf, i)) {
- db->dbm_flags |= _DBM_IOERR;
- return (-1);
- }
- continue;
- }
- i += 2;
- }
- db->dbm_pagbno = db->dbm_blkno;
- (void) lseek(db->dbm_pagf, (long)(db->dbm_blkno*PBLKSIZ), L_SET);
- if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
- db->dbm_flags |= _DBM_IOERR;
- return (-1);
- }
- dbm_clrdirty(db); /*clear dirty*/
- (void) lseek(db->dbm_pagf,
- (long)((db->dbm_blkno+db->dbm_hmask+1)*PBLKSIZ), L_SET);
- if (write(db->dbm_pagf, ovfbuf, PBLKSIZ) != PBLKSIZ) {
- db->dbm_flags |= _DBM_IOERR;
- return (-1);
- }
- if (setbit(db) < 0) {
- db->dbm_flags |= _DBM_IOERR;
- return (-1);
- }
- goto loop;
-}
-
-static long
-dbm_hashinc(DBM *db, long hash)
-{
-
- long bit;
-
- hash &= db->dbm_hmask;
- bit = db->dbm_hmask+1;
- for(;;) {
- bit >>= 1;
- if(bit == 0)
- return(0L);
- if((hash&bit) == 0)
- return(hash|bit);
- hash &= ~bit;
- }
-}
-
-
-
-static datum nullkey= {NULL, 0};
-
-datum
-dbm_firsthash(DBM *db, long hash)
-{
- int i,j;
- datum item, bitem;
-
-loop:
- dbm_access(db, hash);
- j=0;
- bitem = makdatum(db->dbm_pagbuf, 0);
- for(i=2;; i+=2) {
- item = makdatum(db->dbm_pagbuf, i);
- if(item.dptr == NULL)
- break;
- if(cmpdatum(bitem, item) < 0) {
- j=i;
- bitem = item;
- }
- }
- if(bitem.dptr != NULL) {
- db->dbm_keyptr = j + 2;
- db->dbm_blkptr = db->dbm_blkno;
- return(bitem);
- }
- hash = dbm_hashinc(db,hash);
- if(hash == 0)
- return(item); /*null item*/
- goto loop;
-
-}
-
-datum
-dbm_firstkey(DBM *db)
-{
-
- db->dbm_blkptr = 0L;
- db->dbm_keyptr = 0;
- return (dbm_firsthash(db, 0L));
-}
-
-datum
-dbm_nextkey(DBM *db)
-{
-
- return (dbm_do_nextkey(db, nullkey));
-}
-
-/*this is used if keyptr-2,blocknum doesn't point to the previous
-specific key allowing the fast hash order search --
-its use indicates user tampering with our state variables,
-which some evil users might do to search from some specific place.
-It finds the first key at or after blkptr,keyptr in block seq order
-this requires looking at all sorts of emtpy blocks in many cases*/
-
-static datum
-dbm_slow_nextkey(DBM *db)
-{
- struct stat statb;
- datum item;
-
- if (dbm_error(db) || fstat(db->dbm_pagf, &statb) < 0)
- goto err;
- statb.st_size /= PBLKSIZ;
-
- for (;;) {
- if (db->dbm_blkptr != db->dbm_pagbno) {
-
- if (dbm_dirty(db)) dbm_flushpag(db);
-
- db->dbm_pagbno = db->dbm_blkptr;
- (void) lseek(db->dbm_pagf, (long)(db->dbm_blkptr*PBLKSIZ), L_SET);
- if (read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ)
- bzero(db->dbm_pagbuf, PBLKSIZ);
-#ifdef DEBUG
- else if (chkblk(db->dbm_pagbuf) < 0)
- db->dbm_flags |= _DBM_IOERR;
-#endif
- }
- /*Am I an empty block?*/
- if (((short *)db->dbm_pagbuf)[0] != 0) {
- item = makdatum(db->dbm_pagbuf, db->dbm_keyptr);
- if (item.dptr != NULL) {
- db->dbm_keyptr += 2;
- return (item);
- }
- db->dbm_keyptr = 0;
- }
- /*go to next sequential block*/
- if (++db->dbm_blkptr >= statb.st_size)
- break;
- }
-err:
- item.dptr = NULL;
- item.dsize = 0;
- return (item);
-}
-
-datum
-dbm_do_nextkey(DBM *db, datum inkey)
-{
- datum item,bitem;
- long hash;
- datum key;
- int f;
- int i;
- int j;
- short *sp;
- int n;
- char *p1, *p2;
-
- if ( dbm_error(db) ) {
- item.dptr = NULL;
- item.dsize = 0;
- return (item);
- }
-
- /*user has supplied lastkey*/
-
- if(inkey.dptr != NULL) {
- dbm_access(db, (hash=dcalchash(inkey)));
- if ((i = finddatum(db->dbm_pagbuf, inkey)) >= 0) {
- db->dbm_keyptr = i + 2;
- db->dbm_blkptr = db->dbm_blkno;
- }
- key=inkey;
- }
- else {
- /*is this a manual firstkey request? */
-
- if (db->dbm_blkptr == 0L &&
- db->dbm_keyptr == 0)
- return (dbm_firsthash(db, 0L));
-
- /*no -- get lastkey this is like dbm_access by blkptr*/
-
- if (db->dbm_blkptr != db->dbm_pagbno) {
-
- if (dbm_dirty(db)) dbm_flushpag(db);
- db->dbm_pagbno = db->dbm_blkptr;
- (void) lseek(db->dbm_pagf, (long)(db->dbm_blkptr*PBLKSIZ), L_SET);
- if (read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ)
- bzero(db->dbm_pagbuf, PBLKSIZ);
-#ifdef DEBUG
- else if (chkblk(db->dbm_pagbuf) < 0)
- db->dbm_flags |= _DBM_IOERR;
-#endif
- }
- /*now just make up last key datum*/
- if (db->dbm_keyptr >=2) key= makdatum(db->dbm_pagbuf,(db->dbm_keyptr-2));
- else key=nullkey;
-
- /* the keyptr pagbuf have failed us, the user must
- depend on these variables and their former meaning.
- If we set the variables this would have got
- us the key for sure! So give the user the old algorithm.*/
- if (key.dptr == NULL) return (dbm_slow_nextkey(db));
- }
-
- /*at this point the last key is paged in and
- we can proceed as in old dbm -- like Ken did his. */
-
- f = 1;
- j=0;
- sp = (short *)db->dbm_pagbuf;
-
- for(i=0;; i+=2) {
-
- /*begin put makdatum inline*/
-
- if ((unsigned)i >= sp[0]) {
- item.dptr = NULL;
- item.dsize = 0;
- break; /*from below*/
- }
- else {
- if (i > 0) item.dsize = sp[i] - sp[i+1];
- else item.dsize = PBLKSIZ - sp[i+1];
- item.dptr = db->dbm_pagbuf+sp[i+1];
- }
-
- /* item = makdatum(db->dbm_pagbuf, i);*/
- /*end put makdatum inline*/
-
- if(item.dptr == NULL)
- break;
-/*inline cmpdatum*/
-
-
- n = key.dsize;
- if(n != item.dsize)
- if( (n - item.dsize) <= 0 ) continue;
- else { }
- else {
- if(n == 0) continue;
- p1 = key.dptr;
- p2 = item.dptr;
- do
- if(*p1++ != *p2++)
- if((*--p1 - *--p2) > 0) goto keep_going;
- else continue;
- while(--n);
- continue;
- }
-
-keep_going:
-
-/*end inline cmpdatum*/
- /*if(cmpdatum(key, item) <= 0)
- continue;*/
- if (f) {
- bitem = item;
- j=i;
- f = 0;
- }
- else {
-
-/* if(cmpdatum(bitem, item) < 0)*/
-
- n = bitem.dsize;
- if(n != item.dsize)
- {
- if((n - item.dsize) <0) {
- bitem = item;
- j=i;
- }
- }
- else if (n != 0) {
- p1 = bitem.dptr;
- p2 = item.dptr;
- do
- if(*p1++ != *p2++) {
- if((*--p1 - *--p2) <0) {
- bitem = item;
- j=i;
- }
- break;
- }
- while(--n);
- }
- }
- }
-
- if(f == 0) {
- db->dbm_keyptr = j + 2;
- db->dbm_blkptr = db->dbm_blkno;
- return (bitem);
- }
-
- /* really need hash at this point */
- /* if it gave us a key we have already calculated the hash */
- /* if not get the hash */
- if (inkey.dptr == NULL) hash=dcalchash(key);
- hash = dbm_hashinc(db,hash);
-
- if(hash == 0)
- return (item); /*null*/
- /*get first item on next page in hash table order*/
- return (dbm_firsthash(db, hash));
-
-
-}
-
-static void
-dbm_access(DBM *db, long hash)
-{
- int b, i, n;
- long bn;
- long my_bitno;
- long my_hmask;
- long my_blkno;
-
- for (my_hmask=0;; my_hmask=(my_hmask<<1)+1) {
- my_blkno = hash & my_hmask;
- my_bitno = my_blkno + my_hmask;
- /*getbit inline*/
- if (my_bitno > db->dbm_maxbno) break;
- n = my_bitno % BYTESIZ;
- bn = my_bitno / BYTESIZ;
- i = bn % DBLKSIZ;
- b = bn / DBLKSIZ;
- if (b != db->dbm_dirbno) {
- if (dbm_dirdirty(db)) dbm_flushdir(db); /*must flush*/
- db->dbm_dirbno = b;
- (void) lseek(db->dbm_dirf, (long)(b*DBLKSIZ), L_SET);
- if (read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ)
- bzero(db->dbm_dirbuf, DBLKSIZ);
- }
- if ( (db->dbm_dirbuf[i] & (1<<n)) == 0 ) break;
-
- /*
- if (getbit(db) == 0)
- break;
- */
- }
- /*copy*/
- db->dbm_blkno=my_blkno;
- db->dbm_bitno=my_bitno;
- db->dbm_hmask=my_hmask;
-
- if (my_blkno != db->dbm_pagbno) {
- if (dbm_dirty(db)){ /*must page out the page*/
- (void) lseek(db->dbm_pagf, (long)(db->dbm_pagbno*PBLKSIZ), L_SET);
- if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
- db->dbm_flags |= _DBM_IOERR;
- }
- dbm_clrdirty(db);
- }
-
- db->dbm_pagbno = my_blkno;
- (void) lseek(db->dbm_pagf, (long)(my_blkno*PBLKSIZ), L_SET);
- if (read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ)
- bzero(db->dbm_pagbuf, PBLKSIZ);
-#ifdef DEBUG
- else if (chkblk(db->dbm_pagbuf) < 0)
- db->dbm_flags |= _DBM_IOERR;
-#endif
- }
-}
-
-static int
-getbit(DBM *db)
-{
- long bn;
- int b, i, n;
-
-
- if (db->dbm_bitno > db->dbm_maxbno)
- return (0);
- n = db->dbm_bitno % BYTESIZ;
- bn = db->dbm_bitno / BYTESIZ;
- i = bn % DBLKSIZ;
- b = bn / DBLKSIZ;
- if (b != db->dbm_dirbno) {
- if (dbm_dirdirty(db)) dbm_flushdir(db); /*must flush*/
- db->dbm_dirbno = b;
- (void) lseek(db->dbm_dirf, (long)(b*DBLKSIZ), L_SET);
- if (read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ)
- bzero(db->dbm_dirbuf, DBLKSIZ);
- }
- return (db->dbm_dirbuf[i] & (1<<n));
-}
-
-static int
-setbit(DBM *db)
-{
- long bn;
- int i, n, b;
-
- if (db->dbm_bitno > db->dbm_maxbno)
- db->dbm_maxbno = db->dbm_bitno;
- n = db->dbm_bitno % BYTESIZ;
- bn = db->dbm_bitno / BYTESIZ;
- i = bn % DBLKSIZ;
- b = bn / DBLKSIZ;
- if (b != db->dbm_dirbno) {
- if (dbm_dirdirty(db)) dbm_flushdir(db);
- db->dbm_dirbno = b;
- (void) lseek(db->dbm_dirf, (long)(b*DBLKSIZ), L_SET);
- if (read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ)
- bzero(db->dbm_dirbuf, DBLKSIZ);
- }
- db->dbm_dirbuf[i] |= 1<<n;
- db->dbm_dirbno = b;
- if (dbm_defwrite(db)) {
- dbm_setdirdirty(db);
- } else{
- (void) lseek(db->dbm_dirf, (long)(b*DBLKSIZ), L_SET);
- if (write(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ) {
- return (-1);
- }
- }
- return (0);
-}
-
-static datum
-makdatum(char buf[PBLKSIZ], int n)
-{
- short *sp;
- int t;
- datum item;
-
- sp = (short *)buf;
- if ((unsigned)n >= sp[0]) {
- item.dptr = NULL;
- item.dsize = 0;
- return (item);
- }
- t = PBLKSIZ;
- if (n > 0)
- t = sp[n];
- item.dptr = buf+sp[n+1];
- item.dsize = t - sp[n+1];
- return (item);
-}
-
-static int
-cmpdatum(datum d1, datum d2)
-{
- int n;
- char *p1, *p2;
-
- n = d1.dsize;
- if(n != d2.dsize)
- return(n - d2.dsize);
- if(n == 0)
- return(0);
- p1 = d1.dptr;
- p2 = d2.dptr;
- do
- if(*p1++ != *p2++)
- return(*--p1 - *--p2);
- while(--n);
- return(0);
-}
-
-static int
-finddatum(char buf[PBLKSIZ], datum item)
-{
- short *sp;
- int i, n, j;
-
- sp = (short *)buf;
- n = PBLKSIZ;
- for (i=0, j=sp[0]; i<j; i+=2, n = sp[i]) {
- n -= sp[i+1];
- if (n != item.dsize)
- continue;
- if (n == 0 || bcmp(&buf[sp[i+1]], item.dptr, n) == 0)
- return (i);
- }
- return (-1);
-}
-
-static int hitab[16]
- = { 61, 57, 53, 49, 45, 41, 37, 33,
- 29, 25, 21, 17, 13, 9, 5, 1,
-};
-
-static long hltab[64]
- = {
- 06100151277L,06106161736L,06452611562L,05001724107L,
- 02614772546L,04120731531L,04665262210L,07347467531L,
- 06735253126L,06042345173L,03072226605L,01464164730L,
- 03247435524L,07652510057L,01546775256L,05714532133L,
- 06173260402L,07517101630L,02431460343L,01743245566L,
- 00261675137L,02433103631L,03421772437L,04447707466L,
- 04435620103L,03757017115L,03641531772L,06767633246L,
- 02673230344L,00260612216L,04133454451L,00615531516L,
- 06137717526L,02574116560L,02304023373L,07061702261L,
- 05153031405L,05322056705L,07401116734L,06552375715L,
- 06165233473L,05311063631L,01212221723L,01052267235L,
- 06000615237L,01075222665L,06330216006L,04402355630L,
- 01451177262L,02000133436L,06025467062L,07121076461L,
- 03123433522L,01010635225L,01716177066L,05161746527L,
- 01736635071L,06243505026L,03637211610L,01756474365L,
- 04723077174L,03642763134L,05750130273L,03655541561L,
-};
-
-static long
-dcalchash(datum item)
-{
- int s, c, j;
- char *cp;
- long hashl;
- int hashi;
-
- hashl = 0;
- hashi = 0;
- for (cp = item.dptr, s=item.dsize; --s >= 0; ) {
- c = *cp++;
- for (j=0; j<BYTESIZ; j+=4) {
- hashi += hitab[c&017];
- hashl += hltab[hashi&63];
- c >>= 4;
- }
- }
- return (hashl);
-}
-
-/*
- * Delete pairs of items (n & n+1).
- */
-static int
-delitem(char buf[PBLKSIZ], int n)
-{
- short *sp, *sp1;
- int i1, i2;
-
- sp = (short *)buf;
- i2 = sp[0];
- if ((unsigned)n >= i2 || (n & 1))
- return (0);
- if (n == i2-2) {
- sp[0] -= 2;
- return (1);
- }
- i1 = PBLKSIZ;
- if (n > 0)
- i1 = sp[n];
- i1 -= sp[n+2];
- if (i1 > 0) {
- i2 = sp[i2];
- bcopy(&buf[i2], &buf[i2 + i1], sp[n+2] - i2);
- }
- sp[0] -= 2;
- for (sp1 = sp + sp[0], sp += n+1; sp <= sp1; sp++)
- sp[0] = sp[2] + i1;
- return (1);
-}
-
-/*
- * Add pairs of items (item & item1).
- */
-static int
-additem(char buf[PBLKSIZ], datum item, datum item1)
-{
- short *sp;
- int i1, i2;
-
- sp = (short *)buf;
- i1 = PBLKSIZ;
- i2 = sp[0];
- if (i2 > 0)
- i1 = sp[i2];
- i1 -= item.dsize + item1.dsize;
- if (i1 <= (i2+3) * sizeof(short))
- return (0);
- sp[0] += 2;
- sp[++i2] = i1 + item1.dsize;
- bcopy(item.dptr, &buf[i1 + item1.dsize], item.dsize);
- sp[++i2] = i1;
- bcopy(item1.dptr, &buf[i1], item1.dsize);
- return (1);
-}
-
-#ifdef DEBUG
-static int
-chkblk(char buf[PBLKSIZ])
-{
- short *sp;
- int t, i;
-
- sp = (short *)buf;
- t = PBLKSIZ;
- for (i=0; i<sp[0]; i++) {
- if (sp[i+1] > t)
- return (-1);
- t = sp[i+1];
- }
- if (t < (sp[0]+1)*sizeof(short))
- return (-1);
- return (0);
-}
-#endif
diff --git a/usr/src/lib/libbc/libc/gen/common/nl_cxtime.c b/usr/src/lib/libbc/libc/gen/common/nl_cxtime.c
deleted file mode 100644
index 53c73ee0d9..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/nl_cxtime.c
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-
-#include <stdio.h>
-#include <time.h>
-
-#define TBUFSIZE 128
-char _tbuf[TBUFSIZE];
-
-char *
-nl_cxtime(clk, fmt)
- struct tm *clk;
- char *fmt;
-{
- char *nl_ascxtime();
- return (nl_ascxtime(localtime(clk), fmt));
-}
-
-char *
-nl_ascxtime(tmptr, fmt)
- struct tm *tmptr;
- char *fmt;
-{
- return (strftime (_tbuf, TBUFSIZE, fmt ? fmt : "%H:%M:%S", tmptr) ?
- _tbuf : asctime(tmptr));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/nl_strncmp.c b/usr/src/lib/libbc/libc/gen/common/nl_strncmp.c
deleted file mode 100644
index cbf844c983..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/nl_strncmp.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-
-#define MAXSTR 256 /* use same value as used in strcoll */
-
-int
-nl_strncmp(s1, s2, n)
- char *s1;
- char *s2;
- int n;
-{
- char ns1[MAXSTR+1];
- char ns2[MAXSTR+1];
- register int i;
- register char *p1, *p2;
-
- p1 = ns1;
- p2 = ns2;
-
- for (i = 0; i < n && i < MAXSTR; i++) {
- *p1++ = *s1++;
- *p2++ = *s2++;
- }
- *p1 = *p2 = '\0';
-
- return (strcoll(ns1, ns2));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/on_exit.c b/usr/src/lib/libbc/libc/gen/common/on_exit.c
deleted file mode 100644
index 354c9a6409..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/on_exit.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-
-/*
- * Copyright (c) 1987 by Sun Microsystems, Inc.
- */
-
-char *malloc();
-
-struct handlers {
- void (*handler)();
- caddr_t arg;
- struct handlers *next;
-};
-
-extern struct handlers *_exit_handlers;
-
-int
-on_exit(handler, arg)
- void (*handler)();
- caddr_t arg;
-{
- register struct handlers *h =
- (struct handlers *)malloc(sizeof (*h));
-
- if (h == 0)
- return (-1);
- h->handler = handler;
- h->arg = arg;
- h->next = _exit_handlers;
- _exit_handlers = h;
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/opendir.c b/usr/src/lib/libbc/libc/gen/common/opendir.c
deleted file mode 100644
index cf41897df2..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/opendir.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright (c) 1995, by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/param.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <errno.h>
-#include <fcntl.h>
-
-/*
- * open a directory.
- */
-DIR *
-opendir(name)
- char *name;
-{
- register DIR *dirp;
- register int fd;
- struct stat sb;
- extern int errno;
- extern char *malloc();
- extern int open(), close(), fstat();
-
- if ((fd = open(name, O_RDONLY | O_NDELAY)) == -1)
- return (NULL);
- if (fstat(fd, &sb) == -1) {
- (void) close(fd);
- return (NULL);
- }
- if ((sb.st_mode & S_IFMT) != S_IFDIR) {
- errno = ENOTDIR;
- (void) close(fd);
- return (NULL);
- }
- if (((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) ||
- ((dirp->dd_buf = malloc(sb.st_blksize)) == NULL)) {
- if (dirp)
- free(dirp);
- (void) close(fd);
- return (NULL);
- }
- dirp->dd_fd = fd;
- dirp->dd_loc = 0;
- dirp->dd_size = 0;
- dirp->dd_bsize = sb.st_blksize;
- dirp->dd_off = 0;
- (void) fcntl(fd, F_SETFD, FD_CLOEXEC);
- return (dirp);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/optind.c b/usr/src/lib/libbc/libc/gen/common/optind.c
deleted file mode 100644
index 5bfeb416cb..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/optind.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1987 Sun Microsystems, Inc.
- */
-
-/*LINTLIBRARY*/
-int optind = 1;
-int opterr = 1;
-char *optarg;
diff --git a/usr/src/lib/libbc/libc/gen/common/pack_float.c b/usr/src/lib/libbc/libc/gen/common/pack_float.c
deleted file mode 100644
index 4a75254292..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/pack_float.c
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright (c) 1988-1995, by Sun Microsystems, Inc.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "base_conversion.h"
-
-void
-_fp_rightshift(pu, n)
- unpacked *pu;
- int n;
-
-/* Right shift significand sticky by n bits. */
-
-{
- int i;
-
- if (n >= (32 * UNPACKED_SIZE)) { /* drastic */
- for (i = 0; (pu->significand[i] == 0) && (i < UNPACKED_SIZE); i++);
- if (i >= UNPACKED_SIZE) {
- pu->fpclass = fp_zero;
- return;
- } else {
- for (i = 0; i < (UNPACKED_SIZE - 1); i++)
- pu->significand[i] = 0;
- pu->significand[UNPACKED_SIZE - 1] = 1;
- return;
- }
- }
- while (n >= 32) { /* big shift */
- if (pu->significand[UNPACKED_SIZE - 1] != 0)
- pu->significand[UNPACKED_SIZE - 2] |= 1;
- for (i = UNPACKED_SIZE - 2; i >= 0; i--)
- pu->significand[i + 1] = pu->significand[i];
- pu->significand[0] = 0;
- n -= 32;
- }
- if (n >= 1) { /* small shift */
- unsigned long high, low, shiftout = 0;
- for (i = 0; i < UNPACKED_SIZE; i++) {
- high = pu->significand[i] >> n;
- low = pu->significand[i] << (32 - n);
- pu->significand[i] = shiftout | high;
- shiftout = low;
- }
- if (shiftout != 0)
- pu->significand[UNPACKED_SIZE - 1] |= 1;
- }
-}
-
-PRIVATE int
-overflow_to_infinity(sign)
- int sign;
-
-/* Returns 1 if overflow should go to infinity, 0 if to max finite. */
-
-{
- int inf;
-
- switch (_fp_current_direction) {
- case fp_nearest:
- inf = 1;
- break;
- case fp_tozero:
- inf = 0;
- break;
- case fp_positive:
- inf = !sign;
- break;
- case fp_negative:
- inf = sign;
- break;
- }
- return (inf);
-}
-
-PRIVATE void
-round(pu, roundword)
- unpacked *pu;
-
-/*
- * Round according to current rounding mode. pu must be shifted to so that
- * the roundbit is pu->significand[roundword] & 0x80000000
- */
-
-{
- int increment; /* boolean to indicate round up */
- int is;
- unsigned msw; /* msw before increment */
-
- for (is = (roundword + 1); is < UNPACKED_SIZE; is++)
- if (pu->significand[is] != 0) { /* Condense extra bits into
- * sticky bottom of
- * roundword. */
- pu->significand[roundword] |= 1;
- break;
- }
- if (pu->significand[roundword] == 0)
- return;
- _fp_set_exception(fp_inexact);
- switch (_fp_current_direction) {
- case fp_nearest:
- increment = pu->significand[roundword] >= 0x80000000;
- break;
- case fp_tozero:
- increment = 0;
- break;
- case fp_positive:
- increment = (pu->sign == 0) & (pu->significand[roundword] != 0);
- break;
- case fp_negative:
- increment = (pu->sign != 0) & (pu->significand[roundword] != 0);
- break;
- }
- if (increment) {
- msw=pu->significand[0]; /* save msw before round */
- is = roundword;
- do {
- is--;
- pu->significand[is]++;
- }
- while ((pu->significand[is] == 0) && (is > 0));
- if (pu->significand[0] < msw) { /* rounding carried out */
- pu->exponent++;
- pu->significand[0] = 0x80000000;
- }
- }
- if ((_fp_current_direction == fp_nearest) && (pu->significand[roundword] == 0x80000000)) { /* ambiguous case */
- pu->significand[roundword - 1] &= ~1; /* force round to even */
- }
-}
-
-void
-_pack_single(pu, px)
- unpacked *pu; /* unpacked result */
- single *px; /* packed single */
-{
- single_equivalence kluge;
-
- kluge.f.msw.sign = pu->sign;
- switch (pu->fpclass) {
- case fp_zero:
- kluge.f.msw.exponent = 0;
- kluge.f.msw.significand = 0;
- break;
- case fp_infinity:
-infinity:
- kluge.f.msw.exponent = 0xff;
- kluge.f.msw.significand = 0;
- break;
- case fp_quiet:
- kluge.f.msw.exponent = 0xff;
- kluge.f.msw.significand = 0x400000 | (0x3fffff & (pu->significand[0] >> 8));
- break;
- case fp_normal:
- _fp_rightshift(pu, 8);
- pu->exponent += SINGLE_BIAS;
- if (pu->exponent <= 0) {
- kluge.f.msw.exponent = 0;
- _fp_rightshift(pu, 1 - pu->exponent);
- round(pu, 1);
- if (pu->significand[0] == 0x800000) { /* rounded back up to
- * normal */
- kluge.f.msw.exponent = 1;
- kluge.f.msw.significand = 0;
- _fp_set_exception(fp_underflow);
- goto ret;
- }
- if (_fp_current_exceptions & (1 << fp_inexact))
- _fp_set_exception(fp_underflow);
- kluge.f.msw.significand = 0x7fffff & pu->significand[0];
- goto ret;
- }
- round(pu, 1);
- if (pu->significand[0] == 0x1000000) { /* rounding overflow */
- pu->significand[0] = 0x800000;
- pu->exponent += 1;
- }
- if (pu->exponent >= 0xff) {
- _fp_set_exception(fp_overflow);
- _fp_set_exception(fp_inexact);
- if (overflow_to_infinity(pu->sign))
- goto infinity;
- kluge.f.msw.exponent = 0xfe;
- kluge.f.msw.significand = 0x7fffff;
- goto ret;
- }
- kluge.f.msw.exponent = pu->exponent;
- kluge.f.msw.significand = 0x7fffff & pu->significand[0];
- }
-ret:
- *px = kluge.x;
-}
-
-void
-_pack_double(pu, px)
- unpacked *pu; /* unpacked result */
- double *px; /* packed double */
-{
- double_equivalence kluge;
-
- kluge.f.msw.sign = pu->sign;
- switch (pu->fpclass) {
- case fp_zero:
- kluge.f.msw.exponent = 0;
- kluge.f.msw.significand = 0;
- kluge.f.significand2 = 0;
- break;
- case fp_infinity:
-infinity:
- kluge.f.msw.exponent = 0x7ff;
- kluge.f.msw.significand = 0;
- kluge.f.significand2 = 0;
- break;
- case fp_quiet:
- kluge.f.msw.exponent = 0x7ff;
- _fp_rightshift(pu, 11);
- kluge.f.msw.significand = 0x80000 | (0x7ffff & pu->significand[0]);
- kluge.f.significand2 = pu->significand[1];
- break;
- case fp_normal:
- _fp_rightshift(pu, 11);
- pu->exponent += DOUBLE_BIAS;
- if (pu->exponent <= 0) { /* underflow */
- kluge.f.msw.exponent = 0;
- _fp_rightshift(pu, 1 - pu->exponent);
- round(pu, 2);
- if (pu->significand[0] == 0x100000) { /* rounded back up to
- * normal */
- kluge.f.msw.exponent = 1;
- kluge.f.msw.significand = 0;
- kluge.f.significand2 = 0;
- _fp_set_exception(fp_underflow);
- goto ret;
- }
- if (_fp_current_exceptions & (1 << fp_inexact))
- _fp_set_exception(fp_underflow);
- kluge.f.msw.exponent = 0;
- kluge.f.msw.significand = 0xfffff & pu->significand[0];
- kluge.f.significand2 = pu->significand[1];
- goto ret;
- }
- round(pu, 2);
- if (pu->significand[0] == 0x200000) { /* rounding overflow */
- pu->significand[0] = 0x100000;
- pu->exponent += 1;
- }
- if (pu->exponent >= 0x7ff) { /* overflow */
- _fp_set_exception(fp_overflow);
- _fp_set_exception(fp_inexact);
- if (overflow_to_infinity(pu->sign))
- goto infinity;
- kluge.f.msw.exponent = 0x7fe;
- kluge.f.msw.significand = 0xfffff;
- kluge.f.significand2 = 0xffffffff;
- goto ret;
- }
- kluge.f.msw.exponent = pu->exponent;
- kluge.f.msw.significand = 0xfffff & pu->significand[0];
- kluge.f.significand2 = pu->significand[1];
- break;
- }
-ret:
- *px = kluge.x;
-}
-
-void
-_pack_extended(pu, px)
- unpacked *pu; /* unpacked result */
- extended *px; /* packed extended */
-{
- extended_equivalence kluge;
-
- kluge.f.msw.sign = pu->sign;
- switch (pu->fpclass) {
- case fp_zero:
- kluge.f.msw.exponent = 0;
- kluge.f.significand = 0;
- kluge.f.significand2 = 0;
- break;
- case fp_infinity:
-infinity:
- kluge.f.msw.exponent = 0x7fff;
- kluge.f.significand = 0;
- kluge.f.significand2 = 0;
- break;
- case fp_quiet:
- kluge.f.msw.exponent = 0x7fff;
- kluge.f.significand = 0x40000000 | (0x7fffffff & pu->significand[0]);
- kluge.f.significand2 = pu->significand[1];
- break;
- case fp_normal:
- switch (_fp_current_precision) {
- case fp_single:
- {
- single s;
- _pack_single(pu, &s);
- _unpack_single(pu, &s);
- break;
- }
- case fp_double:
- {
- double s;
- _pack_double(pu, &s);
- _unpack_double(pu, &s);
- break;
- }
- }
- pu->exponent += EXTENDED_BIAS;
- if (pu->exponent <= 0) { /* underflow */
- kluge.f.msw.exponent = 0;
- _fp_rightshift(pu, -pu->exponent);
- round(pu, 2);
- if (_fp_current_exceptions & (1 << fp_inexact))
- _fp_set_exception(fp_underflow);
- kluge.f.msw.exponent = 0;
- kluge.f.significand = pu->significand[0];
- kluge.f.significand2 = pu->significand[1];
- goto ret;
- }
- round(pu, 2);
- if (pu->exponent >= 0x7fff) { /* overflow */
- _fp_set_exception(fp_overflow);
- _fp_set_exception(fp_inexact);
- if (overflow_to_infinity(pu->sign))
- goto infinity;
- kluge.f.msw.exponent = 0x7ffe;
- kluge.f.significand = 0xffffffff;
- kluge.f.significand2 = 0xffffffff;
- goto ret;
- }
- kluge.f.msw.exponent = pu->exponent;
- kluge.f.significand = pu->significand[0];
- kluge.f.significand2 = pu->significand[1];
- break;
- }
-ret:
- (*px)[0] = kluge.x[0];
- (*px)[1] = kluge.x[1];
- (*px)[2] = kluge.x[2];
-}
-
-void
-_pack_quadruple(pu, px)
- unpacked *pu; /* unpacked result */
- quadruple *px; /* packed quadruple */
-{
- quadruple_equivalence kluge;
- int i;
-
- kluge.f.msw.sign = pu->sign;
- switch (pu->fpclass) {
- case fp_zero:
- kluge.f.msw.exponent = 0;
- kluge.f.msw.significand = 0;
- kluge.f.significand2 = 0;
- kluge.f.significand3 = 0;
- kluge.f.significand4 = 0;
- break;
- case fp_infinity:
-infinity:
- kluge.f.msw.exponent = 0x7fff;
- kluge.f.msw.significand = 0;
- kluge.f.significand2 = 0;
- kluge.f.significand3 = 0;
- kluge.f.significand4 = 0;
- break;
- case fp_quiet:
- kluge.f.msw.exponent = 0x7fff;
- _fp_rightshift(pu, 15);
- kluge.f.msw.significand = 0x8000 | (0xffff & pu->significand[0]);
- kluge.f.significand2 = pu->significand[1];
- kluge.f.significand3 = pu->significand[2];
- kluge.f.significand4 = pu->significand[3];
- break;
- case fp_normal:
- _fp_rightshift(pu, 15);
- pu->exponent += QUAD_BIAS;
- if (pu->exponent <= 0) { /* underflow */
- kluge.f.msw.exponent = 0;
- _fp_rightshift(pu, 1 - pu->exponent);
- round(pu, 4);
- if (pu->significand[0] == 0x10000) { /* rounded back up to
- * normal */
- kluge.f.msw.exponent = 1;
- kluge.f.msw.significand = 0;
- kluge.f.significand2 = 0;
- kluge.f.significand3 = 0;
- kluge.f.significand4 = 0;
- _fp_set_exception(fp_underflow);
- goto ret;
- }
- if (_fp_current_exceptions & (1 << fp_inexact))
- _fp_set_exception(fp_underflow);
- kluge.f.msw.exponent = 0;
- kluge.f.msw.significand = 0xffff & pu->significand[0];
- kluge.f.significand2 = pu->significand[1];
- kluge.f.significand3 = pu->significand[2];
- kluge.f.significand4 = pu->significand[3];
- goto ret;
- }
- round(pu, 4);
- if (pu->significand[0] == 0x20000) { /* rounding overflow */
- pu->significand[0] = 0x10000;
- pu->exponent += 1;
- }
- if (pu->exponent >= 0x7fff) { /* overflow */
- _fp_set_exception(fp_overflow);
- _fp_set_exception(fp_inexact);
- if (overflow_to_infinity(pu->sign))
- goto infinity;
- kluge.f.msw.exponent = 0x7ffe;
- kluge.f.msw.significand = 0xffff;
- kluge.f.significand2 = 0xffffffff;
- kluge.f.significand3 = 0xffffffff;
- kluge.f.significand4 = 0xffffffff;
- goto ret;
- }
- kluge.f.msw.exponent = pu->exponent;
- kluge.f.msw.significand = pu->significand[0] & 0xffff;
- kluge.f.significand2 = pu->significand[1];
- kluge.f.significand3 = pu->significand[2];
- kluge.f.significand4 = pu->significand[3];
- break;
- }
-ret:
-#ifdef __STDC__
- *px = kluge.x;
-#else
- for (i = 0; i < 4; i++)
- px->u[i] = kluge.x.u[i];
-#endif
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/perror.c b/usr/src/lib/libbc/libc/gen/common/perror.c
deleted file mode 100644
index 484af3f4cf..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/perror.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1983 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Print the error indicated
- * in the cerror cell.
- */
-#include <stdio.h>
-
-extern int fflush();
-extern void _perror();
-
-void
-perror(s)
- char *s;
-{
-
- (void)fflush(stderr);
- _perror(s);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/plock.c b/usr/src/lib/libbc/libc/gen/common/plock.c
deleted file mode 100644
index fe3d069929..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/plock.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * plock - lock "segments" in physical memory.
- *
- * Supports SVID-compatible plock, taking into account dynamically linked
- * objects (such as shared libraries).
- */
-
-#include <sys/types.h>
-#include <sys/mman.h>
-#include <sys/lock.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-#include <machine/param.h>
-#include <machine/vmparam.h>
-#include <a.out.h>
-#include <link.h>
-#include <errno.h>
-
-/*
- * Globals we reference.
- */
-extern struct link_dynamic _DYNAMIC;
-extern int mlock();
-extern int munlock();
-extern caddr_t sbrk(); /* find end of data segment */
-extern caddr_t etext; /* end of text segment */
-
-/*
- * Module-scope variables.
- */
-static int page_size = 0; /* cached result of getpagesize() */
-static int lock_state = 0; /* lock state */
-static int state_pid = -1; /* pid to which state belongs */
-
-/*
- * Local worker routine to lock text and data segments. Handles
- * dynamically loaded objects. This routine is highly dependent
- * on executable format and layout.
- *
- * Arguments:
- * op: desired operation
- * f: function to perform
- */
-static int
-apply_lock(int op, int (*f)(caddr_t, u_int))
-{
- int e = 0; /* return value */
- caddr_t a; /* address of operation */
- u_int l; /* length of operation */
- struct link_map *lmp; /* link map walker */
- struct exec *eh; /* exec header */
-
- /*
- * Operate on application segment first.
- */
- switch (op) {
- case TXTLOCK:
- a = (caddr_t)USRTEXT; /* note: old Sun-2 not handled */
- l = (u_int)&etext - USRTEXT;
- break;
- case DATLOCK:
- a = (caddr_t)(((int)&etext + (SEGSIZ - 1)) & ~(SEGSIZ - 1));
- l = (u_int)(sbrk(0) - a);
- break;
- }
- l = (l + (page_size - 1)) & (u_int)~(page_size - 1);
-
- /*
- * Perform the operation -- if failure, return immediately.
- */
- if (e = (*f)(a, l))
- return (e);
-
- /*
- * If we're not a dynamically linked program, we are finished.
- */
- if (&_DYNAMIC == 0)
- return (0);
-
- /*
- * Find the list of dynamically linked objects. If we get
- * dynamic linking formats we don't recognize, then punt.
- */
- switch (_DYNAMIC.ld_version) {
- case 2:
-#if defined(__sparc)
- case 3:
-#endif /* __sparc */
- lmp = _DYNAMIC.ld_un.ld_2->ld_loaded;
- break;
- default:
- return (0);
- }
-
- /*
- * Loop over all objects. Extract the addresses and lengths as
- * required, and perform the appropriate operation.
- */
-
- while (lmp) {
- eh = (struct exec *)lmp->lm_addr;
- switch (op) {
- case TXTLOCK:
- a = (caddr_t)eh;
- l = (u_int)eh->a_text;
- break;
- case DATLOCK:
- a = (caddr_t)((u_int)eh + N_DATADDR(*eh) -
- N_TXTADDR(*eh));
- l = (u_int)eh->a_data + (u_int)eh->a_bss;
- break;
- }
- l = (l + (page_size - 1)) & ~(page_size - 1);
- if (e = (*f)(a, l))
- return (e);
- lmp = lmp->lm_next;
- }
- return (0);
-}
-
-/*
- * plock
- *
- * Argument:
- * op: desired operation
- */
-int
-plock(int op)
-{
- int e = 0; /* return value */
- int pid; /* current pid */
- caddr_t a1, a2; /* loop variables */
- struct rlimit rl; /* resource limit */
-
- /*
- * Initialize static caches.
- */
- if (page_size == 0)
- page_size = getpagesize();
-
- /*
- * Validate state of lock's. If parent has forked, then
- * the lock state needs to be reset (children do not inherit
- * memory locks, and thus do not inherit their state).
- */
- if ((pid = getpid()) != state_pid) {
- lock_state = 0;
- state_pid = pid;
- }
-
- /*
- * Dispatch on operation. Note: plock and its relatives depend
- * upon "op" being bit encoded.
- */
- switch (op) {
-
- /*
- * UNLOCK: remove all memory locks. Requires that some be set!
- */
- case UNLOCK:
- if (lock_state == 0) {
- errno = EINVAL;
- return (-1);
- }
- if (e = munlockall())
- return (-1);
- else {
- lock_state = 0;
- return (0);
- }
- /*NOTREACHED*/
-
- /*
- * TXTLOCK: locks text segments.
- */
- case TXTLOCK:
-
- /*
- * If a text or process lock is already set, then fail.
- */
- if ((lock_state & TXTLOCK) || (lock_state & PROCLOCK)) {
- errno = EINVAL;
- return (-1);
- }
-
- /*
- * Try to apply the lock(s). If a failure occurs,
- * back them out. On success, remember that a text
- * lock was set.
- */
- if (e = apply_lock(op, mlock))
- (void) apply_lock(op, munlock);
- else
- lock_state |= TXTLOCK;
- return (e);
- /*NOTREACHED*/
-
- /*
- * DATLOCK: locks data segment(s), including the stack and all
- * future growth in the address space.
- */
- case DATLOCK:
-
- /*
- * If a data or process lock is already set, then fail.
- */
- if ((lock_state & DATLOCK) || (lock_state & PROCLOCK)) {
- errno = EINVAL;
- return (-1);
- }
-
- /*
- * Try to lock the data segments. On failure, back out
- * the locks and return.
- */
- if (e = apply_lock(op, mlock)) {
- (void) apply_lock(op, munlock);
- return (-1);
- }
-
- /*
- * Try to lock the stack segment. Find out the extent
- * and start of the stack (there should be a function for
- * this!) and then iterate over the pages of the stack
- * locking them. The stack *could* be sparely populated.
- * Ignore lock failures resulting from the absence of a
- * mapping.
- */
- (void) getrlimit(RLIMIT_STACK, &rl);
- for (a1 = (caddr_t)USRSTACK - page_size;
- a1 != (caddr_t)USRSTACK - rl.rlim_cur; a1 -= page_size)
- if (e = mlock(a1, page_size)) {
- if (errno == ENOMEM)
- e = 0;
- break;
- }
-
- /*
- * If we were successful in locking the stack, then
- * try to set a lock for all future mappings.
- */
- if (!e)
- e = mlockall(MCL_FUTURE);
-
- /*
- * If failures have occurred, back out the locks
- * and return failure.
- */
- if (e) {
- e = errno;
- (void) apply_lock(op, munlock);
- for (a2 = (caddr_t)USRSTACK - page_size; a2 != a1;
- a2 -= page_size)
- (void) munlock(a2, page_size);
- errno = e;
- return (-1);
- }
-
- /*
- * Data, stack, and growth have been locked. Set state
- * and return success.
- */
- lock_state |= DATLOCK;
- return (0);
- /*NOTREACHED*/
-
- /*
- * PROCLOCK: lock everything, and all future things as well.
- * There should be nothing locked when this is called.
- */
- case PROCLOCK:
- if (lock_state) {
- errno = EINVAL;
- return (-1);
- }
- if (mlockall(MCL_CURRENT | MCL_FUTURE) == 0) {
- lock_state |= PROCLOCK;
- return (0);
- } else
- return (-1);
- /*NOTREACHED*/
-
- /*
- * Invalid operation.
- */
- default:
- errno = EINVAL;
- return (-1);
- /*NOTREACHED*/
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/popen.c b/usr/src/lib/libbc/libc/gen/common/popen.c
deleted file mode 100644
index bb295e717a..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/popen.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (c) 1995, by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 5.2 85/06/05 */
-
-/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#include <stdio.h>
-#include <signal.h>
-#include <vfork.h>
-
-#define tst(a,b) (*mode == 'r'? (b) : (a))
-#define RDR 0
-#define WTR 1
-
-extern char *malloc();
-extern int execl(), vfork(), pipe(), close(), fcntl();
-
-static int *popen_pid;
-static int nfiles;
-
-FILE *
-popen(cmd,mode)
- char *cmd;
- char *mode;
-{
- int p[2];
- register int *poptr;
- register int myside, hisside, pid;
-
- if (nfiles <= 0)
- nfiles = getdtablesize();
- if (popen_pid == NULL) {
- popen_pid = (int *)malloc(nfiles * sizeof *popen_pid);
- if (popen_pid == NULL)
- return (NULL);
- for (pid = 0; pid < nfiles; pid++)
- popen_pid[pid] = -1;
- }
- if (pipe(p) < 0)
- return (NULL);
- myside = tst(p[WTR], p[RDR]);
- hisside = tst(p[RDR], p[WTR]);
- if ((pid = vfork()) == 0) {
- /* myside and hisside reverse roles in child */
- int stdio;
-
- /* close all pipes from other popen's */
- for (poptr = popen_pid; poptr < popen_pid+nfiles; poptr++) {
- if(*poptr >= 0)
- close(poptr - popen_pid);
- }
- stdio = tst(0, 1);
- (void) close(myside);
- if (hisside != stdio) {
- (void) dup2(hisside, stdio);
- (void) close(hisside);
- }
- (void) execl("/bin/sh", "sh", "-c", cmd, (char *)NULL);
- _exit(127);
- }
- if (pid == -1) {
- close(myside);
- close(hisside);
- return (NULL);
- }
- popen_pid[myside] = pid;
- close(hisside);
- return (fdopen(myside, mode));
-}
-
-int
-pclose(ptr)
- FILE *ptr;
-{
- int child = -1;
- int pid, status, omask;
-
- if (popen_pid != NULL) {
- child = popen_pid[fileno(ptr)];
- popen_pid[fileno(ptr)] = -1;
- }
- fclose(ptr);
- if (child == -1)
- return (-1);
- omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
- while ((pid = waitpid(child, &status, 0)) != child && pid != -1)
- ;
- (void) sigsetmask(omask);
- return (pid == -1 ? -1 : status);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/posix_sig.c b/usr/src/lib/libbc/libc/gen/common/posix_sig.c
deleted file mode 100644
index c2b867c912..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/posix_sig.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1994 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * posix signal package
- */
-#include <stdio.h>
-#include <signal.h>
-#include <errno.h>
-
-#define cantmask (sigmask(SIGKILL)|sigmask(SIGSTOP))
-
-
-/*
- * sigemptyset - all known signals
- */
-int
-sigemptyset(sigset_t *sigp)
-{
- if (!sigp) {
- errno = EINVAL;
- return (-1);
- }
- *sigp = 0;
- return (0);
-}
-
-/*
- * sigfillset - all known signals
- */
-int
-sigfillset(sigset_t *sigp)
-{
- if (!sigp) {
- errno = EINVAL;
- return (-1);
- }
- *sigp = sigmask(NSIG - 1) | (sigmask(NSIG - 1) - 1);
- return (0);
-}
-
-/*
- * add the signal to the set
- */
-int
-sigaddset(sigset_t *sigp, int signo)
-{
- if (!sigp || signo <= 0 || signo >= NSIG) {
- errno = EINVAL;
- return (-1);
- }
- *sigp |= sigmask(signo);
- return (0);
-}
-
-/*
- * remove the signal from the set
- */
-int
-sigdelset(sigset_t *sigp, int signo)
-{
- if (!sigp || signo <= 0 || signo >= NSIG) {
- errno = EINVAL;
- return (-1);
- }
- *sigp &= ~sigmask(signo);
- return (0);
-}
-
-/*
- * return true if the signal is in the set (return is 0 or 1)
- */
-int
-sigismember(sigset_t *sigp, int signo)
-{
- if (!sigp || signo <= 0 || signo >= NSIG) {
- errno = EINVAL;
- return (-1);
- }
- return ((*sigp & sigmask(signo)) != 0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/posix_tty.c b/usr/src/lib/libbc/libc/gen/common/posix_tty.c
deleted file mode 100644
index ae07844ecd..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/posix_tty.c
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1995 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * wrappers for posix tty manipulation functions
- */
-
-#include <errno.h>
-#include <termios.h>
-#include <termio.h>
-#include <sys/types.h>
-
-/*
- * return the output speed from the struct
- */
-speed_t
-cfgetospeed(struct termios *termios_p)
-{
- return (termios_p->c_cflag & CBAUDEXT ?
- (termios_p->c_cflag & CBAUD) + CBAUD + 1 :
- termios_p->c_cflag & CBAUD);
-}
-
-/*
- * set the speed in the struct
- */
-int
-cfsetospeed(struct termios *termios_p, speed_t speed)
-{
- if (speed > (2*CBAUD + 1)) {
- errno = EINVAL;
- return (-1);
- }
- if (speed > CBAUD) {
- termios_p->c_cflag |= CBAUDEXT;
- speed -= (CBAUD + 1);
- } else
- termios_p->c_cflag &= ~CBAUDEXT;
-
- termios_p->c_cflag =
- (termios_p->c_cflag & ~CBAUD) | (speed & CBAUD);
- return (0);
-}
-
-/*
- * return the input speed from the struct
- */
-speed_t
-cfgetispeed(struct termios *termios_p)
-{
- return (termios_p->c_cflag & CIBAUDEXT ?
- ((termios_p->c_cflag & CIBAUD) >> IBSHIFT)
- + (CIBAUD >> IBSHIFT) + 1 :
- (termios_p->c_cflag & CIBAUD) >> IBSHIFT);
-}
-
-/*
- * set the input speed in the struct
- */
-int
-cfsetispeed(struct termios *termios_p, speed_t speed)
-{
- if (speed > (2*CBAUD + 1)) {
- errno = EINVAL;
- return (-1);
- }
- if ((speed << IBSHIFT) > CIBAUD) {
- termios_p->c_cflag |= CIBAUDEXT;
- speed -= ((CIBAUD >> IBSHIFT) + 1);
- } else
- termios_p->c_cflag &= ~CIBAUDEXT;
- termios_p->c_cflag =
- (termios_p->c_cflag & ~CIBAUD) | ((speed << IBSHIFT) & CIBAUD);
- return (0);
-}
-
-/*
- * grab the modes
- */
-int
-tcgetattr(int fd, struct termios *termios_p)
-{
- return (ioctl(fd, TCGETS, termios_p));
-}
-
-/*
- * set the modes
- */
-int
-tcsetattr(int fd, int option, struct termios *termios_p)
-{
- struct termios work_area;
-
- /* If input speed is zero, set it to the output speed. */
- if ((((termios_p->c_cflag >> IBSHIFT) & CIBAUD) == 0) &&
- ((termios_p->c_cflag & CIBAUDEXT) == 0)) {
- work_area = *termios_p;
- work_area.c_cflag |= (work_area.c_cflag & CBAUD) << IBSHIFT;
- if (termios_p->c_cflag & CBAUDEXT)
- work_area.c_cflag |= CIBAUDEXT;
- termios_p = &work_area;
- }
- switch (option) {
- case TCSADRAIN:
- return (ioctl(fd, TCSETSW, termios_p));
- case TCSAFLUSH:
- return (ioctl(fd, TCSETSF, termios_p));
- case TCSANOW:
- return (ioctl(fd, TCSETS, termios_p));
- default:
- errno = EINVAL;
- return (-1);
- }
- /*NOTREACHED*/
-}
-
-/*
- * send a break
- * This is kludged for duration != 0; it should do something like crank the
- * baud rate down and then send the break if the duration != 0.
- */
-int
-tcsendbreak(int fd, int duration)
-{
- unsigned d = (unsigned)duration;
-
- do
- if (ioctl(fd, TCSBRK, 0) == -1)
- return (-1);
- while (d--);
- return (0);
-}
-
-/*
- * wait for all output to drain from fd
- */
-int
-tcdrain(int fd)
-{
- return (ioctl(fd, TCSBRK, !0));
-}
-
-/*
- * flow control
- */
-int
-tcflow(int fd, int action)
-{
- switch (action) {
- default:
- errno = EINVAL;
- return (-1);
- case TCOOFF:
- case TCOON:
- case TCIOFF:
- case TCION:
- return (ioctl(fd, TCXONC, action));
- }
- /*NOTREACHED*/
-}
-
-/*
- * flush read/write/both
- */
-int
-tcflush(int fd, int queue)
-{
- switch (queue) {
- default:
- errno = EINVAL;
- return (-1);
- case TCIFLUSH:
- case TCOFLUSH:
- case TCIOFLUSH:
- return (ioctl(fd, TCFLSH, queue));
- }
- /*NOTREACHED*/
-}
-
-/*
- * get the foreground process group id
- */
-pid_t
-tcgetpgrp(int fd)
-{
- int grp_id;
-
- if (ioctl(fd, TIOCGETPGRP, &grp_id) == -1)
- return ((pid_t)-1);
- else
- return ((pid_t)grp_id);
-}
-
-/*
- * set the foreground process group id
- */
-int
-tcsetpgrp(int fd, int grp_id)
-{
- return (ioctl(fd, TIOCSETPGRP, &grp_id));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/psignal.c b/usr/src/lib/libbc/libc/gen/common/psignal.c
deleted file mode 100644
index 1be7704b44..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/psignal.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1983 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Print the name of the signal indicated
- * along with the supplied message.
- */
-#include <stdio.h>
-
-extern int fflush();
-extern void _psignal();
-
-void
-psignal(sig, s)
- unsigned sig;
- char *s;
-{
-
- (void)fflush(stderr);
- _psignal(sig, s);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/putenv.c b/usr/src/lib/libbc/libc/gen/common/putenv.c
deleted file mode 100644
index 72796576c8..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/putenv.c
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* LINTLIBRARY */
-/* putenv - change environment variables
- *
- * input - char *change = a pointer to a string of the form
- * "name=value"
- *
- * output - 0, if successful
- * 1, otherwise
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-extern char **environ; /* pointer to enviroment */
-static int reall; /* flag to reallocate space, if putenv is called
- more than once */
-static int find(char *);
-static int match(char *, char *);
-
-int
-putenv(char *change)
-{
- char **newenv; /* points to new environment */
- int which; /* index of variable to replace */
-
- if ((which = find(change)) < 0) {
- /* if a new variable */
- /* which is negative of table size, so invert and
- count new element */
- which = (-which) + 1;
- if (reall) {
- /* we have expanded environ before */
- newenv = (char **)realloc(environ,
- which*sizeof(char *));
- if (newenv == NULL) return (-1);
- /* now that we have space, change environ */
- environ = newenv;
- } else {
- /* environ points to the original space */
- reall++;
- newenv = (char **)malloc(which*sizeof(char *));
- if (newenv == NULL) return (-1);
- (void)memcpy((char *)newenv, (char *)environ,
- (int)(which*sizeof(char *)));
- environ = newenv;
- }
- environ[which-2] = change;
- environ[which-1] = NULL;
- } else {
- /* we are replacing an old variable */
- environ[which] = change;
- }
- return (0);
-}
-
-/* find - find where s2 is in environ
- *
- * input - str = string of form name=value
- *
- * output - index of name in environ that matches "name"
- * -size of table, if none exists
-*/
-static int
-find(char *str)
-{
- int ct = 0; /* index into environ */
-
- while(environ[ct] != NULL) {
- if (match(environ[ct], str) != 0)
- return (ct);
- ct++;
- }
- return (-(++ct));
-}
-/*
- * s1 is either name, or name=value
- * s2 is name=value
- * if names match, return value of 1,
- * else return 0
- */
-
-static int
-match(char *s1, char *s2)
-{
- while(*s1 == *s2++) {
- if (*s1 == '=')
- return (1);
- s1++;
- }
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/pwdauth.c b/usr/src/lib/libbc/libc/gen/common/pwdauth.c
deleted file mode 100644
index bbc367a2bf..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/pwdauth.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <pwd.h>
-#include <shadow.h>
-#include <errno.h>
-
-/*
- * Version to go in the BCP compatibility library in SVr4 version of
- * SunOS. This does not bother talking to rpc.pwdauthd or looking for the
- * password.adjunct file on the system since they do not exist anymore.
- * They have been effectively replaced by a more robust aging security provided
- * by the combination of /etc/shadow file, shadow support in the NIS+
- * passwd table and the use of secure RPC in NIS+.
- */
-
-int
-pwdauth(char *name, char *password)
-{
- /*
- * this routine authenticates a password for the named user.
- * Assumes the adjunct file does not exist.
- * and therefore checks the passwd "source" using the standard
- * getpwnam(3C) routine that uses /etc/nsswitch.conf(4).
- */
-
- struct passwd *pwp = NULL;
- struct spwd *spwp = NULL;
- char *enpwp;
-
- if (spwp = getspnam(name))
- enpwp = spwp->sp_pwdp;
- else if (pwp = getpwnam(name))
- enpwp = pwp->pw_passwd;
- else
- /* user is not in main password system */
- return (-1);
- if (enpwp[0] == '#' && enpwp[1] == '#') {
- /* this means that /etc/passwd has problems */
- fprintf(stderr, "pwdauth: bad passwd entry for %s\n",
- name);
- return (-1);
- }
- if (strcmp(crypt(password, enpwp), enpwp) == 0)
- return (0);
- else
- return (-1);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/pwdnm.c b/usr/src/lib/libbc/libc/gen/common/pwdnm.c
deleted file mode 100644
index dda9de2a15..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/pwdnm.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* c2 secure */
-
-#include <rpc/rpc.h>
-#include <rpcsvc/pwdnm.h>
-
-
-bool_t
-xdr_pwdnm(xdrs,objp)
- XDR *xdrs;
- pwdnm *objp;
-{
- if (! xdr_wrapstring(xdrs, &objp->name)) {
- return(FALSE);
- }
- if (! xdr_wrapstring(xdrs, &objp->password)) {
- return(FALSE);
- }
- return(TRUE);
-}
-
-
diff --git a/usr/src/lib/libbc/libc/gen/common/qeconvert.c b/usr/src/lib/libbc/libc/gen/common/qeconvert.c
deleted file mode 100644
index 38c324ddc2..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/qeconvert.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include "base_conversion.h"
-
-char *
-qeconvert(arg, ndigits, decpt, sign, buf)
- quadruple *arg;
- int ndigits, *decpt, *sign;
- char *buf;
-{
- decimal_mode dm;
- decimal_record dr;
- fp_exception_field_type ef;
- int i;
- static char *nanstring = "NaN";
- static char *infstring = "Infinity";
- char *pc;
- int nc;
-
- dm.rd = fp_direction; /* Rounding direction. */
- dm.df = floating_form; /* E format. */
- dm.ndigits = ndigits; /* Number of significant digits. */
- quadruple_to_decimal(arg, &dm, &dr, &ef);
- *sign = dr.sign;
- switch (dr.fpclass) {
- case fp_normal:
- case fp_subnormal:
- *decpt = dr.exponent + ndigits;
- for (i = 0; i < ndigits; i++)
- buf[i] = dr.ds[i];
- buf[ndigits] = 0;
- break;
- case fp_zero:
- *decpt = 1;
- for (i = 0; i < ndigits; i++)
- buf[i] = '0';
- buf[ndigits] = 0;
- break;
- case fp_infinity:
- *decpt = 0;
- pc = infstring;
- if (ndigits < 8)
- nc = 3;
- else
- nc = 8;
- goto movestring;
- case fp_quiet:
- case fp_signaling:
- *decpt = 0;
- pc = nanstring;
- nc = 3;
-movestring:
- for (i = 0; i < nc; i++)
- buf[i] = pc[i];
- buf[nc] = 0;
- break;
- }
- return buf; /* For compatibility with ecvt. */
-}
-
-char *
-qfconvert(arg, ndigits, decpt, sign, buf)
- quadruple *arg;
- int ndigits, *decpt, *sign;
- char *buf;
-{
- decimal_mode dm;
- decimal_record dr;
- fp_exception_field_type ef;
- int i;
-
- dm.rd = fp_direction; /* Rounding direction. */
- dm.df = fixed_form; /* F format. */
- dm.ndigits = ndigits; /* Number of digits after point. */
- quadruple_to_decimal(arg, &dm, &dr, &ef);
- *sign = dr.sign;
- switch (dr.fpclass) {
- case fp_normal:
- case fp_subnormal:
- if (ndigits >= 0)
- *decpt = dr.ndigits - ndigits;
- else
- *decpt = dr.ndigits;
- for (i = 0; i < dr.ndigits; i++)
- buf[i] = dr.ds[i];
- buf[dr.ndigits] = 0;
- break;
- case fp_zero:
- *decpt = 0;
- buf[0] = '0';
- for (i = 1; i < ndigits; i++)
- buf[i] = '0';
- buf[i] = 0;
- break;
- case fp_infinity:
- *decpt = 0;
- if (ndigits < 8)
- buf = "Inf";
- else
- buf = "Infinity";
- break;
- case fp_quiet:
- case fp_signaling:
- *decpt = 0;
- buf = "NaN";
- break;
- }
- return buf; /* For compatibility with fcvt. */
-}
-
-extern void _gcvt();
-
-char *
-qgconvert(number, ndigit, trailing, buf)
- quadruple *number;
- int ndigit, trailing;
- char *buf;
-{
- decimal_mode dm;
- decimal_record dr;
- fp_exception_field_type fef;
-
- dm.rd = fp_direction;
- dm.df = floating_form;
- dm.ndigits = ndigit;
- quadruple_to_decimal(number, &dm, &dr, &fef);
- _gcvt(ndigit, &dr, trailing, buf);
- return (buf);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/qsort.c b/usr/src/lib/libbc/libc/gen/common/qsort.c
deleted file mode 100644
index ecb276f301..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/qsort.c
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * qsort.c:
- * Our own version of the system qsort routine which is faster by an average
- * of 25%, with lows and highs of 10% and 50%.
- * The THRESHold below is the insertion sort threshold, and has been adjusted
- * for records of size 48 bytes.
- * The MTHREShold is where we stop finding a better median.
- */
-
-#define THRESH 4 /* threshold for insertion */
-#define MTHRESH 6 /* threshold for median */
-
-static int (*qcmp)(); /* the comparison routine */
-static int qsz; /* size of each record */
-static int thresh; /* THRESHold in chars */
-static int mthresh; /* MTHRESHold in chars */
-
-static void qst(char *, char *);
-
-/*
- * qsort:
- * First, set up some global parameters for qst to share. Then, quicksort
- * with qst(), and then a cleanup insertion sort ourselves. Sound simple?
- * It's not...
- */
-
-void
-qsort(char *base, int n, int size, int (*compar)())
-{
- char c, *i, *j, *lo, *hi;
- char *min, *max;
-
- if (n <= 1)
- return;
- qsz = size;
- qcmp = compar;
- thresh = qsz * THRESH;
- mthresh = qsz * MTHRESH;
- max = base + n * qsz;
- if (n >= THRESH) {
- qst(base, max);
- hi = base + thresh;
- } else {
- hi = max;
- }
- /*
- * First put smallest element, which must be in the first THRESH, in
- * the first position as a sentinel. This is done just by searching
- * the first THRESH elements (or the first n if n < THRESH), finding
- * the min, and swapping it into the first position.
- */
- for (j = lo = base; (lo += qsz) < hi; )
- if (qcmp(j, lo) > 0)
- j = lo;
- if (j != base) {
- /* swap j into place */
- for (i = base, hi = base + qsz; i < hi; ) {
- c = *j;
- *j++ = *i;
- *i++ = c;
- }
- }
- /*
- * With our sentinel in place, we now run the following hyper-fast
- * insertion sort. For each remaining element, min, from [1] to [n-1],
- * set hi to the index of the element AFTER which this one goes.
- * Then, do the standard insertion sort shift on a character at a time
- * basis for each element in the frob.
- */
- for (min = base; (hi = min += qsz) < max; ) {
- while (qcmp(hi -= qsz, min) > 0)
- /* void */;
- if ((hi += qsz) != min) {
- for (lo = min + qsz; --lo >= min; ) {
- c = *lo;
- for (i = j = lo; (j -= qsz) >= hi; i = j)
- *i = *j;
- *i = c;
- }
- }
- }
-}
-
-/*
- * qst:
- * Do a quicksort
- * First, find the median element, and put that one in the first place as the
- * discriminator. (This "median" is just the median of the first, last and
- * middle elements). (Using this median instead of the first element is a big
- * win). Then, the usual partitioning/swapping, followed by moving the
- * discriminator into the right place. Then, figure out the sizes of the two
- * partions, do the smaller one recursively and the larger one via a repeat of
- * this code. Stopping when there are less than THRESH elements in a partition
- * and cleaning up with an insertion sort (in our caller) is a huge win.
- * All data swaps are done in-line, which is space-losing but time-saving.
- * (And there are only three places where this is done).
- */
-
-static void
-qst(char *base, char *max)
-{
- char c, *i, *j, *jj;
- int ii;
- char *mid, *tmp;
- int lo, hi;
-
- /*
- * At the top here, lo is the number of characters of elements in the
- * current partition. (Which should be max - base).
- * Find the median of the first, last, and middle element and make
- * that the middle element. Set j to largest of first and middle.
- * If max is larger than that guy, then it's that guy, else compare
- * max with loser of first and take larger. Things are set up to
- * prefer the middle, then the first in case of ties.
- */
- lo = max - base; /* number of elements as chars */
- do {
- mid = i = base + qsz * ((lo / qsz) >> 1);
- if (lo >= mthresh) {
- j = (qcmp((jj = base), i) > 0 ? jj : i);
- if (qcmp(j, (tmp = max - qsz)) > 0) {
- /* switch to first loser */
- j = (j == jj ? i : jj);
- if (qcmp(j, tmp) < 0)
- j = tmp;
- }
- if (j != i) {
- ii = qsz;
- do {
- c = *i;
- *i++ = *j;
- *j++ = c;
- } while (--ii);
- }
- }
- /*
- * Semi-standard quicksort partitioning/swapping
- */
- for (i = base, j = max - qsz; ; ) {
- while (i < mid && qcmp(i, mid) <= 0)
- i += qsz;
- while (j > mid) {
- if (qcmp(mid, j) <= 0) {
- j -= qsz;
- continue;
- }
- tmp = i + qsz; /* value of i after swap */
- if (i == mid) {
- /* j <-> mid, new mid is j */
- mid = jj = j;
- } else {
- /* i <-> j */
- jj = j;
- j -= qsz;
- }
- goto swap;
- }
- if (i == mid) {
- break;
- } else {
- /* i <-> mid, new mid is i */
- jj = mid;
- tmp = mid = i; /* value of i after swap */
- j -= qsz;
- }
- swap:
- ii = qsz;
- do {
- c = *i;
- *i++ = *jj;
- *jj++ = c;
- } while (--ii);
- i = tmp;
- }
- /*
- * Look at sizes of the two partitions, do the smaller
- * one first by recursion, then do the larger one by
- * making sure lo is its size, base and max are update
- * correctly, and branching back. But only repeat
- * (recursively or by branching) if the partition is
- * of at least size THRESH.
- */
- i = (j = mid) + qsz;
- if ((lo = j - base) <= (hi = max - i)) {
- if (lo >= thresh)
- qst(base, j);
- base = i;
- lo = hi;
- } else {
- if (hi >= thresh)
- qst(i, max);
- max = j;
- }
- } while (lo >= thresh);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/random.c b/usr/src/lib/libbc/libc/gen/common/random.c
deleted file mode 100644
index 1fdee713fe..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/random.c
+++ /dev/null
@@ -1,384 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <stdlib.h>
-
-/*
- * random.c:
- * An improved random number generation package. In addition to the standard
- * rand()/srand() like interface, this package also has a special state info
- * interface. The initstate() routine is called with a seed, an array of
- * bytes, and a count of how many bytes are being passed in; this array is then
- * initialized to contain information for random number generation with that
- * much state information. Good sizes for the amount of state information are
- * 32, 64, 128, and 256 bytes. The state can be switched by calling the
- * setstate() routine with the same array as was initiallized with initstate().
- * By default, the package runs with 128 bytes of state information and
- * generates far better random numbers than a linear congruential generator.
- * If the amount of state information is less than 32 bytes, a simple linear
- * congruential R.N.G. is used.
- * Internally, the state information is treated as an array of longs; the
- * zeroeth element of the array is the type of R.N.G. being used (small
- * integer); the remainder of the array is the state information for the
- * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of
- * state information, which will allow a degree seven polynomial. (Note: the
- * zeroeth word of state information also has some other information stored
- * in it -- see setstate() for details).
- * The random number generation technique is a linear feedback shift register
- * approach, employing trinomials (since there are fewer terms to sum up that
- * way). In this approach, the least significant bit of all the numbers in
- * the state table will act as a linear feedback shift register, and will have
- * period 2^deg - 1 (where deg is the degree of the polynomial being used,
- * assuming that the polynomial is irreducible and primitive). The higher
- * order bits will have longer periods, since their values are also influenced
- * by pseudo-random carries out of the lower bits. The total period of the
- * generator is approximately deg*(2**deg - 1); thus doubling the amount of
- * state information has a vast influence on the period of the generator.
- * Note: the deg*(2**deg - 1) is an approximation only good for large deg,
- * when the period of the shift register is the dominant factor. With deg
- * equal to seven, the period is actually much longer than the 7*(2**7 - 1)
- * predicted by this formula.
- */
-
-
-
-/*
- * For each of the currently supported random number generators, we have a
- * break value on the amount of state information (you need at least this
- * many bytes of state info to support this random number generator), a degree
- * for the polynomial (actually a trinomial) that the R.N.G. is based on, and
- * the separation between the two lower order coefficients of the trinomial.
- */
-
-#define TYPE_0 0 /* linear congruential */
-#define BREAK_0 8
-#define DEG_0 0
-#define SEP_0 0
-
-#define TYPE_1 1 /* x**7 + x**3 + 1 */
-#define BREAK_1 32
-#define DEG_1 7
-#define SEP_1 3
-
-#define TYPE_2 2 /* x**15 + x + 1 */
-#define BREAK_2 64
-#define DEG_2 15
-#define SEP_2 1
-
-#define TYPE_3 3 /* x**31 + x**3 + 1 */
-#define BREAK_3 128
-#define DEG_3 31
-#define SEP_3 3
-
-#define TYPE_4 4 /* x**63 + x + 1 */
-#define BREAK_4 256
-#define DEG_4 63
-#define SEP_4 1
-
-
-/*
- * Array versions of the above information to make code run faster -- relies
- * on fact that TYPE_i == i.
- */
-
-#define MAX_TYPES 5 /* max number of types above */
-
-static struct _randomjunk {
- int degrees[MAX_TYPES];
- int seps[MAX_TYPES];
- long randtbl[ DEG_3 + 1 ];
-/*
- * fptr and rptr are two pointers into the state info, a front and a rear
- * pointer. These two pointers are always rand_sep places aparts, as they cycle
- * cyclically through the state information. (Yes, this does mean we could get
- * away with just one pointer, but the code for random() is more efficient this
- * way). The pointers are left positioned as they would be from the call
- * initstate(1, randtbl, 128)
- * (The position of the rear pointer, rptr, is really 0 (as explained above
- * in the initialization of randtbl) because the state table pointer is set
- * to point to randtbl[1] (as explained below).
- */
- long *fptr, *rptr;
-/*
- * The following things are the pointer to the state information table,
- * the type of the current generator, the degree of the current polynomial
- * being used, and the separation between the two pointers.
- * Note that for efficiency of random(), we remember the first location of
- * the state information, not the zeroeth. Hence it is valid to access
- * state[-1], which is used to store the type of the R.N.G.
- * Also, we remember the last location, since this is more efficient than
- * indexing every time to find the address of the last element to see if
- * the front and rear pointers have wrapped.
- */
- long *state;
- int rand_type, rand_deg, rand_sep;
- long *end_ptr;
-} *__randomjunk, *_randomjunk(void), _randominit = {
- /*
- * Initially, everything is set up as if from :
- * initstate(1, &randtbl, 128);
- * Note that this initialization takes advantage of the fact
- * that srandom() advances the front and rear pointers 10*rand_deg
- * times, and hence the rear pointer which starts at 0 will also
- * end up at zero; thus the zeroeth element of the state
- * information, which contains info about the current
- * position of the rear pointer is just
- * MAX_TYPES*(rptr - state) + TYPE_3 == TYPE_3.
- */
- { DEG_0, DEG_1, DEG_2, DEG_3, DEG_4 },
- { SEP_0, SEP_1, SEP_2, SEP_3, SEP_4 },
- { TYPE_3,
- (long)0x9a319039, (long)0x32d9c024, (long)0x9b663182, (long)0x5da1f342,
- (long)0xde3b81e0, (long)0xdf0a6fb5, (long)0xf103bc02, (long)0x48f340fb,
- (long)0x7449e56b, (long)0xbeb1dbb0, (long)0xab5c5918, (long)0x946554fd,
- (long)0x8c2e680f, (long)0xeb3d799f, (long)0xb11ee0b7, (long)0x2d436b86,
- (long)0xda672e2a, (long)0x1588ca88, (long)0xe369735d, (long)0x904f35f7,
- (long)0xd7158fd6, (long)0x6fa6f051, (long)0x616e6b96, (long)0xac94efdc,
- (long)0x36413f93, (long)0xc622c298, (long)0xf5a42ab8, (long)0x8a88d77b,
- (long)0xf5ad9d0e, (long)0x8999220b, (long)0x27fb47b9 },
- &_randominit.randtbl[ SEP_3 + 1 ],
- &_randominit.randtbl[1],
- &_randominit.randtbl[1],
- TYPE_3, DEG_3, SEP_3,
- &_randominit.randtbl[ DEG_3 + 1]
-};
-
-long random(void);
-
-static struct _randomjunk *
-_randomjunk(void)
-{
- struct _randomjunk *rp = __randomjunk;
-
- if (rp == 0) {
- rp = (struct _randomjunk *)malloc(sizeof (*rp));
- if (rp == 0)
- return (0);
- *rp = _randominit;
- __randomjunk = rp;
- }
- return (rp);
-}
-
-/*
- * srandom:
- * Initialize the random number generator based on the given seed. If the
- * type is the trivial no-state-information type, just remember the seed.
- * Otherwise, initializes state[] based on the given "seed" via a linear
- * congruential generator. Then, the pointers are set to known locations
- * that are exactly rand_sep places apart. Lastly, it cycles the state
- * information a given number of times to get rid of any initial dependencies
- * introduced by the L.C.R.N.G.
- * Note that the initialization of randtbl[] for default usage relies on
- * values produced by this routine.
- */
-
-void
-srandom(unsigned x)
-{
- struct _randomjunk *rp = _randomjunk();
- int i;
-
- if (rp == 0)
- return;
- if (rp->rand_type == TYPE_0) {
- rp->state[0] = x;
- } else {
- rp->state[0] = x;
- for (i = 1; i < rp->rand_deg; i++) {
- rp->state[i] = 1103515245*rp->state[i - 1] + 12345;
- }
- rp->fptr = &rp->state[rp->rand_sep];
- rp->rptr = &rp->state[0];
- for (i = 0; i < 10 * rp->rand_deg; i++)
- random();
- }
-}
-
-
-
-/*
- * initstate:
- * Initialize the state information in the given array of n bytes for
- * future random number generation. Based on the number of bytes we
- * are given, and the break values for the different R.N.G.'s, we choose
- * the best (largest) one we can and set things up for it. srandom() is
- * then called to initialize the state information.
- * Note that on return from srandom(), we set state[-1] to be the type
- * multiplexed with the current value of the rear pointer; this is so
- * successive calls to initstate() won't lose this information and will
- * be able to restart with setstate().
- * Note: the first thing we do is save the current state, if any, just like
- * setstate() so that it doesn't matter when initstate is called.
- * Returns a pointer to the old state.
- *
- * Arguments:
- * seed: seed for R. N. G.
- * arg_state: pointer to state array
- * n: # bytes of state info
- */
-
-char *
-initstate(unsigned seed, char *arg_state, int n)
-{
- struct _randomjunk *rp = _randomjunk();
- char *ostate;
-
- if (rp == 0)
- return (0);
- ostate = (char *)(&rp->state[-1]);
-
- if (rp->rand_type == TYPE_0) rp->state[-1] = rp->rand_type;
- else rp->state[-1] =
- MAX_TYPES*(rp->rptr - rp->state) + rp->rand_type;
- if (n < BREAK_0) {
- fprintf(stderr,
- "initstate: state array too small, ignored; minimum size is %d bytes\n",
- BREAK_0);
- return (0);
- } else if (n < BREAK_1) {
- rp->rand_type = TYPE_0;
- rp->rand_deg = DEG_0;
- rp->rand_sep = SEP_0;
- } else if (n < BREAK_2) {
- rp->rand_type = TYPE_1;
- rp->rand_deg = DEG_1;
- rp->rand_sep = SEP_1;
- } else if (n < BREAK_3) {
- rp->rand_type = TYPE_2;
- rp->rand_deg = DEG_2;
- rp->rand_sep = SEP_2;
- } else if (n < BREAK_4) {
- rp->rand_type = TYPE_3;
- rp->rand_deg = DEG_3;
- rp->rand_sep = SEP_3;
- } else {
- rp->rand_type = TYPE_4;
- rp->rand_deg = DEG_4;
- rp->rand_sep = SEP_4;
- }
- rp->state = &((long *)arg_state)[1]; /* first location */
- rp->end_ptr = &rp->state[rp->rand_deg]; /* set end_ptr before srandom */
- srandom(seed);
- rp->state[-1] = (rp->rand_type == TYPE_0) ? rp->rand_type
- : MAX_TYPES * (rp->rptr - rp->state) + rp->rand_type;
- return (ostate);
-}
-
-
-/*
- * setstate:
- * Restore the state from the given state array.
- * Note: it is important that we also remember the locations of the pointers
- * in the current state information, and restore the locations of the pointers
- * from the old state information. This is done by multiplexing the pointer
- * location into the zeroeth word of the state information.
- * Note that due to the order in which things are done, it is OK to call
- * setstate() with the same state as the current state.
- * Returns a pointer to the old state information.
- */
-
-char *
-setstate(char *arg_state)
-{
- struct _randomjunk *rp = _randomjunk();
- long *new_state;
- int type;
- int rear;
- char *ostate;
-
- if (rp == 0)
- return (0);
- new_state = (long *)arg_state;
- type = new_state[0] % MAX_TYPES;
- rear = new_state[0] / MAX_TYPES;
- ostate = (char *)(&rp->state[-1]);
-
- rp->state[-1] = (rp->rand_type == TYPE_0) ? rp->rand_type
- : MAX_TYPES*(rp->rptr - rp->state) + rp->rand_type;
- switch (type) {
- case TYPE_0:
- case TYPE_1:
- case TYPE_2:
- case TYPE_3:
- case TYPE_4:
- rp->rand_type = type;
- rp->rand_deg = rp->degrees[type];
- rp->rand_sep = rp->seps[type];
- break;
-
- default:
- fprintf(stderr, "setstate: invalid state info; not changed.\n");
- }
- rp->state = &new_state[1];
- if (rp->rand_type != TYPE_0) {
- rp->rptr = &rp->state[rear];
- rp->fptr = &rp->state[(rear + rp->rand_sep) % rp->rand_deg];
- }
- rp->end_ptr = &rp->state[rp->rand_deg]; /* set end_ptr too */
- return (ostate);
-}
-
-
-/*
- * random:
- * If we are using the trivial TYPE_0 R.N.G., just do the old linear
- * congruential bit. Otherwise, we do our fancy trinomial stuff, which is the
- * same in all ther other cases due to all the global variables that have been
- * set up. The basic operation is to add the number at the rear pointer into
- * the one at the front pointer. Then both pointers are advanced to the next
- * location cyclically in the table. The value returned is the sum generated,
- * reduced to 31 bits by throwing away the "least random" low bit.
- * Note: the code takes advantage of the fact that both the front and
- * rear pointers can't wrap on the same call by not testing the rear
- * pointer if the front one has wrapped.
- * Returns a 31-bit random number.
- */
-
-long
-random(void)
-{
- struct _randomjunk *rp = _randomjunk();
- long i;
-
- if (rp == 0)
- return (0);
- if (rp->rand_type == TYPE_0) {
- i = rp->state[0] = (rp->state[0]*1103515245 + 12345)&0x7fffffff;
- } else {
- *rp->fptr += *rp->rptr;
- i = (*rp->fptr >> 1)&0x7fffffff; /* chucking least random bit */
- if (++rp->fptr >= rp->end_ptr) {
- rp->fptr = rp->state;
- ++rp->rptr;
- } else if (++rp->rptr >= rp->end_ptr)
- rp->rptr = rp->state;
- }
- return (i);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/readdir.c b/usr/src/lib/libbc/libc/gen/common/readdir.c
deleted file mode 100644
index c4f2c65652..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/readdir.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/param.h>
-#include <dirent.h>
-
-/*
- * get next entry in a directory.
- */
-struct dirent *
-readdir(dirp)
- register DIR *dirp;
-{
- register struct dirent *dp;
- int saveloc = 0;
-
-next:
- if (dirp->dd_size != 0) {
- dp = (struct dirent *)&dirp->dd_buf[dirp->dd_loc];
- saveloc = dirp->dd_loc; /* save for possible EOF */
- dirp->dd_loc += dp->d_reclen;
- }
- if (dirp->dd_loc >= dirp->dd_size)
- dirp->dd_loc = dirp->dd_size = 0;
-
- if (dirp->dd_size == 0 /* refill buffer */
- && (dirp->dd_size = getdents(dirp->dd_fd, dirp->dd_buf, dirp->dd_bsize)
- ) <= 0
- ) {
- if (dirp->dd_size == 0) /* This means EOF */
- dirp->dd_loc = saveloc; /* EOF so save for telldir */
- return (NULL); /* error or EOF */
- }
-
- dp = (struct dirent *)&dirp->dd_buf[dirp->dd_loc];
- if (dp->d_reclen <= 0)
- return (NULL);
- if (dp->d_fileno == 0)
- goto next;
- dirp->dd_off = dp->d_off;
- return(dp);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/realpath.c b/usr/src/lib/libbc/libc/gen/common/realpath.c
deleted file mode 100644
index 2fa7c5333a..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/realpath.c
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1987 by Sun Microsystems, Inc.
- */
-
-#include <strings.h>
-#include <sys/param.h>
-#include <errno.h>
-
-extern char *getwd();
-
-/* LINTLIBRARY */
-
-/*
- * Input name in raw, canonicalized pathname output to canon. If dosymlinks
- * is nonzero, resolves all symbolic links encountered during canonicalization
- * into an equivalent symlink-free form. Returns 0 on success, -1 on failure.
- * The routine fails if the current working directory can't be obtained or if
- * either of the arguments is NULL.
- *
- * Sets errno on failure.
- */
-int
-pathcanon(raw, canon, dosymlinks)
- char *raw,
- *canon;
- int dosymlinks;
-{
- register char *s,
- *d;
- register char *limit = canon + MAXPATHLEN;
- char *modcanon;
- int nlink = 0;
-
- /*
- * Do a bit of sanity checking.
- */
- if (raw == NULL || canon == NULL) {
- errno = EINVAL;
- return (-1);
- }
-
- /*
- * If the path in raw is not already absolute, convert it to that form.
- * In any case, initialize canon with the absolute form of raw. Make
- * sure that none of the operations overflow the corresponding buffers.
- * The code below does the copy operations by hand so that it can easily
- * keep track of whether overflow is about to occur.
- */
- s = raw;
- d = canon;
- if (*s != '/') {
- /* Relative; prepend the working directory. */
- if (getwd(d) == NULL) {
- /* Use whatever errno value getwd may have left around. */
- return (-1);
- }
- d += strlen(d);
- /* Add slash to separate working directory from relative part. */
- if (d < limit)
- *d++ = '/';
- modcanon = d;
- } else
- modcanon = canon;
- while (d < limit && *s)
- *d++ = *s++;
-
- /* Add a trailing slash to simplify the code below. */
- s = "/";
- while (d < limit && (*d++ = *s++))
- continue;
-
-
- /*
- * Canonicalize the path. The strategy is to update in place, with
- * d pointing to the end of the canonicalized portion and s to the
- * current spot from which we're copying. This works because
- * canonicalization doesn't increase path length, except as discussed
- * below. Note also that the path has had a slash added at its end.
- * This greatly simplifies the treatment of boundary conditions.
- */
- d = s = modcanon;
- while (d < limit && *s) {
- if ((*d++ = *s++) == '/' && d > canon + 1) {
- register char *t = d - 2;
-
- switch (*t) {
- case '/':
- /* Found // in the name. */
- d--;
- continue;
- case '.':
- switch (*--t) {
- case '/':
- /* Found /./ in the name. */
- d -= 2;
- continue;
- case '.':
- if (*--t == '/') {
- /* Found /../ in the name. */
- while (t > canon && *--t != '/')
- continue;
- d = t + 1;
- }
- continue;
- default:
- break;
- }
- break;
- default:
- break;
- }
- /*
- * We're at the end of a component. If dosymlinks is set
- * see whether the component is a symbolic link. If so,
- * replace it by its contents.
- */
- if (dosymlinks) {
- char link[MAXPATHLEN + 1];
- register int llen;
-
- /*
- * See whether it's a symlink by trying to read it.
- *
- * Start by isolating it.
- */
- *(d - 1) = '\0';
- if ((llen = readlink(canon, link, sizeof link)) >= 0) {
- /* Make sure that there are no circular links. */
- nlink++;
- if (nlink > MAXSYMLINKS) {
- errno = ELOOP;
- return (-1);
- }
- /*
- * The component is a symlink. Since its value can be
- * of arbitrary size, we can't continue copying in place.
- * Instead, form the new path suffix in the link buffer
- * and then copy it back to its proper spot in canon.
- */
- t = link + llen;
- *t++ = '/';
- /*
- * Copy the remaining unresolved portion to the end
- * of the symlink. If the sum of the unresolved part and
- * the readlink exceeds MAXPATHLEN, the extra bytes
- * will be dropped off. Too bad!
- */
- (void) strncpy(t, s, sizeof link - llen - 1);
- link[sizeof link - 1] = '\0';
- /*
- * If the link's contents are absolute, copy it back
- * to the start of canon, otherwise to the beginning of
- * the link's position in the path.
- */
- if (link[0] == '/') {
- /* Absolute. */
- (void) strcpy(canon, link);
- d = s = canon;
- }
- else {
- /*
- * Relative: find beginning of component and copy.
- */
- --d;
- while (d > canon && *--d != '/')
- continue;
- s = ++d;
- /*
- * If the sum of the resolved part, the readlink
- * and the remaining unresolved part exceeds
- * MAXPATHLEN, the extra bytes will be dropped off.
- */
- if (strlen(link) >= (limit - s)) {
- (void) strncpy(s, link, limit - s);
- *(limit - 1) = '\0';
- } else {
- (void) strcpy(s, link);
- }
- }
- continue;
- } else {
- /*
- * readlink call failed. It can be because it was
- * not a link (i.e. a file, dir etc.) or because the
- * the call actually failed.
- */
- if (errno != EINVAL)
- return (-1);
- *(d - 1) = '/'; /* Restore it */
- }
- } /* if (dosymlinks) */
- }
- } /* while */
-
- /* Remove the trailing slash that was added above. */
- if (*(d - 1) == '/' && d > canon + 1)
- d--;
- *d = '\0';
- return (0);
-}
-
-/*
- * Canonicalize the path given in raw, resolving away all symbolic link
- * components. Store the result into the buffer named by canon, which
- * must be long enough (MAXPATHLEN bytes will suffice). Returns NULL
- * on failure and canon on success.
- *
- * The routine indirectly invokes the readlink() system call and getwd()
- * so it inherits the possibility of hanging due to inaccessible file
- * system resources.
- */
-char *
-realpath(raw, canon)
- char *raw;
- char *canon;
-{
- return (pathcanon(raw, canon, 1) < 0 ? NULL : canon);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/regex.c b/usr/src/lib/libbc/libc/gen/common/regex.c
deleted file mode 100644
index e6bd73361a..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/regex.c
+++ /dev/null
@@ -1,437 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * routines to do regular expression matching
- *
- * Entry points:
- *
- * re_comp(s)
- * char *s;
- * ... returns 0 if the string s was compiled successfully,
- * a pointer to an error message otherwise.
- * If passed 0 or a null string returns without changing
- * the currently compiled re (see note 11 below).
- *
- * re_exec(s)
- * char *s;
- * ... returns 1 if the string s matches the last compiled regular
- * expression,
- * 0 if the string s failed to match the last compiled
- * regular expression, and
- * -1 if the compiled regular expression was invalid
- * (indicating an internal error).
- *
- * The strings passed to both re_comp and re_exec may have trailing or
- * embedded newline characters; they are terminated by nulls.
- *
- * The identity of the author of these routines is lost in antiquity;
- * this is essentially the same as the re code in the original V6 ed.
- *
- * The regular expressions recognized are described below. This description
- * is essentially the same as that for ed.
- *
- * A regular expression specifies a set of strings of characters.
- * A member of this set of strings is said to be matched by
- * the regular expression. In the following specification for
- * regular expressions the word `character' means any character but NUL.
- *
- * 1. Any character except a special character matches itself.
- * Special characters are the regular expression delimiter plus
- * \ [ . and sometimes ^ * $.
- * 2. A . matches any character.
- * 3. A \ followed by any character except a digit or ( )
- * matches that character.
- * 4. A nonempty string s bracketed [s] (or [^s]) matches any
- * character in (or not in) s. In s, \ has no special meaning,
- * and ] may only appear as the first letter. A substring
- * a-b, with a and b in ascending ASCII order, stands for
- * the inclusive range of ASCII characters.
- * 5. A regular expression of form 1-4 followed by * matches a
- * sequence of 0 or more matches of the regular expression.
- * 6. A regular expression, x, of form 1-8, bracketed \(x\)
- * matches what x matches.
- * 7. A \ followed by a digit n matches a copy of the string that the
- * bracketed regular expression beginning with the nth \( matched.
- * 8. A regular expression of form 1-8, x, followed by a regular
- * expression of form 1-7, y matches a match for x followed by
- * a match for y, with the x match being as long as possible
- * while still permitting a y match.
- * 9. A regular expression of form 1-8 preceded by ^ (or followed
- * by $), is constrained to matches that begin at the left
- * (or end at the right) end of a line.
- * 10. A regular expression of form 1-9 picks out the longest among
- * the leftmost matches in a line.
- * 11. An empty regular expression stands for a copy of the last
- * regular expression encountered.
- */
-
-/*
- * constants for re's
- */
-#define CBRA 1
-#define CCHR 2
-#define CDOT 4
-#define CCL 6
-#define NCCL 8
-#define CDOL 10
-#define CEOF 11
-#define CKET 12
-#define CBACK 18
-
-#define CSTAR 01
-
-#define ESIZE 512
-#define NBRA 9
-
-static struct re_globals {
- char _expbuf[ESIZE];
- char *_braslist[NBRA], *_braelist[NBRA];
- char _circf;
-} *re_globals;
-#define expbuf (_re->_expbuf)
-#define braslist (_re->_braslist)
-#define braelist (_re->_braelist)
-#define circf (_re->_circf)
-
-static int advance(char *, char *);
-static int backref(int, char *);
-static int cclass(char *, char, int);
-
-/*
- * compile the regular expression argument into a dfa
- */
-char *
-re_comp(char *sp)
-{
- int c;
- struct re_globals *_re = re_globals;
- char *ep;
- int cclcnt, numbra = 0;
- char *lastep = 0;
- char bracket[NBRA];
- char *bracketp = &bracket[0];
- char *retoolong = "Regular expression too long";
-
- if (_re == 0) {
- _re = (struct re_globals *)calloc(1, sizeof (*_re));
- if (_re == 0)
- return ("Out of memory");
- re_globals = _re;
- }
- ep = expbuf;
-
-#define comerr(msg) {expbuf[0] = 0; numbra = 0; return(msg); }
-
- if (sp == 0 || *sp == '\0') {
- if (*ep == 0)
- return("No previous regular expression");
- return (0);
- }
- if (*sp == '^') {
- circf = 1;
- sp++;
- }
- else
- circf = 0;
- for (;;) {
- if (ep >= &expbuf[ESIZE])
- comerr(retoolong);
- if ((c = *sp++) == '\0') {
- if (bracketp != bracket)
- comerr("unmatched \\(");
- *ep++ = CEOF;
- *ep++ = 0;
- return (0);
- }
- if (c != '*')
- lastep = ep;
- switch (c) {
-
- case '.':
- *ep++ = CDOT;
- continue;
-
- case '*':
- if (lastep == 0 || *lastep == CBRA || *lastep == CKET)
- goto defchar;
- *lastep |= CSTAR;
- continue;
-
- case '$':
- if (*sp != '\0')
- goto defchar;
- *ep++ = CDOL;
- continue;
-
- case '[':
- *ep++ = CCL;
- *ep++ = 0;
- cclcnt = 1;
- if ((c = *sp++) == '^') {
- c = *sp++;
- ep[-2] = NCCL;
- }
- do {
- if (c == '\0')
- comerr("missing ]");
- if (c == '-' && ep [-1] != 0) {
- if ((c = *sp++) == ']') {
- *ep++ = '-';
- cclcnt++;
- break;
- }
- while (ep[-1] < c) {
- *ep = ep[-1] + 1;
- ep++;
- cclcnt++;
- if (ep >= &expbuf[ESIZE])
- comerr(retoolong);
- }
- }
- *ep++ = c;
- cclcnt++;
- if (ep >= &expbuf[ESIZE])
- comerr(retoolong);
- } while ((c = *sp++) != ']');
- lastep[1] = cclcnt;
- continue;
-
- case '\\':
- if ((c = *sp++) == '(') {
- if (numbra >= NBRA)
- comerr("too many \\(\\) pairs");
- *bracketp++ = numbra;
- *ep++ = CBRA;
- *ep++ = numbra++;
- continue;
- }
- if (c == ')') {
- if (bracketp <= bracket)
- comerr("unmatched \\)");
- *ep++ = CKET;
- *ep++ = *--bracketp;
- continue;
- }
- if (c >= '1' && c < ('1' + NBRA)) {
- *ep++ = CBACK;
- *ep++ = c - '1';
- continue;
- }
- *ep++ = CCHR;
- *ep++ = c;
- continue;
-
- defchar:
- default:
- *ep++ = CCHR;
- *ep++ = c;
- }
- }
-}
-
-/*
- * match the argument string against the compiled re
- */
-int
-re_exec(char *p1)
-{
- struct re_globals *_re = re_globals;
- char *p2;
- int c;
- int rv;
-
- if (_re == 0)
- return (0);
- p2 = expbuf;
- for (c = 0; c < NBRA; c++) {
- braslist[c] = 0;
- braelist[c] = 0;
- }
- if (circf)
- return((advance(p1, p2)));
- /*
- * fast check for first character
- */
- if (*p2 == CCHR) {
- c = p2[1];
- do {
- if (*p1 != c)
- continue;
- if (rv = advance(p1, p2))
- return(rv);
- } while (*p1++);
- return(0);
- }
- /*
- * regular algorithm
- */
- do
- if (rv = advance(p1, p2))
- return(rv);
- while (*p1++);
- return(0);
-}
-
-/*
- * try to match the next thing in the dfa
- */
-static int
-advance(char *lp, char *ep)
-{
- char *curlp;
- int ct, i;
- int rv;
- struct re_globals *_re = re_globals;
-
- for (;;)
- switch (*ep++) {
-
- case CCHR:
- if (*ep++ == *lp++)
- continue;
- return(0);
-
- case CDOT:
- if (*lp++)
- continue;
- return(0);
-
- case CDOL:
- if (*lp == '\0')
- continue;
- return(0);
-
- case CEOF:
- return(1);
-
- case CCL:
- if (cclass(ep, *lp++, 1)) {
- ep += *ep;
- continue;
- }
- return(0);
-
- case NCCL:
- if (cclass(ep, *lp++, 0)) {
- ep += *ep;
- continue;
- }
- return(0);
-
- case CBRA:
- braslist[*ep++] = lp;
- continue;
-
- case CKET:
- braelist[*ep++] = lp;
- continue;
-
- case CBACK:
- if (braelist[i = *ep++] == 0)
- return(-1);
- if (backref(i, lp)) {
- lp += braelist[i] - braslist[i];
- continue;
- }
- return(0);
-
- case CBACK|CSTAR:
- if (braelist[i = *ep++] == 0)
- return(-1);
- curlp = lp;
- ct = braelist[i] - braslist[i];
- while (backref(i, lp))
- lp += ct;
- while (lp >= curlp) {
- if (rv = advance(lp, ep))
- return(rv);
- lp -= ct;
- }
- continue;
-
- case CDOT|CSTAR:
- curlp = lp;
- while (*lp++)
- ;
- goto star;
-
- case CCHR|CSTAR:
- curlp = lp;
- while (*lp++ == *ep)
- ;
- ep++;
- goto star;
-
- case CCL|CSTAR:
- case NCCL|CSTAR:
- curlp = lp;
- while (cclass(ep, *lp++, ep[-1] == (CCL|CSTAR)))
- ;
- ep += *ep;
- goto star;
-
- star:
- do {
- lp--;
- if (rv = advance(lp, ep))
- return(rv);
- } while (lp > curlp);
- return(0);
-
- default:
- return(-1);
- }
-}
-
-static int
-backref(int i, char *lp)
-{
- char *bp;
- struct re_globals *_re = re_globals;
-
- bp = braslist[i];
- while (*bp++ == *lp++)
- if (bp >= braelist[i])
- return (1);
- return (0);
-}
-
-static int
-cclass(char *set, char c, int af)
-{
- int n;
-
- if (c == 0)
- return(0);
- n = *set++;
- while (--n)
- if (*set++ == c)
- return (af);
- return (!af);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/rindex.c b/usr/src/lib/libbc/libc/gen/common/rindex.c
deleted file mode 100644
index fd442e4b13..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/rindex.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 4.1 80/12/21 */
-
-/*
- * Return the ptr in sp at which the character c last
- * appears; NULL if not found
- */
-
-#define NULL 0
-
-char *
-rindex(sp, c)
- register char *sp, c;
-{
- register char *r;
-
- r = NULL;
- do {
- if (*sp == c)
- r = sp;
- } while (*sp++);
- return (r);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/scandir.c b/usr/src/lib/libbc/libc/gen/common/scandir.c
deleted file mode 100644
index 633354971b..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/scandir.c
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- */
-
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Scan the directory dirname calling select to make a list of selected
- * directory entries then sort using qsort and compare routine dcomp.
- * Returns the number of entries and a pointer to a list of pointers to
- * struct direct (through namelist). Returns -1 if there were any errors.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/dir.h>
-
-int
-scandir(char *dirname, struct direct *(*namelist[]),
- int (*select)(), int (*dcomp)())
-{
- struct direct *d, *p, **names;
- int nitems;
- char *cp1, *cp2;
- struct stat stb;
- long arraysz;
- DIR *dirp;
-
- if ((dirp = opendir(dirname)) == NULL)
- return (-1);
- if (fstat(dirp->dd_fd, &stb) < 0)
- return (-1);
-
- /*
- * estimate the array size by taking the size of the directory file
- * and dividing it by a multiple of the minimum size entry.
- */
- arraysz = (stb.st_size / 24);
- names = (struct direct **)malloc(arraysz * sizeof(struct direct *));
- if (names == NULL)
- return (-1);
-
- nitems = 0;
- while ((d = readdir(dirp)) != NULL) {
- if (select != NULL && !(*select)(d))
- continue; /* just selected names */
- /*
- * Make a minimum size copy of the data
- */
- p = (struct direct *)malloc(DIRSIZ(d));
- if (p == NULL)
- return (-1);
- p->d_ino = d->d_ino;
- p->d_reclen = d->d_reclen;
- p->d_namlen = d->d_namlen;
- for (cp1 = p->d_name, cp2 = d->d_name; *cp1++ = *cp2++; );
- /*
- * Check to make sure the array has space left and
- * realloc the maximum size.
- */
- if (++nitems >= arraysz) {
- if (fstat(dirp->dd_fd, &stb) < 0)
- return (-1); /* just might have grown */
- arraysz = stb.st_size / 12;
- names = (struct direct **)realloc((char *)names,
- arraysz * sizeof(struct direct *));
- if (names == NULL)
- return (-1);
- }
- names[nitems-1] = p;
- }
- closedir(dirp);
- if (nitems && dcomp != NULL)
- qsort(names, nitems, sizeof(struct direct *), dcomp);
- *namelist = names;
- return (nitems);
-}
-
-/*
- * Alphabetic order comparison routine for those who want it.
- */
-int
-alphasort(struct direct **d1, struct direct **d2)
-{
- return (strcmp((*d1)->d_name, (*d2)->d_name));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/seconvert.c b/usr/src/lib/libbc/libc/gen/common/seconvert.c
deleted file mode 100644
index 99e86a8656..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/seconvert.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include "base_conversion.h"
-
-char *
-seconvert(arg, ndigits, decpt, sign, buf)
- single *arg;
- int ndigits, *decpt, *sign;
- char *buf;
-{
- decimal_mode dm;
- decimal_record dr;
- fp_exception_field_type ef;
- int i;
- static char *nanstring = "NaN";
- static char *infstring = "Infinity";
- char *pc;
- int nc;
-
- dm.rd = fp_direction; /* Rounding direction. */
- dm.df = floating_form; /* E format. */
- dm.ndigits = ndigits; /* Number of significant digits. */
- single_to_decimal(arg, &dm, &dr, &ef);
- *sign = dr.sign;
- switch (dr.fpclass) {
- case fp_normal:
- case fp_subnormal:
- *decpt = dr.exponent + ndigits;
- for (i = 0; i < ndigits; i++)
- buf[i] = dr.ds[i];
- buf[ndigits] = 0;
- break;
- case fp_zero:
- *decpt = 1;
- for (i = 0; i < ndigits; i++)
- buf[i] = '0';
- buf[ndigits] = 0;
- break;
- case fp_infinity:
- *decpt = 0;
- pc = infstring;
- if (ndigits < 8)
- nc = 3;
- else
- nc = 8;
- goto movestring;
- case fp_quiet:
- case fp_signaling:
- *decpt = 0;
- pc = nanstring;
- nc = 3;
-movestring:
- for (i = 0; i < nc; i++)
- buf[i] = pc[i];
- buf[nc] = 0;
- break;
- }
- return buf; /* For compatibility with ecvt. */
-}
-
-char *
-sfconvert(arg, ndigits, decpt, sign, buf)
- single *arg;
- int ndigits, *decpt, *sign;
- char *buf;
-{
- decimal_mode dm;
- decimal_record dr;
- fp_exception_field_type ef;
- int i;
-
- dm.rd = fp_direction; /* Rounding direction. */
- dm.df = fixed_form; /* F format. */
- dm.ndigits = ndigits; /* Number of digits after point. */
- single_to_decimal(arg, &dm, &dr, &ef);
- *sign = dr.sign;
- switch (dr.fpclass) {
- case fp_normal:
- case fp_subnormal:
- if (ndigits >= 0)
- *decpt = dr.ndigits - ndigits;
- else
- *decpt = dr.ndigits;
- for (i = 0; i < dr.ndigits; i++)
- buf[i] = dr.ds[i];
- buf[dr.ndigits] = 0;
- break;
- case fp_zero:
- *decpt = 0;
- buf[0] = '0';
- for (i = 1; i < ndigits; i++)
- buf[i] = '0';
- buf[i] = 0;
- break;
- case fp_infinity:
- *decpt = 0;
- if (ndigits < 8)
- buf = "Inf";
- else
- buf = "Infinity";
- break;
- case fp_quiet:
- case fp_signaling:
- *decpt = 0;
- buf = "NaN";
- break;
- }
- return buf; /* For compatibility with fcvt. */
-}
-
-extern void _gcvt();
-
-char *
-sgconvert(number, ndigit, trailing, buf)
- single *number;
- int ndigit, trailing;
- char *buf;
-{
- decimal_mode dm;
- decimal_record dr;
- fp_exception_field_type fef;
-
- dm.rd = fp_direction;
- dm.df = floating_form;
- dm.ndigits = ndigit;
- single_to_decimal(number, &dm, &dr, &fef);
- _gcvt(ndigit, &dr, trailing, buf);
- return (buf);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/seekdir.c b/usr/src/lib/libbc/libc/gen/common/seekdir.c
deleted file mode 100644
index 55facc6aa2..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/seekdir.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/param.h>
-#include <dirent.h>
-
-/*
- * seek to an entry in a directory.
- * Only values returned by "telldir" should be passed to seekdir.
- */
-void
-seekdir(dirp, tell)
- register DIR *dirp;
- register long tell;
-{
- extern long lseek();
- long curloc;
-
- curloc = telldir(dirp);
- if (curloc == tell)
- return;
- dirp->dd_loc = 0;
- (void) lseek(dirp->dd_fd, tell, 0);
- dirp->dd_size = 0;
- dirp->dd_off = tell;
-}
-
-#undef rewinddir
-
-void
-rewinddir(dirp)
- DIR *dirp;
-{
- seekdir(dirp, 0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/setlocale.c b/usr/src/lib/libbc/libc/gen/common/setlocale.c
deleted file mode 100644
index a6b815ea40..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/setlocale.c
+++ /dev/null
@@ -1,831 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1995 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/fcntl.h>
-#include <locale.h>
-#include <stdlib.h>
-#include "codeset.h"
-#include <ctype.h>
-#include <string.h>
-#include <memory.h>
-#include <malloc.h>
-#include <sys/param.h> /* for MAXPATHLEN */
-#include <sys/stat.h>
-#include <errno.h>
-#include <limits.h>
-
-#define TRAILER ".ci"
-
-
-struct _code_set_info _code_set_info = {
- NULL,
- CODESET_NONE, /* no codeset */
- NULL, /* not defined */
- 0,
-};
-
-/* tolower() and toupper() conversion table
- * is hidden here to avoid being placed in the
- * extern .sa file in the dynamic version of libc
- */
-
-char _ctype_ul[] = { 0,
-
-/* 0 1 2 3 4 5 6 7 */
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- ' ', '!', '"', '#', '$', '%', '&', '\'',
- '(', ')', '*', '+', ',', '-', '.', '/',
- '0', '1', '2', '3', '4', '5', '6', '7',
- '8', '9', ':', ';', '<', '=', '>', '?',
- '@', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
- 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
- 'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
- 'x', 'y', 'z', '[', '\\', ']', '^', '_',
- '`', 'A', 'B', 'C', 'D', 'E', 'F', 'G',
- 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
- 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
- 'X', 'Y', 'Z', '{', '|', '}', '~', '\177',
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
-};
-
-/* following layout is:
- * LC_NUMERIC LC_TIME LC_MONETARY LANGINFO LC_COLLATE LC_MESSAGES
- */
-char _locales[MAXLOCALE - 1][MAXLOCALENAME + 1] ;
-
-char _my_time[MAXLOCALENAME + 1];
-
-/* The array Default holds the systems notion of default locale. It is normally
- * found in {LOCALE}/.default and moved to here. Note there is only one
- * default locale spanning all categories
- */
-
-static char Default[MAXLOCALENAME+1];
-
-struct langinfo _langinfo;
-struct dtconv *_dtconv = NULL;
-
-static char *realmonths = NULL;
-static char *realdays = NULL;
-static char *realfmts = NULL;
-static short lang_succ = ON; /* setlocale success */
-
-
-/* Set the values here to guarantee stdio use of the
- decimal point
- */
-static struct lconv lconv_arr = {
- ".", "", "", "", "",
- "", "", "", "", "",
- CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
- CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX
-};
-
-/* lconv is externally defined by ANSI C */
-struct lconv *lconv = &lconv_arr;
-
-static char *lconv_numeric_str = NULL;
-static char *lconv_monetary_str = NULL;
-
-int openlocale(char *, int, char *, char *);
-int getlocale_ctype(char *, char *, char *);
-char *getlocale_numeric(char *, struct lconv *, char *);
-void init_statics(void);
-static char *getlocale_monetary(char *, struct lconv *, char *);
-static char *getstr(char *, char **);
-static char *getgrouping(char *, char **);
-static char *getnum(char *, char *);
-static char *getbool(char *, char *);
-static void set_default(void);
-
-char *
-setlocale(int category, char *locale)
-{
- static char buf[MAXLOCALE*(MAXLOCALENAME + 1) + 1];
- /* buffer for current LC_ALL value */
- int nonuniform;
- short ret;
- char my_ctype[CTYPE_SIZE]; /* local copy */
- struct lconv my_lconv; /* local copy */
- char *my_lconv_numeric_str;
- char *my_lconv_monetary_str;
- int i;
- char *p;
-
-
- /* initialize my_lconv to lconv */
- memcpy(&my_lconv, lconv, sizeof(my_lconv));
-
- /*
- * Following code is to avoid static initialisation of
- * strings which would otherwise blow up "xstr".
- */
- if (_locales[0][0] == '\0')
- init_statics();
-
- if (locale == NULL) {
- if (category == LC_ALL) {
- /*
- * Assume all locales are set to the same value. Then
- * scan through the locales to see if any are
- * different. If they are the same, return the common
- * value; otherwise, construct a "composite" value.
- */
- nonuniform = 0; /* assume all locales set the same */
- for (i = 0; i < MAXLOCALE - 2; i++) {
- if (strcmp(_locales[i], _locales[i + 1]) != 0) {
- nonuniform = 1;
- break;
- }
- }
- if (nonuniform) {
- /*
- * They're not all the same. Construct a list
- * of all the locale values, in order,
- * separated by slashes. Return that value.
- */
- (void) strcpy(buf, _locales[0]);
- for (i = 1; i < MAXLOCALE - 1; i++) {
- (void) strcat(buf, "/");
- (void) strcat(buf, _locales[i]);
- }
- return (buf);
- } else {
- /*
- * They're all the same; any one you return is
- * OK.
- */
- return (_locales[0]);
- }
- } else
- return (_locales[category - 1]);
- }
-
- switch (category) {
-
- case LC_ALL:
- if (strchr(locale, '/') != NULL) {
- /*
- * Composite value; extract each category.
- */
- if (strlen(locale) > sizeof buf - 1)
- return (NULL); /* too long */
- (void) strcpy(buf, locale);
- p = buf;
-
- /*
- * LC_CTYPE and LC_NUMERIC are set here.
- * Others locales won't be set here,
- * they will be just marked.
- */
- for (i = 0; i < MAXLOCALE - 1; i++) {
- p = strtok(p, "/");
- if (p == NULL)
- return (NULL); /* missing item */
- switch (i) {
-
- case LC_CTYPE - 1:
- if (setlocale(LC_CTYPE,p) == NULL)
- return (NULL);
- break;
- case LC_NUMERIC - 1:
- if (setlocale(LC_NUMERIC,p) == NULL)
- return (NULL);
- break;
- case LC_TIME - 1:
- if (setlocale(LC_TIME,p) == NULL)
- return (NULL);
- break;
- case LC_MONETARY - 1:
- if (setlocale(LC_MONETARY,p) == NULL)
- return (NULL);
- break;
- case LANGINFO - 1:
- if (setlocale(LANGINFO,p) == NULL)
- return (NULL);
- break;
- case LC_COLLATE - 1:
- if (setlocale(LC_COLLATE,p) == NULL)
- return (NULL);
- break;
- case LC_MESSAGES - 1:
- if (setlocale(LC_MESSAGES,p) == NULL)
- return (NULL);
- break;
- }
- p = NULL;
- }
- if (strtok((char *)NULL, "/") != NULL)
- return (NULL); /* extra stuff at end */
- }
-
- /* If category = LC_ALL, Drop through to test each individual
- * category, one at a time. Note default rules where env vars
- * are not set
- */
-
- case LC_CTYPE:
- if ((ret = getlocale_ctype(locale , my_ctype,
- _locales[LC_CTYPE - 1])) < 0)
- return (NULL);
- if (ret) {
- (void) memcpy(_ctype_, my_ctype, CTYPE_SIZE/2);
- (void) memcpy(_ctype_ul, my_ctype+(CTYPE_SIZE/2), CTYPE_SIZE/2);
- }
- if (category != LC_ALL)
- break;
-
- case LC_NUMERIC:
- if ((my_lconv_numeric_str =
- getlocale_numeric(locale, &my_lconv,
- _locales[LC_NUMERIC - 1])) == NULL)
- return (NULL);
- if (*my_lconv_numeric_str) {
- if (lconv_numeric_str != NULL)
- free((malloc_t)lconv_numeric_str);
- lconv_numeric_str = my_lconv_numeric_str;
- memcpy(lconv, my_lconv, sizeof(my_lconv));
- }
- if (category != LC_ALL)
- break;
-
- case LC_TIME:
- if ((ret = openlocale("LC_TIME", LC_TIME, locale,
- _locales[LC_TIME -1])) < 0)
- return (NULL);
- if (ret)
- (void) close(ret);
- if (category != LC_ALL)
- break;
-
- case LC_MONETARY:
- if ((my_lconv_monetary_str =
- getlocale_monetary(locale, &my_lconv,
- _locales[LC_MONETARY - 1])) == NULL)
- return (NULL);
- if (*my_lconv_monetary_str) {
- if (lconv_monetary_str != NULL)
- free((malloc_t)lconv_monetary_str);
- lconv_monetary_str = my_lconv_monetary_str;
- memcpy(lconv, &my_lconv, sizeof(my_lconv));
- }
- if (category != LC_ALL)
- break;
-
- case LANGINFO:
- if ((ret = openlocale("LANGINFO", LANGINFO, locale,
- _locales[LANGINFO - 1])) < 0) {
- lang_succ = OFF;
- return (NULL);
- }
- if (ret) {
- lang_succ = OFF;
- (void) close(ret);
- }
- if (category != LC_ALL)
- break;
-
- case LC_COLLATE:
- if ((ret = openlocale("LC_COLLATE", LC_COLLATE, locale,
- _locales[LC_COLLATE - 1])) < 0)
- return (NULL);
- if (ret) {
- (void) close(ret);
- }
- if (category != LC_ALL)
- break;
-
- case LC_MESSAGES:
- if ((ret = openlocale("LC_MESSAGES", LC_MESSAGES, locale,
- _locales[LC_MESSAGES - 1])) < 0)
- return (NULL);
- if (ret) {
- (void) close(ret);
- }
- }
- return (setlocale(category, (char *)NULL));
-}
-
-int
-getlocale_ctype(char *locale, char *ctypep, char *newlocale)
-{
- int fd;
-
- if ((fd = openlocale("LC_CTYPE", LC_CTYPE, locale, newlocale)) > 0) {
- if (read(fd, (char *)ctypep, CTYPE_SIZE) != CTYPE_SIZE) {
- (void) close(fd);
- fd = -1;
- }
- (void) close(fd);
- }
- return (fd);
-}
-
-/* open and load the numeric information */
-
-char *
-getlocale_numeric(char *locale, struct lconv *lconvp, char *newlocale)
-{
- int fd;
- struct stat buf;
- char *str;
- char *p;
-
- if ((fd = openlocale("LC_NUMERIC", LC_NUMERIC, locale, newlocale)) < 0)
- return (NULL);
- if (fd == 0)
- return "";
- if ((fstat(fd, &buf)) != 0)
- return (NULL);
- if ((str = (char*)malloc((unsigned)buf.st_size + 2)) == NULL)
- return (NULL);
-
- if ((read(fd, str, (int)buf.st_size)) != buf.st_size) {
- free((malloc_t)str);
- return (NULL);
- }
-
- /* Set last character of str to '\0' */
- p = &str[buf.st_size];
- *p++ = '\n';
- *p = '\0';
-
- /* p will "walk thru" str */
- p = str;
-
- p = getstr(p, &lconvp->decimal_point);
- if (p == NULL)
- goto fail;
- p = getstr(p, &lconvp->thousands_sep);
- if (p == NULL)
- goto fail;
- p = getgrouping(p, &lconvp->grouping);
- if (p == NULL)
- goto fail;
- (void) close(fd);
-
- return (str);
-
-fail:
- (void) close(fd);
- free((malloc_t)str);
- return (NULL);
-}
-
-
-static char *
-getlocale_monetary(char *locale, struct lconv *lconvp, char *newlocale)
-{
- int fd;
- struct stat buf;
- char *str;
- char *p;
-
- if ((fd = openlocale("LC_MONETARY", LC_MONETARY, locale, newlocale)) < 0)
- return (NULL);
- if (fd == 0)
- return ("");
- if ((fstat(fd, &buf)) != 0)
- return (NULL);
- if ((str = (char*)malloc((unsigned)buf.st_size + 2)) == NULL)
- return (NULL);
-
- if ((read(fd, str, (int)buf.st_size)) != buf.st_size) {
- free((malloc_t)str);
- return (NULL);
- }
-
- /* Set last character of str to '\0' */
- p = &str[buf.st_size];
- *p++ = '\n';
- *p = '\0';
-
- /* p will "walk thru" str */
- p = str;
-
- p = getstr(p, &lconvp->int_curr_symbol);
- if (p == NULL)
- goto fail;
- p = getstr(p, &lconvp->currency_symbol);
- if (p == NULL)
- goto fail;
- p = getstr(p, &lconvp->mon_decimal_point);
- if (p == NULL)
- goto fail;
- p = getstr(p, &lconvp->mon_thousands_sep);
- if (p == NULL)
- goto fail;
- p = getgrouping(p, &lconvp->mon_grouping);
- if (p == NULL)
- goto fail;
- p = getstr(p, &lconvp->positive_sign);
- if (p == NULL)
- goto fail;
- p = getstr(p, &lconvp->negative_sign);
- if (p == NULL)
- goto fail;
- p = getnum(p, &lconvp->frac_digits);
- if (p == NULL)
- goto fail;
- p = getbool(p, &lconvp->p_cs_precedes);
- if (p == NULL)
- goto fail;
- p = getbool(p, &lconvp->p_sep_by_space);
- if (p == NULL)
- goto fail;
- p = getbool(p, &lconvp->n_cs_precedes);
- if (p == NULL)
- goto fail;
- p = getbool(p, &lconvp->n_sep_by_space);
- if (p == NULL)
- goto fail;
- p = getnum(p, &lconvp->p_sign_posn);
- if (p == NULL)
- goto fail;
- p = getnum(p, &lconvp->n_sign_posn);
- if (p == NULL)
- goto fail;
- (void) close(fd);
-
- return (str);
-
-fail:
- (void) close(fd);
- free((malloc_t)str);
- return (NULL);
-}
-
-static char *
-getstr(char *p, char **strp)
-{
- *strp = p;
- p = strchr(p, '\n');
- if (p == NULL)
- return (NULL); /* no end-of-line */
- *p++ = '\0';
- return (p);
-}
-
-static char *
-getgrouping(char *p, char **groupingp)
-{
- int c;
-
- if (*p == '\0')
- return (NULL); /* no grouping */
- *groupingp = p;
- while ((c = *p) != '\n') {
- if (c == '\0')
- return (NULL); /* no end-of-line */
- if (c >= '0' && c <= '9')
- *p++ = c - '0';
- else
- *p++ = '\177';
- }
- *p++ = '\0';
- return (p);
-}
-
-static char *
-getnum(char *p, char *nump)
-{
- int num;
- int c;
-
- if (*p == '\0')
- return (NULL); /* no number */
- if (*p == '\n')
- *nump = '\177'; /* blank line - no value */
- else {
- num = 0;
- while ((c = *p) != '\n') {
- if (c < '0' || c > '9')
- return (NULL); /* bad number */
- num = num*10 + c - '0';
- p++;
- }
- *nump = num;
- }
- *p++ = '\0';
- return (p);
-}
-
-static char *
-getbool(char *p, char *boolp)
-{
-
- if (*p == '\0')
- return (NULL); /* no number */
- if (*p == '\n')
- *boolp = '\177'; /* blank line - no value */
- else {
- switch (*p++) {
-
- case 'y':
- case 'Y':
- case 't':
- case 'T':
- *boolp = 1; /* true */
- break;
-
- case 'n':
- case 'N':
- case 'f':
- case 'F':
- *boolp = 0; /* false */
- break;
-
- default:
- return (NULL); /* bad boolean */
- }
- if (*p != '\n')
- return (NULL); /* noise at end of line */
- }
- *p++ = '\0';
- return (p);
-}
-
-/*
- * Open a locale file. First, check the value of "locale"; if it's a null
- * string, first check the environment variable with the same name as the
- * category, and then check the environment variable "LANG". If neither of
- * them are set to non-null strings, use the LC_default env.var and if this
- * has no meaning then assume we are running in the C locale. It is expected
- * That LC_default is set across the whole system. If the resulting locale is
- * longer than MAXLOCALENAME characters, reject it. Then, try looking in the
- * per-machine locale directory for the file in question; if it's not found
- * there, try looking in the shared locale directory.
- * If there is no work to do, that is, the last setting of locales is equal
- * to the current request, then we don't do anything, and exit with value 0.
- * Copy the name of the locale used into "newlocale".
- * Exit with positive value if we opened a file
- * Exit with -1 if an error occured (invalid locale).
- * Exit with 0 if there is no need to look at the disk file.
- * (Assumption - there is always at least one fd open before setlocale
- * is called)
- */
-int
-openlocale(char *category, int cat_id, char *locale, char *newlocale)
-{
- char pathname[MAXPATHLEN], *defp;
- int fd, fd2;
- struct _code_header code_header;
- char *my_info;
-
- if (*locale == '\0') {
- locale = getenv(category);
- if (locale == NULL || *locale == '\0') {
- locale = getenv("LANG");
- if (locale == NULL || *locale == '\0') {
- if (*Default == '\0') {
- defp = getenv("LC_default");
- if (defp == NULL || *defp == '\0')
- strcpy(Default,"C");
- else
- strcpy(Default, defp);
- }
- locale = Default;
- }
- }
- }
- if (strcmp(locale,_locales[cat_id-1]) == 0) {
- (void) strcpy(newlocale, locale);
- return (0);
- }
- if (strlen(locale) > MAXLOCALENAME)
- return (-1);
-
- (void) strcpy(pathname, PRIVATE_LOCALE_DIR);
- (void) strcat(pathname, category);
- (void) strcat(pathname, "/");
- (void) strcat(pathname, locale);
- if ((fd = open(pathname, O_RDONLY)) < 0 && errno == ENOENT) {
- (void) strcpy(pathname, LOCALE_DIR);
- (void) strcat(pathname, category);
- (void) strcat(pathname, "/");
- (void) strcat(pathname, locale);
- fd = open(pathname, O_RDONLY);
- }
- if (fd >= 0)
- (void) strcpy(newlocale, locale);
- /*
- * bug id 1072740; if by some chance the actual fd we're going to
- * return is 0, change it to be some non-zero descriptor, because
- * returning 0 means something different. If '0' is the only
- * descriptor left, return an error.
- */
- if (fd == 0) {
- int dupfd;
-
- if ((dupfd = dup(fd)) < 1) {
- (void) close(fd);
- fd = -1;
- } else {
- (void) close(fd);
- fd = dupfd;
- }
- }
-
- if (cat_id == LC_CTYPE) {
-
- /* Go and get the trailer file */
-
- (void) strcat(pathname, TRAILER);
- fd2 = open(pathname, O_RDONLY);
- if ( fd2 == 0 ) {
- fd2 = dup(fd2);
- close(0);
- }
-
- if (fd2 == -1) {
- set_default();
- return (fd);
- }
-
- /*
- * ctype trailer file exists - read it
- */
-
- if (read (fd2, (char *)&code_header, sizeof (code_header)) !=
- sizeof (code_header)) {
- /*
- * File format not correct
- */
- set_default();
- close(fd2);
- return (-1);
- }
- /*
- * set up trailer file
- */
- strcpy(_code_set_info.code_name, code_header.code_name);
- _code_set_info.code_id = code_header.code_id;
- if (_code_set_info.code_info != NULL)
- free (_code_set_info.code_info);
- if (code_header.code_info_size > 0) {
- my_info = malloc(code_header.code_info_size);
- if (read (fd2, (char *)my_info,
- code_header.code_info_size) !=
- code_header.code_info_size) {
- close(fd2);
- set_default();
- return (-1);
- }
- _code_set_info.code_info = my_info;
- }
- else {
- /*
- * We have a corrupted file too
- */
- _code_set_info.code_info = NULL;
- close(fd2);
- set_default();
- return (-1);
- }
- close (fd2);
- }
- return (fd);
-}
-
-struct lconv *
-localeconv(void)
-{
- return (lconv);
-}
-
-struct dtconv *
-localdtconv(void)
-{
- char *p;
- short i;
-
- char *rawmonths = "Jan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug\nSep\nOct\nNov\nDec\nJanuary\nFebruary\nMarch\nApril\nMay\nJune\nJuly\nAugust\nSeptember\nOctober\nNovember\nDecember";
-
- char *rawdays = "Sun\nMon\nTue\nWed\nThu\nFri\nSat\nSunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday";
-
-char *rawfmts = "%H:%M:%S\n%m/%d/%y\n%a %b %e %T %Z %Y\nAM\nPM\n%A, %B %e, %Y\n";
-
- /* fix for bugid 1067574 ... robinson */
- (void)getlocale_time();
-
- if (_dtconv == NULL) {
-
- /* We malloc both the space for the dtconv struct and the
- * copy of the strings above because this program is later run
- * through xstr and the resultant strings are put in read-only
- * text segment. Therefore we cannot write to the original
- * raw strings but we can to their copies.
- */
-
- _dtconv = (struct dtconv*)malloc(sizeof (struct dtconv));
- if (_dtconv == NULL)
- return (NULL);
- if ((realmonths = malloc(strlen(rawmonths)+1)) == NULL)
- return (NULL);
- strcpy(realmonths, rawmonths);
- if ((realdays = malloc(strlen(rawdays)+1)) == NULL)
- return (NULL);
- strcpy(realdays, rawdays);
- if ((realfmts = malloc(strlen(rawfmts)+1)) == NULL)
- return (NULL);
- strcpy(realfmts, rawfmts);
-
- /* p will "walk thru" str */
-
- p = realmonths;
-
- for (i = 0; i < 12; i++)
- p = getstr(p, &(_dtconv->abbrev_month_names[i]));
-
- for (i = 0; i < 12; i++)
- p = getstr(p, &(_dtconv->month_names[i]));
- p = realdays;
- for (i= 0; i < 7; i++)
- p = getstr(p, &(_dtconv->abbrev_weekday_names[i]));
- for (i = 0; i < 7; i++)
- p = getstr(p, &(_dtconv->weekday_names[i]));
- p = realfmts;
- p = getstr(p, &_dtconv->time_format);
- p = getstr(p, &_dtconv->sdate_format);
- p = getstr(p, &_dtconv->dtime_format);
- p = getstr(p, &_dtconv->am_string);
- p = getstr(p, &_dtconv->pm_string);
- p = getstr(p, &_dtconv->ldate_format);
- }
-
- return (_dtconv);
-}
-
-
-static void
-set_default(void)
-{
-
- strcpy(_code_set_info.code_name, Default);
- _code_set_info.code_id = CODESET_NONE;
- if (_code_set_info.code_info != NULL)
- free (_code_set_info.code_info);
- _code_set_info.code_info = NULL;
- _code_set_info.open_flag = 0;
-}
-
-void
-init_statics(void)
-{
-
- short i;
-
- for (i=0; i<MAXLOCALE-1;i++)
- strcpy(_locales[i],"C");
- strcpy(_code_set_info.code_name, "default");
- strcpy(_my_time,"C");
- _langinfo.yesstr = "yes";
- _langinfo.nostr = "no";
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/setrgid.c b/usr/src/lib/libbc/libc/gen/common/setrgid.c
deleted file mode 100644
index 2b1a3298f7..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/setrgid.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-
-int
-setrgid(int rgid)
-{
-
- return (setregid(rgid, -1));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/setruid.c b/usr/src/lib/libbc/libc/gen/common/setruid.c
deleted file mode 100644
index 2aaf47afb8..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/setruid.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-int
-setruid(int ruid)
-{
-
- return (setreuid(ruid, -1));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/sigfpe.c b/usr/src/lib/libbc/libc/gen/common/sigfpe.c
deleted file mode 100644
index 24b24eb95f..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/sigfpe.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1987 by Sun Microsystems, Inc.
- */
-
-/* Swap handler for SIGFPE codes. */
-
-#include <errno.h>
-#include <signal.h>
-#include <floatingpoint.h>
-
-#ifndef FPE_INTDIV_TRAP
-#define FPE_INTDIV_TRAP 0x14 /* integer divide by zero */
-#endif
-#ifndef FPE_CHKINST_TRAP
-#define FPE_CHKINST_TRAP 0x18 /* CHK [CHK2] instruction */
-#endif
-#ifndef FPE_TRAPV_TRAP
-#define FPE_TRAPV_TRAP 0x1c /* TRAPV [cpTRAPcc TRAPcc] instr */
-#endif
-#ifndef FPE_FLTBSUN_TRAP
-#define FPE_FLTBSUN_TRAP 0xc0 /* [branch or set on unordered cond] */
-#endif
-#ifndef FPE_FLTINEX_TRAP
-#define FPE_FLTINEX_TRAP 0xc4 /* [floating inexact result] */
-#endif
-#ifndef FPE_FLTDIV_TRAP
-#define FPE_FLTDIV_TRAP 0xc8 /* [floating divide by zero] */
-#endif
-#ifndef FPE_FLTUND_TRAP
-#define FPE_FLTUND_TRAP 0xcc /* [floating underflow] */
-#endif
-#ifndef FPE_FLTOPERR_TRAP
-#define FPE_FLTOPERR_TRAP 0xd0 /* [floating operand error] */
-#endif
-#ifndef FPE_FLTOVF_TRAP
-#define FPE_FLTOVF_TRAP 0xd4 /* [floating overflow] */
-#endif
-#ifndef FPE_FLTNAN_TRAP
-#define FPE_FLTNAN_TRAP 0xd8 /* [floating Not-A-Number] */
-#endif
-#ifndef FPE_FPA_ENABLE
-#define FPE_FPA_ENABLE 0x400 /* [FPA not enabled] */
-#endif
-#ifndef FPE_FPA_ERROR
-#define FPE_FPA_ERROR 0x404 /* [FPA arithmetic exception] */
-#endif
-
-#define N_SIGFPE_CODE 13
-
-/* Array of SIGFPE codes. */
-
-static sigfpe_code_type sigfpe_codes[N_SIGFPE_CODE] = {
- FPE_INTDIV_TRAP,
- FPE_CHKINST_TRAP,
- FPE_TRAPV_TRAP,
- FPE_FLTBSUN_TRAP,
- FPE_FLTINEX_TRAP,
- FPE_FLTDIV_TRAP,
- FPE_FLTUND_TRAP,
- FPE_FLTOPERR_TRAP,
- FPE_FLTOVF_TRAP,
- FPE_FLTNAN_TRAP,
- FPE_FPA_ENABLE,
- FPE_FPA_ERROR,
- 0};
-
-/* Array of handlers. */
-
-static sigfpe_handler_type sigfpe_handlers[N_SIGFPE_CODE];
-
-static int _sigfpe_master_enabled;
-/* Originally zero, set to 1 by _enable_sigfpe_master. */
-
-void
-_sigfpe_master(sig, code, scp, addr)
- int sig;
- sigfpe_code_type code;
- struct sigcontext *scp;
- char *addr;
-{
- int i;
- enum fp_exception_type exception;
-
- for (i = 0; (i < N_SIGFPE_CODE) && (code != sigfpe_codes[i]); i++);
- /* Find index of handler. */
- if (i >= N_SIGFPE_CODE)
- i = N_SIGFPE_CODE - 1;
- switch ((unsigned int)sigfpe_handlers[i]) {
- case (unsigned int)SIGFPE_DEFAULT:
- switch (code) {
- case FPE_FLTBSUN_TRAP:
- case FPE_FLTOPERR_TRAP:
- case FPE_FLTNAN_TRAP:
- exception = fp_invalid;
- goto ieee;
- case FPE_FLTINEX_TRAP:
- exception = fp_inexact;
- goto ieee;
- case FPE_FLTDIV_TRAP:
- exception = fp_division;
- goto ieee;
- case FPE_FLTUND_TRAP:
- exception = fp_underflow;
- goto ieee;
- case FPE_FLTOVF_TRAP:
- exception = fp_overflow;
- goto ieee;
- default: /* The common default treatment is to abort. */
- break;
- }
- case (unsigned int)SIGFPE_ABORT:
- abort();
- case (unsigned int)SIGFPE_IGNORE:
- return;
- default: /* User-defined not SIGFPE_DEFAULT or
- * SIGFPE_ABORT. */
- (sigfpe_handlers[i]) (sig, code, scp, addr);
- return;
- }
-ieee:
- switch ((unsigned int)ieee_handlers[(int) exception]) {
- case (unsigned int)SIGFPE_DEFAULT:
- /* Error condition but ignore it. */
- case (unsigned int)SIGFPE_IGNORE:
- /* Error condition but ignore it. */
- return;
- case (unsigned int)SIGFPE_ABORT:
- abort();
- default:
- (ieee_handlers[(int) exception]) (sig, code, scp, addr);
- return;
- }
-}
-
-int
-_enable_sigfpe_master()
-{
- /* Enable the sigfpe master handler always. */
- struct sigvec newsigvec, oldsigvec;
-
- newsigvec.sv_handler = _sigfpe_master;
- newsigvec.sv_mask = 0;
- newsigvec.sv_onstack = 0;
- _sigfpe_master_enabled = 1;
- return sigvec(SIGFPE, &newsigvec, &oldsigvec);
-}
-
-int
-_test_sigfpe_master()
-{
- /*
- * Enable the sigfpe master handler if it's never been enabled
- * before.
- */
-
- if (_sigfpe_master_enabled == 0)
- return _enable_sigfpe_master();
- else
- return _sigfpe_master_enabled;
-}
-
-sigfpe_handler_type
-sigfpe(code, hdl)
- sigfpe_code_type code;
- sigfpe_handler_type hdl;
-{
- sigfpe_handler_type oldhdl;
- int i;
-
- _test_sigfpe_master();
- for (i = 0; (i < N_SIGFPE_CODE) && (code != sigfpe_codes[i]); i++);
- /* Find index of handler. */
- if (i >= N_SIGFPE_CODE) {
- errno = EINVAL;
- return (sigfpe_handler_type) BADSIG;/* Not 0 or SIGFPE code */
- }
- oldhdl = sigfpe_handlers[i];
- sigfpe_handlers[i] = hdl;
- return oldhdl;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/siglist.c b/usr/src/lib/libbc/libc/gen/common/siglist.c
deleted file mode 100644
index 3467ab140e..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/siglist.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 5.1 85/30/05 */
-
-/*
- * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-#include <signal.h>
-
-char *sys_siglist[NSIG] = {
- "Signal 0",
- "Hangup", /* SIGHUP */
- "Interrupt", /* SIGINT */
- "Quit", /* SIGQUIT */
- "Illegal instruction", /* SIGILL */
- "Trace/BPT trap", /* SIGTRAP */
- "Abort", /* SIGABRT */
- "Emulator trap", /* SIGEMT */
- "Arithmetic exception", /* SIGFPE */
- "Killed", /* SIGKILL */
- "Bus error", /* SIGBUS */
- "Segmentation fault", /* SIGSEGV */
- "Bad system call", /* SIGSYS */
- "Broken pipe", /* SIGPIPE */
- "Alarm clock", /* SIGALRM */
- "Terminated", /* SIGTERM */
- "Urgent I/O condition", /* SIGURG */
- "Stopped (signal)", /* SIGSTOP */
- "Stopped", /* SIGTSTP */
- "Continued", /* SIGCONT */
- "Child exited", /* SIGCHLD */
- "Stopped (tty input)", /* SIGTTIN */
- "Stopped (tty output)", /* SIGTTOU */
- "I/O possible", /* SIGIO */
- "Cputime limit exceeded", /* SIGXCPU */
- "Filesize limit exceeded", /* SIGXFSZ */
- "Virtual timer expired", /* SIGVTALRM */
- "Profiling timer expired", /* SIGPROF */
- "Window changed", /* SIGWINCH */
- "Resource lost", /* SIGLOST */
- "User defined signal 1", /* SIGUSR1 */
- "User defined signal 2" /* SIGUSR2 */
-};
diff --git a/usr/src/lib/libbc/libc/gen/common/sparc/alloca.s b/usr/src/lib/libbc/libc/gen/common/sparc/alloca.s
deleted file mode 100644
index bec6bc5ba0..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/sparc/alloca.s
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * .seg "data"
- * .asciz ident "%Z%%M% %I% %E% SMI"
- */
-! .seg "text"
-
- .file "alloca.s"
-
-#include <sun4/asm_linkage.h>
-
- !
- ! o0: # bytes of space to allocate, already rounded to 0 mod 8
- ! o1: %sp-relative offset of tmp area
- ! o2: %sp-relative offset of end of tmp area
- !
- ! we want to bump %sp by the requested size
- ! then copy the tmp area to its new home
- ! this is necessasy as we could theoretically
- ! be in the middle of a compilicated expression.
- !
- ENTRY(__builtin_alloca)
- mov %sp, %o3 ! save current sp
- sub %sp, %o0, %sp ! bump to new value
- ! copy loop: should do nothing gracefully
- b 2f
- subcc %o2, %o1, %o5 ! number of bytes to move
-1:
- ld [%o3 + %o1], %o4 ! load from old temp area
- st %o4, [%sp + %o1] ! store to new temp area
- add %o1, 4, %o1
-2: bg 1b
- subcc %o5, 4, %o5
- ! now return new %sp + end-of-temp
- retl
- add %sp, %o2, %o0
- SET_SIZE(__builtin_alloca)
diff --git a/usr/src/lib/libbc/libc/gen/common/sparc/base_conv.c b/usr/src/lib/libbc/libc/gen/common/sparc/base_conv.c
deleted file mode 100644
index 405b0ab99a..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/sparc/base_conv.c
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1986 by Sun Microsystems, Inc.
- */
-
-/*
- * Machine-independent versions of base conversion primitives.
- * Routines to multiply buffers by 2**16 or 10**4. Base 10**4 buffers have
- * b[i] < 10000, carry in and out < 65536. Base 2**16 buffers have b[i] <
- * 65536, carry in and out < 10000. If n is positive, b[0]..b[n-1] are
- * processed; if n is negative, b[0]..b[n+1] are processed.
- */
-
-void
-_fourdigits(t, d)
- unsigned t;
- char d[4];
-
-/* Converts t < 10000 into four ascii digits at *pc. */
-
-{
- register short i;
-
- i = 3;
- do {
- d[i] = '0' + t % 10;
- t = t / 10;
- }
- while (--i != -1);
-}
-
-unsigned
-_quorem10000(u, pr)
- unsigned u;
- unsigned *pr;
-{
- *pr = u % 10000;
- return (u / 10000);
-}
-
-void
-_mul_10000(b, n, c)
- unsigned *b;
- int n;
- unsigned *c;
-{
- /* Multiply base-2**16 buffer by 10000. */
-
- register unsigned carry, t;
- register short int i;
- register unsigned *pb;
-
- carry = *c;
- pb = b;
- if ((i = n) > 0) {
- i--;
- do {
- *pb = (t = (*pb * 10000) + carry) & 0xffff;
- pb++;
- carry = t >> 16;
- }
- while (--i != -1);
- } else {
- i = -i - 1;
- do {
- *pb = (t = (*pb * 10000) + carry) & 0xffff;
- pb--;
- carry = t >> 16;
- }
- while (--i != -1);
- }
- *c = carry;
-}
-
-void
-_mul_65536(b, n, c)
- unsigned *b;
- int n;
- unsigned *c;
-{
- /* Multiply base-10**4 buffer by 65536. */
-
- register unsigned carry, t;
- register short int i;
- register unsigned *pb;
-
- carry = *c;
- pb = b;
- if ((i = n) > 0) {
- i--;
- do {
- *pb = (t = (*pb << 16) | carry) % 10000;
- pb++;
- carry = t / 10000;
- }
- while (--i != -1);
- } else {
- i = -i - 1;
- do {
- *pb = (t = (*pb << 16) | carry) % 10000;
- pb--;
- carry = t / 10000;
- }
- while (--i != -1);
- }
- *c = carry;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/sparc/ffs.s b/usr/src/lib/libbc/libc/gen/common/sparc/ffs.s
deleted file mode 100644
index 5534fcc7ca..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/sparc/ffs.s
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-! .seg "data"
-! .asciz ident "%Z%%M% %I% %E% SMI"
- .seg ".text"
-
- .file "ffs.s"
-
-#include <sun4/asm_linkage.h>
-
- ENTRY(ffs)
- tst %o0 ! if zero, done
- bz 2f
- clr %o1 ! delay slot, return zero if no bit set
-1:
- inc %o1 ! bit that will get checked
- btst 1, %o0
- be 1b ! if bit is zero, keep checking
- srl %o0, 1, %o0 ! shift input right until we hit a 1 bit
-2:
- retl
- mov %o1, %o0 ! return value is in o1
- SET_SIZE(ffs)
diff --git a/usr/src/lib/libbc/libc/gen/common/sparc/insque.s b/usr/src/lib/libbc/libc/gen/common/sparc/insque.s
deleted file mode 100644
index eef886a1c7..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/sparc/insque.s
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1992 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-! .seg "data"
-! .asciz ident "%Z%%M% %I% %E% SMI"
- .seg ".text"
-
- .file "insque.s"
-
-#include <sun4/asm_linkage.h>
-
-/*
- * insque(entryp, predp)
- *
- * Insert entryp after predp in a doubly linked list.
- */
- ENTRY(insque)
- ld [%o1], %g1 ! predp->forw
- st %o1, [%o0 + 4] ! entryp->back = predp
- st %g1, [%o0] ! entryp->forw = predp->forw
- st %o0, [%o1] ! predp->forw = entryp
- retl
- st %o0, [%g1 + 4] ! predp->forw->back = entryp
- SET_SIZE(insque)
diff --git a/usr/src/lib/libbc/libc/gen/common/sparc/isinf.c b/usr/src/lib/libbc/libc/gen/common/sparc/isinf.c
deleted file mode 100644
index 2bd47b88e5..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/sparc/isinf.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1986 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Recognize an infinity or a NaN when one is presented.
- * This is for keeping various IO routines out of trouble
- */
-
-
-int
-isinf( d0, d1 )
- unsigned d0,d1;
- /* a lie -- actually its a ``double'' */
-{
- if (d1 != 0 ) return 0; /* nope -- low-order must be all zeros */
- if (d0 != 0x7ff00000 && d0 != 0xfff00000) return 0; /* nope */
- return 1;
-}
-
-int
-isnan( d0,d1 )
- unsigned d0,d1;
- /* a lie -- actually its a ``double'' */
-{
-#define EXPONENT 0x7ff00000
-#define SIGN 0x80000000
- if ((d0 & EXPONENT) != EXPONENT ) return 0; /* exponent wrong */
- if ((d0 & ~(EXPONENT|SIGN)) == 0 && d1 == 0 ) return 0; /* must have bits */
- return 1;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/sparc/remque.s b/usr/src/lib/libbc/libc/gen/common/sparc/remque.s
deleted file mode 100644
index 358b2eb08c..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/sparc/remque.s
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-! .seg "data"
-! .asciz ident "%Z%%M% %I% %E% SMI"
-! .seg "text"
-
- .file "remque.s"
-
-#include <sun4/asm_linkage.h>
-
-/*
- * remque(entryp)
- *
- * Remove entryp from a doubly linked list
- */
- ENTRY(remque)
- ld [%o0], %g1 ! entryp->forw
- ld [%o0 + 4], %g2 ! entryp->back
- st %g1, [%g2] ! entryp->back = entryp->forw
- retl
- st %g2, [%g1 + 4] ! entryp->forw = entryp->back
- SET_SIZE(remque)
diff --git a/usr/src/lib/libbc/libc/gen/common/ssignal.c b/usr/src/lib/libbc/libc/gen/common/ssignal.c
deleted file mode 100644
index 8becd84fd5..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ssignal.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-/*
- * ssignal, gsignal: software signals
- */
-#include <signal.h>
-
-/* Highest allowable user signal number */
-#define MAXSIG NSIG
-
-/* Lowest allowable signal number (lowest user number is always 1) */
-#define MINSIG (-4)
-
-/* Table of signal values */
-typedef int (*sigfunc)();
-sigfunc *ssigp;
-
-
-sigfunc *
-_ssig()
-{
- if (ssigp == 0)
- ssigp = (sigfunc *)calloc(MAXSIG-MINSIG+1, sizeof (sigfunc));
- return (ssigp);
-}
-
-int
-(*ssignal(sig, fn))()
-register int sig, (*fn)();
-{
- register int (*savefn)();
- register sigfunc *sp = _ssig();
-
- if (sp == 0)
- return ((int (*)())SIG_DFL);
- if (sig >= MINSIG && sig <= MAXSIG) {
- savefn = sp[sig-MINSIG];
- sp[sig-MINSIG] = fn;
- } else
- savefn = (int (*)())SIG_DFL;
-
- return (savefn);
-}
-
-int
-gsignal(sig)
-register int sig;
-{
- register int (*sigfn)();
- register sigfunc *sp = _ssig();
-
- if (sp == 0)
- return (0);
- if (sig < MINSIG || sig > MAXSIG ||
- (sigfn = sp[sig-MINSIG]) == (int (*)())SIG_DFL)
- return (0);
- else if (sigfn == (int (*)())SIG_IGN)
- return (1);
- else {
- sp[sig-MINSIG] = (int (*)())SIG_DFL;
- return ((*sigfn)(sig));
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strchr.c b/usr/src/lib/libbc/libc/gen/common/strchr.c
deleted file mode 100644
index e978579ae1..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strchr.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-/*
- * Return the ptr in sp at which the character c appears;
- * NULL if not found
- */
-
-#define NULL 0
-
-char *
-strchr(sp, c)
-register char *sp, c;
-{
- do {
- if(*sp == c)
- return(sp);
- } while(*sp++);
- return(NULL);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strftime.c b/usr/src/lib/libbc/libc/gen/common/strftime.c
deleted file mode 100644
index 5267bc447a..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strftime.c
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1996 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#if !defined(lint) && defined(SCCSIDS)
-static char *sccsid = "%Z%%M% %I% %E% SMI"; /* from S5R3.1 cftime.c 1.9 */
-#endif
-
-/*LINTLIBRARY*/
-
-#include <locale.h>
-#include <time.h>
-#include <string.h>
-#include <sys/param.h>
-#include <sys/stat.h>
-
-static char *getstr(/*char *p, char **strp*/);
-static char *itoa();
-extern int stat();
-extern char *getenv();
-extern char *malloc();
-extern int openlocale(/*char *category, int cat_id, char *locale, char *newlocale */);
-extern void init_statics();
-
-extern struct dtconv *_dtconv;
-extern char _locales[MAXLOCALE + 1][MAXLOCALENAME + 1];
-extern char _my_time[];
-
-char *dtconv_str = NULL;
-char *getlocale_time();
-
-int
-strftime(buf, maxsize, format, tm)
-char *buf, *format;
-struct tm *tm;
-{
- register char *cp, *p, c;
- int size;
- int i, temp;
- register struct dtconv *dtcp;
-
- (void) getlocale_time();
- dtcp = localdtconv(); /* get locale's strings */
-
- /* Build date string by parsing format string */
- cp = buf;
- size = 0;
- while ((c = *format++) != '\0') {
- if (c == '%') {
- switch (*format++) {
-
- case '%': /* Percent sign */
- if (++size >= maxsize)
- return (0);
- *cp++ = '%';
- break;
-
- case 'a': /* Abbreviated weekday name */
- for (p = dtcp->abbrev_weekday_names[tm->tm_wday];
- *p != '\0'; p++) {
- if (++size >= maxsize)
- return (0);
- *cp++ = *p;
- }
- break;
-
- case 'A': /* Weekday name */
- for (p = dtcp->weekday_names[tm->tm_wday];
- *p != '\0'; p++) {
- if (++size >= maxsize)
- return (0);
- *cp++ = *p;
- }
- break;
-
- case 'h':
- case 'b': /* Abbreviated month name */
- for (p = dtcp->abbrev_month_names[tm->tm_mon];
- *p != '\0'; p++) {
- if (++size >= maxsize)
- return (0);
- *cp++ = *p;
- }
- break;
-
- case 'B': /* Month name */
- for (p = dtcp->month_names[tm->tm_mon];
- *p != '\0'; p++) {
- if (++size >= maxsize)
- return (0);
- *cp++ = *p;
- }
- break;
-
- case 'c': /* date and time representation */
- i = strftime(cp, maxsize - size, "%x %X", tm);
- if (i == 0)
- return (0);
- cp += i;
- size += i;
- break;
-
- case 'C': /* long date and time representation */
- i = strftime(cp, maxsize - size,
- dtcp->ldate_format, tm);
- if (i == 0)
- return (0);
- cp += i;
- size += i;
- break;
-
- case 'd': /* Day of month, with leading zero */
- if ((size += 2) >= maxsize)
- return (0);
- cp = itoa(tm->tm_mday, cp, 2);
- break;
-
- case 'D': /* Shorthand for %m/%d/%y */
- i = strftime(cp, maxsize - size, "%m/%d/%y",
- tm);
- if (i == 0)
- return (0);
- cp += i;
- size += i;
- break;
-
- case 'e': /* Day of month without leading zero */
- if ((size += 2) >= maxsize)
- return (0);
- if (tm->tm_mday < 10) {
- *cp++ = ' ';
- cp = itoa(tm->tm_mday, cp, 1);
- } else
- cp = itoa(tm->tm_mday, cp, 2);
- break;
-
- case 'H': /* Hour (24 hour version) */
- if ((size += 2) >= maxsize)
- return (0);
- cp = itoa(tm->tm_hour, cp, 2);
- break;
-
- case 'I': /* Hour (12 hour version) */
- if ((size += 2) >= maxsize)
- return (0);
- cp = itoa(tm->tm_hour > 12 ?
- tm->tm_hour - 12 :
- (tm->tm_hour == 0 ? 12 : tm->tm_hour),
- cp, 2);
- break;
-
- case 'j': /* Julian date */
- if ((size += 3) >= maxsize)
- return (0);
- cp = itoa(tm->tm_yday + 1, cp, 3);
- break;
-
- case 'k': /* Hour (24 hour version) */
- if ((size += 2) >= maxsize)
- return (0);
- if (tm->tm_hour < 10) {
- *cp++ = ' ';
- cp = itoa(tm->tm_hour, cp, 1);
- } else
- cp = itoa(tm->tm_hour, cp, 2);
- break;
-
- case 'l': /* Hour (12 hour version) */
- if ((size += 2) >= maxsize)
- return (0);
- temp = tm->tm_hour > 12 ?
- tm->tm_hour - 12 :
- (tm->tm_hour == 0 ? 12 : tm->tm_hour);
- if (temp < 10) {
- *cp++ = ' ';
- cp = itoa(temp, cp, 1);
- } else
- cp = itoa(temp, cp, 2);
- break;
-
- case 'm': /* Month number */
- if ((size += 2) >= maxsize)
- return (0);
- cp = itoa(tm->tm_mon + 1, cp, 2);
- break;
-
- case 'M': /* Minute */
- if ((size += 2) >= maxsize)
- return (0);
- cp = itoa(tm->tm_min, cp, 2);
- break;
-
- case 'n': /* Newline */
- if (++size >= maxsize)
- return (0);
- *cp++ = '\n';
- break;
-
- case 'p': /* AM or PM */
- if (tm->tm_hour >= 12)
- p = dtcp->pm_string;
- else
- p = dtcp->am_string;
- for (; *p != '\0'; p++) {
- if (++size >= maxsize)
- return (0);
- *cp++ = *p;
- }
- break;
-
- case 'r': /* Shorthand for %I:%M:%S AM or PM */
- i = strftime(cp, maxsize - size, "%I:%M:%S %p",
- tm);
- if (i == 0)
- return (0);
- cp += i;
- size += i;
- break;
-
- case 'R': /* Time as %H:%M */
- i = strftime(cp, maxsize - size, "%H:%M", tm);
- if (i == 0)
- return (0);
- cp += i;
- size += i;
- break;
-
- case 'S': /* Seconds */
- if ((size += 2) >= maxsize)
- return (0);
- cp = itoa(tm->tm_sec, cp, 2);
- break;
-
- case 't': /* Tab */
- if (++size >= maxsize)
- return (0);
- *cp++ = '\t';
- break;
-
- case 'T': /* Shorthand for %H:%M:%S */
- i = strftime(cp, maxsize - size, "%H:%M:%S",
- tm);
- if (i == 0)
- return (0);
- cp += i;
- size += i;
- break;
-
- case 'U': /* Weekday number, taking Sunday as
- * the first day of the week */
- if ((size += 2) >= maxsize)
- return (0);
- temp = tm->tm_yday - tm->tm_wday;
- if (temp >= -3 ) {
- i = (temp + 1) / 7 + 1; /* +1 for - tm->tm_wday */
- if (temp % 7 >= 4)
- i++;
- } else
- i = 52;
- cp = itoa(i, cp, 2);
- break;
-
- case 'w': /* Weekday number */
- if (++size >= maxsize)
- return (0);
- cp = itoa(tm->tm_wday, cp, 1);
- break;
-
- case 'W': /* Week number of year, taking Monday as
- * first day of week */
- if ((size += 2) >= maxsize)
- return (0);
- if (tm->tm_wday == 0)
- temp = tm->tm_yday - 6;
- else
- temp = tm->tm_yday - tm->tm_wday + 1;
- if (temp >= -3) {
- i = (temp + 1) / 7 + 1; /* 1 for
- -tm->tm_wday */
- if (temp % 7 >= 4)
- i++;
- } else
- i = 52; /* less than 4 days in the first
- week causes it to belong to
- the tail of prev year */
- cp = itoa(i, cp, 2);
- break;
-
- case 'x': /* Localized date format */
- i = strftime(cp, maxsize - size,
- dtcp->sdate_format, tm);
- if (i == 0)
- return (0);
- cp += i;
- size += i;
- break;
-
- case 'X': /* Localized time format */
- i = strftime(cp, maxsize - size,
- dtcp->time_format, tm);
- if (i == 0)
- return (0);
- cp += i;
- size += i;
- break;
-
- case 'y': /* Year in the form yy */
- if ((size += 2) >= maxsize)
- return (0);
- cp = itoa((tm->tm_year% 100), cp, 2);
- break;
-
- case 'Y': /* Year in the form ccyy */
- if ((size += 4) >= maxsize)
- return (0);
- cp = itoa(1900 + tm->tm_year, cp, 4);
- break;
-
- case 'Z': /* Timezone */
- for(p = tm->tm_zone; *p != '\0'; p++) {
- if (++size >= maxsize)
- return (0);
- *cp++ = *p;
- }
- break;
-
- default:
- if ((size += 2) >= maxsize)
- return (0);
- *cp++ = c;
- *cp++ = *(format - 1);
- break;
- }
- } else {
- if (++size >= maxsize)
- return (0);
- *cp++ = c;
- }
- }
- *cp = '\0';
- return(size);
-}
-
-static char *
-itoa(i, ptr, dig)
-register int i;
-register char *ptr;
-register int dig;
-{
- switch(dig) {
- case 4:
- *ptr++ = i / 1000 + '0';
- i = i - i / 1000 * 1000;
- case 3:
- *ptr++ = i / 100 + '0';
- i = i - i / 100 * 100;
- case 2:
- *ptr++ = i / 10 + '0';
- case 1:
- *ptr++ = i % 10 + '0';
- }
-
- return(ptr);
-}
-
-char *
-getlocale_time()
-{
- register int fd;
- struct stat buf;
- char *str;
- register char *p;
- register int i;
- struct dtconv dtconvp;
- char temp[MAXLOCALENAME + 1];
-
- if (_locales[0][0] == '\0')
- init_statics();
-
- /* Here we use the string newlocales to set time constants
- * which should have been saved
- * from a previous call to setlocale. We deferred the read until now
- */
-
- if (strcmp(_my_time, _locales[LC_TIME -1]) == 0) {
- if (dtconv_str == NULL) {
- /*
- * Below is executed if getlocale_time()
- * is called when LC_TIME locale is initial
- * C locale.
- */
- strcpy(temp, "C");
- /*
- * Just to make openlocale() to read LC_TIME file.
- */
- strcat(_locales[LC_TIME-1], temp);
- goto initial;
- }
- return dtconv_str;
- }
- strcpy(temp, _locales[LC_TIME - 1]);
- strcpy(_locales[LC_TIME - 1], _my_time);
-initial:
- if ((fd = openlocale("LC_TIME", LC_TIME, temp, _locales[LC_TIME - 1])) < 0)
- return (NULL);
- strcpy(_my_time, _locales[LC_TIME - 1]);
- if (fd == 0)
- return dtconv_str;
- if ((fstat(fd, &buf)) != 0)
- return (NULL);
- if ((str = malloc((unsigned)buf.st_size + 2)) == NULL) {
- close(fd);
- return (NULL);
- }
-
- if ((read(fd, str, (int)buf.st_size)) != buf.st_size) {
- close(fd);
- free(str);
- return (NULL);
- }
-
- /* Set last character of str to '\0' */
- p = &str[buf.st_size];
- *p++ = '\n';
- *p = '\0';
-
- /* p will "walk thru" str */
- p = str;
-
- for (i = 0; i < 12; i++) {
- p = getstr(p, &dtconvp.abbrev_month_names[i]);
- if (p == NULL)
- goto fail;
- }
- for (i = 0; i < 12; i++) {
- p = getstr(p, &dtconvp.month_names[i]);
- if (p == NULL)
- goto fail;
- }
- for (i = 0; i < 7; i++) {
- p = getstr(p, &dtconvp.abbrev_weekday_names[i]);
- if (p == NULL)
- goto fail;
- }
- for (i = 0; i < 7; i++) {
- p = getstr(p, &dtconvp.weekday_names[i]);
- if (p == NULL)
- goto fail;
- }
- p = getstr(p, &dtconvp.time_format);
- if (p == NULL)
- goto fail;
- p = getstr(p, &dtconvp.sdate_format);
- if (p == NULL)
- goto fail;
- p = getstr(p, &dtconvp.dtime_format);
- if (p == NULL)
- goto fail;
- p = getstr(p, &dtconvp.am_string);
- if (p == NULL)
- goto fail;
- p = getstr(p, &dtconvp.pm_string);
- if (p == NULL)
- goto fail;
- p = getstr(p, &dtconvp.ldate_format);
- if (p == NULL)
- goto fail;
- (void) close(fd);
-
- /*
- * set info.
- */
- if (dtconv_str != NULL)
- free(dtconv_str);
-
- dtconv_str = str;
-
- /* The following is to get space malloc'd for _dtconv */
-
- if (_dtconv == 0)
- (void) localdtconv();
- memcpy(_dtconv, &dtconvp, sizeof(struct dtconv));
- return (dtconv_str);
-
-fail:
- (void) close(fd);
- free(str);
- return (NULL);
-}
-
-
-static char *
-getstr(p, strp)
- register char *p;
- char **strp;
-{
- *strp = p;
- p = strchr(p, '\n');
- if (p == NULL)
- return (NULL); /* no end-of-line */
- *p++ = '\0';
- return (p);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/stricmp.c b/usr/src/lib/libbc/libc/gen/common/stricmp.c
deleted file mode 100644
index 8f903db3de..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/stricmp.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * This array is designed for mapping upper and lower case letter
- * together for a case independent comparison. The mappings are
- * based upon ascii character sequences.
- */
-static char charmap[] = {
- '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007',
- '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017',
- '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027',
- '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037',
- '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047',
- '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057',
- '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067',
- '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077',
- '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137',
- '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147',
- '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157',
- '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167',
- '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177',
- '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207',
- '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217',
- '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227',
- '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237',
- '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247',
- '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257',
- '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267',
- '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277',
- '\300', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\333', '\334', '\335', '\336', '\337',
- '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347',
- '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357',
- '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367',
- '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377',
-};
-
-int
-strcasecmp(char *s1, char *s2)
-{
- char *cm = charmap;
-
- while (cm[*s1] == cm[*s2++])
- if (*s1++ == '\0')
- return (0);
- return(cm[*s1] - cm[*--s2]);
-}
-
-int
-strncasecmp(char *s1, char *s2, int n)
-{
- char *cm = charmap;
-
- while (--n >= 0 && cm[*s1] == cm[*s2++])
- if (*s1++ == '\0')
- return (0);
- return(n < 0 ? 0 : cm[*s1] - cm[*--s2]);
-}
-
-/*
- * For 4.0 compatibility
- */
-int
-stricmp(char *s1, char *s2)
-{
- return (strcasecmp(s1, s2));
-}
-
-int
-strnicmp(char *s1, char *s2, int n)
-{
- return (strncasecmp(s1, s2, n));
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/string_decim.c b/usr/src/lib/libbc/libc/gen/common/string_decim.c
deleted file mode 100644
index 2dd47e6ab1..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/string_decim.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1988 by Sun Microsystems, Inc.
- */
-
-#include <ctype.h>
-#include <stdio.h>
-#ifndef PRE41
-#include <locale.h>
-#endif
-#include "base_conversion.h"
-
-void
-string_to_decimal(ppc, nmax, fortran_conventions, pd, pform, pechar)
- char **ppc;
- int nmax;
- int fortran_conventions;
- decimal_record *pd;
- enum decimal_string_form *pform;
- char **pechar;
-
-{
- register char *cp = *ppc;
- register int current;
- register int nread = 1; /* Number of characters read so far. */
- char *cp0 = cp;
- char *good = cp - 1; /* End of known good token. */
-
- current = *cp;
-
-#define ATEOF 0 /* A string is never at EOF. */
-#define CURRENT current
-#define NEXT \
- if (nread < nmax) \
- {cp++ ; current = *cp ; nread++ ;} \
- else \
- {current = NULL ; } ; /* Increment input character and cp. */
-
-#include "char_to_decimal.h"
-#undef CURRENT
-#undef NEXT
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strncat.c b/usr/src/lib/libbc/libc/gen/common/strncat.c
deleted file mode 100644
index 6c1c5f4ea9..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strncat.c
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Concatenate s2 on the end of s1. S1's space must be large enough.
- * At most n characters are moved.
- * Return s1.
- */
-
-char *
-strncat(char *s1, char *s2, int n)
-{
- char *os1;
-
- os1 = s1;
- while (*s1++)
- ;
- --s1;
- while (*s1++ = *s2++)
- if (--n < 0) {
- *--s1 = '\0';
- break;
- }
- return (os1);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strpbrk.c b/usr/src/lib/libbc/libc/gen/common/strpbrk.c
deleted file mode 100644
index c876665bd9..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strpbrk.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-/*
- * Return ptr to first occurance of any character from `brkset'
- * in the character string `string'; NULL if none exists.
- */
-
-#define NULL (char *) 0
-
-char *
-strpbrk(string, brkset)
-register char *string, *brkset;
-{
- register char *p;
-
- do {
- for(p=brkset; *p != '\0' && *p != *string; ++p)
- ;
- if(*p != '\0')
- return(string);
- }
- while(*string++);
- return(NULL);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strptime.c b/usr/src/lib/libbc/libc/gen/common/strptime.c
deleted file mode 100644
index bfd7aef821..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strptime.c
+++ /dev/null
@@ -1,483 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#if !defined(lint) && defined(SCCSIDS)
-static char *sccsid = "%Z%%M% %I% %E% SMI";
-#endif
-
-#include <ctype.h>
-#include <locale.h>
-#include <time.h>
-
-static char *strmatch(/*char *cp, char *string*/);
-static char *yearmatch(/*char *cp, char *format, struct tm *tm,
- int *hadyearp*/);
-static char *cvtnum(/*char *cp, int *nump*/);
-static char *skipnws(/*char *format*/);
-
-extern char *getlocale_time();
-#define NULL 0
-
-char *
-strptime(buf, format, tm)
- char *buf;
- char *format;
- struct tm *tm;
-{
- register char *cp, *p;
- register int c, ch;
- register int i;
- register struct dtconv *dtcp;
- int hadyear;
-
- (void) getlocale_time();
- dtcp = localdtconv(); /* get locale's strings */
-
- cp = buf;
- while ((c = *format++) != '\0') {
- if (c == '%') {
- switch (*format++) {
-
- case '%': /* Percent sign */
- if (*cp++ != '%')
- return (NULL);
- break;
-
- case 'a': /* Abbreviated weekday name */
- case 'A': /* Weekday name */
- for (i = 0; i < 7; i++) {
- if ((p = strmatch(cp,
- dtcp->weekday_names[i],
- *format)) != NULL
- || (p = strmatch(cp,
- dtcp->abbrev_weekday_names[i],
- *format)) != NULL)
- goto match_wday;
- }
- return (NULL); /* no match */
-
- match_wday:
- tm->tm_wday = i;
- cp = p;
- break;
-
- case 'h':
- case 'b': /* Abbreviated month name */
- case 'B': /* Month name */
- for (i = 0; i < 12; i++) {
- if ((p = strmatch(cp,
- dtcp->month_names[i],
- *format)) != NULL
- || (p = strmatch(cp,
- dtcp->abbrev_month_names[i],
- *format)) != NULL)
- goto match_month;
- }
- return (NULL); /* no match */
-
- match_month:
- tm->tm_mon = i;
- cp = p;
- break;
-
- case 'c': /* date and time representation */
- cp = strptime(cp, "%x %X", tm);
- if (cp == NULL)
- return (NULL);
- break;
-
- case 'C': /* long date and time representation */
- cp = strptime(cp, dtcp->ldate_format, tm);
- if (cp == NULL)
- return (NULL);
- break;
-
- case 'd': /* Day of month, with leading zero */
- case 'e': /* Day of month without leading zero */
- cp = cvtnum(cp, &tm->tm_mday);
- if (cp == NULL)
- return (NULL); /* no digits */
- if (tm->tm_mday > 31)
- return (NULL);
- if ((c = *cp) == '\0'
- || isspace((unsigned char)c))
- format = skipnws(format);
- break;
-
- case 'D': /* Shorthand for %m/%d/%y */
- cp = strptime(cp, "%m/%d/%y", tm);
- if (cp == NULL)
- return (NULL);
- break;
-
- case 'H': /* Hour (24 hour version) */
- case 'k': /* Hour (24 hour version) */
- cp = cvtnum(cp, &tm->tm_hour);
- if (cp == NULL)
- return (NULL); /* no digits */
- if (tm->tm_hour > 23)
- return (NULL);
- if ((c = *cp) == '\0'
- || isspace((unsigned char)c))
- format = skipnws(format);
- break;
-
- case 'I': /* Hour (12 hour version) */
- case 'l': /* Hour (12 hour version) */
- cp = cvtnum(cp, &tm->tm_hour);
- if (cp == NULL)
- return (NULL); /* no digits */
- if (tm->tm_hour == 12)
- tm->tm_hour = 0;
- else if (tm->tm_hour > 11)
- return (NULL);
- if ((c = *cp) == '\0'
- || isspace((unsigned char)c))
- format = skipnws(format);
- break;
-
- case 'j': /* Julian date */
- cp = cvtnum(cp, &tm->tm_yday);
- if (cp == NULL)
- return (NULL); /* no digits */
- if (tm->tm_yday > 365)
- return (NULL);
- break;
-
- case 'm': /* Month number */
- cp = cvtnum(cp, &tm->tm_mon);
- if (cp == NULL)
- return (NULL); /* no digits */
- tm->tm_mon--;
- if (tm->tm_mon < 0 || tm->tm_mon > 11)
- return (NULL);
- if ((c = *cp) == '\0'
- || isspace((unsigned char)c))
- format = skipnws(format);
- break;
-
- case 'M': /* Minute */
- /*
- * This is optional; if we're at the end of the
- * string, or the next character is white
- * space, don't try to match it.
- */
- if ((c = *cp) != '\0'
- && !isspace((unsigned char)c)) {
- cp = cvtnum(cp, &tm->tm_min);
- if (cp == NULL)
- return (NULL); /* no digits */
- if (tm->tm_min > 59)
- return (NULL);
- }
- if ((c = *cp) == '\0'
- || isspace((unsigned char)c))
- format = skipnws(format);
- break;
-
- case 'p': /* AM or PM */
- if ((p = strmatch(cp, dtcp->am_string,
- *format)) != NULL) {
- /*
- * AM.
- */
- if (tm->tm_hour == 12)
- tm->tm_hour = 0;
- cp = p;
- } else if ((p = strmatch(cp, dtcp->pm_string,
- *format)) != NULL) {
- /*
- * PM.
- */
- if (tm->tm_hour > 12)
- return (NULL); /* error */
- else if (tm->tm_hour != 12)
- tm->tm_hour += 12;
- cp = p;
- }
- break;
-
- case 'r': /* Shorthand for %I:%M:%S AM or PM */
- cp = strptime(cp, "%I:%M:%S %p", tm);
- if (cp == NULL)
- return (NULL);
- break;
-
- case 'R': /* Time as %H:%M */
- cp = strptime(cp, "%H:%M", tm);
- if (cp == NULL)
- return (NULL);
- break;
-
- case 'S': /* Seconds */
- /*
- * This is optional; if we're at the end of the
- * string, or the next character is white
- * space, don't try to match it.
- */
- if ((c = *cp) != '\0'
- && !isspace((unsigned char)c)) {
- cp = cvtnum(cp, &tm->tm_sec);
- if (cp == NULL)
- return (NULL); /* no digits */
- if (tm->tm_sec > 59)
- return (NULL);
- }
- if ((c = *cp) == '\0'
- || isspace((unsigned char)c))
- format = skipnws(format);
- break;
-
- case 'T': /* Shorthand for %H:%M:%S */
- cp = strptime(cp, "%H:%M:%S", tm);
- if (cp == NULL)
- return (NULL);
- break;
-
- case 'x': /* Localized date format */
- cp = strptime(cp, dtcp->sdate_format, tm);
- if (cp == NULL)
- return (NULL);
- break;
-
- case 'X': /* Localized time format */
- cp = strptime(cp, dtcp->time_format, tm);
- if (cp == NULL)
- return (NULL);
- break;
-
- case 'y': /* Year in the form yy */
- cp = yearmatch(cp, format, tm, &hadyear);
- if (cp == NULL)
- return (NULL);
- if (hadyear) {
- if (tm->tm_year < 69)
- tm->tm_year += 100;
- }
- return (cp); /* match is complete */
-
- case 'Y': /* Year in the form ccyy */
- cp = yearmatch(cp, format, tm, &hadyear);
- if (cp == NULL)
- return (NULL);
- if (hadyear) {
- tm->tm_year -= 1900;
- if (tm->tm_year < 0)
- return (NULL);
- }
- return (cp); /* match is complete */
-
- default:
- return (NULL); /* unknown conversion */
- }
- } else {
- if (isspace((unsigned char)c)) {
- while ((ch = *cp++) != '\0'
- && isspace((unsigned char)ch))
- ;
- cp--;
- } else {
- if (*cp++ != c)
- return (NULL);
- }
- }
- }
- return (cp);
-}
-
-/*
- * Try to match the beginning of the string pointed to by "cp" with the string
- * pointed to by "string". The match is independent of the case of either
- * string.
- *
- * "termc" is the next character in the format string following the one for
- * which this match is being done. If the match succeeds, make sure the next
- * character after the match is either '\0', or that it would match "termc".
- *
- * If both matches succeed, return a pointer to the next character after the
- * first match. Otherwise, return NULL.
- */
-static char *
-strmatch(cp, string, termc)
- register char *cp;
- register char *string;
- char termc;
-{
- register unsigned char c, strc;
-
- /*
- * Match the beginning portion of "cp" with "string".
- */
- while ((strc = *string++) != '\0') {
- c = *cp++;
- if (isupper(c))
- c = tolower(c);
- if (isupper(strc))
- strc = tolower(strc);
- if (c != strc)
- return (NULL);
- }
-
- if ((c = *cp) != '\0') {
- if (isspace((unsigned char)termc)) {
- if (!isspace(c))
- return (NULL);
- } else {
- if (c != (unsigned char)termc)
- return (NULL);
- }
- }
- return (cp);
-}
-
-/*
- * Try to match a %y or %Y specification.
- * If it matches, try matching the rest of the format. If it succeeds, just
- * return. Otherwise, try backing the scan up, ignoring the %y/%Y and any
- * following non-white-space string. If that succeeds, just return. (This
- * permits a missing year to be detected if it's at the beginning of a date, as
- * well as if it's at the end of a date, so that formats such as "%Y/%m/%d" can
- * match "3/14" and default the year.)
- *
- * Set "*hadyearp" to indicate whether a year was specified or not.
- */
-static char *
-yearmatch(cp, format, tm, hadyearp)
- register char *cp;
- char *format;
- struct tm *tm;
- int *hadyearp;
-{
- register int c;
- char *savecp;
- int saveyear;
-
- /*
- * This is optional; if we're at the end of the
- * string, or the next character is white
- * space, don't try to match it.
- */
- if ((c = *cp) != '\0' && !isspace((unsigned char)c)) {
- savecp = cp;
- saveyear = tm->tm_year;
- cp = cvtnum(cp, &tm->tm_year);
- if (cp == NULL)
- return (NULL); /* no digits */
- if ((c = *cp) == '\0'
- || isspace((unsigned char)c))
- format = skipnws(format);
-
- /*
- * Year can also be optional if it's at
- * the *beginning* of a date. We check
- * this by trying to parse the rest of
- * the date here. If we succeed, OK;
- * otherwise, we skip over the %y and
- * try again.
- */
- cp = strptime(cp, format, tm);
- if (cp != NULL)
- *hadyearp = 1;
- else {
- *hadyearp = 0;
- cp = savecp;
- format = skipnws(format);
- tm->tm_year = saveyear;
- cp = strptime(cp, format, tm);
- }
- } else {
- *hadyearp = 0;
- if ((c = *cp) == '\0'
- || isspace((unsigned char)c))
- format = skipnws(format);
- cp = strptime(cp, format, tm);
- }
-
- return (cp);
-}
-
-/*
- * Try to match a (decimal) number in the string pointed to by "cp".
- * If the match succeeds, store the result in the "int" pointed to by "nump"
- * and return a pointer to the character following the number in the string.
- * If it fails, return NULL.
- */
-static char *
-cvtnum(cp, nump)
- register char *cp;
- int *nump;
-{
- register int c;
- register int i;
-
- c = (unsigned char)*cp++;
- if (!isdigit(c))
- return (NULL); /* no digits */
- i = 0;
- do {
- i = i*10 + c - '0';
- c = (unsigned char)*cp++;
- } while (isdigit(c));
- *nump = i;
- return (cp - 1);
-}
-
-/*
- * If a format item (such as %H, hours) is followed by a non-white-space
- * character other than "%", and the part of the string that matched the format
- * item is followed by white space, the string of non-white-space,
- * non-format-item characters following that format item may be omitted.
- */
-static char *
-skipnws(format)
- register char *format;
-{
- register char c;
-
- /*
- * Skip over non-white-space, non-digit characters. "%" is special.
- */
- while ((c = *format) != '\0' && !isspace((unsigned char)c)) {
- if (c == '%') {
- /*
- * This is a format item. If it's %%, skip it as
- * that's a non-white space, non-digit character.
- */
- if (*(format + 1) == '%')
- format++; /* skip % */
- else
- break;
- }
- format++;
- }
-
- return (format);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strrchr.c b/usr/src/lib/libbc/libc/gen/common/strrchr.c
deleted file mode 100644
index 28c338b895..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strrchr.c
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-/*
- * Return the ptr in sp at which the character c last
- * appears; NULL if not found
-*/
-
-#define NULL 0
-
-char *
-strrchr(sp, c)
-register char *sp, c;
-{
- register char *r;
-
- r = NULL;
- do {
- if(*sp == c)
- r = sp;
- } while(*sp++);
- return(r);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strspn.c b/usr/src/lib/libbc/libc/gen/common/strspn.c
deleted file mode 100644
index d68f5ce6af..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strspn.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-/*
- * Return the number of characters in the maximum leading segment
- * of string which consists solely of characters from charset.
- */
-int
-strspn(string, charset)
-char *string;
-register char *charset;
-{
- register char *p, *q;
-
- for(q=string; *q != '\0'; ++q) {
- for(p=charset; *p != '\0' && *p != *q; ++p)
- ;
- if(*p == '\0')
- break;
- }
- return(q-string);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strstr.c b/usr/src/lib/libbc/libc/gen/common/strstr.c
deleted file mode 100644
index 79bc3151fd..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strstr.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Get matching substring
- */
-#include <string.h>
-
-#pragma weak strstr = _strstr
-
-char *
-_strstr(s1, s2)
- register char *s1, *s2;
-{
- int s2len = strlen(s2); /* length of the second string */
- /*
- * If the length of the second string is 0,
- * return the first argument.
- */
- if (s2len == 0)
- return (s1);
-
- while (strlen(s1) >= s2len) {
- if (strncmp(s1, s2, s2len) == 0)
- return (s1);
- s1++;
- }
- return (0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strtod.c b/usr/src/lib/libbc/libc/gen/common/strtod.c
deleted file mode 100644
index fa551c76f1..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strtod.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1987 by Sun Microsystems, Inc.
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <values.h>
-#include <floatingpoint.h>
-
-double
-strtod(cp, ptr)
- char *cp;
- char **ptr;
-{
- double x;
- decimal_mode mr;
- decimal_record dr;
- fp_exception_field_type fs;
- enum decimal_string_form form;
- char *pechar;
-
- string_to_decimal(&cp, MAXINT, 0, &dr, &form, &pechar);
- if (ptr != (char **) NULL)
- *ptr = cp;
- if (form == invalid_form)
- return 0.0; /* Shameful kluge for SVID's sake. */
- mr.rd = fp_direction;
- decimal_to_double(&x, &mr, &dr, &fs);
- if (fs & (1 << fp_overflow)) { /* Overflow. */
- errno = ERANGE;
- }
- if (fs & (1 << fp_underflow)) { /* underflow */
- errno = ERANGE;
- }
- return x;
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strtok.c b/usr/src/lib/libbc/libc/gen/common/strtok.c
deleted file mode 100644
index 07fdbc7e94..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strtok.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-/*
- * uses strpbrk and strspn to break string into tokens on
- * sequentially subsequent calls. returns NULL when no
- * non-separator characters remain.
- * `subsequent' calls are calls with first argument NULL.
- */
-
-#define NULL (char*)0
-
-extern int strspn();
-extern char *strpbrk();
-
-char *
-strtok(string, sepset)
-char *string, *sepset;
-{
- register char *p, *q, *r;
- static char *savept;
-
- /*first or subsequent call*/
- p = (string == NULL)? savept: string;
-
- if(p == 0) /* return if no tokens remaining */
- return(NULL);
-
- q = p + strspn(p, sepset); /* skip leading separators */
-
- if(*q == '\0') /* return if no tokens remaining */
- return(NULL);
-
- if((r = strpbrk(q, sepset)) == NULL) /* move past token */
- savept = 0; /* indicate this is last token */
- else {
- *r = '\0';
- savept = ++r;
- }
- return(q);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/strtol.c b/usr/src/lib/libbc/libc/gen/common/strtol.c
deleted file mode 100644
index 5871be330f..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/strtol.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 2.1 */
-
-/*LINTLIBRARY*/
-#include <ctype.h>
-#define DIGIT(x) (isdigit(x) ? (x) - '0' : \
- islower(x) ? (x) + 10 - 'a' : (x) + 10 - 'A')
-#define MBASE ('z' - 'a' + 1 + 10)
-
-long
-strtol(str, ptr, base)
-register char *str;
-char **ptr;
-register int base;
-{
- register long val;
- register int c;
- int xx, neg = 0;
-
- if (ptr != (char **)0)
- *ptr = str; /* in case no number is formed */
- if (base < 0 || base > MBASE)
- return (0); /* base is invalid -- should be a fatal error */
- if (!isalnum(c = *str)) {
- while (isspace(c))
- c = *++str;
- switch (c) {
- case '-':
- neg++;
- case '+': /* fall-through */
- c = *++str;
- }
- }
- if (base == 0)
- if (c != '0')
- base = 10;
- else if (str[1] == 'x' || str[1] == 'X')
- base = 16;
- else
- base = 8;
- /*
- * for any base > 10, the digits incrementally following
- * 9 are assumed to be "abc...z" or "ABC...Z"
- */
- if (!isalnum(c) || (xx = DIGIT(c)) >= base)
- return (0); /* no number formed */
- if (base == 16 && c == '0' && isxdigit(str[2]) &&
- (str[1] == 'x' || str[1] == 'X'))
- c = *(str += 2); /* skip over leading "0x" or "0X" */
- for (val = -DIGIT(c); isalnum(c = *++str) && (xx = DIGIT(c)) < base; )
- /* accumulate neg avoids surprises near MAXLONG */
- val = base * val - xx;
- if (ptr != (char **)0)
- *ptr = str;
- return (neg ? val : -val);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/swab.c b/usr/src/lib/libbc/libc/gen/common/swab.c
deleted file mode 100644
index 19c50d1e99..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/swab.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1989 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 4.2 83/06/27 */
-
-/*
- * Swab bytes
- * Jeffrey Mogul, Stanford
- */
-
-void
-swab(from, to, n)
- register char *from, *to;
- register int n;
-{
- register unsigned long temp;
-
- if (n <= 1)
- return;
- n >>= 1; n++;
-#define STEP temp = *from++,*to++ = *from++,*to++ = temp
- /* round to multiple of 8 */
- while ((--n) & 07)
- STEP;
- n >>= 3;
- while (--n >= 0) {
- STEP; STEP; STEP; STEP;
- STEP; STEP; STEP; STEP;
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/syslog.c b/usr/src/lib/libbc/libc/gen/common/syslog.c
deleted file mode 100644
index 8ff41f8e94..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/syslog.c
+++ /dev/null
@@ -1,331 +0,0 @@
-/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1983 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * SYSLOG -- print message on log file
- *
- * This routine looks a lot like printf, except that it
- * outputs to the log file instead of the standard output.
- * Also:
- * adds a timestamp,
- * prints the module name in front of the message,
- * has some other formatting types (or will sometime),
- * adds a newline on the end of the message.
- *
- * The output of this routine is intended to be read by /etc/syslogd.
- *
- * Author: Eric Allman
- * Modified to use UNIX domain IPC by Ralph Campbell
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/file.h>
-#include <sys/signal.h>
-#include <sys/syslog.h>
-#include <sys/time.h>
-#include <sys/unistd.h>
-#include <netdb.h>
-#include <strings.h>
-#include <stdarg.h>
-#include <vfork.h>
-#include <stdio.h>
-#include <errno.h>
-#include <malloc.h>
-
-
-#define MAXLINE 1024 /* max message size */
-
-#define PRIMASK(p) (1 << ((p) & LOG_PRIMASK))
-#define PRIFAC(p) (((p) & LOG_FACMASK) >> 3)
-#define IMPORTANT LOG_ERR
-
-static char *logname = "/dev/log";
-static char *ctty = "/dev/console";
-static char *sysmsg = "/dev/sysmsg";
-
-static struct _syslog {
- int _LogFile;
- int _LogStat;
- char *_LogTag;
- int _LogMask;
- struct sockaddr _SyslogAddr;
- char *_SyslogHost;
- int _LogFacility;
-} *_syslog;
-#define LogFile (_syslog->_LogFile)
-#define LogStat (_syslog->_LogStat)
-#define LogTag (_syslog->_LogTag)
-#define LogMask (_syslog->_LogMask)
-#define SyslogAddr (_syslog->_SyslogAddr)
-#define SyslogHost (_syslog->_SyslogHost)
-#define LogFacility (_syslog->_LogFacility)
-
-
-extern char *strerror(int);
-extern time_t time();
-
-void vsyslog(int, char *, va_list);
-void openlog(char *, int, int);
-static int snprintf(char *, size_t, char *, ...);
-static int vsnprintf(char *, size_t, char *, va_list ap);
-
-static int
-allocstatic(void)
-{
- _syslog = (struct _syslog *)calloc(1, sizeof (struct _syslog));
- if (_syslog == 0)
- return (0); /* can't do it */
- LogFile = -1; /* fd for log */
- LogStat = 0; /* status bits, set by openlog() */
- LogTag = "syslog"; /* string to tag the entry with */
- LogMask = 0xff; /* mask of priorities to be logged */
- LogFacility = LOG_USER; /* default facility code */
- return (1);
-}
-
-void
-syslog(int pri, char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- vsyslog(pri, fmt, ap);
- va_end(ap);
-}
-
-void
-vsyslog(int pri, char *fmt, va_list ap)
-{
- char buf[MAXLINE + 1], outline[MAXLINE + 1];
- char *b, *f, *o;
- int c;
- long now;
- int pid, olderrno = errno;
- int retsiz, outsiz = MAXLINE + 1;
- int taglen;
-/*
- * Maximum tag length is 256 (the pad in outline) minus the size of the
- * other things that can go in the pad.
- */
-#define MAX_TAG 230
-
-
- if (_syslog == 0 && !allocstatic())
- return;
-
- /* see if we should just throw out this message */
- if (pri <= 0 || PRIFAC(pri) >= LOG_NFACILITIES ||
- (PRIMASK(pri) & LogMask) == 0)
- return;
- if (LogFile < 0)
- openlog(LogTag, LogStat | LOG_NDELAY, 0);
-
- /* set default facility if none specified */
- if ((pri & LOG_FACMASK) == 0)
- pri |= LogFacility;
-
- /* build the message */
- o = outline;
- (void) time(&now);
- (void) sprintf(o, "<%d>%.15s ", pri, ctime(&now) + 4);
- o += strlen(o);
-
- if (LogTag) {
- taglen = strlen(LogTag) < MAX_TAG ? strlen(LogTag) : MAX_TAG;
- strncpy(o, LogTag, taglen);
- o[taglen] = '\0';
- o += strlen(o);
- }
- if (LogStat & LOG_PID) {
- (void) sprintf(o, "[%d]", getpid());
- o += strlen(o);
- }
- if (LogTag) {
- (void) strcpy(o, ": ");
- o += 2;
- }
-
- b = buf;
- f = fmt;
- while ((c = *f++) != '\0' && c != '\n' && b < &buf[MAXLINE]) {
- char *errstr;
-
- if (c != '%') {
- *b++ = c;
- continue;
- }
- if ((c = *f++) != 'm') {
- *b++ = '%';
- *b++ = c;
- continue;
- }
- if ((errstr = strerror(olderrno)) == NULL)
- (void) snprintf(b, &buf[MAXLINE] - b, "error %d",
- olderrno);
- else {
- while (*errstr != '\0' && b < &buf[MAXLINE]) {
- if (*errstr == '%') {
- strcpy(b, "%%");
- b += 2;
- }
- else
- *b++ = *errstr;
- errstr++;
- }
- *b = '\0';
- }
- b += strlen(b);
- }
- if (b > buf && *(b-1) != '\n') /* ensure at least one newline */
- *b++ = '\n';
- *b = '\0';
- (void) vsnprintf(o, &outline[sizeof (outline)] - o, buf, ap);
- c = strlen(outline) + 1; /* add one for NULL byte */
- if (c > MAXLINE) {
- c = MAXLINE;
- outline[MAXLINE-1] = '\0';
- }
-
- /* output the message to the local logger */
- if (sendto(LogFile, outline, c, 0, &SyslogAddr,
- sizeof (SyslogAddr)) >= 0)
- return;
- if (!(LogStat & LOG_CONS))
- return;
-
- /* output the message to the console */
- pid = vfork();
- if (pid == -1)
- return;
- if (pid == 0) {
- int fd;
-
- (void) signal(SIGALRM, SIG_DFL);
- (void) sigsetmask(sigblock(0) & ~sigmask(SIGALRM));
- (void) alarm(5);
- if (((fd = open(sysmsg, O_WRONLY)) >= 0) ||
- (fd = open(ctty, O_WRONLY)) >= 0) {
- (void) alarm(0);
- if (outsiz > 2) { /* Just in case */
- (void) strcat(o, "\r\n");
- c += 2;
- }
- o = index(outline, '>') + 1;
- (void) write(fd, o, c - (o - outline));
- (void) close(fd);
- } else
- (void) alarm(0);
- _exit(0);
- }
- if (!(LogStat & LOG_NOWAIT))
- while ((c = wait((int *)0)) > 0 && c != pid)
- ;
-}
-
-/*
- * OPENLOG -- open system log
- */
-void
-openlog(char *ident, int logstat, int logfac)
-{
- if (_syslog == 0 && !allocstatic())
- return;
- if (ident != NULL)
- LogTag = ident;
- LogStat = logstat;
- if (logfac != 0)
- LogFacility = logfac & LOG_FACMASK;
- if (LogFile >= 0)
- return;
- SyslogAddr.sa_family = AF_UNIX;
- (void) strncpy(SyslogAddr.sa_data, logname,
- sizeof (SyslogAddr.sa_data));
- if (LogStat & LOG_NDELAY) {
- LogFile = socket(AF_UNIX, SOCK_DGRAM, 0);
- (void) fcntl(LogFile, F_SETFD, 1);
- }
-}
-
-/*
- * CLOSELOG -- close the system log
- */
-void
-closelog(void)
-{
-
- if (_syslog == 0)
- return;
- (void) close(LogFile);
- LogFile = -1;
-}
-
-/*
- * SETLOGMASK -- set the log mask level
- */
-int
-setlogmask(int pmask)
-{
- int omask;
-
- if (_syslog == 0 && !allocstatic())
- return (-1);
- omask = LogMask;
- if (pmask != 0)
- LogMask = pmask;
- return (omask);
-}
-
-/*
- * snprintf/vsnprintf -- These routines are here
- * temporarily to solve bugid 1220257. Perhaps
- * they could become a public interface at some
- * point but not for now.
- */
-
-extern int _doprnt();
-
-static int
-snprintf(char *string, size_t n, char *format, ...)
-{
- int count;
- FILE siop;
- va_list ap;
-
- if (n == 0)
- return (0);
- siop._cnt = n - 1;
- siop._base = siop._ptr = (unsigned char *)string;
- siop._flag = _IOWRT+_IOSTRG;
- va_start(ap, format);
- count = _doprnt(format, ap, &siop);
- va_end(ap);
- *siop._ptr = '\0'; /* plant terminating null character */
- return (count);
-}
-
-static int
-vsnprintf(char *string, size_t n, char *format, va_list ap)
-{
- int count;
- FILE siop;
-
- if (n == 0)
- return (0);
- siop._cnt = n - 1;
- siop._base = siop._ptr = (unsigned char *)string;
- siop._flag = _IOWRT+_IOSTRG;
- count = _doprnt(format, ap, &siop);
- *siop._ptr = '\0'; /* plant terminating null character */
- return (count);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/telldir.c b/usr/src/lib/libbc/libc/gen/common/telldir.c
deleted file mode 100644
index 84364cb547..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/telldir.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1987 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/param.h>
-#include <dirent.h>
-
-/*
- * return a pointer into a directory
- */
-long
-telldir(dirp)
- register DIR *dirp;
-{
- return(dirp->dd_off);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/tfind.c b/usr/src/lib/libbc/libc/gen/common/tfind.c
deleted file mode 100644
index b58036f1bd..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/tfind.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI" /* from S5R2 1.2 */
-
-/*LINTLIBRARY*/
-/*
- * Tree search algorithm, generalized from Knuth (6.2.2) Algorithm T.
- *
- * The NODE * arguments are declared in the lint files as char *,
- * because the definition of NODE isn't available to the user.
- */
-
-#include <search.h>
-typedef char *POINTER;
-typedef struct node { POINTER key; struct node *llink, *rlink; } NODE;
-
-#define NULL 0
-
-
-/* tfind - find a node, or return 0 */
-NODE *
-tfind(key, rootp, compar)
-POINTER key; /* Key to be located */
-register NODE **rootp; /* Address of the root of the tree */
-int (*compar)(); /* Comparison function */
-{
- if (rootp == NULL)
- return (NULL);
- while (*rootp != NULL) { /* T1: */
- int r = (*compar)(key, (*rootp)->key); /* T2: */
- if (r == 0)
- return (*rootp); /* Key found */
- rootp = (r < 0) ?
- &(*rootp)->llink : /* T3: Take left branch */
- &(*rootp)->rlink; /* T4: Take right branch */
- }
- return (NODE *)(NULL);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/time.c b/usr/src/lib/libbc/libc/gen/common/time.c
deleted file mode 100644
index 7b73f79bd8..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/time.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 4.2 83/02/27 */
-
-/*
- * Backwards compatible time call.
- */
-#include <sys/types.h>
-#include <sys/time.h>
-
-time_t
-time(t)
- time_t *t;
-{
- struct timeval tt;
-
- if (gettimeofday(&tt, (struct timezone *)0) < 0)
- return (-1);
- if (t)
- *t = tt.tv_sec;
- return (tt.tv_sec);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/tsearch.c b/usr/src/lib/libbc/libc/gen/common/tsearch.c
deleted file mode 100644
index 287c84806a..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/tsearch.c
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/* Copyright (c) 1984 AT&T */
-/* All Rights Reserved */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*LINTLIBRARY*/
-/*
- * Tree search algorithm, generalized from Knuth (6.2.2) Algorithm T.
- *
- *
- * The NODE * arguments are declared in the lint files as char *,
- * because the definition of NODE isn't available to the user.
- */
-
-#include <search.h>
-#include <stdio.h>
-#include <malloc.h>
-
-typedef char *POINTER;
-typedef struct node { POINTER key; struct node *llink, *rlink; } NODE;
-
-/*
- * Find or insert key into search tree
- *
- * Arguments
- * key: Key to be located
- * rootp: Address of the root of the tree
- * compar: Comparison function
- */
-NODE *
-tsearch(POINTER key, NODE **rootp, int (*compar)(POINTER, POINTER))
-{
- NODE *q; /* New node if key not found */
-
- if (rootp == NULL)
- return (NULL);
- while (*rootp != NULL) { /* T1: */
- int r = (*compar)(key, (*rootp)->key); /* T2: */
- if (r == 0)
- return (*rootp); /* Key found */
- rootp = (r < 0) ?
- &(*rootp)->llink : /* T3: Take left branch */
- &(*rootp)->rlink; /* T4: Take right branch */
- }
- q = (NODE *) malloc(sizeof(NODE)); /* T5: Not found */
- if (q != NULL) { /* Allocate new node */
- *rootp = q; /* Link new node to old */
- q->key = key; /* Initialize new node */
- q->llink = q->rlink = NULL;
- }
- return (q);
-}
-
-/*
- * Delete node with key key
- *
- * Arguments
- * key: Key to be deleted
- * rootp: Address of the root of tree
- * compar: Comparison function
- */
-NODE *
-tdelete(POINTER key, NODE **rootp, int (*compar)(POINTER, POINTER))
-{
- NODE *p; /* Parent of node to be deleted */
- NODE *q; /* Successor node */
- NODE *r; /* Right son node */
- int ans; /* Result of comparison */
-
- if (rootp == NULL || (p = *rootp) == NULL)
- return (NULL);
- while ((ans = (*compar)(key, (*rootp)->key)) != 0) {
- p = *rootp;
- rootp = (ans < 0) ?
- &(*rootp)->llink : /* Take left branch */
- &(*rootp)->rlink; /* Take right branch */
- if (*rootp == NULL)
- return (NULL); /* Key not found */
- }
- r = (*rootp)->rlink; /* D1: */
- if ((q = (*rootp)->llink) == NULL) /* Llink NULL? */
- q = r;
- else if (r != NULL) { /* Rlink NULL? */
- if (r->llink == NULL) { /* D2: Find successor */
- r->llink = q;
- q = r;
- } else { /* D3: Find NULL link */
- for (q = r->llink; q->llink != NULL; q = r->llink)
- r = q;
- r->llink = q->rlink;
- q->llink = (*rootp)->llink;
- q->rlink = (*rootp)->rlink;
- }
- }
- free((POINTER) *rootp); /* D4: Free node */
- *rootp = q; /* Link parent to replacement */
- return (p);
-}
-
-static void _twalk(NODE *, void (*)(NODE *, VISIT, int), int);
-
-/*
- * Walk the nodes of a tree
- *
- * Arguments
- * root: Root of the tree to be walked
- * action: Function to be called at each node
- */
-void
-twalk(NODE *root, void (*action)(NODE *, VISIT, int))
-{
-
- if (root != NULL && action != NULL)
- _twalk(root, action, 0);
-}
-
-/*
- * Walk the nodes of a tree
- *
- * Arguments
- * root: Root of the tree to be walked
- * action: Function to be called at each node
- */
-static void
-_twalk(NODE *root, void (*action)(NODE *, VISIT, int), int level)
-{
- if (root->llink == NULL && root->rlink == NULL)
- (*action)(root, leaf, level);
- else {
- (*action)(root, preorder, level);
- if (root->llink != NULL)
- _twalk(root->llink, action, level + 1);
- (*action)(root, postorder, level);
- if (root->rlink != NULL)
- _twalk(root->rlink, action, level + 1);
- (*action)(root, endorder, level);
- }
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/ttyslot.c b/usr/src/lib/libbc/libc/gen/common/ttyslot.c
deleted file mode 100644
index 24a132f4f1..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ttyslot.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (the "License").
- * You may not use this file except in compliance with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-
-/*
- * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1984 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-/*
- * Return the number of the slot in the utmp file
- * corresponding to the current user: try for file 0, 1, 2.
- * To mimic the behavior of getttyent, we loop through utmp
- * and try to find an entry with a matching line number.
- * If we don't find one we return the index of the end of
- * the file, so that the record can be added to the end of
- * the file.
- */
-#include "../../sys/common/compat.h"
-#include <sys/syscall.h>
-#include <sys/fcntl.h>
-#include <stdio.h>
-#include <unistd.h>
-#include <strings.h>
-
-int
-ttyslot(void)
-{
- char *tp, *p;
- int s;
- int fd;
- struct utmpx utx;
-
-
- if ((tp = ttyname(0)) == NULL &&
- (tp = ttyname(1)) == NULL &&
- (tp = ttyname(2)) == NULL)
- return (0);
- if ((p = rindex(tp, '/')) == NULL)
- p = tp;
- else
- p++;
-
- if ((fd = _syscall(SYS_openat,
- AT_FDCWD, "/etc/utmpx", O_RDONLY)) == -1) {
- perror("ttyslot: open of /etc/utmpx failed:");
- return (0);
- }
-
- s = 0;
- while (_read(fd, &utx, sizeof (struct utmpx)) > 0) {
- s++;
- if (strncmp(utx.ut_line, p, sizeof (utx.ut_line)) == 0) {
- _syscall(SYS_close, fd);
- return (s);
- }
- }
- _syscall(SYS_close, fd);
- return (s);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/ualarm.c b/usr/src/lib/libbc/libc/gen/common/ualarm.c
deleted file mode 100644
index 9972b0b279..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/ualarm.c
+++ /dev/null
@@ -1,36 +0,0 @@
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 5.1 85/06/05 */
-
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#include <sys/time.h>
-
-#define USPS 1000000 /* # of microseconds in a second */
-
-/*
- * Generate a SIGALRM signal in ``usecs'' microseconds.
- * If ``reload'' is non-zero, keep generating SIGALRM
- * every ``reload'' microseconds after the first signal.
- */
-unsigned
-ualarm(usecs, reload)
- register unsigned usecs;
- register unsigned reload;
-{
- struct itimerval new, old;
-
- new.it_interval.tv_usec = reload % USPS;
- new.it_interval.tv_sec = reload / USPS;
-
- new.it_value.tv_usec = usecs % USPS;
- new.it_value.tv_sec = usecs / USPS;
-
- if (setitimer(ITIMER_REAL, &new, &old) == 0)
- return (old.it_value.tv_sec * USPS + old.it_value.tv_usec);
- /* else */
- return (-1);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/unpack_float.c b/usr/src/lib/libbc/libc/gen/common/unpack_float.c
deleted file mode 100644
index b102daeb0c..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/unpack_float.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1988 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* IEEE function implementations. */
-
-#include "base_conversion.h"
-
-enum fp_class_type
-_class_single(single *x)
-{
- single_equivalence kluge;
-
- kluge.x = *x;
- if (kluge.f.msw.exponent == 0) { /* 0 or sub */
- if (kluge.f.msw.significand == 0)
- return fp_zero;
- else
- return fp_subnormal;
- } else if (kluge.f.msw.exponent == 0xff) { /* inf or nan */
- if (kluge.f.msw.significand == 0)
- return fp_infinity;
- else if (kluge.f.msw.significand >= 0x400000)
- return fp_quiet;
- else
- return fp_signaling;
- } else
- return fp_normal;
-}
-
-enum fp_class_type
-_class_extended(extended *x)
-{
- extended_equivalence kluge;
-
- kluge.x[0] = (*x)[0];
- kluge.x[1] = (*x)[1];
- kluge.x[2] = (*x)[2];
- if (kluge.f.msw.exponent == 0) { /* 0 or sub */
- if ((kluge.f.significand == 0) && (kluge.f.significand2 == 0))
- return fp_zero;
- else
- return fp_subnormal;
- } else if (kluge.f.msw.exponent == 0x7fff) { /* inf or nan */
- if (((kluge.f.significand & 0x7fffffff) == 0) && (kluge.f.significand2 == 0))
- return fp_infinity;
- else if ((kluge.f.significand & 0x7fffffff) >= 0x40000000)
- return fp_quiet;
- else
- return fp_signaling;
- } else
- return fp_normal;
-}
-
-void
-_unpack_single(unpacked *pu, single *px)
-{
- single_equivalence x;
- int i;
-
- x.x = *px;
- (*pu).sign = x.f.msw.sign;
- for (i = 1; i < UNPACKED_SIZE; i++)
- pu->significand[i] = 0;
- if (x.f.msw.exponent == 0) { /* zero or sub */
- if (x.f.msw.significand == 0) { /* zero */
- pu->fpclass = fp_zero;
- return;
- } else { /* subnormal */
- pu->fpclass = fp_normal;
- pu->exponent = -SINGLE_BIAS;
- pu->significand[0] = x.f.msw.significand << 9;
- _fp_normalize(pu);
- return;
- }
- } else if (x.f.msw.exponent == 0xff) { /* inf or nan */
- if (x.f.msw.significand == 0) { /* inf */
- pu->fpclass = fp_infinity;
- return;
- } else { /* nan */
- if ((x.f.msw.significand & 0x400000) != 0) { /* quiet */
- pu->fpclass = fp_quiet;
- } else {/* signaling */
- pu->fpclass = fp_quiet;
- _fp_set_exception(fp_invalid);
- }
- pu->significand[0] = 0x40000000 | (x.f.msw.significand << 8);
- return;
- }
- }
- (*pu).exponent = x.f.msw.exponent - SINGLE_BIAS;
- (*pu).fpclass = fp_normal;
- (*pu).significand[0] = 0x80000000 | (x.f.msw.significand << 8);
-}
-
-void
-_unpack_extended(unpacked *pu, extended *px)
-{
- extended_equivalence x;
- int i;
-
- x.x[0] = (*px)[0];
- x.x[1] = (*px)[1];
- x.x[2] = (*px)[2];
- pu->sign = x.f.msw.sign;
- pu->fpclass = fp_normal;
- pu->exponent = x.f.msw.exponent - EXTENDED_BIAS;
- pu->significand[0] = x.f.significand;
- pu->significand[1] = x.f.significand2;
- for (i = 2; i < UNPACKED_SIZE; i++)
- pu->significand[i] = 0;
- if (x.f.msw.exponent == 0x7fff) { /* inf or nan */
- if (((x.f.significand & 0x7fffffff) == 0) && (x.f.significand2 == 0)) { /* inf */
- pu->fpclass = fp_infinity;
- return;
- } else { /* nan */
- if ((x.f.significand & 0x40000000) != 0) { /* quiet */
- pu->fpclass = fp_quiet;
- } else {/* signaling */
- pu->fpclass = fp_quiet;
- _fp_set_exception(fp_invalid);
- }
- return;
- }
- }
- if (x.f.significand < 0x80000000) { /* zero or unnormal */
- if ((x.f.significand == 0) && (x.f.significand2 == 0)) { /* zero */
- pu->fpclass = fp_zero;
- return;
- } else { /* unnormal */
- pu->fpclass = fp_normal;
- _fp_normalize(pu);
- return;
- }
- }
-}
-
-void
-_display_unpacked(unpacked *pu)
-{
- int i, e;
-
- (void) printf(" unpacked ");
- if (pu->sign == 1)
- (void) printf("-");
- else
- (void) printf("+");
- switch (pu->fpclass) {
- case fp_zero:
- (void) printf("0");
- break;
- case fp_infinity:
- (void) printf("Infinity");
- break;
- case fp_quiet:
- (void) printf("NaN(quiet)");
- break;
- case fp_signaling:
- (void) printf("NaN(signaling)");
- break;
- case fp_subnormal:
- case fp_normal:
- e = 1 + pu->exponent;
- for (i = 0; i < UNPACKED_SIZE; i++) {
- e -= 32;
- (void) printf(" %8X *2**%d + ", pu->significand[i], e);
- }
- }
- (void) printf("\n");
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/usleep.c b/usr/src/lib/libbc/libc/gen/common/usleep.c
deleted file mode 100644
index 65b5071b36..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/usleep.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright 1996 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1985 Regents of the University of California.
- * All rights reserved. The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
- */
-
-#include <unistd.h>
-#include <sys/time.h>
-#include <signal.h>
-
-#define USPS 1000000 /* number of microseconds in a second */
-#define TICK (USPS / _sysconf(_SC_CLK_TCK))
-
-#define setvec(vec, a) \
- vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0
-
-static int ringring;
-
-static void
-sleepx(void)
-{
-
- ringring = 1;
-}
-
-void
-usleep(unsigned n)
-{
- int omask;
- struct itimerval itv, oitv;
- struct itimerval *itp = &itv;
- struct sigvec vec, ovec;
-
- if (n == 0)
- return;
- timerclear(&itp->it_interval);
- timerclear(&itp->it_value);
- if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
- return;
- itp->it_value.tv_sec = n / USPS;
- itp->it_value.tv_usec = n % USPS;
- if (timerisset(&oitv.it_value)) {
- if (timercmp(&oitv.it_value, &itp->it_value, >)) {
- oitv.it_value.tv_sec -= itp->it_value.tv_sec;
- oitv.it_value.tv_usec -= itp->it_value.tv_usec;
- if (oitv.it_value.tv_usec < 0) {
- oitv.it_value.tv_usec += USPS;
- oitv.it_value.tv_sec--;
- }
- } else {
- itp->it_value = oitv.it_value;
- oitv.it_value.tv_sec = 0;
- oitv.it_value.tv_usec = 2 * TICK;
- }
- }
- setvec(vec, sleepx);
- (void) sigvec(SIGALRM, &vec, &ovec);
- omask = sigblock(sigmask(SIGALRM));
- ringring = 0;
- (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0);
- while (!ringring)
- sigpause(omask &~ sigmask(SIGALRM));
- (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0);
- (void) sigsetmask(omask);
- (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/valloc.c b/usr/src/lib/libbc/libc/gen/common/valloc.c
deleted file mode 100644
index 68fd6a9efc..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/valloc.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
- /* from UCB 4.3 83/07/01 */
-
-extern unsigned getpagesize();
-extern char *memalign();
-
-char *
-valloc(size)
- unsigned size;
-{
- static unsigned pagesize;
- if (!pagesize)
- pagesize = getpagesize();
- return memalign(pagesize, size);
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/wcstombs.c b/usr/src/lib/libbc/libc/gen/common/wcstombs.c
deleted file mode 100644
index 9520238429..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/wcstombs.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1991 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * wcstombs
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#if !defined(lint) && defined(SCCSIDS)
-static char *sccsid = "%Z%%M% %I% %E% SMI";
-#endif
-
-#include <sys/types.h>
-#include "codeset.h"
-#include "mbextern.h"
-
-size_t
-wcstombs(s, pwcs, n)
- char *s;
- wchar_t * pwcs;
- size_t n;
-{
- char *handle; /* handle */
- int (*p)();
- int num = 0;
- int ret;
-
- switch (_code_set_info.code_id) {
- case CODESET_NONE:
- /*
- * default code set
- */
- while (*pwcs && (num < n)) {
- *s++ = *pwcs++ & 0x00ff;
- num++;
- }
- if (num < n)
- *s = 0;
- return (num);
- break;
- case CODESET_EUC:
- /*
- * EUC code set
- */
- return(_wcstombs_euc(s, pwcs, n));
- break;
-
- case CODESET_XCCS:
- /*
- * XCCS code set
- */
- return(_wcstombs_xccs(s, pwcs, n));
- break;
-
- case CODESET_ISO2022:
- /*
- * ISO family
- */
- return(_wcstombs_iso(s, pwcs, n));
- break;
-
- default:
- /*
- * User defined code set
- */
- handle = _ml_open_library();
- if (handle == (char *)NULL)
- return(ERROR_NO_LIB); /* No user library */
- p = (int (*)()) dlsym(handle, "_wcstombs");
- if (p == (int (*)()) NULL)
- return(ERROR_NO_SYM);
- ret = (*p)(s, pwcs, n);
- return (ret);
- break;
- }
- /* NOTREACHED */
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/wctomb.c b/usr/src/lib/libbc/libc/gen/common/wctomb.c
deleted file mode 100644
index dba8d0999d..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/wctomb.c
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1991 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * wctomb
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#if !defined(lint) && defined(SCCSIDS)
-static char *sccsid = "%Z%%M% %I% %E% SMI";
-#endif
-
-#include <sys/types.h>
-#include "codeset.h"
-#include "mbextern.h"
-
-int
-wctomb(s, pwc)
- char *s;
- wchar_t pwc;
-{
- char *handle; /* handle */
- int (*p)();
- int ret;
-
- switch (_code_set_info.code_id) {
- case CODESET_NONE:
- /*
- * Default code set,
- */
- if (s == NULL)
- return (0); /* No state dependency */
- else {
- *s = (char) (pwc & 0x00ff);
- return (1);
- }
- case CODESET_EUC:
- /*
- * EUC code set
- */
- if (s == NULL)
- return (0); /* No state dependecy */
- return(_wctomb_euc(s, pwc));
- break;
-
- case CODESET_XCCS:
- /*
- * XCCS code set
- */
- if (s == 0)
- return (0); /* No state dependecy */
- return(_wctomb_xccs(s, pwc));
- break;
-
- case CODESET_ISO2022:
- /*
- * ISO family
- */
- if (s == 0)
- return (1); /* State dependant */
- return(_wctomb_iso(s, pwc));
- break;
-
- default:
- /*
- * User defined code set
- */
- handle = _ml_open_library();
- if (handle == (char *)NULL)
- return(ERROR_NO_LIB); /* No user library */
- p = (int (*)()) dlsym(handle, "_wctomb");
- if (p == (int (*)()) NULL)
- return(ERROR_NO_SYM);
- ret = (*p)(s, pwc);
- return (ret);
- break;
- }
- /* NOTREACHED */
-}
diff --git a/usr/src/lib/libbc/libc/gen/common/xccs.multibyte.c b/usr/src/lib/libbc/libc/gen/common/xccs.multibyte.c
deleted file mode 100644
index 6685f4d707..0000000000
--- a/usr/src/lib/libbc/libc/gen/common/xccs.multibyte.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#if !defined(lint) && defined(SCCSIDS)
-static char *sccsid = "%Z%%M% %I% %E% SMI";
-#endif
-
-#include <stdio.h>
-#include <sys/types.h>
-
-#define CS377 0377
-#define MASK 0x0000ffff
-#define TOP1 0x80000000
-#define TOP2 0x08000000
-
-
-/*
- * mbtowc routines for the Xerox XCCS codeset standard
- */
-int
-_mbtowc_xccs(pwc, s, n)
- wchar_t *pwc;
- char *s;
- int n;
-{
- static unsigned int CSselect = 0;
- static int CSlength = 1;
- wchar_t twchar = 0;
-
- /*
- * If length is negative, return error
- */
- if (n <= 0)
- return (-1);
-
- /*
- * End of string ?
- */
- if (*s == 0 && CSlength == 1)
- return (0);
- if (*s == 0 && *(s + 1) == 0 && CSlength == 2)
- return (0);
-
- /*
- * Get a character
- */
- if ((unsigned char)*s == CS377) {
- /*
- * Switching code set
- */
- ++s;
- /*
- * Change characteristics
- */
- if ((unsigned char)*s == CS377) {
- ++s;
- /*
- * two byte sequence
- */
- if (*s++ != 0)
- return (-1);
- CSselect = 0;
- CSlength = 2;
-
- }
- else {
- /*
- * Change CSselect
- */
- CSselect = (unsigned int)*s++;
- CSlength = 1;
- }
- }
-
- /*
- * Get a character and return
- */
- if (CSlength == 1) {
- twchar = CSselect;
- }
- else {
- twchar = *s++;
- }
- twchar = twchar << 8;
- twchar = twchar | *s;
- if (pwc)
- *pwc = twchar & MASK;
- /*
- * Encode additional information
- */
- if (CSlength == 2)
- if (pwc)
- *pwc |= TOP1;
- return (CSlength);
-}
-
-/*
- * wctomb routines
- */
-int
-_wctomb_xccs(s, pwc)
- char *s;
- wchar_t pwc;
-{
- unsigned char upper, lower;
- char *old = s;
-#ifdef DEBUG
- printf ("XCCS- xctomb\n");
-#endif
-
- if (!s)
- return (0);
-
- /*
- * Get lower and upper anyway
- */
- lower = pwc & 0x00ff;
- upper = (pwc >> 8) & 0x00ff;
- if (lower == CS377 || upper == CS377)
- return (-1);
- if (pwc & TOP1) { /* length == 2 */
- /*
- * This was the marker.
- * Emitt 3 additional characters.
- */
- *s++ = CS377;
- *s++ = CS377;
- *s++ = 0;
- *s++ = upper;
- *s++ = lower;
- }
- else {
- /*
- * This was the marker.
- * Emitt 2 additional characters.
- */
- *s++ = CS377;
- *s++ = upper;
- *s++ = lower;
- }
- return (s - old);
-}
-
-
-/*
- * mbstowcs routines
- */
-size_t
-_mbstowcs_xccs(pwc, s, n)
- wchar_t *pwc;
- char *s;
- int n;
-{
- static unsigned int CSselect = 0;
- static int CSlength = 1;
- wchar_t twchar = 0;
- int cnt = 0;
-
- /*
- * If length is negative, return error
- */
- if (n <= 0)
- return (-1);
-
- /*
- * End of string ?
- */
- if (*s == 0 && CSlength == 1)
- return (0);
- if (*s == 0 && *(s + 1) == 0 && CSlength == 2)
- return (0);
-
- do {
- /*
- * Check for an end of the string
- */
- if (((*s == 0 && CSlength == 1)) ||
- ((*s == 0 && *(s + 1) == 0 && CSlength == 2))) {
- *pwc = 0;
- ++cnt;
- --n;
- break;
- }
- /*
- * Get a character
- */
- if ((unsigned char)*s == CS377) {
- ++s;
- /*
- * Change characterristics
- */
- if ((unsigned char)*s == CS377) {
- ++s;
- /*
- * two byte sequence
- */
- if (*s++ != 0)
- return (-1);
- CSselect = 0;
- CSlength = 2;
-
- }
- else {
- /*
- * Change CSselect
- */
- CSselect = (unsigned int)*s++;
- CSlength = 1;
- }
- }
-
- /*
- * Get a character and return
- */
- if (CSlength == 1) {
- twchar = CSselect;
- }
- else {
- twchar = *s++;
- }
- twchar = twchar << 8;
- twchar = twchar | *s++;
- *pwc = twchar & MASK;
- if (CSlength == 2)
- *pwc |= TOP1;
- ++pwc;
- ++cnt;
- --n;
- } while (n >= 0);
- return (cnt);
-}
-
-
-/*
- * wcstombs routines
- */
-size_t
-_wcstombs_xccs(s, pwc, n)
- char *s;
- wchar_t *pwc;
- int n;
-{
- int cnt = 0;
- unsigned char lower, upper;
- int in_2byte = 0;
- int in_1byte = 0;
- int current = 0;
-
- if (n <= 0)
- return (-1);
-
- if (*pwc == 0)
- return (0);
-
- do {
- lower = *pwc & 0x00ff;
- upper = (*pwc >> 8) & 0x00ff;
- /*
- * End of string ?
- */
- if (lower == 0) {
- *s++ = 0;
- ++cnt;
- --n;
- if (n == 0)
- break;
- *s++ = 0;
- ++cnt;
- break;
- }
- if (lower == CS377 || upper == CS377)
- return (-1);
- if (*pwc & TOP1) { /* length == 2 */
- if (in_2byte == 0) {
- /*
- * This was the marker.
- * Emitt 3 additional characters.
- */
- *s++ = CS377; ++cnt; --n;
- *s++ = CS377; ++cnt; --n;
- *s++ = 0; ++cnt; --n;
- in_2byte = 1;
- in_1byte = 0;
- }
- *s++ = upper; ++cnt; --n;
- if (n == 0)
- break;
- *s++ = lower; ++cnt; --n;
- if (n == 0)
- break;
- }
- else {
- if ((in_1byte == 0 && in_2byte == 1) ||
- (in_1byte == 1 && upper != current) ||
- (in_1byte == 0 && in_2byte == 0 && upper != 0)) {
- /*
- * This was the marker.
- * Emitt 2 additional characters.
- */
- *s++ = CS377; ++cnt; --n;
- if (n == 0)
- break;
- *s++ = upper; ++cnt; --n;
- if (n == 0)
- break;
- in_2byte = 0;
- in_1byte = 1;
- current = upper;
- }
- *s++ = lower; ++cnt; --n;
- if (n == 0)
- break;
- }
- ++pwc;
- } while (n >= 0);
- return (cnt);
-}