From 500f2902ed75b97ff68a524260b375430a2ab666 Mon Sep 17 00:00:00 2001 From: Huan <2981268462@qq.com> Date: Fri, 2 Jul 2021 01:54:23 +0100 Subject: [PATCH 1/2] Second commit --- hello.c | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 hello.c diff --git a/hello.c b/hello.c new file mode 100644 index 0000000..e69de29 From 73689987b9b0cebf97a7131c031326bbbe99660d Mon Sep 17 00:00:00 2001 From: Huan <2981268462@qq.com> Date: Fri, 2 Jul 2021 15:18:51 +0100 Subject: [PATCH 2/2] Second commit --- 1/.DS_Store | Bin 0 -> 6148 bytes 1/._.DS_Store | Bin 0 -> 4096 bytes 1/._2-系统调用扩充实验指南.pdf | Bin 0 -> 4096 bytes 1/._Makefile | Bin 0 -> 4096 bytes 1/._execve.c | Bin 0 -> 4096 bytes 1/._execve2.c | Bin 0 -> 4096 bytes 1/._newlibc | 0 1/2-系统调用扩充实验指南.pdf | Bin 0 -> 70044 bytes 1/Makefile | 12 + 1/execve.c | 21 + 1/execve2.c | 25 + 1/newlibc/._Makefile | 0 1/newlibc/._README | 0 1/newlibc/._README.wen | 0 1/newlibc/._ansi | 0 1/newlibc/._copying.dj | 0 1/newlibc/._crt | 0 1/newlibc/._dirent | 0 1/newlibc/._grp | 0 1/newlibc/._include | 0 1/newlibc/._malloc | 0 1/newlibc/._math | 0 1/newlibc/._misc | 0 1/newlibc/._mlinux | 0 1/newlibc/._other | 0 1/newlibc/._posix | 0 1/newlibc/._pwd | 0 1/newlibc/._soft | 0 1/newlibc/._stdio | 0 1/newlibc/._termcap | 0 1/newlibc/._unistd | 0 1/newlibc/Makefile | 62 ++ 1/newlibc/README | 73 ++ 1/newlibc/README.wen | 1 + 1/newlibc/ansi/._Makefile | 0 1/newlibc/ansi/._abort.c | 0 1/newlibc/ansi/._abs.c | 0 1/newlibc/ansi/._atof.c | 0 1/newlibc/ansi/._atoi.c | 0 1/newlibc/ansi/._bsearch.c | 0 1/newlibc/ansi/._ctime.c | 0 1/newlibc/ansi/._ctype.c | 0 1/newlibc/ansi/._div.c | 0 1/newlibc/ansi/._errno.c | 0 1/newlibc/ansi/._ftime.c | 0 1/newlibc/ansi/._getenv.c | 0 1/newlibc/ansi/._gettimeofday.c | 0 1/newlibc/ansi/._isatty.c | 0 1/newlibc/ansi/._qsort.c | 0 1/newlibc/ansi/._rand.c | 0 1/newlibc/ansi/._strerror.c | 0 1/newlibc/ansi/._strftime.c | 0 1/newlibc/ansi/._string.c | 0 1/newlibc/ansi/._strtol.c | 0 1/newlibc/ansi/._system.c | 0 1/newlibc/ansi/._tzset.c | 0 1/newlibc/ansi/Makefile | 46 + 1/newlibc/ansi/abort.c | 12 + 1/newlibc/ansi/abs.c | 15 + 1/newlibc/ansi/atof.c | 44 + 1/newlibc/ansi/atoi.c | 16 + 1/newlibc/ansi/bsearch.c | 56 ++ 1/newlibc/ansi/ctime.c | 142 +++ 1/newlibc/ansi/ctype.c | 29 + 1/newlibc/ansi/div.c | 24 + 1/newlibc/ansi/errno.c | 5 + 1/newlibc/ansi/ftime.c | 19 + 1/newlibc/ansi/getenv.c | 25 + 1/newlibc/ansi/gettimeofday.c | 17 + 1/newlibc/ansi/isatty.c | 15 + 1/newlibc/ansi/qsort.c | 239 +++++ 1/newlibc/ansi/rand.c | 19 + 1/newlibc/ansi/strerror.c | 60 ++ 1/newlibc/ansi/strftime.c | 312 ++++++ 1/newlibc/ansi/string.c | 13 + 1/newlibc/ansi/strtol.c | 91 ++ 1/newlibc/ansi/system.c | 30 + 1/newlibc/ansi/tzset.c | 47 + 1/newlibc/copying.dj | 46 + 1/newlibc/crt/._Makefile | 0 1/newlibc/crt/._crt0.s | 0 1/newlibc/crt/Makefile | 40 + 1/newlibc/crt/crt0.s | 55 ++ 1/newlibc/dirent/._Makefile | 0 1/newlibc/dirent/._closedir.c | 0 1/newlibc/dirent/._opendir.c | 0 1/newlibc/dirent/._readdir.c | 0 1/newlibc/dirent/._rewinddir.c | 0 1/newlibc/dirent/Makefile | 46 + 1/newlibc/dirent/closedir.c | 24 + 1/newlibc/dirent/opendir.c | 31 + 1/newlibc/dirent/readdir.c | 46 + 1/newlibc/dirent/rewinddir.c | 19 + 1/newlibc/grp/._Makefile | 0 1/newlibc/grp/._fgetgrent.c | 0 1/newlibc/grp/._getgrent.c | 0 1/newlibc/grp/._getgrgid.c | 0 1/newlibc/grp/._getgrnam.c | 0 1/newlibc/grp/._grpopen.c | 0 1/newlibc/grp/._grpread.c | 0 1/newlibc/grp/._initgroups.c | 0 1/newlibc/grp/Makefile | 44 + 1/newlibc/grp/fgetgrent.c | 41 + 1/newlibc/grp/getgrent.c | 67 ++ 1/newlibc/grp/getgrgid.c | 50 + 1/newlibc/grp/getgrnam.c | 50 + 1/newlibc/grp/grpopen.c | 28 + 1/newlibc/grp/grpread.c | 132 +++ 1/newlibc/grp/initgroups.c | 66 ++ 1/newlibc/include/._a.out.h | 0 1/newlibc/include/._ansidecl.h | 0 1/newlibc/include/._ar.h | 0 1/newlibc/include/._asm | 0 1/newlibc/include/._assert.h | 0 1/newlibc/include/._blocksize.h | 0 1/newlibc/include/._const.h | 0 1/newlibc/include/._ctype.h | 0 1/newlibc/include/._dirent.h | 0 1/newlibc/include/._errno.h | 0 1/newlibc/include/._fcntl.h | 0 1/newlibc/include/._float.h | 0 1/newlibc/include/._getopt.h | 0 1/newlibc/include/._gnu-stabs.h | 0 1/newlibc/include/._grp.h | 0 1/newlibc/include/._limits.h | 0 1/newlibc/include/._linux | 0 1/newlibc/include/._localeinfo.h | 0 1/newlibc/include/._math.h | 0 1/newlibc/include/._pwd.h | 0 1/newlibc/include/._regex.h | 0 1/newlibc/include/._setjmp.h | 0 1/newlibc/include/._signal.h | 0 1/newlibc/include/._stdarg.h | 0 1/newlibc/include/._stddef.h | 0 1/newlibc/include/._stdio.h | 0 1/newlibc/include/._stdlib.h | 0 1/newlibc/include/._string.h | 0 1/newlibc/include/._strings.h | 0 1/newlibc/include/._sys | 0 1/newlibc/include/._termcap.h | 0 1/newlibc/include/._termio.h | 0 1/newlibc/include/._termios.h | 0 1/newlibc/include/._time.h | 0 1/newlibc/include/._unistd.h | 0 1/newlibc/include/._utime.h | 0 1/newlibc/include/._varargs.h | 0 1/newlibc/include/a.out.h | 222 +++++ 1/newlibc/include/ansidecl.h | 108 +++ 1/newlibc/include/ar.h | 20 + 1/newlibc/include/asm/._io.h | 0 1/newlibc/include/asm/._memory.h | 0 1/newlibc/include/asm/._segment.h | 0 1/newlibc/include/asm/._system.h | 0 1/newlibc/include/asm/io.h | 24 + 1/newlibc/include/asm/memory.h | 14 + 1/newlibc/include/asm/segment.h | 65 ++ 1/newlibc/include/asm/system.h | 66 ++ 1/newlibc/include/assert.h | 34 + 1/newlibc/include/blocksize.h | 6 + 1/newlibc/include/const.h | 16 + 1/newlibc/include/ctype.h | 34 + 1/newlibc/include/dirent.h | 33 + 1/newlibc/include/errno.h | 60 ++ 1/newlibc/include/fcntl.h | 56 ++ 1/newlibc/include/float.h | 25 + 1/newlibc/include/getopt.h | 11 + 1/newlibc/include/gnu-stabs.h | 83 ++ 1/newlibc/include/grp.h | 101 ++ 1/newlibc/include/limits.h | 59 ++ 1/newlibc/include/linux/._config.h | 0 1/newlibc/include/linux/._fdreg.h | 0 1/newlibc/include/linux/._fs.h | 0 1/newlibc/include/linux/._hdreg.h | 0 1/newlibc/include/linux/._head.h | 0 1/newlibc/include/linux/._kernel.h | 0 1/newlibc/include/linux/._mm.h | 0 1/newlibc/include/linux/._sched.h | 0 1/newlibc/include/linux/._sys.h | 0 1/newlibc/include/linux/._tty.h | 0 1/newlibc/include/linux/config.h | 48 + 1/newlibc/include/linux/fdreg.h | 71 ++ 1/newlibc/include/linux/fs.h | 202 ++++ 1/newlibc/include/linux/hdreg.h | 65 ++ 1/newlibc/include/linux/head.h | 20 + 1/newlibc/include/linux/kernel.h | 22 + 1/newlibc/include/linux/mm.h | 10 + 1/newlibc/include/linux/sched.h | 233 +++++ 1/newlibc/include/linux/sys.h | 86 ++ 1/newlibc/include/linux/tty.h | 77 ++ 1/newlibc/include/localeinfo.h | 208 ++++ 1/newlibc/include/math.h | 31 + 1/newlibc/include/pwd.h | 89 ++ 1/newlibc/include/regex.h | 257 +++++ 1/newlibc/include/setjmp.h | 16 + 1/newlibc/include/signal.h | 69 ++ 1/newlibc/include/stdarg.h | 28 + 1/newlibc/include/stddef.h | 19 + 1/newlibc/include/stdio.h | 256 +++++ 1/newlibc/include/stdlib.h | 43 + 1/newlibc/include/string.h | 405 ++++++++ 1/newlibc/include/strings.h | 1 + 1/newlibc/include/sys/._dir.h | 0 1/newlibc/include/sys/._dirent.h | 0 1/newlibc/include/sys/._file.h | 0 1/newlibc/include/sys/._ioctl.h | 0 1/newlibc/include/sys/._param.h | 0 1/newlibc/include/sys/._stat.h | 0 1/newlibc/include/sys/._sysmacros.h | 0 1/newlibc/include/sys/._time.h | 0 1/newlibc/include/sys/._timeb.h | 0 1/newlibc/include/sys/._times.h | 0 1/newlibc/include/sys/._types.h | 0 1/newlibc/include/sys/._utsname.h | 0 1/newlibc/include/sys/._varargs.h | 0 1/newlibc/include/sys/._wait.h | 0 1/newlibc/include/sys/dir.h | 16 + 1/newlibc/include/sys/dirent.h | 13 + 1/newlibc/include/sys/file.h | 10 + 1/newlibc/include/sys/ioctl.h | 4 + 1/newlibc/include/sys/param.h | 6 + 1/newlibc/include/sys/stat.h | 58 ++ 1/newlibc/include/sys/sysmacros.h | 8 + 1/newlibc/include/sys/time.h | 55 ++ 1/newlibc/include/sys/timeb.h | 13 + 1/newlibc/include/sys/times.h | 15 + 1/newlibc/include/sys/types.h | 46 + 1/newlibc/include/sys/utsname.h | 16 + 1/newlibc/include/sys/varargs.h | 19 + 1/newlibc/include/sys/wait.h | 23 + 1/newlibc/include/termcap.h | 11 + 1/newlibc/include/termio.h | 1 + 1/newlibc/include/termios.h | 225 +++++ 1/newlibc/include/time.h | 49 + 1/newlibc/include/unistd.h | 269 +++++ 1/newlibc/include/utime.h | 13 + 1/newlibc/include/varargs.h | 19 + 1/newlibc/malloc/._Makefile | 0 1/newlibc/malloc/._README | 0 1/newlibc/malloc/._ansidecl.h | 0 1/newlibc/malloc/._free.c | 0 1/newlibc/malloc/._gmalloc.c | 0 1/newlibc/malloc/._gmalloc.c.old | 0 1/newlibc/malloc/._gmalloc.sed | 0 1/newlibc/malloc/._gmalloc.skel | 0 1/newlibc/malloc/._limits.h | 0 1/newlibc/malloc/._malloc.c.1 | 0 1/newlibc/malloc/._malloc.h | 0 1/newlibc/malloc/._mcheck.c | 0 1/newlibc/malloc/._mstats.c | 0 1/newlibc/malloc/._realloc.c | 0 1/newlibc/malloc/._stddef.h | 0 1/newlibc/malloc/._stdlib.h | 0 1/newlibc/malloc/._string.h | 0 1/newlibc/malloc/._unix.c | 0 1/newlibc/malloc/._valloc.c | 0 1/newlibc/malloc/Makefile | 18 + 1/newlibc/malloc/README | 4 + 1/newlibc/malloc/ansidecl.h | 93 ++ 1/newlibc/malloc/free.c | 192 ++++ 1/newlibc/malloc/gmalloc.c | 1130 ++++++++++++++++++++++ 1/newlibc/malloc/gmalloc.c.old | 1111 +++++++++++++++++++++ 1/newlibc/malloc/gmalloc.sed | 15 + 1/newlibc/malloc/gmalloc.skel | 54 ++ 1/newlibc/malloc/limits.h | 43 + 1/newlibc/malloc/malloc.c.1 | 308 ++++++ 1/newlibc/malloc/malloc.h | 156 +++ 1/newlibc/malloc/mcheck.c | 113 +++ 1/newlibc/malloc/mstats.c | 38 + 1/newlibc/malloc/realloc.c | 137 +++ 1/newlibc/malloc/stddef.h | 24 + 1/newlibc/malloc/stdlib.h | 10 + 1/newlibc/malloc/string.h | 0 1/newlibc/malloc/unix.c | 41 + 1/newlibc/malloc/valloc.c | 42 + 1/newlibc/math/._Makefile | 0 1/newlibc/math/._acos.s | 0 1/newlibc/math/._acosh.c | 0 1/newlibc/math/._asin.s | 0 1/newlibc/math/._asinh.c | 0 1/newlibc/math/._atan.s | 0 1/newlibc/math/._atan2.s | 0 1/newlibc/math/._atanh.c | 0 1/newlibc/math/._ceil.s | 0 1/newlibc/math/._cos.s | 0 1/newlibc/math/._cosh.c | 0 1/newlibc/math/._erf.c | 0 1/newlibc/math/._exp.s | 0 1/newlibc/math/._fabs.s | 0 1/newlibc/math/._floor.s | 0 1/newlibc/math/._fmod.s | 0 1/newlibc/math/._frexp.c | 0 1/newlibc/math/._hypot.c | 0 1/newlibc/math/._j0.c | 0 1/newlibc/math/._j1.c | 0 1/newlibc/math/._jn.c | 0 1/newlibc/math/._lgamma.c | 0 1/newlibc/math/._log.s | 0 1/newlibc/math/._log10.s | 0 1/newlibc/math/._sin.s | 0 1/newlibc/math/._sinh.c | 0 1/newlibc/math/._sqrt.s | 0 1/newlibc/math/._tan.s | 0 1/newlibc/math/._tanh.c | 0 1/newlibc/math/Makefile | 44 + 1/newlibc/math/acos.s | 35 + 1/newlibc/math/acosh.c | 6 + 1/newlibc/math/asin.s | 28 + 1/newlibc/math/asinh.c | 7 + 1/newlibc/math/atan.s | 21 + 1/newlibc/math/atan2.s | 0 1/newlibc/math/atanh.c | 6 + 1/newlibc/math/ceil.s | 37 + 1/newlibc/math/cos.s | 29 + 1/newlibc/math/cosh.c | 6 + 1/newlibc/math/erf.c | 124 +++ 1/newlibc/math/exp.s | 92 ++ 1/newlibc/math/fabs.s | 5 + 1/newlibc/math/floor.s | 37 + 1/newlibc/math/fmod.s | 43 + 1/newlibc/math/frexp.c | 17 + 1/newlibc/math/hypot.c | 6 + 1/newlibc/math/j0.c | 208 ++++ 1/newlibc/math/j1.c | 214 ++++ 1/newlibc/math/jn.c | 122 +++ 1/newlibc/math/lgamma.c | 143 +++ 1/newlibc/math/log.s | 20 + 1/newlibc/math/log10.s | 20 + 1/newlibc/math/sin.s | 29 + 1/newlibc/math/sinh.c | 7 + 1/newlibc/math/sqrt.s | 19 + 1/newlibc/math/tan.s | 30 + 1/newlibc/math/tanh.c | 7 + 1/newlibc/misc/._Makefile | 0 1/newlibc/misc/._README | 0 1/newlibc/misc/._atexit.c | 0 1/newlibc/misc/._bcopy.s | 0 1/newlibc/misc/._exit.c | 0 1/newlibc/misc/._frexp.c | 0 1/newlibc/misc/._ldexp.c | 0 1/newlibc/misc/._modf.c | 0 1/newlibc/misc/._perror.c | 0 1/newlibc/misc/._readv.c | 0 1/newlibc/misc/._tmpnam.c | 0 1/newlibc/misc/._values.s | 0 1/newlibc/misc/._writev.c | 0 1/newlibc/misc/Makefile | 52 + 1/newlibc/misc/README | 7 + 1/newlibc/misc/atexit.c | 55 ++ 1/newlibc/misc/bcopy.s | 105 ++ 1/newlibc/misc/exit.c | 32 + 1/newlibc/misc/frexp.c | 26 + 1/newlibc/misc/ldexp.c | 11 + 1/newlibc/misc/modf.c | 120 +++ 1/newlibc/misc/perror.c | 48 + 1/newlibc/misc/readv.c | 40 + 1/newlibc/misc/tmpnam.c | 105 ++ 1/newlibc/misc/values.s | 53 + 1/newlibc/misc/writev.c | 38 + 1/newlibc/mlinux/._Makefile | 0 1/newlibc/mlinux/._README | 0 1/newlibc/mlinux/._acos.s | 0 1/newlibc/mlinux/._acosh.s | 0 1/newlibc/mlinux/._asin.s | 0 1/newlibc/mlinux/._asinh.s | 0 1/newlibc/mlinux/._atan.s | 0 1/newlibc/mlinux/._atan2.s | 0 1/newlibc/mlinux/._atanh.s | 0 1/newlibc/mlinux/._ceil.s | 0 1/newlibc/mlinux/._cos.s | 0 1/newlibc/mlinux/._cosh.s | 0 1/newlibc/mlinux/._erf.c | 0 1/newlibc/mlinux/._exp.s | 0 1/newlibc/mlinux/._fabs.s | 0 1/newlibc/mlinux/._floor.s | 0 1/newlibc/mlinux/._fmod.s | 0 1/newlibc/mlinux/._frexp.c | 0 1/newlibc/mlinux/._hypot.s | 0 1/newlibc/mlinux/._j0.c | 0 1/newlibc/mlinux/._j1.c | 0 1/newlibc/mlinux/._jn.c | 0 1/newlibc/mlinux/._lgamma.c | 0 1/newlibc/mlinux/._log.s | 0 1/newlibc/mlinux/._log10.s | 0 1/newlibc/mlinux/._math.h | 0 1/newlibc/mlinux/._sin.s | 0 1/newlibc/mlinux/._sinh.s | 0 1/newlibc/mlinux/._sqrt.s | 0 1/newlibc/mlinux/._tan.s | 0 1/newlibc/mlinux/._tanh.s | 0 1/newlibc/mlinux/Makefile | 36 + 1/newlibc/mlinux/README | 8 + 1/newlibc/mlinux/acos.s | 33 + 1/newlibc/mlinux/acosh.s | 30 + 1/newlibc/mlinux/asin.s | 29 + 1/newlibc/mlinux/asinh.s | 27 + 1/newlibc/mlinux/atan.s | 21 + 1/newlibc/mlinux/atan2.s | 22 + 1/newlibc/mlinux/atanh.s | 35 + 1/newlibc/mlinux/ceil.s | 38 + 1/newlibc/mlinux/cos.s | 32 + 1/newlibc/mlinux/cosh.s | 50 + 1/newlibc/mlinux/erf.c | 124 +++ 1/newlibc/mlinux/exp.s | 92 ++ 1/newlibc/mlinux/fabs.s | 14 + 1/newlibc/mlinux/floor.s | 38 + 1/newlibc/mlinux/fmod.s | 36 + 1/newlibc/mlinux/frexp.c | 17 + 1/newlibc/mlinux/hypot.s | 23 + 1/newlibc/mlinux/j0.c | 208 ++++ 1/newlibc/mlinux/j1.c | 214 ++++ 1/newlibc/mlinux/jn.c | 122 +++ 1/newlibc/mlinux/lgamma.c | 143 +++ 1/newlibc/mlinux/log.s | 20 + 1/newlibc/mlinux/log10.s | 20 + 1/newlibc/mlinux/math.h | 47 + 1/newlibc/mlinux/sin.s | 32 + 1/newlibc/mlinux/sinh.s | 50 + 1/newlibc/mlinux/sqrt.s | 19 + 1/newlibc/mlinux/tan.s | 31 + 1/newlibc/mlinux/tanh.s | 63 ++ 1/newlibc/other/._Makefile | 0 1/newlibc/other/._getcwd.c | 0 1/newlibc/other/._getopt.c | 0 1/newlibc/other/._mktemp.c | 0 1/newlibc/other/._popen.c | 0 1/newlibc/other/._setjmp.s | 0 1/newlibc/other/._sig_restore.s | 0 1/newlibc/other/Makefile | 47 + 1/newlibc/other/getcwd.c | 163 ++++ 1/newlibc/other/getopt.c | 431 +++++++++ 1/newlibc/other/mktemp.c | 16 + 1/newlibc/other/popen.c | 58 ++ 1/newlibc/other/setjmp.s | 45 + 1/newlibc/other/sig_restore.s | 20 + 1/newlibc/posix/._Makefile | 0 1/newlibc/posix/._cfsetget.c | 0 1/newlibc/posix/._rename.c | 0 1/newlibc/posix/._sigmask.c | 0 1/newlibc/posix/._sleep.c | 0 1/newlibc/posix/._sysconf.c | 0 1/newlibc/posix/._tcattr.c | 0 1/newlibc/posix/._tcflow.c | 0 1/newlibc/posix/._tcsetpgrp.c | 0 1/newlibc/posix/._ttyname.c | 0 1/newlibc/posix/Makefile | 55 ++ 1/newlibc/posix/cfsetget.c | 26 + 1/newlibc/posix/rename.c | 4 + 1/newlibc/posix/sigmask.c | 76 ++ 1/newlibc/posix/sleep.c | 66 ++ 1/newlibc/posix/sysconf.c | 37 + 1/newlibc/posix/tcattr.c | 34 + 1/newlibc/posix/tcflow.c | 7 + 1/newlibc/posix/tcsetpgrp.c | 19 + 1/newlibc/posix/ttyname.c | 79 ++ 1/newlibc/pwd/._Makefile | 0 1/newlibc/pwd/._fgetpwent.c | 0 1/newlibc/pwd/._getpw.c | 0 1/newlibc/pwd/._getpwent.c | 0 1/newlibc/pwd/._getpwnam.c | 0 1/newlibc/pwd/._getpwuid.c | 0 1/newlibc/pwd/._putpwent.c | 0 1/newlibc/pwd/._pwdopen.c | 0 1/newlibc/pwd/._pwdread.c | 0 1/newlibc/pwd/Makefile | 46 + 1/newlibc/pwd/fgetpwent.c | 40 + 1/newlibc/pwd/getpw.c | 48 + 1/newlibc/pwd/getpwent.c | 67 ++ 1/newlibc/pwd/getpwnam.c | 50 + 1/newlibc/pwd/getpwuid.c | 50 + 1/newlibc/pwd/putpwent.c | 41 + 1/newlibc/pwd/pwdopen.c | 28 + 1/newlibc/pwd/pwdread.c | 115 +++ 1/newlibc/soft/._Makefile | 0 1/newlibc/soft/._README | 0 1/newlibc/soft/._asin.c | 0 1/newlibc/soft/._atan.c | 0 1/newlibc/soft/._const.c | 0 1/newlibc/soft/._erf.c | 0 1/newlibc/soft/._exp.c | 0 1/newlibc/soft/._fabs.c | 0 1/newlibc/soft/._floor.c | 0 1/newlibc/soft/._frexp.c | 0 1/newlibc/soft/._hypot.c | 0 1/newlibc/soft/._j0.c | 0 1/newlibc/soft/._j1.c | 0 1/newlibc/soft/._jn.c | 0 1/newlibc/soft/._ldexp.c | 0 1/newlibc/soft/._lgamma.c | 0 1/newlibc/soft/._log.c | 0 1/newlibc/soft/._main.c | 0 1/newlibc/soft/._modf.c | 0 1/newlibc/soft/._pow.c | 0 1/newlibc/soft/._sin.c | 0 1/newlibc/soft/._sinh.c | 0 1/newlibc/soft/._soft.h | 0 1/newlibc/soft/._soft.h.old | 0 1/newlibc/soft/._sqrt.c | 0 1/newlibc/soft/._tan.c | 0 1/newlibc/soft/._tanh.c | 0 1/newlibc/soft/Makefile | 41 + 1/newlibc/soft/README | 20 + 1/newlibc/soft/asin.c | 44 + 1/newlibc/soft/atan.c | 97 ++ 1/newlibc/soft/const.c | 41 + 1/newlibc/soft/erf.c | 124 +++ 1/newlibc/soft/exp.c | 40 + 1/newlibc/soft/fabs.c | 8 + 1/newlibc/soft/floor.c | 26 + 1/newlibc/soft/frexp.c | 17 + 1/newlibc/soft/hypot.c | 25 + 1/newlibc/soft/j0.c | 183 ++++ 1/newlibc/soft/j1.c | 188 ++++ 1/newlibc/soft/jn.c | 101 ++ 1/newlibc/soft/ldexp.c | 0 1/newlibc/soft/lgamma.c | 146 +++ 1/newlibc/soft/log.c | 53 + 1/newlibc/soft/main.c | 16 + 1/newlibc/soft/modf.c | 54 ++ 1/newlibc/soft/pow.c | 33 + 1/newlibc/soft/sin.c | 67 ++ 1/newlibc/soft/sinh.c | 65 ++ 1/newlibc/soft/soft.h | 46 + 1/newlibc/soft/soft.h.old | 62 ++ 1/newlibc/soft/sqrt.c | 51 + 1/newlibc/soft/tan.c | 67 ++ 1/newlibc/soft/tanh.c | 25 + 1/newlibc/stdio/._Makefile | 0 1/newlibc/stdio/._clrerr.c | 0 1/newlibc/stdio/._doprnt.c | 0 1/newlibc/stdio/._doscan.c | 0 1/newlibc/stdio/._fdopen.c | 0 1/newlibc/stdio/._fgetc.c | 0 1/newlibc/stdio/._fgets.c | 0 1/newlibc/stdio/._filbuf.c | 0 1/newlibc/stdio/._findiop.c | 0 1/newlibc/stdio/._flsbuf.c | 0 1/newlibc/stdio/._fopen.c | 0 1/newlibc/stdio/._fprintf.c | 0 1/newlibc/stdio/._fputc.c | 0 1/newlibc/stdio/._fputs.c | 0 1/newlibc/stdio/._fread.c | 0 1/newlibc/stdio/._freopen.c | 0 1/newlibc/stdio/._fseek.c | 0 1/newlibc/stdio/._ftell.c | 0 1/newlibc/stdio/._fwrite.c | 0 1/newlibc/stdio/._getchar.c | 0 1/newlibc/stdio/._gets.c | 0 1/newlibc/stdio/._getw.c | 0 1/newlibc/stdio/._printf.c | 0 1/newlibc/stdio/._putchar.c | 0 1/newlibc/stdio/._puts.c | 0 1/newlibc/stdio/._putw.c | 0 1/newlibc/stdio/._rew.c | 0 1/newlibc/stdio/._scanf.c | 0 1/newlibc/stdio/._setbuf.c | 0 1/newlibc/stdio/._setbuffe.c | 0 1/newlibc/stdio/._setvbuf.c | 0 1/newlibc/stdio/._sprintf.c | 0 1/newlibc/stdio/._ungetc.c | 0 1/newlibc/stdio/._vfprintf.c | 0 1/newlibc/stdio/._vprintf.c | 0 1/newlibc/stdio/._vsprintf.c | 0 1/newlibc/stdio/Makefile | 51 + 1/newlibc/stdio/clrerr.c | 19 + 1/newlibc/stdio/doprnt.c | 717 ++++++++++++++ 1/newlibc/stdio/doscan.c | 301 ++++++ 1/newlibc/stdio/fdopen.c | 93 ++ 1/newlibc/stdio/fgetc.c | 18 + 1/newlibc/stdio/fgets.c | 29 + 1/newlibc/stdio/filbuf.c | 87 ++ 1/newlibc/stdio/findiop.c | 148 +++ 1/newlibc/stdio/flsbuf.c | 170 ++++ 1/newlibc/stdio/fopen.c | 92 ++ 1/newlibc/stdio/fprintf.c | 59 ++ 1/newlibc/stdio/fputc.c | 17 + 1/newlibc/stdio/fputs.c | 50 + 1/newlibc/stdio/fread.c | 56 ++ 1/newlibc/stdio/freopen.c | 89 ++ 1/newlibc/stdio/fseek.c | 70 ++ 1/newlibc/stdio/ftell.c | 62 ++ 1/newlibc/stdio/fwrite.c | 60 ++ 1/newlibc/stdio/getchar.c | 22 + 1/newlibc/stdio/gets.c | 27 + 1/newlibc/stdio/getw.c | 27 + 1/newlibc/stdio/printf.c | 43 + 1/newlibc/stdio/putchar.c | 23 + 1/newlibc/stdio/puts.c | 22 + 1/newlibc/stdio/putw.c | 23 + 1/newlibc/stdio/rew.c | 47 + 1/newlibc/stdio/scanf.c | 56 ++ 1/newlibc/stdio/setbuf.c | 42 + 1/newlibc/stdio/setbuffe.c | 62 ++ 1/newlibc/stdio/setvbuf.c | 54 ++ 1/newlibc/stdio/sprintf.c | 48 + 1/newlibc/stdio/ungetc.c | 0 1/newlibc/stdio/vfprintf.c | 55 ++ 1/newlibc/stdio/vprintf.c | 43 + 1/newlibc/stdio/vsprintf.c | 48 + 1/newlibc/termcap/._COPYING | 0 1/newlibc/termcap/._COPYING.LIB | 0 1/newlibc/termcap/._ChangeLog | 0 1/newlibc/termcap/._Makefile.in | 0 1/newlibc/termcap/._README | 0 1/newlibc/termcap/._bsearch.c | 0 1/newlibc/termcap/._configure | 0 1/newlibc/termcap/._conversions.c | 0 1/newlibc/termcap/._getopt.c | 0 1/newlibc/termcap/._getopt.h | 0 1/newlibc/termcap/._getopt1.c | 0 1/newlibc/termcap/._makefile | 0 1/newlibc/termcap/._termcap.c | 0 1/newlibc/termcap/._termcap.h | 0 1/newlibc/termcap/._tparam.c | 0 1/newlibc/termcap/._tput.c | 0 1/newlibc/termcap/._tput.h | 0 1/newlibc/termcap/._tput.texinfo | 0 1/newlibc/termcap/COPYING | 339 +++++++ 1/newlibc/termcap/COPYING.LIB | 481 +++++++++ 1/newlibc/termcap/ChangeLog | 26 + 1/newlibc/termcap/Makefile.in | 80 ++ 1/newlibc/termcap/README | 42 + 1/newlibc/termcap/bsearch.c | 61 ++ 1/newlibc/termcap/configure | 129 +++ 1/newlibc/termcap/conversions.c | 337 +++++++ 1/newlibc/termcap/getopt.c | 596 ++++++++++++ 1/newlibc/termcap/getopt.h | 102 ++ 1/newlibc/termcap/getopt1.c | 160 +++ 1/newlibc/termcap/makefile | 45 + 1/newlibc/termcap/termcap.c | 681 +++++++++++++ 1/newlibc/termcap/termcap.h | 42 + 1/newlibc/termcap/tparam.c | 283 ++++++ 1/newlibc/termcap/tput.c | 341 +++++++ 1/newlibc/termcap/tput.h | 35 + 1/newlibc/termcap/tput.texinfo | 651 +++++++++++++ 1/newlibc/unistd/._Makefile | 0 1/newlibc/unistd/.__exit.c | 0 1/newlibc/unistd/._access.c | 0 1/newlibc/unistd/._acct.c | 0 1/newlibc/unistd/._alarm.c | 0 1/newlibc/unistd/._brk.c | 0 1/newlibc/unistd/._chdir.c | 0 1/newlibc/unistd/._chmod.c | 0 1/newlibc/unistd/._chown.c | 0 1/newlibc/unistd/._chroot.c | 0 1/newlibc/unistd/._close.c | 0 1/newlibc/unistd/._creat.c | 0 1/newlibc/unistd/._dup.c | 0 1/newlibc/unistd/._dup2.c | 0 1/newlibc/unistd/._exec.c | 0 1/newlibc/unistd/._execp.c | 0 1/newlibc/unistd/._execve.c | 0 1/newlibc/unistd/._fcntl.c | 0 1/newlibc/unistd/._fork.c | 0 1/newlibc/unistd/._fstat.c | 0 1/newlibc/unistd/._getegid.c | 0 1/newlibc/unistd/._geteuid.c | 0 1/newlibc/unistd/._getgid.c | 0 1/newlibc/unistd/._getgroups.c | 0 1/newlibc/unistd/._gethostnam.c | 0 1/newlibc/unistd/._getpgrp.c | 0 1/newlibc/unistd/._getpid.c | 0 1/newlibc/unistd/._getppid.c | 0 1/newlibc/unistd/._getrlimit.c | 0 1/newlibc/unistd/._getrusage.c | 0 1/newlibc/unistd/._gettime.c | 0 1/newlibc/unistd/._getuid.c | 0 1/newlibc/unistd/._ioctl.c | 0 1/newlibc/unistd/._kill.c | 0 1/newlibc/unistd/._link.c | 0 1/newlibc/unistd/._lseek.c | 0 1/newlibc/unistd/._lstat.c | 0 1/newlibc/unistd/._mkdir.c | 0 1/newlibc/unistd/._mknod.c | 0 1/newlibc/unistd/._mount.c | 0 1/newlibc/unistd/._nice.c | 0 1/newlibc/unistd/._open.c | 0 1/newlibc/unistd/._pause.c | 0 1/newlibc/unistd/._pipe.c | 0 1/newlibc/unistd/._read.c | 0 1/newlibc/unistd/._readlink.c | 0 1/newlibc/unistd/._rmdir.c | 0 1/newlibc/unistd/._select.c | 0 1/newlibc/unistd/._setgid.c | 0 1/newlibc/unistd/._setgroups.c | 0 1/newlibc/unistd/._sethostnam.c | 0 1/newlibc/unistd/._setpgrp.c | 0 1/newlibc/unistd/._setregid.c | 0 1/newlibc/unistd/._setreuid.c | 0 1/newlibc/unistd/._setrlimit.c | 0 1/newlibc/unistd/._setsid.c | 0 1/newlibc/unistd/._settime.c | 0 1/newlibc/unistd/._setuid.c | 0 1/newlibc/unistd/._signal.c | 0 1/newlibc/unistd/._sigpend.c | 0 1/newlibc/unistd/._sigsusp.c | 0 1/newlibc/unistd/._stat.c | 0 1/newlibc/unistd/._stime.c | 0 1/newlibc/unistd/._symlink.c | 0 1/newlibc/unistd/._sync.c | 0 1/newlibc/unistd/._time.c | 0 1/newlibc/unistd/._times.c | 0 1/newlibc/unistd/._ulimit.c | 0 1/newlibc/unistd/._umask.c | 0 1/newlibc/unistd/._umount.c | 0 1/newlibc/unistd/._uname.c | 0 1/newlibc/unistd/._unlink.c | 0 1/newlibc/unistd/._uselib.c | 0 1/newlibc/unistd/._ustat.c | 0 1/newlibc/unistd/._utime.c | 0 1/newlibc/unistd/._wait.c | 0 1/newlibc/unistd/._write.c | 0 1/newlibc/unistd/Makefile | 53 + 1/newlibc/unistd/_exit.c | 12 + 1/newlibc/unistd/access.c | 4 + 1/newlibc/unistd/acct.c | 4 + 1/newlibc/unistd/alarm.c | 0 1/newlibc/unistd/brk.c | 48 + 1/newlibc/unistd/chdir.c | 4 + 1/newlibc/unistd/chmod.c | 4 + 1/newlibc/unistd/chown.c | 0 1/newlibc/unistd/chroot.c | 4 + 1/newlibc/unistd/close.c | 0 1/newlibc/unistd/creat.c | 4 + 1/newlibc/unistd/dup.c | 0 1/newlibc/unistd/dup2.c | 4 + 1/newlibc/unistd/exec.c | 30 + 1/newlibc/unistd/execp.c | 60 ++ 1/newlibc/unistd/execve.c | 4 + 1/newlibc/unistd/fcntl.c | 27 + 1/newlibc/unistd/fork.c | 4 + 1/newlibc/unistd/fstat.c | 4 + 1/newlibc/unistd/getegid.c | 4 + 1/newlibc/unistd/geteuid.c | 0 1/newlibc/unistd/getgid.c | 4 + 1/newlibc/unistd/getgroups.c | 4 + 1/newlibc/unistd/gethostnam.c | 16 + 1/newlibc/unistd/getpgrp.c | 4 + 1/newlibc/unistd/getpid.c | 4 + 1/newlibc/unistd/getppid.c | 4 + 1/newlibc/unistd/getrlimit.c | 4 + 1/newlibc/unistd/getrusage.c | 5 + 1/newlibc/unistd/gettime.c | 5 + 1/newlibc/unistd/getuid.c | 4 + 1/newlibc/unistd/ioctl.c | 27 + 1/newlibc/unistd/kill.c | 4 + 1/newlibc/unistd/link.c | 4 + 1/newlibc/unistd/lseek.c | 4 + 1/newlibc/unistd/lstat.c | 4 + 1/newlibc/unistd/mkdir.c | 4 + 1/newlibc/unistd/mknod.c | 4 + 1/newlibc/unistd/mount.c | 4 + 1/newlibc/unistd/nice.c | 4 + 1/newlibc/unistd/open.c | 0 1/newlibc/unistd/pause.c | 4 + 1/newlibc/unistd/pipe.c | 4 + 1/newlibc/unistd/read.c | 4 + 1/newlibc/unistd/readlink.c | 4 + 1/newlibc/unistd/rmdir.c | 4 + 1/newlibc/unistd/select.c | 24 + 1/newlibc/unistd/setgid.c | 4 + 1/newlibc/unistd/setgroups.c | 4 + 1/newlibc/unistd/sethostnam.c | 5 + 1/newlibc/unistd/setpgrp.c | 0 1/newlibc/unistd/setregid.c | 0 1/newlibc/unistd/setreuid.c | 4 + 1/newlibc/unistd/setrlimit.c | 4 + 1/newlibc/unistd/setsid.c | 4 + 1/newlibc/unistd/settime.c | 4 + 1/newlibc/unistd/setuid.c | 4 + 1/newlibc/unistd/signal.c | 64 ++ 1/newlibc/unistd/sigpend.c | 5 + 1/newlibc/unistd/sigsusp.c | 24 + 1/newlibc/unistd/stat.c | 0 1/newlibc/unistd/stime.c | 0 1/newlibc/unistd/symlink.c | 4 + 1/newlibc/unistd/sync.c | 4 + 1/newlibc/unistd/time.c | 4 + 1/newlibc/unistd/times.c | 4 + 1/newlibc/unistd/ulimit.c | 4 + 1/newlibc/unistd/umask.c | 4 + 1/newlibc/unistd/umount.c | 4 + 1/newlibc/unistd/uname.c | 4 + 1/newlibc/unistd/unlink.c | 4 + 1/newlibc/unistd/uselib.c | 4 + 1/newlibc/unistd/ustat.c | 0 1/newlibc/unistd/utime.c | 4 + 1/newlibc/unistd/wait.c | 10 + 1/newlibc/unistd/write.c | 4 + 1/rundev/._0.11-dev.bxrc | Bin 0 -> 4096 bytes 1/rundev/._readme.txt | Bin 0 -> 4096 bytes 1/rundev/._rundev | Bin 0 -> 4096 bytes 1/rundev/0.11-dev.bxrc | 31 + 1/rundev/readme.txt | 5 + 1/rundev/rundev | 3 + 794 files changed, 24917 insertions(+) create mode 100755 1/.DS_Store create mode 100755 1/._.DS_Store create mode 100755 1/._2-系统调用扩充实验指南.pdf create mode 100755 1/._Makefile create mode 100755 1/._execve.c create mode 100755 1/._execve2.c create mode 100755 1/._newlibc create mode 100755 1/2-系统调用扩充实验指南.pdf create mode 100755 1/Makefile create mode 100755 1/execve.c create mode 100755 1/execve2.c create mode 100755 1/newlibc/._Makefile create mode 100755 1/newlibc/._README create mode 100755 1/newlibc/._README.wen create mode 100755 1/newlibc/._ansi create mode 100755 1/newlibc/._copying.dj create mode 100755 1/newlibc/._crt create mode 100755 1/newlibc/._dirent create mode 100755 1/newlibc/._grp create mode 100755 1/newlibc/._include create mode 100755 1/newlibc/._malloc create mode 100755 1/newlibc/._math create mode 100755 1/newlibc/._misc create mode 100755 1/newlibc/._mlinux create mode 100755 1/newlibc/._other create mode 100755 1/newlibc/._posix create mode 100755 1/newlibc/._pwd create mode 100755 1/newlibc/._soft create mode 100755 1/newlibc/._stdio create mode 100755 1/newlibc/._termcap create mode 100755 1/newlibc/._unistd create mode 100755 1/newlibc/Makefile create mode 100755 1/newlibc/README create mode 100755 1/newlibc/README.wen create mode 100755 1/newlibc/ansi/._Makefile create mode 100755 1/newlibc/ansi/._abort.c create mode 100755 1/newlibc/ansi/._abs.c create mode 100755 1/newlibc/ansi/._atof.c create mode 100755 1/newlibc/ansi/._atoi.c create mode 100755 1/newlibc/ansi/._bsearch.c create mode 100755 1/newlibc/ansi/._ctime.c create mode 100755 1/newlibc/ansi/._ctype.c create mode 100755 1/newlibc/ansi/._div.c create mode 100755 1/newlibc/ansi/._errno.c create mode 100755 1/newlibc/ansi/._ftime.c create mode 100755 1/newlibc/ansi/._getenv.c create mode 100755 1/newlibc/ansi/._gettimeofday.c create mode 100755 1/newlibc/ansi/._isatty.c create mode 100755 1/newlibc/ansi/._qsort.c create mode 100755 1/newlibc/ansi/._rand.c create mode 100755 1/newlibc/ansi/._strerror.c create mode 100755 1/newlibc/ansi/._strftime.c create mode 100755 1/newlibc/ansi/._string.c create mode 100755 1/newlibc/ansi/._strtol.c create mode 100755 1/newlibc/ansi/._system.c create mode 100755 1/newlibc/ansi/._tzset.c create mode 100755 1/newlibc/ansi/Makefile create mode 100755 1/newlibc/ansi/abort.c create mode 100755 1/newlibc/ansi/abs.c create mode 100755 1/newlibc/ansi/atof.c create mode 100755 1/newlibc/ansi/atoi.c create mode 100755 1/newlibc/ansi/bsearch.c create mode 100755 1/newlibc/ansi/ctime.c create mode 100755 1/newlibc/ansi/ctype.c create mode 100755 1/newlibc/ansi/div.c create mode 100755 1/newlibc/ansi/errno.c create mode 100755 1/newlibc/ansi/ftime.c create mode 100755 1/newlibc/ansi/getenv.c create mode 100755 1/newlibc/ansi/gettimeofday.c create mode 100755 1/newlibc/ansi/isatty.c create mode 100755 1/newlibc/ansi/qsort.c create mode 100755 1/newlibc/ansi/rand.c create mode 100755 1/newlibc/ansi/strerror.c create mode 100755 1/newlibc/ansi/strftime.c create mode 100755 1/newlibc/ansi/string.c create mode 100755 1/newlibc/ansi/strtol.c create mode 100755 1/newlibc/ansi/system.c create mode 100755 1/newlibc/ansi/tzset.c create mode 100755 1/newlibc/copying.dj create mode 100755 1/newlibc/crt/._Makefile create mode 100755 1/newlibc/crt/._crt0.s create mode 100755 1/newlibc/crt/Makefile create mode 100755 1/newlibc/crt/crt0.s create mode 100755 1/newlibc/dirent/._Makefile create mode 100755 1/newlibc/dirent/._closedir.c create mode 100755 1/newlibc/dirent/._opendir.c create mode 100755 1/newlibc/dirent/._readdir.c create mode 100755 1/newlibc/dirent/._rewinddir.c create mode 100755 1/newlibc/dirent/Makefile create mode 100755 1/newlibc/dirent/closedir.c create mode 100755 1/newlibc/dirent/opendir.c create mode 100755 1/newlibc/dirent/readdir.c create mode 100755 1/newlibc/dirent/rewinddir.c create mode 100755 1/newlibc/grp/._Makefile create mode 100755 1/newlibc/grp/._fgetgrent.c create mode 100755 1/newlibc/grp/._getgrent.c create mode 100755 1/newlibc/grp/._getgrgid.c create mode 100755 1/newlibc/grp/._getgrnam.c create mode 100755 1/newlibc/grp/._grpopen.c create mode 100755 1/newlibc/grp/._grpread.c create mode 100755 1/newlibc/grp/._initgroups.c create mode 100755 1/newlibc/grp/Makefile create mode 100755 1/newlibc/grp/fgetgrent.c create mode 100755 1/newlibc/grp/getgrent.c create mode 100755 1/newlibc/grp/getgrgid.c create mode 100755 1/newlibc/grp/getgrnam.c create mode 100755 1/newlibc/grp/grpopen.c create mode 100755 1/newlibc/grp/grpread.c create mode 100755 1/newlibc/grp/initgroups.c create mode 100755 1/newlibc/include/._a.out.h create mode 100755 1/newlibc/include/._ansidecl.h create mode 100755 1/newlibc/include/._ar.h create mode 100755 1/newlibc/include/._asm create mode 100755 1/newlibc/include/._assert.h create mode 100755 1/newlibc/include/._blocksize.h create mode 100755 1/newlibc/include/._const.h create mode 100755 1/newlibc/include/._ctype.h create mode 100755 1/newlibc/include/._dirent.h create mode 100755 1/newlibc/include/._errno.h create mode 100755 1/newlibc/include/._fcntl.h create mode 100755 1/newlibc/include/._float.h create mode 100755 1/newlibc/include/._getopt.h create mode 100755 1/newlibc/include/._gnu-stabs.h create mode 100755 1/newlibc/include/._grp.h create mode 100755 1/newlibc/include/._limits.h create mode 100755 1/newlibc/include/._linux create mode 100755 1/newlibc/include/._localeinfo.h create mode 100755 1/newlibc/include/._math.h create mode 100755 1/newlibc/include/._pwd.h create mode 100755 1/newlibc/include/._regex.h create mode 100755 1/newlibc/include/._setjmp.h create mode 100755 1/newlibc/include/._signal.h create mode 100755 1/newlibc/include/._stdarg.h create mode 100755 1/newlibc/include/._stddef.h create mode 100755 1/newlibc/include/._stdio.h create mode 100755 1/newlibc/include/._stdlib.h create mode 100755 1/newlibc/include/._string.h create mode 100755 1/newlibc/include/._strings.h create mode 100755 1/newlibc/include/._sys create mode 100755 1/newlibc/include/._termcap.h create mode 100755 1/newlibc/include/._termio.h create mode 100755 1/newlibc/include/._termios.h create mode 100755 1/newlibc/include/._time.h create mode 100755 1/newlibc/include/._unistd.h create mode 100755 1/newlibc/include/._utime.h create mode 100755 1/newlibc/include/._varargs.h create mode 100755 1/newlibc/include/a.out.h create mode 100755 1/newlibc/include/ansidecl.h create mode 100755 1/newlibc/include/ar.h create mode 100755 1/newlibc/include/asm/._io.h create mode 100755 1/newlibc/include/asm/._memory.h create mode 100755 1/newlibc/include/asm/._segment.h create mode 100755 1/newlibc/include/asm/._system.h create mode 100755 1/newlibc/include/asm/io.h create mode 100755 1/newlibc/include/asm/memory.h create mode 100755 1/newlibc/include/asm/segment.h create mode 100755 1/newlibc/include/asm/system.h create mode 100755 1/newlibc/include/assert.h create mode 100755 1/newlibc/include/blocksize.h create mode 100755 1/newlibc/include/const.h create mode 100755 1/newlibc/include/ctype.h create mode 100755 1/newlibc/include/dirent.h create mode 100755 1/newlibc/include/errno.h create mode 100755 1/newlibc/include/fcntl.h create mode 100755 1/newlibc/include/float.h create mode 100755 1/newlibc/include/getopt.h create mode 100755 1/newlibc/include/gnu-stabs.h create mode 100755 1/newlibc/include/grp.h create mode 100755 1/newlibc/include/limits.h create mode 100755 1/newlibc/include/linux/._config.h create mode 100755 1/newlibc/include/linux/._fdreg.h create mode 100755 1/newlibc/include/linux/._fs.h create mode 100755 1/newlibc/include/linux/._hdreg.h create mode 100755 1/newlibc/include/linux/._head.h create mode 100755 1/newlibc/include/linux/._kernel.h create mode 100755 1/newlibc/include/linux/._mm.h create mode 100755 1/newlibc/include/linux/._sched.h create mode 100755 1/newlibc/include/linux/._sys.h create mode 100755 1/newlibc/include/linux/._tty.h create mode 100755 1/newlibc/include/linux/config.h create mode 100755 1/newlibc/include/linux/fdreg.h create mode 100755 1/newlibc/include/linux/fs.h create mode 100755 1/newlibc/include/linux/hdreg.h create mode 100755 1/newlibc/include/linux/head.h create mode 100755 1/newlibc/include/linux/kernel.h create mode 100755 1/newlibc/include/linux/mm.h create mode 100755 1/newlibc/include/linux/sched.h create mode 100755 1/newlibc/include/linux/sys.h create mode 100755 1/newlibc/include/linux/tty.h create mode 100755 1/newlibc/include/localeinfo.h create mode 100755 1/newlibc/include/math.h create mode 100755 1/newlibc/include/pwd.h create mode 100755 1/newlibc/include/regex.h create mode 100755 1/newlibc/include/setjmp.h create mode 100755 1/newlibc/include/signal.h create mode 100755 1/newlibc/include/stdarg.h create mode 100755 1/newlibc/include/stddef.h create mode 100755 1/newlibc/include/stdio.h create mode 100755 1/newlibc/include/stdlib.h create mode 100755 1/newlibc/include/string.h create mode 100755 1/newlibc/include/strings.h create mode 100755 1/newlibc/include/sys/._dir.h create mode 100755 1/newlibc/include/sys/._dirent.h create mode 100755 1/newlibc/include/sys/._file.h create mode 100755 1/newlibc/include/sys/._ioctl.h create mode 100755 1/newlibc/include/sys/._param.h create mode 100755 1/newlibc/include/sys/._stat.h create mode 100755 1/newlibc/include/sys/._sysmacros.h create mode 100755 1/newlibc/include/sys/._time.h create mode 100755 1/newlibc/include/sys/._timeb.h create mode 100755 1/newlibc/include/sys/._times.h create mode 100755 1/newlibc/include/sys/._types.h create mode 100755 1/newlibc/include/sys/._utsname.h create mode 100755 1/newlibc/include/sys/._varargs.h create mode 100755 1/newlibc/include/sys/._wait.h create mode 100755 1/newlibc/include/sys/dir.h create mode 100755 1/newlibc/include/sys/dirent.h create mode 100755 1/newlibc/include/sys/file.h create mode 100755 1/newlibc/include/sys/ioctl.h create mode 100755 1/newlibc/include/sys/param.h create mode 100755 1/newlibc/include/sys/stat.h create mode 100755 1/newlibc/include/sys/sysmacros.h create mode 100755 1/newlibc/include/sys/time.h create mode 100755 1/newlibc/include/sys/timeb.h create mode 100755 1/newlibc/include/sys/times.h create mode 100755 1/newlibc/include/sys/types.h create mode 100755 1/newlibc/include/sys/utsname.h create mode 100755 1/newlibc/include/sys/varargs.h create mode 100755 1/newlibc/include/sys/wait.h create mode 100755 1/newlibc/include/termcap.h create mode 100755 1/newlibc/include/termio.h create mode 100755 1/newlibc/include/termios.h create mode 100755 1/newlibc/include/time.h create mode 100755 1/newlibc/include/unistd.h create mode 100755 1/newlibc/include/utime.h create mode 100755 1/newlibc/include/varargs.h create mode 100755 1/newlibc/malloc/._Makefile create mode 100755 1/newlibc/malloc/._README create mode 100755 1/newlibc/malloc/._ansidecl.h create mode 100755 1/newlibc/malloc/._free.c create mode 100755 1/newlibc/malloc/._gmalloc.c create mode 100755 1/newlibc/malloc/._gmalloc.c.old create mode 100755 1/newlibc/malloc/._gmalloc.sed create mode 100755 1/newlibc/malloc/._gmalloc.skel create mode 100755 1/newlibc/malloc/._limits.h create mode 100755 1/newlibc/malloc/._malloc.c.1 create mode 100755 1/newlibc/malloc/._malloc.h create mode 100755 1/newlibc/malloc/._mcheck.c create mode 100755 1/newlibc/malloc/._mstats.c create mode 100755 1/newlibc/malloc/._realloc.c create mode 100755 1/newlibc/malloc/._stddef.h create mode 100755 1/newlibc/malloc/._stdlib.h create mode 100755 1/newlibc/malloc/._string.h create mode 100755 1/newlibc/malloc/._unix.c create mode 100755 1/newlibc/malloc/._valloc.c create mode 100755 1/newlibc/malloc/Makefile create mode 100755 1/newlibc/malloc/README create mode 100755 1/newlibc/malloc/ansidecl.h create mode 100755 1/newlibc/malloc/free.c create mode 100755 1/newlibc/malloc/gmalloc.c create mode 100755 1/newlibc/malloc/gmalloc.c.old create mode 100755 1/newlibc/malloc/gmalloc.sed create mode 100755 1/newlibc/malloc/gmalloc.skel create mode 100755 1/newlibc/malloc/limits.h create mode 100755 1/newlibc/malloc/malloc.c.1 create mode 100755 1/newlibc/malloc/malloc.h create mode 100755 1/newlibc/malloc/mcheck.c create mode 100755 1/newlibc/malloc/mstats.c create mode 100755 1/newlibc/malloc/realloc.c create mode 100755 1/newlibc/malloc/stddef.h create mode 100755 1/newlibc/malloc/stdlib.h create mode 100755 1/newlibc/malloc/string.h create mode 100755 1/newlibc/malloc/unix.c create mode 100755 1/newlibc/malloc/valloc.c create mode 100755 1/newlibc/math/._Makefile create mode 100755 1/newlibc/math/._acos.s create mode 100755 1/newlibc/math/._acosh.c create mode 100755 1/newlibc/math/._asin.s create mode 100755 1/newlibc/math/._asinh.c create mode 100755 1/newlibc/math/._atan.s create mode 100755 1/newlibc/math/._atan2.s create mode 100755 1/newlibc/math/._atanh.c create mode 100755 1/newlibc/math/._ceil.s create mode 100755 1/newlibc/math/._cos.s create mode 100755 1/newlibc/math/._cosh.c create mode 100755 1/newlibc/math/._erf.c create mode 100755 1/newlibc/math/._exp.s create mode 100755 1/newlibc/math/._fabs.s create mode 100755 1/newlibc/math/._floor.s create mode 100755 1/newlibc/math/._fmod.s create mode 100755 1/newlibc/math/._frexp.c create mode 100755 1/newlibc/math/._hypot.c create mode 100755 1/newlibc/math/._j0.c create mode 100755 1/newlibc/math/._j1.c create mode 100755 1/newlibc/math/._jn.c create mode 100755 1/newlibc/math/._lgamma.c create mode 100755 1/newlibc/math/._log.s create mode 100755 1/newlibc/math/._log10.s create mode 100755 1/newlibc/math/._sin.s create mode 100755 1/newlibc/math/._sinh.c create mode 100755 1/newlibc/math/._sqrt.s create mode 100755 1/newlibc/math/._tan.s create mode 100755 1/newlibc/math/._tanh.c create mode 100755 1/newlibc/math/Makefile create mode 100755 1/newlibc/math/acos.s create mode 100755 1/newlibc/math/acosh.c create mode 100755 1/newlibc/math/asin.s create mode 100755 1/newlibc/math/asinh.c create mode 100755 1/newlibc/math/atan.s create mode 100755 1/newlibc/math/atan2.s create mode 100755 1/newlibc/math/atanh.c create mode 100755 1/newlibc/math/ceil.s create mode 100755 1/newlibc/math/cos.s create mode 100755 1/newlibc/math/cosh.c create mode 100755 1/newlibc/math/erf.c create mode 100755 1/newlibc/math/exp.s create mode 100755 1/newlibc/math/fabs.s create mode 100755 1/newlibc/math/floor.s create mode 100755 1/newlibc/math/fmod.s create mode 100755 1/newlibc/math/frexp.c create mode 100755 1/newlibc/math/hypot.c create mode 100755 1/newlibc/math/j0.c create mode 100755 1/newlibc/math/j1.c create mode 100755 1/newlibc/math/jn.c create mode 100755 1/newlibc/math/lgamma.c create mode 100755 1/newlibc/math/log.s create mode 100755 1/newlibc/math/log10.s create mode 100755 1/newlibc/math/sin.s create mode 100755 1/newlibc/math/sinh.c create mode 100755 1/newlibc/math/sqrt.s create mode 100755 1/newlibc/math/tan.s create mode 100755 1/newlibc/math/tanh.c create mode 100755 1/newlibc/misc/._Makefile create mode 100755 1/newlibc/misc/._README create mode 100755 1/newlibc/misc/._atexit.c create mode 100755 1/newlibc/misc/._bcopy.s create mode 100755 1/newlibc/misc/._exit.c create mode 100755 1/newlibc/misc/._frexp.c create mode 100755 1/newlibc/misc/._ldexp.c create mode 100755 1/newlibc/misc/._modf.c create mode 100755 1/newlibc/misc/._perror.c create mode 100755 1/newlibc/misc/._readv.c create mode 100755 1/newlibc/misc/._tmpnam.c create mode 100755 1/newlibc/misc/._values.s create mode 100755 1/newlibc/misc/._writev.c create mode 100755 1/newlibc/misc/Makefile create mode 100755 1/newlibc/misc/README create mode 100755 1/newlibc/misc/atexit.c create mode 100755 1/newlibc/misc/bcopy.s create mode 100755 1/newlibc/misc/exit.c create mode 100755 1/newlibc/misc/frexp.c create mode 100755 1/newlibc/misc/ldexp.c create mode 100755 1/newlibc/misc/modf.c create mode 100755 1/newlibc/misc/perror.c create mode 100755 1/newlibc/misc/readv.c create mode 100755 1/newlibc/misc/tmpnam.c create mode 100755 1/newlibc/misc/values.s create mode 100755 1/newlibc/misc/writev.c create mode 100755 1/newlibc/mlinux/._Makefile create mode 100755 1/newlibc/mlinux/._README create mode 100755 1/newlibc/mlinux/._acos.s create mode 100755 1/newlibc/mlinux/._acosh.s create mode 100755 1/newlibc/mlinux/._asin.s create mode 100755 1/newlibc/mlinux/._asinh.s create mode 100755 1/newlibc/mlinux/._atan.s create mode 100755 1/newlibc/mlinux/._atan2.s create mode 100755 1/newlibc/mlinux/._atanh.s create mode 100755 1/newlibc/mlinux/._ceil.s create mode 100755 1/newlibc/mlinux/._cos.s create mode 100755 1/newlibc/mlinux/._cosh.s create mode 100755 1/newlibc/mlinux/._erf.c create mode 100755 1/newlibc/mlinux/._exp.s create mode 100755 1/newlibc/mlinux/._fabs.s create mode 100755 1/newlibc/mlinux/._floor.s create mode 100755 1/newlibc/mlinux/._fmod.s create mode 100755 1/newlibc/mlinux/._frexp.c create mode 100755 1/newlibc/mlinux/._hypot.s create mode 100755 1/newlibc/mlinux/._j0.c create mode 100755 1/newlibc/mlinux/._j1.c create mode 100755 1/newlibc/mlinux/._jn.c create mode 100755 1/newlibc/mlinux/._lgamma.c create mode 100755 1/newlibc/mlinux/._log.s create mode 100755 1/newlibc/mlinux/._log10.s create mode 100755 1/newlibc/mlinux/._math.h create mode 100755 1/newlibc/mlinux/._sin.s create mode 100755 1/newlibc/mlinux/._sinh.s create mode 100755 1/newlibc/mlinux/._sqrt.s create mode 100755 1/newlibc/mlinux/._tan.s create mode 100755 1/newlibc/mlinux/._tanh.s create mode 100755 1/newlibc/mlinux/Makefile create mode 100755 1/newlibc/mlinux/README create mode 100755 1/newlibc/mlinux/acos.s create mode 100755 1/newlibc/mlinux/acosh.s create mode 100755 1/newlibc/mlinux/asin.s create mode 100755 1/newlibc/mlinux/asinh.s create mode 100755 1/newlibc/mlinux/atan.s create mode 100755 1/newlibc/mlinux/atan2.s create mode 100755 1/newlibc/mlinux/atanh.s create mode 100755 1/newlibc/mlinux/ceil.s create mode 100755 1/newlibc/mlinux/cos.s create mode 100755 1/newlibc/mlinux/cosh.s create mode 100755 1/newlibc/mlinux/erf.c create mode 100755 1/newlibc/mlinux/exp.s create mode 100755 1/newlibc/mlinux/fabs.s create mode 100755 1/newlibc/mlinux/floor.s create mode 100755 1/newlibc/mlinux/fmod.s create mode 100755 1/newlibc/mlinux/frexp.c create mode 100755 1/newlibc/mlinux/hypot.s create mode 100755 1/newlibc/mlinux/j0.c create mode 100755 1/newlibc/mlinux/j1.c create mode 100755 1/newlibc/mlinux/jn.c create mode 100755 1/newlibc/mlinux/lgamma.c create mode 100755 1/newlibc/mlinux/log.s create mode 100755 1/newlibc/mlinux/log10.s create mode 100755 1/newlibc/mlinux/math.h create mode 100755 1/newlibc/mlinux/sin.s create mode 100755 1/newlibc/mlinux/sinh.s create mode 100755 1/newlibc/mlinux/sqrt.s create mode 100755 1/newlibc/mlinux/tan.s create mode 100755 1/newlibc/mlinux/tanh.s create mode 100755 1/newlibc/other/._Makefile create mode 100755 1/newlibc/other/._getcwd.c create mode 100755 1/newlibc/other/._getopt.c create mode 100755 1/newlibc/other/._mktemp.c create mode 100755 1/newlibc/other/._popen.c create mode 100755 1/newlibc/other/._setjmp.s create mode 100755 1/newlibc/other/._sig_restore.s create mode 100755 1/newlibc/other/Makefile create mode 100755 1/newlibc/other/getcwd.c create mode 100755 1/newlibc/other/getopt.c create mode 100755 1/newlibc/other/mktemp.c create mode 100755 1/newlibc/other/popen.c create mode 100755 1/newlibc/other/setjmp.s create mode 100755 1/newlibc/other/sig_restore.s create mode 100755 1/newlibc/posix/._Makefile create mode 100755 1/newlibc/posix/._cfsetget.c create mode 100755 1/newlibc/posix/._rename.c create mode 100755 1/newlibc/posix/._sigmask.c create mode 100755 1/newlibc/posix/._sleep.c create mode 100755 1/newlibc/posix/._sysconf.c create mode 100755 1/newlibc/posix/._tcattr.c create mode 100755 1/newlibc/posix/._tcflow.c create mode 100755 1/newlibc/posix/._tcsetpgrp.c create mode 100755 1/newlibc/posix/._ttyname.c create mode 100755 1/newlibc/posix/Makefile create mode 100755 1/newlibc/posix/cfsetget.c create mode 100755 1/newlibc/posix/rename.c create mode 100755 1/newlibc/posix/sigmask.c create mode 100755 1/newlibc/posix/sleep.c create mode 100755 1/newlibc/posix/sysconf.c create mode 100755 1/newlibc/posix/tcattr.c create mode 100755 1/newlibc/posix/tcflow.c create mode 100755 1/newlibc/posix/tcsetpgrp.c create mode 100755 1/newlibc/posix/ttyname.c create mode 100755 1/newlibc/pwd/._Makefile create mode 100755 1/newlibc/pwd/._fgetpwent.c create mode 100755 1/newlibc/pwd/._getpw.c create mode 100755 1/newlibc/pwd/._getpwent.c create mode 100755 1/newlibc/pwd/._getpwnam.c create mode 100755 1/newlibc/pwd/._getpwuid.c create mode 100755 1/newlibc/pwd/._putpwent.c create mode 100755 1/newlibc/pwd/._pwdopen.c create mode 100755 1/newlibc/pwd/._pwdread.c create mode 100755 1/newlibc/pwd/Makefile create mode 100755 1/newlibc/pwd/fgetpwent.c create mode 100755 1/newlibc/pwd/getpw.c create mode 100755 1/newlibc/pwd/getpwent.c create mode 100755 1/newlibc/pwd/getpwnam.c create mode 100755 1/newlibc/pwd/getpwuid.c create mode 100755 1/newlibc/pwd/putpwent.c create mode 100755 1/newlibc/pwd/pwdopen.c create mode 100755 1/newlibc/pwd/pwdread.c create mode 100755 1/newlibc/soft/._Makefile create mode 100755 1/newlibc/soft/._README create mode 100755 1/newlibc/soft/._asin.c create mode 100755 1/newlibc/soft/._atan.c create mode 100755 1/newlibc/soft/._const.c create mode 100755 1/newlibc/soft/._erf.c create mode 100755 1/newlibc/soft/._exp.c create mode 100755 1/newlibc/soft/._fabs.c create mode 100755 1/newlibc/soft/._floor.c create mode 100755 1/newlibc/soft/._frexp.c create mode 100755 1/newlibc/soft/._hypot.c create mode 100755 1/newlibc/soft/._j0.c create mode 100755 1/newlibc/soft/._j1.c create mode 100755 1/newlibc/soft/._jn.c create mode 100755 1/newlibc/soft/._ldexp.c create mode 100755 1/newlibc/soft/._lgamma.c create mode 100755 1/newlibc/soft/._log.c create mode 100755 1/newlibc/soft/._main.c create mode 100755 1/newlibc/soft/._modf.c create mode 100755 1/newlibc/soft/._pow.c create mode 100755 1/newlibc/soft/._sin.c create mode 100755 1/newlibc/soft/._sinh.c create mode 100755 1/newlibc/soft/._soft.h create mode 100755 1/newlibc/soft/._soft.h.old create mode 100755 1/newlibc/soft/._sqrt.c create mode 100755 1/newlibc/soft/._tan.c create mode 100755 1/newlibc/soft/._tanh.c create mode 100755 1/newlibc/soft/Makefile create mode 100755 1/newlibc/soft/README create mode 100755 1/newlibc/soft/asin.c create mode 100755 1/newlibc/soft/atan.c create mode 100755 1/newlibc/soft/const.c create mode 100755 1/newlibc/soft/erf.c create mode 100755 1/newlibc/soft/exp.c create mode 100755 1/newlibc/soft/fabs.c create mode 100755 1/newlibc/soft/floor.c create mode 100755 1/newlibc/soft/frexp.c create mode 100755 1/newlibc/soft/hypot.c create mode 100755 1/newlibc/soft/j0.c create mode 100755 1/newlibc/soft/j1.c create mode 100755 1/newlibc/soft/jn.c create mode 100755 1/newlibc/soft/ldexp.c create mode 100755 1/newlibc/soft/lgamma.c create mode 100755 1/newlibc/soft/log.c create mode 100755 1/newlibc/soft/main.c create mode 100755 1/newlibc/soft/modf.c create mode 100755 1/newlibc/soft/pow.c create mode 100755 1/newlibc/soft/sin.c create mode 100755 1/newlibc/soft/sinh.c create mode 100755 1/newlibc/soft/soft.h create mode 100755 1/newlibc/soft/soft.h.old create mode 100755 1/newlibc/soft/sqrt.c create mode 100755 1/newlibc/soft/tan.c create mode 100755 1/newlibc/soft/tanh.c create mode 100755 1/newlibc/stdio/._Makefile create mode 100755 1/newlibc/stdio/._clrerr.c create mode 100755 1/newlibc/stdio/._doprnt.c create mode 100755 1/newlibc/stdio/._doscan.c create mode 100755 1/newlibc/stdio/._fdopen.c create mode 100755 1/newlibc/stdio/._fgetc.c create mode 100755 1/newlibc/stdio/._fgets.c create mode 100755 1/newlibc/stdio/._filbuf.c create mode 100755 1/newlibc/stdio/._findiop.c create mode 100755 1/newlibc/stdio/._flsbuf.c create mode 100755 1/newlibc/stdio/._fopen.c create mode 100755 1/newlibc/stdio/._fprintf.c create mode 100755 1/newlibc/stdio/._fputc.c create mode 100755 1/newlibc/stdio/._fputs.c create mode 100755 1/newlibc/stdio/._fread.c create mode 100755 1/newlibc/stdio/._freopen.c create mode 100755 1/newlibc/stdio/._fseek.c create mode 100755 1/newlibc/stdio/._ftell.c create mode 100755 1/newlibc/stdio/._fwrite.c create mode 100755 1/newlibc/stdio/._getchar.c create mode 100755 1/newlibc/stdio/._gets.c create mode 100755 1/newlibc/stdio/._getw.c create mode 100755 1/newlibc/stdio/._printf.c create mode 100755 1/newlibc/stdio/._putchar.c create mode 100755 1/newlibc/stdio/._puts.c create mode 100755 1/newlibc/stdio/._putw.c create mode 100755 1/newlibc/stdio/._rew.c create mode 100755 1/newlibc/stdio/._scanf.c create mode 100755 1/newlibc/stdio/._setbuf.c create mode 100755 1/newlibc/stdio/._setbuffe.c create mode 100755 1/newlibc/stdio/._setvbuf.c create mode 100755 1/newlibc/stdio/._sprintf.c create mode 100755 1/newlibc/stdio/._ungetc.c create mode 100755 1/newlibc/stdio/._vfprintf.c create mode 100755 1/newlibc/stdio/._vprintf.c create mode 100755 1/newlibc/stdio/._vsprintf.c create mode 100755 1/newlibc/stdio/Makefile create mode 100755 1/newlibc/stdio/clrerr.c create mode 100755 1/newlibc/stdio/doprnt.c create mode 100755 1/newlibc/stdio/doscan.c create mode 100755 1/newlibc/stdio/fdopen.c create mode 100755 1/newlibc/stdio/fgetc.c create mode 100755 1/newlibc/stdio/fgets.c create mode 100755 1/newlibc/stdio/filbuf.c create mode 100755 1/newlibc/stdio/findiop.c create mode 100755 1/newlibc/stdio/flsbuf.c create mode 100755 1/newlibc/stdio/fopen.c create mode 100755 1/newlibc/stdio/fprintf.c create mode 100755 1/newlibc/stdio/fputc.c create mode 100755 1/newlibc/stdio/fputs.c create mode 100755 1/newlibc/stdio/fread.c create mode 100755 1/newlibc/stdio/freopen.c create mode 100755 1/newlibc/stdio/fseek.c create mode 100755 1/newlibc/stdio/ftell.c create mode 100755 1/newlibc/stdio/fwrite.c create mode 100755 1/newlibc/stdio/getchar.c create mode 100755 1/newlibc/stdio/gets.c create mode 100755 1/newlibc/stdio/getw.c create mode 100755 1/newlibc/stdio/printf.c create mode 100755 1/newlibc/stdio/putchar.c create mode 100755 1/newlibc/stdio/puts.c create mode 100755 1/newlibc/stdio/putw.c create mode 100755 1/newlibc/stdio/rew.c create mode 100755 1/newlibc/stdio/scanf.c create mode 100755 1/newlibc/stdio/setbuf.c create mode 100755 1/newlibc/stdio/setbuffe.c create mode 100755 1/newlibc/stdio/setvbuf.c create mode 100755 1/newlibc/stdio/sprintf.c create mode 100755 1/newlibc/stdio/ungetc.c create mode 100755 1/newlibc/stdio/vfprintf.c create mode 100755 1/newlibc/stdio/vprintf.c create mode 100755 1/newlibc/stdio/vsprintf.c create mode 100755 1/newlibc/termcap/._COPYING create mode 100755 1/newlibc/termcap/._COPYING.LIB create mode 100755 1/newlibc/termcap/._ChangeLog create mode 100755 1/newlibc/termcap/._Makefile.in create mode 100755 1/newlibc/termcap/._README create mode 100755 1/newlibc/termcap/._bsearch.c create mode 100755 1/newlibc/termcap/._configure create mode 100755 1/newlibc/termcap/._conversions.c create mode 100755 1/newlibc/termcap/._getopt.c create mode 100755 1/newlibc/termcap/._getopt.h create mode 100755 1/newlibc/termcap/._getopt1.c create mode 100755 1/newlibc/termcap/._makefile create mode 100755 1/newlibc/termcap/._termcap.c create mode 100755 1/newlibc/termcap/._termcap.h create mode 100755 1/newlibc/termcap/._tparam.c create mode 100755 1/newlibc/termcap/._tput.c create mode 100755 1/newlibc/termcap/._tput.h create mode 100755 1/newlibc/termcap/._tput.texinfo create mode 100755 1/newlibc/termcap/COPYING create mode 100755 1/newlibc/termcap/COPYING.LIB create mode 100755 1/newlibc/termcap/ChangeLog create mode 100755 1/newlibc/termcap/Makefile.in create mode 100755 1/newlibc/termcap/README create mode 100755 1/newlibc/termcap/bsearch.c create mode 100755 1/newlibc/termcap/configure create mode 100755 1/newlibc/termcap/conversions.c create mode 100755 1/newlibc/termcap/getopt.c create mode 100755 1/newlibc/termcap/getopt.h create mode 100755 1/newlibc/termcap/getopt1.c create mode 100755 1/newlibc/termcap/makefile create mode 100755 1/newlibc/termcap/termcap.c create mode 100755 1/newlibc/termcap/termcap.h create mode 100755 1/newlibc/termcap/tparam.c create mode 100755 1/newlibc/termcap/tput.c create mode 100755 1/newlibc/termcap/tput.h create mode 100755 1/newlibc/termcap/tput.texinfo create mode 100755 1/newlibc/unistd/._Makefile create mode 100755 1/newlibc/unistd/.__exit.c create mode 100755 1/newlibc/unistd/._access.c create mode 100755 1/newlibc/unistd/._acct.c create mode 100755 1/newlibc/unistd/._alarm.c create mode 100755 1/newlibc/unistd/._brk.c create mode 100755 1/newlibc/unistd/._chdir.c create mode 100755 1/newlibc/unistd/._chmod.c create mode 100755 1/newlibc/unistd/._chown.c create mode 100755 1/newlibc/unistd/._chroot.c create mode 100755 1/newlibc/unistd/._close.c create mode 100755 1/newlibc/unistd/._creat.c create mode 100755 1/newlibc/unistd/._dup.c create mode 100755 1/newlibc/unistd/._dup2.c create mode 100755 1/newlibc/unistd/._exec.c create mode 100755 1/newlibc/unistd/._execp.c create mode 100755 1/newlibc/unistd/._execve.c create mode 100755 1/newlibc/unistd/._fcntl.c create mode 100755 1/newlibc/unistd/._fork.c create mode 100755 1/newlibc/unistd/._fstat.c create mode 100755 1/newlibc/unistd/._getegid.c create mode 100755 1/newlibc/unistd/._geteuid.c create mode 100755 1/newlibc/unistd/._getgid.c create mode 100755 1/newlibc/unistd/._getgroups.c create mode 100755 1/newlibc/unistd/._gethostnam.c create mode 100755 1/newlibc/unistd/._getpgrp.c create mode 100755 1/newlibc/unistd/._getpid.c create mode 100755 1/newlibc/unistd/._getppid.c create mode 100755 1/newlibc/unistd/._getrlimit.c create mode 100755 1/newlibc/unistd/._getrusage.c create mode 100755 1/newlibc/unistd/._gettime.c create mode 100755 1/newlibc/unistd/._getuid.c create mode 100755 1/newlibc/unistd/._ioctl.c create mode 100755 1/newlibc/unistd/._kill.c create mode 100755 1/newlibc/unistd/._link.c create mode 100755 1/newlibc/unistd/._lseek.c create mode 100755 1/newlibc/unistd/._lstat.c create mode 100755 1/newlibc/unistd/._mkdir.c create mode 100755 1/newlibc/unistd/._mknod.c create mode 100755 1/newlibc/unistd/._mount.c create mode 100755 1/newlibc/unistd/._nice.c create mode 100755 1/newlibc/unistd/._open.c create mode 100755 1/newlibc/unistd/._pause.c create mode 100755 1/newlibc/unistd/._pipe.c create mode 100755 1/newlibc/unistd/._read.c create mode 100755 1/newlibc/unistd/._readlink.c create mode 100755 1/newlibc/unistd/._rmdir.c create mode 100755 1/newlibc/unistd/._select.c create mode 100755 1/newlibc/unistd/._setgid.c create mode 100755 1/newlibc/unistd/._setgroups.c create mode 100755 1/newlibc/unistd/._sethostnam.c create mode 100755 1/newlibc/unistd/._setpgrp.c create mode 100755 1/newlibc/unistd/._setregid.c create mode 100755 1/newlibc/unistd/._setreuid.c create mode 100755 1/newlibc/unistd/._setrlimit.c create mode 100755 1/newlibc/unistd/._setsid.c create mode 100755 1/newlibc/unistd/._settime.c create mode 100755 1/newlibc/unistd/._setuid.c create mode 100755 1/newlibc/unistd/._signal.c create mode 100755 1/newlibc/unistd/._sigpend.c create mode 100755 1/newlibc/unistd/._sigsusp.c create mode 100755 1/newlibc/unistd/._stat.c create mode 100755 1/newlibc/unistd/._stime.c create mode 100755 1/newlibc/unistd/._symlink.c create mode 100755 1/newlibc/unistd/._sync.c create mode 100755 1/newlibc/unistd/._time.c create mode 100755 1/newlibc/unistd/._times.c create mode 100755 1/newlibc/unistd/._ulimit.c create mode 100755 1/newlibc/unistd/._umask.c create mode 100755 1/newlibc/unistd/._umount.c create mode 100755 1/newlibc/unistd/._uname.c create mode 100755 1/newlibc/unistd/._unlink.c create mode 100755 1/newlibc/unistd/._uselib.c create mode 100755 1/newlibc/unistd/._ustat.c create mode 100755 1/newlibc/unistd/._utime.c create mode 100755 1/newlibc/unistd/._wait.c create mode 100755 1/newlibc/unistd/._write.c create mode 100755 1/newlibc/unistd/Makefile create mode 100755 1/newlibc/unistd/_exit.c create mode 100755 1/newlibc/unistd/access.c create mode 100755 1/newlibc/unistd/acct.c create mode 100755 1/newlibc/unistd/alarm.c create mode 100755 1/newlibc/unistd/brk.c create mode 100755 1/newlibc/unistd/chdir.c create mode 100755 1/newlibc/unistd/chmod.c create mode 100755 1/newlibc/unistd/chown.c create mode 100755 1/newlibc/unistd/chroot.c create mode 100755 1/newlibc/unistd/close.c create mode 100755 1/newlibc/unistd/creat.c create mode 100755 1/newlibc/unistd/dup.c create mode 100755 1/newlibc/unistd/dup2.c create mode 100755 1/newlibc/unistd/exec.c create mode 100755 1/newlibc/unistd/execp.c create mode 100755 1/newlibc/unistd/execve.c create mode 100755 1/newlibc/unistd/fcntl.c create mode 100755 1/newlibc/unistd/fork.c create mode 100755 1/newlibc/unistd/fstat.c create mode 100755 1/newlibc/unistd/getegid.c create mode 100755 1/newlibc/unistd/geteuid.c create mode 100755 1/newlibc/unistd/getgid.c create mode 100755 1/newlibc/unistd/getgroups.c create mode 100755 1/newlibc/unistd/gethostnam.c create mode 100755 1/newlibc/unistd/getpgrp.c create mode 100755 1/newlibc/unistd/getpid.c create mode 100755 1/newlibc/unistd/getppid.c create mode 100755 1/newlibc/unistd/getrlimit.c create mode 100755 1/newlibc/unistd/getrusage.c create mode 100755 1/newlibc/unistd/gettime.c create mode 100755 1/newlibc/unistd/getuid.c create mode 100755 1/newlibc/unistd/ioctl.c create mode 100755 1/newlibc/unistd/kill.c create mode 100755 1/newlibc/unistd/link.c create mode 100755 1/newlibc/unistd/lseek.c create mode 100755 1/newlibc/unistd/lstat.c create mode 100755 1/newlibc/unistd/mkdir.c create mode 100755 1/newlibc/unistd/mknod.c create mode 100755 1/newlibc/unistd/mount.c create mode 100755 1/newlibc/unistd/nice.c create mode 100755 1/newlibc/unistd/open.c create mode 100755 1/newlibc/unistd/pause.c create mode 100755 1/newlibc/unistd/pipe.c create mode 100755 1/newlibc/unistd/read.c create mode 100755 1/newlibc/unistd/readlink.c create mode 100755 1/newlibc/unistd/rmdir.c create mode 100755 1/newlibc/unistd/select.c create mode 100755 1/newlibc/unistd/setgid.c create mode 100755 1/newlibc/unistd/setgroups.c create mode 100755 1/newlibc/unistd/sethostnam.c create mode 100755 1/newlibc/unistd/setpgrp.c create mode 100755 1/newlibc/unistd/setregid.c create mode 100755 1/newlibc/unistd/setreuid.c create mode 100755 1/newlibc/unistd/setrlimit.c create mode 100755 1/newlibc/unistd/setsid.c create mode 100755 1/newlibc/unistd/settime.c create mode 100755 1/newlibc/unistd/setuid.c create mode 100755 1/newlibc/unistd/signal.c create mode 100755 1/newlibc/unistd/sigpend.c create mode 100755 1/newlibc/unistd/sigsusp.c create mode 100755 1/newlibc/unistd/stat.c create mode 100755 1/newlibc/unistd/stime.c create mode 100755 1/newlibc/unistd/symlink.c create mode 100755 1/newlibc/unistd/sync.c create mode 100755 1/newlibc/unistd/time.c create mode 100755 1/newlibc/unistd/times.c create mode 100755 1/newlibc/unistd/ulimit.c create mode 100755 1/newlibc/unistd/umask.c create mode 100755 1/newlibc/unistd/umount.c create mode 100755 1/newlibc/unistd/uname.c create mode 100755 1/newlibc/unistd/unlink.c create mode 100755 1/newlibc/unistd/uselib.c create mode 100755 1/newlibc/unistd/ustat.c create mode 100755 1/newlibc/unistd/utime.c create mode 100755 1/newlibc/unistd/wait.c create mode 100755 1/newlibc/unistd/write.c create mode 100755 1/rundev/._0.11-dev.bxrc create mode 100755 1/rundev/._readme.txt create mode 100755 1/rundev/._rundev create mode 100755 1/rundev/0.11-dev.bxrc create mode 100755 1/rundev/readme.txt create mode 100755 1/rundev/rundev diff --git a/1/.DS_Store b/1/.DS_Store new file mode 100755 index 0000000000000000000000000000000000000000..3d1bb7d834d02a7677b79f574ba644769bb48573 GIT binary patch literal 6148 zcmeHKL2uJA6n^fyEfGTWfW(fzaO{w!{>{RlvPj~28jYuftE zlrHw0IV+308I8WH-cEmaZ$FCTD83oLO;2r`Hd(W*r`h5)x1MLssR{KL)|MCb%)Bh- z?eXCDQ(HAzQOy@Fxya`TdGo5Ma@$VrvdU{WPU<_{M8|`J)oMI?Jk<9dP1ZxbnoLGR z{oww?^*WC3+#NqTI(h%$UkMK`Wua+y;U5CyKa0=z$H7;_T1^X#?`6z&QD?!)bXI{!3s zjt-mz?mVLhP(BsxQ&qTPD4!0$4sl7~&a+P^6)qnt%&fuE?T<7^B1r>J`BbJZi b1DFH+nk(QWaOW8wKz;!|5SmWwrg|q literal 0 HcmV?d00001 diff --git a/1/._.DS_Store b/1/._.DS_Store new file mode 100755 index 0000000000000000000000000000000000000000..e5df4dd64d52cfb302d9680dc7d0ef9480083b2d GIT binary patch literal 4096 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDJkFz{^v(m+1nBL)UWIhYCu0iY;W;207T z#2^sj57EI;fmP9{;AjYphQMeDjE2By2#kinXb6mkz-S1JhQMeDjE2By2v9i$7=h-2 zFc`>%WMmdA6r~pDmlh?bDx~EXWh-Rnm89mCWaj53=Hyf=w1 QnnLwI+$%B+a{vDW0LaE2i2wiq literal 0 HcmV?d00001 diff --git a/1/._2-系统调用扩充实验指南.pdf b/1/._2-系统调用扩充实验指南.pdf new file mode 100755 index 0000000000000000000000000000000000000000..62c987b6733361d46599826df91b768d135d6377 GIT binary patch literal 4096 zcmeH~&q~8U5XPs1h?mlfo+RuGBy4SLA~_{7xrxw3@VeP=7VAWFyCQ*w}HdcBRBxKW}Ms<0M%U zD~z}6c$9_dlKSbTn+199`dJ>h;l(0%$Vqox1Ojhs@R)|o50+1L3ClDJkFz{^v(m+1nBL)UWIUt(=a103vVh{*P zhUj3J0aPxEriBs6hl-0P=jZAr78K;9>J^qI7A5ADWagzZ7#LU>S(_Q8SX!E;rdkIl zrX?0-TB8{<${h`X(GVC7fzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4FTj30ChG&7!2e> zGBS%5ic*X7ON)|I71HvHvK2D(N>YK{&iuT@oSaI9oYb@ug`}Lsylh}!7^-VXQ>gxj Ldqsvp?*D%PPZcXS literal 0 HcmV?d00001 diff --git a/1/._execve.c b/1/._execve.c new file mode 100755 index 0000000000000000000000000000000000000000..70d7f0cb92ced162fb97bfeb41b2ffa6cf96fd20 GIT binary patch literal 4096 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDJkFz{^v(m+1nBL)UWIUt(=a103vVh{+4 zh3H_I0aPxEriBs6hl-0P=jZAr78K;9>J^qI7A5ADWagzZ7#LU>S(_Q8SX!E;rdkIl zrX?0-TB8{<${h`X(GVC7fzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4FTj30ChG&7!2e> zGBS%5ic*X7ON)|I71HvHvK2D(N>YK{&iuT@oSaI9oYb@ug`}Lsylh}!7^-VXQ>gxj Ldqsvp?*D%P@hB@X literal 0 HcmV?d00001 diff --git a/1/._execve2.c b/1/._execve2.c new file mode 100755 index 0000000000000000000000000000000000000000..8dff3f50c6ccb1f4a4257a4adec99a83b39c1ee7 GIT binary patch literal 4096 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDJkFz{^v(m+1nBL)UWIUt(=a103vVh{*P zgXmzG0aPxEriBs6hl-0P=jZAr78K;9>J^qI7A5ADWagzZ7#LU>S(_Q8SX!E;rdkIl zrX?0-TB8{<${h`X(GVC7fzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4FTj30ChG&7!2e> zGBS%5ic*X7ON)|I71HvHvK2D(N>YK{&iuT@oSaI9oYb@ug`}Lsylh}!7^-VXQ>gxj Ldqsvp?*D%PegrEz literal 0 HcmV?d00001 diff --git a/1/._newlibc b/1/._newlibc new file mode 100755 index 0000000..e69de29 diff --git a/1/2-系统调用扩充实验指南.pdf b/1/2-系统调用扩充实验指南.pdf new file mode 100755 index 0000000000000000000000000000000000000000..5d4a4e3a024a11c945a897aa6d162dbfab5b2867 GIT binary patch literal 70044 zcmafbWk4NSvn}o(++Bh@gy3$$gF6RzcbDL?tSn6;dJlr z-CetDu}-a84P>%HBD9Qj%rIm0f3N)2gc6c7NBbZ;|$!YsUAsFZ{wMvJy|Cc!(C<6 zqrSE|Dz4Wnx5?fOyUl;utpSQD3#5+t@bpmRY!TDieaa0*V^-UJa;O*md|0d(eKmg? zxuV@{)&8XFIG@4Q`S$b>64@h;^~CiOq_~pVH(kuhZ4niI>;#8%rfyT-CwuC7G3aE2|;Xhs)6Ml_l-EkQjLpRq>!+>6H-& z*)~BnC@Or9?_EL5Me^{gCF-nnfN)z|!5P}XeOs&>`#CLrMlE{SD}1$4Y6{v=_7)fi zR_&4iM3%vyx$sIJ;qpl!hZj3K`EjYcs#?1R?M-@*$I18-*EUkcSAN(1*c=ioH&+wV zB2He-PH(d>h%_O&S8Kc&lKTwO`JVfICLFV`aIYFGR=D|rwE-qc3!Zr1Y)g@ z7LI4s5Z)~hu3<>J_Au7%Hm*)S=(ixC!yY?GI&dLj4x^Y=`KPy{xNLpGL$<;j|5BzY-8 zO$JIFxf*(Fn@yH23~Sb${T%$*%Fe>31C^G^j#|UIdJ$K$H`8aO zaRc`~(AEnQMcnl0h#ttUtdDzN{3^MjmDpXB=R-+UXW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#C=)jBy{L)Q75gC9Ha~0*hV%+%od1KO2h&}SK!li(vF`Nqsg9ymkXn7er1%89)L+xQK$#ARRDL zTyF(yMF3#{N+U5%2VSmT^6%e+@vQ@YBQcDQ&Q1-dsu90&`5*MgX6UaNK)5g}LJ>)WAq~v1}V_1u2jKT87Eo5`WagVV9D@F0Sl&cy> z82Blwj|`J(s_Oy!MO$A$b7=iiOtrHB zKH%Tv`=GWX)OlvYan-RgLA1RA8rOXkI6V12n1C#$YfPPI@M-4~&NRSD)b^N653 tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/ansi/abort.c b/1/newlibc/ansi/abort.c new file mode 100755 index 0000000..ccb63b9 --- /dev/null +++ b/1/newlibc/ansi/abort.c @@ -0,0 +1,12 @@ +#include +#include + +/* + * More of these kind of library routines, please. Linus + */ + +void abort(void) +{ + kill(getpid(), SIGABRT); + _exit(-1); +} diff --git a/1/newlibc/ansi/abs.c b/1/newlibc/ansi/abs.c new file mode 100755 index 0000000..3f9395e --- /dev/null +++ b/1/newlibc/ansi/abs.c @@ -0,0 +1,15 @@ +#include + +/* + * These I liked writing. More library routines like these. Linus + */ + +int abs(int n) +{ + return (n<0)?-n:n; +} + +long labs(long n) +{ + return (n<0)?-n:n; +} diff --git a/1/newlibc/ansi/atof.c b/1/newlibc/ansi/atof.c new file mode 100755 index 0000000..af0506f --- /dev/null +++ b/1/newlibc/ansi/atof.c @@ -0,0 +1,44 @@ +#include + +/* + * braindead atof. + * Seems to work now. Linus + */ + +double atof(char * s) +{ + double f = 0.0; + int frac = 0, sign, esign, exp = 0; + + f = 0.0; + while (isspace(*s)) + s++; + if ((sign=(*s == '-')) || (*s == '+')) + s++; + while (isdigit(*s)) + f = f*10.0 + (*s++ - '0'); + if (*s == '.') { + s++; + while (isdigit(*s)) { + f = f*10.0 + (*s++ - '0'); + frac++; + } + } + if (toupper(*s) == 'E') { + if ((esign=(*++s == '-')) || (*s == '+')) + s++; + while (isdigit(*s)) + exp = exp*10 + (*s++ - '0'); + if (esign) + exp = -exp; + } + exp -= frac; + if (exp>0) + while (exp--) + f *= 10.0; + else + while (exp++) + f /= 10.0; + return sign ? -f : f; +} + diff --git a/1/newlibc/ansi/atoi.c b/1/newlibc/ansi/atoi.c new file mode 100755 index 0000000..e91b93b --- /dev/null +++ b/1/newlibc/ansi/atoi.c @@ -0,0 +1,16 @@ +#include + +/* + * see strtol.c for these. Linus + */ + +int atoi(const char *s) +{ + return (int) strtol(s, (char **) NULL, 10); +} + +long atol(const char *s) +{ + return strtol(s, (char **) NULL, 10); +} + diff --git a/1/newlibc/ansi/bsearch.c b/1/newlibc/ansi/bsearch.c new file mode 100755 index 0000000..02eb4ed --- /dev/null +++ b/1/newlibc/ansi/bsearch.c @@ -0,0 +1,56 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include + + +/* Perform a binary search for KEY in BASE which has NMEMB elements + of SIZE bytes each. The comparisons are done by (*COMPAR)(). */ +PTR +DEFUN(bsearch, (key, base, nmemb, size, compar), + register CONST PTR key AND register CONST PTR base AND + size_t nmemb AND register size_t size AND + register int EXFUN((*compar), (CONST PTR, CONST PTR))) +{ + register size_t l, u, idx; + register CONST PTR p; + register int comparison; + + l = 0; + u = nmemb - 1; + while (l <= u) + { + idx = (l + u) / 2; + p = (PTR) (((CONST char *) base) + (idx * size)); + comparison = (*compar)(key, p); + /* Don't make U negative because it will wrap around. */ + if (comparison < 0) + { + if (idx == 0) + break; + u = idx - 1; + } + else if (comparison > 0) + l = idx + 1; + else + return (PTR) p; + } + + return NULL; +} diff --git a/1/newlibc/ansi/ctime.c b/1/newlibc/ansi/ctime.c new file mode 100755 index 0000000..a09737e --- /dev/null +++ b/1/newlibc/ansi/ctime.c @@ -0,0 +1,142 @@ +/* mktime, localtime, gmtime */ +/* written by ERS and placed in the public domain */ + +#include +#include +#include +#include +#include + +#define SECS_PER_MIN (60L) +#define SECS_PER_HOUR (60*SECS_PER_MIN) +#define SECS_PER_DAY (24*SECS_PER_HOUR) +#define SECS_PER_YEAR (365*SECS_PER_DAY) +#define SECS_PER_LEAPYEAR (SECS_PER_DAY + SECS_PER_YEAR) + +static int days_per_mth[12] = + {31, 28, 31, 30, + 31, 30, 31, 31, + 30, 31, 30, 31 }; + +time_t timezone = -1; /* holds # seconds west of GMT */ +static int dst = -1; /* whether dst holds in current timezone */ + +/* + * FIXME: none of these routines is very efficient. Also, none of them + * handle dates before Jan 1, 1970. + * + */ + +/* + * mktime: take a time structure representing the local time (such as is + * returned by localtime() and convert it into the standard representation + * (as seconds since midnight Jan. 1 1970, GMT). + * + */ + +time_t mktime(struct tm * t) +{ + time_t s; + int y; + + y = t->tm_year - 70; + if (y < 0) /* year before 1970 */ + return (time_t) -1; + s = (SECS_PER_YEAR * y) + ( ((y+1)/4) * SECS_PER_DAY); + /* extra days for leap years */ + if ( (y+2)%4 ) + days_per_mth[1] = 28; + else + days_per_mth[1] = 29; + + for (y = 0; y < t->tm_mon; y++) + s += SECS_PER_DAY * days_per_mth[y]; + + s += (t->tm_mday - 1) * SECS_PER_DAY; + s += t->tm_hour * SECS_PER_HOUR; + s += t->tm_min * SECS_PER_MIN; + s += t->tm_sec; + return s; +} + +static struct tm the_time; + +struct tm *gmtime(const time_t *t) +{ + struct tm *stm = &the_time; + time_t time = *t; + int year, mday, i; + + if (time < 0) /* negative times are bad */ + return 0; + stm->tm_wday = ((time/SECS_PER_DAY) + 4) % 7; + + year = 70; + for (;;) { + if (time < SECS_PER_YEAR) break; + if ((year % 4) == 0) { + if (time < SECS_PER_LEAPYEAR) + break; + else + time -= SECS_PER_LEAPYEAR; + } + else + time -= SECS_PER_YEAR; + year++; + } + stm->tm_year = year; + mday = stm->tm_yday = time/SECS_PER_DAY; + days_per_mth[1] = (year % 4) ? 28 : 29; + for (i = 0; mday >= days_per_mth[i]; i++) + mday -= days_per_mth[i]; + stm->tm_mon = i; + stm->tm_mday = mday + 1; + time = time % SECS_PER_DAY; + stm->tm_hour = time/SECS_PER_HOUR; + time = time % SECS_PER_HOUR; + stm->tm_min = time/SECS_PER_MIN; + stm->tm_sec = time % SECS_PER_MIN; + stm->tm_isdst = 0; + return stm; +} + +/* given a standard time, convert it to a local time */ + +struct tm *localtime(const time_t * t) +{ + struct tm *stm; + time_t offset; /* seconds between local time and GMT */ + + if (timezone == -1) tzset(); + offset = *t - timezone; + stm = gmtime(&offset); + if (stm == (struct tm *)NULL) return stm; /* check for illegal time */ + stm->tm_isdst = (dst == -1) ? -1 : 0; + return stm; +} + +static const char *day[] = +{"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; + +static const char *month[] = + {"Jan", "Feb", "Mar", "Apr", + "May", "Jun", "Jul", "Aug", + "Sep", "Oct", "Nov", "Dec"}; + +char * asctime(const struct tm * time) +{ + static char buf[40]; + + if (time == (struct tm *)NULL) + strcpy(buf, "??? ??? ?? ??:??:?? ????\n"); + else + sprintf(buf, "%.3s %.3s %2d %02d:%02d:%02d %04d\n", + day[time->tm_wday], month[time->tm_mon], time->tm_mday, + time->tm_hour, time->tm_min, time->tm_sec, 1900+time->tm_year); + return(buf); +} + +char *ctime(const time_t *tp) +{ + return(asctime(localtime(tp))); +} diff --git a/1/newlibc/ansi/ctype.c b/1/newlibc/ansi/ctype.c new file mode 100755 index 0000000..bf58aac --- /dev/null +++ b/1/newlibc/ansi/ctype.c @@ -0,0 +1,29 @@ +#include + +char _ctmp; +unsigned char _ctype[] = {0x00, /* EOF */ +_C,_C,_C,_C,_C,_C,_C,_C, /* 0-7 */ +_C,_C|_S,_C|_S,_C|_S,_C|_S,_C|_S,_C,_C, /* 8-15 */ +_C,_C,_C,_C,_C,_C,_C,_C, /* 16-23 */ +_C,_C,_C,_C,_C,_C,_C,_C, /* 24-31 */ +_S|_SP,_P,_P,_P,_P,_P,_P,_P, /* 32-39 */ +_P,_P,_P,_P,_P,_P,_P,_P, /* 40-47 */ +_D,_D,_D,_D,_D,_D,_D,_D, /* 48-55 */ +_D,_D,_P,_P,_P,_P,_P,_P, /* 56-63 */ +_P,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U|_X,_U, /* 64-71 */ +_U,_U,_U,_U,_U,_U,_U,_U, /* 72-79 */ +_U,_U,_U,_U,_U,_U,_U,_U, /* 80-87 */ +_U,_U,_U,_P,_P,_P,_P,_P, /* 88-95 */ +_P,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L|_X,_L, /* 96-103 */ +_L,_L,_L,_L,_L,_L,_L,_L, /* 104-111 */ +_L,_L,_L,_L,_L,_L,_L,_L, /* 112-119 */ +_L,_L,_L,_P,_P,_P,_P,_C, /* 120-127 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 128-143 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 144-159 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 160-175 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 176-191 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 192-207 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 208-223 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 224-239 */ +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; /* 240-255 */ + diff --git a/1/newlibc/ansi/div.c b/1/newlibc/ansi/div.c new file mode 100755 index 0000000..ff0e2f1 --- /dev/null +++ b/1/newlibc/ansi/div.c @@ -0,0 +1,24 @@ +#include + +/* + * Ok, there are probably buggy: sign etc. Linus + */ + +div_t div(int num, int denom) +{ + div_t res; + + __asm__("idivl %3":"=a" (res.quot),"=d" (res.rem) + :"0" (num),"g" (denom)); + return res; +} + +ldiv_t ldiv(long num, long denom) +{ + ldiv_t res; + + __asm__("idivl %3":"=a" (res.quot),"=d" (res.rem) + :"0" (num),"g" (denom)); + return res; +} + diff --git a/1/newlibc/ansi/errno.c b/1/newlibc/ansi/errno.c new file mode 100755 index 0000000..bf43aa4 --- /dev/null +++ b/1/newlibc/ansi/errno.c @@ -0,0 +1,5 @@ +/* + * Great file. Linus + */ + +int errno; diff --git a/1/newlibc/ansi/ftime.c b/1/newlibc/ansi/ftime.c new file mode 100755 index 0000000..23f277c --- /dev/null +++ b/1/newlibc/ansi/ftime.c @@ -0,0 +1,19 @@ +#include +#include + +/* + * I simply don't know what all these time-fns should do. Linus + */ + +int ftime(struct timeb * tp) +{ + time_t t; + + if (time(&t)<0) + return -1; + tp->time = t; + tp->millitm = 0; + tp->timezone = -120; + tp->dstflag = 0; + return 0; +} diff --git a/1/newlibc/ansi/getenv.c b/1/newlibc/ansi/getenv.c new file mode 100755 index 0000000..76a2a68 --- /dev/null +++ b/1/newlibc/ansi/getenv.c @@ -0,0 +1,25 @@ +#include +#include + +/* + * Simple getenv. Linus + */ + +extern char ** environ; + +char * getenv(const char * name) +{ + int len; + char * tmp; + char ** env; + + len = strlen(name); + if (env=environ) + while (tmp=*(env++)) { + if (strncmp(name,tmp,len)) + continue; + if (tmp[len]=='=') + return tmp+len+1; + } + return NULL; +} diff --git a/1/newlibc/ansi/gettimeofday.c b/1/newlibc/ansi/gettimeofday.c new file mode 100755 index 0000000..1234a19 --- /dev/null +++ b/1/newlibc/ansi/gettimeofday.c @@ -0,0 +1,17 @@ +#include +#include +#include + +/* + * Another of these time-functions. I sure wish I knew what I am doing. + * Linus + */ + +int gettimeofday(struct timeval * tp, struct timezone * tz) +{ + tp->tv_sec = time(NULL); + tp->tv_usec = 0; + tz->tz_minuteswest = -120; + tz->tz_dsttime = DST_NONE; + return 0; +} diff --git a/1/newlibc/ansi/isatty.c b/1/newlibc/ansi/isatty.c new file mode 100755 index 0000000..66f5382 --- /dev/null +++ b/1/newlibc/ansi/isatty.c @@ -0,0 +1,15 @@ +#include +#include + +/* + * Simple isatty for Linux. + */ + +int isatty(int fd) +{ + struct termios tmp; + + if (ioctl(fd,TCGETS,&tmp)<0) + return (0); + return 1; +} diff --git a/1/newlibc/ansi/qsort.c b/1/newlibc/ansi/qsort.c new file mode 100755 index 0000000..0cdacf2 --- /dev/null +++ b/1/newlibc/ansi/qsort.c @@ -0,0 +1,239 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. +Written by Douglas C. Schmidt (schmidt@ics.uci.edu). + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +/* Byte-wise swap two items of size SIZE. */ +#define SWAP(a, b, size) \ + do \ + { \ + register size_t __size = (size); \ + register char *__a = (a), *__b = (b); \ + do \ + { \ + char __tmp = *__a; \ + *__a++ = *__b; \ + *__b++ = __tmp; \ + } while (--__size > 0); \ + } while (0) + +/* Discontinue quicksort algorithm when partition gets below this size. + This particular magic number was chosen to work best on a Sun 4/260. */ +#define MAX_THRESH 4 + +/* Stack node declarations used to store unfulfilled partition obligations. */ +typedef struct + { + char *lo; + char *hi; + } stack_node; + +/* The next 4 #defines implement a very fast in-line stack abstraction. */ +#define STACK_SIZE (8 * sizeof(unsigned long int)) +#define PUSH(low, high) ((void) ((top->lo = (low)), (top->hi = (high)), ++top)) +#define POP(low, high) ((void) (--top, (low = top->lo), (high = top->hi))) +#define STACK_NOT_EMPTY (stack < top) + + +/* Order size using quicksort. This implementation incorporates + four optimizations discussed in Sedgewick: + + 1. Non-recursive, using an explicit stack of pointer that store the + next array partition to sort. To save time, this maximum amount + of space required to store an array of MAX_INT is allocated on the + stack. Assuming a 32-bit integer, this needs only 32 * + sizeof(stack_node) == 136 bits. Pretty cheap, actually. + + 2. Chose the pivot element using a median-of-three decision tree. + This reduces the probability of selecting a bad pivot value and + eliminates certain extraneous comparisons. + + 3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving + insertion sort to order the MAX_THRESH items within each partition. + This is a big win, since insertion sort is faster for small, mostly + sorted array segements. + + 4. The larger of the two sub-partitions is always pushed onto the + stack first, with the algorithm then concentrating on the + smaller partition. This *guarantees* no more than log (n) + stack size is needed (actually O(1) in this case)! */ + +void +DEFUN(qsort, (pbase, total_elems, size, cmp), + PTR CONST pbase AND size_t total_elems AND size_t size AND + int EXFUN((*cmp), (CONST PTR, CONST PTR))) +{ + register char *base_ptr = (char *) pbase; + + /* Allocating SIZE bytes for a pivot buffer facilitates a better + algorithm below since we can do comparisons directly on the pivot. */ + char *pivot_buffer = (char *) __alloca (size); + CONST size_t max_thresh = MAX_THRESH * size; + + if (total_elems > MAX_THRESH) + { + char *lo = base_ptr; + char *hi = &lo[size * (total_elems - 1)]; + /* Largest size needed for 32-bit int!!! */ + stack_node stack[STACK_SIZE]; + stack_node *top = stack + 1; + + while (STACK_NOT_EMPTY) + { + char *left_ptr; + char *right_ptr; + + char *pivot = pivot_buffer; + + /* Select median value from among LO, MID, and HI. Rearrange + LO and HI so the three values are sorted. This lowers the + probability of picking a pathological pivot value and + skips a comparison for both the LEFT_PTR and RIGHT_PTR. */ + + char *mid = lo + size * ((hi - lo) / size >> 1); + + if ((*cmp)((PTR) mid, (PTR) lo) < 0) + SWAP(mid, lo, size); + if ((*cmp)((PTR) hi, (PTR) mid) < 0) + SWAP(mid, hi, size); + else + goto jump_over; + if ((*cmp)((PTR) mid, (PTR) lo) < 0) + SWAP(mid, lo, size); + jump_over:; + memcpy(pivot, mid, size); + pivot = pivot_buffer; + + left_ptr = lo + size; + right_ptr = hi - size; + + /* Here's the famous ``collapse the walls'' section of quicksort. + Gotta like those tight inner loops! They are the main reason + that this algorithm runs much faster than others. */ + do + { + while ((*cmp)((PTR) left_ptr, (PTR) pivot) < 0) + left_ptr += size; + + while ((*cmp)((PTR) pivot, (PTR) right_ptr) < 0) + right_ptr -= size; + + if (left_ptr < right_ptr) + { + SWAP(left_ptr, right_ptr, size); + left_ptr += size; + right_ptr -= size; + } + else if (left_ptr == right_ptr) + { + left_ptr += size; + right_ptr -= size; + break; + } + } + while (left_ptr <= right_ptr); + + /* Set up pointers for next iteration. First determine whether + left and right partitions are below the threshold size. If so, + ignore one or both. Otherwise, push the larger partition's + bounds on the stack and continue sorting the smaller one. */ + + if ((size_t) (right_ptr - lo) <= max_thresh) + { + if ((size_t) (hi - left_ptr) <= max_thresh) + /* Ignore both small partitions. */ + POP(lo, hi); + else + /* Ignore small left partition. */ + lo = left_ptr; + } + else if ((size_t) (hi - left_ptr) <= max_thresh) + /* Ignore small right partition. */ + hi = right_ptr; + else if ((right_ptr - lo) > (hi - left_ptr)) + { + /* Push larger left partition indices. */ + PUSH(lo, right_ptr); + lo = left_ptr; + } + else + { + /* Push larger right partition indices. */ + PUSH(left_ptr, hi); + hi = right_ptr; + } + } + } + + /* Once the BASE_PTR array is partially sorted by quicksort the rest + is completely sorted using insertion sort, since this is efficient + for partitions below MAX_THRESH size. BASE_PTR points to the beginning + of the array to sort, and END_PTR points at the very last element in + the array (*not* one beyond it!). */ + +#define min(x, y) ((x) < (y) ? (x) : (y)) + + { + char *CONST end_ptr = &base_ptr[size * (total_elems - 1)]; + char *tmp_ptr = base_ptr; + char *thresh = min(end_ptr, base_ptr + max_thresh); + register char *run_ptr; + + /* Find smallest element in first threshold and place it at the + array's beginning. This is the smallest array element, + and the operation speeds up insertion sort's inner loop. */ + + for (run_ptr = tmp_ptr + size; run_ptr <= thresh; run_ptr += size) + if ((*cmp)((PTR) run_ptr, (PTR) tmp_ptr) < 0) + tmp_ptr = run_ptr; + + if (tmp_ptr != base_ptr) + SWAP(tmp_ptr, base_ptr, size); + + /* Insertion sort, running from left-hand-side up to right-hand-side. */ + + run_ptr = base_ptr + size; + while ((run_ptr += size) <= end_ptr) + { + tmp_ptr = run_ptr - size; + while ((*cmp)((PTR) run_ptr, (PTR) tmp_ptr) < 0) + tmp_ptr -= size; + + tmp_ptr += size; + if (tmp_ptr != run_ptr) + { + char *trav; + + trav = run_ptr + size; + while (--trav >= run_ptr) + { + char c = *trav; + char *hi, *lo; + + for (hi = lo = trav; (lo -= size) >= tmp_ptr; hi = lo) + *hi = *lo; + *hi = c; + } + } + } + } +} + diff --git a/1/newlibc/ansi/rand.c b/1/newlibc/ansi/rand.c new file mode 100755 index 0000000..7082bcb --- /dev/null +++ b/1/newlibc/ansi/rand.c @@ -0,0 +1,19 @@ +#include + +/* we're useing GGUBS - should work, but it isn't the best algorithm */ + +static unsigned long _seed; + +int rand(void) +{ + if (!_seed) + _seed++; + _seed *= 16807; + _seed %= 0x7fffffff; + return _seed-1; +} + +void srand(unsigned int seed) +{ + _seed = seed; +} diff --git a/1/newlibc/ansi/strerror.c b/1/newlibc/ansi/strerror.c new file mode 100755 index 0000000..55baf32 --- /dev/null +++ b/1/newlibc/ansi/strerror.c @@ -0,0 +1,60 @@ +#include + +/* + * Yeah, I obviously put down a lot of thinking in the error messages. + * Linus + */ + +char * sys_errlist[] = { + "Unknown error", + "Not owner", + "No such file or directory", + "No such process", + "Interrupted system call", + "I/O error", + "No such device", + "Arg list too big", + "Unable to exec binary file", + "Bad file nr", + "No children", + "Try again", + "Out of memory", + "EACCES", + "EFAULT", + "ENOTBLK", + "EBUSY", + "EEXIST", + "EXDEV", + "ENODEV", + "ENOTDIR", + "EISDIR", + "EINVAL", + "ENFILE", + "EMFILE", + "ENOTTY", + "ETXTBSY", + "EFBIG", + "ENOSPC", + "ESPIPE", + "EROFS", + "EMLINK", + "EPIPE", + "EDOM", + "ERANGE", + "EDEADLK", + "ENAMETOOLONG", + "ENOLCK", + "ENOSYS", + "ENOTEMPTY"}; + +#define NR_ERRORS ((sizeof (sys_errlist))/(sizeof(char *))-1) + +int sys_nerr = NR_ERRORS; + +char * strerror(int n) +{ + if (n<0 || n>NR_ERRORS) + return ("unknown error"); + return sys_errlist[n]; +} + diff --git a/1/newlibc/ansi/strftime.c b/1/newlibc/ansi/strftime.c new file mode 100755 index 0000000..87cc995 --- /dev/null +++ b/1/newlibc/ansi/strftime.c @@ -0,0 +1,312 @@ +/* + * strftime.c + * + * Public-domain relatively quick-and-dirty implemenation of + * ANSI library routine for System V Unix systems. + * + * If you want stuff in the System V ascftime routine, add the SYSV_EXT define. + * For stuff needed to implement the P1003.2 date command, add POSIX2_DATE. + * + * The code for %c, %x, and %X is my best guess as to what's "appropriate". + * This version ignores LOCALE information. + * It also doesn't worry about multi-byte characters. + * So there. + * + * Arnold Robbins + * January, February, March, 1991 + * + * Fixes from ado@elsie.nci.nih.gov + * February 1991 + */ + +#include +#include +#include +#include +#include + +static int weeknumber(const struct tm *timeptr, int firstweekday); + +static char *tzname[2] = {"",""}; +int daylight = 1; + +#define SYSV_EXT 1 /* stuff in System V ascftime routine */ +#define POSIX2_DATE 1 /* stuff in Posix 1003.2 date command */ +#define VMS_EXT 1 /* include %V for VMS date format */ + +#if defined(POSIX2_DATE) && ! defined(SYSV_EXT) +#define SYSV_EXT 1 +#endif + +/* strftime --- produce formatted time */ + +size_t strftime(char *s, size_t maxsize, const char *format, + const struct tm *timeptr) +{ + char *endp = s + maxsize; + char *start = s; + char tbuf[100]; + int i; + static short first = 1; + + /* various tables, useful in North America */ + static char *days_a[] = { + "Sun", "Mon", "Tue", "Wed", + "Thu", "Fri", "Sat", + }; + static char *days_l[] = { + "Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday", + }; + static char *months_a[] = { + "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", + }; + static char *months_l[] = { + "January", "February", "March", "April", + "May", "June", "July", "August", "September", + "October", "November", "December", + }; + static char *ampm[] = { "AM", "PM", }; + + if (s == NULL || format == NULL || timeptr == NULL || maxsize == 0) + return 0; + + if (strchr(format, '%') == NULL && strlen(format) + 1 >= maxsize) + return 0; + + if (first) { + tzset(); + first = 0; + } + + for (; *format && s < endp - 1; format++) { + tbuf[0] = '\0'; + if (*format != '%') { + *s++ = *format; + continue; + } + again: + switch (*++format) { + case '\0': + *s++ = '%'; + goto out; + + case '%': + *s++ = '%'; + continue; + + case 'a': /* abbreviated weekday name */ + if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6) + strcpy(tbuf, "?"); + else + strcpy(tbuf, days_a[timeptr->tm_wday]); + break; + + case 'A': /* full weekday name */ + if (timeptr->tm_wday < 0 || timeptr->tm_wday > 6) + strcpy(tbuf, "?"); + else + strcpy(tbuf, days_l[timeptr->tm_wday]); + break; + +#ifdef SYSV_EXT + case 'h': /* abbreviated month name */ +#endif + case 'b': /* abbreviated month name */ + if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11) + strcpy(tbuf, "?"); + else + strcpy(tbuf, months_a[timeptr->tm_mon]); + break; + + case 'B': /* full month name */ + if (timeptr->tm_mon < 0 || timeptr->tm_mon > 11) + strcpy(tbuf, "?"); + else + strcpy(tbuf, months_l[timeptr->tm_mon]); + break; + + case 'c': /* appropriate date and time representation */ + sprintf(tbuf, "%s %s %2d %02d:%02d:%02d %d", + days_a[timeptr->tm_wday], + months_a[timeptr->tm_mon], + timeptr->tm_mday, + timeptr->tm_hour, + timeptr->tm_min, + timeptr->tm_sec, + timeptr->tm_year + 1900); + break; + + case 'd': /* day of the month, 01 - 31 */ + sprintf(tbuf, "%02d", timeptr->tm_mday); + break; + + case 'H': /* hour, 24-hour clock, 00 - 23 */ + sprintf(tbuf, "%02d", timeptr->tm_hour); + break; + + case 'I': /* hour, 12-hour clock, 01 - 12 */ + i = timeptr->tm_hour; + if (i == 0) + i = 12; + else if (i > 12) + i -= 12; + sprintf(tbuf, "%02d", i); + break; + + case 'j': /* day of the year, 001 - 366 */ + sprintf(tbuf, "%03d", timeptr->tm_yday + 1); + break; + + case 'm': /* month, 01 - 12 */ + sprintf(tbuf, "%02d", timeptr->tm_mon + 1); + break; + + case 'M': /* minute, 00 - 59 */ + sprintf(tbuf, "%02d", timeptr->tm_min); + break; + + case 'p': /* am or pm based on 12-hour clock */ + if (timeptr->tm_hour < 12) + strcpy(tbuf, ampm[0]); + else + strcpy(tbuf, ampm[1]); + break; + + case 'S': /* second, 00 - 61 */ + sprintf(tbuf, "%02d", timeptr->tm_sec); + break; + + case 'U': /* week of year, Sunday is first day of week */ + sprintf(tbuf, "%d", weeknumber(timeptr, 0)); + break; + + case 'w': /* weekday, Sunday == 0, 0 - 6 */ + sprintf(tbuf, "%d", timeptr->tm_wday); + break; + + case 'W': /* week of year, Monday is first day of week */ + sprintf(tbuf, "%d", weeknumber(timeptr, 1)); + break; + + case 'x': /* appropriate date representation */ + sprintf(tbuf, "%s %s %2d %d", + days_a[timeptr->tm_wday], + months_a[timeptr->tm_mon], + timeptr->tm_mday, + timeptr->tm_year + 1900); + break; + + case 'X': /* appropriate time representation */ + sprintf(tbuf, "%02d:%02d:%02d", + timeptr->tm_hour, + timeptr->tm_min, + timeptr->tm_sec); + break; + + case 'y': /* year without a century, 00 - 99 */ + i = timeptr->tm_year % 100; + sprintf(tbuf, "%d", i); + break; + + case 'Y': /* year with century */ + sprintf(tbuf, "%d", 1900 + timeptr->tm_year); + break; + + case 'Z': /* time zone name or abbrevation */ + i = 0; + if (daylight && timeptr->tm_isdst) + i = 1; + strcpy(tbuf, tzname[i]); + break; + +#ifdef SYSV_EXT + case 'n': /* same as \n */ + tbuf[0] = '\n'; + tbuf[1] = '\0'; + break; + + case 't': /* same as \t */ + tbuf[0] = '\t'; + tbuf[1] = '\0'; + break; + + case 'D': /* date as %m/%d/%y */ + strftime(tbuf, sizeof tbuf, "%m/%d/%y", timeptr); + break; + + case 'e': /* day of month, blank padded */ + sprintf(tbuf, "%2d", timeptr->tm_mday); + break; + + case 'r': /* time as %I:%M:%S %p */ + strftime(tbuf, sizeof tbuf, "%I:%M:%S %p", timeptr); + break; + + case 'R': /* time as %H:%M */ + strftime(tbuf, sizeof tbuf, "%H:%M", timeptr); + break; + + case 'T': /* time as %H:%M:%S */ + strftime(tbuf, sizeof tbuf, "%H:%M:%S", timeptr); + break; +#endif + + +#ifdef VMS_EXT + case 'V': /* date as dd-bbb-YYYY */ + sprintf(tbuf, "%2d-%3.3s-%4d", + timeptr->tm_mday, + months_a[timeptr->tm_mon], + timeptr->tm_year + 1900); + for (i = 3; i < 6; i++) + if (islower(tbuf[i])) + tbuf[i] = toupper(tbuf[i]); + break; +#endif + + +#ifdef POSIX2_DATE + case 'C': + sprintf(tbuf, "%02d", (timeptr->tm_year + 1900) / 100); + break; + + + case 'E': + case 'O': + /* POSIX locale extensions, ignored for now */ + goto again; +#endif + default: + tbuf[0] = '%'; + tbuf[1] = *format; + tbuf[2] = '\0'; + break; + } + i = strlen(tbuf); + if (i) + if (s + i < endp - 1) { + strcpy(s, tbuf); + s += i; + } else + return 0; + } +out: + if (s < endp && *format == '\0') { + *s = '\0'; + return (s - start); + } else + return 0; +} + +/* weeknumber --- figure how many weeks into the year */ + +static int weeknumber(const struct tm *timeptr, int firstweekday) +{ + if (firstweekday == 0) + return (timeptr->tm_yday + 7 - timeptr->tm_wday) / 7; + else + return (timeptr->tm_yday + 7 - + (timeptr->tm_wday ? (timeptr->tm_wday - 1) : 6)) / 7; +} diff --git a/1/newlibc/ansi/string.c b/1/newlibc/ansi/string.c new file mode 100755 index 0000000..dd28670 --- /dev/null +++ b/1/newlibc/ansi/string.c @@ -0,0 +1,13 @@ +#ifndef __GNUC__ +#error I want gcc! +#endif + +/* + * Quick and dirty way of getting all the string routines into the lib. + * Linus + */ + +#define extern +#define inline +#define __LIBRARY__ +#include diff --git a/1/newlibc/ansi/strtol.c b/1/newlibc/ansi/strtol.c new file mode 100755 index 0000000..fc3c94e --- /dev/null +++ b/1/newlibc/ansi/strtol.c @@ -0,0 +1,91 @@ +#include +#include +#include +#include + +/* + * strtoul etc... Hope it works. Linus + */ + +/* ok, this isn't portable, but it works */ + +#define do_mul(base,result,overflow) \ +__asm__("mull %3":"=a" (result),"=d" (overflow):"0" (result),"g" (base)) + +#define NUM(c) (isdigit(c)?c-'0':islower(c)?c-'a'+10:isupper(c)?c-'A'+10:127) + +static unsigned long _strtoul(const char * s, char **endp, int base) +{ + unsigned long overflow,num,result; + + if (!base) + if (*s=='0') + if (toupper(s[1])=='X') + base=16; + else + base=8; + else + base=10; + if (base == 16 && *s=='0' && toupper(s[1])=='X') + s += 2; + overflow = 1; /* forces error if no while */ + result = 0; + while ((num=NUM(*s))36) + return LONG_MAX; + while (isspace(*s)) + s++; + *endp = (char *) s; + if (sign=(*s=='-')) + s++; + result = _strtoul(s,endp,base); + if (!sign && result > (unsigned) LONG_MAX) { + errno = ERANGE; + return LONG_MAX; + } else if (sign && result > (unsigned) LONG_MAX+1) { + errno = ERANGE; + return LONG_MIN; + } + return sign?-result:result; +} + +unsigned long strtoul(const char * s, char **endp, int base) +{ + char * tmp; + + if (!endp) /* tmp is never really used, this just */ + endp = &tmp; /* is a hack so that we never have to check */ + *endp = (char *) s; + if (base<0 || base==1 || base>36) { + errno = ERANGE; + return ULONG_MAX; + } + while (isspace(*s)) + s++; + *endp = (char *) s; + return _strtoul(s,endp,base); +} + diff --git a/1/newlibc/ansi/system.c b/1/newlibc/ansi/system.c new file mode 100755 index 0000000..f6dfc2c --- /dev/null +++ b/1/newlibc/ansi/system.c @@ -0,0 +1,30 @@ +#include +#include +#include +#include +#include + +/* + * Urgh. If this works I'm surprised. Linus + * + * Should be updated to use sigactions, I think. + */ + +int system(const char * cmd) +{ + int ret, pid, waitstat; + void (*sigint) (), (*sigquit) (); + + if ((pid = fork()) == 0) { + execl("/bin/sh", "sh", "-c", cmd, NULL); + exit(127); + } + if (pid < 0) return(127 << 8); + sigint = signal(SIGINT, SIG_IGN); + sigquit = signal(SIGQUIT, SIG_IGN); + while ((waitstat = wait(&ret)) != pid && waitstat != -1); + if (waitstat == -1) ret = -1; + signal(SIGINT, sigint); + signal(SIGQUIT, sigquit); + return(ret); +} diff --git a/1/newlibc/ansi/tzset.c b/1/newlibc/ansi/tzset.c new file mode 100755 index 0000000..3ea5473 --- /dev/null +++ b/1/newlibc/ansi/tzset.c @@ -0,0 +1,47 @@ +#include +#include +#include + +/* + * More of these damn time-functions. I hope somebody has a complete + * PD library out there. Linus + */ + +static char tz1[1024]; +static char tz2[1024]; + +char *tzname[2] = { + tz1, tz2 +}; +extern int daylight; + +/* I don't know how to implement this - the results are ... */ +static char *timezone(int minutes, int dst) +{ + static char tmp[40]; + + if (dst) + minutes += 60; + strcpy(tmp,"GMT"); + if (!minutes) + return tmp; + if (minutes<0) { + tmp[3] = '-'; + minutes = -minutes; + } else + tmp[3] = '+'; + tmp[4] = '0'+(minutes/60); + tmp[5] = 0; + return tmp; +} + +void tzset(void) +{ + struct timeval tp; + struct timezone tz; + + gettimeofday(&tp, &tz); + strcpy(tz1, timezone(tz.tz_minuteswest, 0)); + strcpy(tz2, timezone(tz.tz_minuteswest, 1)); + daylight = tz.tz_dsttime; +} diff --git a/1/newlibc/copying.dj b/1/newlibc/copying.dj new file mode 100755 index 0000000..63a39a1 --- /dev/null +++ b/1/newlibc/copying.dj @@ -0,0 +1,46 @@ +This is the file "copying.dj". + + Copyright Information for sources and executables that are marked + Copyright (C) DJ Delorie + 24 Kirsten Ave + Rochester NH 03867-2954 + +This document is Copyright (C) DJ Delorie and may be distributed +verbatim, but changing it is not allowed. + +Source code and executables copyright DJ Delorie are referred to as +"djcode" in this document. + +Source code copyright DJ Delorie is distributed under the terms of the +GNU General Public Licence, with the following exceptions: + + 1 If the user of this software develops an application that requires + djcode to run, and that application is distributed under the terms + of the GNU General Public License (GPL), a binary executable of + djcode may be distributed with binary executables of the application, + and source files for djcode must be available with source files for + the application, under the terms of the GNU GPL. + + 2 If the user of this software develops an application that requires + djcode to run, and that application is NOT distributed under the terms + of the GNU General Public License (GPL), a binary executable of + djcode may be distributed with binary executables of the application, + provided a royalty of 5% of the total sale price or $5 (whichever is + more) per copy sold is paid to DJ Delorie (at the address above). + + 3 A person or organization who develops software that requires djcode + but does not distribute that software under the terms of the GNU GPL + relinquishes all rights to obtain or redistribute the source code + for djcode, including any rights granted by the GNU General Public + License, and may only distribute executables of djcode under the + terms of exception 2, above. + + Basically, the GNU GPL only applies to my code if it applies to your code. + +A copy of the file "COPYING" is included with this document. If you did not +receive a copy of "COPYING", you may obtain one from whence this document +was obtained, or by writing: + Free Software Foundation + 675 Mass Ave + Cambridge, MA 02139 + USA diff --git a/1/newlibc/crt/._Makefile b/1/newlibc/crt/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/crt/._crt0.s b/1/newlibc/crt/._crt0.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/crt/Makefile b/1/newlibc/crt/Makefile new file mode 100755 index 0000000..4219597 --- /dev/null +++ b/1/newlibc/crt/Makefile @@ -0,0 +1,40 @@ +# +# Makefile for crt0.o of Linux +# +#AR =/usr/local/bin/gar +AR =/usr/local/bin/ar +#AS =/usr/local/bin/gcc-as +AS =/usr/local/bin/as +#LD =/usr/local/bin/gld +LD =/usr/local/bin/ld +RANLIB =/usr/local/bin/ranlib +LDFLAGS =-s -x +CC =/usr/local/bin/gcc -B/usr/local/bin/ -v +#CC =/local/bin/gcc-i386-sysv -v +INC =-nostdinc -I. -I../include +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + $(INC)# -DNEW_CRT0 +CPP =$(CC) -E $(INC) +RM =/usr/bin/rm + +.c.s: + $(CC) $(CFLAGS) -S -o $*.s $< +.s.o: + $(CC) -c -o $*.o $< +.c.o: + $(CC) $(CFLAGS) -c -o $*.o $< + +OBJS = crt0.o + +all: $(OBJS) + +clean: + $(RM) -f core *.o *.a tmp_make + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/crt/crt0.s b/1/newlibc/crt/crt0.s new file mode 100755 index 0000000..473dc1a --- /dev/null +++ b/1/newlibc/crt/crt0.s @@ -0,0 +1,55 @@ + .text + + .globl _environ + +__entry: + fldcw init_cw +# movl $45,%eax +# movl $0,%ebx +# int $0x80 +# movl %eax,____brk_addr + movl 8(%esp),%eax + movl %eax,_environ + call _main + pushl %eax +1: call _exit + jmp 1b + + .data + .align 2 +_environ: + .long 0 +init_cw: + .word 0x0262 + +/* Here is the dirty part. Settup up your 387 through the control word + * (cw) register. + * + * 15-13 12 11-10 9-8 7-6 5 4 3 2 1 0 + * | reserved | IC | RC | PC | reserved | PM | UM | OM | ZM | DM | IM + * + * IM: Invalid operation mask + * DM: Denormalized operand mask + * ZM: Zero-divide mask + * OM: Overflow mask + * UM: Underflow mask + * PM: Precision (inexact result) mask + * + * Mask bit is 1 means no interrupt. + * + * PC: Precision control + * 11 - round to extended precision + * 10 - round to double precision + * 00 - round to single precision + * + * RC: Rounding control + * 00 - rounding to nearest + * 01 - rounding down (toward - infinity) + * 10 - rounding up (toward + infinity) + * 11 - rounding toward zero + * + * IC: Infinity control + * That is for 8087 and 80287 only. + * + * The hardware default is 0x037f. I choose 0x0262. + */ diff --git a/1/newlibc/dirent/._Makefile b/1/newlibc/dirent/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/dirent/._closedir.c b/1/newlibc/dirent/._closedir.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/dirent/._opendir.c b/1/newlibc/dirent/._opendir.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/dirent/._readdir.c b/1/newlibc/dirent/._readdir.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/dirent/._rewinddir.c b/1/newlibc/dirent/._rewinddir.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/dirent/Makefile b/1/newlibc/dirent/Makefile new file mode 100755 index 0000000..827198c --- /dev/null +++ b/1/newlibc/dirent/Makefile @@ -0,0 +1,46 @@ +# +# Makefile for the direntry-library functions +# + +LIB =../Libc.a +#AR =gar +#AS =gas +#LD =gld +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =gcc +INC =-nostdinc -I../include +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions $(INC) +CPP =$(CC) -E $(INC) + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(CC) -c -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = closedir.o opendir.o readdir.o rewinddir.o + +all: library + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/dirent/closedir.c b/1/newlibc/dirent/closedir.c new file mode 100755 index 0000000..284ced4 --- /dev/null +++ b/1/newlibc/dirent/closedir.c @@ -0,0 +1,24 @@ +/* + * Simple dirent routines for Linux. + * + * (C) 1991 Linus Torvalds + */ + +#include +#include +#include +#include + +int closedir(DIR * dir) +{ + int fd; + + if (!dir) { + errno = EBADF; + return -1; + } + fd = dir->dd_fd; + free(dir->dd_buf); + free(dir); + return close(fd); +} diff --git a/1/newlibc/dirent/opendir.c b/1/newlibc/dirent/opendir.c new file mode 100755 index 0000000..d20210b --- /dev/null +++ b/1/newlibc/dirent/opendir.c @@ -0,0 +1,31 @@ +/* + * Simple dirent routines for Linux. + * + * (C) 1991 Linus Torvalds + */ + +#include +#include +#include +#include +#include +#include + +DIR * opendir(const char * dirname) +{ + int fd; + struct stat stat_buf; + DIR * ptr; + + if ((fd = open(dirname,O_RDONLY))<0) + return NULL; + if (fstat(fd,&stat_buf)<0 || + !S_ISDIR(stat_buf.st_mode) || + !(ptr=malloc(sizeof(*ptr)))) { + close(fd); + return NULL; + } + memset(ptr,0,sizeof(*ptr)); + ptr->dd_fd = fd; + return ptr; +} diff --git a/1/newlibc/dirent/readdir.c b/1/newlibc/dirent/readdir.c new file mode 100755 index 0000000..07b3778 --- /dev/null +++ b/1/newlibc/dirent/readdir.c @@ -0,0 +1,46 @@ +/* + * Simple dirent routines for Linux. + * + * (C) 1991 Linus Torvalds + */ + +#include +#include +#include +#include +#include +#include + +static struct dirent result; + +struct dirent * readdir(DIR * dir) +{ + struct direct * ptr; + + if (!dir) { + errno = EBADF; + return NULL; + } + if (!dir->dd_buf) + if (!(dir->dd_buf = malloc(DIRBUF))) + return NULL; + else + dir->dd_size = dir->dd_loc = 0; + while (1) { + if (dir->dd_size <= dir->dd_loc) { + dir->dd_loc = 0; + dir->dd_size = read(dir->dd_fd,dir->dd_buf,DIRBUF); + } + if (dir->dd_size <= 0) + return NULL; + ptr = (struct direct *) (dir->dd_loc + dir->dd_buf); + dir->dd_loc += sizeof (*ptr); + if (!ptr->d_ino) + continue; + result.d_ino = ptr->d_ino; + strncpy(result.d_name,ptr->d_name,NAME_MAX); + result.d_name[NAME_MAX] = 0; + result.d_reclen = strlen(result.d_name); + return &result; + } +} diff --git a/1/newlibc/dirent/rewinddir.c b/1/newlibc/dirent/rewinddir.c new file mode 100755 index 0000000..4d0e975 --- /dev/null +++ b/1/newlibc/dirent/rewinddir.c @@ -0,0 +1,19 @@ +/* + * Simple dirent routines for Linux. + * + * (C) 1991 Linus Torvalds + */ + +#include +#include +#include + +void rewinddir(DIR * dir) +{ + if (!dir) { + errno = EBADF; + return; + } + dir->dd_size = dir->dd_loc = 0; + lseek(dir->dd_fd,0L,SEEK_SET); +} diff --git a/1/newlibc/grp/._Makefile b/1/newlibc/grp/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/grp/._fgetgrent.c b/1/newlibc/grp/._fgetgrent.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/grp/._getgrent.c b/1/newlibc/grp/._getgrent.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/grp/._getgrgid.c b/1/newlibc/grp/._getgrgid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/grp/._getgrnam.c b/1/newlibc/grp/._getgrnam.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/grp/._grpopen.c b/1/newlibc/grp/._grpopen.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/grp/._grpread.c b/1/newlibc/grp/._grpread.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/grp/._initgroups.c b/1/newlibc/grp/._initgroups.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/grp/Makefile b/1/newlibc/grp/Makefile new file mode 100755 index 0000000..3f40ef7 --- /dev/null +++ b/1/newlibc/grp/Makefile @@ -0,0 +1,44 @@ +# +# Makefile for some ansi-library functions +# + +LIB =../Libc.a +AR =gar +AS =gas +LD =gld +LDFLAGS =-s -x +CC =gcc +#INC =-nostdinc -I/linux/usr/include +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions $(INC) +CPP =(CC) -E $(INC) + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(CC) -c -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = fgetgrent.o getgrent.o getgrgid.o getgrnam.o grpopen.o \ + grpread.o initgroups.o + +all: library + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/grp/fgetgrent.c b/1/newlibc/grp/fgetgrent.c new file mode 100755 index 0000000..bef3e3f --- /dev/null +++ b/1/newlibc/grp/fgetgrent.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include + + +/* Read a group entry from STREAM. */ +struct group * +DEFUN(fgetgrent, (stream), FILE *stream) +{ + static PTR info = NULL; + if (info == NULL) + { + info = __grpalloc(); + if (info == NULL) + return NULL; + } + + return __grpread(stream, info); +} diff --git a/1/newlibc/grp/getgrent.c b/1/newlibc/grp/getgrent.c new file mode 100755 index 0000000..105572f --- /dev/null +++ b/1/newlibc/grp/getgrent.c @@ -0,0 +1,67 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + +static FILE *stream = NULL; + +/* Rewind the stream. */ +void +DEFUN_VOID(setgrent) +{ + if (stream != NULL) + rewind(stream); +} + + +/* Close the stream. */ +void +DEFUN_VOID(endgrent) +{ + if (stream != NULL) + { + (void) fclose(stream); + stream = NULL; + } +} + + +/* Read an entry from the stream. */ +struct group * +DEFUN_VOID(getgrent) +{ + static PTR info = NULL; + if (info == NULL) + { + info = __grpalloc(); + if (info == NULL) + return(NULL); + } + + if (stream == NULL) + { + stream = __grpopen(); + if (stream == NULL) + return(NULL); + } + + return(__grpread(stream, info)); +} diff --git a/1/newlibc/grp/getgrgid.c b/1/newlibc/grp/getgrgid.c new file mode 100755 index 0000000..1375f5f --- /dev/null +++ b/1/newlibc/grp/getgrgid.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +/* Search for an entry with a matching group ID. */ +struct group * +DEFUN(getgrgid, (gid), register gid_t gid) +{ + static PTR info = NULL; + register FILE *stream; + register struct group *g; + + if (info == NULL) + { + info = __grpalloc(); + if (info == NULL) + return NULL; + } + + stream = __grpopen(); + if (stream == NULL) + return NULL; + + while ((g = __grpread(stream, info)) != NULL) + if (g->gr_gid == (gid_t) gid) + break; + + (void) fclose(stream); + return g; +} diff --git a/1/newlibc/grp/getgrnam.c b/1/newlibc/grp/getgrnam.c new file mode 100755 index 0000000..1f88ea3 --- /dev/null +++ b/1/newlibc/grp/getgrnam.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +/* Search for an entry with a matching name. */ +struct group * +DEFUN(getgrnam, (name), register CONST char *name) +{ + static PTR info = NULL; + register FILE *stream; + register struct group *g; + + if (info == NULL) + { + info = __grpalloc(); + if (info == NULL) + return NULL; + } + + stream = __grpopen(); + if (stream == NULL) + return NULL; + + while ((g = __grpread(stream, info)) != NULL) + if (!strcmp(g->gr_name, name)) + break; + + (void) fclose(stream); + return g; +} diff --git a/1/newlibc/grp/grpopen.c b/1/newlibc/grp/grpopen.c new file mode 100755 index 0000000..77d1597 --- /dev/null +++ b/1/newlibc/grp/grpopen.c @@ -0,0 +1,28 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +/* Return a new stream open on the group file. */ +FILE * +DEFUN_VOID(__grpopen) +{ + return fopen("/etc/group", "r"); +} diff --git a/1/newlibc/grp/grpread.c b/1/newlibc/grp/grpread.c new file mode 100755 index 0000000..bf288a5 --- /dev/null +++ b/1/newlibc/grp/grpread.c @@ -0,0 +1,132 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* This is the function that all the others are based on. + The format of the group file is known only here. */ + +/* Structure containing info kept by each __grpread caller. */ +typedef struct + { +#define NAME_SIZE 8 +#define PASSWD_SIZE 20 +#define MEMLIST_SIZE 1000 + char buf[NAME_SIZE + 1 + PASSWD_SIZE + 1 + 20 + 1 + 20 + MEMLIST_SIZE + 1]; + size_t max_members; + char **members; + struct group g; + } grpread_info; + + +/* Return a chunk of memory containing a pre-initialized `grpread_info'. */ +PTR +DEFUN_VOID(__grpalloc) +{ + grpread_info *info = (PTR) malloc(sizeof(grpread_info)); + if (info == NULL) + return NULL; + + info->max_members = 5; + info->members = (char **) malloc(5 * sizeof(char *)); + if (info->members == NULL) + { + free((PTR) info); + return NULL; + } + + return info; +} + +/* Read a group entry from STREAM, filling in G. */ +struct group * +DEFUN(__grpread, (stream, g), FILE *stream AND PTR CONST g) +{ + register grpread_info *CONST info = (grpread_info *) g; + char *start, *end; + register size_t i; + + /* Idiocy checks. */ + if (stream == NULL) + { + errno = EINVAL; + return NULL; + } + + if (fgets (info->buf, sizeof(info->buf), stream) == NULL) + return NULL; + + start = info->buf; + end = strchr (start, ':'); + if (end == NULL) + return NULL; + *end = '\0'; + info->g.gr_name = start; + + start = end + 1; + end = strchr (start, ':'); + if (end == NULL) + return NULL; + *end = '\0'; + info->g.gr_passwd = start; + + info->g.gr_gid = (gid_t) strtol (end + 1, &end, 10); + if (*end != ':') + return NULL; + + i = 0; + do + { + start = end + 1; + end = strchr (start, ','); + if (end == NULL) + { + end = strchr (start, '\n'); + if (end == start) + break; + if (end == NULL) + return NULL; + *end = '\0'; + end = NULL; + } + else + *end = '\0'; + + if (i == info->max_members - 2) + { + info->max_members += 5; + info->members = (char **) + realloc ((PTR) info->members, info->max_members * sizeof (char *)); + if (info->members == NULL) + return NULL; + } + + info->members[i++] = start; + } while (end != NULL); + info->members[i] = NULL; + info->g.gr_mem = info->members; + + return &info->g; +} diff --git a/1/newlibc/grp/initgroups.c b/1/newlibc/grp/initgroups.c new file mode 100755 index 0000000..e35811f --- /dev/null +++ b/1/newlibc/grp/initgroups.c @@ -0,0 +1,66 @@ +/* Copyright (C) 1989, 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include + + +/* Initialize the group set for the current user + by reading the group database and using all groups + of which USER is a member. Also include GROUP. */ +int +DEFUN(initgroups, (user, group), + CONST char *user AND gid_t group) +{ + static PTR info = NULL; + register FILE *stream; + register struct group *g; + gid_t groups[NGROUPS_MAX]; + register size_t n; + + if (info == NULL) + { + info = __grpalloc(); + if (info == NULL) + return -1; + } + + stream = __grpopen(); + if (stream == NULL) + return -1; + + n = 0; + if (group >= 0) + groups[n++] = group; + + while (n < NGROUPS_MAX && (g = __grpread(stream, info)) != NULL) + if (g->gr_gid != group) + { + register char **m; + + for (m = g->gr_mem; *m != NULL; ++m) + if (!strcmp(*m, user)) + groups[n++] = g->gr_gid; + } + + return setgroups(n, groups); +} diff --git a/1/newlibc/include/._a.out.h b/1/newlibc/include/._a.out.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._ansidecl.h b/1/newlibc/include/._ansidecl.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._ar.h b/1/newlibc/include/._ar.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._asm b/1/newlibc/include/._asm new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._assert.h b/1/newlibc/include/._assert.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._blocksize.h b/1/newlibc/include/._blocksize.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._const.h b/1/newlibc/include/._const.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._ctype.h b/1/newlibc/include/._ctype.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._dirent.h b/1/newlibc/include/._dirent.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._errno.h b/1/newlibc/include/._errno.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._fcntl.h b/1/newlibc/include/._fcntl.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._float.h b/1/newlibc/include/._float.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._getopt.h b/1/newlibc/include/._getopt.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._gnu-stabs.h b/1/newlibc/include/._gnu-stabs.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._grp.h b/1/newlibc/include/._grp.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._limits.h b/1/newlibc/include/._limits.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._linux b/1/newlibc/include/._linux new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._localeinfo.h b/1/newlibc/include/._localeinfo.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._math.h b/1/newlibc/include/._math.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._pwd.h b/1/newlibc/include/._pwd.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._regex.h b/1/newlibc/include/._regex.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._setjmp.h b/1/newlibc/include/._setjmp.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._signal.h b/1/newlibc/include/._signal.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._stdarg.h b/1/newlibc/include/._stdarg.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._stddef.h b/1/newlibc/include/._stddef.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._stdio.h b/1/newlibc/include/._stdio.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._stdlib.h b/1/newlibc/include/._stdlib.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._string.h b/1/newlibc/include/._string.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._strings.h b/1/newlibc/include/._strings.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._sys b/1/newlibc/include/._sys new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._termcap.h b/1/newlibc/include/._termcap.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._termio.h b/1/newlibc/include/._termio.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._termios.h b/1/newlibc/include/._termios.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._time.h b/1/newlibc/include/._time.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._unistd.h b/1/newlibc/include/._unistd.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._utime.h b/1/newlibc/include/._utime.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/._varargs.h b/1/newlibc/include/._varargs.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/a.out.h b/1/newlibc/include/a.out.h new file mode 100755 index 0000000..c6e42bd --- /dev/null +++ b/1/newlibc/include/a.out.h @@ -0,0 +1,222 @@ +/* Gnu a.out.h modified for linux */ +#ifndef __A_OUT_H__ +#define __A_OUT_H__ + +#define __GNU_EXEC_MACROS__ + +struct exec +{ + unsigned long a_magic; /* Use macros N_MAGIC, etc for access */ + unsigned a_text; /* length of text, in bytes */ + unsigned a_data; /* length of data, in bytes */ + unsigned a_bss; /* length of uninitialized data area for file, in bytes */ + unsigned a_syms; /* length of symbol table data in file, in bytes */ + unsigned a_entry; /* start address */ + unsigned a_trsize; /* length of relocation info for text, in bytes */ + unsigned a_drsize; /* length of relocation info for data, in bytes */ +}; + +#ifndef N_MAGIC +#define N_MAGIC(exec) ((exec).a_magic) +#endif + +#ifndef OMAGIC +/* Code indicating object file or impure executable. */ +#define OMAGIC 0407 +/* Code indicating pure executable. */ +#define NMAGIC 0410 +/* Code indicating demand-paged executable. */ +#define ZMAGIC 0413 +#endif /* not OMAGIC */ + +#ifndef N_BADMAG +#define N_BADMAG(x) \ + (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC) +#endif + +#define _N_BADMAG(x) \ + (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \ + && N_MAGIC(x) != ZMAGIC) + +#define _N_HDROFF(x) (SEGMENT_SIZE - sizeof (struct exec)) + +#ifndef N_TXTOFF +#define N_TXTOFF(x) \ + (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec)) +#endif + +#ifndef N_DATOFF +#define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text) +#endif + +#ifndef N_TRELOFF +#define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data) +#endif + +#ifndef N_DRELOFF +#define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize) +#endif + +#ifndef N_SYMOFF +#define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize) +#endif + +#ifndef N_STROFF +#define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms) +#endif + +/* Address of text segment in memory after it is loaded. */ +#ifndef N_TXTADDR +#define N_TXTADDR(x) 0 +#endif + +/* Address of data segment in memory after it is loaded. + Note that it is up to you to define SEGMENT_SIZE + on machines not listed here. */ +#if defined(vax) || defined(hp300) || defined(pyr) +#define SEGMENT_SIZE PAGE_SIZE +#endif +#ifdef hp300 +#define PAGE_SIZE 4096 +#endif +#ifdef sony +#define SEGMENT_SIZE 0x2000 +#endif /* Sony. */ +#ifdef is68k +#define SEGMENT_SIZE 0x20000 +#endif +#if defined(m68k) && defined(PORTAR) +#define PAGE_SIZE 0x400 +#define SEGMENT_SIZE PAGE_SIZE +#endif + +#define PAGE_SIZE 4096 +#define SEGMENT_SIZE 1024 + +#define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1)) + +#define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text) + +#ifndef N_DATADDR +#define N_DATADDR(x) \ + (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \ + : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x)))) +#endif + +/* Address of bss segment in memory after it is loaded. */ +#ifndef N_BSSADDR +#define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data) +#endif + +#ifndef N_NLIST_DECLARED +struct nlist { + union { + char *n_name; + struct nlist *n_next; + long n_strx; + } n_un; + unsigned char n_type; + char n_other; + short n_desc; + unsigned long n_value; +}; +#endif + +#ifndef N_UNDF +#define N_UNDF 0 +#endif +#ifndef N_ABS +#define N_ABS 2 +#endif +#ifndef N_TEXT +#define N_TEXT 4 +#endif +#ifndef N_DATA +#define N_DATA 6 +#endif +#ifndef N_BSS +#define N_BSS 8 +#endif +#ifndef N_COMM +#define N_COMM 18 +#endif +#ifndef N_FN +#define N_FN 15 +#endif + +#ifndef N_EXT +#define N_EXT 1 +#endif +#ifndef N_TYPE +#define N_TYPE 036 +#endif +#ifndef N_STAB +#define N_STAB 0340 +#endif + +/* The following type indicates the definition of a symbol as being + an indirect reference to another symbol. The other symbol + appears as an undefined reference, immediately following this symbol. + + Indirection is asymmetrical. The other symbol's value will be used + to satisfy requests for the indirect symbol, but not vice versa. + If the other symbol does not have a definition, libraries will + be searched to find a definition. */ +#define N_INDR 0xa + +/* The following symbols refer to set elements. + All the N_SET[ATDB] symbols with the same name form one set. + Space is allocated for the set in the text section, and each set + element's value is stored into one word of the space. + The first word of the space is the length of the set (number of elements). + + The address of the set is made into an N_SETV symbol + whose name is the same as the name of the set. + This symbol acts like a N_DATA global symbol + in that it can satisfy undefined external references. */ + +/* These appear as input to LD, in a .o file. */ +#define N_SETA 0x14 /* Absolute set element symbol */ +#define N_SETT 0x16 /* Text set element symbol */ +#define N_SETD 0x18 /* Data set element symbol */ +#define N_SETB 0x1A /* Bss set element symbol */ + +/* This is output from LD. */ +#define N_SETV 0x1C /* Pointer to set vector in data area. */ + +#ifndef N_RELOCATION_INFO_DECLARED + +/* This structure describes a single relocation to be performed. + The text-relocation section of the file is a vector of these structures, + all of which apply to the text section. + Likewise, the data-relocation section applies to the data section. */ + +struct relocation_info +{ + /* Address (within segment) to be relocated. */ + int r_address; + /* The meaning of r_symbolnum depends on r_extern. */ + unsigned int r_symbolnum:24; + /* Nonzero means value is a pc-relative offset + and it should be relocated for changes in its own address + as well as for changes in the symbol or section specified. */ + unsigned int r_pcrel:1; + /* Length (as exponent of 2) of the field to be relocated. + Thus, a value of 2 indicates 1<<2 bytes. */ + unsigned int r_length:2; + /* 1 => relocate with value of symbol. + r_symbolnum is the index of the symbol + in file's the symbol table. + 0 => relocate with the address of a segment. + r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS + (the N_EXT bit may be set also, but signifies nothing). */ + unsigned int r_extern:1; + /* Four bits that aren't used, but when writing an object file + it is desirable to clear them. */ + unsigned int r_pad:4; +}; +#endif /* no N_RELOCATION_INFO_DECLARED. */ + + +#endif /* __A_OUT_GNU_H__ */ diff --git a/1/newlibc/include/ansidecl.h b/1/newlibc/include/ansidecl.h new file mode 100755 index 0000000..c351653 --- /dev/null +++ b/1/newlibc/include/ansidecl.h @@ -0,0 +1,108 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU C Library; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* ANSI and traditional C compatibility macros + + ANSI C is assumed if __STDC__ is #defined. + + Macro ANSI C definition Traditional C definition + ----- ---- - ---------- ----------- - ---------- + PTR `void *' `char *' + LONG_DOUBLE `long double' `double' + CONST `const' `' + VOLATILE `volatile' `' + SIGNED `signed' `' + PTRCONST `void *const' `char *' + + DEFUN(name, arglist, args) + + Defines function NAME. + + ARGLIST lists the arguments, separated by commas and enclosed in + parentheses. ARGLIST becomes the argument list in traditional C. + + ARGS list the arguments with their types. It becomes a prototype in + ANSI C, and the type declarations in traditional C. Arguments should + be separated with `AND'. For functions with a variable number of + arguments, the last thing listed should be `DOTS'. + + DEFUN_VOID(name) + + Defines a function NAME, which takes no arguments. + + EXFUN(name, prototype) + + Is used in an external function declaration. + In ANSI C it is `NAMEPROTOTYPE' (so PROTOTYPE should be enclosed in + parentheses). In traditional C it is `NAME()'. + For a function that takes no arguments, PROTOTYPE should be `(NOARGS)'. + + For example: + extern int EXFUN(printf, (CONST char *format DOTS)); + int DEFUN(fprintf, (stream, format), + FILE *stream AND CONST char *format DOTS) { ... } + void DEFUN_VOID(abort) { ... } +*/ + +#ifndef _ANSIDECL_H + +#define _ANSIDECL_H 1 + + +/* Every source file includes this file, + so they will all get the switch for lint. */ +/* LINTLIBRARY */ + + +#ifdef __STDC__ + +#define PTR void * +#define PTRCONST void *CONST +#define LONG_DOUBLE long double + +#define AND , +#define NOARGS void +#define CONST const +#define VOLATILE volatile +#define SIGNED signed +#define DOTS , ... + +#define EXFUN(name, proto) name proto +#define DEFUN(name, arglist, args) name(args) +#define DEFUN_VOID(name) name(NOARGS) + +#else /* Not ANSI C. */ + +#define PTR char * +#define PTRCONST PTR +#define LONG_DOUBLE double + +#define AND ; +#define NOARGS +#define CONST +#define VOLATILE +#define SIGNED +#define DOTS + +#define EXFUN(name, proto) name() +#define DEFUN(name, arglist, args) name arglist args; +#define DEFUN_VOID(name) name() + +#endif /* ANSI C. */ + + +#endif /* ansidecl.h */ diff --git a/1/newlibc/include/ar.h b/1/newlibc/include/ar.h new file mode 100755 index 0000000..99fac5a --- /dev/null +++ b/1/newlibc/include/ar.h @@ -0,0 +1,20 @@ +/* Typed in by Richard */ +/* minor changes for linux */ +#ifndef _AR_H +#define _AR_H + +#define ARMAG "!\n" +#define SARMAG 8 +#define ARFMAG "`\n" + +struct ar_hdr { + char ar_name[16], + ar_date[12], + ar_uid[6], + ar_gid[6], + ar_mode[8], + ar_size[10], + ar_fmag[2]; +}; + +#endif /* _AR_H */ diff --git a/1/newlibc/include/asm/._io.h b/1/newlibc/include/asm/._io.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/asm/._memory.h b/1/newlibc/include/asm/._memory.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/asm/._segment.h b/1/newlibc/include/asm/._segment.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/asm/._system.h b/1/newlibc/include/asm/._system.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/asm/io.h b/1/newlibc/include/asm/io.h new file mode 100755 index 0000000..d5cc42a --- /dev/null +++ b/1/newlibc/include/asm/io.h @@ -0,0 +1,24 @@ +#define outb(value,port) \ +__asm__ ("outb %%al,%%dx"::"a" (value),"d" (port)) + + +#define inb(port) ({ \ +unsigned char _v; \ +__asm__ volatile ("inb %%dx,%%al":"=a" (_v):"d" (port)); \ +_v; \ +}) + +#define outb_p(value,port) \ +__asm__ ("outb %%al,%%dx\n" \ + "\tjmp 1f\n" \ + "1:\tjmp 1f\n" \ + "1:"::"a" (value),"d" (port)) + +#define inb_p(port) ({ \ +unsigned char _v; \ +__asm__ volatile ("inb %%dx,%%al\n" \ + "\tjmp 1f\n" \ + "1:\tjmp 1f\n" \ + "1:":"=a" (_v):"d" (port)); \ +_v; \ +}) diff --git a/1/newlibc/include/asm/memory.h b/1/newlibc/include/asm/memory.h new file mode 100755 index 0000000..4b0a98e --- /dev/null +++ b/1/newlibc/include/asm/memory.h @@ -0,0 +1,14 @@ +/* + * NOTE!!! memcpy(dest,src,n) assumes ds=es=normal data segment. This + * goes for all kernel functions (ds=es=kernel space, fs=local data, + * gs=null), as well as for all well-behaving user programs (ds=es= + * user data space). This is NOT a bug, as any user program that changes + * es deserves to die if it isn't careful. + */ +#define memcpy(dest,src,n) ({ \ +void * _res = dest; \ +__asm__ ("cld;rep;movsb" \ + ::"D" ((long)(_res)),"S" ((long)(src)),"c" ((long) (n)) \ + :"di","si","cx"); \ +_res; \ +}) diff --git a/1/newlibc/include/asm/segment.h b/1/newlibc/include/asm/segment.h new file mode 100755 index 0000000..c03657f --- /dev/null +++ b/1/newlibc/include/asm/segment.h @@ -0,0 +1,65 @@ +extern inline unsigned char get_fs_byte(const char * addr) +{ + unsigned register char _v; + + __asm__ ("movb %%fs:%1,%0":"=r" (_v):"m" (*addr)); + return _v; +} + +extern inline unsigned short get_fs_word(const unsigned short *addr) +{ + unsigned short _v; + + __asm__ ("movw %%fs:%1,%0":"=r" (_v):"m" (*addr)); + return _v; +} + +extern inline unsigned long get_fs_long(const unsigned long *addr) +{ + unsigned long _v; + + __asm__ ("movl %%fs:%1,%0":"=r" (_v):"m" (*addr)); \ + return _v; +} + +extern inline void put_fs_byte(char val,char *addr) +{ +__asm__ ("movb %0,%%fs:%1"::"r" (val),"m" (*addr)); +} + +extern inline void put_fs_word(short val,short * addr) +{ +__asm__ ("movw %0,%%fs:%1"::"r" (val),"m" (*addr)); +} + +extern inline void put_fs_long(unsigned long val,unsigned long * addr) +{ +__asm__ ("movl %0,%%fs:%1"::"r" (val),"m" (*addr)); +} + +/* + * Someone who knows GNU asm better than I should double check the followig. + * It seems to work, but I don't know if I'm doing something subtly wrong. + * --- TYT, 11/24/91 + * [ nothing wrong here, Linus ] + */ + +extern inline unsigned long get_fs() +{ + unsigned short _v; + __asm__("mov %%fs,%%ax":"=a" (_v):); + return _v; +} + +extern inline unsigned long get_ds() +{ + unsigned short _v; + __asm__("mov %%ds,%%ax":"=a" (_v):); + return _v; +} + +extern inline void set_fs(unsigned long val) +{ + __asm__("mov %0,%%fs"::"a" ((unsigned short) val)); +} + diff --git a/1/newlibc/include/asm/system.h b/1/newlibc/include/asm/system.h new file mode 100755 index 0000000..0b5a21d --- /dev/null +++ b/1/newlibc/include/asm/system.h @@ -0,0 +1,66 @@ +#define move_to_user_mode() \ +__asm__ ("movl %%esp,%%eax\n\t" \ + "pushl $0x17\n\t" \ + "pushl %%eax\n\t" \ + "pushfl\n\t" \ + "pushl $0x0f\n\t" \ + "pushl $1f\n\t" \ + "iret\n" \ + "1:\tmovl $0x17,%%eax\n\t" \ + "movw %%ax,%%ds\n\t" \ + "movw %%ax,%%es\n\t" \ + "movw %%ax,%%fs\n\t" \ + "movw %%ax,%%gs" \ + :::"ax") + +#define sti() __asm__ ("sti"::) +#define cli() __asm__ ("cli"::) +#define nop() __asm__ ("nop"::) + +#define iret() __asm__ ("iret"::) + +#define _set_gate(gate_addr,type,dpl,addr) \ +__asm__ ("movw %%dx,%%ax\n\t" \ + "movw %0,%%dx\n\t" \ + "movl %%eax,%1\n\t" \ + "movl %%edx,%2" \ + : \ + : "i" ((short) (0x8000+(dpl<<13)+(type<<8))), \ + "o" (*((char *) (gate_addr))), \ + "o" (*(4+(char *) (gate_addr))), \ + "d" ((char *) (addr)),"a" (0x00080000)) + +#define set_intr_gate(n,addr) \ + _set_gate(&idt[n],14,0,addr) + +#define set_trap_gate(n,addr) \ + _set_gate(&idt[n],15,0,addr) + +#define set_system_gate(n,addr) \ + _set_gate(&idt[n],15,3,addr) + +#define _set_seg_desc(gate_addr,type,dpl,base,limit) {\ + *(gate_addr) = ((base) & 0xff000000) | \ + (((base) & 0x00ff0000)>>16) | \ + ((limit) & 0xf0000) | \ + ((dpl)<<13) | \ + (0x00408000) | \ + ((type)<<8); \ + *((gate_addr)+1) = (((base) & 0x0000ffff)<<16) | \ + ((limit) & 0x0ffff); } + +#define _set_tssldt_desc(n,addr,type) \ +__asm__ ("movw $104,%1\n\t" \ + "movw %%ax,%2\n\t" \ + "rorl $16,%%eax\n\t" \ + "movb %%al,%3\n\t" \ + "movb $" type ",%4\n\t" \ + "movb $0x00,%5\n\t" \ + "movb %%ah,%6\n\t" \ + "rorl $16,%%eax" \ + ::"a" (addr), "m" (*(n)), "m" (*(n+2)), "m" (*(n+4)), \ + "m" (*(n+5)), "m" (*(n+6)), "m" (*(n+7)) \ + ) + +#define set_tss_desc(n,addr) _set_tssldt_desc(((char *) (n)),addr,"0x89") +#define set_ldt_desc(n,addr) _set_tssldt_desc(((char *) (n)),addr,"0x82") diff --git a/1/newlibc/include/assert.h b/1/newlibc/include/assert.h new file mode 100755 index 0000000..26b5d13 --- /dev/null +++ b/1/newlibc/include/assert.h @@ -0,0 +1,34 @@ +/* Allow this file to be included multiple times + with different settings of NDEBUG. */ +#undef assert +#undef __assert + +#ifdef NDEBUG +#define assert(ignore) ((void)0) +#else + +void __eprintf (); /* Defined in gnulib */ + +#ifdef __STDC__ + +#define assert(expression) \ + ((expression) ? 0 : (__assert (#expression, __FILE__, __LINE__), 0)) + +#define __assert(expression, file, line) \ + (__eprintf ("Failed assertion `%s' at line %d of `%s'.\n", \ + expression, line, file), \ + abort ()) + +#else /* no __STDC__; i.e. -traditional. */ + +#define assert(expression) \ + ((expression) ? 0 : __assert (expression, __FILE__, __LINE__)) + +#define __assert(expression, file, lineno) \ + (__eprintf ("Failed assertion `%s' at line %d of `%s'.\n", \ + "expression", lineno, file), \ + abort ()) + +#endif /* no __STDC__; i.e. -traditional. */ + +#endif diff --git a/1/newlibc/include/blocksize.h b/1/newlibc/include/blocksize.h new file mode 100755 index 0000000..a93c31d --- /dev/null +++ b/1/newlibc/include/blocksize.h @@ -0,0 +1,6 @@ +#ifndef _BLOCK_SIZE_H +#define _BLOCK_SIZE_H + +#define BLOCK_SIZE 1024 /* file system data block size */ + +#endif /* _BLOCK_SIZE_H */ diff --git a/1/newlibc/include/const.h b/1/newlibc/include/const.h new file mode 100755 index 0000000..0f0b88f --- /dev/null +++ b/1/newlibc/include/const.h @@ -0,0 +1,16 @@ +#ifndef _CONST_H + +#define _CONST_H + +#define BUFFER_END 0x200000 + +#define I_TYPE 0170000 +#define I_DIRECTORY 0040000 +#define I_REGULAR 0100000 +#define I_BLOCK_SPECIAL 0060000 +#define I_CHAR_SPECIAL 0020000 +#define I_NAMED_PIPE 0010000 +#define I_SET_UID_BIT 0004000 +#define I_SET_GID_BIT 0002000 + +#endif diff --git a/1/newlibc/include/ctype.h b/1/newlibc/include/ctype.h new file mode 100755 index 0000000..7acf55d --- /dev/null +++ b/1/newlibc/include/ctype.h @@ -0,0 +1,34 @@ +#ifndef _CTYPE_H +#define _CTYPE_H + +#define _U 0x01 /* upper */ +#define _L 0x02 /* lower */ +#define _D 0x04 /* digit */ +#define _C 0x08 /* cntrl */ +#define _P 0x10 /* punct */ +#define _S 0x20 /* white space (space/lf/tab) */ +#define _X 0x40 /* hex digit */ +#define _SP 0x80 /* hard space (0x20) */ + +extern unsigned char _ctype[]; +extern char _ctmp; + +#define isalnum(c) ((_ctype+1)[c]&(_U|_L|_D)) +#define isalpha(c) ((_ctype+1)[c]&(_U|_L)) +#define iscntrl(c) ((_ctype+1)[c]&(_C)) +#define isdigit(c) ((_ctype+1)[c]&(_D)) +#define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_D)) +#define islower(c) ((_ctype+1)[c]&(_L)) +#define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_D|_SP)) +#define ispunct(c) ((_ctype+1)[c]&(_P)) +#define isspace(c) ((_ctype+1)[c]&(_S)) +#define isupper(c) ((_ctype+1)[c]&(_U)) +#define isxdigit(c) ((_ctype+1)[c]&(_D|_X)) + +#define isascii(c) (((unsigned) c)<=0x7f) +#define toascii(c) (((unsigned) c)&0x7f) + +#define tolower(c) (_ctmp=c,isupper(_ctmp)?_ctmp-('A'-'a'):_ctmp) +#define toupper(c) (_ctmp=c,islower(_ctmp)?_ctmp-('a'-'A'):_ctmp) + +#endif diff --git a/1/newlibc/include/dirent.h b/1/newlibc/include/dirent.h new file mode 100755 index 0000000..fb916d7 --- /dev/null +++ b/1/newlibc/include/dirent.h @@ -0,0 +1,33 @@ +/* + -- definitions for SVR3 directory access routines + + last edit: 25-Apr-1987 D A Gwyn + + Prerequisite: +*/ + +/* NOTE! The actual routines by D A Gwyn aren't used in linux - I though + * they were too complicated, so I wrote my own. I use the header files, + * though, as I didn't know what should be in them. + */ + +#include +#include + +#define DIRBUF 8192 /* buffer size for fs-indep. dirs */ + /* must in general be larger than the filesystem buffer size */ + +typedef struct + { + int dd_fd; /* file descriptor */ + int dd_loc; /* offset in block */ + int dd_size; /* amount of valid data */ + char *dd_buf; /* -> directory block */ + } DIR; /* stream data from opendir() */ + +extern DIR *opendir(); +extern struct dirent *readdir(); +extern off_t telldir(); +extern void seekdir(); +extern void rewinddir(); +extern int closedir(); diff --git a/1/newlibc/include/errno.h b/1/newlibc/include/errno.h new file mode 100755 index 0000000..c282f69 --- /dev/null +++ b/1/newlibc/include/errno.h @@ -0,0 +1,60 @@ +#ifndef _ERRNO_H +#define _ERRNO_H + +/* + * ok, as I hadn't got any other source of information about + * possible error numbers, I was forced to use the same numbers + * as minix. + * Hopefully these are posix or something. I wouldn't know (and posix + * isn't telling me - they want $$$ for their f***ing standard). + * + * We don't use the _SIGN cludge of minix, so kernel returns must + * see to the sign by themselves. + * + * NOTE! Remember to change strerror() if you change this file! + */ + +extern int errno; + +#define ERROR 99 +#define EPERM 1 +#define ENOENT 2 +#define ESRCH 3 +#define EINTR 4 +#define EIO 5 +#define ENXIO 6 +#define E2BIG 7 +#define ENOEXEC 8 +#define EBADF 9 +#define ECHILD 10 +#define EAGAIN 11 +#define ENOMEM 12 +#define EACCES 13 +#define EFAULT 14 +#define ENOTBLK 15 +#define EBUSY 16 +#define EEXIST 17 +#define EXDEV 18 +#define ENODEV 19 +#define ENOTDIR 20 +#define EISDIR 21 +#define EINVAL 22 +#define ENFILE 23 +#define EMFILE 24 +#define ENOTTY 25 +#define ETXTBSY 26 +#define EFBIG 27 +#define ENOSPC 28 +#define ESPIPE 29 +#define EROFS 30 +#define EMLINK 31 +#define EPIPE 32 +#define EDOM 33 +#define ERANGE 34 +#define EDEADLK 35 +#define ENAMETOOLONG 36 +#define ENOLCK 37 +#define ENOSYS 38 +#define ENOTEMPTY 39 + +#endif diff --git a/1/newlibc/include/fcntl.h b/1/newlibc/include/fcntl.h new file mode 100755 index 0000000..0eadd32 --- /dev/null +++ b/1/newlibc/include/fcntl.h @@ -0,0 +1,56 @@ +#ifndef _FCNTL_H +#define _FCNTL_H + +/* I don't think this should be included like this, but it's easier */ +#include + +/* open/fcntl - NOCTTY, NDELAY isn't implemented yet */ +#define O_ACCMODE 00003 +#define O_RDONLY 00 +#define O_WRONLY 01 +#define O_RDWR 02 +#define O_CREAT 00100 /* not fcntl */ +#define O_EXCL 00200 /* not fcntl */ +#define O_NOCTTY 00400 /* not fcntl */ +#define O_TRUNC 01000 /* not fcntl */ +#define O_APPEND 02000 +#define O_NONBLOCK 04000 /* not fcntl */ +#define O_NDELAY O_NONBLOCK + +/* Defines for fcntl-commands. Note that currently + * locking isn't supported, and other things aren't really + * tested. + */ +#define F_DUPFD 0 /* dup */ +#define F_GETFD 1 /* get f_flags */ +#define F_SETFD 2 /* set f_flags */ +#define F_GETFL 3 /* more flags (cloexec) */ +#define F_SETFL 4 +#define F_GETLK 5 /* not implemented */ +#define F_SETLK 6 +#define F_SETLKW 7 + +/* for F_[GET|SET]FL */ +#define FD_CLOEXEC 1 /* actually anything with low bit set goes */ + +/* Ok, these are locking features, and aren't implemented at any + * level. POSIX wants them. + */ +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 + +/* Once again - not implemented, but ... */ +struct flock { + short l_type; + short l_whence; + off_t l_start; + off_t l_len; + pid_t l_pid; +}; + +extern int creat(const char * filename,mode_t mode); +extern int fcntl(int fildes,int cmd, ...); +extern int open(const char * filename, int flags, ...); + +#endif diff --git a/1/newlibc/include/float.h b/1/newlibc/include/float.h new file mode 100755 index 0000000..4959d9f --- /dev/null +++ b/1/newlibc/include/float.h @@ -0,0 +1,25 @@ +/* float.h */ +/* Produced by hard-params version 4.1, CWI, Amsterdam */ + +#define FLT_RADIX 2 +#define FLT_MANT_DIG 24 +#define FLT_DIG 6 +#define FLT_ROUNDS 1 +#define FLT_EPSILON ((float)1.19209290e-07) +#define FLT_MIN_EXP (-125) +#define FLT_MIN ((float)1.17549435e-38) +#define FLT_MIN_10_EXP (-37) +#define FLT_MAX_EXP 128 +#define FLT_MAX ((float)3.40282347e+38) +#define FLT_MAX_10_EXP 38 + +#define DBL_MANT_DIG 53 +#define DBL_DIG 15 +#define DBL_EPSILON 2.2204460492503131e-16 +#define DBL_MIN_EXP (-1021) +#define DBL_MIN 2.2250738585072014e-308 +#define DBL_MIN_10_EXP (-307) +#define DBL_MAX_EXP 1024 +#define DBL_MAX 1.7976931348623157e+308 +#define DBL_MAX_10_EXP 308 + diff --git a/1/newlibc/include/getopt.h b/1/newlibc/include/getopt.h new file mode 100755 index 0000000..d3c2048 --- /dev/null +++ b/1/newlibc/include/getopt.h @@ -0,0 +1,11 @@ +#ifndef _GETOPT_H +#define _GETOPT_H + +extern int opterr; +extern int optind; +extern int optopt; +extern char *optarg; + +extern int getopt(int argc, char ** argv, char * opts); + +#endif /* _GETOPT_H */ diff --git a/1/newlibc/include/gnu-stabs.h b/1/newlibc/include/gnu-stabs.h new file mode 100755 index 0000000..e4e58f9 --- /dev/null +++ b/1/newlibc/include/gnu-stabs.h @@ -0,0 +1,83 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifndef __GNU_STABS_H + +#define __GNU_STABS_H 1 + +#ifdef __GNU_STAB__ + +/* Alias a function: + function_alias(creat, _creat, int, (file, mode), + DEFUN(creat, (file, mode), + CONST char *file AND int mode)) + Yes, this is very repetitive. Nothing you can do about it, so shut up. */ +#define function_alias(name, _name, type, args, defun) \ + symbol_alias(_name, name); + +/* Make references to ALIAS refer to SYMBOL. */ +#ifdef __STDC__ +#define symbol_alias(symbol, alias) \ + asm(".stabs \"" "_" #alias "\",11,0,0,0\n"\ + ".stabs \"" "_" #symbol "\",1,0,0,0") +#else +/* Your assembler better grok this right! */ +#define symbol_alias(symbol, alias) \ + asm(".stabs \"_/**/alias\",11,0,0,0\n.stabs \"_/**/symbol\",1,0,0,0") +#endif + +/* Issue a warning message from the linker whenever SYMBOL is referenced. */ +#ifdef __STDC__ +#define warn_references(symbol, msg) \ + asm(".stabs \"" msg "\",30,0,0,0\n" \ + ".stabs \"_" #symbol "\",1,0,0,0") +#else +#define warn_references(symbol, msg) \ + asm(".stabs msg,30,0,0,0\n.stabs \"_/**/symbol\",1,0,0,0") +#endif + +#ifdef __STDC__ +#define stub_warning(name) \ + warn_references(name, \ + "warning: " #name " is not implemented and will always fail") +#else +#define stub_warning(name) \ + warn_references(name, \ + "warning: name is not implemented and will always fail") +#endif + +#ifdef __STDC__ +#define text_set_element(set, symbol) \ + asm(".stabs \"_" #set "\",23,0,0,_" #symbol) +#define data_set_element(set, symbol) \ + asm(".stabs \"_" #set "\",25,0,0,_" #symbol) +#else +#define text_set_element(set, symbol) \ + asm(".stabs \"_/**/set\",23,0,0,_/**/symbol") +#define data_set_element(set, symbol) \ + asm(".stabs \"_/**/set\",25,0,0,_/**/symbol") +#endif + +#else /* No GNU stabs. */ + +#define function_alias(name, _name, type, args, defun) \ + type defun { return name args; } + +#endif /* GNU stabs. */ + +#endif /* gnu-stabs.h */ diff --git a/1/newlibc/include/grp.h b/1/newlibc/include/grp.h new file mode 100755 index 0000000..4830148 --- /dev/null +++ b/1/newlibc/include/grp.h @@ -0,0 +1,101 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* + * POSIX Standard: 9.2.1 Group Database Access + */ + +#ifndef _GRP_H + +#define _GRP_H 1 + +#include +#include + +#define __USE_SVID +#define __USE_BSD +#define __USE_GNU + +/* The group structure. */ +struct group + { + char *gr_name; /* Group name. */ + char *gr_passwd; /* Password. */ + gid_t gr_gid; /* Group ID. */ + char **gr_mem; /* Member list. */ + }; + + +#if defined(__USE_SVID) || defined(__USE_GNU) +#define __need_FILE +#include +#endif + +#ifdef __USE_GNU +/* Return a new stream open on the group file. */ +extern FILE *EXFUN(__grpopen, (NOARGS)); + +/* Read a group entry from STREAM, filling in G. + Return the `struct group' of G if successful, NULL on failure. */ +extern struct group *EXFUN(__grpread, (FILE *__stream, PTR __g)); + +/* Return a chunk of memory containing pre-initialized data for __grpread. */ +extern PTR EXFUN(__grpalloc, (NOARGS)); +#endif + + +#if defined(__USE_SVID) || defined(__USE_MISC) +/* Rewind the group-file stream. */ +extern void EXFUN(setgrent, (NOARGS)); + +/* Close the group-file stream. */ +extern void EXFUN(endgrent, (NOARGS)); + +/* Read an entry from the group-file stream, opening it if necessary. */ +extern struct group *EXFUN(getgrent, (NOARGS)); +#endif + +#ifdef __USE_SVID +/* Read a group entry from STREAM. */ +extern struct group *EXFUN(fgetgrent, (FILE *__stream)); +#endif + +/* Search for an entry with a matching group ID. */ +extern struct group *EXFUN(getgrgid, (gid_t __gid)); + +/* Search for an entry with a matching group name. */ +extern struct group *EXFUN(getgrnam, (CONST char *__name)); + + +#ifdef __USE_BSD + +#define __need_size_t +#include + +/* Set the group set for the current user to GROUPS (N of them). */ +extern int EXFUN(setgroups, (size_t __n, CONST gid_t *groups)); + +/* Initialize the group set for the current user + by reading the group database and using all groups + of which USER is a member. Also include GROUP. */ +extern int EXFUN(initgroups, (CONST char *user, gid_t group)); + +#endif /* Use BSD. */ + + +#endif /* grp.h */ diff --git a/1/newlibc/include/limits.h b/1/newlibc/include/limits.h new file mode 100755 index 0000000..a486d7b --- /dev/null +++ b/1/newlibc/include/limits.h @@ -0,0 +1,59 @@ +#ifndef _LIMITS_H +#define _LIMITS_H + +#define RAND_MAX 0x7ffffffd /* don't ask - see rand.c */ + +#define CHAR_BIT 8 +#define MB_LEN_MAX 1 + +#define SCHAR_MIN (-128) +#define SCHAR_MAX 127 + +#define UCHAR_MAX 255U + +#ifdef __CHAR_UNSIGNED__ +#define CHAR_MIN 0 +#define CHAR_MAX UCHAR_MAX +#else +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX SCHAR_MAX +#endif + +#define SHRT_MIN (-32768) +#define SHRT_MAX 32767 + +#define USHRT_MAX 65535U + +#define INT_MIN (-2147483648) +#define INT_MAX 2147483647 + +#define UINT_MAX 4294967295U + +#define LONG_MIN (-2147483648) +#define LONG_MAX 2147483647 + +#define ULONG_MAX 4294967295U + +#define _POSIX_ARG_MAX 40960 /* exec() may have 40K worth of args */ +#define _POSIX_CHILD_MAX 6 /* a process may have 6 children */ +#define _POSIX_LINK_MAX 8 /* a file may have 8 links */ +#define _POSIX_MAX_CANON 255 /* size of the canonical input queue */ +#define _POSIX_MAX_INPUT 255 /* you can type 255 chars ahead */ +#define _POSIX_NAME_MAX 14 /* a file name may have 14 chars */ +#define _POSIX_NGROUPS_MAX 0 /* supplementary group IDs are optional */ +#define _POSIX_OPEN_MAX 16 /* a process may have 16 files open */ +#define _POSIX_PATH_MAX 255 /* a pathname may contain 255 chars */ +#define _POSIX_PIPE_BUF 512 /* pipes writes of 512 bytes must be atomic */ + +#define NGROUPS_MAX 0 /* supplemental group IDs not available */ +#define ARG_MAX 40960 /* # bytes of args + environ for exec() */ +#define CHILD_MAX 999 /* no limit :-) */ +#define OPEN_MAX 20 /* # open files a process may have */ +#define LINK_MAX 127 /* # links a file may have */ +#define MAX_CANON 255 /* size of the canonical input queue */ +#define MAX_INPUT 255 /* size of the type-ahead buffer */ +#define NAME_MAX 14 /* # chars in a file name */ +#define PATH_MAX 1024 /* # chars in a path name */ +#define PIPE_BUF 4095 /* # bytes in atomic write to a pipe */ + +#endif diff --git a/1/newlibc/include/linux/._config.h b/1/newlibc/include/linux/._config.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/linux/._fdreg.h b/1/newlibc/include/linux/._fdreg.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/linux/._fs.h b/1/newlibc/include/linux/._fs.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/linux/._hdreg.h b/1/newlibc/include/linux/._hdreg.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/linux/._head.h b/1/newlibc/include/linux/._head.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/linux/._kernel.h b/1/newlibc/include/linux/._kernel.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/linux/._mm.h b/1/newlibc/include/linux/._mm.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/linux/._sched.h b/1/newlibc/include/linux/._sched.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/linux/._sys.h b/1/newlibc/include/linux/._sys.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/linux/._tty.h b/1/newlibc/include/linux/._tty.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/linux/config.h b/1/newlibc/include/linux/config.h new file mode 100755 index 0000000..b706122 --- /dev/null +++ b/1/newlibc/include/linux/config.h @@ -0,0 +1,48 @@ +#ifndef _CONFIG_H +#define _CONFIG_H + +/* + * The root-device is no longer hard-coded. You can change the default + * root-device by changing the line ROOT_DEV = XXX in boot/bootsect.s + */ + +/* + * define your keyboard here - + * KBD_FINNISH for Finnish keyboards + * KBD_US for US-type + * KBD_GR for German keyboards + * KBD_FR for Frech keyboard + */ +/*#define KBD_US */ +/*#define KBD_GR */ +/*#define KBD_FR */ +#define KBD_FINNISH + +/* + * Normally, Linux can get the drive parameters from the BIOS at + * startup, but if this for some unfathomable reason fails, you'd + * be left stranded. For this case, you can define HD_TYPE, which + * contains all necessary info on your harddisk. + * + * The HD_TYPE macro should look like this: + * + * #define HD_TYPE { head, sect, cyl, wpcom, lzone, ctl} + * + * In case of two harddisks, the info should be sepatated by + * commas: + * + * #define HD_TYPE { h,s,c,wpcom,lz,ctl },{ h,s,c,wpcom,lz,ctl } + */ +/* + This is an example, two drives, first is type 2, second is type 3: + +#define HD_TYPE { 4,17,615,300,615,8 }, { 6,17,615,300,615,0 } + + NOTE: ctl is 0 for all drives with heads<=8, and ctl=8 for drives + with more than 8 heads. + + If you want the BIOS to tell what kind of drive you have, just + leave HD_TYPE undefined. This is the normal thing to do. +*/ + +#endif diff --git a/1/newlibc/include/linux/fdreg.h b/1/newlibc/include/linux/fdreg.h new file mode 100755 index 0000000..01355af --- /dev/null +++ b/1/newlibc/include/linux/fdreg.h @@ -0,0 +1,71 @@ +/* + * This file contains some defines for the floppy disk controller. + * Various sources. Mostly "IBM Microcomputers: A Programmers + * Handbook", Sanches and Canton. + */ +#ifndef _FDREG_H +#define _FDREG_H + +extern int ticks_to_floppy_on(unsigned int nr); +extern void floppy_on(unsigned int nr); +extern void floppy_off(unsigned int nr); +extern void floppy_select(unsigned int nr); +extern void floppy_deselect(unsigned int nr); + +/* Fd controller regs. S&C, about page 340 */ +#define FD_STATUS 0x3f4 +#define FD_DATA 0x3f5 +#define FD_DOR 0x3f2 /* Digital Output Register */ +#define FD_DIR 0x3f7 /* Digital Input Register (read) */ +#define FD_DCR 0x3f7 /* Diskette Control Register (write)*/ + +/* Bits of main status register */ +#define STATUS_BUSYMASK 0x0F /* drive busy mask */ +#define STATUS_BUSY 0x10 /* FDC busy */ +#define STATUS_DMA 0x20 /* 0- DMA mode */ +#define STATUS_DIR 0x40 /* 0- cpu->fdc */ +#define STATUS_READY 0x80 /* Data reg ready */ + +/* Bits of FD_ST0 */ +#define ST0_DS 0x03 /* drive select mask */ +#define ST0_HA 0x04 /* Head (Address) */ +#define ST0_NR 0x08 /* Not Ready */ +#define ST0_ECE 0x10 /* Equipment chech error */ +#define ST0_SE 0x20 /* Seek end */ +#define ST0_INTR 0xC0 /* Interrupt code mask */ + +/* Bits of FD_ST1 */ +#define ST1_MAM 0x01 /* Missing Address Mark */ +#define ST1_WP 0x02 /* Write Protect */ +#define ST1_ND 0x04 /* No Data - unreadable */ +#define ST1_OR 0x10 /* OverRun */ +#define ST1_CRC 0x20 /* CRC error in data or addr */ +#define ST1_EOC 0x80 /* End Of Cylinder */ + +/* Bits of FD_ST2 */ +#define ST2_MAM 0x01 /* Missing Addess Mark (again) */ +#define ST2_BC 0x02 /* Bad Cylinder */ +#define ST2_SNS 0x04 /* Scan Not Satisfied */ +#define ST2_SEH 0x08 /* Scan Equal Hit */ +#define ST2_WC 0x10 /* Wrong Cylinder */ +#define ST2_CRC 0x20 /* CRC error in data field */ +#define ST2_CM 0x40 /* Control Mark = deleted */ + +/* Bits of FD_ST3 */ +#define ST3_HA 0x04 /* Head (Address) */ +#define ST3_TZ 0x10 /* Track Zero signal (1=track 0) */ +#define ST3_WP 0x40 /* Write Protect */ + +/* Values for FD_COMMAND */ +#define FD_RECALIBRATE 0x07 /* move to track 0 */ +#define FD_SEEK 0x0F /* seek track */ +#define FD_READ 0xE6 /* read with MT, MFM, SKip deleted */ +#define FD_WRITE 0xC5 /* write with MT, MFM */ +#define FD_SENSEI 0x08 /* Sense Interrupt Status */ +#define FD_SPECIFY 0x03 /* specify HUT etc */ + +/* DMA commands */ +#define DMA_READ 0x46 +#define DMA_WRITE 0x4A + +#endif diff --git a/1/newlibc/include/linux/fs.h b/1/newlibc/include/linux/fs.h new file mode 100755 index 0000000..7a90b10 --- /dev/null +++ b/1/newlibc/include/linux/fs.h @@ -0,0 +1,202 @@ +/* + * This file has definitions for some important file table + * structures etc. + */ + +#ifndef _FS_H +#define _FS_H + +#include + +/* devices are as follows: (same as minix, so we can use the minix + * file system. These are major numbers.) + * + * 0 - unused (nodev) + * 1 - /dev/mem + * 2 - /dev/fd + * 3 - /dev/hd + * 4 - /dev/ttyx + * 5 - /dev/tty + * 6 - /dev/lp + * 7 - unnamed pipes + */ + +#define IS_SEEKABLE(x) ((x)>=1 && (x)<=3) + +#define READ 0 +#define WRITE 1 +#define READA 2 /* read-ahead - don't pause */ +#define WRITEA 3 /* "write-ahead" - silly, but somewhat useful */ + +void buffer_init(long buffer_end); + +#define MAJOR(a) (((unsigned)(a))>>8) +#define MINOR(a) ((a)&0xff) + +#define NAME_LEN 14 +#define ROOT_INO 1 + +#define I_MAP_SLOTS 8 +#define Z_MAP_SLOTS 8 +#define SUPER_MAGIC 0x137F + +#define NR_OPEN 20 +#define NR_INODE 32 +#define NR_FILE 64 +#define NR_SUPER 8 +#define NR_HASH 307 +#define NR_BUFFERS nr_buffers +#define BLOCK_SIZE 1024 +#define BLOCK_SIZE_BITS 10 +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#define INODES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct d_inode))) +#define DIR_ENTRIES_PER_BLOCK ((BLOCK_SIZE)/(sizeof (struct dir_entry))) + +#define PIPE_HEAD(inode) ((inode).i_zone[0]) +#define PIPE_TAIL(inode) ((inode).i_zone[1]) +#define PIPE_SIZE(inode) ((PIPE_HEAD(inode)-PIPE_TAIL(inode))&(PAGE_SIZE-1)) +#define PIPE_EMPTY(inode) (PIPE_HEAD(inode)==PIPE_TAIL(inode)) +#define PIPE_FULL(inode) (PIPE_SIZE(inode)==(PAGE_SIZE-1)) +#define INC_PIPE(head) \ +__asm__("incl %0\n\tandl $4095,%0"::"m" (head)) + +typedef char buffer_block[BLOCK_SIZE]; + +struct buffer_head { + char * b_data; /* pointer to data block (1024 bytes) */ + unsigned long b_blocknr; /* block number */ + unsigned short b_dev; /* device (0 = free) */ + unsigned char b_uptodate; + unsigned char b_dirt; /* 0-clean,1-dirty */ + unsigned char b_count; /* users using this block */ + unsigned char b_lock; /* 0 - ok, 1 -locked */ + struct task_struct * b_wait; + struct buffer_head * b_prev; + struct buffer_head * b_next; + struct buffer_head * b_prev_free; + struct buffer_head * b_next_free; +}; + +struct d_inode { + unsigned short i_mode; + unsigned short i_uid; + unsigned long i_size; + unsigned long i_time; + unsigned char i_gid; + unsigned char i_nlinks; + unsigned short i_zone[9]; +}; + +struct m_inode { + unsigned short i_mode; + unsigned short i_uid; + unsigned long i_size; + unsigned long i_mtime; + unsigned char i_gid; + unsigned char i_nlinks; + unsigned short i_zone[9]; +/* these are in memory also */ + struct task_struct * i_wait; + unsigned long i_atime; + unsigned long i_ctime; + unsigned short i_dev; + unsigned short i_num; + unsigned short i_count; + unsigned char i_lock; + unsigned char i_dirt; + unsigned char i_pipe; + unsigned char i_mount; + unsigned char i_seek; + unsigned char i_update; +}; + +struct file { + unsigned short f_mode; + unsigned short f_flags; + unsigned short f_count; + struct m_inode * f_inode; + off_t f_pos; +}; + +struct super_block { + unsigned short s_ninodes; + unsigned short s_nzones; + unsigned short s_imap_blocks; + unsigned short s_zmap_blocks; + unsigned short s_firstdatazone; + unsigned short s_log_zone_size; + unsigned long s_max_size; + unsigned short s_magic; +/* These are only in memory */ + struct buffer_head * s_imap[8]; + struct buffer_head * s_zmap[8]; + unsigned short s_dev; + struct m_inode * s_isup; + struct m_inode * s_imount; + unsigned long s_time; + struct task_struct * s_wait; + unsigned char s_lock; + unsigned char s_rd_only; + unsigned char s_dirt; +}; + +struct d_super_block { + unsigned short s_ninodes; + unsigned short s_nzones; + unsigned short s_imap_blocks; + unsigned short s_zmap_blocks; + unsigned short s_firstdatazone; + unsigned short s_log_zone_size; + unsigned long s_max_size; + unsigned short s_magic; +}; + +struct dir_entry { + unsigned short inode; + char name[NAME_LEN]; +}; + +extern struct m_inode inode_table[NR_INODE]; +extern struct file file_table[NR_FILE]; +extern struct super_block super_block[NR_SUPER]; +extern struct buffer_head * start_buffer; +extern int nr_buffers; + +extern void check_disk_change(int dev); +extern int floppy_change(unsigned int nr); +extern int ticks_to_floppy_on(unsigned int dev); +extern void floppy_on(unsigned int dev); +extern void floppy_off(unsigned int dev); +extern void truncate(struct m_inode * inode); +extern void sync_inodes(void); +extern void wait_on(struct m_inode * inode); +extern int bmap(struct m_inode * inode,int block); +extern int create_block(struct m_inode * inode,int block); +extern struct m_inode * namei(const char * pathname); +extern int open_namei(const char * pathname, int flag, int mode, + struct m_inode ** res_inode); +extern void iput(struct m_inode * inode); +extern struct m_inode * iget(int dev,int nr); +extern struct m_inode * get_empty_inode(void); +extern struct m_inode * get_pipe_inode(void); +extern struct buffer_head * get_hash_table(int dev, int block); +extern struct buffer_head * getblk(int dev, int block); +extern void ll_rw_block(int rw, struct buffer_head * bh); +extern void brelse(struct buffer_head * buf); +extern struct buffer_head * bread(int dev,int block); +extern void bread_page(unsigned long addr,int dev,int b[4]); +extern struct buffer_head * breada(int dev,int block,...); +extern int new_block(int dev); +extern void free_block(int dev, int block); +extern struct m_inode * new_inode(int dev); +extern void free_inode(struct m_inode * inode); +extern int sync_dev(int dev); +extern struct super_block * get_super(int dev); +extern int ROOT_DEV; + +extern void mount_root(void); + +#endif diff --git a/1/newlibc/include/linux/hdreg.h b/1/newlibc/include/linux/hdreg.h new file mode 100755 index 0000000..e6c593f --- /dev/null +++ b/1/newlibc/include/linux/hdreg.h @@ -0,0 +1,65 @@ +/* + * This file contains some defines for the AT-hd-controller. + * Various sources. Check out some definitions (see comments with + * a ques). + */ +#ifndef _HDREG_H +#define _HDREG_H + +/* Hd controller regs. Ref: IBM AT Bios-listing */ +#define HD_DATA 0x1f0 /* _CTL when writing */ +#define HD_ERROR 0x1f1 /* see err-bits */ +#define HD_NSECTOR 0x1f2 /* nr of sectors to read/write */ +#define HD_SECTOR 0x1f3 /* starting sector */ +#define HD_LCYL 0x1f4 /* starting cylinder */ +#define HD_HCYL 0x1f5 /* high byte of starting cyl */ +#define HD_CURRENT 0x1f6 /* 101dhhhh , d=drive, hhhh=head */ +#define HD_STATUS 0x1f7 /* see status-bits */ +#define HD_PRECOMP HD_ERROR /* same io address, read=error, write=precomp */ +#define HD_COMMAND HD_STATUS /* same io address, read=status, write=cmd */ + +#define HD_CMD 0x3f6 + +/* Bits of HD_STATUS */ +#define ERR_STAT 0x01 +#define INDEX_STAT 0x02 +#define ECC_STAT 0x04 /* Corrected error */ +#define DRQ_STAT 0x08 +#define SEEK_STAT 0x10 +#define WRERR_STAT 0x20 +#define READY_STAT 0x40 +#define BUSY_STAT 0x80 + +/* Values for HD_COMMAND */ +#define WIN_RESTORE 0x10 +#define WIN_READ 0x20 +#define WIN_WRITE 0x30 +#define WIN_VERIFY 0x40 +#define WIN_FORMAT 0x50 +#define WIN_INIT 0x60 +#define WIN_SEEK 0x70 +#define WIN_DIAGNOSE 0x90 +#define WIN_SPECIFY 0x91 + +/* Bits for HD_ERROR */ +#define MARK_ERR 0x01 /* Bad address mark ? */ +#define TRK0_ERR 0x02 /* couldn't find track 0 */ +#define ABRT_ERR 0x04 /* ? */ +#define ID_ERR 0x10 /* ? */ +#define ECC_ERR 0x40 /* ? */ +#define BBD_ERR 0x80 /* ? */ + +struct partition { + unsigned char boot_ind; /* 0x80 - active (unused) */ + unsigned char head; /* ? */ + unsigned char sector; /* ? */ + unsigned char cyl; /* ? */ + unsigned char sys_ind; /* ? */ + unsigned char end_head; /* ? */ + unsigned char end_sector; /* ? */ + unsigned char end_cyl; /* ? */ + unsigned int start_sect; /* starting sector counting from 0 */ + unsigned int nr_sects; /* nr of sectors in partition */ +}; + +#endif diff --git a/1/newlibc/include/linux/head.h b/1/newlibc/include/linux/head.h new file mode 100755 index 0000000..db3dda2 --- /dev/null +++ b/1/newlibc/include/linux/head.h @@ -0,0 +1,20 @@ +#ifndef _HEAD_H +#define _HEAD_H + +typedef struct desc_struct { + unsigned long a,b; +} desc_table[256]; + +extern unsigned long pg_dir[1024]; +extern desc_table idt,gdt; + +#define GDT_NUL 0 +#define GDT_CODE 1 +#define GDT_DATA 2 +#define GDT_TMP 3 + +#define LDT_NUL 0 +#define LDT_CODE 1 +#define LDT_DATA 2 + +#endif diff --git a/1/newlibc/include/linux/kernel.h b/1/newlibc/include/linux/kernel.h new file mode 100755 index 0000000..cb40dd5 --- /dev/null +++ b/1/newlibc/include/linux/kernel.h @@ -0,0 +1,22 @@ +/* + * 'kernel.h' contains some often-used function prototypes etc + */ +void verify_area(void * addr,int count); +volatile void panic(const char * str); +int printf(const char * fmt, ...); +int printk(const char * fmt, ...); +int tty_write(unsigned ch,char * buf,int count); +void * malloc(unsigned int size); +void free_s(void * obj, int size); + +#define free(x) free_s((x), 0) + +/* + * This is defined as a macro, but at some point this might become a + * real subroutine that sets a flag if it returns true (to do + * BSD-style accounting where the process is flagged if it uses root + * privs). The implication of this is that you should do normal + * permissions checks first, and check suser() last. + */ +#define suser() (current->euid == 0) + diff --git a/1/newlibc/include/linux/mm.h b/1/newlibc/include/linux/mm.h new file mode 100755 index 0000000..5a160f3 --- /dev/null +++ b/1/newlibc/include/linux/mm.h @@ -0,0 +1,10 @@ +#ifndef _MM_H +#define _MM_H + +#define PAGE_SIZE 4096 + +extern unsigned long get_free_page(void); +extern unsigned long put_page(unsigned long page,unsigned long address); +extern void free_page(unsigned long addr); + +#endif diff --git a/1/newlibc/include/linux/sched.h b/1/newlibc/include/linux/sched.h new file mode 100755 index 0000000..3407bb9 --- /dev/null +++ b/1/newlibc/include/linux/sched.h @@ -0,0 +1,233 @@ +#ifndef _SCHED_H +#define _SCHED_H + +#define NR_TASKS 64 +#define HZ 100 + +#define FIRST_TASK task[0] +#define LAST_TASK task[NR_TASKS-1] + +#include +#include +#include +#include + +#if (NR_OPEN > 32) +#error "Currently the close-on-exec-flags are in one word, max 32 files/proc" +#endif + +#define TASK_RUNNING 0 +#define TASK_INTERRUPTIBLE 1 +#define TASK_UNINTERRUPTIBLE 2 +#define TASK_ZOMBIE 3 +#define TASK_STOPPED 4 + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +extern int copy_page_tables(unsigned long from, unsigned long to, long size); +extern int free_page_tables(unsigned long from, unsigned long size); + +extern void sched_init(void); +extern void schedule(void); +extern void trap_init(void); +extern void panic(const char * str); +extern int tty_write(unsigned minor,char * buf,int count); + +typedef int (*fn_ptr)(); + +struct i387_struct { + long cwd; + long swd; + long twd; + long fip; + long fcs; + long foo; + long fos; + long st_space[20]; /* 8*10 bytes for each FP-reg = 80 bytes */ +}; + +struct tss_struct { + long back_link; /* 16 high bits zero */ + long esp0; + long ss0; /* 16 high bits zero */ + long esp1; + long ss1; /* 16 high bits zero */ + long esp2; + long ss2; /* 16 high bits zero */ + long cr3; + long eip; + long eflags; + long eax,ecx,edx,ebx; + long esp; + long ebp; + long esi; + long edi; + long es; /* 16 high bits zero */ + long cs; /* 16 high bits zero */ + long ss; /* 16 high bits zero */ + long ds; /* 16 high bits zero */ + long fs; /* 16 high bits zero */ + long gs; /* 16 high bits zero */ + long ldt; /* 16 high bits zero */ + long trace_bitmap; /* bits: trace 0, bitmap 16-31 */ + struct i387_struct i387; +}; + +struct task_struct { +/* these are hardcoded - don't touch */ + long state; /* -1 unrunnable, 0 runnable, >0 stopped */ + long counter; + long priority; + long signal; + struct sigaction sigaction[32]; + long blocked; /* bitmap of masked signals */ +/* various fields */ + int exit_code; + unsigned long start_code,end_code,end_data,brk,start_stack; + long pid,father,pgrp,session,leader; + unsigned short uid,euid,suid; + unsigned short gid,egid,sgid; + long alarm; + long utime,stime,cutime,cstime,start_time; + unsigned short used_math; +/* file system info */ + int tty; /* -1 if no tty, so it must be signed */ + unsigned short umask; + struct m_inode * pwd; + struct m_inode * root; + struct m_inode * executable; + unsigned long close_on_exec; + struct file * filp[NR_OPEN]; +/* ldt for this task 0 - zero 1 - cs 2 - ds&ss */ + struct desc_struct ldt[3]; +/* tss for this task */ + struct tss_struct tss; +}; + +/* + * INIT_TASK is used to set up the first task table, touch at + * your own risk!. Base=0, limit=0x9ffff (=640kB) + */ +#define INIT_TASK \ +/* state etc */ { 0,15,15, \ +/* signals */ 0,{{},},0, \ +/* ec,brk... */ 0,0,0,0,0,0, \ +/* pid etc.. */ 0,-1,0,0,0, \ +/* uid etc */ 0,0,0,0,0,0, \ +/* alarm */ 0,0,0,0,0,0, \ +/* math */ 0, \ +/* fs info */ -1,0022,NULL,NULL,NULL,0, \ +/* filp */ {NULL,}, \ + { \ + {0,0}, \ +/* ldt */ {0x9f,0xc0fa00}, \ + {0x9f,0xc0f200}, \ + }, \ +/*tss*/ {0,PAGE_SIZE+(long)&init_task,0x10,0,0,0,0,(long)&pg_dir,\ + 0,0,0,0,0,0,0,0, \ + 0,0,0x17,0x17,0x17,0x17,0x17,0x17, \ + _LDT(0),0x80000000, \ + {} \ + }, \ +} + +extern struct task_struct *task[NR_TASKS]; +extern struct task_struct *last_task_used_math; +extern struct task_struct *current; +extern long volatile jiffies; +extern long startup_time; + +#define CURRENT_TIME (startup_time+jiffies/HZ) + +extern void add_timer(long jiffies, void (*fn)(void)); +extern void sleep_on(struct task_struct ** p); +extern void interruptible_sleep_on(struct task_struct ** p); +extern void wake_up(struct task_struct ** p); + +/* + * Entry into gdt where to find first TSS. 0-nul, 1-cs, 2-ds, 3-syscall + * 4-TSS0, 5-LDT0, 6-TSS1 etc ... + */ +#define FIRST_TSS_ENTRY 4 +#define FIRST_LDT_ENTRY (FIRST_TSS_ENTRY+1) +#define _TSS(n) ((((unsigned long) n)<<4)+(FIRST_TSS_ENTRY<<3)) +#define _LDT(n) ((((unsigned long) n)<<4)+(FIRST_LDT_ENTRY<<3)) +#define ltr(n) __asm__("ltr %%ax"::"a" (_TSS(n))) +#define lldt(n) __asm__("lldt %%ax"::"a" (_LDT(n))) +#define str(n) \ +__asm__("str %%ax\n\t" \ + "subl %2,%%eax\n\t" \ + "shrl $4,%%eax" \ + :"=a" (n) \ + :"a" (0),"i" (FIRST_TSS_ENTRY<<3)) +/* + * switch_to(n) should switch tasks to task nr n, first + * checking that n isn't the current task, in which case it does nothing. + * This also clears the TS-flag if the task we switched to has used + * tha math co-processor latest. + */ +#define switch_to(n) {\ +struct {long a,b;} __tmp; \ +__asm__("cmpl %%ecx,_current\n\t" \ + "je 1f\n\t" \ + "movw %%dx,%1\n\t" \ + "xchgl %%ecx,_current\n\t" \ + "ljmp %0\n\t" \ + "cmpl %%ecx,_last_task_used_math\n\t" \ + "jne 1f\n\t" \ + "clts\n" \ + "1:" \ + ::"m" (*&__tmp.a),"m" (*&__tmp.b), \ + "d" (_TSS(n)),"c" ((long) task[n])); \ +} + +#define PAGE_ALIGN(n) (((n)+0xfff)&0xfffff000) + +#define _set_base(addr,base) \ +__asm__("movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %%dl,%1\n\t" \ + "movb %%dh,%2" \ + ::"m" (*((addr)+2)), \ + "m" (*((addr)+4)), \ + "m" (*((addr)+7)), \ + "d" (base) \ + :"dx") + +#define _set_limit(addr,limit) \ +__asm__("movw %%dx,%0\n\t" \ + "rorl $16,%%edx\n\t" \ + "movb %1,%%dh\n\t" \ + "andb $0xf0,%%dh\n\t" \ + "orb %%dh,%%dl\n\t" \ + "movb %%dl,%1" \ + ::"m" (*(addr)), \ + "m" (*((addr)+6)), \ + "d" (limit) \ + :"dx") + +#define set_base(ldt,base) _set_base( ((char *)&(ldt)) , base ) +#define set_limit(ldt,limit) _set_limit( ((char *)&(ldt)) , (limit-1)>>12 ) + +#define _get_base(addr) ({\ +unsigned long __base; \ +__asm__("movb %3,%%dh\n\t" \ + "movb %2,%%dl\n\t" \ + "shll $16,%%edx\n\t" \ + "movw %1,%%dx" \ + :"=d" (__base) \ + :"m" (*((addr)+2)), \ + "m" (*((addr)+4)), \ + "m" (*((addr)+7))); \ +__base;}) + +#define get_base(ldt) _get_base( ((char *)&(ldt)) ) + +#define get_limit(segment) ({ \ +unsigned long __limit; \ +__asm__("lsll %1,%0\n\tincl %0":"=r" (__limit):"r" (segment)); \ +__limit;}) + +#endif diff --git a/1/newlibc/include/linux/sys.h b/1/newlibc/include/linux/sys.h new file mode 100755 index 0000000..c538fc1 --- /dev/null +++ b/1/newlibc/include/linux/sys.h @@ -0,0 +1,86 @@ +extern int sys_setup(); +extern int sys_exit(); +extern int sys_fork(); +extern int sys_read(); +extern int sys_write(); +extern int sys_open(); +extern int sys_close(); +extern int sys_waitpid(); +extern int sys_creat(); +extern int sys_link(); +extern int sys_unlink(); +extern int sys_execve(); +extern int sys_chdir(); +extern int sys_time(); +extern int sys_mknod(); +extern int sys_chmod(); +extern int sys_chown(); +extern int sys_break(); +extern int sys_stat(); +extern int sys_lseek(); +extern int sys_getpid(); +extern int sys_mount(); +extern int sys_umount(); +extern int sys_setuid(); +extern int sys_getuid(); +extern int sys_stime(); +extern int sys_ptrace(); +extern int sys_alarm(); +extern int sys_fstat(); +extern int sys_pause(); +extern int sys_utime(); +extern int sys_stty(); +extern int sys_gtty(); +extern int sys_access(); +extern int sys_nice(); +extern int sys_ftime(); +extern int sys_sync(); +extern int sys_kill(); +extern int sys_rename(); +extern int sys_mkdir(); +extern int sys_rmdir(); +extern int sys_dup(); +extern int sys_pipe(); +extern int sys_times(); +extern int sys_prof(); +extern int sys_brk(); +extern int sys_setgid(); +extern int sys_getgid(); +extern int sys_signal(); +extern int sys_geteuid(); +extern int sys_getegid(); +extern int sys_acct(); +extern int sys_phys(); +extern int sys_lock(); +extern int sys_ioctl(); +extern int sys_fcntl(); +extern int sys_mpx(); +extern int sys_setpgid(); +extern int sys_ulimit(); +extern int sys_uname(); +extern int sys_umask(); +extern int sys_chroot(); +extern int sys_ustat(); +extern int sys_dup2(); +extern int sys_getppid(); +extern int sys_getpgrp(); +extern int sys_setsid(); +extern int sys_sigaction(); +extern int sys_sgetmask(); +extern int sys_ssetmask(); +extern int sys_setreuid(); +extern int sys_setregid(); + +fn_ptr sys_call_table[] = { sys_setup, sys_exit, sys_fork, sys_read, +sys_write, sys_open, sys_close, sys_waitpid, sys_creat, sys_link, +sys_unlink, sys_execve, sys_chdir, sys_time, sys_mknod, sys_chmod, +sys_chown, sys_break, sys_stat, sys_lseek, sys_getpid, sys_mount, +sys_umount, sys_setuid, sys_getuid, sys_stime, sys_ptrace, sys_alarm, +sys_fstat, sys_pause, sys_utime, sys_stty, sys_gtty, sys_access, +sys_nice, sys_ftime, sys_sync, sys_kill, sys_rename, sys_mkdir, +sys_rmdir, sys_dup, sys_pipe, sys_times, sys_prof, sys_brk, sys_setgid, +sys_getgid, sys_signal, sys_geteuid, sys_getegid, sys_acct, sys_phys, +sys_lock, sys_ioctl, sys_fcntl, sys_mpx, sys_setpgid, sys_ulimit, +sys_uname, sys_umask, sys_chroot, sys_ustat, sys_dup2, sys_getppid, +sys_getpgrp, sys_setsid, sys_sigaction, sys_sgetmask, sys_ssetmask, +sys_setreuid,sys_setregid }; diff --git a/1/newlibc/include/linux/tty.h b/1/newlibc/include/linux/tty.h new file mode 100755 index 0000000..ad846b3 --- /dev/null +++ b/1/newlibc/include/linux/tty.h @@ -0,0 +1,77 @@ +/* + * 'tty.h' defines some structures used by tty_io.c and some defines. + * + * NOTE! Don't touch this without checking that nothing in rs_io.s or + * con_io.s breaks. Some constants are hardwired into the system (mainly + * offsets into 'tty_queue' + */ + +#ifndef _TTY_H +#define _TTY_H + +#include + +#define TTY_BUF_SIZE 1024 + +struct tty_queue { + unsigned long data; + unsigned long head; + unsigned long tail; + struct task_struct * proc_list; + char buf[TTY_BUF_SIZE]; +}; + +#define INC(a) ((a) = ((a)+1) & (TTY_BUF_SIZE-1)) +#define DEC(a) ((a) = ((a)-1) & (TTY_BUF_SIZE-1)) +#define EMPTY(a) ((a).head == (a).tail) +#define LEFT(a) (((a).tail-(a).head-1)&(TTY_BUF_SIZE-1)) +#define LAST(a) ((a).buf[(TTY_BUF_SIZE-1)&((a).head-1)]) +#define FULL(a) (!LEFT(a)) +#define CHARS(a) (((a).head-(a).tail)&(TTY_BUF_SIZE-1)) +#define GETCH(queue,c) \ +(void)({c=(queue).buf[(queue).tail];INC((queue).tail);}) +#define PUTCH(c,queue) \ +(void)({(queue).buf[(queue).head]=(c);INC((queue).head);}) + +#define INTR_CHAR(tty) ((tty)->termios.c_cc[VINTR]) +#define QUIT_CHAR(tty) ((tty)->termios.c_cc[VQUIT]) +#define ERASE_CHAR(tty) ((tty)->termios.c_cc[VERASE]) +#define KILL_CHAR(tty) ((tty)->termios.c_cc[VKILL]) +#define EOF_CHAR(tty) ((tty)->termios.c_cc[VEOF]) +#define START_CHAR(tty) ((tty)->termios.c_cc[VSTART]) +#define STOP_CHAR(tty) ((tty)->termios.c_cc[VSTOP]) +#define SUSPEND_CHAR(tty) ((tty)->termios.c_cc[VSUSP]) + +struct tty_struct { + struct termios termios; + int pgrp; + int stopped; + void (*write)(struct tty_struct * tty); + struct tty_queue read_q; + struct tty_queue write_q; + struct tty_queue secondary; + }; + +extern struct tty_struct tty_table[]; + +/* intr=^C quit=^| erase=del kill=^U + eof=^D vtime=\0 vmin=\1 sxtc=\0 + start=^Q stop=^S susp=^Z eol=\0 + reprint=^R discard=^U werase=^W lnext=^V + eol2=\0 +*/ +#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" + +void rs_init(void); +void con_init(void); +void tty_init(void); + +int tty_read(unsigned c, char * buf, int n); +int tty_write(unsigned c, char * buf, int n); + +void rs_write(struct tty_struct * tty); +void con_write(struct tty_struct * tty); + +void copy_to_cooked(struct tty_struct * tty); + +#endif diff --git a/1/newlibc/include/localeinfo.h b/1/newlibc/include/localeinfo.h new file mode 100755 index 0000000..2dc0f4d --- /dev/null +++ b/1/newlibc/include/localeinfo.h @@ -0,0 +1,208 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* Locale-specific information. */ + +#ifndef _LOCALEINFO_H + +#define _LOCALEINFO_H 1 + +#define __need_size_t +#define __need_wchar_t +#include +#include + + +/* Change these if the `wchar_t' type is changed. */ +#define WCHAR_MAX ((wchar_t) UCHAR_MAX) + + +/* Used by multibyte char functions. */ +typedef struct + { + char *string; /* Bytes. */ + size_t len; /* # of bytes. */ + long int shift; /* # of mb_char's to shift. */ + } mb_char; + +struct ctype_mbchar_info + { + size_t mb_max; /* Max MB char length. */ + mb_char *mb_chars; /* MB chars. */ + }; + +struct ctype_ctype_info + { + unsigned short int *ctype_b; /* Characteristics. */ + unsigned char *ctype_tolower; /* Case mappings. */ + unsigned char *ctype_toupper; /* Case mappings. */ + }; + +struct ctype_info + { + struct ctype_ctype_info *ctype; + struct ctype_mbchar_info *mbchar; + }; + +extern CONST struct ctype_info *_ctype_info; + +/* These are necessary because they are used in a header file. */ +extern CONST unsigned short int *__ctype_b; +extern CONST unsigned char *__ctype_tolower; +extern CONST unsigned char *__ctype_toupper; + + +/* Used by strcoll and strxfrm. */ +typedef struct + { + unsigned char *values; + size_t nvalues; + } literal_value; + +typedef struct + { + union + { + literal_value literal; + /* %%% This may become a regex_t in the future. */ + char *regexp; + } replace, with; + unsigned int regexp:1; + } subst; + +struct collate_info + { + size_t nsubsts; + subst *substs; + + unsigned char *values; + unsigned char *offsets; + }; + +extern CONST struct collate_info *_collate_info; + + +/* Used by strtod, atof. */ +struct numeric_info + { + char *decimal_point; + char *thousands_sep; + char *grouping; + }; + +extern CONST struct numeric_info *_numeric_info; + + +/* Used in the return value of localeconv. */ +struct monetary_info + { + char *int_curr_symbol; + char *currency_symbol; + char *mon_decimal_point; + char *mon_thousands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; + }; + +extern CONST struct monetary_info *_monetary_info; + + +/* Used by strftime, asctime. */ +struct time_info + { + char *abbrev_wkday[7]; /* Short weekday names. */ + char *full_wkday[7]; /* Full weekday names. */ + char *abbrev_month[12]; /* Short month names. */ + char *full_month[12]; /* Full month names. */ + char *ampm[2]; /* "AM" and "PM" strings. */ + + char *date_time; /* Appropriate date and time format. */ + char *date; /* Appropriate date format. */ + char *time; /* Appropriate time format. */ + + char *ut0; /* Name for GMT. */ + char *tz; /* Default TZ value. */ + }; + +extern CONST struct time_info *_time_info; + +struct response_info + { + /* Regexp for affirmative answers. */ + char *yesexpr; + + /* Regexp for negative answers. */ + char *noexpr; + }; + +extern CONST struct response_info *_response_info; + +/* Locale structure. */ +typedef struct + { + char *name; + int categories; + + unsigned int allocated:1; + + int subcategories; + size_t num_sublocales; + struct sub_locale *sublocales; + + PTR *info; + } locale; + +typedef struct sub_locale + { + unsigned int pointer:1; + + int categories; + char *name; + + locale *locale; + } sublocale; + + +/* This is the magic number that localeinfo object files begin with. + In case you're wondering why I chose the value 0x051472CA, it's + because I was born on 05-14-72 in Oakland, CA. */ +#define LIMAGIC 0x051472CA +/* This is the magic number that precedes each category-specific section + of a localeinfo object file. It's the arbitrary magic number above, + but modified by the category so that it's different from the per-file + magic number and unique for each category. */ +#define CATEGORY_MAGIC(x) (LIMAGIC ^ (x)) + +extern CONST char *__lidir, *__lidefault; + +extern locale *EXFUN(__find_locale, (int categories, CONST char *name)); +extern locale *EXFUN(__new_locale, (locale *)); +extern locale *EXFUN(__localefile, (CONST char *file)); +extern void EXFUN(__free_locale, (locale *)); + + +#endif /* localeinfo.h */ diff --git a/1/newlibc/include/math.h b/1/newlibc/include/math.h new file mode 100755 index 0000000..c013bec --- /dev/null +++ b/1/newlibc/include/math.h @@ -0,0 +1,31 @@ +/* The header contains prototypes for mathematical functions. */ + +#ifndef _MATH_H +#define _MATH_H + +#define HUGE_VAL 9.9e+307 + +double acos(double x); +double asin(double x); +double atan(double x); +double atan2(double y, double x); +double ceil(double x); +double cos(double x); +double cosh(double x); +double exp(double x); +double fabs(double x); +double floor(double x); +double fmod(double x, double y); +double frexp(double x, int *exp); +double ldexp(double x, int exp); +double log(double x); +double log10(double x); +double modf(double x, double *iptr); +double pow(double x, double y); +double sin(double x); +double sinh(double x); +double sqrt(double x); +double tan(double x); +double tanh(double x); + +#endif /* _MATH_H */ diff --git a/1/newlibc/include/pwd.h b/1/newlibc/include/pwd.h new file mode 100755 index 0000000..4616f65 --- /dev/null +++ b/1/newlibc/include/pwd.h @@ -0,0 +1,89 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* + * POSIX Standard: 9.2.2 User Database Access + */ + +#ifndef _PWD_H +#define _PWD_H 1 + +#include +#include + +#define __USE_SVID +#define __USE_GNU + +/* The passwd structure. */ +struct passwd + { + char *pw_name; /* Username. */ + char *pw_passwd; /* Password. */ + uid_t pw_uid; /* User ID. */ + gid_t pw_gid; /* Group ID. */ + char *pw_gecos; /* Real name. */ + char *pw_dir; /* Home directory. */ + char *pw_shell; /* Shell program. */ + }; + + +#if defined(__USE_SVID) || defined(__USE_GNU) +#define __need_FILE +#include +#endif + +#ifdef __USE_GNU +/* Return a new stream open on the password file. */ +extern FILE *EXFUN(__pwdopen, (NOARGS)); + +/* Read a password entry from STREAM, filling in P. + Return the `struct passwd' of P if successful, NULL on failure. */ +extern struct passwd *EXFUN(__pwdread, (FILE *__stream, PTR __p)); + +/* Return a chunk of memory containing pre-initialized data for __pwdread. */ +extern PTR EXFUN(__pwdalloc, (NOARGS)); +#endif + + +#if defined(__USE_SVID) || defined(__USE_MISC) +/* Rewind the password-file stream. */ +extern void EXFUN(setpwent, (NOARGS)); + +/* Close the password-file stream. */ +extern void EXFUN(endpwent, (NOARGS)); + +/* Read an entry from the password-file stream, opening it if necessary. */ +extern struct passwd *EXFUN(getpwent, (NOARGS)); +#endif + +#ifdef __USE_SVID +/* Read an entry from STREAM. */ +extern struct passwd *EXFUN(fgetpwent, (FILE *__stream)); + +/* Write the given entry onto the given stream. */ +extern int EXFUN(putpwent, (CONST struct passwd *__p, FILE *__f)); +#endif + +/* Search for an entry with a matching user ID. */ +extern struct passwd *EXFUN(getpwuid, (uid_t __uid)); + +/* Search for an entry with a matching username. */ +extern struct passwd *EXFUN(getpwnam, (CONST char *__name)); + + +#endif /* pwd.h */ diff --git a/1/newlibc/include/regex.h b/1/newlibc/include/regex.h new file mode 100755 index 0000000..81f953a --- /dev/null +++ b/1/newlibc/include/regex.h @@ -0,0 +1,257 @@ +/* Definitions for data structures callers pass the regex library. + + Copyright (C) 1985, 1989-90 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +#ifdef __GNUC__ + #pragma once +#endif + +#ifndef __REGEXP_LIBRARY +#define __REGEXP_LIBRARY + +/* Define number of parens for which we record the beginnings and ends. + This affects how much space the `struct re_registers' type takes up. */ +#ifndef RE_NREGS +#define RE_NREGS 10 +#endif + +#define BYTEWIDTH 8 + + +/* Maximum number of duplicates an interval can allow. */ +#define RE_DUP_MAX ((1 << 15) - 1) + + +/* This defines the various regexp syntaxes. */ +extern int obscure_syntax; + + +/* The following bits are used in the obscure_syntax variable to choose among + alternative regexp syntaxes. */ + +/* If this bit is set, plain parentheses serve as grouping, and backslash + parentheses are needed for literal searching. + If not set, backslash-parentheses are grouping, and plain parentheses + are for literal searching. */ +#define RE_NO_BK_PARENS 1 + +/* If this bit is set, plain | serves as the `or'-operator, and \| is a + literal. + If not set, \| serves as the `or'-operator, and | is a literal. */ +#define RE_NO_BK_VBAR (1 << 1) + +/* If this bit is not set, plain + or ? serves as an operator, and \+, \? are + literals. + If set, \+, \? are operators and plain +, ? are literals. */ +#define RE_BK_PLUS_QM (1 << 2) + +/* If this bit is set, | binds tighter than ^ or $. + If not set, the contrary. */ +#define RE_TIGHT_VBAR (1 << 3) + +/* If this bit is set, then treat newline as an OR operator. + If not set, treat it as a normal character. */ +#define RE_NEWLINE_OR (1 << 4) + +/* If this bit is set, then special characters may act as normal + characters in some contexts. Specifically, this applies to: + ^ -- only special at the beginning, or after ( or |; + $ -- only special at the end, or before ) or |; + *, +, ? -- only special when not after the beginning, (, or |. + If this bit is not set, special characters (such as *, ^, and $) + always have their special meaning regardless of the surrounding + context. */ +#define RE_CONTEXT_INDEP_OPS (1 << 5) + +/* If this bit is not set, then \ before anything inside [ and ] is taken as + a real \. + If set, then such a \ escapes the following character. This is a + special case for awk. */ +#define RE_AWK_CLASS_HACK (1 << 6) + +/* If this bit is set, then \{ and \} or { and } serve as interval operators. + If not set, then \{ and \} and { and } are treated as literals. */ +#define RE_INTERVALS (1 << 7) + +/* If this bit is not set, then \{ and \} serve as interval operators and + { and } are literals. + If set, then { and } serve as interval operators and \{ and \} are + literals. */ +#define RE_NO_BK_CURLY_BRACES (1 << 8) + +/* If this bit is set, then character classes are supported; they are: + [:alpha:], [:upper:], [:lower:], [:digit:], [:alnum:], [:xdigit:], + [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:]. + If not set, then character classes are not supported. */ +#define RE_CHAR_CLASSES (1 << 9) + +/* If this bit is set, then the dot re doesn't match a null byte. + If not set, it does. */ +#define RE_DOT_NOT_NULL (1 << 10) + +/* If this bit is set, then [^...] doesn't match a newline. + If not set, it does. */ +#define RE_HAT_NOT_NEWLINE (1 << 11) + +/* If this bit is set, back references are recognized. + If not set, they aren't. */ +#define RE_NO_BK_REFS (1 << 12) + +/* If this bit is set, back references must refer to a preceding + subexpression. If not set, a back reference to a nonexistent + subexpression is treated as literal characters. */ +#define RE_NO_EMPTY_BK_REF (1 << 13) + +/* If this bit is set, bracket expressions can't be empty. + If it is set, they can be empty. */ +#define RE_NO_EMPTY_BRACKETS (1 << 14) + +/* If this bit is set, then *, +, ? and { cannot be first in an re or + immediately after a |, or a (. Furthermore, a | cannot be first or + last in an re, or immediately follow another | or a (. Also, a ^ + cannot appear in a nonleading position and a $ cannot appear in a + nontrailing position (outside of bracket expressions, that is). */ +#define RE_CONTEXTUAL_INVALID_OPS (1 << 15) + +/* If this bit is set, then +, ? and | aren't recognized as operators. + If it's not, they are. */ +#define RE_LIMITED_OPS (1 << 16) + +/* If this bit is set, then an ending range point has to collate higher + or equal to the starting range point. + If it's not set, then when the ending range point collates higher + than the starting range point, the range is just considered empty. */ +#define RE_NO_EMPTY_RANGES (1 << 17) + +/* If this bit is set, then a hyphen (-) can't be an ending range point. + If it isn't, then it can. */ +#define RE_NO_HYPHEN_RANGE_END (1 << 18) + + +/* Define combinations of bits for the standard possibilities. */ +#define RE_SYNTAX_POSIX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \ + | RE_CONTEXT_INDEP_OPS) +#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR \ + | RE_CONTEXT_INDEP_OPS | RE_AWK_CLASS_HACK) +#define RE_SYNTAX_EGREP (RE_NO_BK_PARENS | RE_NO_BK_VBAR \ + | RE_CONTEXT_INDEP_OPS | RE_NEWLINE_OR) +#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR) +#define RE_SYNTAX_EMACS 0 +#define RE_SYNTAX_POSIX_BASIC (RE_INTERVALS | RE_BK_PLUS_QM \ + | RE_CHAR_CLASSES | RE_DOT_NOT_NULL \ + | RE_HAT_NOT_NEWLINE | RE_NO_EMPTY_BK_REF \ + | RE_NO_EMPTY_BRACKETS | RE_LIMITED_OPS \ + | RE_NO_EMPTY_RANGES | RE_NO_HYPHEN_RANGE_END) + +#define RE_SYNTAX_POSIX_EXTENDED (RE_INTERVALS | RE_NO_BK_CURLY_BRACES \ + | RE_NO_BK_VBAR | RE_NO_BK_PARENS \ + | RE_HAT_NOT_NEWLINE | RE_CHAR_CLASSES \ + | RE_NO_EMPTY_BRACKETS | RE_CONTEXTUAL_INVALID_OPS \ + | RE_NO_BK_REFS | RE_NO_EMPTY_RANGES \ + | RE_NO_HYPHEN_RANGE_END) + + +/* This data structure is used to represent a compiled pattern. */ + +struct re_pattern_buffer + { + char *buffer; /* Space holding the compiled pattern commands. */ + long allocated; /* Size of space that `buffer' points to. */ + long used; /* Length of portion of buffer actually occupied */ + char *fastmap; /* Pointer to fastmap, if any, or zero if none. */ + /* re_search uses the fastmap, if there is one, + to skip over totally implausible characters. */ + char *translate; /* Translate table to apply to all characters before + comparing, or zero for no translation. + The translation is applied to a pattern when it is + compiled and to data when it is matched. */ + char fastmap_accurate; + /* Set to zero when a new pattern is stored, + set to one when the fastmap is updated from it. */ + char can_be_null; /* Set to one by compiling fastmap + if this pattern might match the null string. + It does not necessarily match the null string + in that case, but if this is zero, it cannot. + 2 as value means can match null string + but at end of range or before a character + listed in the fastmap. */ + }; + + +/* search.c (search_buffer) needs this one value. It is defined both in + regex.c and here. */ +#define RE_EXACTN_VALUE 1 + + +/* Structure to store register contents data in. + + Pass the address of such a structure as an argument to re_match, etc., + if you want this information back. + + For i from 1 to RE_NREGS - 1, start[i] records the starting index in + the string of where the ith subexpression matched, and end[i] records + one after the ending index. start[0] and end[0] are analogous, for + the entire pattern. */ + +struct re_registers + { + int start[RE_NREGS]; + int end[RE_NREGS]; + }; + + + +#ifdef __STDC__ + +extern char *re_compile_pattern (char *, int, struct re_pattern_buffer *); +/* Is this really advertised? */ +extern void re_compile_fastmap (struct re_pattern_buffer *); +extern int re_search (struct re_pattern_buffer *, char*, int, int, int, + struct re_registers *); +extern int re_search_2 (struct re_pattern_buffer *, char *, int, + char *, int, int, int, + struct re_registers *, int); +extern int re_match (struct re_pattern_buffer *, char *, int, int, + struct re_registers *); +extern int re_match_2 (struct re_pattern_buffer *, char *, int, + char *, int, int, struct re_registers *, int); + +/* 4.2 bsd compatibility. */ +extern char *re_comp (char *); +extern int re_exec (char *); + +#else /* !__STDC__ */ + +extern char *re_compile_pattern (); +/* Is this really advertised? */ +extern void re_compile_fastmap (); +extern int re_search (), re_search_2 (); +extern int re_match (), re_match_2 (); + +/* 4.2 bsd compatibility. */ +extern char *re_comp (); +extern int re_exec (); + +#endif /* __STDC__ */ + + +#ifdef SYNTAX_TABLE +extern char *re_syntax_table; +#endif + +#endif /* !__REGEXP_LIBRARY */ diff --git a/1/newlibc/include/setjmp.h b/1/newlibc/include/setjmp.h new file mode 100755 index 0000000..b2d8141 --- /dev/null +++ b/1/newlibc/include/setjmp.h @@ -0,0 +1,16 @@ +#ifndef _SETJMP_H +#define _SETJMP_H + +/* longjump wants %ebp, %esp, %eip, %ebx, %esi, %edi */ +#define _JBLEN 32 +#define _SJBLEN (_JBLEN+4) + +typedef char * jmp_buf[_JBLEN]; +typedef char * sigjmp_buf[_SJBLEN]; + +int setjmp(jmp_buf env); +void longjmp(jmp_buf env, int val); +int sigsetjmp(sigjmp_buf env, int savemask); +int siglongjmp(sigjmp_buf env, int val); + +#endif diff --git a/1/newlibc/include/signal.h b/1/newlibc/include/signal.h new file mode 100755 index 0000000..ad599f0 --- /dev/null +++ b/1/newlibc/include/signal.h @@ -0,0 +1,69 @@ +#ifndef _SIGNAL_H +#define _SIGNAL_H + +#include + +typedef int sig_atomic_t; +typedef unsigned int sigset_t; /* 32 bits */ + +#define _NSIG 32 +#define NSIG _NSIG + +#define SIGHUP 1 +#define SIGINT 2 +#define SIGQUIT 3 +#define SIGILL 4 +#define SIGTRAP 5 +#define SIGABRT 6 +#define SIGIOT 6 +#define SIGUNUSED 7 +#define SIGFPE 8 +#define SIGKILL 9 +#define SIGUSR1 10 +#define SIGSEGV 11 +#define SIGUSR2 12 +#define SIGPIPE 13 +#define SIGALRM 14 +#define SIGTERM 15 +#define SIGSTKFLT 16 +#define SIGCHLD 17 +#define SIGCONT 18 +#define SIGSTOP 19 +#define SIGTSTP 20 +#define SIGTTIN 21 +#define SIGTTOU 22 + +/* Ok, I haven't implemented sigactions, but trying to keep headers POSIX */ +#define SA_NOCLDSTOP 1 +#define SA_NOMASK 0x40000000 +#define SA_ONESHOT 0x80000000 + +#define SIG_BLOCK 0 /* for blocking signals */ +#define SIG_UNBLOCK 1 /* for unblocking signals */ +#define SIG_SETMASK 2 /* for setting the signal mask */ + +#define SIG_DFL ((void (*)(int))0) /* default signal handling */ +#define SIG_IGN ((void (*)(int))1) /* ignore signal */ +#define SIG_ERR ((void (*)(int))-1) /* error return from signal */ + +struct sigaction { + void (*sa_handler)(int); + sigset_t sa_mask; + int sa_flags; + void (*sa_restorer)(void); +}; + +void (*signal(int _sig, void (*_func)(int)))(int); +int raise(int sig); +int kill(pid_t pid, int sig); +int sigaddset(sigset_t *mask, int signo); +int sigdelset(sigset_t *mask, int signo); +int sigemptyset(sigset_t *mask); +int sigfillset(sigset_t *mask); +int sigismember(sigset_t *mask, int signo); /* 1 - is, 0 - not, -1 error */ +int sigpending(sigset_t *set); +int sigprocmask(int how, sigset_t *set, sigset_t *oldset); +int sigsuspend(sigset_t *sigmask); +int sigaction(int sig, struct sigaction *act, struct sigaction *oldact); + +#endif /* _SIGNAL_H */ diff --git a/1/newlibc/include/stdarg.h b/1/newlibc/include/stdarg.h new file mode 100755 index 0000000..fd79ec0 --- /dev/null +++ b/1/newlibc/include/stdarg.h @@ -0,0 +1,28 @@ +#ifndef _STDARG_H +#define _STDARG_H + +typedef char *va_list; + +/* Amount of space required in an argument list for an arg of type TYPE. + TYPE may alternatively be an expression whose type is used. */ + +#define __va_rounded_size(TYPE) \ + (((sizeof (TYPE) + sizeof (int) - 1) / sizeof (int)) * sizeof (int)) + +#ifndef __sparc__ +#define va_start(AP, LASTARG) \ + (AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) +#else +#define va_start(AP, LASTARG) \ + (__builtin_saveregs (), \ + AP = ((char *) &(LASTARG) + __va_rounded_size (LASTARG))) +#endif + +void va_end (va_list); /* Defined in gnulib */ +#define va_end(AP) + +#define va_arg(AP, TYPE) \ + (AP += __va_rounded_size (TYPE), \ + *((TYPE *) (AP - __va_rounded_size (TYPE)))) + +#endif /* _STDARG_H */ diff --git a/1/newlibc/include/stddef.h b/1/newlibc/include/stddef.h new file mode 100755 index 0000000..97f72ff --- /dev/null +++ b/1/newlibc/include/stddef.h @@ -0,0 +1,19 @@ +#ifndef _STDDEF_H +#define _STDDEF_H + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef long ptrdiff_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned long size_t; +#endif + +#undef NULL +#define NULL ((void *)0) + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#endif diff --git a/1/newlibc/include/stdio.h b/1/newlibc/include/stdio.h new file mode 100755 index 0000000..a779059 --- /dev/null +++ b/1/newlibc/include/stdio.h @@ -0,0 +1,256 @@ +#ifndef _STDIO_H +#define _STDIO_H + +/* s t d i o + * + * Author: C. E. Chew + * Date: August 1989 + * + * (C) Copyright C E Chew + * + * Feel free to copy, use and distribute this software provided: + * + * 1. you do not pretend that you wrote it + * 2. you leave this copyright notice intact. + * + * Definitions and user interface for the stream io package. + * + * Patchlevel 2.0 + * + * Edit History: + */ + +/* Site specific definitions */ +/*@*/ +#ifndef NULL +# define NULL ((void *)0) +#endif +#define _STDIO_UCHAR_ 0 +#define _STDIO_VA_LIST_ char * +#define _STDIO_SIZE_T_ unsigned int /* type returned by sizeof */ +#define _STDIO_USIZE_T_ unsigned int +/*=*/ + +/* Definitions based on ANSI compiler */ +#ifdef __STDC__ +# ifndef _STDIO_P_ +# define _STDIO_P_(x) x +# endif +# ifndef _STDIO_VA_ +# define _STDIO_VA_ , ... +# endif +# ifndef _STDIO_UCHAR_ +# define _STDIO_UCHAR_ 0 +# endif +#else +# ifndef _STDIO_P_ +# define _STDIO_P_(x) () +# endif +# ifndef _STDIO_VA_ +# define _STDIO_VA_ +# endif +# ifndef _STDIO_UCHAR_ +# define _STDIO_UCHAR_ (0xff) +# endif +#endif + +#ifndef _STDIO_VA_LIST_ +# define _STDIO_VA_LIST_ void * +#endif + +#ifndef _STDIO_SIZE_T_ +# define _STDIO_SIZE_T_ unsigned int +#endif + +#ifndef _STDIO_USIZE_T_ +# define _STDIO_USIZE_T_ unsigned int +#endif + +/* ANSI Definitions */ +#define BUFSIZ 1024 /* default buffer size */ + +#ifndef NULL +# define NULL ((void *) 0) /* null pointer */ +#endif + +#define EOF (-1) /* eof flag */ +#define FOPEN_MAX 16 /* minimum guarantee */ +#define FILENAME_MAX 127 /* maximum length of file name */ + +#define SEEK_SET 0 /* seek from beginning */ +#define SEEK_CUR 1 /* seek from here */ +#define SEEK_END 2 /* seek from end */ + +#define TMP_MAX (0xffff) /* maximum number of temporaries */ + +#define L_tmpnam (5 + 8 + 4 + 1 + 1) /* length of temporary file name */ + +#ifndef _FPOS_T +# define _FPOS_T + typedef long fpos_t; /* stream positioning */ +#endif + +#ifndef _SIZE_T +# define _SIZE_T + typedef _STDIO_SIZE_T_ size_t; /* sizeof type */ +#endif + +#define _IOFBF 000000 /* fully buffered io */ +#define _IOREAD 000001 /* opened for reading */ +#define _IOWRITE 000002 /* opened for writing */ +#define _IONBF 000004 /* unbuffered */ +#define _IOMYBUF 000010 /* allocated buffer */ +#define _IOPOOLBUF 000020 /* buffer belongs to pool */ +#define _IOEOF 000040 /* eof encountered */ +#define _IOERR 000100 /* error encountered */ +#define _IOSTRING 000200 /* strings */ +#define _IOLBF 000400 /* line buffered */ +#define _IORW 001000 /* opened for reading and writing */ +#define _IOAPPEND 002000 /* append mode */ +#define _IOINSERT 004000 /* insert into __iop chain */ +#define _IOSTDX 030000 /* standard stream */ + +#define _IOSTDIN 010000 /* stdin indication */ +#define _IOSTDOUT 020000 /* stdout indication */ +#define _IOSTDERR 030000 /* stderr indication */ + +#define _IORETAIN (_IOSTDX | _IOINSERT) /* flags to be retained */ + +/* Implementation Definitions */ + +typedef char __stdiobuf_t; /* stdio buffer type */ +typedef _STDIO_USIZE_T_ __stdiosize_t; /* unsigned size_t */ + +typedef struct __iobuf { + __stdiobuf_t *__rptr; /* pointer into read buffer */ + __stdiobuf_t *__rend; /* point at end of read buffer */ + __stdiobuf_t *__wptr; /* pointer into write buffer */ + __stdiobuf_t *__wend; /* point at end of write buffer */ + __stdiobuf_t *__base; /* base of buffer */ + __stdiosize_t __bufsiz; /* size of buffer */ + short __flag; /* flags */ + char __file; /* channel number */ + __stdiobuf_t __buf; /* small buffer */ + int (*__filbuf) _STDIO_P_((struct __iobuf *)); /* fill input buffer */ + int (*__flsbuf) _STDIO_P_((int, struct __iobuf *)); /* flush output buffer */ + int (*__flush) _STDIO_P_((struct __iobuf *)); /* flush buffer */ + struct __iobuf *__next; /* next in chain */ +} FILE; + +extern FILE __stdin; /* stdin */ +extern FILE __stdout; /* stdout */ +extern FILE __stderr; /* stderr */ + +#define stdin (&__stdin) +#define stdout (&__stdout) +#define stderr (&__stderr) + +/* ANSI Stdio Requirements */ + +int getc _STDIO_P_((FILE *)); +#if _STDIO_UCHAR_ +# define getc(p) ((p)->__rptr>=(p)->__rend\ + ?(*(p)->__filbuf)(p)\ + :(int)(*(p)->__rptr++&_STDIO_UCHAR_)) +#else +# define getc(p) ((p)->__rptr>=(p)->__rend\ + ?(*(p)->__filbuf)(p)\ + :(int)((unsigned char)(*(p)->__rptr++))) +#endif + +int getchar _STDIO_P_((void)); +#define getchar() getc(stdin) + +int putc _STDIO_P_((int, FILE *)); +#if _STDIO_UCHAR_ +# define putc(x,p) ((p)->__wptr>=(p)->__wend\ + ?(*(p)->__flsbuf)((x),(p))\ + :(int)(*(p)->__wptr++=(x)&_STDIO_UCHAR_)) +#else +# define putc(x,p) ((p)->__wptr>=(p)->__wend\ + ?(*(p)->__flsbuf)((x),(p))\ + :(int)((unsigned char)(*(p)->__wptr++=(x)))) +#endif + +int putchar _STDIO_P_((int)); +#define putchar(x) putc(x,stdout) + +int feof _STDIO_P_((FILE *)); +#define feof(p) (((p)->__flag&_IOEOF)!=0) + +int ferror _STDIO_P_((FILE *)); +#define ferror(p) (((p)->__flag&_IOERR)!=0) + +void clearerr _STDIO_P_((FILE *)); +#define clearerr(p) ((p)->__flag&=~(_IOEOF|_IOERR)) + +FILE *fopen _STDIO_P_((const char *, const char *)); +FILE *freopen _STDIO_P_((const char *, const char *, FILE *)); +int fflush _STDIO_P_((FILE *)); +int fclose _STDIO_P_((FILE *)); + +int fgetpos _STDIO_P_((FILE *, fpos_t *)); +int fsetpos _STDIO_P_((FILE *, fpos_t *)); +long ftell _STDIO_P_((FILE *)); +int fseek _STDIO_P_((FILE *, long, int)); +void rewind _STDIO_P_((FILE *)); + +int fgetc _STDIO_P_((FILE *)); +int fputc _STDIO_P_((int, FILE *)); +__stdiosize_t fread _STDIO_P_((void *, __stdiosize_t, + __stdiosize_t, FILE *)); +__stdiosize_t fwrite _STDIO_P_((void *, __stdiosize_t, + __stdiosize_t, FILE *)); + +int getw _STDIO_P_((FILE *)); +int putw _STDIO_P_((int, FILE *)); +char *gets _STDIO_P_((char *)); +char *fgets _STDIO_P_((char *, int, FILE *)); +int puts _STDIO_P_((const char *)); +int fputs _STDIO_P_((const char *, FILE *)); + +int ungetc _STDIO_P_((int, FILE *)); + +int printf _STDIO_P_((const char * _STDIO_VA_)); +int fprintf _STDIO_P_((FILE *, const char * _STDIO_VA_)); +int sprintf _STDIO_P_((char *, const char * _STDIO_VA_)); +int vprintf _STDIO_P_((const char *, _STDIO_VA_LIST_)); +int vfprintf _STDIO_P_((FILE *, const char *, _STDIO_VA_LIST_)); +int vsprintf _STDIO_P_((char *, const char *, _STDIO_VA_LIST_)); +int scanf _STDIO_P_((const char * _STDIO_VA_)); +int fscanf _STDIO_P_((FILE *, const char * _STDIO_VA_)); +int sscanf _STDIO_P_((const char *, const char * _STDIO_VA_)); + +void setbuf _STDIO_P_((FILE *, char *)); +int setvbuf _STDIO_P_((FILE *, char *, int, __stdiosize_t)); + +int rename _STDIO_P_((const char *, const char *)); +int remove _STDIO_P_((const char *)); + +void perror _STDIO_P_((const char *)); + +char * tmpnam _STDIO_P_((char *)); +FILE * tmpfile _STDIO_P_((void)); + +/* Posix Definitions */ +int unlink _STDIO_P_((const char *)); +#define remove(x) unlink((x)) + +#define L_ctermid 9 +char * ctermid _STDIO_P_((char *s)); + +#define L_cuserid 9 +char * cuserid _STDIO_P_((char *s)); + +FILE *fdopen _STDIO_P_((int, const char *)); + +int fileno _STDIO_P_((FILE *)); +#define fileno(p) ((p)->__file) + +#undef _STDIO_P_ +#undef _STDIO_VA_ +#undef _STDIO_VA_LIST_ +/*ndef _STDIO_UCHAR_*/ +#undef _STDIO_SIZE_T_ +#undef _STDIO_USIZE_T_ +#endif diff --git a/1/newlibc/include/stdlib.h b/1/newlibc/include/stdlib.h new file mode 100755 index 0000000..7880598 --- /dev/null +++ b/1/newlibc/include/stdlib.h @@ -0,0 +1,43 @@ +#ifndef _STDLIB_H +#define _STDLIB_H + +#include + +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE 1 + +extern double atof(const char * s); +extern int atoi(const char *s); +extern long atol(const char *s); +extern double strtod(const char *s, char **endp); +extern long strtol(const char *s, char **endp, int base); +extern unsigned long strtoul(const char *s, char **endp, int base); +extern int rand(void); +extern void srand(unsigned int seed); +extern void * calloc(size_t nobj, size_t size); +extern void * malloc(size_t size); +extern void * realloc(void * p, size_t size); +extern void free(void * p); +extern void abort(void); +extern volatile void exit(int status); +extern int atexit(void (*fcn)(void)); +extern int system(const char *s); +extern char * getenv(const char *name); +extern void * bsearch(const void *key, const void *base, + size_t n, size_t size, + int (*cmp)(const void *keyval, const void *datum)); +extern void qsort(void *base, size_t n, size_t size, + int (*cmp)(const void *,const void *)); +extern int abs(int n); +extern long labs(long n); +extern div_t div(int num, int denom); +extern ldiv_t ldiv(long num, long denom); +extern char * getcwd(char * buf, size_t size); + +#ifdef __GNUC__ +#define __alloca(n) __builtin_alloca(n) +#else +#define __alloca(n) alloca(n) +#endif + +#endif diff --git a/1/newlibc/include/string.h b/1/newlibc/include/string.h new file mode 100755 index 0000000..05a6d9c --- /dev/null +++ b/1/newlibc/include/string.h @@ -0,0 +1,405 @@ +#ifndef _STRING_H_ +#define _STRING_H_ + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +extern char * strerror(int errno); + +/* + * This string-include defines all string functions as inline + * functions. Use gcc. It also assumes ds=es=data space, this should be + * normal. Most of the string-functions are rather heavily hand-optimized, + * see especially strtok,strstr,str[c]spn. They should work, but are not + * very easy to understand. Everything is done entirely within the register + * set, making the functions fast and clean. String instructions have been + * used through-out, making for "slightly" unclear code :-) + * + * (C) 1991 Linus Torvalds + */ + +extern inline char * strcpy(char * dest,const char *src) +{ +__asm__("cld\n" + "1:\tlodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + ::"S" (src),"D" (dest):"si","di","ax"); +return dest; +} + +extern inline char * strncpy(char * dest,const char *src,int count) +{ +__asm__("cld\n" + "1:\tdecl %2\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "rep\n\t" + "stosb\n" + "2:" + ::"S" (src),"D" (dest),"c" (count):"si","di","ax","cx"); +return dest; +} + +extern inline char * strcat(char * dest,const char * src) +{ +__asm__("cld\n\t" + "repne\n\t" + "scasb\n\t" + "decl %1\n" + "1:\tlodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b" + ::"S" (src),"D" (dest),"a" (0),"c" (0xffffffff):"si","di","ax","cx"); +return dest; +} + +extern inline char * strncat(char * dest,const char * src,int count) +{ +__asm__("cld\n\t" + "repne\n\t" + "scasb\n\t" + "decl %1\n\t" + "movl %4,%3\n" + "1:\tdecl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "stosb\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n" + "2:\txorl %2,%2\n\t" + "stosb" + ::"S" (src),"D" (dest),"a" (0),"c" (0xffffffff),"g" (count) + :"si","di","ax","cx"); +return dest; +} + +extern inline int strcmp(const char * cs,const char * ct) +{ +register int __res __asm__("ax"); +__asm__("cld\n" + "1:\tlodsb\n\t" + "scasb\n\t" + "jne 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "xorl %%eax,%%eax\n\t" + "jmp 3f\n" + "2:\tmovl $1,%%eax\n\t" + "jl 3f\n\t" + "negl %%eax\n" + "3:" + :"=a" (__res):"D" (cs),"S" (ct):"si","di"); +return __res; +} + +extern inline int strncmp(const char * cs,const char * ct,int count) +{ +register int __res __asm__("ax"); +__asm__("cld\n" + "1:\tdecl %3\n\t" + "js 2f\n\t" + "lodsb\n\t" + "scasb\n\t" + "jne 3f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n" + "2:\txorl %%eax,%%eax\n\t" + "jmp 4f\n" + "3:\tmovl $1,%%eax\n\t" + "jl 4f\n\t" + "negl %%eax\n" + "4:" + :"=a" (__res):"D" (cs),"S" (ct),"c" (count):"si","di","cx"); +return __res; +} + +extern inline char * strchr(const char * s,char c) +{ +register char * __res __asm__("ax"); +__asm__("cld\n\t" + "movb %%al,%%ah\n" + "1:\tlodsb\n\t" + "cmpb %%ah,%%al\n\t" + "je 2f\n\t" + "testb %%al,%%al\n\t" + "jne 1b\n\t" + "movl $1,%1\n" + "2:\tmovl %1,%0\n\t" + "decl %0" + :"=a" (__res):"S" (s),"0" (c):"si"); +return __res; +} + +extern inline char * strrchr(const char * s,char c) +{ +register char * __res __asm__("dx"); +__asm__("cld\n\t" + "movb %%al,%%ah\n" + "1:\tlodsb\n\t" + "cmpb %%ah,%%al\n\t" + "jne 2f\n\t" + "movl %%esi,%0\n\t" + "decl %0\n" + "2:\ttestb %%al,%%al\n\t" + "jne 1b" + :"=d" (__res):"0" (0),"S" (s),"a" (c):"ax","si"); +return __res; +} + +extern inline int strspn(const char * cs, const char * ct) +{ +register char * __res __asm__("si"); +__asm__("cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "je 1b\n" + "2:\tdecl %0" + :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) + :"ax","cx","dx","di"); +return __res-cs; +} + +extern inline int strcspn(const char * cs, const char * ct) +{ +register char * __res __asm__("si"); +__asm__("cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "jne 1b\n" + "2:\tdecl %0" + :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) + :"ax","cx","dx","di"); +return __res-cs; +} + +extern inline char * strpbrk(const char * cs,const char * ct) +{ +register char * __res __asm__("si"); +__asm__("cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "movl %%ecx,%%edx\n" + "1:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 2f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "jne 1b\n\t" + "decl %0\n\t" + "jmp 3f\n" + "2:\txorl %0,%0\n" + "3:" + :"=S" (__res):"a" (0),"c" (0xffffffff),"0" (cs),"g" (ct) + :"ax","cx","dx","di"); +return __res; +} + +extern inline char * strstr(const char * cs,const char * ct) +{ +register char * __res __asm__("ax"); +__asm__("cld\n\t" \ + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */ + "movl %%ecx,%%edx\n" + "1:\tmovl %4,%%edi\n\t" + "movl %%esi,%%eax\n\t" + "movl %%edx,%%ecx\n\t" + "repe\n\t" + "cmpsb\n\t" + "je 2f\n\t" /* also works for empty string, see above */ + "xchgl %%eax,%%esi\n\t" + "incl %%esi\n\t" + "cmpb $0,-1(%%eax)\n\t" + "jne 1b\n\t" + "xorl %%eax,%%eax\n\t" + "2:" + :"=a" (__res):"0" (0),"c" (0xffffffff),"S" (cs),"g" (ct) + :"cx","dx","di","si"); +return __res; +} + +extern inline int strlen(const char * s) +{ +register int __res __asm__("cx"); +__asm__("cld\n\t" + "repne\n\t" + "scasb\n\t" + "notl %0\n\t" + "decl %0" + :"=c" (__res):"D" (s),"a" (0),"0" (0xffffffff):"di"); +return __res; +} + +extern char * ___strtok; + +extern inline char * strtok(char * s,const char * ct) +{ +register char * __res __asm__("si"); +__asm__("testl %1,%1\n\t" + "jne 1f\n\t" + "testl %0,%0\n\t" + "je 8f\n\t" + "movl %0,%1\n" + "1:\txorl %0,%0\n\t" + "movl $-1,%%ecx\n\t" + "xorl %%eax,%%eax\n\t" + "cld\n\t" + "movl %4,%%edi\n\t" + "repne\n\t" + "scasb\n\t" + "notl %%ecx\n\t" + "decl %%ecx\n\t" + "je 7f\n\t" /* empty delimeter-string */ + "movl %%ecx,%%edx\n" + "2:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 7f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "je 2b\n\t" + "decl %1\n\t" + "cmpb $0,(%1)\n\t" + "je 7f\n\t" + "movl %1,%0\n" + "3:\tlodsb\n\t" + "testb %%al,%%al\n\t" + "je 5f\n\t" + "movl %4,%%edi\n\t" + "movl %%edx,%%ecx\n\t" + "repne\n\t" + "scasb\n\t" + "jne 3b\n\t" + "decl %1\n\t" + "cmpb $0,(%1)\n\t" + "je 5f\n\t" + "movb $0,(%1)\n\t" + "incl %1\n\t" + "jmp 6f\n" + "5:\txorl %1,%1\n" + "6:\tcmpb $0,(%0)\n\t" + "jne 7f\n\t" + "xorl %0,%0\n" + "7:\ttestl %0,%0\n\t" + "jne 8f\n\t" + "movl %0,%1\n" + "8:" + :"=b" (__res),"=S" (___strtok) + :"0" (___strtok),"1" (s),"g" (ct) + :"ax","cx","dx","di"); +return __res; +} + +extern inline void * memcpy(void * dest,const void * src, int n) +{ +__asm__("cld\n\t" + "rep\n\t" + "movsb" + ::"c" (n),"S" (src),"D" (dest) + :"cx","si","di"); +return dest; +} + +extern inline void * memmove(void * dest,const void * src, int n) +{ +if (dest diff --git a/1/newlibc/include/sys/._dir.h b/1/newlibc/include/sys/._dir.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._dirent.h b/1/newlibc/include/sys/._dirent.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._file.h b/1/newlibc/include/sys/._file.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._ioctl.h b/1/newlibc/include/sys/._ioctl.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._param.h b/1/newlibc/include/sys/._param.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._stat.h b/1/newlibc/include/sys/._stat.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._sysmacros.h b/1/newlibc/include/sys/._sysmacros.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._time.h b/1/newlibc/include/sys/._time.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._timeb.h b/1/newlibc/include/sys/._timeb.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._times.h b/1/newlibc/include/sys/._times.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._types.h b/1/newlibc/include/sys/._types.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._utsname.h b/1/newlibc/include/sys/._utsname.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._varargs.h b/1/newlibc/include/sys/._varargs.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/._wait.h b/1/newlibc/include/sys/._wait.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/include/sys/dir.h b/1/newlibc/include/sys/dir.h new file mode 100755 index 0000000..7ca5a7d --- /dev/null +++ b/1/newlibc/include/sys/dir.h @@ -0,0 +1,16 @@ +#ifndef _SYS_DIR_H +#define _SYS_DIR_H + +#include +#include + +#ifndef DIRSIZ +#define DIRSIZ NAME_MAX +#endif + +struct direct { + ino_t d_ino; + char d_name[NAME_MAX]; +}; + +#endif diff --git a/1/newlibc/include/sys/dirent.h b/1/newlibc/include/sys/dirent.h new file mode 100755 index 0000000..d0873a9 --- /dev/null +++ b/1/newlibc/include/sys/dirent.h @@ -0,0 +1,13 @@ +#ifndef _SYS_DIRENT_H +#define _SYS_DIRENT_H + +#include + +struct dirent { + long d_ino; + off_t d_off; + unsigned short d_reclen; + char d_name[NAME_MAX+1]; +}; + +#endif diff --git a/1/newlibc/include/sys/file.h b/1/newlibc/include/sys/file.h new file mode 100755 index 0000000..5192a59 --- /dev/null +++ b/1/newlibc/include/sys/file.h @@ -0,0 +1,10 @@ +#ifndef _SYS_FILE_H +#define _SYS_FILE_H + +#include + +#define L_SET 0 /* absolute offset */ +#define L_INCR 1 /* relative to current offset */ +#define L_XTND 2 /* relative to end of file */ + +#endif diff --git a/1/newlibc/include/sys/ioctl.h b/1/newlibc/include/sys/ioctl.h new file mode 100755 index 0000000..541e4d5 --- /dev/null +++ b/1/newlibc/include/sys/ioctl.h @@ -0,0 +1,4 @@ +#ifndef _SYS_IOCTL_H +#define _SYS_IOCTL_H + +#endif diff --git a/1/newlibc/include/sys/param.h b/1/newlibc/include/sys/param.h new file mode 100755 index 0000000..0a21cfa --- /dev/null +++ b/1/newlibc/include/sys/param.h @@ -0,0 +1,6 @@ +#ifndef _SYS_PARAM_H +#define _SYS_PARAM_H + +#define HZ 100 + +#endif diff --git a/1/newlibc/include/sys/stat.h b/1/newlibc/include/sys/stat.h new file mode 100755 index 0000000..41c3840 --- /dev/null +++ b/1/newlibc/include/sys/stat.h @@ -0,0 +1,58 @@ +#ifndef _SYS_STAT_H +#define _SYS_STAT_H + +#include + +struct stat { + dev_t st_dev; + ino_t st_ino; + umode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + time_t st_atime; + time_t st_mtime; + time_t st_ctime; +}; + +#define S_IFMT 00170000 +#define S_IFREG 0100000 +#define S_IFBLK 0060000 +#define S_IFDIR 0040000 +#define S_IFCHR 0020000 +#define S_IFIFO 0010000 +#define S_ISUID 0004000 +#define S_ISGID 0002000 +#define S_ISVTX 0001000 + +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) + +#define S_IRWXU 00700 +#define S_IRUSR 00400 +#define S_IWUSR 00200 +#define S_IXUSR 00100 + +#define S_IRWXG 00070 +#define S_IRGRP 00040 +#define S_IWGRP 00020 +#define S_IXGRP 00010 + +#define S_IRWXO 00007 +#define S_IROTH 00004 +#define S_IWOTH 00002 +#define S_IXOTH 00001 + +extern int chmod(const char *_path, mode_t mode); +extern int fstat(int fildes, struct stat *stat_buf); +extern int mkdir(const char *_path, mode_t mode); +extern int mkfifo(const char *_path, mode_t mode); +extern int stat(const char *filename, struct stat *stat_buf); +extern mode_t umask(mode_t mask); + +#endif diff --git a/1/newlibc/include/sys/sysmacros.h b/1/newlibc/include/sys/sysmacros.h new file mode 100755 index 0000000..1747bb8 --- /dev/null +++ b/1/newlibc/include/sys/sysmacros.h @@ -0,0 +1,8 @@ +#ifndef _SYS_SYSMACROS_H +#define _SYS_SYSMACROS_H + +#define major(dev) (((unsigned) (dev))>>8) +#define minor(dev) ((dev)&0xff) +#define makedev(major,minor) ((major<<8)|minor) + +#endif diff --git a/1/newlibc/include/sys/time.h b/1/newlibc/include/sys/time.h new file mode 100755 index 0000000..19645e8 --- /dev/null +++ b/1/newlibc/include/sys/time.h @@ -0,0 +1,55 @@ +#ifndef _SYS_TIME_H +#define _SYS_TIME_H + +/* gettimofday returns this */ +struct timeval { + long tv_sec; /* seconds */ + long tv_usec; /* microseconds */ +}; + +struct timezone { + int tz_minuteswest; /* minutes west of Greenwich */ + int tz_dsttime; /* type of dst correction */ +}; + +#define DST_NONE 0 /* not on dst */ +#define DST_USA 1 /* USA style dst */ +#define DST_AUST 2 /* Australian style dst */ +#define DST_WET 3 /* Western European dst */ +#define DST_MET 4 /* Middle European dst */ +#define DST_EET 5 /* Eastern European dst */ +#define DST_CAN 6 /* Canada */ +#define DST_GB 7 /* Great Britain and Eire */ +#define DST_RUM 8 /* Rumania */ +#define DST_TUR 9 /* Turkey */ +#define DST_AUSTALT 10 /* Australian style with shift in 1986 */ + +/* + * Operations on timevals. + * + * NB: timercmp does not work for >= or <=. + */ +#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) +#define timercmp(tvp, uvp, cmp) \ + ((tvp)->tv_sec cmp (uvp)->tv_sec || \ + (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec) +#define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) + +/* + * Names of the interval timers, and structure + * defining a timer setting. + */ +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 + +struct itimerval { + struct timeval it_interval; /* timer interval */ + struct timeval it_value; /* current value */ +}; + +#include + +int gettimeofday(struct timeval * tp, struct timezone * tz); + +#endif /*_SYS_TIME_H*/ diff --git a/1/newlibc/include/sys/timeb.h b/1/newlibc/include/sys/timeb.h new file mode 100755 index 0000000..caf0b81 --- /dev/null +++ b/1/newlibc/include/sys/timeb.h @@ -0,0 +1,13 @@ +#ifndef _SYS_TIMEB_H +#define _SYS_TIMEB_H + +#include + +struct timeb { + time_t time; + unsigned short millitm; + short timezone; + short dstflag; +}; + +#endif /* _SYS_TIMEB_H */ diff --git a/1/newlibc/include/sys/times.h b/1/newlibc/include/sys/times.h new file mode 100755 index 0000000..68d5bfb --- /dev/null +++ b/1/newlibc/include/sys/times.h @@ -0,0 +1,15 @@ +#ifndef _TIMES_H +#define _TIMES_H + +#include + +struct tms { + time_t tms_utime; + time_t tms_stime; + time_t tms_cutime; + time_t tms_cstime; +}; + +extern time_t times(struct tms * tp); + +#endif diff --git a/1/newlibc/include/sys/types.h b/1/newlibc/include/sys/types.h new file mode 100755 index 0000000..557aa31 --- /dev/null +++ b/1/newlibc/include/sys/types.h @@ -0,0 +1,46 @@ +#ifndef _SYS_TYPES_H +#define _SYS_TYPES_H + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _PTRDIFF_T +#define _PTRDIFF_T +typedef long ptrdiff_t; +#endif + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +typedef int pid_t; +typedef unsigned short uid_t; +typedef unsigned char gid_t; +typedef unsigned short dev_t; +typedef unsigned short ino_t; +typedef unsigned short mode_t; +typedef unsigned short umode_t; +typedef unsigned char nlink_t; +typedef int daddr_t; +typedef long off_t; +typedef unsigned char u_char; +typedef unsigned short ushort; + +typedef struct { int quot,rem; } div_t; +typedef struct { long quot,rem; } ldiv_t; + +struct ustat { + daddr_t f_tfree; + ino_t f_tinode; + char f_fname[6]; + char f_fpack[6]; +}; + +#endif diff --git a/1/newlibc/include/sys/utsname.h b/1/newlibc/include/sys/utsname.h new file mode 100755 index 0000000..0a1c5a0 --- /dev/null +++ b/1/newlibc/include/sys/utsname.h @@ -0,0 +1,16 @@ +#ifndef _SYS_UTSNAME_H +#define _SYS_UTSNAME_H + +#include + +struct utsname { + char sysname[9]; + char nodename[9]; + char release[9]; + char version[9]; + char machine[9]; +}; + +extern int uname(struct utsname * utsbuf); + +#endif diff --git a/1/newlibc/include/sys/varargs.h b/1/newlibc/include/sys/varargs.h new file mode 100755 index 0000000..4bd4921 --- /dev/null +++ b/1/newlibc/include/sys/varargs.h @@ -0,0 +1,19 @@ +/* @(#)varargs.h 1.11 89/06/14 SMI; from UCB 4.1 83/05/03 */ + +#ifndef _sys_varargs_h +#define _sys_varargs_h + +typedef char *va_list; +#if defined(sparc) +# define va_alist __builtin_va_alist +#endif +# define va_dcl int va_alist; +# define va_start(list) list = (char *) &va_alist +# define va_end(list) +# if defined(__BUILTIN_VA_ARG_INCR) && !defined(lint) +# define va_arg(list,mode) ((mode*)__builtin_va_arg_incr((mode *)list))[0] +# else +# define va_arg(list,mode) ((mode *)(list += sizeof(mode)))[-1] +# endif + +#endif /*!_sys_varargs_h*/ diff --git a/1/newlibc/include/sys/wait.h b/1/newlibc/include/sys/wait.h new file mode 100755 index 0000000..53190c2 --- /dev/null +++ b/1/newlibc/include/sys/wait.h @@ -0,0 +1,23 @@ +#ifndef _SYS_WAIT_H +#define _SYS_WAIT_H + +#include + +#define _LOW(v) ( (v) & 0377) +#define _HIGH(v) ( ((v) >> 8) & 0377) + +/* options for waitpid, WUNTRACED not supported */ +#define WNOHANG 1 +#define WUNTRACED 2 + +#define WIFEXITED(s) (!((s)&0xFF) +#define WIFSTOPPED(s) (((s)&0xFF)==0x7F) +#define WEXITSTATUS(s) (((s)>>8)&0xFF) +#define WTERMSIG(s) ((s)&0x7F) +#define WSTOPSIG(s) (((s)>>8)&0xFF) +#define WIFSIGNALED(s) (((unsigned int)(s)-1 & 0xFFFF) < 0xFF) + +pid_t wait(int *stat_loc); +pid_t waitpid(pid_t pid, int *stat_loc, int options); + +#endif diff --git a/1/newlibc/include/termcap.h b/1/newlibc/include/termcap.h new file mode 100755 index 0000000..9947377 --- /dev/null +++ b/1/newlibc/include/termcap.h @@ -0,0 +1,11 @@ +#ifndef _TERMCAP_H +#define _TERMCAP_H + +extern int tgetent(char *bp, char *name); +extern int tgetflag(char *id); +extern int tgetnum(char *id); +extern char *tgetstr(char *id, char **area); +extern char *tgoto(char *cm, int destcol, int destline); +extern int tputs(char *cp, int affcnt, void (*outc)(int)); + +#endif /* _TERMCAP_H */ diff --git a/1/newlibc/include/termio.h b/1/newlibc/include/termio.h new file mode 100755 index 0000000..9e26956 --- /dev/null +++ b/1/newlibc/include/termio.h @@ -0,0 +1 @@ +#include diff --git a/1/newlibc/include/termios.h b/1/newlibc/include/termios.h new file mode 100755 index 0000000..2421db5 --- /dev/null +++ b/1/newlibc/include/termios.h @@ -0,0 +1,225 @@ +#ifndef _TERMIOS_H +#define _TERMIOS_H + +#define TTY_BUF_SIZE 1024 + +/* 0x54 is just a magic number to make these relatively uniqe ('T') */ + +#define TCGETS 0x5401 +#define TCSETS 0x5402 +#define TCSETSW 0x5403 +#define TCSETSF 0x5404 +#define TCGETA 0x5405 +#define TCSETA 0x5406 +#define TCSETAW 0x5407 +#define TCSETAF 0x5408 +#define TCSBRK 0x5409 +#define TCXONC 0x540A +#define TCFLSH 0x540B +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D +#define TIOCSCTTY 0x540E +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCOUTQ 0x5411 +#define TIOCSTI 0x5412 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#define TIOCMGET 0x5415 +#define TIOCMBIS 0x5416 +#define TIOCMBIC 0x5417 +#define TIOCMSET 0x5418 +#define TIOCGSOFTCAR 0x5419 +#define TIOCSSOFTCAR 0x541A +#define TIOCINQ 0x541B + +struct winsize { + unsigned short ws_row; + unsigned short ws_col; + unsigned short ws_xpixel; + unsigned short ws_ypixel; +}; + +#define NCC 8 +struct termio { + unsigned short c_iflag; /* input mode flags */ + unsigned short c_oflag; /* output mode flags */ + unsigned short c_cflag; /* control mode flags */ + unsigned short c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCC]; /* control characters */ +}; + +#define NCCS 17 +struct termios { + unsigned long c_iflag; /* input mode flags */ + unsigned long c_oflag; /* output mode flags */ + unsigned long c_cflag; /* control mode flags */ + unsigned long c_lflag; /* local mode flags */ + unsigned char c_line; /* line discipline */ + unsigned char c_cc[NCCS]; /* control characters */ +}; + +/* c_cc characters */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 +#define NLDLY 0000400 +#define NL0 0000000 +#define NL1 0000400 +#define CRDLY 0003000 +#define CR0 0000000 +#define CR1 0001000 +#define CR2 0002000 +#define CR3 0003000 +#define TABDLY 0014000 +#define TAB0 0000000 +#define TAB1 0004000 +#define TAB2 0010000 +#define TAB3 0014000 +#define XTABS 0014000 +#define BSDLY 0020000 +#define BS0 0000000 +#define BS1 0020000 +#define VTDLY 0040000 +#define VT0 0000000 +#define VT1 0040000 +#define FFDLY 0040000 +#define FF0 0000000 +#define FF1 0040000 + +/* c_cflag bit meaning */ +#define CBAUD 0000017 +#define B0 0000000 /* hang up */ +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define EXTA B19200 +#define EXTB B38400 +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 +#define CIBAUD 03600000 /* input baud rate (not used) */ +#define CRTSCTS 020000000000 /* flow control */ + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#define XCASE 0000004 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define IEXTEN 0100000 + +/* modem lines */ +#define TIOCM_LE 0x001 +#define TIOCM_DTR 0x002 +#define TIOCM_RTS 0x004 +#define TIOCM_ST 0x008 +#define TIOCM_SR 0x010 +#define TIOCM_CTS 0x020 +#define TIOCM_CAR 0x040 +#define TIOCM_RNG 0x080 +#define TIOCM_DSR 0x100 +#define TIOCM_CD TIOCM_CAR +#define TIOCM_RI TIOCM_RNG + +/* tcflow() and TCXONC use these */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 + +/* tcflush() and TCFLSH use these */ +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* tcsetattr uses these */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +typedef int speed_t; + +extern speed_t cfgetispeed(struct termios *termios_p); +extern speed_t cfgetospeed(struct termios *termios_p); +extern int cfsetispeed(struct termios *termios_p, speed_t speed); +extern int cfsetospeed(struct termios *termios_p, speed_t speed); +extern int tcdrain(int fildes); +extern int tcflow(int fildes, int action); +extern int tcflush(int fildes, int queue_selector); +extern int tcgetattr(int fildes, struct termios *termios_p); +extern int tcsendbreak(int fildes, int duration); +extern int tcsetattr(int fildes, int optional_actions, + struct termios *termios_p); + +#endif diff --git a/1/newlibc/include/time.h b/1/newlibc/include/time.h new file mode 100755 index 0000000..fbb4e73 --- /dev/null +++ b/1/newlibc/include/time.h @@ -0,0 +1,49 @@ +#ifndef _TIME_H +#define _TIME_H + +#ifndef _TIME_T +#define _TIME_T +typedef long time_t; +#endif + +#ifndef _SIZE_T +#define _SIZE_T +typedef unsigned int size_t; +#endif + +#ifndef NULL +#define NULL ((void *) 0) +#endif + +#define CLOCKS_PER_SEC 100 + +typedef long clock_t; + +struct tm { + int tm_sec; + int tm_min; + int tm_hour; + int tm_mday; + int tm_mon; + int tm_year; + int tm_wday; + int tm_yday; + int tm_isdst; +}; + +#define __isleap(year) \ + ((year) % 4 == 0 && ((year) % 100 != 0 || (year) % 1000 == 0)) + +clock_t clock(void); +time_t time(time_t * tp); +double difftime(time_t time2, time_t time1); +time_t mktime(struct tm * tp); + +char * asctime(const struct tm * tp); +char * ctime(const time_t * tp); +struct tm * gmtime(const time_t *tp); +struct tm *localtime(const time_t * tp); +size_t strftime(char * s, size_t smax, const char * fmt, const struct tm * tp); +void tzset(void); + +#endif diff --git a/1/newlibc/include/unistd.h b/1/newlibc/include/unistd.h new file mode 100755 index 0000000..dcbc754 --- /dev/null +++ b/1/newlibc/include/unistd.h @@ -0,0 +1,269 @@ +#ifndef _UNISTD_H +#define _UNISTD_H + +/* ok, this may be a joke, but I'm working on it */ +#define _POSIX_VERSION 198808L + +#define _POSIX_CHOWN_RESTRICTED /* only root can do a chown (I think..) */ +#define _POSIX_NO_TRUNC /* no pathname truncation (but see in kernel) */ +#define _POSIX_VDISABLE '\0' /* character to disable things like ^C */ +/*#define _POSIX_SAVED_IDS */ /* we'll get to this yet */ +/*#define _POSIX_JOB_CONTROL */ /* we aren't there quite yet. Soon hopefully */ + +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +#ifndef NULL +#define NULL ((void *)0) +#endif + +/* access */ +#define F_OK 0 +#define X_OK 1 +#define W_OK 2 +#define R_OK 4 + +/* lseek */ +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 + +/* _SC stands for System Configuration. We don't use them much */ +#define _SC_ARG_MAX 1 +#define _SC_CHILD_MAX 2 +#define _SC_CLOCKS_PER_SEC 3 +#define _SC_NGROUPS_MAX 4 +#define _SC_OPEN_MAX 5 +#define _SC_JOB_CONTROL 6 +#define _SC_SAVED_IDS 7 +#define _SC_VERSION 8 + +/* more (possibly) configurable things - now pathnames */ +#define _PC_LINK_MAX 1 +#define _PC_MAX_CANON 2 +#define _PC_MAX_INPUT 3 +#define _PC_NAME_MAX 4 +#define _PC_PATH_MAX 5 +#define _PC_PIPE_BUF 6 +#define _PC_NO_TRUNC 7 +#define _PC_VDISABLE 8 +#define _PC_CHOWN_RESTRICTED 9 + +#include +#include +#include +#include + +#ifdef __LIBRARY__ + +#define __NR_setup 0 /* used only by init, to get system going */ +#define __NR_exit 1 +#define __NR_fork 2 +#define __NR_read 3 +#define __NR_write 4 +#define __NR_open 5 +#define __NR_close 6 +#define __NR_waitpid 7 +#define __NR_creat 8 +#define __NR_link 9 +#define __NR_unlink 10 +#define __NR_execve 11 +#define __NR_chdir 12 +#define __NR_time 13 +#define __NR_mknod 14 +#define __NR_chmod 15 +#define __NR_chown 16 +#define __NR_break 17 +#define __NR_stat 18 +#define __NR_lseek 19 +#define __NR_getpid 20 +#define __NR_mount 21 +#define __NR_umount 22 +#define __NR_setuid 23 +#define __NR_getuid 24 +#define __NR_stime 25 +#define __NR_ptrace 26 +#define __NR_alarm 27 +#define __NR_fstat 28 +#define __NR_pause 29 +#define __NR_utime 30 +#define __NR_stty 31 +#define __NR_gtty 32 +#define __NR_access 33 +#define __NR_nice 34 +#define __NR_ftime 35 +#define __NR_sync 36 +#define __NR_kill 37 +#define __NR_rename 38 +#define __NR_mkdir 39 +#define __NR_rmdir 40 +#define __NR_dup 41 +#define __NR_pipe 42 +#define __NR_times 43 +#define __NR_prof 44 +#define __NR_brk 45 +#define __NR_setgid 46 +#define __NR_getgid 47 +#define __NR_signal 48 +#define __NR_geteuid 49 +#define __NR_getegid 50 +#define __NR_acct 51 +#define __NR_phys 52 +#define __NR_lock 53 +#define __NR_ioctl 54 +#define __NR_fcntl 55 +#define __NR_mpx 56 +#define __NR_setpgid 57 +#define __NR_ulimit 58 +#define __NR_uname 59 +#define __NR_umask 60 +#define __NR_chroot 61 +#define __NR_ustat 62 +#define __NR_dup2 63 +#define __NR_getppid 64 +#define __NR_getpgrp 65 +#define __NR_setsid 66 +#define __NR_sigaction 67 +#define __NR_sgetmask 68 +#define __NR_ssetmask 69 +#define __NR_setreuid 70 +#define __NR_setregid 71 +#define __NR_sigsuspend 72 +#define __NR_sigpending 73 +#define __NR_sethostname 74 +#define __NR_setrlimit 75 +#define __NR_getrlimit 76 +#define __NR_getrusage 77 +#define __NR_gettimeofday 78 +#define __NR_settimeofday 79 +#define __NR_getgroups 80 +#define __NR_setgroups 81 +#define __NR_select 82 +#define __NR_symlink 83 +#define __NR_lstat 84 +#define __NR_readlink 85 +#define __NR_uselib 86 +#define _syscall0(type,name) \ +type name(void) \ +{ \ +long __res; \ +__asm__ volatile ("int $0x80" \ + : "=a" (__res) \ + : "0" (__NR_##name)); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall1(type,name,atype,a) \ +type name(atype a) \ +{ \ +long __res; \ +__asm__ volatile ("int $0x80" \ + : "=a" (__res) \ + : "0" (__NR_##name),"b" ((long)(a))); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall2(type,name,atype,a,btype,b) \ +type name(atype a,btype b) \ +{ \ +long __res; \ +__asm__ volatile ("int $0x80" \ + : "=a" (__res) \ + : "0" (__NR_##name),"b" ((long)(a)),"c" ((long)(b))); \ +if (__res >= 0) \ + return (type) __res; \ +errno = -__res; \ +return -1; \ +} + +#define _syscall3(type,name,atype,a,btype,b,ctype,c) \ +type name(atype a,btype b,ctype c) \ +{ \ +long __res; \ +__asm__ volatile ("int $0x80" \ + : "=a" (__res) \ + : "0" (__NR_##name),"b" ((long)(a)),"c" ((long)(b)),"d" ((long)(c))); \ +if (__res>=0) \ + return (type) __res; \ +errno=-__res; \ +return -1; \ +} + +#endif /* __LIBRARY__ */ + +extern int errno; + +int access(const char * filename, mode_t mode); +int acct(const char * filename); +int alarm(int sec); +int brk(void * end_data_segment); +void * sbrk(ptrdiff_t increment); +int chdir(const char * filename); +int chmod(const char * filename, mode_t mode); +int chown(const char * filename, uid_t owner, gid_t group); +int chroot(const char * filename); +int close(int fildes); +int creat(const char * filename, mode_t mode); +int dup(int fildes); +int execve(const char * filename, char ** argv, char ** envp); +int execv(const char * pathname, char ** argv); +int execvp(const char * file, char ** argv); +int execl(const char * pathname, char * arg0, ...); +int execlp(const char * file, char * arg0, ...); +int execle(const char * pathname, char * arg0, ...); +volatile void exit(int status); +volatile void _exit(int status); +int fcntl(int fildes, int cmd, ...); +int fork(void); +int getpid(void); +int getuid(void); +int geteuid(void); +int getgid(void); +int getegid(void); +int ioctl(int fildes, int cmd, ...); +int kill(pid_t pid, int signal); +int link(const char * filename1, const char * filename2); +int lseek(int fildes, off_t offset, int origin); +int mknod(const char * filename, mode_t mode, dev_t dev); +int mount(const char * specialfile, const char * dir, int rwflag); +int nice(int val); +int open(const char * filename, int flag, ...); +int pause(void); +int pipe(int * fildes); +int read(int fildes, char * buf, off_t count); +int setpgrp(void); +int setpgid(pid_t pid,pid_t pgid); +int setuid(uid_t uid); +int setgid(gid_t gid); +void (*signal(int sig, void (*fn)(int)))(int); +int stat(const char * filename, struct stat * stat_buf); +int fstat(int fildes, struct stat * stat_buf); +int stime(time_t * tptr); +int sync(void); +time_t time(time_t * tloc); +time_t times(struct tms * tbuf); +int ulimit(int cmd, long limit); +mode_t umask(mode_t mask); +int umount(const char * specialfile); +int uname(struct utsname * name); +int unlink(const char * filename); +int ustat(dev_t dev, struct ustat * ubuf); +int utime(const char * filename, struct utimbuf * times); +pid_t waitpid(pid_t pid,int * wait_stat,int options); +pid_t wait(int * wait_stat); +int write(int fildes, const char * buf, off_t count); +int dup2(int oldfd, int newfd); +int getppid(void); +pid_t getpgrp(void); +pid_t setsid(void); + +#define __always_inline inline __attribute__((always_inline)) + +#endif diff --git a/1/newlibc/include/utime.h b/1/newlibc/include/utime.h new file mode 100755 index 0000000..83f07c7 --- /dev/null +++ b/1/newlibc/include/utime.h @@ -0,0 +1,13 @@ +#ifndef _UTIME_H +#define _UTIME_H + +#include /* I know - shouldn't do this, but .. */ + +struct utimbuf { + time_t actime; + time_t modtime; +}; + +extern int utime(const char *filename, struct utimbuf *times); + +#endif diff --git a/1/newlibc/include/varargs.h b/1/newlibc/include/varargs.h new file mode 100755 index 0000000..4bd4921 --- /dev/null +++ b/1/newlibc/include/varargs.h @@ -0,0 +1,19 @@ +/* @(#)varargs.h 1.11 89/06/14 SMI; from UCB 4.1 83/05/03 */ + +#ifndef _sys_varargs_h +#define _sys_varargs_h + +typedef char *va_list; +#if defined(sparc) +# define va_alist __builtin_va_alist +#endif +# define va_dcl int va_alist; +# define va_start(list) list = (char *) &va_alist +# define va_end(list) +# if defined(__BUILTIN_VA_ARG_INCR) && !defined(lint) +# define va_arg(list,mode) ((mode*)__builtin_va_arg_incr((mode *)list))[0] +# else +# define va_arg(list,mode) ((mode *)(list += sizeof(mode)))[-1] +# endif + +#endif /*!_sys_varargs_h*/ diff --git a/1/newlibc/malloc/._Makefile b/1/newlibc/malloc/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._README b/1/newlibc/malloc/._README new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._ansidecl.h b/1/newlibc/malloc/._ansidecl.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._free.c b/1/newlibc/malloc/._free.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._gmalloc.c b/1/newlibc/malloc/._gmalloc.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._gmalloc.c.old b/1/newlibc/malloc/._gmalloc.c.old new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._gmalloc.sed b/1/newlibc/malloc/._gmalloc.sed new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._gmalloc.skel b/1/newlibc/malloc/._gmalloc.skel new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._limits.h b/1/newlibc/malloc/._limits.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._malloc.c.1 b/1/newlibc/malloc/._malloc.c.1 new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._malloc.h b/1/newlibc/malloc/._malloc.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._mcheck.c b/1/newlibc/malloc/._mcheck.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._mstats.c b/1/newlibc/malloc/._mstats.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._realloc.c b/1/newlibc/malloc/._realloc.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._stddef.h b/1/newlibc/malloc/._stddef.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._stdlib.h b/1/newlibc/malloc/._stdlib.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._string.h b/1/newlibc/malloc/._string.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._unix.c b/1/newlibc/malloc/._unix.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/._valloc.c b/1/newlibc/malloc/._valloc.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/Makefile b/1/newlibc/malloc/Makefile new file mode 100755 index 0000000..a950d27 --- /dev/null +++ b/1/newlibc/malloc/Makefile @@ -0,0 +1,18 @@ +CC = gcc +INC=-nostdinc -I. -I../include +CFLAGS=-O $(INC) +OBJS=free.o malloc.o mcheck.o mstats.o realloc.o unix.o valloc.o +ONESRC=ansidecl.h limits.h stddef.h stdlib.h string.h malloc.h \ + free.c malloc.c realloc.c unix.c valloc.c + +all: library + +library: gmalloc.o + $(AR) uvc ../Libc.a gmalloc.o + sync + +#gmalloc.c: $(ONESRC) gmalloc.sed gmalloc.skel +# sed -f gmalloc.sed gmalloc.skel > gmalloc.c + +clean: + $(RM) -f $(OBJS) gmalloc.o diff --git a/1/newlibc/malloc/README b/1/newlibc/malloc/README new file mode 100755 index 0000000..ca01a92 --- /dev/null +++ b/1/newlibc/malloc/README @@ -0,0 +1,4 @@ +This is a alpha/pre-alpha version of the new GNU malloc, and is +intended for people who want to play with it/look for bugs/etc. It +has not been extensively tested and is not intended for widespread +distribution. Bug reports should be sent to mike@ai.mit.edu. diff --git a/1/newlibc/malloc/ansidecl.h b/1/newlibc/malloc/ansidecl.h new file mode 100755 index 0000000..9e8f390 --- /dev/null +++ b/1/newlibc/malloc/ansidecl.h @@ -0,0 +1,93 @@ +/* Copyright (C) 1989 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU C Library; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* ANSI and traditional C compatibility macros + + ANSI C is assumed if __STDC__ is #defined. + + Macros + PTR - Generic pointer type + LONG_DOUBLE - `long double' type + CONST - `const' keyword + VOLATILE - `volatile' keyword + SIGNED - `signed' keyword + PTRCONST - Generic const pointer (void *const) + + EXFUN(name, prototype) - declare external function NAME + with prototype PROTOTYPE + DEFUN(name, arglist, args) - define function NAME with + args ARGLIST of types in ARGS + DEFUN_VOID(name) - define function NAME with no args + AND - argument separator for ARGS + NOARGS - null arglist + DOTS - `...' in args + + For example: + extern int EXFUN(printf, (CONST char *format DOTS)); + int DEFUN(fprintf, (stream, format), + FILE *stream AND CONST char *format DOTS) { ... } + void DEFUN_VOID(abort) { ... } +*/ + +#ifndef _ANSIDECL_H + +#define _ANSIDECL_H 1 + + +/* Every source file includes this file, + so they will all get the switch for lint. */ +/* LINTLIBRARY */ + + +#ifdef __STDC__ + +#define PTR void * +#define PTRCONST void *CONST +#define LONG_DOUBLE long double + +#define AND , +#define NOARGS void +#define CONST const +#define VOLATILE volatile +#define SIGNED signed +#define DOTS , ... + +#define EXFUN(name, proto) name proto +#define DEFUN(name, arglist, args) name(args) +#define DEFUN_VOID(name) name(NOARGS) + +#else /* Not ANSI C. */ + +#define PTR char * +#define PTRCONST PTR +#define LONG_DOUBLE double + +#define AND ; +#define NOARGS +#define CONST +#define VOLATILE +#define SIGNED +#define DOTS + +#define EXFUN(name, proto) name() +#define DEFUN(name, arglist, args) name arglist args; +#define DEFUN_VOID(name) name() + +#endif /* ANSI C. */ + + +#endif /* ansidecl.h */ diff --git a/1/newlibc/malloc/free.c b/1/newlibc/malloc/free.c new file mode 100755 index 0000000..e3ea952 --- /dev/null +++ b/1/newlibc/malloc/free.c @@ -0,0 +1,192 @@ +/* Free a block of memory allocated by `malloc'. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +/* Debugging hook for free. */ +void EXFUN((*__free_hook), (PTR __ptr)); + +/* Return memory to the heap. */ +void +DEFUN(free, (ptr), PTR ptr) +{ + int type; + size_t block, blocks; + register size_t i; + struct list *prev, *next; + + if (ptr == NULL) + return; + + if (__free_hook != NULL) + { + (*__free_hook)(ptr); + return; + } + + block = BLOCK(ptr); + + type = _heapinfo[block].busy.type; + switch (type) + { + case 0: + /* Get as many statistics as early as we can. */ + --_chunks_used; + _bytes_used -= _heapinfo[block].busy.info.size * BLOCKSIZE; + _bytes_free += _heapinfo[block].busy.info.size * BLOCKSIZE; + + /* Find the free cluster previous to this one in the free list. + Start searching at the last block referenced; this may benefit + programs with locality of allocation. */ + i = _heapindex; + if (i > block) + while (i > block) + i = _heapinfo[i].free.prev; + else + { + do + i = _heapinfo[i].free.next; + while (i > 0 && i < block); + i = _heapinfo[i].free.prev; + } + + /* Determine how to link this block into the free list. */ + if (block == i + _heapinfo[i].free.size) + { + /* Coalesce this block with its predecessor. */ + _heapinfo[i].free.size += _heapinfo[block].busy.info.size; + block = i; + } + else + { + /* Really link this block back into the free list. */ + _heapinfo[block].free.size = _heapinfo[block].busy.info.size; + _heapinfo[block].free.next = _heapinfo[i].free.next; + _heapinfo[block].free.prev = i; + _heapinfo[i].free.next = block; + _heapinfo[_heapinfo[block].free.next].free.prev = block; + ++_chunks_free; + } + + /* Now that the block is linked in, see if we can coalesce it + with its successor (by deleting its successor from the list + and adding in its size). */ + if (block + _heapinfo[block].free.size == _heapinfo[block].free.next) + { + _heapinfo[block].free.size + += _heapinfo[_heapinfo[block].free.next].free.size; + _heapinfo[block].free.next + = _heapinfo[_heapinfo[block].free.next].free.next; + _heapinfo[_heapinfo[block].free.next].free.prev = block; + --_chunks_free; + } + + /* Now see if we can return stuff to the system. */ + blocks = _heapinfo[block].free.size; + if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit + && (*__morecore)(0) == ADDRESS(block + blocks)) + { + register size_t bytes = blocks * BLOCKSIZE; + _heaplimit -= blocks; + (*__morecore)(- bytes); + _heapinfo[_heapinfo[block].free.prev].free.next + = _heapinfo[block].free.next; + _heapinfo[_heapinfo[block].free.next].free.prev + = _heapinfo[block].free.prev; + block = _heapinfo[block].free.prev; + --_chunks_free; + _bytes_free -= bytes; + } + + /* Set the next search to begin at this block. */ + _heapindex = block; + break; + + default: + /* Do some of the statistics. */ + --_chunks_used; + _bytes_used -= 1 << type; + ++_chunks_free; + _bytes_free += 1 << type; + + /* Get the address of the first free fragment in this block. */ + prev = (struct list *) ((char *) ADDRESS(block) + + (_heapinfo[block].busy.info.frag.first << type)); + + if (_heapinfo[block].busy.info.frag.nfree == (BLOCKSIZE >> type) - 1) + { + /* If all fragments of this block are free, remove them + from the fragment list and free the whole block. */ + next = prev; + for (i = 1; i < BLOCKSIZE >> type; ++i) + next = next->next; + prev->prev->next = next; + if (next != NULL) + next->prev = prev->prev; + _heapinfo[block].busy.type = 0; + _heapinfo[block].busy.info.size = 1; + + /* Keep the statistics accurate. */ + ++_chunks_used; + _bytes_used += BLOCKSIZE; + _chunks_free -= BLOCKSIZE >> type; + _bytes_free -= BLOCKSIZE; + + free(ADDRESS(block)); + } + else if (_heapinfo[block].busy.info.frag.nfree != 0) + { + /* If some fragments of this block are free, link this + fragment into the fragment list after the first free + fragment of this block. */ + next = (struct list *) ptr; + next->next = prev->next; + next->prev = prev; + prev->next = next; + if (next->next != NULL) + next->next->prev = next; + ++_heapinfo[block].busy.info.frag.nfree; + } + else + { + /* No fragments of this block are free, so link this + fragment into the fragment list and announce that + it is the first free fragment of this block. */ + prev = (struct list *) ptr; + _heapinfo[block].busy.info.frag.nfree = 1; + _heapinfo[block].busy.info.frag.first = (unsigned int) + (((char *) ptr - (char *) NULL) % BLOCKSIZE >> type); + prev->next = _fraghead[type].next; + prev->prev = &_fraghead[type]; + prev->prev->next = prev; + if (prev->next != NULL) + prev->next->prev = prev; + } + break; + } +} diff --git a/1/newlibc/malloc/gmalloc.c b/1/newlibc/malloc/gmalloc.c new file mode 100755 index 0000000..71db4e1 --- /dev/null +++ b/1/newlibc/malloc/gmalloc.c @@ -0,0 +1,1130 @@ + +/* gmalloc.c - THIS FILE IS AUTOMAGICALLY GENERATED SO DON'T EDIT IT. */ + +/* Single-file skeleton for GNU malloc. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#define __ONEFILE + +/* DO NOT DELETE THIS LINE -- ansidecl.h INSERTED HERE. */ +/* Copyright (C) 1989 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU C Library; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* ANSI and traditional C compatibility macros + + ANSI C is assumed if __STDC__ is #defined. + + Macros + PTR - Generic pointer type + LONG_DOUBLE - `long double' type + CONST - `const' keyword + VOLATILE - `volatile' keyword + SIGNED - `signed' keyword + PTRCONST - Generic const pointer (void *const) + + EXFUN(name, prototype) - declare external function NAME + with prototype PROTOTYPE + DEFUN(name, arglist, args) - define function NAME with + args ARGLIST of types in ARGS + DEFUN_VOID(name) - define function NAME with no args + AND - argument separator for ARGS + NOARGS - null arglist + DOTS - `...' in args + + For example: + extern int EXFUN(printf, (CONST char *format DOTS)); + int DEFUN(fprintf, (stream, format), + FILE *stream AND CONST char *format DOTS) { ... } + void DEFUN_VOID(abort) { ... } +*/ + +#ifndef _ANSIDECL_H + +#define _ANSIDECL_H 1 + + +/* Every source file includes this file, + so they will all get the switch for lint. */ +/* LINTLIBRARY */ + + +#ifdef __STDC__ + +#define PTR void * +#define PTRCONST void *CONST +#define LONG_DOUBLE long double + +#define AND , +#define NOARGS void +#define CONST const +#define VOLATILE volatile +#define SIGNED signed +#define DOTS , ... + +#define EXFUN(name, proto) name proto +#define DEFUN(name, arglist, args) name(args) +#define DEFUN_VOID(name) name(NOARGS) + +#else /* Not ANSI C. */ + +#define PTR char * +#define PTRCONST PTR +#define LONG_DOUBLE double + +#define AND ; +#define NOARGS +#define CONST +#define VOLATILE +#define SIGNED +#define DOTS + +#define EXFUN(name, proto) name() +#define DEFUN(name, arglist, args) name arglist args; +#define DEFUN_VOID(name) name() + +#endif /* ANSI C. */ + + +#endif /* ansidecl.h */ + +#ifdef __STDC__ +#include +#else +/* DO NOT DELETE THIS LINE -- limits.h INSERTED HERE. */ +/* Number of bits in a `char'. */ +#define CHAR_BIT 8 + +/* No multibyte characters supported yet. */ +#define MB_LEN_MAX 1 + +/* Minimum and maximum values a `signed char' can hold. */ +#define SCHAR_MIN -128 +#define SCHAR_MAX 127 + +/* Maximum value an `unsigned char' can hold. (Minimum is 0). */ +#define UCHAR_MAX 255U + +/* Minimum and maximum values a `char' can hold. */ +#ifdef __CHAR_UNSIGNED__ +#define CHAR_MIN 0 +#define CHAR_MAX 255U +#else +#define CHAR_MIN -128 +#define CHAR_MAX 127 +#endif + +/* Minimum and maximum values a `signed short int' can hold. */ +#define SHRT_MIN -32768 +#define SHRT_MAX 32767 + +/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ +#define USHRT_MAX 65535U + +/* Minimum and maximum values a `signed int' can hold. */ +#define INT_MIN -2147483648 +#define INT_MAX 2147483647 + +/* Maximum value an `unsigned int' can hold. (Minimum is 0). */ +#define UINT_MAX 4294967295U + +/* Minimum and maximum values a `signed long int' can hold. + (Same as `int'). */ +#define LONG_MIN (-LONG_MAX-1) +#define LONG_MAX 2147483647 + +/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ +#define ULONG_MAX 4294967295U +#endif + +#ifdef __STDC__ +#include +#else +/* DO NOT DELETE THIS LINE -- stddef.h INSERTED HERE. */ +#ifndef _STDDEF_H +#define _STDDEF_H + +/* Signed type of difference of two pointers. */ + +typedef long ptrdiff_t; + +/* Unsigned type of `sizeof' something. */ + +#ifndef _SIZE_T /* in case has defined it. */ +#define _SIZE_T +typedef unsigned long size_t; +#endif /* _SIZE_T */ + +/* A null pointer constant. */ + +#undef NULL /* in case has defined it. */ +#define NULL 0 + +/* Offset of member MEMBER in a struct of type TYPE. */ + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#endif /* _STDDEF_H */ +#endif + +/* DO NOT DELETE THIS LINE -- stdlib.h INSERTED HERE. */ +/* Fake stdlib.h supplying the stuff needed by malloc. */ + +#ifndef __ONEFILE +#include +#endif + +extern void EXFUN(abort, (void)); +extern void EXFUN(free, (PTR)); +extern PTR EXFUN(malloc, (size_t)); +extern PTR EXFUN(realloc, (PTR, size_t)); + +/* DO NOT DELETE THIS LINE -- string.h INSERTED HERE. */ +/* Fake string.h supplying stuff used by malloc. */ +#ifndef __ONEFILE +#include +#endif + +extern PTR EXFUN(memcpy, (PTR, PTR, size_t)); +extern PTR EXFUN(memset, (PTR, int, size_t)); +#define memmove memcpy + +#define _MALLOC_INTERNAL +/* DO NOT DELETE THIS LINE -- malloc.h INSERTED HERE. */ +/* Declarations for `malloc' and friends. + Copyright 1990 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef _MALLOC_H + +#define _MALLOC_H 1 + +#ifndef __ONEFILE +#define __need_NULL +#define __need_size_t +#define __need_ptrdiff_t +#include +#endif + +#ifdef _MALLOC_INTERNAL + +#ifndef __ONEFILE +#include +#endif + +/* The allocator divides the heap into blocks of fixed size; large + requests receive one or more whole blocks, and small requests + receive a fragment of a block. Fragment sizes are powers of two, + and all fragments of a block are the same size. When all the + fragments in a block have been freed, the block itself is freed. */ +#define INT_BIT (CHAR_BIT * sizeof(int)) +#define BLOCKLOG (INT_BIT > 16 ? 12 : 9) +#define BLOCKSIZE (1 << BLOCKLOG) +#define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) + +/* Determine the amount of memory spanned by the initial heap table + (not an absolute limit). */ +#define HEAP (INT_BIT > 16 ? 4194304 : 65536) + +/* Number of contiguous free blocks allowed to build up at the end of + memory before they will be returned to the system. */ +#define FINAL_FREE_BLOCKS 8 + +/* Where to start searching the free list when looking for new memory. + The two possible values are 0 and _heapindex. Starting at 0 seems + to reduce total memory usage, while starting at _heapindex seems to + run faster. */ +#define MALLOC_SEARCH_START _heapindex + +/* Data structure giving per-block information. */ +typedef union + { + /* Heap information for a busy block. */ + struct + { + /* Zero for a large block, or positive giving the + logarithm to the base two of the fragment size. */ + int type; + union + { + struct + { + size_t nfree; /* Free fragments in a fragmented block. */ + size_t first; /* First free fragment of the block. */ + } frag; + /* Size (in blocks) of a large cluster. */ + size_t size; + } info; + } busy; + /* Heap information for a free block (that may be the first of + a free cluster). */ + struct + { + size_t size; /* Size (in blocks) of a free cluster. */ + size_t next; /* Index of next free cluster. */ + size_t prev; /* Index of previous free cluster. */ + } free; + } malloc_info; + +/* Pointer to first block of the heap. */ +extern char *_heapbase; + +/* Table indexed by block number giving per-block information. */ +extern malloc_info *_heapinfo; + +/* Address to block number and vice versa. */ +#define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) +#define ADDRESS(B) ((PTR) (((B) - 1) * BLOCKSIZE + _heapbase)) + +/* Current search index for the heap table. */ +extern size_t _heapindex; + +/* Limit of valid info table indices. */ +extern size_t _heaplimit; + +/* Doubly linked lists of free fragments. */ +struct list + { + struct list *next; + struct list *prev; + }; + +/* Free list headers for each fragment size. */ +extern struct list _fraghead[]; + +/* Instrumentation. */ +extern size_t _chunks_used; +extern size_t _bytes_used; +extern size_t _chunks_free; +extern size_t _bytes_free; + +/* Internal version of free() used in morecore(). */ +extern void EXFUN(__free, (PTR __ptr)); + +#endif /* _MALLOC_INTERNAL. */ + +/* Underlying allocation function; successive calls should + return contiguous pieces of memory. */ +extern PTR EXFUN((*__morecore), (ptrdiff_t __size)); + +/* Default value of previous. */ +extern PTR EXFUN(__default_morecore, (ptrdiff_t __size)); + +/* Flag whether malloc has been called. */ +extern int __malloc_initialized; + +/* Hooks for debugging versions. */ +extern void EXFUN((*__free_hook), (PTR __ptr)); +extern PTR EXFUN((*__malloc_hook), (size_t __size)); +extern PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); + +/* Activate a standard collection of debugging hooks. */ +extern void EXFUN(mcheck, (void EXFUN((*func), (void)))); + +/* Statistics available to the user. */ +struct mstats + { + size_t bytes_total; /* Total size of the heap. */ + size_t chunks_used; /* Chunks allocated by the user. */ + size_t bytes_used; /* Byte total of user-allocated chunks. */ + size_t chunks_free; /* Chunks in the free list. */ + size_t bytes_free; /* Byte total of chunks in the free list. */ + }; + +/* Pick up the current statistics. */ +extern struct mstats EXFUN(mstats, (NOARGS)); + +#endif /* malloc.h */ + +/* DO NOT DELETE THIS LINE -- free.c INSERTED HERE. */ +/* Free a block of memory allocated by `malloc'. + Copyright 1990 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +/* Debugging hook for free. */ +void EXFUN((*__free_hook), (PTR __ptr)); + +/* Return memory to the heap. Like free() but don't call a __free_hook + if there is one. */ +void +DEFUN(__free, (ptr), PTR ptr) +{ + int type; + size_t block, blocks; + register size_t i; + struct list *prev, *next; + + block = BLOCK(ptr); + + type = _heapinfo[block].busy.type; + switch (type) + { + case 0: + /* Get as many statistics as early as we can. */ + --_chunks_used; + _bytes_used -= _heapinfo[block].busy.info.size * BLOCKSIZE; + _bytes_free += _heapinfo[block].busy.info.size * BLOCKSIZE; + + /* Find the free cluster previous to this one in the free list. + Start searching at the last block referenced; this may benefit + programs with locality of allocation. */ + i = _heapindex; + if (i > block) + while (i > block) + i = _heapinfo[i].free.prev; + else + { + do + i = _heapinfo[i].free.next; + while (i > 0 && i < block); + i = _heapinfo[i].free.prev; + } + + /* Determine how to link this block into the free list. */ + if (block == i + _heapinfo[i].free.size) + { + /* Coalesce this block with its predecessor. */ + _heapinfo[i].free.size += _heapinfo[block].busy.info.size; + block = i; + } + else + { + /* Really link this block back into the free list. */ + _heapinfo[block].free.size = _heapinfo[block].busy.info.size; + _heapinfo[block].free.next = _heapinfo[i].free.next; + _heapinfo[block].free.prev = i; + _heapinfo[i].free.next = block; + _heapinfo[_heapinfo[block].free.next].free.prev = block; + ++_chunks_free; + } + + /* Now that the block is linked in, see if we can coalesce it + with its successor (by deleting its successor from the list + and adding in its size). */ + if (block + _heapinfo[block].free.size == _heapinfo[block].free.next) + { + _heapinfo[block].free.size + += _heapinfo[_heapinfo[block].free.next].free.size; + _heapinfo[block].free.next + = _heapinfo[_heapinfo[block].free.next].free.next; + _heapinfo[_heapinfo[block].free.next].free.prev = block; + --_chunks_free; + } + + /* Now see if we can return stuff to the system. */ + blocks = _heapinfo[block].free.size; + if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit + && (*__morecore)(0) == ADDRESS(block + blocks)) + { + register size_t bytes = blocks * BLOCKSIZE; + _heaplimit -= blocks; + (*__morecore)(- bytes); + _heapinfo[_heapinfo[block].free.prev].free.next + = _heapinfo[block].free.next; + _heapinfo[_heapinfo[block].free.next].free.prev + = _heapinfo[block].free.prev; + block = _heapinfo[block].free.prev; + --_chunks_free; + _bytes_free -= bytes; + } + + /* Set the next search to begin at this block. */ + _heapindex = block; + break; + + default: + /* Do some of the statistics. */ + --_chunks_used; + _bytes_used -= 1 << type; + ++_chunks_free; + _bytes_free += 1 << type; + + /* Get the address of the first free fragment in this block. */ + prev = (struct list *) ((char *) ADDRESS(block) + + (_heapinfo[block].busy.info.frag.first << type)); + + if (_heapinfo[block].busy.info.frag.nfree == (BLOCKSIZE >> type) - 1) + { + /* If all fragments of this block are free, remove them + from the fragment list and free the whole block. */ + next = prev; + for (i = 1; i < BLOCKSIZE >> type; ++i) + next = next->next; + prev->prev->next = next; + if (next != NULL) + next->prev = prev->prev; + _heapinfo[block].busy.type = 0; + _heapinfo[block].busy.info.size = 1; + + /* Keep the statistics accurate. */ + ++_chunks_used; + _bytes_used += BLOCKSIZE; + _chunks_free -= BLOCKSIZE >> type; + _bytes_free -= BLOCKSIZE; + + free(ADDRESS(block)); + } + else if (_heapinfo[block].busy.info.frag.nfree != 0) + { + /* If some fragments of this block are free, link this + fragment into the fragment list after the first free + fragment of this block. */ + next = (struct list *) ptr; + next->next = prev->next; + next->prev = prev; + prev->next = next; + if (next->next != NULL) + next->next->prev = next; + ++_heapinfo[block].busy.info.frag.nfree; + } + else + { + /* No fragments of this block are free, so link this + fragment into the fragment list and announce that + it is the first free fragment of this block. */ + prev = (struct list *) ptr; + _heapinfo[block].busy.info.frag.nfree = 1; + _heapinfo[block].busy.info.frag.first = (unsigned int) + (((char *) ptr - (char *) NULL) % BLOCKSIZE >> type); + prev->next = _fraghead[type].next; + prev->prev = &_fraghead[type]; + prev->prev->next = prev; + if (prev->next != NULL) + prev->next->prev = prev; + } + break; + } +} + +/* Return memory to the heap. */ +void +DEFUN(free, (ptr), PTR ptr) +{ + if (ptr == NULL) + return; + + if (__free_hook != NULL) + (*__free_hook)(ptr); + else + __free (ptr); +} + +/* DO NOT DELETE THIS LINE -- malloc.c INSERTED HERE. */ +/* Memory allocator `malloc'. + Copyright 1990 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#include +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +/* How to really get more memory. */ +PTR EXFUN((*__morecore), (ptrdiff_t __size)) = __default_morecore; + +/* Debugging hook for `malloc'. */ +PTR EXFUN((*__malloc_hook), (size_t __size)); + +/* Pointer to the base of the first block. */ +char *_heapbase; + +/* Block information table. Allocated with align/__free (not malloc/free). */ +malloc_info *_heapinfo; + +/* Number of info entries. */ +static size_t heapsize; + +/* Search index in the info table. */ +size_t _heapindex; + +/* Limit of valid info table indices. */ +size_t _heaplimit; + +/* Free lists for each fragment size. */ +struct list _fraghead[BLOCKLOG]; + +/* Instrumentation. */ +size_t _chunks_used; +size_t _bytes_used; +size_t _chunks_free; +size_t _bytes_free; + +/* Are you experienced? */ +int __malloc_initialized; + +/* Aligned allocation. */ +static PTR +DEFUN(align, (size), size_t size) +{ + PTR result; + unsigned int adj; + + result = (*__morecore)(size); + adj = (unsigned int) ((char *) result - (char *) NULL) % BLOCKSIZE; + if (adj != 0) + { + adj = BLOCKSIZE - adj; + (void) (*__morecore)(adj); + result = (char *) result + adj; + } + return result; +} + +/* Set everything up and remember that we have. */ +static int +DEFUN_VOID(initialize) +{ + heapsize = HEAP / BLOCKSIZE; + _heapinfo = (malloc_info *) align(heapsize * sizeof(malloc_info)); + if (_heapinfo == NULL) + return 0; + memset(_heapinfo, 0, heapsize * sizeof(malloc_info)); + _heapinfo[0].free.size = 0; + _heapinfo[0].free.next = _heapinfo[0].free.prev = 0; + _heapindex = 0; + _heapbase = (char *) _heapinfo; + __malloc_initialized = 1; + return 1; +} + +/* Get neatly aligned memory, initializing or + growing the heap info table as necessary. */ +static PTR +DEFUN(morecore, (size), size_t size) +{ + PTR result; + malloc_info *newinfo, *oldinfo; + size_t newsize; + + result = align(size); + if (result == NULL) + return NULL; + + /* Check if we need to grow the info table. */ + if (BLOCK((char *) result + size) > heapsize) + { + newsize = heapsize; + while (BLOCK((char *) result + size) > newsize) + newsize *= 2; + newinfo = (malloc_info *) align(newsize * sizeof(malloc_info)); + if (newinfo == NULL) + { + (*__morecore)(- size); + return NULL; + } + memset(newinfo, 0, newsize * sizeof(malloc_info)); + memcpy(newinfo, _heapinfo, heapsize * sizeof(malloc_info)); + oldinfo = _heapinfo; + newinfo[BLOCK(oldinfo)].busy.type = 0; + newinfo[BLOCK(oldinfo)].busy.info.size + = BLOCKIFY(heapsize * sizeof(malloc_info)); + _heapinfo = newinfo; + __free(oldinfo); + heapsize = newsize; + } + + _heaplimit = BLOCK((char *) result + size); + return result; +} + +void * calloc(size_t n, size_t size) +{ + void * tmp; + size_t total = n*size; + + if (tmp=malloc(total)) + memset(tmp,0,total); + return tmp; +} + +/* Allocate memory from the heap. */ +PTR +DEFUN(malloc, (size), size_t size) +{ + PTR result; + size_t block, blocks, lastblocks, start; + register size_t i; + struct list *next; + + if (size == 0) + return NULL; + + if (__malloc_hook != NULL) + return (*__malloc_hook)(size); + + if (!__malloc_initialized) + if (!initialize()) + return NULL; + + if (size < sizeof(struct list)) + size = sizeof(struct list); + + /* Determine the allocation policy based on the request size. */ + if (size <= BLOCKSIZE / 2) + { + /* Small allocation to receive a fragment of a block. + Determine the logarithm to base two of the fragment size. */ + register size_t log = 1; + --size; + while ((size /= 2) != 0) + ++log; + + /* Look in the fragment lists for a + free fragment of the desired size. */ + next = _fraghead[log].next; + if (next != NULL) + { + /* There are free fragments of this size. + Pop a fragment out of the fragment list and return it. + Update the block's nfree and first counters. */ + result = (PTR) next; + next->prev->next = next->next; + if (next->next != NULL) + next->next->prev = next->prev; + block = BLOCK(result); + if (--_heapinfo[block].busy.info.frag.nfree != 0) + _heapinfo[block].busy.info.frag.first = (unsigned int) + (((char *) next->next - (char *) NULL) % BLOCKSIZE) >> log; + + /* Update the statistics. */ + ++_chunks_used; + _bytes_used += 1 << log; + --_chunks_free; + _bytes_free -= 1 << log; + } + else + { + /* No free fragments of the desired size, so get a new block + and break it into fragments, returning the first. */ + result = malloc(BLOCKSIZE); + if (result == NULL) + return NULL; + + /* Link all fragments but the first into the free list. */ + for (i = 1; i < BLOCKSIZE >> log; ++i) + { + next = (struct list *) ((char *) result + (i << log)); + next->next = _fraghead[log].next; + next->prev = &_fraghead[log]; + next->prev->next = next; + if (next->next != NULL) + next->next->prev = next; + } + + /* Initialize the nfree and first counters for this block. */ + block = BLOCK(result); + _heapinfo[block].busy.type = log; + _heapinfo[block].busy.info.frag.nfree = i - 1; + _heapinfo[block].busy.info.frag.first = i - 1; + + _chunks_free += (BLOCKSIZE >> log) - 1; + _bytes_free += BLOCKSIZE - (1 << log); + } + } + else + { + /* Large allocation to receive one or more blocks. + Search the free list in a circle starting at the last place visited. + If we loop completely around without finding a large enough + space we will have to get more memory from the system. */ + blocks = BLOCKIFY(size); + start = block = MALLOC_SEARCH_START; + while (_heapinfo[block].free.size < blocks) + { + block = _heapinfo[block].free.next; + if (block == start) + { + /* Need to get more from the system. Check to see if + the new core will be contiguous with the final free + block; if so we don't need to get as much. */ + block = _heapinfo[0].free.prev; + lastblocks = _heapinfo[block].free.size; + if (_heaplimit != 0 && block + lastblocks == _heaplimit && + (*__morecore)(0) == ADDRESS(block + lastblocks) && + (morecore((blocks - lastblocks) * BLOCKSIZE)) != NULL) + { + _heapinfo[block].free.size = blocks; + _bytes_free += (blocks - lastblocks) * BLOCKSIZE; + continue; + } + result = morecore(blocks * BLOCKSIZE); + if (result == NULL) + return NULL; + block = BLOCK(result); + _heapinfo[block].busy.type = 0; + _heapinfo[block].busy.info.size = blocks; + ++_chunks_used; + _bytes_used += blocks * BLOCKSIZE; + return result; + } + } + + /* At this point we have found a suitable free list entry. + Figure out how to remove what we need from the list. */ + result = ADDRESS(block); + if (_heapinfo[block].free.size > blocks) + { + /* The block we found has a bit left over, + so relink the tail end back into the free list. */ + _heapinfo[block + blocks].free.size + = _heapinfo[block].free.size - blocks; + _heapinfo[block + blocks].free.next + = _heapinfo[block].free.next; + _heapinfo[block + blocks].free.prev + = _heapinfo[block].free.prev; + _heapinfo[_heapinfo[block].free.prev].free.next + = _heapinfo[_heapinfo[block].free.next].free.prev + = _heapindex = block + blocks; + } + else + { + /* The block exactly matches our requirements, + so just remove it from the list. */ + _heapinfo[_heapinfo[block].free.next].free.prev + = _heapinfo[block].free.prev; + _heapinfo[_heapinfo[block].free.prev].free.next + = _heapindex = _heapinfo[block].free.next; + --_chunks_free; + } + + _heapinfo[block].busy.type = 0; + _heapinfo[block].busy.info.size = blocks; + ++_chunks_used; + _bytes_used += blocks * BLOCKSIZE; + _bytes_free -= blocks * BLOCKSIZE; + } + + return result; +} + +/* DO NOT DELETE THIS LINE -- realloc.c INSERTED HERE. */ +/* Change the size of a block allocated by `malloc'. + Copyright 1990 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +#define MIN(A, B) ((A) < (B) ? (A) : (B)) + +/* Debugging hook for realloc. */ +PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); + +/* Resize the given region to the new size, returning a pointer + to the (possibly moved) region. This is optimized for speed; + some benchmarks seem to indicate that greater compactness is + achieved by unconditionally allocating and copying to a + new region. This module has incestuous knowledge of the + internals of both free and malloc. */ +PTR +DEFUN(realloc, (ptr, size), PTR ptr AND size_t size) +{ + PTR result; + int type; + size_t block, blocks, oldlimit; + + if (size == 0) + { + free(ptr); + return NULL; + } + else if (ptr == NULL) + return malloc(size); + + if (__realloc_hook != NULL) + return (*__realloc_hook)(ptr, size); + + block = BLOCK(ptr); + + type = _heapinfo[block].busy.type; + switch (type) + { + case 0: + /* Maybe reallocate a large block to a small fragment. */ + if (size <= BLOCKSIZE / 2) + { + result = malloc(size); + if (result != NULL) + { + memcpy(result, ptr, size); + free(ptr); + return result; + } + } + + /* The new size is a large allocation as well; + see if we can hold it in place. */ + blocks = BLOCKIFY(size); + if (blocks < _heapinfo[block].busy.info.size) + { + /* The new size is smaller; return + excess memory to the free list. */ + _heapinfo[block + blocks].busy.type = 0; + _heapinfo[block + blocks].busy.info.size + = _heapinfo[block].busy.info.size - blocks; + _heapinfo[block].busy.info.size = blocks; + free(ADDRESS(block + blocks)); + result = ptr; + } + else if (blocks == _heapinfo[block].busy.info.size) + /* No size change necessary. */ + result = ptr; + else + { + /* Won't fit, so allocate a new region that will. + Free the old region first in case there is sufficient + adjacent free space to grow without moving. */ + blocks = _heapinfo[block].busy.info.size; + /* Prevent free from actually returning memory to the system. */ + oldlimit = _heaplimit; + _heaplimit = 0; + free(ptr); + _heaplimit = oldlimit; + result = malloc(size); + if (result == NULL) + { + (void) malloc(blocks * BLOCKSIZE); + return NULL; + } + if (ptr != result) + memmove(result, ptr, blocks * BLOCKSIZE); + } + break; + + default: + /* Old size is a fragment; type is logarithm + to base two of the fragment size. */ + if (size > 1 << (type - 1) && size <= 1 << type) + /* The new size is the same kind of fragment. */ + result = ptr; + else + { + /* The new size is different; allocate a new space, + and copy the lesser of the new size and the old. */ + result = malloc(size); + if (result == NULL) + return NULL; + memcpy(result, ptr, MIN(size, 1 << type)); + free(ptr); + } + break; + } + + return result; +} + +/* DO NOT DELETE THIS LINE -- unix.c INSERTED HERE. */ +/* unix.c - get more memory with a UNIX system call. + Copyright 1990 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +extern PTR EXFUN(sbrk, (ptrdiff_t size)); + +PTR +DEFUN(__default_morecore, (size), ptrdiff_t size) +{ + PTR result; + + result = sbrk(size); + if (result == (PTR) -1) + return NULL; + return result; +} + +#define __getpagesize getpagesize +/* DO NOT DELETE THIS LINE -- valloc.c INSERTED HERE. */ +/* Allocate memory on a page boundary. + Copyright 1990 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#endif /* __ONEFILE */ + +#ifdef linux +#define getpagesize() 4096 +#else +extern size_t EXFUN(__getpagesize, (NOARGS)); +#endif + +static size_t pagesize; + +PTR +DEFUN(valloc, (size), size_t size) +{ + PTR result; + unsigned int adj; + + if (pagesize == 0) + pagesize = __getpagesize(); + + result = malloc(size + pagesize); + if (result == NULL) + return NULL; + adj = (unsigned int) ((char *) result - (char *) NULL) % pagesize; + if (adj != 0) + result = (char *) result + pagesize - adj; + return result; +} diff --git a/1/newlibc/malloc/gmalloc.c.old b/1/newlibc/malloc/gmalloc.c.old new file mode 100755 index 0000000..3e96215 --- /dev/null +++ b/1/newlibc/malloc/gmalloc.c.old @@ -0,0 +1,1111 @@ + +/* gmalloc.c - THIS FILE IS AUTOMAGICALLY GENERATED SO DON'T EDIT IT. */ + +/* Single-file skeleton for GNU malloc. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#define __ONEFILE + +/* DO NOT DELETE THIS LINE -- ansidecl.h INSERTED HERE. */ +/* Copyright (C) 1989 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with the GNU C Library; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* ANSI and traditional C compatibility macros + + ANSI C is assumed if __STDC__ is #defined. + + Macros + PTR - Generic pointer type + LONG_DOUBLE - `long double' type + CONST - `const' keyword + VOLATILE - `volatile' keyword + SIGNED - `signed' keyword + PTRCONST - Generic const pointer (void *const) + + EXFUN(name, prototype) - declare external function NAME + with prototype PROTOTYPE + DEFUN(name, arglist, args) - define function NAME with + args ARGLIST of types in ARGS + DEFUN_VOID(name) - define function NAME with no args + AND - argument separator for ARGS + NOARGS - null arglist + DOTS - `...' in args + + For example: + extern int EXFUN(printf, (CONST char *format DOTS)); + int DEFUN(fprintf, (stream, format), + FILE *stream AND CONST char *format DOTS) { ... } + void DEFUN_VOID(abort) { ... } +*/ + +#ifndef _ANSIDECL_H + +#define _ANSIDECL_H 1 + + +/* Every source file includes this file, + so they will all get the switch for lint. */ +/* LINTLIBRARY */ + + +#ifdef __STDC__ + +#define PTR void * +#define PTRCONST void *CONST +#define LONG_DOUBLE long double + +#define AND , +#define NOARGS void +#define CONST const +#define VOLATILE volatile +#define SIGNED signed +#define DOTS , ... + +#define EXFUN(name, proto) name proto +#define DEFUN(name, arglist, args) name(args) +#define DEFUN_VOID(name) name(NOARGS) + +#else /* Not ANSI C. */ + +#define PTR char * +#define PTRCONST PTR +#define LONG_DOUBLE double + +#define AND ; +#define NOARGS +#define CONST +#define VOLATILE +#define SIGNED +#define DOTS + +#define EXFUN(name, proto) name() +#define DEFUN(name, arglist, args) name arglist args; +#define DEFUN_VOID(name) name() + +#endif /* ANSI C. */ + + +#endif /* ansidecl.h */ + +#ifdef __STDC__ +#include +#else +/* DO NOT DELETE THIS LINE -- limits.h INSERTED HERE. */ +/* Number of bits in a `char'. */ +#define CHAR_BIT 8 + +/* No multibyte characters supported yet. */ +#define MB_LEN_MAX 1 + +/* Minimum and maximum values a `signed char' can hold. */ +#define SCHAR_MIN -128 +#define SCHAR_MAX 127 + +/* Maximum value an `unsigned char' can hold. (Minimum is 0). */ +#define UCHAR_MAX 255U + +/* Minimum and maximum values a `char' can hold. */ +#ifdef __CHAR_UNSIGNED__ +#define CHAR_MIN 0 +#define CHAR_MAX 255U +#else +#define CHAR_MIN -128 +#define CHAR_MAX 127 +#endif + +/* Minimum and maximum values a `signed short int' can hold. */ +#define SHRT_MIN -32768 +#define SHRT_MAX 32767 + +/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ +#define USHRT_MAX 65535U + +/* Minimum and maximum values a `signed int' can hold. */ +#define INT_MIN -2147483648 +#define INT_MAX 2147483647 + +/* Maximum value an `unsigned int' can hold. (Minimum is 0). */ +#define UINT_MAX 4294967295U + +/* Minimum and maximum values a `signed long int' can hold. + (Same as `int'). */ +#define LONG_MIN (-LONG_MAX-1) +#define LONG_MAX 2147483647 + +/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ +#define ULONG_MAX 4294967295U +#endif + +#ifdef __STDC__ +#include +#else +/* DO NOT DELETE THIS LINE -- stddef.h INSERTED HERE. */ +#ifndef _STDDEF_H +#define _STDDEF_H + +/* Signed type of difference of two pointers. */ + +typedef long ptrdiff_t; + +/* Unsigned type of `sizeof' something. */ + +#ifndef _SIZE_T /* in case has defined it. */ +#define _SIZE_T +typedef unsigned long size_t; +#endif /* _SIZE_T */ + +/* A null pointer constant. */ + +#undef NULL /* in case has defined it. */ +#define NULL 0 + +/* Offset of member MEMBER in a struct of type TYPE. */ + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#endif /* _STDDEF_H */ +#endif + +/* DO NOT DELETE THIS LINE -- stdlib.h INSERTED HERE. */ +/* Fake stdlib.h supplying the stuff needed by malloc. */ + +#ifndef __ONEFILE +#include +#endif + +extern void EXFUN(abort, (void)); +extern void EXFUN(free, (PTR)); +extern PTR EXFUN(malloc, (size_t)); +extern PTR EXFUN(realloc, (PTR, size_t)); + +/* DO NOT DELETE THIS LINE -- string.h INSERTED HERE. */ +/* Fake string.h supplying stuff used by malloc. */ +#ifndef __ONEFILE +#include +#endif + +extern PTR EXFUN(memcpy, (PTR, PTR, size_t)); +extern PTR EXFUN(memset, (PTR, int, size_t)); +#define memmove memcpy + +#define _MALLOC_INTERNAL +/* DO NOT DELETE THIS LINE -- malloc.h INSERTED HERE. */ +/* Declarations for `malloc' and friends. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef _MALLOC_H + +#define _MALLOC_H 1 + +#ifndef __ONEFILE +#define __need_NULL +#define __need_size_t +#define __need_ptrdiff_t +#include +#endif + +#ifdef _MALLOC_INTERNAL + +#ifndef __ONEFILE +#include +#endif + +/* The allocator divides the heap into blocks of fixed size; large + requests receive one or more whole blocks, and small requests + receive a fragment of a block. Fragment sizes are powers of two, + and all fragments of a block are the same size. When all the + fragments in a block have been freed, the block itself is freed. */ +#define INT_BIT (CHAR_BIT * sizeof(int)) +#define BLOCKLOG (INT_BIT > 16 ? 12 : 9) +#define BLOCKSIZE (1 << BLOCKLOG) +#define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) + +/* Determine the amount of memory spanned by the initial heap table + (not an absolute limit). */ +#define HEAP (INT_BIT > 16 ? 4194304 : 65536) + +/* Number of contiguous free blocks allowed to build up at the end of + memory before they will be returned to the system. */ +#define FINAL_FREE_BLOCKS 8 + +/* Where to start searching the free list when looking for new memory. + The two possible values are 0 and _heapindex. Starting at 0 seems + to reduce total memory usage, while starting at _heapindex seems to + run faster. */ +#define MALLOC_SEARCH_START _heapindex + +/* Data structure giving per-block information. */ +typedef union + { + struct + { + /* Zero for a large block, or positive giving the + logarithm to the base two of the fragment size. */ + int type; + + union + { + struct + { + size_t nfree; /* Free fragments in a fragmented block. */ + size_t first; /* First free fragment of the block. */ + } frag; + /* Size (in blocks) of a large cluster. */ + size_t size; + } info; + } busy; + struct + { + size_t size; /* Size (in blocks) of a free cluster. */ + size_t next; /* Index of next free cluster. */ + size_t prev; /* Index of previous free cluster. */ + } free; + } malloc_info; + +/* Pointer to first block of the heap. */ +extern char *_heapbase; + +/* Table indexed by block number giving per-block information. */ +extern malloc_info *_heapinfo; + +/* Address to block number and vice versa. */ +#define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) +#define ADDRESS(B) ((PTR) (((B) - 1) * BLOCKSIZE + _heapbase)) + +/* Current search index for the heap table. */ +extern size_t _heapindex; + +/* Limit of valid info table indices. */ +extern size_t _heaplimit; + +/* Doubly linked lists of free fragments. */ +struct list + { + struct list *next; + struct list *prev; + }; + +/* Free list headers for each fragment size. */ +extern struct list _fraghead[]; + +/* Instrumentation. */ +extern size_t _chunks_used; +extern size_t _bytes_used; +extern size_t _chunks_free; +extern size_t _bytes_free; + +#endif /* _MALLOC_INTERNAL. */ + +/* Underlying allocation function; successive calls should + return contiguous pieces of memory. */ +extern PTR EXFUN((*__morecore), (ptrdiff_t __size)); + +/* Default value of previous. */ +extern PTR EXFUN(__default_morecore, (ptrdiff_t __size)); + +/* Flag whether malloc has been called. */ +extern int __malloc_initialized; + +/* Hooks for debugging versions. */ +extern void EXFUN((*__free_hook), (PTR __ptr)); +extern PTR EXFUN((*__malloc_hook), (size_t __size)); +extern PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); + +/* Activate a standard collection of debugging hooks. */ +extern void EXFUN(mcheck, (NOARGS)); + +/* Statistics available to the user. */ +struct mstats + { + size_t bytes_total; /* Total size of the heap. */ + size_t chunks_used; /* Chunks allocated by the user. */ + size_t bytes_used; /* Byte total of user-allocated chunks. */ + size_t chunks_free; /* Chunks in the free list. */ + size_t bytes_free; /* Byte total of chunks in the free list. */ + }; + +/* Pick up the current statistics. */ +extern struct mstats EXFUN(mstats, (NOARGS)); + +#endif /* malloc.h */ + +/* DO NOT DELETE THIS LINE -- free.c INSERTED HERE. */ +/* Free a block of memory allocated by `malloc'. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +/* Debugging hook for free. */ +void EXFUN((*__free_hook), (PTR __ptr)); + +/* Return memory to the heap. */ +void +DEFUN(free, (ptr), PTR ptr) +{ + int type; + size_t block, blocks; + register size_t i; + struct list *prev, *next; + + if (ptr == NULL) + return; + + if (__free_hook != NULL) + { + (*__free_hook)(ptr); + return; + } + + block = BLOCK(ptr); + + type = _heapinfo[block].busy.type; + switch (type) + { + case 0: + /* Get as many statistics as early as we can. */ + --_chunks_used; + _bytes_used -= _heapinfo[block].busy.info.size * BLOCKSIZE; + _bytes_free += _heapinfo[block].busy.info.size * BLOCKSIZE; + + /* Find the free cluster previous to this one in the free list. + Start searching at the last block referenced; this may benefit + programs with locality of allocation. */ + i = _heapindex; + if (i > block) + while (i > block) + i = _heapinfo[i].free.prev; + else + { + do + i = _heapinfo[i].free.next; + while (i > 0 && i < block); + i = _heapinfo[i].free.prev; + } + + /* Determine how to link this block into the free list. */ + if (block == i + _heapinfo[i].free.size) + { + /* Coalesce this block with its predecessor. */ + _heapinfo[i].free.size += _heapinfo[block].busy.info.size; + block = i; + } + else + { + /* Really link this block back into the free list. */ + _heapinfo[block].free.size = _heapinfo[block].busy.info.size; + _heapinfo[block].free.next = _heapinfo[i].free.next; + _heapinfo[block].free.prev = i; + _heapinfo[i].free.next = block; + _heapinfo[_heapinfo[block].free.next].free.prev = block; + ++_chunks_free; + } + + /* Now that the block is linked in, see if we can coalesce it + with its successor (by deleting its successor from the list + and adding in its size). */ + if (block + _heapinfo[block].free.size == _heapinfo[block].free.next) + { + _heapinfo[block].free.size + += _heapinfo[_heapinfo[block].free.next].free.size; + _heapinfo[block].free.next + = _heapinfo[_heapinfo[block].free.next].free.next; + _heapinfo[_heapinfo[block].free.next].free.prev = block; + --_chunks_free; + } + + /* Now see if we can return stuff to the system. */ + blocks = _heapinfo[block].free.size; + if (blocks >= FINAL_FREE_BLOCKS && block + blocks == _heaplimit + && (*__morecore)(0) == ADDRESS(block + blocks)) + { + register size_t bytes = blocks * BLOCKSIZE; + _heaplimit -= blocks; + (*__morecore)(- bytes); + _heapinfo[_heapinfo[block].free.prev].free.next + = _heapinfo[block].free.next; + _heapinfo[_heapinfo[block].free.next].free.prev + = _heapinfo[block].free.prev; + block = _heapinfo[block].free.prev; + --_chunks_free; + _bytes_free -= bytes; + } + + /* Set the next search to begin at this block. */ + _heapindex = block; + break; + + default: + /* Do some of the statistics. */ + --_chunks_used; + _bytes_used -= 1 << type; + ++_chunks_free; + _bytes_free += 1 << type; + + /* Get the address of the first free fragment in this block. */ + prev = (struct list *) ((char *) ADDRESS(block) + + (_heapinfo[block].busy.info.frag.first << type)); + + if (_heapinfo[block].busy.info.frag.nfree == (BLOCKSIZE >> type) - 1) + { + /* If all fragments of this block are free, remove them + from the fragment list and free the whole block. */ + next = prev; + for (i = 1; i < BLOCKSIZE >> type; ++i) + next = next->next; + prev->prev->next = next; + if (next != NULL) + next->prev = prev->prev; + _heapinfo[block].busy.type = 0; + _heapinfo[block].busy.info.size = 1; + + /* Keep the statistics accurate. */ + ++_chunks_used; + _bytes_used += BLOCKSIZE; + _chunks_free -= BLOCKSIZE >> type; + _bytes_free -= BLOCKSIZE; + + free(ADDRESS(block)); + } + else if (_heapinfo[block].busy.info.frag.nfree != 0) + { + /* If some fragments of this block are free, link this + fragment into the fragment list after the first free + fragment of this block. */ + next = (struct list *) ptr; + next->next = prev->next; + next->prev = prev; + prev->next = next; + if (next->next != NULL) + next->next->prev = next; + ++_heapinfo[block].busy.info.frag.nfree; + } + else + { + /* No fragments of this block are free, so link this + fragment into the fragment list and announce that + it is the first free fragment of this block. */ + prev = (struct list *) ptr; + _heapinfo[block].busy.info.frag.nfree = 1; + _heapinfo[block].busy.info.frag.first = (unsigned int) + (((char *) ptr - (char *) NULL) % BLOCKSIZE >> type); + prev->next = _fraghead[type].next; + prev->prev = &_fraghead[type]; + prev->prev->next = prev; + if (prev->next != NULL) + prev->next->prev = prev; + } + break; + } +} + +/* DO NOT DELETE THIS LINE -- malloc.c INSERTED HERE. */ +/* Memory allocator `malloc'. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#include +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +/* How to really get more memory. */ +PTR EXFUN((*__morecore), (ptrdiff_t __size)) = __default_morecore; + +/* Debugging hook for `malloc'. */ +PTR EXFUN((*__malloc_hook), (size_t __size)); + +/* Pointer to the base of the first block. */ +char *_heapbase; + +/* Block information table. */ +malloc_info *_heapinfo; + +/* Number of info entries. */ +static size_t heapsize; + +/* Search index in the info table. */ +size_t _heapindex; + +/* Limit of valid info table indices. */ +size_t _heaplimit; + +/* Free lists for each fragment size. */ +struct list _fraghead[BLOCKLOG]; + +/* Instrumentation. */ +size_t _chunks_used; +size_t _bytes_used; +size_t _chunks_free; +size_t _bytes_free; + +/* Are you experienced? */ +int __malloc_initialized; + +/* Aligned allocation. */ +static PTR +DEFUN(align, (size), size_t size) +{ + PTR result; + unsigned int adj; + + result = (*__morecore)(size); + adj = (unsigned int) ((char *) result - (char *) NULL) % BLOCKSIZE; + if (adj != 0) + { + adj = BLOCKSIZE - adj; + (void) (*__morecore)(adj); + result = (char *) result + adj; + } + return result; +} + +/* Set everything up and remember that we have. */ +static int +DEFUN_VOID(initialize) +{ + heapsize = HEAP / BLOCKSIZE; + _heapinfo = (malloc_info *) align(heapsize * sizeof(malloc_info)); + if (_heapinfo == NULL) + return 0; + memset(_heapinfo, 0, heapsize * sizeof(malloc_info)); + _heapinfo[0].free.size = 0; + _heapinfo[0].free.next = _heapinfo[0].free.prev = 0; + _heapindex = 0; + _heapbase = (char *) _heapinfo; + __malloc_initialized = 1; + return 1; +} + +/* Get neatly aligned memory, initializing or + growing the heap info table as necessary. */ +static PTR +DEFUN(morecore, (size), size_t size) +{ + PTR result; + malloc_info *newinfo, *oldinfo; + size_t newsize; + + result = align(size); + if (result == NULL) + return NULL; + + /* Check if we need to grow the info table. */ + if (BLOCK((char *) result + size) > heapsize) + { + newsize = heapsize; + while (BLOCK((char *) result + size) > newsize) + newsize *= 2; + newinfo = (malloc_info *) align(newsize * sizeof(malloc_info)); + if (newinfo == NULL) + { + (*__morecore)(- size); + return NULL; + } + memset(newinfo, 0, newsize * sizeof(malloc_info)); + memcpy(newinfo, _heapinfo, heapsize * sizeof(malloc_info)); + oldinfo = _heapinfo; + newinfo[BLOCK(oldinfo)].busy.type = 0; + newinfo[BLOCK(oldinfo)].busy.info.size + = BLOCKIFY(heapsize * sizeof(malloc_info)); + _heapinfo = newinfo; + free(oldinfo); + heapsize = newsize; + } + + _heaplimit = BLOCK((char *) result + size); + return result; +} + +void * calloc(size_t n, size_t size) +{ + void * tmp; + size_t total = n*size; + + if (tmp=malloc(total)) + memset(tmp,0,total); + return tmp; +} + +/* Allocate memory from the heap. */ +PTR +DEFUN(malloc, (size), size_t size) +{ + PTR result; + size_t block, blocks, lastblocks, start; + register size_t i; + struct list *next; + + if (size == 0) + return NULL; + + if (__malloc_hook != NULL) + return (*__malloc_hook)(size); + + if (!__malloc_initialized) + if (!initialize()) + return NULL; + + if (size < sizeof(struct list)) + size = sizeof(struct list); + + /* Determine the allocation policy based on the request size. */ + if (size <= BLOCKSIZE / 2) + { + /* Small allocation to receive a fragment of a block. + Determine the logarithm to base two of the fragment size. */ + register size_t log = 1; + --size; + while ((size /= 2) != 0) + ++log; + + /* Look in the fragment lists for a + free fragment of the desired size. */ + next = _fraghead[log].next; + if (next != NULL) + { + /* There are free fragments of this size. + Pop a fragment out of the fragment list and return it. + Update the block's nfree and first counters. */ + result = (PTR) next; + next->prev->next = next->next; + if (next->next != NULL) + next->next->prev = next->prev; + block = BLOCK(result); + if (--_heapinfo[block].busy.info.frag.nfree != 0) + _heapinfo[block].busy.info.frag.first = (unsigned int) + (((char *) next->next - (char *) NULL) % BLOCKSIZE) >> log; + + /* Update the statistics. */ + ++_chunks_used; + _bytes_used += 1 << log; + --_chunks_free; + _bytes_free -= 1 << log; + } + else + { + /* No free fragments of the desired size, so get a new block + and break it into fragments, returning the first. */ + result = malloc(BLOCKSIZE); + if (result == NULL) + return NULL; + + /* Link all fragments but the first into the free list. */ + for (i = 1; i < BLOCKSIZE >> log; ++i) + { + next = (struct list *) ((char *) result + (i << log)); + next->next = _fraghead[log].next; + next->prev = &_fraghead[log]; + next->prev->next = next; + if (next->next != NULL) + next->next->prev = next; + } + + /* Initialize the nfree and first counters for this block. */ + block = BLOCK(result); + _heapinfo[block].busy.type = log; + _heapinfo[block].busy.info.frag.nfree = i - 1; + _heapinfo[block].busy.info.frag.first = i - 1; + + _chunks_free += (BLOCKSIZE >> log) - 1; + _bytes_free += BLOCKSIZE - (1 << log); + } + } + else + { + /* Large allocation to receive one or more blocks. + Search the free list in a circle starting at the last place visited. + If we loop completely around without finding a large enough + space we will have to get more memory from the system. */ + blocks = BLOCKIFY(size); + start = block = MALLOC_SEARCH_START; + while (_heapinfo[block].free.size < blocks) + { + block = _heapinfo[block].free.next; + if (block == start) + { + /* Need to get more from the system. Check to see if + the new core will be contiguous with the final free + block; if so we don't need to get as much. */ + block = _heapinfo[0].free.prev; + lastblocks = _heapinfo[block].free.size; + if (_heaplimit != 0 && block + lastblocks == _heaplimit && + (*__morecore)(0) == ADDRESS(block + lastblocks) && + (morecore((blocks - lastblocks) * BLOCKSIZE)) != NULL) + { + _heapinfo[block].free.size = blocks; + _bytes_free += (blocks - lastblocks) * BLOCKSIZE; + continue; + } + result = morecore(blocks * BLOCKSIZE); + if (result == NULL) + return NULL; + block = BLOCK(result); + _heapinfo[block].busy.type = 0; + _heapinfo[block].busy.info.size = blocks; + ++_chunks_used; + _bytes_used += blocks * BLOCKSIZE; + return result; + } + } + + /* At this point we have found a suitable free list entry. + Figure out how to remove what we need from the list. */ + result = ADDRESS(block); + if (_heapinfo[block].free.size > blocks) + { + /* The block we found has a bit left over, + so relink the tail end back into the free list. */ + _heapinfo[block + blocks].free.size + = _heapinfo[block].free.size - blocks; + _heapinfo[block + blocks].free.next + = _heapinfo[block].free.next; + _heapinfo[block + blocks].free.prev + = _heapinfo[block].free.prev; + _heapinfo[_heapinfo[block].free.prev].free.next + = _heapinfo[_heapinfo[block].free.next].free.prev + = _heapindex = block + blocks; + } + else + { + /* The block exactly matches our requirements, + so just remove it from the list. */ + _heapinfo[_heapinfo[block].free.next].free.prev + = _heapinfo[block].free.prev; + _heapinfo[_heapinfo[block].free.prev].free.next + = _heapindex = _heapinfo[block].free.next; + --_chunks_free; + } + + _heapinfo[block].busy.type = 0; + _heapinfo[block].busy.info.size = blocks; + ++_chunks_used; + _bytes_used += blocks * BLOCKSIZE; + _bytes_free -= blocks * BLOCKSIZE; + } + + return result; +} + +/* DO NOT DELETE THIS LINE -- realloc.c INSERTED HERE. */ +/* Change the size of a block allocated by `malloc'. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +#define MIN(A, B) ((A) < (B) ? (A) : (B)) + +/* Debugging hook for realloc. */ +PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); + +/* Resize the given region to the new size, returning a pointer + to the (possibly moved) region. This is optimized for speed; + some benchmarks seem to indicate that greater compactness is + achieved by unconditionally allocating and copying to a + new region. This module has incestuous knowledge of the + internals of both free and malloc. */ +PTR +DEFUN(realloc, (ptr, size), PTR ptr AND size_t size) +{ + PTR result; + int type; + size_t block, blocks, oldlimit; + + if (size == 0) + { + free(ptr); + return NULL; + } + else if (ptr == NULL) + return malloc(size); + + if (__realloc_hook != NULL) + return (*__realloc_hook)(ptr, size); + + block = BLOCK(ptr); + + type = _heapinfo[block].busy.type; + switch (type) + { + case 0: + /* Maybe reallocate a large block to a small fragment. */ + if (size <= BLOCKSIZE / 2) + { + result = malloc(size); + if (result != NULL) + { + memcpy(result, ptr, size); + free(ptr); + return result; + } + } + + /* The new size is a large allocation as well; + see if we can hold it in place. */ + blocks = BLOCKIFY(size); + if (blocks < _heapinfo[block].busy.info.size) + { + /* The new size is smaller; return + excess memory to the free list. */ + _heapinfo[block + blocks].busy.type = 0; + _heapinfo[block + blocks].busy.info.size + = _heapinfo[block].busy.info.size - blocks; + _heapinfo[block].busy.info.size = blocks; + free(ADDRESS(block + blocks)); + result = ptr; + } + else if (blocks == _heapinfo[block].busy.info.size) + /* No size change necessary. */ + result = ptr; + else + { + /* Won't fit, so allocate a new region that will. + Free the old region first in case there is sufficient + adjacent free space to grow without moving. */ + blocks = _heapinfo[block].busy.info.size; + /* Prevent free from actually returning memory to the system. */ + oldlimit = _heaplimit; + _heaplimit = 0; + free(ptr); + _heaplimit = oldlimit; + result = malloc(size); + if (result == NULL) + { + (void) malloc(blocks * BLOCKSIZE); + return NULL; + } + if (ptr != result) + memmove(result, ptr, blocks * BLOCKSIZE); + } + break; + + default: + /* Old size is a fragment; type is logarithm + to base two of the fragment size. */ + if (size > 1 << (type - 1) && size <= 1 << type) + /* The new size is the same kind of fragment. */ + result = ptr; + else + { + /* The new size is different; allocate a new space, + and copy the lesser of the new size and the old. */ + result = malloc(size); + if (result == NULL) + return NULL; + memcpy(result, ptr, MIN(size, 1 << type)); + free(ptr); + } + break; + } + + return result; +} + +/* DO NOT DELETE THIS LINE -- unix.c INSERTED HERE. */ +/* unix.c - get more memory with a UNIX system call. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +extern PTR EXFUN(sbrk, (ptrdiff_t size)); + +PTR +DEFUN(__default_morecore, (size), ptrdiff_t size) +{ + PTR result; + + result = sbrk(size); + if (result == (PTR) -1) + return NULL; + return result; +} + +#define __getpagesize getpagesize +/* DO NOT DELETE THIS LINE -- valloc.c INSERTED HERE. */ +/* Allocate memory on a page boundary. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#endif /* __ONEFILE */ + +#define pagesize 4096 + +PTR +DEFUN(valloc, (size), size_t size) +{ + PTR result; + unsigned int adj; + + result = malloc(size + pagesize); + if (result == NULL) + return NULL; + adj = (unsigned int) ((char *) result - (char *) NULL) % pagesize; + if (adj != 0) + result = (char *) result + pagesize - adj; + return result; +} diff --git a/1/newlibc/malloc/gmalloc.sed b/1/newlibc/malloc/gmalloc.sed new file mode 100755 index 0000000..f9892a4 --- /dev/null +++ b/1/newlibc/malloc/gmalloc.sed @@ -0,0 +1,15 @@ +1i\ +\ +/* gmalloc.c - THIS FILE IS AUTOMAGICALLY GENERATED SO DON'T EDIT IT. */\ + +/DO NOT DELETE THIS LINE -- ansidecl.h INSERTED HERE/r ansidecl.h +/DO NOT DELETE THIS LINE -- limits.h INSERTED HERE/r limits.h +/DO NOT DELETE THIS LINE -- stddef.h INSERTED HERE/r stddef.h +/DO NOT DELETE THIS LINE -- stdlib.h INSERTED HERE/r stdlib.h +/DO NOT DELETE THIS LINE -- string.h INSERTED HERE/r string.h +/DO NOT DELETE THIS LINE -- malloc.h INSERTED HERE/r malloc.h +/DO NOT DELETE THIS LINE -- free.c INSERTED HERE/r free.c +/DO NOT DELETE THIS LINE -- malloc.c INSERTED HERE/r malloc.c +/DO NOT DELETE THIS LINE -- realloc.c INSERTED HERE/r realloc.c +/DO NOT DELETE THIS LINE -- unix.c INSERTED HERE/r unix.c +/DO NOT DELETE THIS LINE -- valloc.c INSERTED HERE/r valloc.c diff --git a/1/newlibc/malloc/gmalloc.skel b/1/newlibc/malloc/gmalloc.skel new file mode 100755 index 0000000..3312bcc --- /dev/null +++ b/1/newlibc/malloc/gmalloc.skel @@ -0,0 +1,54 @@ +/* Single-file skeleton for GNU malloc. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#define __ONEFILE + +/* DO NOT DELETE THIS LINE -- ansidecl.h INSERTED HERE. */ + +#ifdef __STDC__ +#include +#else +/* DO NOT DELETE THIS LINE -- limits.h INSERTED HERE. */ +#endif + +#ifdef __STDC__ +#include +#else +/* DO NOT DELETE THIS LINE -- stddef.h INSERTED HERE. */ +#endif + +/* DO NOT DELETE THIS LINE -- stdlib.h INSERTED HERE. */ + +/* DO NOT DELETE THIS LINE -- string.h INSERTED HERE. */ + +#define _MALLOC_INTERNAL +/* DO NOT DELETE THIS LINE -- malloc.h INSERTED HERE. */ + +/* DO NOT DELETE THIS LINE -- free.c INSERTED HERE. */ + +/* DO NOT DELETE THIS LINE -- malloc.c INSERTED HERE. */ + +/* DO NOT DELETE THIS LINE -- realloc.c INSERTED HERE. */ + +/* DO NOT DELETE THIS LINE -- unix.c INSERTED HERE. */ + +#define __getpagesize getpagesize +/* DO NOT DELETE THIS LINE -- valloc.c INSERTED HERE. */ diff --git a/1/newlibc/malloc/limits.h b/1/newlibc/malloc/limits.h new file mode 100755 index 0000000..74ae1fb --- /dev/null +++ b/1/newlibc/malloc/limits.h @@ -0,0 +1,43 @@ +/* Number of bits in a `char'. */ +#define CHAR_BIT 8 + +/* No multibyte characters supported yet. */ +#define MB_LEN_MAX 1 + +/* Minimum and maximum values a `signed char' can hold. */ +#define SCHAR_MIN -128 +#define SCHAR_MAX 127 + +/* Maximum value an `unsigned char' can hold. (Minimum is 0). */ +#define UCHAR_MAX 255U + +/* Minimum and maximum values a `char' can hold. */ +#ifdef __CHAR_UNSIGNED__ +#define CHAR_MIN 0 +#define CHAR_MAX 255U +#else +#define CHAR_MIN -128 +#define CHAR_MAX 127 +#endif + +/* Minimum and maximum values a `signed short int' can hold. */ +#define SHRT_MIN -32768 +#define SHRT_MAX 32767 + +/* Maximum value an `unsigned short int' can hold. (Minimum is 0). */ +#define USHRT_MAX 65535U + +/* Minimum and maximum values a `signed int' can hold. */ +#define INT_MIN -2147483648 +#define INT_MAX 2147483647 + +/* Maximum value an `unsigned int' can hold. (Minimum is 0). */ +#define UINT_MAX 4294967295U + +/* Minimum and maximum values a `signed long int' can hold. + (Same as `int'). */ +#define LONG_MIN (-LONG_MAX-1) +#define LONG_MAX 2147483647 + +/* Maximum value an `unsigned long int' can hold. (Minimum is 0). */ +#define ULONG_MAX 4294967295U diff --git a/1/newlibc/malloc/malloc.c.1 b/1/newlibc/malloc/malloc.c.1 new file mode 100755 index 0000000..545728c --- /dev/null +++ b/1/newlibc/malloc/malloc.c.1 @@ -0,0 +1,308 @@ +/* Memory allocator `malloc'. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#include +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +/* How to really get more memory. */ +PTR EXFUN((*__morecore), (ptrdiff_t __size)) = __default_morecore; + +/* Debugging hook for `malloc'. */ +PTR EXFUN((*__malloc_hook), (size_t __size)); + +/* Pointer to the base of the first block. */ +char *_heapbase; + +/* Block information table. */ +malloc_info *_heapinfo; + +/* Number of info entries. */ +static size_t heapsize; + +/* Search index in the info table. */ +size_t _heapindex; + +/* Limit of valid info table indices. */ +size_t _heaplimit; + +/* Free lists for each fragment size. */ +struct list _fraghead[BLOCKLOG]; + +/* Instrumentation. */ +size_t _chunks_used; +size_t _bytes_used; +size_t _chunks_free; +size_t _bytes_free; + +/* Are you experienced? */ +int __malloc_initialized; + +/* Aligned allocation. */ +static PTR +DEFUN(align, (size), size_t size) +{ + PTR result; + unsigned int adj; + + result = (*__morecore)(size); + adj = (unsigned int) ((char *) result - (char *) NULL) % BLOCKSIZE; + if (adj != 0) + { + adj = BLOCKSIZE - adj; + (void) (*__morecore)(adj); + result = (char *) result + adj; + } + return result; +} + +/* Set everything up and remember that we have. */ +static int +DEFUN_VOID(initialize) +{ + heapsize = HEAP / BLOCKSIZE; + _heapinfo = (malloc_info *) align(heapsize * sizeof(malloc_info)); + if (_heapinfo == NULL) + return 0; + memset(_heapinfo, 0, heapsize * sizeof(malloc_info)); + _heapinfo[0].free.size = 0; + _heapinfo[0].free.next = _heapinfo[0].free.prev = 0; + _heapindex = 0; + _heapbase = (char *) _heapinfo; + __malloc_initialized = 1; + return 1; +} + +/* Get neatly aligned memory, initializing or + growing the heap info table as necessary. */ +static PTR +DEFUN(morecore, (size), size_t size) +{ + PTR result; + malloc_info *newinfo, *oldinfo; + size_t newsize; + + result = align(size); + if (result == NULL) + return NULL; + + /* Check if we need to grow the info table. */ + if (BLOCK((char *) result + size) > heapsize) + { + newsize = heapsize; + while (BLOCK((char *) result + size) > newsize) + newsize *= 2; + newinfo = (malloc_info *) align(newsize * sizeof(malloc_info)); + if (newinfo == NULL) + { + (*__morecore)(- size); + return NULL; + } + memset(newinfo, 0, newsize * sizeof(malloc_info)); + memcpy(newinfo, _heapinfo, heapsize * sizeof(malloc_info)); + oldinfo = _heapinfo; + newinfo[BLOCK(oldinfo)].busy.type = 0; + newinfo[BLOCK(oldinfo)].busy.info.size + = BLOCKIFY(heapsize * sizeof(malloc_info)); + _heapinfo = newinfo; + free(oldinfo); + heapsize = newsize; + } + + _heaplimit = BLOCK((char *) result + size); + return result; +} + +void * calloc(size_t n, size_t size) +{ + void * tmp; + size_t total = n*size; + + if (tmp=malloc(total)) + memset(tmp,0,total); + return tmp; +} + +/* Allocate memory from the heap. */ +PTR +DEFUN(malloc, (size), size_t size) +{ + PTR result; + size_t block, blocks, lastblocks, start; + register size_t i; + struct list *next; + + if (size == 0) + return NULL; + + if (__malloc_hook != NULL) + return (*__malloc_hook)(size); + + if (!__malloc_initialized) + if (!initialize()) + return NULL; + + if (size < sizeof(struct list)) + size = sizeof(struct list); + + /* Determine the allocation policy based on the request size. */ + if (size <= BLOCKSIZE / 2) + { + /* Small allocation to receive a fragment of a block. + Determine the logarithm to base two of the fragment size. */ + register size_t log = 1; + --size; + while ((size /= 2) != 0) + ++log; + + /* Look in the fragment lists for a + free fragment of the desired size. */ + next = _fraghead[log].next; + if (next != NULL) + { + /* There are free fragments of this size. + Pop a fragment out of the fragment list and return it. + Update the block's nfree and first counters. */ + result = (PTR) next; + next->prev->next = next->next; + if (next->next != NULL) + next->next->prev = next->prev; + block = BLOCK(result); + if (--_heapinfo[block].busy.info.frag.nfree != 0) + _heapinfo[block].busy.info.frag.first = (unsigned int) + (((char *) next->next - (char *) NULL) % BLOCKSIZE) >> log; + + /* Update the statistics. */ + ++_chunks_used; + _bytes_used += 1 << log; + --_chunks_free; + _bytes_free -= 1 << log; + } + else + { + /* No free fragments of the desired size, so get a new block + and break it into fragments, returning the first. */ + result = malloc(BLOCKSIZE); + if (result == NULL) + return NULL; + + /* Link all fragments but the first into the free list. */ + for (i = 1; i < BLOCKSIZE >> log; ++i) + { + next = (struct list *) ((char *) result + (i << log)); + next->next = _fraghead[log].next; + next->prev = &_fraghead[log]; + next->prev->next = next; + if (next->next != NULL) + next->next->prev = next; + } + + /* Initialize the nfree and first counters for this block. */ + block = BLOCK(result); + _heapinfo[block].busy.type = log; + _heapinfo[block].busy.info.frag.nfree = i - 1; + _heapinfo[block].busy.info.frag.first = i - 1; + + _chunks_free += (BLOCKSIZE >> log) - 1; + _bytes_free += BLOCKSIZE - (1 << log); + } + } + else + { + /* Large allocation to receive one or more blocks. + Search the free list in a circle starting at the last place visited. + If we loop completely around without finding a large enough + space we will have to get more memory from the system. */ + blocks = BLOCKIFY(size); + start = block = MALLOC_SEARCH_START; + while (_heapinfo[block].free.size < blocks) + { + block = _heapinfo[block].free.next; + if (block == start) + { + /* Need to get more from the system. Check to see if + the new core will be contiguous with the final free + block; if so we don't need to get as much. */ + block = _heapinfo[0].free.prev; + lastblocks = _heapinfo[block].free.size; + if (_heaplimit != 0 && block + lastblocks == _heaplimit && + (*__morecore)(0) == ADDRESS(block + lastblocks) && + (morecore((blocks - lastblocks) * BLOCKSIZE)) != NULL) + { + _heapinfo[block].free.size = blocks; + _bytes_free += (blocks - lastblocks) * BLOCKSIZE; + continue; + } + result = morecore(blocks * BLOCKSIZE); + if (result == NULL) + return NULL; + block = BLOCK(result); + _heapinfo[block].busy.type = 0; + _heapinfo[block].busy.info.size = blocks; + ++_chunks_used; + _bytes_used += blocks * BLOCKSIZE; + return result; + } + } + + /* At this point we have found a suitable free list entry. + Figure out how to remove what we need from the list. */ + result = ADDRESS(block); + if (_heapinfo[block].free.size > blocks) + { + /* The block we found has a bit left over, + so relink the tail end back into the free list. */ + _heapinfo[block + blocks].free.size + = _heapinfo[block].free.size - blocks; + _heapinfo[block + blocks].free.next + = _heapinfo[block].free.next; + _heapinfo[block + blocks].free.prev + = _heapinfo[block].free.prev; + _heapinfo[_heapinfo[block].free.prev].free.next + = _heapinfo[_heapinfo[block].free.next].free.prev + = _heapindex = block + blocks; + } + else + { + /* The block exactly matches our requirements, + so just remove it from the list. */ + _heapinfo[_heapinfo[block].free.next].free.prev + = _heapinfo[block].free.prev; + _heapinfo[_heapinfo[block].free.prev].free.next + = _heapindex = _heapinfo[block].free.next; + --_chunks_free; + } + + _heapinfo[block].busy.type = 0; + _heapinfo[block].busy.info.size = blocks; + ++_chunks_used; + _bytes_used += blocks * BLOCKSIZE; + _bytes_free -= blocks * BLOCKSIZE; + } + + return result; +} diff --git a/1/newlibc/malloc/malloc.h b/1/newlibc/malloc/malloc.h new file mode 100755 index 0000000..6c77f73 --- /dev/null +++ b/1/newlibc/malloc/malloc.h @@ -0,0 +1,156 @@ +/* Declarations for `malloc' and friends. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef _MALLOC_H + +#define _MALLOC_H 1 + +#ifndef __ONEFILE +#define __need_NULL +#define __need_size_t +#define __need_ptrdiff_t +#include +#endif + +#ifdef _MALLOC_INTERNAL + +#ifndef __ONEFILE +#include +#endif + +/* The allocator divides the heap into blocks of fixed size; large + requests receive one or more whole blocks, and small requests + receive a fragment of a block. Fragment sizes are powers of two, + and all fragments of a block are the same size. When all the + fragments in a block have been freed, the block itself is freed. */ +#define INT_BIT (CHAR_BIT * sizeof(int)) +#define BLOCKLOG (INT_BIT > 16 ? 12 : 9) +#define BLOCKSIZE (1 << BLOCKLOG) +#define BLOCKIFY(SIZE) (((SIZE) + BLOCKSIZE - 1) / BLOCKSIZE) + +/* Determine the amount of memory spanned by the initial heap table + (not an absolute limit). */ +#define HEAP (INT_BIT > 16 ? 4194304 : 65536) + +/* Number of contiguous free blocks allowed to build up at the end of + memory before they will be returned to the system. */ +#define FINAL_FREE_BLOCKS 8 + +/* Where to start searching the free list when looking for new memory. + The two possible values are 0 and _heapindex. Starting at 0 seems + to reduce total memory usage, while starting at _heapindex seems to + run faster. */ +#define MALLOC_SEARCH_START _heapindex + +/* Data structure giving per-block information. */ +typedef union + { + struct + { + /* Zero for a large block, or positive giving the + logarithm to the base two of the fragment size. */ + int type; + + union + { + struct + { + size_t nfree; /* Free fragments in a fragmented block. */ + size_t first; /* First free fragment of the block. */ + } frag; + /* Size (in blocks) of a large cluster. */ + size_t size; + } info; + } busy; + struct + { + size_t size; /* Size (in blocks) of a free cluster. */ + size_t next; /* Index of next free cluster. */ + size_t prev; /* Index of previous free cluster. */ + } free; + } malloc_info; + +/* Pointer to first block of the heap. */ +extern char *_heapbase; + +/* Table indexed by block number giving per-block information. */ +extern malloc_info *_heapinfo; + +/* Address to block number and vice versa. */ +#define BLOCK(A) (((char *) (A) - _heapbase) / BLOCKSIZE + 1) +#define ADDRESS(B) ((PTR) (((B) - 1) * BLOCKSIZE + _heapbase)) + +/* Current search index for the heap table. */ +extern size_t _heapindex; + +/* Limit of valid info table indices. */ +extern size_t _heaplimit; + +/* Doubly linked lists of free fragments. */ +struct list + { + struct list *next; + struct list *prev; + }; + +/* Free list headers for each fragment size. */ +extern struct list _fraghead[]; + +/* Instrumentation. */ +extern size_t _chunks_used; +extern size_t _bytes_used; +extern size_t _chunks_free; +extern size_t _bytes_free; + +#endif /* _MALLOC_INTERNAL. */ + +/* Underlying allocation function; successive calls should + return contiguous pieces of memory. */ +extern PTR EXFUN((*__morecore), (ptrdiff_t __size)); + +/* Default value of previous. */ +extern PTR EXFUN(__default_morecore, (ptrdiff_t __size)); + +/* Flag whether malloc has been called. */ +extern int __malloc_initialized; + +/* Hooks for debugging versions. */ +extern void EXFUN((*__free_hook), (PTR __ptr)); +extern PTR EXFUN((*__malloc_hook), (size_t __size)); +extern PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); + +/* Activate a standard collection of debugging hooks. */ +extern void EXFUN(mcheck, (NOARGS)); + +/* Statistics available to the user. */ +struct mstats + { + size_t bytes_total; /* Total size of the heap. */ + size_t chunks_used; /* Chunks allocated by the user. */ + size_t bytes_used; /* Byte total of user-allocated chunks. */ + size_t chunks_free; /* Chunks in the free list. */ + size_t bytes_free; /* Byte total of chunks in the free list. */ + }; + +/* Pick up the current statistics. */ +extern struct mstats EXFUN(mstats, (NOARGS)); + +#endif /* malloc.h */ diff --git a/1/newlibc/malloc/mcheck.c b/1/newlibc/malloc/mcheck.c new file mode 100755 index 0000000..72f3360 --- /dev/null +++ b/1/newlibc/malloc/mcheck.c @@ -0,0 +1,113 @@ +/* Standard debugging hooks for `malloc'. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#include "ansidecl.h" +#include +#include "malloc.h" + +/* Old hook values. */ +static void EXFUN((*old_free_hook), (PTR ptr)); +static PTR EXFUN((*old_malloc_hook), (size_t size)); +static PTR EXFUN((*old_realloc_hook), (PTR ptr, size_t size)); + +/* Arbitrary magical numbers. */ +#define MAGICWORD 0xfedabeeb +#define MAGICBYTE ((char) 0xd7) + +struct hdr + { + size_t size; /* Exact size requested by user. */ + unsigned int magic; /* Magic number to check header integrity. */ + }; + +static void +DEFUN(checkhdr, (hdr), CONST struct hdr *hdr) +{ + if (hdr->magic != MAGICWORD || ((char *) &hdr[1])[hdr->size] != MAGICBYTE) + abort(); +} + +static void +DEFUN(freehook, (ptr), PTR ptr) +{ + struct hdr *hdr = ((struct hdr *) ptr) - 1; + checkhdr(hdr); + hdr->magic = 0; + __free_hook = old_free_hook; + free(hdr); + __free_hook = freehook; +} + +static PTR +DEFUN(mallochook, (size), size_t size) +{ + struct hdr *hdr; + + __malloc_hook = old_malloc_hook; + hdr = (struct hdr *) malloc(sizeof(struct hdr) + size + 1); + __malloc_hook = mallochook; + if (hdr == NULL) + return NULL; + + hdr->size = size; + hdr->magic = MAGICWORD; + ((char *) &hdr[1])[size] = MAGICBYTE; + return (PTR) (hdr + 1); +} + +static PTR +DEFUN(reallochook, (ptr, size), PTR ptr AND size_t size) +{ + struct hdr *hdr = ((struct hdr *) ptr) - 1; + + checkhdr(hdr); + __free_hook = old_free_hook; + __malloc_hook = old_malloc_hook; + __realloc_hook = old_realloc_hook; + hdr = (struct hdr *) realloc((PTR) hdr, sizeof(struct hdr) + size + 1); + __free_hook = freehook; + __malloc_hook = mallochook; + __realloc_hook = reallochook; + if (hdr == NULL) + return NULL; + + hdr->size = size; + ((char *) &hdr[1])[size] = MAGICBYTE; + return (PTR) (hdr + 1); +} + +void +DEFUN_VOID(mcheck) +{ + static int mcheck_used = 0; + + /* These hooks may not be safely inserted if malloc is already in use. */ + if (!__malloc_initialized && !mcheck_used) + { + old_free_hook = __free_hook; + __free_hook = freehook; + old_malloc_hook = __malloc_hook; + __malloc_hook = mallochook; + old_realloc_hook = __realloc_hook; + __realloc_hook = reallochook; + mcheck_used = 1; + } +} diff --git a/1/newlibc/malloc/mstats.c b/1/newlibc/malloc/mstats.c new file mode 100755 index 0000000..1561526 --- /dev/null +++ b/1/newlibc/malloc/mstats.c @@ -0,0 +1,38 @@ +/* Access the statistics maintained by `malloc'. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#include "ansidecl.h" + +#define _MALLOC_INTERNAL +#include "malloc.h" + +struct mstats +DEFUN_VOID(mstats) +{ + struct mstats result; + + result.bytes_total = (char *) (*__morecore)(0) - _heapbase; + result.chunks_used = _chunks_used; + result.bytes_used = _bytes_used; + result.chunks_free = _chunks_free; + result.bytes_free = _bytes_free; + return result; +} diff --git a/1/newlibc/malloc/realloc.c b/1/newlibc/malloc/realloc.c new file mode 100755 index 0000000..2ee58c2 --- /dev/null +++ b/1/newlibc/malloc/realloc.c @@ -0,0 +1,137 @@ +/* Change the size of a block allocated by `malloc'. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +#define MIN(A, B) ((A) < (B) ? (A) : (B)) + +/* Debugging hook for realloc. */ +PTR EXFUN((*__realloc_hook), (PTR __ptr, size_t __size)); + +/* Resize the given region to the new size, returning a pointer + to the (possibly moved) region. This is optimized for speed; + some benchmarks seem to indicate that greater compactness is + achieved by unconditionally allocating and copying to a + new region. This module has incestuous knowledge of the + internals of both free and malloc. */ +PTR +DEFUN(realloc, (ptr, size), PTR ptr AND size_t size) +{ + PTR result; + int type; + size_t block, blocks, oldlimit; + + if (size == 0) + { + free(ptr); + return NULL; + } + else if (ptr == NULL) + return malloc(size); + + if (__realloc_hook != NULL) + return (*__realloc_hook)(ptr, size); + + block = BLOCK(ptr); + + type = _heapinfo[block].busy.type; + switch (type) + { + case 0: + /* Maybe reallocate a large block to a small fragment. */ + if (size <= BLOCKSIZE / 2) + { + result = malloc(size); + if (result != NULL) + { + memcpy(result, ptr, size); + free(ptr); + return result; + } + } + + /* The new size is a large allocation as well; + see if we can hold it in place. */ + blocks = BLOCKIFY(size); + if (blocks < _heapinfo[block].busy.info.size) + { + /* The new size is smaller; return + excess memory to the free list. */ + _heapinfo[block + blocks].busy.type = 0; + _heapinfo[block + blocks].busy.info.size + = _heapinfo[block].busy.info.size - blocks; + _heapinfo[block].busy.info.size = blocks; + free(ADDRESS(block + blocks)); + result = ptr; + } + else if (blocks == _heapinfo[block].busy.info.size) + /* No size change necessary. */ + result = ptr; + else + { + /* Won't fit, so allocate a new region that will. + Free the old region first in case there is sufficient + adjacent free space to grow without moving. */ + blocks = _heapinfo[block].busy.info.size; + /* Prevent free from actually returning memory to the system. */ + oldlimit = _heaplimit; + _heaplimit = 0; + free(ptr); + _heaplimit = oldlimit; + result = malloc(size); + if (result == NULL) + { + (void) malloc(blocks * BLOCKSIZE); + return NULL; + } + if (ptr != result) + memmove(result, ptr, blocks * BLOCKSIZE); + } + break; + + default: + /* Old size is a fragment; type is logarithm + to base two of the fragment size. */ + if (size > 1 << (type - 1) && size <= 1 << type) + /* The new size is the same kind of fragment. */ + result = ptr; + else + { + /* The new size is different; allocate a new space, + and copy the lesser of the new size and the old. */ + result = malloc(size); + if (result == NULL) + return NULL; + memcpy(result, ptr, MIN(size, 1 << type)); + free(ptr); + } + break; + } + + return result; +} diff --git a/1/newlibc/malloc/stddef.h b/1/newlibc/malloc/stddef.h new file mode 100755 index 0000000..d95a815 --- /dev/null +++ b/1/newlibc/malloc/stddef.h @@ -0,0 +1,24 @@ +#ifndef _STDDEF_H +#define _STDDEF_H + +/* Signed type of difference of two pointers. */ + +typedef long ptrdiff_t; + +/* Unsigned type of `sizeof' something. */ + +#ifndef _SIZE_T /* in case has defined it. */ +#define _SIZE_T +typedef unsigned long size_t; +#endif /* _SIZE_T */ + +/* A null pointer constant. */ + +#undef NULL /* in case has defined it. */ +#define NULL 0 + +/* Offset of member MEMBER in a struct of type TYPE. */ + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#endif /* _STDDEF_H */ diff --git a/1/newlibc/malloc/stdlib.h b/1/newlibc/malloc/stdlib.h new file mode 100755 index 0000000..40ce167 --- /dev/null +++ b/1/newlibc/malloc/stdlib.h @@ -0,0 +1,10 @@ +/* Fake stdlib.h supplying the stuff needed by malloc. */ + +#ifndef __ONEFILE +#include +#endif + +extern void EXFUN(abort, (void)); +extern void EXFUN(free, (PTR)); +extern PTR EXFUN(malloc, (size_t)); +extern PTR EXFUN(realloc, (PTR, size_t)); diff --git a/1/newlibc/malloc/string.h b/1/newlibc/malloc/string.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/malloc/unix.c b/1/newlibc/malloc/unix.c new file mode 100755 index 0000000..5b08897 --- /dev/null +++ b/1/newlibc/malloc/unix.c @@ -0,0 +1,41 @@ +/* unix.c - get more memory with a UNIX system call. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include + +#define _MALLOC_INTERNAL +#include "malloc.h" +#endif /* __ONEFILE */ + +extern PTR EXFUN(sbrk, (ptrdiff_t size)); + +PTR +DEFUN(__default_morecore, (size), ptrdiff_t size) +{ + PTR result; + + result = sbrk(size); + if (result == (PTR) -1) + return NULL; + return result; +} diff --git a/1/newlibc/malloc/valloc.c b/1/newlibc/malloc/valloc.c new file mode 100755 index 0000000..2a93ed1 --- /dev/null +++ b/1/newlibc/malloc/valloc.c @@ -0,0 +1,42 @@ +/* Allocate memory on a page boundary. + Copyright 1989 Free Software Foundation + Written May 1989 by Mike Haertel. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 1, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + + The author may be reached (Email) at the address mike@ai.mit.edu, + or (US mail) as Mike Haertel c/o Free Software Foundation. */ + +#ifndef __ONEFILE +#include "ansidecl.h" +#include +#endif /* __ONEFILE */ + +#define pagesize 4096 + +PTR +DEFUN(valloc, (size), size_t size) +{ + PTR result; + unsigned int adj; + + result = malloc(size + pagesize); + if (result == NULL) + return NULL; + adj = (unsigned int) ((char *) result - (char *) NULL) % pagesize; + if (adj != 0) + result = (char *) result + pagesize - adj; + return result; +} diff --git a/1/newlibc/math/._Makefile b/1/newlibc/math/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._acos.s b/1/newlibc/math/._acos.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._acosh.c b/1/newlibc/math/._acosh.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._asin.s b/1/newlibc/math/._asin.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._asinh.c b/1/newlibc/math/._asinh.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._atan.s b/1/newlibc/math/._atan.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._atan2.s b/1/newlibc/math/._atan2.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._atanh.c b/1/newlibc/math/._atanh.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._ceil.s b/1/newlibc/math/._ceil.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._cos.s b/1/newlibc/math/._cos.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._cosh.c b/1/newlibc/math/._cosh.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._erf.c b/1/newlibc/math/._erf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._exp.s b/1/newlibc/math/._exp.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._fabs.s b/1/newlibc/math/._fabs.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._floor.s b/1/newlibc/math/._floor.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._fmod.s b/1/newlibc/math/._fmod.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._frexp.c b/1/newlibc/math/._frexp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._hypot.c b/1/newlibc/math/._hypot.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._j0.c b/1/newlibc/math/._j0.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._j1.c b/1/newlibc/math/._j1.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._jn.c b/1/newlibc/math/._jn.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._lgamma.c b/1/newlibc/math/._lgamma.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._log.s b/1/newlibc/math/._log.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._log10.s b/1/newlibc/math/._log10.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._sin.s b/1/newlibc/math/._sin.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._sinh.c b/1/newlibc/math/._sinh.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._sqrt.s b/1/newlibc/math/._sqrt.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._tan.s b/1/newlibc/math/._tan.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/._tanh.c b/1/newlibc/math/._tanh.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/Makefile b/1/newlibc/math/Makefile new file mode 100755 index 0000000..19f82c8 --- /dev/null +++ b/1/newlibc/math/Makefile @@ -0,0 +1,44 @@ +# This is file Makefile +# +# Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +# +# This file is distributed under the terms listed in the document +# "copying.dj", available from DJ Delorie at the address above. +# A copy of "copying.dj" should accompany this file; if not, a copy +# should be available from where this file was obtained. This file +# may not be distributed without a verbatim copy of "copying.dj". +# +# This file is distributed WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +LIB=../Libm.a +CC= gcc +CFLAGS = -Wall -O -fstrength-reduce -fomit-frame-pointer $(INC) +CPP=$(CC) -E $(INC) + +.s.o : + $(CC) $(CFLAGS) -c $*.s + +.c.o : + $(CC) $(CFLAGS) -c $*.c + +OBJS = acos.o acosh.o asin.o asinh.o atan.o atan2.o atanh.o ceil.o \ + cos.o cosh.o exp.o fabs.o floor.o fmod.o frexp.o hypot.o \ + log.o log10.o sin.o sinh.o sqrt.o tan.o tanh.o \ + erf.o j0.o j1.o jn.o lgamma.o + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/math/acos.s b/1/newlibc/math/acos.s new file mode 100755 index 0000000..a7ea1e3 --- /dev/null +++ b/1/newlibc/math/acos.s @@ -0,0 +1,35 @@ +/* This is file ACOS.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .text +LC0: + .double 0d1.00000000000000000000e+00 + + .globl _acos +_acos: + fldl 4(%esp) + fld1 + fsubp %st(0),%st(1) + fsqrt + + fldl 4(%esp) + fld1 + faddp %st(0),%st(1) + fsqrt + + fpatan + + fld %st(0) + faddp + ret diff --git a/1/newlibc/math/acosh.c b/1/newlibc/math/acosh.c new file mode 100755 index 0000000..6a33989 --- /dev/null +++ b/1/newlibc/math/acosh.c @@ -0,0 +1,6 @@ +#include + +double acosh(double x) +{ + return log(x + sqrt(x*x - 1)); +} diff --git a/1/newlibc/math/asin.s b/1/newlibc/math/asin.s new file mode 100755 index 0000000..4240d72 --- /dev/null +++ b/1/newlibc/math/asin.s @@ -0,0 +1,28 @@ +/* This is file ASIN.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/* History:11,23 */ + .globl _asin +_asin: + fldl 4(%esp) + fld %st(0) + fmulp + fld1 + fsubp + fsqrt + fldl 4(%esp) + fxch %st(1) + fpatan + ret + diff --git a/1/newlibc/math/asinh.c b/1/newlibc/math/asinh.c new file mode 100755 index 0000000..fffa8fa --- /dev/null +++ b/1/newlibc/math/asinh.c @@ -0,0 +1,7 @@ +#include + +double asinh(double x) +{ + return log(x + sqrt(x*x + 1)); +} + diff --git a/1/newlibc/math/atan.s b/1/newlibc/math/atan.s new file mode 100755 index 0000000..d11ebf2 --- /dev/null +++ b/1/newlibc/math/atan.s @@ -0,0 +1,21 @@ +/* This is file ATAN.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .globl _atan +_atan: + fldl 4(%esp) + fld1 + fpatan + ret + diff --git a/1/newlibc/math/atan2.s b/1/newlibc/math/atan2.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/math/atanh.c b/1/newlibc/math/atanh.c new file mode 100755 index 0000000..40df2c1 --- /dev/null +++ b/1/newlibc/math/atanh.c @@ -0,0 +1,6 @@ +#include + +double atanh(double x) +{ + return log((1+x)/(1-x)) / 2.0; +} diff --git a/1/newlibc/math/ceil.s b/1/newlibc/math/ceil.s new file mode 100755 index 0000000..f6a2bf6 --- /dev/null +++ b/1/newlibc/math/ceil.s @@ -0,0 +1,37 @@ +/* This is file CEIL.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .globl _ceil +_ceil: + pushl %ebp + movl %esp,%ebp + sub $8,%esp /* -4 = old CW, -2 = new CW */ + + fstcw -4(%ebp) + fwait + movw -4(%ebp),%ax + andw $0xf3ff,%ax + orw $0x0800,%ax + movw %ax,-2(%ebp) + fldcww -2(%ebp) + + fldl 8(%ebp) + frndint + + fldcww -4(%ebp) + + movl %ebp,%esp + popl %ebp + ret + diff --git a/1/newlibc/math/cos.s b/1/newlibc/math/cos.s new file mode 100755 index 0000000..f5e5fa3 --- /dev/null +++ b/1/newlibc/math/cos.s @@ -0,0 +1,29 @@ +/* This is file COS.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +L0: + .quad 0xffffffffffffffff + + .globl _cos +_cos: + fldl 4(%esp) + fcos + fstsw + sahf + jnp L1 + fstp %st(0) + fldl L0 +L1: + ret + diff --git a/1/newlibc/math/cosh.c b/1/newlibc/math/cosh.c new file mode 100755 index 0000000..c88cbf0 --- /dev/null +++ b/1/newlibc/math/cosh.c @@ -0,0 +1,6 @@ +#include + +double cosh(double x) +{ + return (exp(x) + exp(-x)) / 2.0; +} diff --git a/1/newlibc/math/erf.c b/1/newlibc/math/erf.c new file mode 100755 index 0000000..a3fe575 --- /dev/null +++ b/1/newlibc/math/erf.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)erf.c 5.2 (Berkeley) 4/29/88"; +#endif /* not lint */ + +/* + C program for floating point error function + + erf(x) returns the error function of its argument + erfc(x) returns 1.0-erf(x) + + erf(x) is defined by + ${2 over sqrt(pi)} int from 0 to x e sup {-t sup 2} dt$ + + the entry for erfc is provided because of the + extreme loss of relative accuracy if erf(x) is + called for large x and the result subtracted + from 1. (e.g. for x= 10, 12 places are lost). + + There are no error returns. + + Calls exp. + + Coefficients for large x are #5667 from Hart & Cheney (18.72D). +*/ + +#include + +#define M 7 +#define N 9 +static double torp = 1.1283791670955125738961589031; +static double p1[] = { + 0.804373630960840172832162e5, + 0.740407142710151470082064e4, + 0.301782788536507577809226e4, + 0.380140318123903008244444e2, + 0.143383842191748205576712e2, + -.288805137207594084924010e0, + 0.007547728033418631287834e0, +}; +static double q1[] = { + 0.804373630960840172826266e5, + 0.342165257924628539769006e5, + 0.637960017324428279487120e4, + 0.658070155459240506326937e3, + 0.380190713951939403753468e2, + 0.100000000000000000000000e1, + 0.0, +}; +static double p2[] = { + 0.18263348842295112592168999e4, + 0.28980293292167655611275846e4, + 0.2320439590251635247384768711e4, + 0.1143262070703886173606073338e4, + 0.3685196154710010637133875746e3, + 0.7708161730368428609781633646e2, + 0.9675807882987265400604202961e1, + 0.5641877825507397413087057563e0, + 0.0, +}; +static double q2[] = { + 0.18263348842295112595576438e4, + 0.495882756472114071495438422e4, + 0.60895424232724435504633068e4, + 0.4429612803883682726711528526e4, + 0.2094384367789539593790281779e4, + 0.6617361207107653469211984771e3, + 0.1371255960500622202878443578e3, + 0.1714980943627607849376131193e2, + 1.0, +}; + +double +erf(double arg) +{ + int sign; + double argsq; + double d, n; + int i; + + sign = 1; + if(arg < 0.){ + arg = -arg; + sign = -1; + } + if(arg < 0.5){ + argsq = arg*arg; + for(n=0,d=0,i=M-1; i>=0; i--){ + n = n*argsq + p1[i]; + d = d*argsq + q1[i]; + } + return(sign*torp*arg*n/d); + } + if(arg >= 10.) + return(sign*1.); + return(sign*(1. - erfc(arg))); +} + +double +erfc(double arg) +{ + double n, d; + int i; + + if(arg < 0.) + return(2. - erfc(-arg)); +/* + if(arg < 0.5) + return(1. - erf(arg)); +*/ + if(arg >= 10.) + return(0.); + + for(n=0,d=0,i=N-1; i>=0; i--){ + n = n*arg + p2[i]; + d = d*arg + q2[i]; + } + return(exp(-arg*arg)*n/d); +} diff --git a/1/newlibc/math/exp.s b/1/newlibc/math/exp.s new file mode 100755 index 0000000..70b1280 --- /dev/null +++ b/1/newlibc/math/exp.s @@ -0,0 +1,92 @@ +/* This is file EXP.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** Modified O.ROBERT 24, Avenue de Verdun 92170 VANVES, FRANCE +** +** E-mail: roberto@germinal.ibp.fr +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +** +** or 03-Apr-1991 corrected bug about argument zero to pow +** fyl2x didn't like it +*/ + +/* History:15,24 */ + .data +LCW1: + .word 0 +LCW2: + .word 0 + + .text + +LC0: + .double 0d1.0e+00 + + .globl _pow2 +_pow2: + fldl 4(%esp) +Lpow2: + fstcww LCW1 + fstcww LCW2 + fwait + andl $0xf3ff,LCW2 + orl $0x0400,LCW2 + fldcww LCW2 + fldl %st(0) + frndint + fldcww LCW1 + fxch %st(1) + fsub %st(1),%st + f2xm1 + faddl LC0 + fscale + fstp %st(1) + ret + + .globl _exp +_exp: + fldl 4(%esp) + fldl2e + fmulp + jmp Lpow2 + + .globl _pow10 +_pow10: + fldl 4(%esp) + fldl2t + fmulp + jmp Lpow2 + + .globl _pow +_pow: + fldl 4(%esp) + ftst + fnstsww %ax + sahf + je zero1 + fldl 12(%esp) + ftst + fnstsww %ax + sahf + je zero2 + fxch %st(1) + fyl2x + jmp Lpow2 +zero1: + fstpl 4(%esp) + fldzl + ret +zero2: + fstpl 4(%esp) + fstpl 4(%esp) + fld1l + ret diff --git a/1/newlibc/math/fabs.s b/1/newlibc/math/fabs.s new file mode 100755 index 0000000..e098501 --- /dev/null +++ b/1/newlibc/math/fabs.s @@ -0,0 +1,5 @@ + .globl _fabs +_fabs: + fldl 4(%esp) + fabs + ret diff --git a/1/newlibc/math/floor.s b/1/newlibc/math/floor.s new file mode 100755 index 0000000..179c278 --- /dev/null +++ b/1/newlibc/math/floor.s @@ -0,0 +1,37 @@ +/* This is file FLOOR.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .globl _floor +_floor: + pushl %ebp + movl %esp,%ebp + sub $8,%esp /* -4 = old CW, -2 = new CW */ + + fstcw -4(%ebp) + fwait + movw -4(%ebp),%ax + andw $0xf3ff,%ax + orw $0x0400,%ax + movw %ax,-2(%ebp) + fldcww -2(%ebp) + + fldl 8(%ebp) + frndint + + fldcww -4(%ebp) + + movl %ebp,%esp + popl %ebp + ret + diff --git a/1/newlibc/math/fmod.s b/1/newlibc/math/fmod.s new file mode 100755 index 0000000..dae8d53 --- /dev/null +++ b/1/newlibc/math/fmod.s @@ -0,0 +1,43 @@ +/* This is file FMOD.S */ +/* +** Copyright (C) 1991 O. ROBERT, 24, Avenue de Verdun, 92170 VANVES, FRANCE +** +** Internet: roberto@germinal.ibp.fr +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + .data +LCW1: + .word 0 + .align 4 + + .text + + .globl _fmod +_fmod: + fldl 4(%esp) + fldl 12(%esp) + ftst + fnstsw %ax + fxch %st(1) + sahf + jnz next + fstpl %st(0) + jmp out +next: + fpreml + fnstsw %ax + sahf + jpe next + fstpl %st(1) +out: + ret + + diff --git a/1/newlibc/math/frexp.c b/1/newlibc/math/frexp.c new file mode 100755 index 0000000..d833426 --- /dev/null +++ b/1/newlibc/math/frexp.c @@ -0,0 +1,17 @@ +#include + +/* Stores binary exponent of d in e, and returns whole fraction of d + * (with binary exponent of 0) (special case for d=0) + */ +double frexp(double d, int *e) +{ + struct bitdouble *dp = (struct bitdouble *)&d; + + if (dp->exp == 0) /* value is zero, return exponent of 0 */ + *e = 0; + else { + *e = dp->exp - BIAS + 1; + dp->exp = BIAS - 1; + } + return d; +} diff --git a/1/newlibc/math/hypot.c b/1/newlibc/math/hypot.c new file mode 100755 index 0000000..95e1728 --- /dev/null +++ b/1/newlibc/math/hypot.c @@ -0,0 +1,6 @@ +#include + +double hypot(double x, double y) +{ + return sqrt(x*x + y*y); +} diff --git a/1/newlibc/math/j0.c b/1/newlibc/math/j0.c new file mode 100755 index 0000000..159b8a7 --- /dev/null +++ b/1/newlibc/math/j0.c @@ -0,0 +1,208 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)j0.c 5.3 (Berkeley) 9/22/88"; +#endif /* not lint */ + +/* + floating point Bessel's function + of the first and second kinds + of order zero + + j0(x) returns the value of J0(x) + for all real values of x. + + There are no error returns. + Calls sin, cos, sqrt. + + There is a niggling bug in J0 which + causes errors up to 2e-16 for x in the + interval [-8,8]. + The bug is caused by an inappropriate order + of summation of the series. rhm will fix it + someday. + + Coefficients are from Hart & Cheney. + #5849 (19.22D) + #6549 (19.25D) + #6949 (19.41D) + + y0(x) returns the value of Y0(x) + for positive real values of x. + For x<=0, if on the VAX, error number EDOM is set and + the reserved operand fault is generated; + otherwise (an IEEE machine) an invalid operation is performed. + + Calls sin, cos, sqrt, log, j0. + + The values of Y0 have not been checked + to more than ten places. + + Coefficients are from Hart & Cheney. + #6245 (18.78D) + #6549 (19.25D) + #6949 (19.41D) +*/ + +#include + +#if defined(vax)||defined(tahoe) +#include +#else /* defined(vax)||defined(tahoe) */ +static const double zero = 0.e0; +#endif /* defined(vax)||defined(tahoe) */ + +static double pzero, qzero; + +static const double tpi = .6366197723675813430755350535e0; +static const double pio4 = .7853981633974483096156608458e0; +static const double p1[] = { + 0.4933787251794133561816813446e21, + -.1179157629107610536038440800e21, + 0.6382059341072356562289432465e19, + -.1367620353088171386865416609e18, + 0.1434354939140344111664316553e16, + -.8085222034853793871199468171e13, + 0.2507158285536881945555156435e11, + -.4050412371833132706360663322e8, + 0.2685786856980014981415848441e5, +}; +static const double q1[] = { + 0.4933787251794133562113278438e21, + 0.5428918384092285160200195092e19, + 0.3024635616709462698627330784e17, + 0.1127756739679798507056031594e15, + 0.3123043114941213172572469442e12, + 0.6699987672982239671814028660e9, + 0.1114636098462985378182402543e7, + 0.1363063652328970604442810507e4, + 1.0 +}; +static const double p2[] = { + 0.5393485083869438325262122897e7, + 0.1233238476817638145232406055e8, + 0.8413041456550439208464315611e7, + 0.2016135283049983642487182349e7, + 0.1539826532623911470917825993e6, + 0.2485271928957404011288128951e4, + 0.0, +}; +static const double q2[] = { + 0.5393485083869438325560444960e7, + 0.1233831022786324960844856182e8, + 0.8426449050629797331554404810e7, + 0.2025066801570134013891035236e7, + 0.1560017276940030940592769933e6, + 0.2615700736920839685159081813e4, + 1.0, +}; +static const double p3[] = { + -.3984617357595222463506790588e4, + -.1038141698748464093880530341e5, + -.8239066313485606568803548860e4, + -.2365956170779108192723612816e4, + -.2262630641933704113967255053e3, + -.4887199395841261531199129300e1, + 0.0, +}; +static const double q3[] = { + 0.2550155108860942382983170882e6, + 0.6667454239319826986004038103e6, + 0.5332913634216897168722255057e6, + 0.1560213206679291652539287109e6, + 0.1570489191515395519392882766e5, + 0.4087714673983499223402830260e3, + 1.0, +}; +static const double p4[] = { + -.2750286678629109583701933175e20, + 0.6587473275719554925999402049e20, + -.5247065581112764941297350814e19, + 0.1375624316399344078571335453e18, + -.1648605817185729473122082537e16, + 0.1025520859686394284509167421e14, + -.3436371222979040378171030138e11, + 0.5915213465686889654273830069e8, + -.4137035497933148554125235152e5, +}; +static const double q4[] = { + 0.3726458838986165881989980e21, + 0.4192417043410839973904769661e19, + 0.2392883043499781857439356652e17, + 0.9162038034075185262489147968e14, + 0.2613065755041081249568482092e12, + 0.5795122640700729537480087915e9, + 0.1001702641288906265666651753e7, + 0.1282452772478993804176329391e4, + 1.0, +}; + +static void asympt(double); + +double +j0(double arg) +{ + double argsq, n, d; + int i; + + if(arg < 0.) arg = -arg; + if(arg > 8.){ + asympt(arg); + n = arg - pio4; + return(sqrt(tpi/arg)*(pzero*cos(n) - qzero*sin(n))); + } + argsq = arg*arg; + for(n=0,d=0,i=8;i>=0;i--){ + n = n*argsq + p1[i]; + d = d*argsq + q1[i]; + } + return(n/d); +} + +double +y0(double arg) +{ + double argsq, n, d; + int i; + + if(arg <= 0.){ +#if defined(vax)||defined(tahoe) + return(infnan(EDOM)); /* NaN */ +#else /* defined(vax)||defined(tahoe) */ + return(zero/zero); /* IEEE machines: invalid operation */ +#endif /* defined(vax)||defined(tahoe) */ + } + if(arg > 8.){ + asympt(arg); + n = arg - pio4; + return(sqrt(tpi/arg)*(pzero*sin(n) + qzero*cos(n))); + } + argsq = arg*arg; + for(n=0,d=0,i=8;i>=0;i--){ + n = n*argsq + p4[i]; + d = d*argsq + q4[i]; + } + return(n/d + tpi*j0(arg)*log(arg)); +} + +static void +asympt(double arg) +{ + double zsq, n, d; + int i; + zsq = 64./(arg*arg); + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p2[i]; + d = d*zsq + q2[i]; + } + pzero = n/d; + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p3[i]; + d = d*zsq + q3[i]; + } + qzero = (8./arg)*(n/d); +} diff --git a/1/newlibc/math/j1.c b/1/newlibc/math/j1.c new file mode 100755 index 0000000..8ca1042 --- /dev/null +++ b/1/newlibc/math/j1.c @@ -0,0 +1,214 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)j1.c 5.3 (Berkeley) 9/22/88"; +#endif /* not lint */ + +/* + floating point Bessel's function + of the first and second kinds + of order one + + j1(x) returns the value of J1(x) + for all real values of x. + + There are no error returns. + Calls sin, cos, sqrt. + + There is a niggling bug in J1 which + causes errors up to 2e-16 for x in the + interval [-8,8]. + The bug is caused by an inappropriate order + of summation of the series. rhm will fix it + someday. + + Coefficients are from Hart & Cheney. + #6050 (20.98D) + #6750 (19.19D) + #7150 (19.35D) + + y1(x) returns the value of Y1(x) + for positive real values of x. + For x<=0, if on the VAX, error number EDOM is set and + the reserved operand fault is generated; + otherwise (an IEEE machine) an invalid operation is performed. + + Calls sin, cos, sqrt, log, j1. + + The values of Y1 have not been checked + to more than ten places. + + Coefficients are from Hart & Cheney. + #6447 (22.18D) + #6750 (19.19D) + #7150 (19.35D) +*/ + +#include + +#if defined(vax)||defined(tahoe) +#include +#else /* defined(vax)||defined(tahoe) */ +static const double zero = 0.e0; +#endif /* defined(vax)||defined(tahoe) */ + +static double pzero, qzero; + +static const double tpi = .6366197723675813430755350535e0; +static const double pio4 = .7853981633974483096156608458e0; +static const double p1[] = { + 0.581199354001606143928050809e21, + -.6672106568924916298020941484e20, + 0.2316433580634002297931815435e19, + -.3588817569910106050743641413e17, + 0.2908795263834775409737601689e15, + -.1322983480332126453125473247e13, + 0.3413234182301700539091292655e10, + -.4695753530642995859767162166e7, + 0.2701122710892323414856790990e4, +}; +static const double q1[] = { + 0.1162398708003212287858529400e22, + 0.1185770712190320999837113348e20, + 0.6092061398917521746105196863e17, + 0.2081661221307607351240184229e15, + 0.5243710262167649715406728642e12, + 0.1013863514358673989967045588e10, + 0.1501793594998585505921097578e7, + 0.1606931573481487801970916749e4, + 1.0, +}; +static const double p2[] = { + -.4435757816794127857114720794e7, + -.9942246505077641195658377899e7, + -.6603373248364939109255245434e7, + -.1523529351181137383255105722e7, + -.1098240554345934672737413139e6, + -.1611616644324610116477412898e4, + 0.0, +}; +static const double q2[] = { + -.4435757816794127856828016962e7, + -.9934124389934585658967556309e7, + -.6585339479723087072826915069e7, + -.1511809506634160881644546358e7, + -.1072638599110382011903063867e6, + -.1455009440190496182453565068e4, + 1.0, +}; +static const double p3[] = { + 0.3322091340985722351859704442e5, + 0.8514516067533570196555001171e5, + 0.6617883658127083517939992166e5, + 0.1849426287322386679652009819e5, + 0.1706375429020768002061283546e4, + 0.3526513384663603218592175580e2, + 0.0, +}; +static const double q3[] = { + 0.7087128194102874357377502472e6, + 0.1819458042243997298924553839e7, + 0.1419460669603720892855755253e7, + 0.4002944358226697511708610813e6, + 0.3789022974577220264142952256e5, + 0.8638367769604990967475517183e3, + 1.0, +}; +static const double p4[] = { + -.9963753424306922225996744354e23, + 0.2655473831434854326894248968e23, + -.1212297555414509577913561535e22, + 0.2193107339917797592111427556e20, + -.1965887462722140658820322248e18, + 0.9569930239921683481121552788e15, + -.2580681702194450950541426399e13, + 0.3639488548124002058278999428e10, + -.2108847540133123652824139923e7, + 0.0, +}; +static const double q4[] = { + 0.5082067366941243245314424152e24, + 0.5435310377188854170800653097e22, + 0.2954987935897148674290758119e20, + 0.1082258259408819552553850180e18, + 0.2976632125647276729292742282e15, + 0.6465340881265275571961681500e12, + 0.1128686837169442121732366891e10, + 0.1563282754899580604737366452e7, + 0.1612361029677000859332072312e4, + 1.0, +}; + +static void asympt(double); + +double +j1(double arg) +{ + double xsq, n, d, x; + int i; + + x = arg; + if(x < 0.) x = -x; + if(x > 8.){ + asympt(x); + n = x - 3.*pio4; + n = sqrt(tpi/x)*(pzero*cos(n) - qzero*sin(n)); + if(arg <0.) n = -n; + return(n); + } + xsq = x*x; + for(n=0,d=0,i=8;i>=0;i--){ + n = n*xsq + p1[i]; + d = d*xsq + q1[i]; + } + return(arg*n/d); +} + +double +y1(double arg) +{ + double xsq, n, d, x; + int i; + + x = arg; + if(x <= 0.){ +#if defined(vax)||defined(tahoe) + return(infnan(EDOM)); /* NaN */ +#else /* defined(vax)||defined(tahoe) */ + return(zero/zero); /* IEEE machines: invalid operation */ +#endif /* defined(vax)||defined(tahoe) */ + } + if(x > 8.){ + asympt(x); + n = x - 3*pio4; + return(sqrt(tpi/x)*(pzero*sin(n) + qzero*cos(n))); + } + xsq = x*x; + for(n=0,d=0,i=9;i>=0;i--){ + n = n*xsq + p4[i]; + d = d*xsq + q4[i]; + } + return(x*n/d + tpi*(j1(x)*log(x)-1./x)); +} + +static void +asympt(double arg) +{ + double zsq, n, d; + int i; + zsq = 64./(arg*arg); + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p2[i]; + d = d*zsq + q2[i]; + } + pzero = n/d; + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p3[i]; + d = d*zsq + q3[i]; + } + qzero = (8./arg)*(n/d); +} diff --git a/1/newlibc/math/jn.c b/1/newlibc/math/jn.c new file mode 100755 index 0000000..aa5597a --- /dev/null +++ b/1/newlibc/math/jn.c @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)jn.c 5.3 (Berkeley) 9/22/88"; +#endif /* not lint */ + +/* + floating point Bessel's function of + the first and second kinds and of + integer order. + + int n; + double x; + jn(n,x); + + returns the value of Jn(x) for all + integer values of n and all real values + of x. + + There are no error returns. + Calls j0, j1. + + For n=0, j0(x) is called, + for n=1, j1(x) is called, + for nx, a continued fraction approximation to + j(n,x)/j(n-1,x) is evaluated and then backward + recursion is used starting from a supposed value + for j(n,x). The resulting value of j(0,x) is + compared with the actual value to correct the + supposed value of j(n,x). + + yn(n,x) is similar in all respects, except + that forward recursion is used for all + values of n>1. +*/ + +#include +#if defined(vax)||defined(tahoe) +#include +#else /* defined(vax)||defined(tahoe) */ +static double zero = 0.e0; +#endif /* defined(vax)||defined(tahoe) */ + +double +jn(int n, double x) +{ + int i; + double a, b, temp; + double xsq, t; + + if(n<0){ + n = -n; + x = -x; + } + if(n==0) return(j0(x)); + if(n==1) return(j1(x)); + if(x == 0.) return(0.); + if(n>x) goto recurs; + + a = j0(x); + b = j1(x); + for(i=1;in;i--){ + t = xsq/(2.*i - t); + } + t = x/(2.*n-t); + + a = t; + b = 1; + for(i=n-1;i>0;i--){ + temp = b; + b = (2.*i/x)*b - a; + a = temp; + } + return(t*j0(x)/b); +} + +double +yn(int n, double x) +{ + int i; + int sign; + double a, b, temp; + + if (x <= 0.0) { +#if defined(vax)||defined(tahoe) + return(infnan(EDOM)); /* NaN */ +#else /* defined(vax)||defined(tahoe) */ + return(zero/zero); /* IEEE machines: invalid operation */ +#endif /* defined(vax)||defined(tahoe) */ + } + sign = 1; + if(n<0){ + n = -n; + if(n%2 == 1) sign = -1; + } + if(n==0) return(y0(x)); + if(n==1) return(sign*y1(x)); + + a = y0(x); + b = y1(x); + for(i=1;i + +#if defined(vax)||defined(tahoe) +#include +#endif /* defined(vax)||defined(tahoe) */ + +int signgam = 0; +static const double goobie = 0.9189385332046727417803297; /* log(2*pi)/2 */ +static const double pi = 3.1415926535897932384626434; + +#define M 6 +#define N 8 +static const double p1[] = { + 0.83333333333333101837e-1, + -.277777777735865004e-2, + 0.793650576493454e-3, + -.5951896861197e-3, + 0.83645878922e-3, + -.1633436431e-2, +}; +static const double p2[] = { + -.42353689509744089647e5, + -.20886861789269887364e5, + -.87627102978521489560e4, + -.20085274013072791214e4, + -.43933044406002567613e3, + -.50108693752970953015e2, + -.67449507245925289918e1, + 0.0, +}; +static const double q2[] = { + -.42353689509744090010e5, + -.29803853309256649932e4, + 0.99403074150827709015e4, + -.15286072737795220248e4, + -.49902852662143904834e3, + 0.18949823415702801641e3, + -.23081551524580124562e2, + 0.10000000000000000000e1, +}; + +static double pos(double), neg(double), asym(double); + +double +lgamma(double arg) +{ + + signgam = 1.; + if(arg <= 0.) return(neg(arg)); + if(arg > 8.) return(asym(arg)); + return(log(pos(arg))); +} + +static double +asym(double arg) +{ + double n, argsq; + int i; + + argsq = 1./(arg*arg); + for(n=0,i=M-1; i>=0; i--){ + n = n*argsq + p1[i]; + } + return((arg-.5)*log(arg) - arg + goobie + n/arg); +} + +static double +neg(double arg) +{ + double t; + + arg = -arg; + /* + * to see if arg were a true integer, the old code used the + * mathematically correct observation: + * sin(n*pi) = 0 <=> n is an integer. + * but in finite precision arithmetic, sin(n*PI) will NEVER + * be zero simply because n*PI is a rational number. hence + * it failed to work with our newer, more accurate sin() + * which uses true pi to do the argument reduction... + * temp = sin(pi*arg); + */ + t = floor(arg); + if (arg - t > 0.5e0) + t += 1.e0; /* t := integer nearest arg */ +#if defined(vax)||defined(tahoe) + if (arg == t) { + return(infnan(ERANGE)); /* +INF */ + } +#endif /* defined(vax)||defined(tahoe) */ + signgam = (int) (t - 2*floor(t/2)); /* signgam = 1 if t was odd, */ + /* 0 if t was even */ + signgam = signgam - 1 + signgam; /* signgam = 1 if t was odd, */ + /* -1 if t was even */ + t = arg - t; /* -0.5 <= t <= 0.5 */ + if (t < 0.e0) { + t = -t; + signgam = -signgam; + } + return(-log(arg*pos(arg)*sin(pi*t)/pi)); +} + +static double +pos(double arg) +{ + double n, d, s; + register i; + + if(arg < 2.) return(pos(arg+1.)/arg); + if(arg > 3.) return((arg-1.)*pos(arg-1.)); + + s = arg - 2.; + for(n=0,d=0,i=N-1; i>=0; i--){ + n = n*s + p2[i]; + d = d*s + q2[i]; + } + return(n/d); +} diff --git a/1/newlibc/math/log.s b/1/newlibc/math/log.s new file mode 100755 index 0000000..ea2dcc0 --- /dev/null +++ b/1/newlibc/math/log.s @@ -0,0 +1,20 @@ +/* This is file LOG.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .globl _log +_log: + fldln2 + fldl 4(%esp) + fyl2x + ret diff --git a/1/newlibc/math/log10.s b/1/newlibc/math/log10.s new file mode 100755 index 0000000..2e889be --- /dev/null +++ b/1/newlibc/math/log10.s @@ -0,0 +1,20 @@ +/* This is file LOG10.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .globl _log10 +_log10: + fldlg2 + fldl 4(%esp) + fyl2x + ret diff --git a/1/newlibc/math/sin.s b/1/newlibc/math/sin.s new file mode 100755 index 0000000..2761475 --- /dev/null +++ b/1/newlibc/math/sin.s @@ -0,0 +1,29 @@ +/* This is file SIN.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +L0: + .quad 0xffffffffffffffff + + .globl _sin +_sin: + fldl 4(%esp) + fsin + fstsw + sahf + jnp L1 + fstp %st(0) + fldl L0 +L1: + ret + diff --git a/1/newlibc/math/sinh.c b/1/newlibc/math/sinh.c new file mode 100755 index 0000000..4f9f09d --- /dev/null +++ b/1/newlibc/math/sinh.c @@ -0,0 +1,7 @@ +#include + +double sinh(double x) +{ + return (exp(x) - exp(-x)) / 2.0; +} + diff --git a/1/newlibc/math/sqrt.s b/1/newlibc/math/sqrt.s new file mode 100755 index 0000000..73b1137 --- /dev/null +++ b/1/newlibc/math/sqrt.s @@ -0,0 +1,19 @@ +/* This is file SQRT.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .globl _sqrt +_sqrt: + fldl 4(%esp) + fsqrt + ret diff --git a/1/newlibc/math/tan.s b/1/newlibc/math/tan.s new file mode 100755 index 0000000..eef28be --- /dev/null +++ b/1/newlibc/math/tan.s @@ -0,0 +1,30 @@ +/* This is file TAN.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +L0: + .quad 0xffffffffffffffff + + .globl _tan +_tan: + fldl 4(%esp) + fptan + fstsw + fstp %st(0) + sahf + jnp L1 + fstp %st(0) + fldl L0 +L1: + ret + diff --git a/1/newlibc/math/tanh.c b/1/newlibc/math/tanh.c new file mode 100755 index 0000000..1ffb6ce --- /dev/null +++ b/1/newlibc/math/tanh.c @@ -0,0 +1,7 @@ +#include + +double tanh(double x) +{ + return (exp(x) - exp(-x)) / (exp(x) + exp(-x)); +} + diff --git a/1/newlibc/misc/._Makefile b/1/newlibc/misc/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._README b/1/newlibc/misc/._README new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._atexit.c b/1/newlibc/misc/._atexit.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._bcopy.s b/1/newlibc/misc/._bcopy.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._exit.c b/1/newlibc/misc/._exit.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._frexp.c b/1/newlibc/misc/._frexp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._ldexp.c b/1/newlibc/misc/._ldexp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._modf.c b/1/newlibc/misc/._modf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._perror.c b/1/newlibc/misc/._perror.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._readv.c b/1/newlibc/misc/._readv.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._tmpnam.c b/1/newlibc/misc/._tmpnam.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._values.s b/1/newlibc/misc/._values.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/._writev.c b/1/newlibc/misc/._writev.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/misc/Makefile b/1/newlibc/misc/Makefile new file mode 100755 index 0000000..e68eea0 --- /dev/null +++ b/1/newlibc/misc/Makefile @@ -0,0 +1,52 @@ +# +# Makefile for some odd library functions +# + +XCFLAGS =-DSOFT_387 +LIB =../Libc.a +AR =/usr/local/bin/ar +AS =/usr/local/bin/as +LD =/usr/local/bin/ld +LDFLAGS =-s -x +CC =/usr/local/bin/gcc -B/usr/local/bin/ +INC =-nostdinc -I. -I../include +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer $(INC) \ + $(XCFLAGS) +CPP =$(CC) -E $(INC) $(XCFLAGS) + +.SUFFIXES: .S .o + +.S.o: + $(CPP) -c -o $*.s $< + $(AS) -c -o $*.o $*.s + $(RM) -f $*.s +.c.s: + $(CC) $(CFLAGS) -S -o $*.s $< +.s.o: + $(CC) -c -o $*.o $< +.c.o: + $(CC) $(CFLAGS) -c -o $*.o $< + +OBJS = bcopy.o ldexp.o modf.o tmpnam.o \ + readv.o writev.o values.o perror.o +#atexit.o exit.o +#OBJS = bcopy.o ldexp.o modf.o perror.o tmpnam.o readv.o writev.o +#OBJS = bcopy.o frexp.o ldexp.o modf.o + +all: library + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/misc/README b/1/newlibc/misc/README new file mode 100755 index 0000000..b39206a --- /dev/null +++ b/1/newlibc/misc/README @@ -0,0 +1,7 @@ +These files are from all over the places. I didn't put readv () in +libc.a. You can add it your self. It will be in libc.a when gcc 2.0 +is released. + +H.J. Lu +hlu@eecs.wsu.edu +02/18/92 diff --git a/1/newlibc/misc/atexit.c b/1/newlibc/misc/atexit.c new file mode 100755 index 0000000..5be41c5 --- /dev/null +++ b/1/newlibc/misc/atexit.c @@ -0,0 +1,55 @@ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)atexit.c 5.1 (Berkeley) 5/15/90"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +/* + * Register a function to be performed at exit. + */ +int +atexit(void (*fn)(void)) +{ + static struct atexit __atexit0; /* one guaranteed table */ + register struct atexit *p; + + if ((p = __atexit) == NULL) + __atexit = p = &__atexit0; + if (p->ind >= ATEXIT_SIZE) { + if ((p = (struct atexit *) malloc(sizeof(*p))) == NULL) + return (-1); + __atexit->next = p; + __atexit = p; + } + p->fns[p->ind++] = fn; + return (0); +} diff --git a/1/newlibc/misc/bcopy.s b/1/newlibc/misc/bcopy.s new file mode 100755 index 0000000..3914344 --- /dev/null +++ b/1/newlibc/misc/bcopy.s @@ -0,0 +1,105 @@ +/* + * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + * + * Permission to use, copy, modify, distribute, and sell this software and its + * documentation for any purpose is hereby granted without fee, provided that + * the above copyright notice appear in all copies and that both that + * copyright notice and this permission notice appear in supporting + * documentation, and that the name of Thomas Roell not be used in + * advertising or publicity pertaining to distribution of the software without + * specific, written prior permission. Thomas Roell makes no representations + * about the suitability of this software for any purpose. It is provided + * "as is" without express or implied warranty. + * + * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO + * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + * + * Author: Thomas Roell, roell@informatik.tu-muenchen.de + * + * $Header: /proj/X11/mit/server/ddx/at386/bsdemul/RCS/bcopy.s,v 1.5 91/02/10 16:23:21 root Exp $ + */ + +/* + * bcopy (b1, b2, length) + * register unsigned char *b1, *b2; + * register length; + * { + * if (b1 < b2) { + * b2 += length; + * b1 += length; + * while (length--) { + * *--b2 = *--b1; + * } + * } + * else { + * while (length--) { + * *b2++ = *b1++; + * } + * } + * } + */ + + .text + .globl _bcopy + .align 2 +_bcopy: + pushl %ebp + movl %esp,%ebp + pushl %esi /* save register */ + pushl %edi + + movl 8(%ebp),%esi /* unsigned char * b1 */ + movl 12(%ebp),%edi /* unsigned char * b2 */ + movl 16(%ebp),%ecx /* length */ + + cmpl %esi,%edi + jbe .uploop + + std + addl %ecx,%esi /* adjust pointer, so that we can move */ + addl %ecx,%edi + + movl %ecx,%edx + shrl $2,%ecx + subl $4,%esi + subl $4,%edi + rep /* move longwords */ + movsl + addl $4,%esi + addl $4,%edi + + movl %edx,%ecx + andl $3,%ecx + + decl %esi + decl %edi + rep /* move bytes */ + movsb + + cld + popl %edi + popl %esi + leave + ret + +.uploop: + movl %ecx,%edx + shrl $2,%ecx + rep /* move longwords */ + movsl + + movl %edx,%ecx + andl $3,%ecx + + rep /* move bytes */ + movsb + + popl %edi + popl %esi + leave + ret diff --git a/1/newlibc/misc/exit.c b/1/newlibc/misc/exit.c new file mode 100755 index 0000000..fc19533 --- /dev/null +++ b/1/newlibc/misc/exit.c @@ -0,0 +1,32 @@ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +#include + +extern void _cleanup (); +extern void _exit(int exit_code); + +void +exit(code) + int code; +{ + struct atexit *a = __atexit; + while (a) + { + while (a->ind) + (a->fns[--a->ind])(); + a = a->next; + } + _cleanup(); + _exit(code); +} diff --git a/1/newlibc/misc/frexp.c b/1/newlibc/misc/frexp.c new file mode 100755 index 0000000..c0b3247 --- /dev/null +++ b/1/newlibc/misc/frexp.c @@ -0,0 +1,26 @@ +#include + +double frexp(double x, int *i) +{ + double rv = x; + int sign=1; + int ri = 0; + if (rv < 0) + { + sign = -1; + rv = -rv; + } + while (rv > 1) + { + ri++; + rv /= 2.0; + } + while (rv < 0.5) + { + ri--; + rv *= 2; + } + *i = ri; + return rv*sign; +} + diff --git a/1/newlibc/misc/ldexp.c b/1/newlibc/misc/ldexp.c new file mode 100755 index 0000000..3e94415 --- /dev/null +++ b/1/newlibc/misc/ldexp.c @@ -0,0 +1,11 @@ +#include "soft.h" + +/* Adds 'e' to binary exponent of d (unless d=0), result is returned + */ +double ldexp(double d, int e) +{ + struct bitdouble *dp = (struct bitdouble *)&d; + + if (dp->exp) dp->exp += e; + return d; +} diff --git a/1/newlibc/misc/modf.c b/1/newlibc/misc/modf.c new file mode 100755 index 0000000..76e0e25 --- /dev/null +++ b/1/newlibc/misc/modf.c @@ -0,0 +1,120 @@ +/* This file has been modified by Hongjiu Lu (Feb 1992). + */ + +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Sean Eric Fagan + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#ifndef SOFT_387 + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)modf.c 5.1 (Berkeley) 4/23/90"; +#endif /* LIBC_SCCS and not lint */ + +/* + * modf(value, iptr): return fractional part of value, and stores the + * integral part into iptr (a pointer to double). + * + * Written by Sean Eric Fagan (sef@kithrup.COM) + * Sun Mar 11 20:27:30 PST 1990 + */ + +/* With CHOP mode on, frndint behaves as TRUNC does. Useful. */ +double +modf(double value, double *iptr) +{ + double temp; + volatile short i87flag, i87temp; + __asm ("fnstcw %0" : "=m" (i87flag) : ); + i87temp = i87flag | 0xc00 ; /* turn on chop mode [truncation] */ + __asm ("fldcw %0" : : "m" (i87temp)); +#ifdef PRE_GCC_2 + __asm ("frndint" : "=t" (temp) : "0" (value)); /* temp = int of value */ +#else + __asm ("frndint" : "=f" (temp) : "0" (value)); /* temp = int of value */ +#endif + __asm ("fldcw %0" : : "m" (i87flag)); + *iptr = temp; + return (value - temp); +} + +#else + +#include "soft.h" + +#define shiftleft(dp,n) { /* n = 0 to 32 */ \ + dp->mant1 = ((dp->mant1 << (n)) + (dp->mant2 >> (32-(n)))) \ + & 0x0FFFFF; dp->mant2 <<= (n); dp->exp -= (n); } + + +/* Returns fractional part of d, stores integer part in *integ + */ +double modf(double d, double *integ) +{ + struct bitdouble *dp = (struct bitdouble *)&d; + struct bitdouble *ip = (struct bitdouble *)integ; + int e = dp->exp - BIAS; + + if (e < 0) { /* no integer part */ + *integ = 0; + return d; + } + + /* compute integer: clear fractional part where necessary + */ + *integ = d; + if (e <= 20) { + ip->mant1 &= (-1L << (20-e)); /* split in mant1... */ + ip->mant2 = 0; + } + else + if (e <= 52) + ip->mant2 &= (-1L << (52-e)); /* split in mant2 */ + else return 0; /* no fractional part */ + + /* compute fractional part: shift left over integer part + */ + if (e) + if (e <= 32) + shiftleft(dp,e) + else { + dp->mant1 = (dp->mant2 << (e-32)) & 0x0FFFFF; + dp->mant2 = 0; + dp->exp -= e; + } + + /* adjust fractional part shifting left... + */ + if (dp->mant1==0 && dp->mant2==0) /* fraction is zero */ + return 0; + + while (!(dp->mant1 & 0x080000)) /* stack to the left */ + shiftleft(dp,1); + + shiftleft(dp,1); /* lose 'invisible bit' */ + return d; +} +#endif diff --git a/1/newlibc/misc/perror.c b/1/newlibc/misc/perror.c new file mode 100755 index 0000000..a1a1f6a --- /dev/null +++ b/1/newlibc/misc/perror.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)perror.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +/* + * Print the error indicated + * in the cerror cell. + */ +#include +#include + +#ifdef linux +#include +extern char *strerror(int n); +extern int writev(int handle, struct iovec *iov, int count); +#endif + +extern int errno; +extern int sys_nerr; +extern char *sys_errlist[]; + +void +perror(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 = strerror (errno); + v->iov_len = strlen(v->iov_base); + v++; + v->iov_base = "\n"; + v->iov_len = 1; + (void) writev(2, iov, (v - iov) + 1); +} diff --git a/1/newlibc/misc/readv.c b/1/newlibc/misc/readv.c new file mode 100755 index 0000000..d10dcb1 --- /dev/null +++ b/1/newlibc/misc/readv.c @@ -0,0 +1,40 @@ +/* This file has been modified by H.J. Lu. */ + +/* This is file READV.C */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +** +** Modified by H.J. Lu 1992 +*/ + +#include +#include + +#ifdef linux +#include +#endif + +int +readv(int handle, const struct iovec *iov, size_t count) +{ + int r, t=0; + + while (count) { + r = read(handle, iov->iov_base, iov->iov_len); + if (r < 0) + return r; + t += r; + iov++; + count--; + } + return t; +} diff --git a/1/newlibc/misc/tmpnam.c b/1/newlibc/misc/tmpnam.c new file mode 100755 index 0000000..26f8ed7 --- /dev/null +++ b/1/newlibc/misc/tmpnam.c @@ -0,0 +1,105 @@ +/* This is file TMPNAM.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted provided + * that: (1) source distributions retain this entire copyright notice and + * comment, and (2) distributions including binaries display the following + * acknowledgement: ``This product includes software developed by the + * University of California, Berkeley and its contributors'' in the + * documentation or other materials provided with the distribution and in + * all advertising materials mentioning features or use of this software. + * Neither the name of the University nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)tmpnam.c 4.8 (Berkeley) 6/22/90"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +#ifdef linux +#include +#include +#include + +#define MAXPATHLEN PATH_MAX + +extern char *mktemp(char * template); +#endif + +#ifndef P_tmpdir +#define P_tmpdir "/usr/tmp" +#endif + +char * +tmpnam(s) + char *s; +{ +#ifndef linux + char *malloc(), *mktemp(); +#endif + + if (!s && !(s = (char *) malloc((unsigned int)MAXPATHLEN))) + return(NULL); + (void)sprintf(s, "%s/XXXXXX", P_tmpdir); + return(mktemp(s)); +} + +char * +tempnam(dir, pfx) + char *dir, *pfx; +{ + char *f, *name; +#ifndef linux + char *getenv(), *malloc(), *mktemp(); +#endif + + if (!(name = (char *) malloc((unsigned int)MAXPATHLEN))) + return(NULL); + + if (f = getenv("TMPDIR")) { + (void)sprintf(name, "%s/%sXXXXXX", f, pfx ? "" : pfx); + if (f = mktemp(name)) + return(f); + } + if (dir) { + (void)sprintf(name, "%s/%sXXXXXX", dir, pfx ? "" : pfx); + if (f = mktemp(name)) + return(f); + } + (void)sprintf(name, "%s/%sXXXXXX", P_tmpdir, pfx ? "" : pfx); + if (f = mktemp(name)) + return(f); + (void)sprintf(name, "/tmp/%sXXXXXX", pfx ? "" : pfx); + if (!(f = mktemp(name))) + (void)free(name); + return(f); +} + +FILE * +tmpfile() +{ + FILE *fp; + char *f; + + if (!(f = tmpnam((char *)NULL)) || !(fp = fopen(f, "w+"))) { + fprintf(stderr, "tmpfile: cannot open %s.\n", f); + return(NULL); + } + (void)unlink(f); + return(fp); +} diff --git a/1/newlibc/misc/values.s b/1/newlibc/misc/values.s new file mode 100755 index 0000000..376a0d1 --- /dev/null +++ b/1/newlibc/misc/values.s @@ -0,0 +1,53 @@ +// +// This file is part of the alternative 80386 math library and is +// covered by the GNU General Public license with my modification +// as noted in the README file that accompanied this file. +// +// Copyright 1990 G. Geers +// +// Modified by H.J. Lu +// + + .file "values.s" + + .align 2 + .globl _isnan +_isnan: + movl 8(%esp),%eax + andl $0x7ff00000,%eax + cmpl $0x7ff00000,%eax + jne Lnotnan + movl 8(%esp),%eax + andl $0xfffff,%eax + orl 4(%esp),%eax + je Lnotnan + + xorl %eax,%eax + incl %eax + ret + +Lnotnan: + xorl %eax,%eax + ret + + .align 2 + .globl _isinf +_isinf: + movl 8(%esp),%eax + andl $0x7ff00000, %eax + cmpl $0x7ff00000, %eax + je Lcouldbeinf + +Lnotinf: + xorl %eax,%eax + ret + +Lcouldbeinf: + movl 8(%esp),%eax + andl $0xfffff,%eax + orl 4(%esp),%eax + jne Lnotinf + + xorl %eax,%eax + incl %eax + ret diff --git a/1/newlibc/misc/writev.c b/1/newlibc/misc/writev.c new file mode 100755 index 0000000..2f458b8 --- /dev/null +++ b/1/newlibc/misc/writev.c @@ -0,0 +1,38 @@ +/* This file has been modified by H.J. Lu. */ + +/* This is file WRITEV.C */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +#include +#include + +#ifdef linux +#include +#endif + +int +writev(int handle, const struct iovec *iov, size_t count) +{ + int r, t=0; + + while (count) { + r = write(handle, iov->iov_base, iov->iov_len); + if (r < 0) + return r; + t += r; + iov++; + count--; + } + return t; +} diff --git a/1/newlibc/mlinux/._Makefile b/1/newlibc/mlinux/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._README b/1/newlibc/mlinux/._README new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._acos.s b/1/newlibc/mlinux/._acos.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._acosh.s b/1/newlibc/mlinux/._acosh.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._asin.s b/1/newlibc/mlinux/._asin.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._asinh.s b/1/newlibc/mlinux/._asinh.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._atan.s b/1/newlibc/mlinux/._atan.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._atan2.s b/1/newlibc/mlinux/._atan2.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._atanh.s b/1/newlibc/mlinux/._atanh.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._ceil.s b/1/newlibc/mlinux/._ceil.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._cos.s b/1/newlibc/mlinux/._cos.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._cosh.s b/1/newlibc/mlinux/._cosh.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._erf.c b/1/newlibc/mlinux/._erf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._exp.s b/1/newlibc/mlinux/._exp.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._fabs.s b/1/newlibc/mlinux/._fabs.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._floor.s b/1/newlibc/mlinux/._floor.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._fmod.s b/1/newlibc/mlinux/._fmod.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._frexp.c b/1/newlibc/mlinux/._frexp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._hypot.s b/1/newlibc/mlinux/._hypot.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._j0.c b/1/newlibc/mlinux/._j0.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._j1.c b/1/newlibc/mlinux/._j1.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._jn.c b/1/newlibc/mlinux/._jn.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._lgamma.c b/1/newlibc/mlinux/._lgamma.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._log.s b/1/newlibc/mlinux/._log.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._log10.s b/1/newlibc/mlinux/._log10.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._math.h b/1/newlibc/mlinux/._math.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._sin.s b/1/newlibc/mlinux/._sin.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._sinh.s b/1/newlibc/mlinux/._sinh.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._sqrt.s b/1/newlibc/mlinux/._sqrt.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._tan.s b/1/newlibc/mlinux/._tan.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/._tanh.s b/1/newlibc/mlinux/._tanh.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/mlinux/Makefile b/1/newlibc/mlinux/Makefile new file mode 100755 index 0000000..57a616d --- /dev/null +++ b/1/newlibc/mlinux/Makefile @@ -0,0 +1,36 @@ +# This is Makefile of the math lib for Linux +# +LIB=../Libm.a +CC= /usr2/linux/cross/bin/gcc -B/usr2/linux/cross/lib/gcc- +CFLAGS = -Wall -O -fstrength-reduce -fomit-frame-pointer $(INC) +INC=-nostdinc -I. -I/usr2/linux/lib.new/2.0 -I/usr2/linux/usr/include +CPP=$(CC) -E $(INC) +AR=/usr2/linux/cross/bin/ar +RM=/bin/rm + +.s.o : + $(CC) $(CFLAGS) -c $*.s + +.c.o : + $(CC) $(CFLAGS) -c $*.c + +OBJS = acos.o acosh.o asin.o asinh.o atan.o atan2.o atanh.o ceil.o \ + cos.o cosh.o exp.o fabs.o floor.o fmod.o frexp.o hypot.o \ + log.o log10.o sin.o sinh.o sqrt.o tan.o tanh.o \ + erf.o j0.o j1.o jn.o lgamma.o + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/mlinux/README b/1/newlibc/mlinux/README new file mode 100755 index 0000000..2dc9009 --- /dev/null +++ b/1/newlibc/mlinux/README @@ -0,0 +1,8 @@ +This is the math lib for Linux. Some of them are borrowed from DJ +Delorie and BSD 4.3 and are covered by respective copyright notices. +The rest is written by me, which is covered by the GNU General Public +license version 2, or any later version. + +H.J. Lu +02/17/92 +hlu@eecs.wsu.edu diff --git a/1/newlibc/mlinux/acos.s b/1/newlibc/mlinux/acos.s new file mode 100755 index 0000000..3e2c194 --- /dev/null +++ b/1/newlibc/mlinux/acos.s @@ -0,0 +1,33 @@ +/* This is file ACOS.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .text + .globl _acos + .align 2 +_acos: + fldl 4(%esp) + fld1 + fsubp %st(0),%st(1) + fsqrt + + fldl 4(%esp) + fld1 + faddp %st(0),%st(1) + fsqrt + + fpatan + + fld %st(0) + faddp + ret diff --git a/1/newlibc/mlinux/acosh.s b/1/newlibc/mlinux/acosh.s new file mode 100755 index 0000000..ddfac1b --- /dev/null +++ b/1/newlibc/mlinux/acosh.s @@ -0,0 +1,30 @@ +// +// This file is part of the alternative 80386 math library and is +// covered by the GNU General Public license with my modification +// as noted in the README file that accompanied this file. +// +// Copyright 1990 G. Geers +// +// Modified by H.J. Lu for Linux 1992 +// + + .file "acosh.s" + + .align 2 + .globl _acosh +_acosh: + fldl 4(%esp) + fmull 4(%esp) + + fld1 + fsubrp + fsqrt + + faddl 4(%esp) + + fldln2 + + fxch %st(1) + fyl2x + + ret diff --git a/1/newlibc/mlinux/asin.s b/1/newlibc/mlinux/asin.s new file mode 100755 index 0000000..f2e518a --- /dev/null +++ b/1/newlibc/mlinux/asin.s @@ -0,0 +1,29 @@ +/* This is file ASIN.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +/* History:11,23 */ + .text + .align 2 + .globl _asin +_asin: + fldl 4(%esp) + fld %st(0) + fmulp + fld1 + fsubp + fsqrt + fldl 4(%esp) + fxch %st(1) + fpatan + ret diff --git a/1/newlibc/mlinux/asinh.s b/1/newlibc/mlinux/asinh.s new file mode 100755 index 0000000..b59e3c4 --- /dev/null +++ b/1/newlibc/mlinux/asinh.s @@ -0,0 +1,27 @@ +// +// This file is part of the alternative 80386 math library and is +// covered by the GNU General Public license with my modification +// as noted in the README file that accompanied this file. +// +// Copyright 1990 G. Geers +// +// Modified by H.J. Lu for Linux 1992 +// + + .file "asinh.s" + + .align 2 + .globl _asinh +_asinh: + fldl 4(%esp) + + fmull 4(%esp) + fld1 + faddp + fsqrt + faddl 4(%esp) + fldln2 + fxch %st(1) + fyl2x + + ret diff --git a/1/newlibc/mlinux/atan.s b/1/newlibc/mlinux/atan.s new file mode 100755 index 0000000..e65bcd6 --- /dev/null +++ b/1/newlibc/mlinux/atan.s @@ -0,0 +1,21 @@ +/* This is file ATAN.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + .text + .align 2 + .globl _atan +_atan: + fldl 4(%esp) + fld1 + fpatan + ret diff --git a/1/newlibc/mlinux/atan2.s b/1/newlibc/mlinux/atan2.s new file mode 100755 index 0000000..6f72f40 --- /dev/null +++ b/1/newlibc/mlinux/atan2.s @@ -0,0 +1,22 @@ +/* This is file ATAN2.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .text + .align 2 + .globl _atan2 +_atan2: + fldl 4(%esp) + fldl 12(%esp) + fpatan + ret diff --git a/1/newlibc/mlinux/atanh.s b/1/newlibc/mlinux/atanh.s new file mode 100755 index 0000000..e4d6a84 --- /dev/null +++ b/1/newlibc/mlinux/atanh.s @@ -0,0 +1,35 @@ +// +// This file is part of the alternative 80386 math library and is +// covered by the GNU General Public license with my modification +// as noted in the README file that accompanied this file. +// +// Copyright 1990 G. Geers +// +// Modified by H.J. Lu for Linux 1992 +// +// + + .file "atanh.s" + + .text + .align 2 +Lhalf: + .double 0d5.0000000000000000000000e-01 + + .align 2 + .globl _atanh +_atanh: + fld1 + faddl 4(%esp) + fld1 + fsubl 4(%esp) + fdivrp + + fldln2 + fxch %st(1) + fyl2x + + fldl Lhalf + fmulp + + ret diff --git a/1/newlibc/mlinux/ceil.s b/1/newlibc/mlinux/ceil.s new file mode 100755 index 0000000..2913b9f --- /dev/null +++ b/1/newlibc/mlinux/ceil.s @@ -0,0 +1,38 @@ +/* This is file CEIL.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .text + .align 2 + .globl _ceil +_ceil: + pushl %ebp + movl %esp,%ebp + sub $8,%esp /* -4 = old CW, -2 = new CW */ + + fstcw -4(%ebp) + fwait + movw -4(%ebp),%ax + andw $0xf3ff,%ax + orw $0x0800,%ax + movw %ax,-2(%ebp) + fldcww -2(%ebp) + + fldl 8(%ebp) + frndint + + fldcww -4(%ebp) + + movl %ebp,%esp + popl %ebp + ret diff --git a/1/newlibc/mlinux/cos.s b/1/newlibc/mlinux/cos.s new file mode 100755 index 0000000..8058809 --- /dev/null +++ b/1/newlibc/mlinux/cos.s @@ -0,0 +1,32 @@ +// +// This file is part of the math library for Linux and is +// covered by the GNU General Public license version 2, or +// any later version. +// +// Copyright 1992 by H.J. Lu +// + .file "cos.s" + .text + .align 2 + .globl _cos +_cos: + fldl 4(%esp) + jmp L3 +L1: + fldpi + fld %st(0) + faddp %st,%st(1) + fxch %st(1) +L2: + fprem1 + fstsw %ax + sahf + jp L2 + fxch %st(1) + fstp %st(0) +L3: + fcos + fstsw %ax + sahf + jp L1 + ret diff --git a/1/newlibc/mlinux/cosh.s b/1/newlibc/mlinux/cosh.s new file mode 100755 index 0000000..669c38b --- /dev/null +++ b/1/newlibc/mlinux/cosh.s @@ -0,0 +1,50 @@ +// +// This file is part of the math library for Linux and is +// covered by the GNU General Public license version 2, or +// any later version. +// +// Copyright 1992 by H.J. Lu +// + .file "cosh.s" + .data + .align 2 +LCW1: + .word 0 +LCW2: + .word 0 + + .text + .align 2 +LC2: + .double 0d5.0000000000000000000000e-01 + + .align 2 + .globl _cosh +_cosh: + fldl 4(%esp) + fldl2e + fmulp %st,%st(1) + fst %st(1) + fstcw LCW1 + fstcw LCW2 + fwait + andw $0xf3ff,LCW1 + fldcw LCW1 + frndint + fldcw LCW2 + fst %st(2) + fsubrp %st,%st(1) + f2xm1 + fld1 + faddp %st,%st(1) + fscale + fst %st(1) + + fld1 + fdivp %st,%st(1) + faddp %st,%st(1) + + fldl LC2 + fmulp %st,%st(1) + + ret diff --git a/1/newlibc/mlinux/erf.c b/1/newlibc/mlinux/erf.c new file mode 100755 index 0000000..a3fe575 --- /dev/null +++ b/1/newlibc/mlinux/erf.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)erf.c 5.2 (Berkeley) 4/29/88"; +#endif /* not lint */ + +/* + C program for floating point error function + + erf(x) returns the error function of its argument + erfc(x) returns 1.0-erf(x) + + erf(x) is defined by + ${2 over sqrt(pi)} int from 0 to x e sup {-t sup 2} dt$ + + the entry for erfc is provided because of the + extreme loss of relative accuracy if erf(x) is + called for large x and the result subtracted + from 1. (e.g. for x= 10, 12 places are lost). + + There are no error returns. + + Calls exp. + + Coefficients for large x are #5667 from Hart & Cheney (18.72D). +*/ + +#include + +#define M 7 +#define N 9 +static double torp = 1.1283791670955125738961589031; +static double p1[] = { + 0.804373630960840172832162e5, + 0.740407142710151470082064e4, + 0.301782788536507577809226e4, + 0.380140318123903008244444e2, + 0.143383842191748205576712e2, + -.288805137207594084924010e0, + 0.007547728033418631287834e0, +}; +static double q1[] = { + 0.804373630960840172826266e5, + 0.342165257924628539769006e5, + 0.637960017324428279487120e4, + 0.658070155459240506326937e3, + 0.380190713951939403753468e2, + 0.100000000000000000000000e1, + 0.0, +}; +static double p2[] = { + 0.18263348842295112592168999e4, + 0.28980293292167655611275846e4, + 0.2320439590251635247384768711e4, + 0.1143262070703886173606073338e4, + 0.3685196154710010637133875746e3, + 0.7708161730368428609781633646e2, + 0.9675807882987265400604202961e1, + 0.5641877825507397413087057563e0, + 0.0, +}; +static double q2[] = { + 0.18263348842295112595576438e4, + 0.495882756472114071495438422e4, + 0.60895424232724435504633068e4, + 0.4429612803883682726711528526e4, + 0.2094384367789539593790281779e4, + 0.6617361207107653469211984771e3, + 0.1371255960500622202878443578e3, + 0.1714980943627607849376131193e2, + 1.0, +}; + +double +erf(double arg) +{ + int sign; + double argsq; + double d, n; + int i; + + sign = 1; + if(arg < 0.){ + arg = -arg; + sign = -1; + } + if(arg < 0.5){ + argsq = arg*arg; + for(n=0,d=0,i=M-1; i>=0; i--){ + n = n*argsq + p1[i]; + d = d*argsq + q1[i]; + } + return(sign*torp*arg*n/d); + } + if(arg >= 10.) + return(sign*1.); + return(sign*(1. - erfc(arg))); +} + +double +erfc(double arg) +{ + double n, d; + int i; + + if(arg < 0.) + return(2. - erfc(-arg)); +/* + if(arg < 0.5) + return(1. - erf(arg)); +*/ + if(arg >= 10.) + return(0.); + + for(n=0,d=0,i=N-1; i>=0; i--){ + n = n*arg + p2[i]; + d = d*arg + q2[i]; + } + return(exp(-arg*arg)*n/d); +} diff --git a/1/newlibc/mlinux/exp.s b/1/newlibc/mlinux/exp.s new file mode 100755 index 0000000..5581fe8 --- /dev/null +++ b/1/newlibc/mlinux/exp.s @@ -0,0 +1,92 @@ +/* This is file EXP.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** Modified O.ROBERT 24, Avenue de Verdun 92170 VANVES, FRANCE +** +** E-mail: roberto@germinal.ibp.fr +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +** +** or 03-Apr-1991 corrected bug about argument zero to pow +** fyl2x didn't like it +*/ + +/* History:15,24 */ + .data +LCW1: + .word 0 +LCW2: + .word 0 + + .text + .align 2 +LC0: + .double 0d1.0e+00 + + .globl _pow2 + .align 2 +_pow2: + fldl 4(%esp) +Lpow2: + fstcw LCW1 + fstcw LCW2 + fwait + andw $0xf3ff,LCW1 + fldcw LCW1 + fldl %st(0) + frndint + fldcw LCW2 + fxch %st(1) + fsub %st(1),%st + f2xm1 + faddl LC0 + fscale + fstp %st(1) + ret + + .globl _exp +_exp: + fldl 4(%esp) + fldl2e + fmulp + jmp Lpow2 + + .globl _pow10 +_pow10: + fldl 4(%esp) + fldl2t + fmulp + jmp Lpow2 + + .globl _pow +_pow: + fldl 4(%esp) + ftst + fnstsww %ax + sahf + je zero1 + fldl 12(%esp) + ftst + fnstsww %ax + sahf + je zero2 + fxch %st(1) + fyl2x + jmp Lpow2 +zero1: + fstpl 4(%esp) + fldzl + ret +zero2: + fstpl 4(%esp) + fstpl 4(%esp) + fld1l + ret diff --git a/1/newlibc/mlinux/fabs.s b/1/newlibc/mlinux/fabs.s new file mode 100755 index 0000000..312c1d3 --- /dev/null +++ b/1/newlibc/mlinux/fabs.s @@ -0,0 +1,14 @@ +// +// This file is part of the math library for Linux and is +// covered by the GNU General Public license version 2, or +// any later version. +// +// Copyright 1992 by H.J. Lu +// + .text + .align 2 + .globl _fabs +_fabs: + fldl 4(%esp) + fabs + ret diff --git a/1/newlibc/mlinux/floor.s b/1/newlibc/mlinux/floor.s new file mode 100755 index 0000000..988c00f --- /dev/null +++ b/1/newlibc/mlinux/floor.s @@ -0,0 +1,38 @@ +/* This is file FLOOR.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .text + .align 2 + .globl _floor +_floor: + pushl %ebp + movl %esp,%ebp + sub $8,%esp /* -4 = old CW, -2 = new CW */ + + fstcw -4(%ebp) + fwait + movw -4(%ebp),%ax + andw $0xf3ff,%ax + orw $0x0400,%ax + movw %ax,-2(%ebp) + fldcww -2(%ebp) + + fldl 8(%ebp) + frndint + + fldcww -4(%ebp) + + movl %ebp,%esp + popl %ebp + ret diff --git a/1/newlibc/mlinux/fmod.s b/1/newlibc/mlinux/fmod.s new file mode 100755 index 0000000..aba16d2 --- /dev/null +++ b/1/newlibc/mlinux/fmod.s @@ -0,0 +1,36 @@ +/* This is file FMOD.S */ +/* +** Copyright (C) 1991 O. ROBERT, 24, Avenue de Verdun, 92170 VANVES, FRANCE +** +** Internet: roberto@germinal.ibp.fr +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + .text + .globl _fmod + .align 2 +_fmod: + fldl 4(%esp) + fldl 12(%esp) + ftst + fnstsw %ax + fxch %st(1) + sahf + jnz next + fstpl %st(0) + jmp out +next: + fpreml + fnstsw %ax + sahf + jpe next + fstpl %st(1) +out: + ret diff --git a/1/newlibc/mlinux/frexp.c b/1/newlibc/mlinux/frexp.c new file mode 100755 index 0000000..d833426 --- /dev/null +++ b/1/newlibc/mlinux/frexp.c @@ -0,0 +1,17 @@ +#include + +/* Stores binary exponent of d in e, and returns whole fraction of d + * (with binary exponent of 0) (special case for d=0) + */ +double frexp(double d, int *e) +{ + struct bitdouble *dp = (struct bitdouble *)&d; + + if (dp->exp == 0) /* value is zero, return exponent of 0 */ + *e = 0; + else { + *e = dp->exp - BIAS + 1; + dp->exp = BIAS - 1; + } + return d; +} diff --git a/1/newlibc/mlinux/hypot.s b/1/newlibc/mlinux/hypot.s new file mode 100755 index 0000000..6f67ccd --- /dev/null +++ b/1/newlibc/mlinux/hypot.s @@ -0,0 +1,23 @@ +// +// This file is part of the alternative 80386 math library and is +// covered by the GNU General Public license with my modification +// as noted in the README file that accompanied this file. +// +// Copyright 1990 G. Geers +// +// Modified by H.J. Lu for Linux 1992 +// + + .file "hypot.s" + + .text + .align 2 + .globl _hypot +_hypot: + fldl 4(%esp) + fmull 4(%esp) + fldl 12(%esp) + fmull 12(%esp) + faddp + fsqrt + ret diff --git a/1/newlibc/mlinux/j0.c b/1/newlibc/mlinux/j0.c new file mode 100755 index 0000000..159b8a7 --- /dev/null +++ b/1/newlibc/mlinux/j0.c @@ -0,0 +1,208 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)j0.c 5.3 (Berkeley) 9/22/88"; +#endif /* not lint */ + +/* + floating point Bessel's function + of the first and second kinds + of order zero + + j0(x) returns the value of J0(x) + for all real values of x. + + There are no error returns. + Calls sin, cos, sqrt. + + There is a niggling bug in J0 which + causes errors up to 2e-16 for x in the + interval [-8,8]. + The bug is caused by an inappropriate order + of summation of the series. rhm will fix it + someday. + + Coefficients are from Hart & Cheney. + #5849 (19.22D) + #6549 (19.25D) + #6949 (19.41D) + + y0(x) returns the value of Y0(x) + for positive real values of x. + For x<=0, if on the VAX, error number EDOM is set and + the reserved operand fault is generated; + otherwise (an IEEE machine) an invalid operation is performed. + + Calls sin, cos, sqrt, log, j0. + + The values of Y0 have not been checked + to more than ten places. + + Coefficients are from Hart & Cheney. + #6245 (18.78D) + #6549 (19.25D) + #6949 (19.41D) +*/ + +#include + +#if defined(vax)||defined(tahoe) +#include +#else /* defined(vax)||defined(tahoe) */ +static const double zero = 0.e0; +#endif /* defined(vax)||defined(tahoe) */ + +static double pzero, qzero; + +static const double tpi = .6366197723675813430755350535e0; +static const double pio4 = .7853981633974483096156608458e0; +static const double p1[] = { + 0.4933787251794133561816813446e21, + -.1179157629107610536038440800e21, + 0.6382059341072356562289432465e19, + -.1367620353088171386865416609e18, + 0.1434354939140344111664316553e16, + -.8085222034853793871199468171e13, + 0.2507158285536881945555156435e11, + -.4050412371833132706360663322e8, + 0.2685786856980014981415848441e5, +}; +static const double q1[] = { + 0.4933787251794133562113278438e21, + 0.5428918384092285160200195092e19, + 0.3024635616709462698627330784e17, + 0.1127756739679798507056031594e15, + 0.3123043114941213172572469442e12, + 0.6699987672982239671814028660e9, + 0.1114636098462985378182402543e7, + 0.1363063652328970604442810507e4, + 1.0 +}; +static const double p2[] = { + 0.5393485083869438325262122897e7, + 0.1233238476817638145232406055e8, + 0.8413041456550439208464315611e7, + 0.2016135283049983642487182349e7, + 0.1539826532623911470917825993e6, + 0.2485271928957404011288128951e4, + 0.0, +}; +static const double q2[] = { + 0.5393485083869438325560444960e7, + 0.1233831022786324960844856182e8, + 0.8426449050629797331554404810e7, + 0.2025066801570134013891035236e7, + 0.1560017276940030940592769933e6, + 0.2615700736920839685159081813e4, + 1.0, +}; +static const double p3[] = { + -.3984617357595222463506790588e4, + -.1038141698748464093880530341e5, + -.8239066313485606568803548860e4, + -.2365956170779108192723612816e4, + -.2262630641933704113967255053e3, + -.4887199395841261531199129300e1, + 0.0, +}; +static const double q3[] = { + 0.2550155108860942382983170882e6, + 0.6667454239319826986004038103e6, + 0.5332913634216897168722255057e6, + 0.1560213206679291652539287109e6, + 0.1570489191515395519392882766e5, + 0.4087714673983499223402830260e3, + 1.0, +}; +static const double p4[] = { + -.2750286678629109583701933175e20, + 0.6587473275719554925999402049e20, + -.5247065581112764941297350814e19, + 0.1375624316399344078571335453e18, + -.1648605817185729473122082537e16, + 0.1025520859686394284509167421e14, + -.3436371222979040378171030138e11, + 0.5915213465686889654273830069e8, + -.4137035497933148554125235152e5, +}; +static const double q4[] = { + 0.3726458838986165881989980e21, + 0.4192417043410839973904769661e19, + 0.2392883043499781857439356652e17, + 0.9162038034075185262489147968e14, + 0.2613065755041081249568482092e12, + 0.5795122640700729537480087915e9, + 0.1001702641288906265666651753e7, + 0.1282452772478993804176329391e4, + 1.0, +}; + +static void asympt(double); + +double +j0(double arg) +{ + double argsq, n, d; + int i; + + if(arg < 0.) arg = -arg; + if(arg > 8.){ + asympt(arg); + n = arg - pio4; + return(sqrt(tpi/arg)*(pzero*cos(n) - qzero*sin(n))); + } + argsq = arg*arg; + for(n=0,d=0,i=8;i>=0;i--){ + n = n*argsq + p1[i]; + d = d*argsq + q1[i]; + } + return(n/d); +} + +double +y0(double arg) +{ + double argsq, n, d; + int i; + + if(arg <= 0.){ +#if defined(vax)||defined(tahoe) + return(infnan(EDOM)); /* NaN */ +#else /* defined(vax)||defined(tahoe) */ + return(zero/zero); /* IEEE machines: invalid operation */ +#endif /* defined(vax)||defined(tahoe) */ + } + if(arg > 8.){ + asympt(arg); + n = arg - pio4; + return(sqrt(tpi/arg)*(pzero*sin(n) + qzero*cos(n))); + } + argsq = arg*arg; + for(n=0,d=0,i=8;i>=0;i--){ + n = n*argsq + p4[i]; + d = d*argsq + q4[i]; + } + return(n/d + tpi*j0(arg)*log(arg)); +} + +static void +asympt(double arg) +{ + double zsq, n, d; + int i; + zsq = 64./(arg*arg); + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p2[i]; + d = d*zsq + q2[i]; + } + pzero = n/d; + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p3[i]; + d = d*zsq + q3[i]; + } + qzero = (8./arg)*(n/d); +} diff --git a/1/newlibc/mlinux/j1.c b/1/newlibc/mlinux/j1.c new file mode 100755 index 0000000..8ca1042 --- /dev/null +++ b/1/newlibc/mlinux/j1.c @@ -0,0 +1,214 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)j1.c 5.3 (Berkeley) 9/22/88"; +#endif /* not lint */ + +/* + floating point Bessel's function + of the first and second kinds + of order one + + j1(x) returns the value of J1(x) + for all real values of x. + + There are no error returns. + Calls sin, cos, sqrt. + + There is a niggling bug in J1 which + causes errors up to 2e-16 for x in the + interval [-8,8]. + The bug is caused by an inappropriate order + of summation of the series. rhm will fix it + someday. + + Coefficients are from Hart & Cheney. + #6050 (20.98D) + #6750 (19.19D) + #7150 (19.35D) + + y1(x) returns the value of Y1(x) + for positive real values of x. + For x<=0, if on the VAX, error number EDOM is set and + the reserved operand fault is generated; + otherwise (an IEEE machine) an invalid operation is performed. + + Calls sin, cos, sqrt, log, j1. + + The values of Y1 have not been checked + to more than ten places. + + Coefficients are from Hart & Cheney. + #6447 (22.18D) + #6750 (19.19D) + #7150 (19.35D) +*/ + +#include + +#if defined(vax)||defined(tahoe) +#include +#else /* defined(vax)||defined(tahoe) */ +static const double zero = 0.e0; +#endif /* defined(vax)||defined(tahoe) */ + +static double pzero, qzero; + +static const double tpi = .6366197723675813430755350535e0; +static const double pio4 = .7853981633974483096156608458e0; +static const double p1[] = { + 0.581199354001606143928050809e21, + -.6672106568924916298020941484e20, + 0.2316433580634002297931815435e19, + -.3588817569910106050743641413e17, + 0.2908795263834775409737601689e15, + -.1322983480332126453125473247e13, + 0.3413234182301700539091292655e10, + -.4695753530642995859767162166e7, + 0.2701122710892323414856790990e4, +}; +static const double q1[] = { + 0.1162398708003212287858529400e22, + 0.1185770712190320999837113348e20, + 0.6092061398917521746105196863e17, + 0.2081661221307607351240184229e15, + 0.5243710262167649715406728642e12, + 0.1013863514358673989967045588e10, + 0.1501793594998585505921097578e7, + 0.1606931573481487801970916749e4, + 1.0, +}; +static const double p2[] = { + -.4435757816794127857114720794e7, + -.9942246505077641195658377899e7, + -.6603373248364939109255245434e7, + -.1523529351181137383255105722e7, + -.1098240554345934672737413139e6, + -.1611616644324610116477412898e4, + 0.0, +}; +static const double q2[] = { + -.4435757816794127856828016962e7, + -.9934124389934585658967556309e7, + -.6585339479723087072826915069e7, + -.1511809506634160881644546358e7, + -.1072638599110382011903063867e6, + -.1455009440190496182453565068e4, + 1.0, +}; +static const double p3[] = { + 0.3322091340985722351859704442e5, + 0.8514516067533570196555001171e5, + 0.6617883658127083517939992166e5, + 0.1849426287322386679652009819e5, + 0.1706375429020768002061283546e4, + 0.3526513384663603218592175580e2, + 0.0, +}; +static const double q3[] = { + 0.7087128194102874357377502472e6, + 0.1819458042243997298924553839e7, + 0.1419460669603720892855755253e7, + 0.4002944358226697511708610813e6, + 0.3789022974577220264142952256e5, + 0.8638367769604990967475517183e3, + 1.0, +}; +static const double p4[] = { + -.9963753424306922225996744354e23, + 0.2655473831434854326894248968e23, + -.1212297555414509577913561535e22, + 0.2193107339917797592111427556e20, + -.1965887462722140658820322248e18, + 0.9569930239921683481121552788e15, + -.2580681702194450950541426399e13, + 0.3639488548124002058278999428e10, + -.2108847540133123652824139923e7, + 0.0, +}; +static const double q4[] = { + 0.5082067366941243245314424152e24, + 0.5435310377188854170800653097e22, + 0.2954987935897148674290758119e20, + 0.1082258259408819552553850180e18, + 0.2976632125647276729292742282e15, + 0.6465340881265275571961681500e12, + 0.1128686837169442121732366891e10, + 0.1563282754899580604737366452e7, + 0.1612361029677000859332072312e4, + 1.0, +}; + +static void asympt(double); + +double +j1(double arg) +{ + double xsq, n, d, x; + int i; + + x = arg; + if(x < 0.) x = -x; + if(x > 8.){ + asympt(x); + n = x - 3.*pio4; + n = sqrt(tpi/x)*(pzero*cos(n) - qzero*sin(n)); + if(arg <0.) n = -n; + return(n); + } + xsq = x*x; + for(n=0,d=0,i=8;i>=0;i--){ + n = n*xsq + p1[i]; + d = d*xsq + q1[i]; + } + return(arg*n/d); +} + +double +y1(double arg) +{ + double xsq, n, d, x; + int i; + + x = arg; + if(x <= 0.){ +#if defined(vax)||defined(tahoe) + return(infnan(EDOM)); /* NaN */ +#else /* defined(vax)||defined(tahoe) */ + return(zero/zero); /* IEEE machines: invalid operation */ +#endif /* defined(vax)||defined(tahoe) */ + } + if(x > 8.){ + asympt(x); + n = x - 3*pio4; + return(sqrt(tpi/x)*(pzero*sin(n) + qzero*cos(n))); + } + xsq = x*x; + for(n=0,d=0,i=9;i>=0;i--){ + n = n*xsq + p4[i]; + d = d*xsq + q4[i]; + } + return(x*n/d + tpi*(j1(x)*log(x)-1./x)); +} + +static void +asympt(double arg) +{ + double zsq, n, d; + int i; + zsq = 64./(arg*arg); + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p2[i]; + d = d*zsq + q2[i]; + } + pzero = n/d; + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p3[i]; + d = d*zsq + q3[i]; + } + qzero = (8./arg)*(n/d); +} diff --git a/1/newlibc/mlinux/jn.c b/1/newlibc/mlinux/jn.c new file mode 100755 index 0000000..aa5597a --- /dev/null +++ b/1/newlibc/mlinux/jn.c @@ -0,0 +1,122 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)jn.c 5.3 (Berkeley) 9/22/88"; +#endif /* not lint */ + +/* + floating point Bessel's function of + the first and second kinds and of + integer order. + + int n; + double x; + jn(n,x); + + returns the value of Jn(x) for all + integer values of n and all real values + of x. + + There are no error returns. + Calls j0, j1. + + For n=0, j0(x) is called, + for n=1, j1(x) is called, + for nx, a continued fraction approximation to + j(n,x)/j(n-1,x) is evaluated and then backward + recursion is used starting from a supposed value + for j(n,x). The resulting value of j(0,x) is + compared with the actual value to correct the + supposed value of j(n,x). + + yn(n,x) is similar in all respects, except + that forward recursion is used for all + values of n>1. +*/ + +#include +#if defined(vax)||defined(tahoe) +#include +#else /* defined(vax)||defined(tahoe) */ +static double zero = 0.e0; +#endif /* defined(vax)||defined(tahoe) */ + +double +jn(int n, double x) +{ + int i; + double a, b, temp; + double xsq, t; + + if(n<0){ + n = -n; + x = -x; + } + if(n==0) return(j0(x)); + if(n==1) return(j1(x)); + if(x == 0.) return(0.); + if(n>x) goto recurs; + + a = j0(x); + b = j1(x); + for(i=1;in;i--){ + t = xsq/(2.*i - t); + } + t = x/(2.*n-t); + + a = t; + b = 1; + for(i=n-1;i>0;i--){ + temp = b; + b = (2.*i/x)*b - a; + a = temp; + } + return(t*j0(x)/b); +} + +double +yn(int n, double x) +{ + int i; + int sign; + double a, b, temp; + + if (x <= 0.0) { +#if defined(vax)||defined(tahoe) + return(infnan(EDOM)); /* NaN */ +#else /* defined(vax)||defined(tahoe) */ + return(zero/zero); /* IEEE machines: invalid operation */ +#endif /* defined(vax)||defined(tahoe) */ + } + sign = 1; + if(n<0){ + n = -n; + if(n%2 == 1) sign = -1; + } + if(n==0) return(y0(x)); + if(n==1) return(sign*y1(x)); + + a = y0(x); + b = y1(x); + for(i=1;i + +#if defined(vax)||defined(tahoe) +#include +#endif /* defined(vax)||defined(tahoe) */ + +int signgam = 0; +static const double goobie = 0.9189385332046727417803297; /* log(2*pi)/2 */ +static const double pi = 3.1415926535897932384626434; + +#define M 6 +#define N 8 +static const double p1[] = { + 0.83333333333333101837e-1, + -.277777777735865004e-2, + 0.793650576493454e-3, + -.5951896861197e-3, + 0.83645878922e-3, + -.1633436431e-2, +}; +static const double p2[] = { + -.42353689509744089647e5, + -.20886861789269887364e5, + -.87627102978521489560e4, + -.20085274013072791214e4, + -.43933044406002567613e3, + -.50108693752970953015e2, + -.67449507245925289918e1, + 0.0, +}; +static const double q2[] = { + -.42353689509744090010e5, + -.29803853309256649932e4, + 0.99403074150827709015e4, + -.15286072737795220248e4, + -.49902852662143904834e3, + 0.18949823415702801641e3, + -.23081551524580124562e2, + 0.10000000000000000000e1, +}; + +static double pos(double), neg(double), asym(double); + +double +lgamma(double arg) +{ + + signgam = 1.; + if(arg <= 0.) return(neg(arg)); + if(arg > 8.) return(asym(arg)); + return(log(pos(arg))); +} + +static double +asym(double arg) +{ + double n, argsq; + int i; + + argsq = 1./(arg*arg); + for(n=0,i=M-1; i>=0; i--){ + n = n*argsq + p1[i]; + } + return((arg-.5)*log(arg) - arg + goobie + n/arg); +} + +static double +neg(double arg) +{ + double t; + + arg = -arg; + /* + * to see if arg were a true integer, the old code used the + * mathematically correct observation: + * sin(n*pi) = 0 <=> n is an integer. + * but in finite precision arithmetic, sin(n*PI) will NEVER + * be zero simply because n*PI is a rational number. hence + * it failed to work with our newer, more accurate sin() + * which uses true pi to do the argument reduction... + * temp = sin(pi*arg); + */ + t = floor(arg); + if (arg - t > 0.5e0) + t += 1.e0; /* t := integer nearest arg */ +#if defined(vax)||defined(tahoe) + if (arg == t) { + return(infnan(ERANGE)); /* +INF */ + } +#endif /* defined(vax)||defined(tahoe) */ + signgam = (int) (t - 2*floor(t/2)); /* signgam = 1 if t was odd, */ + /* 0 if t was even */ + signgam = signgam - 1 + signgam; /* signgam = 1 if t was odd, */ + /* -1 if t was even */ + t = arg - t; /* -0.5 <= t <= 0.5 */ + if (t < 0.e0) { + t = -t; + signgam = -signgam; + } + return(-log(arg*pos(arg)*sin(pi*t)/pi)); +} + +static double +pos(double arg) +{ + double n, d, s; + register i; + + if(arg < 2.) return(pos(arg+1.)/arg); + if(arg > 3.) return((arg-1.)*pos(arg-1.)); + + s = arg - 2.; + for(n=0,d=0,i=N-1; i>=0; i--){ + n = n*s + p2[i]; + d = d*s + q2[i]; + } + return(n/d); +} diff --git a/1/newlibc/mlinux/log.s b/1/newlibc/mlinux/log.s new file mode 100755 index 0000000..ea2dcc0 --- /dev/null +++ b/1/newlibc/mlinux/log.s @@ -0,0 +1,20 @@ +/* This is file LOG.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .globl _log +_log: + fldln2 + fldl 4(%esp) + fyl2x + ret diff --git a/1/newlibc/mlinux/log10.s b/1/newlibc/mlinux/log10.s new file mode 100755 index 0000000..2e889be --- /dev/null +++ b/1/newlibc/mlinux/log10.s @@ -0,0 +1,20 @@ +/* This is file LOG10.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .globl _log10 +_log10: + fldlg2 + fldl 4(%esp) + fyl2x + ret diff --git a/1/newlibc/mlinux/math.h b/1/newlibc/mlinux/math.h new file mode 100755 index 0000000..4cf23d1 --- /dev/null +++ b/1/newlibc/mlinux/math.h @@ -0,0 +1,47 @@ +/* The header contains prototypes for mathematical functions. */ + +#ifndef _MATH_H +#define _MATH_H + +#define HUGE_VAL 9.9e+307 + +extern double acos(double x); +extern double asin(double x); +extern double atan(double x); +extern double atan2(double y, double x); +extern double ceil(double x); +extern double cos(double x); +extern double cosh(double x); +extern double exp(double x); +extern double fabs(double x); +extern double floor(double x); +extern double fmod(double x, double y); +extern double frexp(double x, int *exp); +extern double ldexp(double x, int exp); +extern double log(double x); +extern double log10(double x); +extern double modf(double x, double *iptr); +extern double pow(double x, double y); +extern double sin(double x); +extern double sinh(double x); +extern double sqrt(double x); +extern double tan(double x); +extern double tanh(double x); + +extern int isinf (double); +extern int isnan (double); +extern double erf (double x); +extern double erfc (double x); +extern double j0 (double x); +extern double j1 (double x); +extern double jn (int n, double x); +extern double lgamma (double x); +extern double y0 (double x); +extern double y1 (double x); +extern double yn (int n, double x); + +#ifndef __LIBRARY__ +extern int signgam; +#endif + +#endif /* _MATH_H */ diff --git a/1/newlibc/mlinux/sin.s b/1/newlibc/mlinux/sin.s new file mode 100755 index 0000000..800791f --- /dev/null +++ b/1/newlibc/mlinux/sin.s @@ -0,0 +1,32 @@ +// +// This file is part of the math library for Linux and is +// covered by the GNU General Public license version 2, or +// any later version. +// +// Copyright 1992 by H.J. Lu +// + .file "sin.s" + .text + .align 2 + .globl _sin +_sin: + fldl 4(%esp) + jmp L3 +L1: + fldpi + fld %st(0) + faddp %st,%st(1) + fxch %st(1) +L2: + fprem1 + fstsw %ax + sahf + jp L2 + fxch %st(1) + fstp %st(0) +L3: + fsin + fstsw %ax + sahf + jp L1 + ret diff --git a/1/newlibc/mlinux/sinh.s b/1/newlibc/mlinux/sinh.s new file mode 100755 index 0000000..3d13915 --- /dev/null +++ b/1/newlibc/mlinux/sinh.s @@ -0,0 +1,50 @@ +// +// This file is part of the math library for Linux and is +// covered by the GNU General Public license version 2, or +// any later version. +// +// Copyright 1992 by H.J. Lu +// + .file "sinh.s" + .data + .align 2 +LCW1: + .word 0 +LCW2: + .word 0 + + .text + .align 2 +LC2: + .double 0d5.0000000000000000000000e-01 + + .align 2 + .globl _sinh +_sinh: + fldl 4(%esp) + fldl2e + fmulp %st,%st(1) + fst %st(1) + fstcw LCW1 + fstcw LCW2 + fwait + andw $0xf3ff,LCW1 + fldcw LCW1 + frndint + fldcw LCW2 + fst %st(2) + fsubrp %st,%st(1) + f2xm1 + fld1 + faddp %st,%st(1) + fscale + fst %st(1) + + fld1 + fdivp %st,%st(1) + fsubrp %st,%st(1) + + fldl LC2 + fmulp %st,%st(1) + + ret diff --git a/1/newlibc/mlinux/sqrt.s b/1/newlibc/mlinux/sqrt.s new file mode 100755 index 0000000..73b1137 --- /dev/null +++ b/1/newlibc/mlinux/sqrt.s @@ -0,0 +1,19 @@ +/* This is file SQRT.S */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + + .globl _sqrt +_sqrt: + fldl 4(%esp) + fsqrt + ret diff --git a/1/newlibc/mlinux/tan.s b/1/newlibc/mlinux/tan.s new file mode 100755 index 0000000..cadc762 --- /dev/null +++ b/1/newlibc/mlinux/tan.s @@ -0,0 +1,31 @@ +// +// This file is part of the math library for Linux and is +// covered by the GNU General Public license version 2, or +// any later version. +// +// Copyright 1992 by H.J. Lu +// + .file "tan.s" + .text + .align 2 + .globl _tan +_tan: + fldl 4(%esp) + jmp L3 +L1: + fldpi + fxch %st(1) +L2: + fprem1 + fstsw %ax + sahf + jp L2 + fxch %st(1) + fstp %st(0) +L3: + fptan + fstsw %ax + sahf + jp L1 + fstp %st(0) + ret diff --git a/1/newlibc/mlinux/tanh.s b/1/newlibc/mlinux/tanh.s new file mode 100755 index 0000000..a0b7cf5 --- /dev/null +++ b/1/newlibc/mlinux/tanh.s @@ -0,0 +1,63 @@ +// +// This file is part of the math library for Linux and is +// covered by the GNU General Public license version 2, or +// any later version. +// +// Copyright 1992 by H.J. Lu +// + .file "tanh.s" + .data + .align 2 +LCW1: + .word 0 +LCW2: + .word 0 + + .text + .align 2 + .globl _tanh +_tanh: + fldl 4(%esp) + ftst + fstsw %ax + sahf + jna Lneg + fchs + xorl %eax,%eax + incl %eax + jmp L1 +Lneg: + xorl %eax,%eax +L1: + fld %st(0) + faddp %st,%st(1) + fldl2e + fmulp %st,%st(1) + fst %st(1) + fstcw LCW1 + fstcw LCW2 + fwait + andw $0xf3ff,LCW1 + fldcw LCW1 + frndint + fldcw LCW2 + fst %st(2) + fsubrp %st,%st(1) + f2xm1 + fld1 + faddp %st,%st(1) + fscale + fst %st(1) + + fld1 + faddp %st,%st(1) + fxch %st(1) + fld1 + fsubrp %st,%st(1) + fdivp %st,%st(1) + + testl %eax,%eax + jna L2 + fchs +L2: + ret diff --git a/1/newlibc/other/._Makefile b/1/newlibc/other/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/other/._getcwd.c b/1/newlibc/other/._getcwd.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/other/._getopt.c b/1/newlibc/other/._getopt.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/other/._mktemp.c b/1/newlibc/other/._mktemp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/other/._popen.c b/1/newlibc/other/._popen.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/other/._setjmp.s b/1/newlibc/other/._setjmp.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/other/._sig_restore.s b/1/newlibc/other/._sig_restore.s new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/other/Makefile b/1/newlibc/other/Makefile new file mode 100755 index 0000000..8fdbcb5 --- /dev/null +++ b/1/newlibc/other/Makefile @@ -0,0 +1,47 @@ +# +# Makefile for some odd library functions +# + +LIB =../Libc.a +#AR =gar +AR =ar +#AS =gas +AS =as +#LD =gld +LD =ld +LDFLAGS =-s -x +CC =gcc +INC =-nostdinc -I/../include +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions $(INC) -DUSG -DSTDC_HEADERS +CPP =$(CC) -E $(INC) + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(CC) -c -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = sig_restore.o setjmp.o getcwd.o mktemp.o \ + popen.o getopt.o + +all: library + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/other/getcwd.c b/1/newlibc/other/getcwd.c new file mode 100755 index 0000000..e3894c2 --- /dev/null +++ b/1/newlibc/other/getcwd.c @@ -0,0 +1,163 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define d_namlen d_reclen +#define d_fileno d_ino + +/* Get the pathname of the current working directory, + and put it in SIZE bytes of BUF. Returns NULL if the + directory couldn't be determined or SIZE was too small. + If successful, returns BUF. In GNU, if BUF is NULL, + an array is allocated with `malloc'; the array is SIZE + bytes long, unless SIZE <= 0, in which case it is as + big as necessary. */ +char * +DEFUN(getcwd, (buf, size), char *buf AND size_t size) +{ + dev_t rootdev, thisdev; + ino_t rootino, thisino; + char path[PATH_MAX + 1]; + register char *pathp; + struct stat st; + + if (buf != NULL && size == 0) + { + errno = EINVAL; + return NULL; + } + + pathp = &path[sizeof(path)]; + *--pathp = '\0'; + + if (stat(".", &st) < 0) + return NULL; + thisdev = st.st_dev; + thisino = st.st_ino; + + if (stat("/", &st) < 0) + return NULL; + rootdev = st.st_dev; + rootino = st.st_ino; + + while (!(thisdev == rootdev && thisino == rootino)) + { + register DIR *dirstream; + register struct dirent *d; + dev_t dotdev; + ino_t dotino; + char mount_point; + + /* Move up a directory. */ + if (chdir("..") < 0) + { + if (pathp != &path[sizeof(path) - 1]) + { + /* Try to get back to the original directory. + This is the only place where this is possible. */ + int save = errno; + (void) chdir (pathp); + errno = save; + } + return NULL; + } + + /* Figure out if this directory is a mount point. */ + if (stat(".", &st) < 0) + return NULL; + dotdev = st.st_dev; + dotino = st.st_ino; + mount_point = dotdev != thisdev; + + /* Search for the last directory. */ + dirstream = opendir("."); + if (dirstream == NULL) + return NULL; + while ((d = readdir(dirstream)) != NULL) + { + if (d->d_name[0] == '.' && + (d->d_namlen == 1 || (d->d_namlen == 2 && d->d_name[1] == '.'))) + continue; + if (mount_point || d->d_fileno == thisino) + { + if (stat(d->d_name, &st) < 0) + { + int save = errno; + (void) closedir(dirstream); + errno = save; + return NULL; + } + if (st.st_dev == thisdev && st.st_ino == thisino) + break; + } + } + if (d == NULL) + { + int save = errno; + (void) closedir(dirstream); + errno = save; + return NULL; + } + else + { + pathp -= d->d_namlen; + (void) memcpy(pathp, d->d_name, d->d_namlen); + *--pathp = '/'; + (void) closedir(dirstream); + } + + thisdev = dotdev; + thisino = dotino; + } + + if (pathp == &path[sizeof(path) - 1]) + *--pathp = '/'; + + if (chdir(pathp) < 0) + return NULL; + + { + size_t len = &path[sizeof(path)] - pathp; + if (buf == NULL) + { + if (len < (size_t) size) + len = size; + buf = (char *) malloc(len); + if (buf == NULL) + return NULL; + } + else if ((size_t) size < len) + { + errno = ERANGE; + return NULL; + } + (void) memcpy((PTR) buf, (PTR) pathp, len); + } + + return buf; +} diff --git a/1/newlibc/other/getopt.c b/1/newlibc/other/getopt.c new file mode 100755 index 0000000..5bc01c5 --- /dev/null +++ b/1/newlibc/other/getopt.c @@ -0,0 +1,431 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +/* This version of `getopt' appears to the caller like standard POSIX + `getopt' but it behaves differently for the user, since it allows + the user to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of ARGV so that, when it + is done, all the options precede everything else. Thus all application + programs are extended to handle flexible argument order. + + Setting the environment variable _POSIX_OPTION_ORDER disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include +#include +#include +#include +#include +#include + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg = NULL; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns -1, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +int optind = 1; + +static int initialized = 0; + +int optopt; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static CONST char *nextchar; + +/* Callers store zero here to inhibit the + error message for unrecognized options. */ + +int opterr = 1; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + UNSPECIFIED means the caller did not specify anything; + the default is then REQUIRE_ORDER if the environment variable + _POSIX_OPTION_ORDER is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options. + Stop option processing when the first non-option is seen. + This is what Unix does. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code zero. + Using `-' as the first character of the list of option characters + requests this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return -1 with `optind' != ARGC. */ + +static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering; + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ +static void +DEFUN(exchange, (argv), CONST char **argv) +{ + size_t nonopts_size = (last_nonopt - first_nonopt) * sizeof(char *); + char **temp = (char **) __alloca(nonopts_size); + + /* Interchange the two blocks of data in ARGV. */ + + memcpy(temp, &argv[first_nonopt], nonopts_size); + memcpy(&argv[first_nonopt], &argv[last_nonopt], nonopts_size); + memcpy(&argv[first_nonopt + optind - last_nonopt], temp, nonopts_size); + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + + +/* Scan elements of ARGV (whose length is ARGC) for + option characters given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option + characters from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns -1. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + A colon in OPTSTRING means that the previous character is an option + that wants an argument. The argument is taken from the rest of the + current ARGV-element, or from the following ARGV-element, + and returned in `optarg'. + + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message and setting `optopt' + to the option character. If you set `opterr' to zero, the error + message is suppressed but we still set `optopt' and return '?'. + + If a character in OPTSTRING is followed by a colon, that means + it wants an argument, so the following text inthe same + ARGV-element, or the text of the following ARGV-element, is + returned in `optarg'. Two colons mean an option that wants an + optional argument; if there is text in the current ARGV-element, + it is returned in `optarg'. + + If OPTSTRING starts with `-', it requests a different method of handling the + non-option ARGV-elements. See the comments about RETURN_IN_ORDER, above. + */ + +int +DEFUN(getopt, (argc, argv, optstring), + int argc AND CONST char **argv AND CONST char *optstring) +{ + /* Initialize the internal data when the first call is made. + Start processing options with ARGV-element 1 + (since ARGV-element 0 is the program name); + the sequence of previously skipped non-option + ARGV-elements is empty. */ + + if (!initialized) + { + first_nonopt = last_nonopt = optind = 1; + initialized = 1; + + nextchar = NULL; + + if (optstring[0] == ':') + { + ++optstring; + opterr = 0; + } + + /* Determine how to handle the ordering of options and nonoptions. */ + if (optstring[0] == '-') + ordering = RETURN_IN_ORDER; + else if (getenv("_POSIX_OPTION_ORDER") != NULL) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + + if (optstring[0] == ':') + { + ++optstring; + opterr = 0; + } + } + + if (nextchar == NULL || *nextchar == '\0') + { + if (ordering == PERMUTE) + { + /* If we have just processed some options + following some non-options, exchange them + so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange(argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Now skip any additional non-options and extend + the range of non-options previously skipped. */ + + while (optind < argc && + (argv[optind][0] != '-' || argv[optind][1] == '\0')) + ++optind; + last_nonopt = optind; + } + + /* Special ARGV-element `--' means premature end of options. + Skip it like a null option, then exchange with previous + non-options as if it were an option, then skip everything + else like a non-option. */ + + if (optind != argc && !strcmp(argv[optind], "--")) + { + ++optind; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange(argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, + stop the scan and back over any non-options + that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the + non-options that we previously skipped, + so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return -1; + } + + /* If we have come to a non-option and did + not permute it, either stop the scan or + describe it to the caller and pass it by. */ + + if (argv[optind][0] != '-' || argv[optind][1] == 0) + if (ordering == REQUIRE_ORDER) + return -1; + else + { + optarg = (char *) argv[optind++]; + return 0; + } + + /* We have found another option-ARGV-element. + Start decoding its characters. */ + + nextchar = argv[optind] + 1; + } + + /* Look at and handle the next option-character. */ + + { + char c = *nextchar++; + char *temp = strchr(optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == '\0') + ++optind; + + if (temp == NULL) + { + if (opterr) + { + if (!isprint(c)) + fprintf(stderr, + "%s: unrecognized option, character code %#.3o octal\n", + argv[0], (unsigned int) c); + else + fprintf(stderr, "%s: unrecognized option `-%c'\n", + argv[0], c); + } + optopt = c; + return '?'; + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an optional argument. */ + if (*nextchar != '\0') + optarg = (char *) nextchar; + else + optarg = NULL; + nextchar = NULL; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != '\0') + { + optarg = (char *) nextchar; + /* If we end this ARGV-element by taking the rest as an + argument, we must advance to the next element now. */ + ++optind; + nextchar = NULL; + } + else if (optind == argc) + { + if (opterr) + { + if (isprint(c)) + fprintf(stderr, "%s: no argument for `-%c' option\n", + argv[0], c); + else + fprintf(stderr, + "%s: no argument for option %#.3o octal\n", + argv[0], (unsigned int) c); + } + optopt = c; + optarg = NULL; + return '?'; + } + else + /* We already incremented `optind' once; increment it again + when taking the next ARGV-element as an argument. */ + optarg = (char *) argv[optind++]; + } + } + return c; + } +} + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use + in testing the above definition of `getopt'. */ + +int +DEFUN(main, (argc, argv), int argc AND char **argv) +{ + register int c; + int digit_optind = 0; + + for (;;) + { + int this_option_optind = optind; + if ((c = getopt(argc, argv, "abc:d:0123456789")) == -1) + break; + else + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind > 0 && digit_optind != this_option_optind) + puts("digits occur in two different ARGV-elements."); + digit_optind = this_option_optind; + printf("option %c\n", c); + break; + case 'a': + puts("option a"); + break; + case 'b': + puts("option b"); + break; + case 'c': + printf("option c with value `%s'\n", optarg); + break; + case '?': + break; + default: + printf("?? getopt returned character code %#.3o ??\n", c); + break; + } + } + + if (optind < argc) + { + fputs("non-option ARGV-elements: ", stdout); + while (optind < argc) + printf("%s ", argv[optind++]); + putchar('\n'); + } + + exit(0); + return 0; +} + +#endif /* TEST */ diff --git a/1/newlibc/other/mktemp.c b/1/newlibc/other/mktemp.c new file mode 100755 index 0000000..1d396d8 --- /dev/null +++ b/1/newlibc/other/mktemp.c @@ -0,0 +1,16 @@ +#include +#include + +char * mktemp(char * template) +{ + int pid; + int len; + + pid = getpid(); + len = strlen(template); + while (len-->0 && template[len] == 'X') { + template[len] = '0' + (pid % 10); + pid = pid / 10; + } + return(template); +} diff --git a/1/newlibc/other/popen.c b/1/newlibc/other/popen.c new file mode 100755 index 0000000..fc7fb1d --- /dev/null +++ b/1/newlibc/other/popen.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include + +static int pids[20]; + +FILE *popen(const char *command, const char *type) +{ + int piped[2]; + int Xtype = *type == 'r' ? 0 : *type == 'w' ? 1 : 2; + int pid; + + if (Xtype == 2 || pipe(piped) < 0) + return NULL; + if ((pid = fork()) < 0) { + close(piped[0]); + close(piped[1]); + return NULL; + } + + if (pid == 0) { + register int *p; + + for (p = pids; p < &pids[20]; p++) { + if (*p) close(p - pids); + } + close(piped[Xtype]); + dup2(piped[!Xtype], !Xtype); + close(piped[!Xtype]); + execl("/bin/sh", "sh", "-c", command, (char *) 0); + exit(-1); /* like system() ??? */ + } + pids[piped[Xtype]] = pid; + close(piped[!Xtype]); + return(fdopen(piped[Xtype], type)); +} + +int pclose(FILE * iop) +{ + int fd = fileno(iop); + int status, wret; + void (*intsave) () = signal(SIGINT, SIG_IGN); + void (*quitsave) () = signal(SIGQUIT, SIG_IGN); + void (*hupsave) () = signal(SIGHUP, SIG_IGN); + + fclose(iop); + while ((wret = wait(&status)) != -1) { + if (wret == pids[fd]) break; + } + if (wret == -1) status = -1; + signal(SIGINT, intsave); + signal(SIGQUIT, quitsave); + signal(SIGHUP, hupsave); + pids[fd] = 0; + return(status); +} diff --git a/1/newlibc/other/setjmp.s b/1/newlibc/other/setjmp.s new file mode 100755 index 0000000..7879e57 --- /dev/null +++ b/1/newlibc/other/setjmp.s @@ -0,0 +1,45 @@ +/* + * setjmp & longjmp for gcc. + * + * We need to save all regs except %eax,%ecx,%edx, as these are + * used by calls. + * + * Jump buffer looks like this (same as bruce evans for minix): + * + * 00: %ebp + * 04: %esp + * 08: %eip + * 0C: %ebx + * 10: %esi + * 14: %edi + * + * Total length hex 18 = 24 bytes. + */ + +.text +.globl _setjmp,_longjmp +.align 2 +_setjmp: + popl %ecx # get return address + movl 0(%esp),%edx # and jump buffer address + movl %ebp,0(%edx) + movl %esp,4(%edx) + movl %ecx,8(%edx) + movl %ebx,12(%edx) + movl %esi,16(%edx) + movl %edi,20(%edx) + xorl %eax,%eax # non-jump return + jmpl *%ecx + +.align 2 +_longjmp: + movl 4(%esp),%edx # jump buffer address + movl 8(%esp),%eax # val + cmpl $1,%eax # Value may not be zero (code by bruce?) + adcb $0,%al # nice code, somewhat cryptic, no? + movl 0(%edx),%ebp # restore %ebp + movl 4(%edx),%esp + movl 12(%edx),%ebx + movl 16(%edx),%esi + movl 20(%edx),%edi + jmp 8(%edx) diff --git a/1/newlibc/other/sig_restore.s b/1/newlibc/other/sig_restore.s new file mode 100755 index 0000000..ebda416 --- /dev/null +++ b/1/newlibc/other/sig_restore.s @@ -0,0 +1,20 @@ +.globl ____sig_restore +.globl ____masksig_restore + +____sig_restore: + addl $4,%esp # signr + popl %eax + popl %ecx + popl %edx + popfl + ret + +____masksig_restore: + addl $4,%esp # signr + call ____ssetmask # old blocking + addl $4,%esp + popl %eax + popl %ecx + popl %edx + popfl + ret diff --git a/1/newlibc/posix/._Makefile b/1/newlibc/posix/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/posix/._cfsetget.c b/1/newlibc/posix/._cfsetget.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/posix/._rename.c b/1/newlibc/posix/._rename.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/posix/._sigmask.c b/1/newlibc/posix/._sigmask.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/posix/._sleep.c b/1/newlibc/posix/._sleep.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/posix/._sysconf.c b/1/newlibc/posix/._sysconf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/posix/._tcattr.c b/1/newlibc/posix/._tcattr.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/posix/._tcflow.c b/1/newlibc/posix/._tcflow.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/posix/._tcsetpgrp.c b/1/newlibc/posix/._tcsetpgrp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/posix/._ttyname.c b/1/newlibc/posix/._ttyname.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/posix/Makefile b/1/newlibc/posix/Makefile new file mode 100755 index 0000000..de66aa4 --- /dev/null +++ b/1/newlibc/posix/Makefile @@ -0,0 +1,55 @@ +# +# Makefile for some ansi-library functions +# + +LIB =../Libc.a +#AR =gar +#AS =gas +#LD =gld +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =/usr/local/bin/gcc -B/usr/local/bin/ +#CC =/local/bin/gcc-i386-sysv -v -DPRE_GCC_2 +INC =-nostdinc -I. \ + -I../include +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions $(INC) +#CFLAGS =-Wall -O -fstrength-reduce -finline-functions $(INC) +CPP =$(CC) -E $(INC) + +.SUFFIXES: .C .c + +.c.C: + $(CPP) $(CFLAGS) -S -o $*.C $< + +.c.s: + $(CC) $(CFLAGS) -S -o $*.s $< + +.s.o: + $(CC) -c -o $*.o $< + +.c.o: + $(CC) $(CFLAGS) -c -o $*.o $< + +OBJS = sigmask.o tcattr.o sysconf.o sleep.o tcsetpgrp.o rename.o \ + ttyname.o cfsetget.o tcflow.o + +all: library + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/posix/cfsetget.c b/1/newlibc/posix/cfsetget.c new file mode 100755 index 0000000..cad59e9 --- /dev/null +++ b/1/newlibc/posix/cfsetget.c @@ -0,0 +1,26 @@ +#include + +speed_t cfgetospeed(struct termios *tp) +{ + return (tp->c_cflag & CBAUD); +} + +speed_t cfgetispeed(struct termios *tp) +{ + return (tp->c_cflag & CBAUD); +} + +int cfsetospeed(struct termios *tp, speed_t speed) +{ + if (speed < B0 || speed > B38400) + return 0; + tp->c_cflag &= ~CBAUD; + tp->c_cflag |= (speed & CBAUD); + + return 0; +} + +int cfsetispeed(struct termios *tp, speed_t speed) +{ + return cfsetospeed(tp, speed); +} diff --git a/1/newlibc/posix/rename.c b/1/newlibc/posix/rename.c new file mode 100755 index 0000000..a73d68c --- /dev/null +++ b/1/newlibc/posix/rename.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,rename,const char *,from,const char *,to) diff --git a/1/newlibc/posix/sigmask.c b/1/newlibc/posix/sigmask.c new file mode 100755 index 0000000..ac46800 --- /dev/null +++ b/1/newlibc/posix/sigmask.c @@ -0,0 +1,76 @@ +#include +#include +#include + +extern int ___sgetmask(); +extern int ___ssetmask(int); + +int raise(int sig) +{ + return kill(getpid(),sig); +} + +int sigaddset(sigset_t *mask, int signo) +{ + if (signo >= NSIG || signo <= 0) { + errno = EINVAL; + return -1; + } + *mask |= 1<<(signo-1); + return 1; +} + +int sigdelset(sigset_t *mask, int signo) +{ + if (signo >= NSIG || signo <= 0) { + errno = EINVAL; + return -1; + } + *mask &= ~(1<<(signo-1)); + return 1; +} + +int sigemptyset(sigset_t *mask) +{ + *mask = 0; + return 1; +} + +int sigfillset(sigset_t *mask) +{ + *mask = ~0; + return 1; +} + +int sigismember(sigset_t *mask, int signo) +{ + if (signo >= NSIG || signo <= 0) { + errno = EINVAL; + return -1; + } + return (*mask & (1<<(signo-1))) != 0; +} + +int sigprocmask(int how, sigset_t * set, sigset_t * oset) +{ + sigset_t old; + int rval = 0; + + old = ___sgetmask(); + + if (set) switch(how) { + case SIG_BLOCK: + rval = ___ssetmask((*set) | old); + break; + case SIG_UNBLOCK: + rval = ___ssetmask((~(*set)) & old); + break; + case SIG_SETMASK: + rval = ___ssetmask(*set); + break; + } + + if (oset) + *oset = old; + return rval; +} diff --git a/1/newlibc/posix/sleep.c b/1/newlibc/posix/sleep.c new file mode 100755 index 0000000..f7698e2 --- /dev/null +++ b/1/newlibc/posix/sleep.c @@ -0,0 +1,66 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + + +/* SIGALRM signal handler for `sleep'. This does nothing but return, + but SIG_IGN isn't supposed to break `pause'. */ +static void +DEFUN(sleep_handler, (sig), int sig) +{ + return; +} + +/* Make the process sleep for SECONDS seconds, or until a signal arrives + and is not ignored. The function returns the number of seconds less + than SECONDS which it actually slept (zero if it slept the full time). + If a signal handler does a `longjmp' or modifies the handling of the + SIGALRM signal while inside `sleep' call, the handling of the SIGALRM + signal afterwards is undefined. There is no return value to indicate + error, but if `sleep' returns SECONDS, it probably didn't work. */ +unsigned int +DEFUN(sleep, (seconds), unsigned int seconds) +{ + unsigned int remaining, slept; + void EXFUN((*handler), (int sig)); + time_t before, after; + + handler = signal(SIGALRM, sleep_handler); + if (handler == SIG_ERR) + return seconds; + + if (seconds == 0) + return 0; + before = time((time_t *) NULL); + remaining = alarm(seconds); + after = time((time_t *) NULL); + + (void) pause(); + + (void) signal(SIGALRM, handler); + + slept = (after - before) / 1000; + if (remaining > slept) + alarm(remaining - slept); + + return slept; +} diff --git a/1/newlibc/posix/sysconf.c b/1/newlibc/posix/sysconf.c new file mode 100755 index 0000000..5c114e6 --- /dev/null +++ b/1/newlibc/posix/sysconf.c @@ -0,0 +1,37 @@ +#include +#include +#include +#include + +long int sysconf(int name) +{ + switch(name) { + case _SC_ARG_MAX: + return (long) ARG_MAX; + + case _SC_CHILD_MAX: + return (long) CHILD_MAX; + + case _SC_CLOCKS_PER_SEC: + return (long) CLOCKS_PER_SEC; + + case _SC_NGROUPS_MAX: + return (long) NGROUPS_MAX; + + case _SC_OPEN_MAX: + return (long) OPEN_MAX; + + case _SC_JOB_CONTROL: + return -1L; /* no job control yet */ + + case _SC_SAVED_IDS: + return -1L; /* no saved uid/gid */ + + case _SC_VERSION: + return (long) _POSIX_VERSION; + + default: + errno = EINVAL; + return -1L; + } +} diff --git a/1/newlibc/posix/tcattr.c b/1/newlibc/posix/tcattr.c new file mode 100755 index 0000000..57cfce2 --- /dev/null +++ b/1/newlibc/posix/tcattr.c @@ -0,0 +1,34 @@ +#include +#include +#include + +speed_t cfgetispeed(struct termios *termios_p); +speed_t cfgetospeed(struct termios *termios_p); + +int cfsetispeed(struct termios *termios_p, speed_t speed); +int cfsetospeed(struct termios *termios_p, speed_t speed); + +int tcdrain(int fildes); +int tcflow(int fildes, int action); +int tcflush(int fildes, int queue_selector); +int tcsendbreak(int fildes, int duration); + +int tcgetattr(int fildes, struct termios *termios_p) +{ + return ioctl(fildes, TCGETS, termios_p); +} + +int tcsetattr(int fildes, int optional_actions, struct termios *termios_p) +{ + switch(optional_actions) { + case TCSANOW: + return ioctl(fildes, TCSETS, termios_p); + case TCSADRAIN: + return ioctl(fildes, TCSETSW, termios_p); + case TCSAFLUSH: + return ioctl(fildes, TCSETSF, termios_p); + default: + errno = EINVAL; + return -1; + } +} diff --git a/1/newlibc/posix/tcflow.c b/1/newlibc/posix/tcflow.c new file mode 100755 index 0000000..91d5811 --- /dev/null +++ b/1/newlibc/posix/tcflow.c @@ -0,0 +1,7 @@ +#include +#include + +int tcflow(int fd, int action) +{ + return(ioctl(fd,TCXONC,action)); +} diff --git a/1/newlibc/posix/tcsetpgrp.c b/1/newlibc/posix/tcsetpgrp.c new file mode 100755 index 0000000..9017bd6 --- /dev/null +++ b/1/newlibc/posix/tcsetpgrp.c @@ -0,0 +1,19 @@ +#include +#include +#include + +pid_t tcgetpgrp(int fildes) +{ + int tmp; + + if (ioctl(fildes,TIOCGPGRP,&tmp)<0) + return -1; + return tmp; +} + +int tcsetpgrp(int fildes, pid_t pgid) +{ + int tmp=pgid; + + return ioctl(fildes,TIOCSPGRP,&tmp); +} diff --git a/1/newlibc/posix/ttyname.c b/1/newlibc/posix/ttyname.c new file mode 100755 index 0000000..f9dbd1e --- /dev/null +++ b/1/newlibc/posix/ttyname.c @@ -0,0 +1,79 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define d_fileno d_ino +#define d_namlen d_reclen + +char *__ttyname = NULL; + +/* Return the pathname of the terminal FD is open on, or NULL on errors. + The returned storage is good only until the next call to this function. */ +char * +DEFUN(ttyname, (fd), int fd) +{ + static char dev[] = "/dev"; + char name[PATH_MAX]; + char *CONST np = &name[sizeof(dev)]; + struct stat st; + dev_t mydev; + ino_t myino; + DIR *dirstream; + struct dirent *d; + + if (fstat(fd, &st) < 0) + return NULL; + if (!S_ISCHR(st.st_mode)) + { + errno = EINVAL; + return NULL; + } + mydev = st.st_dev; + myino = st.st_ino; + + dirstream = opendir(dev); + if (dirstream == NULL) + return NULL; + + (void) memcpy(name, dev, sizeof(dev) - 1); + np[-1] = '/'; + while ((d = readdir(dirstream)) != NULL) + if (d->d_fileno == myino) + { + (void) memcpy(np, d->d_name, d->d_namlen + 1); + if (stat(name, &st) == 0 && st.st_dev == mydev) + { + static char result[PATH_MAX]; + (void) memcpy(result, name, (np - name) + d->d_namlen + 1); + (void) closedir(dirstream); + __ttyname = result; + return result; + } + } + (void) closedir(dirstream); + return NULL; +} diff --git a/1/newlibc/pwd/._Makefile b/1/newlibc/pwd/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/pwd/._fgetpwent.c b/1/newlibc/pwd/._fgetpwent.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/pwd/._getpw.c b/1/newlibc/pwd/._getpw.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/pwd/._getpwent.c b/1/newlibc/pwd/._getpwent.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/pwd/._getpwnam.c b/1/newlibc/pwd/._getpwnam.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/pwd/._getpwuid.c b/1/newlibc/pwd/._getpwuid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/pwd/._putpwent.c b/1/newlibc/pwd/._putpwent.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/pwd/._pwdopen.c b/1/newlibc/pwd/._pwdopen.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/pwd/._pwdread.c b/1/newlibc/pwd/._pwdread.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/pwd/Makefile b/1/newlibc/pwd/Makefile new file mode 100755 index 0000000..6c7f682 --- /dev/null +++ b/1/newlibc/pwd/Makefile @@ -0,0 +1,46 @@ +# +# Makefile for some ansi-library functions +# + +LIB =../Libc.a +AR =gar +AS =gas +LD =gld +LDFLAGS =-s -x +CC =gcc +#INC =-nostdinc -I/linux/usr/include +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions $(INC) +CPP =$(CC) -E $(INC) + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< + +.s.o: + $(CC) -c -o $*.o $< + +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = fgetpwent.o getpw.o getpwent.o getpwnam.o getpwuid.o \ + putpwent.o pwdopen.o pwdread.o + +all: library + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/pwd/fgetpwent.c b/1/newlibc/pwd/fgetpwent.c new file mode 100755 index 0000000..4a21cbb --- /dev/null +++ b/1/newlibc/pwd/fgetpwent.c @@ -0,0 +1,40 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include + +/* Read one entry from the given stream. */ +struct passwd * +DEFUN(fgetpwent, (stream), FILE *stream) +{ + static PTR info = NULL; + if (info == NULL) + { + info = __pwdalloc(); + if (info == NULL) + return(NULL); + } + + return(__pwdread(stream, info)); +} diff --git a/1/newlibc/pwd/getpw.c b/1/newlibc/pwd/getpw.c new file mode 100755 index 0000000..45fb271 --- /dev/null +++ b/1/newlibc/pwd/getpw.c @@ -0,0 +1,48 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + + +/* Re-construct the password-file line for the given uid + in the given buffer. This knows the format that the caller + will expect, but this need not be the format of the password file. */ +int +DEFUN(getpw, (uid, buf), int uid AND register char *buf) +{ + register struct passwd *p; + + if (uid < 0 || buf == NULL) + { + errno = EINVAL; + return(-1); + } + + p = getpwuid(uid); + if (p == NULL) + return(-1); + + if (sprintf(buf, "%s:%s:%d:%d:%s:%s:%s", p->pw_name, p->pw_passwd, + p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_dir, p->pw_shell) < 0) + return(-1); + + return(0); +} diff --git a/1/newlibc/pwd/getpwent.c b/1/newlibc/pwd/getpwent.c new file mode 100755 index 0000000..1c88950 --- /dev/null +++ b/1/newlibc/pwd/getpwent.c @@ -0,0 +1,67 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + +static FILE *stream = NULL; + +/* Rewind the stream. */ +void +DEFUN_VOID(setpwent) +{ + if (stream != NULL) + rewind(stream); +} + + +/* Close the stream. */ +void +DEFUN_VOID(endpwent) +{ + if (stream != NULL) + { + (void) fclose(stream); + stream = NULL; + } +} + + +/* Return one entry from the password file. */ +struct passwd * +DEFUN_VOID(getpwent) +{ + static PTR info = NULL; + if (info == NULL) + { + info = __pwdalloc(); + if (info == NULL) + return(NULL); + } + + if (stream == NULL) + { + stream = __pwdopen(); + if (stream == NULL) + return(NULL); + } + + return(__pwdread(stream, info)); +} diff --git a/1/newlibc/pwd/getpwnam.c b/1/newlibc/pwd/getpwnam.c new file mode 100755 index 0000000..1e7ea5c --- /dev/null +++ b/1/newlibc/pwd/getpwnam.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +/* Search for an entry with a matching name. */ +struct passwd * +DEFUN(getpwnam, (name), register CONST char *name) +{ + static PTR info = NULL; + register FILE *stream; + register struct passwd *p; + + if (info == NULL) + { + info = __pwdalloc(); + if (info == NULL) + return(NULL); + } + + stream = __pwdopen(); + if (stream == NULL) + return(NULL); + + while ((p = __pwdread(stream, info)) != NULL) + if (!strcmp(p->pw_name, name)) + break; + + (void) fclose(stream); + return(p); +} diff --git a/1/newlibc/pwd/getpwuid.c b/1/newlibc/pwd/getpwuid.c new file mode 100755 index 0000000..30e4032 --- /dev/null +++ b/1/newlibc/pwd/getpwuid.c @@ -0,0 +1,50 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include + +/* Search for an entry with a matching uid. */ +struct passwd * +DEFUN(getpwuid, (uid), register uid_t uid) +{ + static PTR info; + register FILE *stream; + register struct passwd *p; + + if (info == NULL) + { + info = __pwdalloc(); + if (info == NULL) + return(NULL); + } + + stream = __pwdopen(); + if (stream == NULL) + return(NULL); + + while ((p = __pwdread(stream, info)) != NULL) + if (p->pw_uid == uid) + break; + + (void) fclose(stream); + return(p); +} diff --git a/1/newlibc/pwd/putpwent.c b/1/newlibc/pwd/putpwent.c new file mode 100755 index 0000000..a2abd49 --- /dev/null +++ b/1/newlibc/pwd/putpwent.c @@ -0,0 +1,41 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include + + +/* Write an entry to the given stream. + This must know the format of the password file. */ +int +DEFUN(putpwent, (p, stream), register CONST struct passwd *p AND FILE *stream) +{ + if (p == NULL || stream == NULL) + { + errno = EINVAL; + return(-1); + } + + if (fprintf(stream, "%s:%s:%d:%d:%s:%s\n", p->pw_name, p->pw_passwd, + p->pw_uid, p->pw_gid, p->pw_gecos, p->pw_shell) < 0) + return(-1); + + return(0); +} diff --git a/1/newlibc/pwd/pwdopen.c b/1/newlibc/pwd/pwdopen.c new file mode 100755 index 0000000..6d35ab9 --- /dev/null +++ b/1/newlibc/pwd/pwdopen.c @@ -0,0 +1,28 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include + +/* Return a new stream open on the password file. */ +FILE * +DEFUN_VOID(__pwdopen) +{ + return(fopen("/etc/passwd", "r")); +} diff --git a/1/newlibc/pwd/pwdread.c b/1/newlibc/pwd/pwdread.c new file mode 100755 index 0000000..ce099f0 --- /dev/null +++ b/1/newlibc/pwd/pwdread.c @@ -0,0 +1,115 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +/* This is the function that all the others are based on. + The format of the password file is known only here. */ + +/* Structure containing info kept by each __pwdread caller. */ +typedef struct + { +#define NAME_SIZE 8 +#define PASSWD_SIZE 20 +#define GECOS_SIZE 100 + char buf[NAME_SIZE + 1 + PASSWD_SIZE + 1 + 20 + 1 + 20 + 1 + + GECOS_SIZE + 1 + PATH_MAX + 1 + PATH_MAX + 1]; + struct passwd p; + } pwdread_info; + + +/* Return a chunk of memory containing a pre-initialized `pwdread_info'. */ +PTR +DEFUN_VOID(__pwdalloc) +{ + pwdread_info *info = (PTR) malloc(sizeof(pwdread_info)); + if (info == NULL) + return NULL; + return info; +} + +/* Read a password entry from STREAM, filling in P. */ +struct passwd * +DEFUN(__pwdread, (stream, p), FILE *stream AND PTR CONST p) +{ + register pwdread_info *CONST info = (pwdread_info *) p; + char *start, *end; + + /* Idiocy checks. */ + if (stream == NULL) + { + errno = EINVAL; + return NULL; + } + + if (fgets (info->buf, sizeof (info->buf), stream) == NULL) + return NULL; + + start = info->buf; + end = strchr (start, ':'); + if (end == NULL) + return NULL; + *end = '\0'; + info->p.pw_name = start; + + start = end + 1; + end = strchr (start, ':'); + if (end == NULL) + return NULL; + *end = '\0'; + info->p.pw_passwd = start; + + info->p.pw_uid = (uid_t) strtol (end + 1, &end, 10); + if (*end != ':') + return NULL; + info->p.pw_gid = (gid_t) strtol (end + 1, &end, 10); + if (*end != ':') + return NULL; + + start = end + 1; + end = strchr (start, ':'); + if (end == NULL) + return NULL; + *end = '\0'; + info->p.pw_gecos = start; + + start = end + 1; + end = strchr (start, ':'); + if (end == NULL) + return NULL; + *end = '\0'; + info->p.pw_dir = start; + + start = end + 1; + end = strchr (start, '\n'); + if (end == NULL) + return NULL; + *end = '\0'; + info->p.pw_shell = start; + + return &info->p; +} diff --git a/1/newlibc/soft/._Makefile b/1/newlibc/soft/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._README b/1/newlibc/soft/._README new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._asin.c b/1/newlibc/soft/._asin.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._atan.c b/1/newlibc/soft/._atan.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._const.c b/1/newlibc/soft/._const.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._erf.c b/1/newlibc/soft/._erf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._exp.c b/1/newlibc/soft/._exp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._fabs.c b/1/newlibc/soft/._fabs.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._floor.c b/1/newlibc/soft/._floor.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._frexp.c b/1/newlibc/soft/._frexp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._hypot.c b/1/newlibc/soft/._hypot.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._j0.c b/1/newlibc/soft/._j0.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._j1.c b/1/newlibc/soft/._j1.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._jn.c b/1/newlibc/soft/._jn.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._ldexp.c b/1/newlibc/soft/._ldexp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._lgamma.c b/1/newlibc/soft/._lgamma.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._log.c b/1/newlibc/soft/._log.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._main.c b/1/newlibc/soft/._main.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._modf.c b/1/newlibc/soft/._modf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._pow.c b/1/newlibc/soft/._pow.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._sin.c b/1/newlibc/soft/._sin.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._sinh.c b/1/newlibc/soft/._sinh.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._soft.h b/1/newlibc/soft/._soft.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._soft.h.old b/1/newlibc/soft/._soft.h.old new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._sqrt.c b/1/newlibc/soft/._sqrt.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._tan.c b/1/newlibc/soft/._tan.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/._tanh.c b/1/newlibc/soft/._tanh.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/soft/Makefile b/1/newlibc/soft/Makefile new file mode 100755 index 0000000..86afc0d --- /dev/null +++ b/1/newlibc/soft/Makefile @@ -0,0 +1,41 @@ +LIB=../Libsoft.a +AR =/usr2/linux/cross/bin/gar +AS =/usr2/linux/cross/lib/gcc-as +LD =/usr2/linux/cross/bin/gld +RANLIB =/usr2/linux/cross/bin/ranlib +LDFLAGS =-s -x +CC =/usr2/linux/cross/bin/gcc -B/usr2/linux/cross/lib/gcc- +INC =-nostdinc -I. -I/usr2/linux/src/lib.new/new \ + -I/usr2/linux/usr/include +CFLAGS = -Wall -O -fstrength-reduce -fomit-frame-pointer $(INC) +CPP=$(CC) -E $(INC) +LIBS= -lm + +.s.o : + $(CC) $(CFLAGS) -c $*.s + +.c.o : + $(CC) $(CFLAGS) -c $*.c + +OBJS = asin.o atan.o const.o exp.o fabs.o floor.o frexp.o hypot.o \ + j0.o j1.o jn.o log.o pow.o sin.o sinh.o sqrt.o tan.o tanh.o \ + erf.o lgamma.o + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +test: $(OBJS) + $(CC) -o $@ $(OBJS) $(LIBS) + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/soft/README b/1/newlibc/soft/README new file mode 100755 index 0000000..ad1dc90 --- /dev/null +++ b/1/newlibc/soft/README @@ -0,0 +1,20 @@ + 01/13/90 +I implemented frexp(), ldexp(), and modf() +as needed by this math library, using the IEEE double's of GNU CC +for the 68000. This was previously implemented for the trix compiler +only (harmony stuff, in crt.a). + -Marc E. G. + +Now uses a sensible custom math.h instead of libm.h. + + 02/28/91 +Added infnan() and finite() in const.c; these constants should be revised... + -MEG + +--------------------------------- +I adopted this package to Linux. It works on all legal numbers. But it +needs more work to get error handling right. + +H.J. Lu +hlu@eecs.wsu.edu +02/18/92 diff --git a/1/newlibc/soft/asin.c b/1/newlibc/soft/asin.c new file mode 100755 index 0000000..3857868 --- /dev/null +++ b/1/newlibc/soft/asin.c @@ -0,0 +1,44 @@ +#include + +/* + asin(arg) and acos(arg) return the arcsin, arccos, + respectively of their arguments. + + Arctan is called after appropriate range reduction. + + need error handling +*/ + +double asin(double arg) +{ + double sign, temp; + + sign = 1.; + if(arg <0){ + arg = -arg; + sign = -1.; + } + + if(arg > 1.){ + errno = EDOM; + return(0.); + } + + temp = sqrt(1. - arg*arg); + if(arg > 0.7) + temp = pio2 - atan(temp/arg); + else + temp = atan(arg/temp); + + return(sign*temp); +} + +double acos(double arg) +{ + if((arg > 1.) || (arg < -1.)){ + /*errno = EDOM;*/ + return(0.); + } + + return(pio2 - asin(arg)); +} diff --git a/1/newlibc/soft/atan.c b/1/newlibc/soft/atan.c new file mode 100755 index 0000000..de8fbc2 --- /dev/null +++ b/1/newlibc/soft/atan.c @@ -0,0 +1,97 @@ +#include + + +/* + floating-point arctangent + + atan returns the value of the arctangent of its + argument in the range [-pi/2,pi/2]. + + atan2 returns the arctangent of arg1/arg2 + in the range [-pi,pi]. + + there are no error returns. + + coefficients are #5077 from Hart & Cheney. (19.56D) +*/ + + double pio2 = 1.570796326794896619; +static double sq2p1 =2.414213562373095048802e0; +static double sq2m1 = .414213562373095048802e0; +static double pio4 = .785398163397448309615e0; +static double p4 = .161536412982230228262e2; +static double p3 = .26842548195503973794141e3; +static double p2 = .11530293515404850115428136e4; +static double p1 = .178040631643319697105464587e4; +static double p0 = .89678597403663861959987488e3; +static double q4 = .5895697050844462222791e2; +static double q3 = .536265374031215315104235e3; +static double q2 = .16667838148816337184521798e4; +static double q1 = .207933497444540981287275926e4; +static double q0 = .89678597403663861962481162e3; +static double satan(double); +static double xatan(double); + +/* + atan makes its argument positive and + calls the inner routine satan. +*/ + +double atan(double arg) +{ + if(arg>0) + return(satan(arg)); + else + return(-satan(-arg)); +} + + +/* + atan2 discovers what quadrant the angle + is in and calls atan. +*/ + +double atan2(double arg1, double arg2) +{ + if((arg1+arg2)==arg1) + if(arg1 >= 0.) return(pio2); + else return(-pio2); + else if(arg2 <0.) + if(arg1 >= 0.) + return(pio2+pio2 - satan(-arg1/arg2)); + else + return(-pio2-pio2 + satan(arg1/arg2)); + else if(arg1>0) + return(satan(arg1/arg2)); + return(-satan(-arg1/arg2)); +} + +/* + satan reduces its argument (known to be positive) + to the range [0,0.414...] and calls xatan. +*/ + +static double satan(double arg) +{ + if(arg < sq2m1) + return(xatan(arg)); + else if(arg > sq2p1) + return(pio2 - xatan(1.0/arg)); + return(pio4 + xatan((arg-1.0)/(arg+1.0))); +} + +/* + xatan evaluates a series valid in the + range [-0.414...,+0.414...]. +*/ + +static double xatan(double arg) +{ + double argsq; + double value; + + argsq = arg*arg; + value = ((((p4*argsq + p3)*argsq + p2)*argsq + p1)*argsq + p0); + value = value/(((((argsq + q4)*argsq + q3)*argsq + q2)*argsq + q1)*argsq + q0); + return(value*arg); +} diff --git a/1/newlibc/soft/const.c b/1/newlibc/soft/const.c new file mode 100755 index 0000000..3ce8d86 --- /dev/null +++ b/1/newlibc/soft/const.c @@ -0,0 +1,41 @@ + +#include + +/* I made these up - I don't know what are the actual bit-representations + * of infinites and NaN's -meg + */ + +static struct bitdouble bdouble_inf = {0,0x7ff,0,0}; +static struct bitdouble bdouble_minf = {1,0x7ff,0,0}; +static struct bitdouble bdouble_NaN = {0,0x001,0,1}; +static struct bitdouble bdouble_huge = {0,0x7ff,0xfffff,0xffffffff}; +static struct bitdouble bdouble_tiny = {0,0x001,0x00000,0x00000000}; +static struct bitfloat bfloat_huge = {0,0xff,0x7fffff}; +static struct bitfloat bfloat_tiny = {0,0x01,0x000000}; + +double *double_inf = (double*)&bdouble_inf; +double *double_minf = (double*)&bdouble_minf; +double *double_NaN = (double*)&bdouble_NaN; +double *double_huge = (double*)&bdouble_huge; +double *double_tiny = (double*)&bdouble_tiny; +float *float_huge = (float*)&bfloat_huge; +float *float_tiny = (float*)&bfloat_tiny; + +int finite(double arg) +{ + if (arg==*double_inf || arg==*double_minf || arg==*double_NaN) + return 0; + return 1; +} + +double infnan(int iarg) +{ + /* should signal error handling; called by libm routines upon error */ + switch (iarg) { + case EDOM: return *double_NaN; + case ERANGE: return *double_inf; + case -ERANGE: return *double_minf; + default: return *double_NaN; + } +} + diff --git a/1/newlibc/soft/erf.c b/1/newlibc/soft/erf.c new file mode 100755 index 0000000..2b1c319 --- /dev/null +++ b/1/newlibc/soft/erf.c @@ -0,0 +1,124 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +static char sccsid[] = "@(#)erf.c 5.2 (Berkeley) 4/29/88"; +#endif /* not lint */ + +/* + C program for floating point error function + + erf(x) returns the error function of its argument + erfc(x) returns 1.0-erf(x) + + erf(x) is defined by + ${2 over sqrt(pi)} int from 0 to x e sup {-t sup 2} dt$ + + the entry for erfc is provided because of the + extreme loss of relative accuracy if erf(x) is + called for large x and the result subtracted + from 1. (e.g. for x= 10, 12 places are lost). + + There are no error returns. + + Calls exp. + + Coefficients for large x are #5667 from Hart & Cheney (18.72D). +*/ + +#include + +#define M 7 +#define N 9 +static double torp = 1.1283791670955125738961589031; +static double p1[] = { + 0.804373630960840172832162e5, + 0.740407142710151470082064e4, + 0.301782788536507577809226e4, + 0.380140318123903008244444e2, + 0.143383842191748205576712e2, + -.288805137207594084924010e0, + 0.007547728033418631287834e0, +}; +static double q1[] = { + 0.804373630960840172826266e5, + 0.342165257924628539769006e5, + 0.637960017324428279487120e4, + 0.658070155459240506326937e3, + 0.380190713951939403753468e2, + 0.100000000000000000000000e1, + 0.0, +}; +static double p2[] = { + 0.18263348842295112592168999e4, + 0.28980293292167655611275846e4, + 0.2320439590251635247384768711e4, + 0.1143262070703886173606073338e4, + 0.3685196154710010637133875746e3, + 0.7708161730368428609781633646e2, + 0.9675807882987265400604202961e1, + 0.5641877825507397413087057563e0, + 0.0, +}; +static double q2[] = { + 0.18263348842295112595576438e4, + 0.495882756472114071495438422e4, + 0.60895424232724435504633068e4, + 0.4429612803883682726711528526e4, + 0.2094384367789539593790281779e4, + 0.6617361207107653469211984771e3, + 0.1371255960500622202878443578e3, + 0.1714980943627607849376131193e2, + 1.0, +}; + +double +erf(double arg) +{ + int sign; + double argsq; + double d, n; + int i; + + sign = 1; + if(arg < 0.){ + arg = -arg; + sign = -1; + } + if(arg < 0.5){ + argsq = arg*arg; + for(n=0,d=0,i=M-1; i>=0; i--){ + n = n*argsq + p1[i]; + d = d*argsq + q1[i]; + } + return(sign*torp*arg*n/d); + } + if(arg >= 10.) + return(sign*1.); + return(sign*(1. - erfc(arg))); +} + +double +erfc(double arg) +{ + double n, d; + int i; + + if(arg < 0.) + return(2. - erfc(-arg)); +/* + if(arg < 0.5) + return(1. - erf(arg)); +*/ + if(arg >= 10.) + return(0.); + + for(n=0,d=0,i=N-1; i>=0; i--){ + n = n*arg + p2[i]; + d = d*arg + q2[i]; + } + return(exp(-arg*arg)*n/d); +} diff --git a/1/newlibc/soft/exp.c b/1/newlibc/soft/exp.c new file mode 100755 index 0000000..e7c2456 --- /dev/null +++ b/1/newlibc/soft/exp.c @@ -0,0 +1,40 @@ +#include + +/* + exp returns the exponential function of its + floating-point argument. + + The coefficients are #1069 from Hart and Cheney. (22.35D) +*/ + +static double exp_p0 = .2080384346694663001443843411e7; +static double exp_p1 = .3028697169744036299076048876e5; +static double exp_p2 = .6061485330061080841615584556e2; +static double exp_q0 = .6002720360238832528230907598e7; +static double exp_q1 = .3277251518082914423057964422e6; +static double exp_q2 = .1749287689093076403844945335e4; +static double log2e = 1.4426950408889634073599247; +static double sqrt2 = 1.4142135623730950488016887; +static double maxf = 10000; + +double exp(double arg) +{ + double fract; + double temexp_p1, temexp_p2, xsq; + int ent; + + if(arg == 0.) + return(1.); + if(arg < -maxf) + return(0.); + if(arg > maxf) { + return(HUGE_VAL); + } + arg *= log2e; + ent = floor(arg); + fract = (arg-ent) - 0.5; + xsq = fract*fract; + temexp_p1 = ((exp_p2*xsq+exp_p1)*xsq+exp_p0)*fract; + temexp_p2 = ((1.0*xsq+exp_q2)*xsq+exp_q1)*xsq + exp_q0; + return(ldexp(sqrt2*(temexp_p2+temexp_p1)/(temexp_p2-temexp_p1), ent)); +} diff --git a/1/newlibc/soft/fabs.c b/1/newlibc/soft/fabs.c new file mode 100755 index 0000000..c180c59 --- /dev/null +++ b/1/newlibc/soft/fabs.c @@ -0,0 +1,8 @@ +#include + +double fabs(double arg) +{ + if(arg < 0.) + arg = -arg; + return(arg); +} diff --git a/1/newlibc/soft/floor.c b/1/newlibc/soft/floor.c new file mode 100755 index 0000000..89eac30 --- /dev/null +++ b/1/newlibc/soft/floor.c @@ -0,0 +1,26 @@ +#include + +/* + * floor and ceil-- greatest integer <= arg + * (resp least >=) + */ + +double floor(double d) +{ + double fract; + + if (d<0.0) { + d = -d; + fract = modf(d, &d); + if (fract != 0.0) + d += 1; + d = -d; + } else + modf(d, &d); + return(d); +} + +double ceil(double d) +{ + return(-floor(-d)); +} diff --git a/1/newlibc/soft/frexp.c b/1/newlibc/soft/frexp.c new file mode 100755 index 0000000..d833426 --- /dev/null +++ b/1/newlibc/soft/frexp.c @@ -0,0 +1,17 @@ +#include + +/* Stores binary exponent of d in e, and returns whole fraction of d + * (with binary exponent of 0) (special case for d=0) + */ +double frexp(double d, int *e) +{ + struct bitdouble *dp = (struct bitdouble *)&d; + + if (dp->exp == 0) /* value is zero, return exponent of 0 */ + *e = 0; + else { + *e = dp->exp - BIAS + 1; + dp->exp = BIAS - 1; + } + return d; +} diff --git a/1/newlibc/soft/hypot.c b/1/newlibc/soft/hypot.c new file mode 100755 index 0000000..c727404 --- /dev/null +++ b/1/newlibc/soft/hypot.c @@ -0,0 +1,25 @@ +#include + +/* + * sqrt(a^2 + b^2) + * (but carefully) + */ + +double hypot(double a, double b) +{ + double t; + if(a<0) a = -a; + if(b<0) b = -b; + if(a > b) { + t = a; + a = b; + b = t; + } + if(b==0) return(0.); + a /= b; + /* + * pathological overflow possible + * in the next line. + */ + return(b*sqrt(1. + a*a)); +} diff --git a/1/newlibc/soft/j0.c b/1/newlibc/soft/j0.c new file mode 100755 index 0000000..3d4665f --- /dev/null +++ b/1/newlibc/soft/j0.c @@ -0,0 +1,183 @@ +#include + +/* + floating point Bessel's function + of the first and second kinds + of order zero + + j0(x) returns the value of J0(x) + for all real values of x. + + There are no error returns. + Calls sin, cos, sqrt. + + There is a niggling bug in J0 which + causes errors up to 2e-16 for x in the + interval [-8,8]. + The bug is caused by an inappropriate order + of summation of the series. rhm will fix it + someday. + + Coefficients are from Hart & Cheney. + #5849 (19.22D) + #6549 (19.25D) + #6949 (19.41D) + + y0(x) returns the value of Y0(x) + for positive real values of x. + For x<=0, error number EDOM is set and a + large negative value is returned. + + Calls sin, cos, sqrt, log, j0. + + The values of Y0 have not been checked + to more than ten places. + + Coefficients are from Hart & Cheney. + #6245 (18.78D) + #6549 (19.25D) + #6949 (19.41D) +*/ + +static void asympt(double); +static double pzero, qzero; +static double tpi = .6366197723675813430755350535e0; +static double pio4 = .7853981633974483096156608458e0; +static double p1[] = { + 0.4933787251794133561816813446e21, + -.1179157629107610536038440800e21, + 0.6382059341072356562289432465e19, + -.1367620353088171386865416609e18, + 0.1434354939140344111664316553e16, + -.8085222034853793871199468171e13, + 0.2507158285536881945555156435e11, + -.4050412371833132706360663322e8, + 0.2685786856980014981415848441e5, +}; +static double q1[] = { + 0.4933787251794133562113278438e21, + 0.5428918384092285160200195092e19, + 0.3024635616709462698627330784e17, + 0.1127756739679798507056031594e15, + 0.3123043114941213172572469442e12, + 0.6699987672982239671814028660e9, + 0.1114636098462985378182402543e7, + 0.1363063652328970604442810507e4, + 1.0 +}; +static double p2[] = { + 0.5393485083869438325262122897e7, + 0.1233238476817638145232406055e8, + 0.8413041456550439208464315611e7, + 0.2016135283049983642487182349e7, + 0.1539826532623911470917825993e6, + 0.2485271928957404011288128951e4, + 0.0, +}; +static double q2[] = { + 0.5393485083869438325560444960e7, + 0.1233831022786324960844856182e8, + 0.8426449050629797331554404810e7, + 0.2025066801570134013891035236e7, + 0.1560017276940030940592769933e6, + 0.2615700736920839685159081813e4, + 1.0, +}; +static double p3[] = { + -.3984617357595222463506790588e4, + -.1038141698748464093880530341e5, + -.8239066313485606568803548860e4, + -.2365956170779108192723612816e4, + -.2262630641933704113967255053e3, + -.4887199395841261531199129300e1, + 0.0, +}; +static double q3[] = { + 0.2550155108860942382983170882e6, + 0.6667454239319826986004038103e6, + 0.5332913634216897168722255057e6, + 0.1560213206679291652539287109e6, + 0.1570489191515395519392882766e5, + 0.4087714673983499223402830260e3, + 1.0, +}; +static double p4[] = { + -.2750286678629109583701933175e20, + 0.6587473275719554925999402049e20, + -.5247065581112764941297350814e19, + 0.1375624316399344078571335453e18, + -.1648605817185729473122082537e16, + 0.1025520859686394284509167421e14, + -.3436371222979040378171030138e11, + 0.5915213465686889654273830069e8, + -.4137035497933148554125235152e5, +}; +static double q4[] = { + 0.3726458838986165881989980e21, + 0.4192417043410839973904769661e19, + 0.2392883043499781857439356652e17, + 0.9162038034075185262489147968e14, + 0.2613065755041081249568482092e12, + 0.5795122640700729537480087915e9, + 0.1001702641288906265666651753e7, + 0.1282452772478993804176329391e4, + 1.0, +}; + +double j0(double arg) +{ + double argsq, n, d; + int i; + + if(arg < 0.) arg = -arg; + if(arg > 8.){ + asympt(arg); + n = arg - pio4; + return(sqrt(tpi/arg)*(pzero*cos(n) - qzero*sin(n))); + } + argsq = arg*arg; + for(n=0,d=0,i=8;i>=0;i--){ + n = n*argsq + p1[i]; + d = d*argsq + q1[i]; + } + return(n/d); +} + +double y0(double arg) +{ + double argsq, n, d; + double sin(), cos(), sqrt(), log(), j0(); + int i; + + if(arg <= 0.){ + return(-HUGE_VAL); + } + if(arg > 8.){ + asympt(arg); + n = arg - pio4; + return(sqrt(tpi/arg)*(pzero*sin(n) + qzero*cos(n))); + } + argsq = arg*arg; + for(n=0,d=0,i=8;i>=0;i--){ + n = n*argsq + p4[i]; + d = d*argsq + q4[i]; + } + return(n/d + tpi*j0(arg)*log(arg)); +} + +static void asympt(double arg) +{ + double zsq, n, d; + int i; + zsq = 64./(arg*arg); + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p2[i]; + d = d*zsq + q2[i]; + } + pzero = n/d; + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p3[i]; + d = d*zsq + q3[i]; + } + qzero = (8./arg)*(n/d); +} diff --git a/1/newlibc/soft/j1.c b/1/newlibc/soft/j1.c new file mode 100755 index 0000000..0c966ca --- /dev/null +++ b/1/newlibc/soft/j1.c @@ -0,0 +1,188 @@ +#include + +/* + floating point Bessel's function + of the first and second kinds + of order one + + j1(x) returns the value of J1(x) + for all real values of x. + + There are no error returns. + Calls sin, cos, sqrt. + + There is a niggling bug in J1 which + causes errors up to 2e-16 for x in the + interval [-8,8]. + The bug is caused by an inappropriate order + of summation of the series. rhm will fix it + someday. + + Coefficients are from Hart & Cheney. + #6050 (20.98D) + #6750 (19.19D) + #7150 (19.35D) + + y1(x) returns the value of Y1(x) + for positive real values of x. + For x<=0, error number EDOM is set and a + large negative value is returned. + + Calls sin, cos, sqrt, log, j1. + + The values of Y1 have not been checked + to more than ten places. + + Coefficients are from Hart & Cheney. + #6447 (22.18D) + #6750 (19.19D) + #7150 (19.35D) +*/ + +static void asympt(double); +static double pzero, qzero; +static double tpi = .6366197723675813430755350535e0; +static double pio4 = .7853981633974483096156608458e0; +static double p1[] = { + 0.581199354001606143928050809e21, + -.6672106568924916298020941484e20, + 0.2316433580634002297931815435e19, + -.3588817569910106050743641413e17, + 0.2908795263834775409737601689e15, + -.1322983480332126453125473247e13, + 0.3413234182301700539091292655e10, + -.4695753530642995859767162166e7, + 0.2701122710892323414856790990e4, +}; +static double q1[] = { + 0.1162398708003212287858529400e22, + 0.1185770712190320999837113348e20, + 0.6092061398917521746105196863e17, + 0.2081661221307607351240184229e15, + 0.5243710262167649715406728642e12, + 0.1013863514358673989967045588e10, + 0.1501793594998585505921097578e7, + 0.1606931573481487801970916749e4, + 1.0, +}; +static double p2[] = { + -.4435757816794127857114720794e7, + -.9942246505077641195658377899e7, + -.6603373248364939109255245434e7, + -.1523529351181137383255105722e7, + -.1098240554345934672737413139e6, + -.1611616644324610116477412898e4, + 0.0, +}; +static double q2[] = { + -.4435757816794127856828016962e7, + -.9934124389934585658967556309e7, + -.6585339479723087072826915069e7, + -.1511809506634160881644546358e7, + -.1072638599110382011903063867e6, + -.1455009440190496182453565068e4, + 1.0, +}; +static double p3[] = { + 0.3322091340985722351859704442e5, + 0.8514516067533570196555001171e5, + 0.6617883658127083517939992166e5, + 0.1849426287322386679652009819e5, + 0.1706375429020768002061283546e4, + 0.3526513384663603218592175580e2, + 0.0, +}; +static double q3[] = { + 0.7087128194102874357377502472e6, + 0.1819458042243997298924553839e7, + 0.1419460669603720892855755253e7, + 0.4002944358226697511708610813e6, + 0.3789022974577220264142952256e5, + 0.8638367769604990967475517183e3, + 1.0, +}; +static double p4[] = { + -.9963753424306922225996744354e23, + 0.2655473831434854326894248968e23, + -.1212297555414509577913561535e22, + 0.2193107339917797592111427556e20, + -.1965887462722140658820322248e18, + 0.9569930239921683481121552788e15, + -.2580681702194450950541426399e13, + 0.3639488548124002058278999428e10, + -.2108847540133123652824139923e7, + 0.0, +}; +static double q4[] = { + 0.5082067366941243245314424152e24, + 0.5435310377188854170800653097e22, + 0.2954987935897148674290758119e20, + 0.1082258259408819552553850180e18, + 0.2976632125647276729292742282e15, + 0.6465340881265275571961681500e12, + 0.1128686837169442121732366891e10, + 0.1563282754899580604737366452e7, + 0.1612361029677000859332072312e4, + 1.0, +}; + +double j1(double arg) +{ + double xsq, n, d, x; + int i; + + x = arg; + if(x < 0.) x = -x; + if(x > 8.){ + asympt(x); + n = x - 3.*pio4; + n = sqrt(tpi/x)*(pzero*cos(n) - qzero*sin(n)); + if(arg <0.) n = -n; + return(n); + } + xsq = x*x; + for(n=0,d=0,i=8;i>=0;i--){ + n = n*xsq + p1[i]; + d = d*xsq + q1[i]; + } + return(arg*n/d); +} + +double y1(double arg) +{ + double xsq, n, d, x; + int i; + + x = arg; + if(x <= 0.){ + return(-HUGE_VAL); + } + if(x > 8.){ + asympt(x); + n = x - 3*pio4; + return(sqrt(tpi/x)*(pzero*sin(n) + qzero*cos(n))); + } + xsq = x*x; + for(n=0,d=0,i=9;i>=0;i--){ + n = n*xsq + p4[i]; + d = d*xsq + q4[i]; + } + return(x*n/d + tpi*(j1(x)*log(x)-1./x)); +} + +static void asympt(double arg) +{ + double zsq, n, d; + int i; + zsq = 64./(arg*arg); + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p2[i]; + d = d*zsq + q2[i]; + } + pzero = n/d; + for(n=0,d=0,i=6;i>=0;i--){ + n = n*zsq + p3[i]; + d = d*zsq + q3[i]; + } + qzero = (8./arg)*(n/d); +} diff --git a/1/newlibc/soft/jn.c b/1/newlibc/soft/jn.c new file mode 100755 index 0000000..d7046a8 --- /dev/null +++ b/1/newlibc/soft/jn.c @@ -0,0 +1,101 @@ +#include + +/* + floating point Bessel's function of + the first and second kinds and of + integer order. + + int n; + double x; + jn(n,x); + + returns the value of Jn(x) for all + integer values of n and all real values + of x. + + There are no error returns. + Calls j0, j1. + + For n=0, j0(x) is called, + for n=1, j1(x) is called, + for nx, a continued fraction approximation to + j(n,x)/j(n-1,x) is evaluated and then backward + recursion is used starting from a supposed value + for j(n,x). The resulting value of j(0,x) is + compared with the actual value to correct the + supposed value of j(n,x). + + yn(n,x) is similar in all respects, except + that forward recursion is used for all + values of n>1. +*/ + +double jn(int n, double x) +{ + int i; + double a, b, temp; + double xsq, t; + + if(n<0){ + n = -n; + x = -x; + } + if(n==0) return(j0(x)); + if(n==1) return(j1(x)); + if(x == 0.) return(0.); + if(n>x) goto recurs; + + a = j0(x); + b = j1(x); + for(i=1;in;i--){ + t = xsq/(2.*i - t); + } + t = x/(2.*n-t); + + a = t; + b = 1; + for(i=n-1;i>0;i--){ + temp = b; + b = (2.*i/x)*b - a; + a = temp; + } + return(t*j0(x)/b); +} + +double yn(int n, double x) +{ + int i; + int sign; + double a, b, temp; + + if (x <= 0) { + return(-HUGE_VAL); + } + sign = 1; + if(n<0){ + n = -n; + if(n%2 == 1) sign = -1; + } + if(n==0) return(y0(x)); + if(n==1) return(sign*y1(x)); + + a = y0(x); + b = y1(x); + for(i=1;i +#endif +#if defined(vax)||defined(tahoe) +#include +#endif /* defined(vax)||defined(tahoe) */ + +int signgam = 0; +static const double goobie = 0.9189385332046727417803297; /* log(2*pi)/2 */ +static const double pi = 3.1415926535897932384626434; + +#define M 6 +#define N 8 +static const double p1[] = { + 0.83333333333333101837e-1, + -.277777777735865004e-2, + 0.793650576493454e-3, + -.5951896861197e-3, + 0.83645878922e-3, + -.1633436431e-2, +}; +static const double p2[] = { + -.42353689509744089647e5, + -.20886861789269887364e5, + -.87627102978521489560e4, + -.20085274013072791214e4, + -.43933044406002567613e3, + -.50108693752970953015e2, + -.67449507245925289918e1, + 0.0, +}; +static const double q2[] = { + -.42353689509744090010e5, + -.29803853309256649932e4, + 0.99403074150827709015e4, + -.15286072737795220248e4, + -.49902852662143904834e3, + 0.18949823415702801641e3, + -.23081551524580124562e2, + 0.10000000000000000000e1, +}; + +static double pos(double), neg(double), asym(double); + +double +lgamma(double arg) +{ + + signgam = 1.; + if(arg <= 0.) return(neg(arg)); + if(arg > 8.) return(asym(arg)); + return(log(pos(arg))); +} + +static double +asym(double arg) +{ + double n, argsq; + int i; + + argsq = 1./(arg*arg); + for(n=0,i=M-1; i>=0; i--){ + n = n*argsq + p1[i]; + } + return((arg-.5)*log(arg) - arg + goobie + n/arg); +} + +static double +neg(double arg) +{ + double t; + + arg = -arg; + /* + * to see if arg were a true integer, the old code used the + * mathematically correct observation: + * sin(n*pi) = 0 <=> n is an integer. + * but in finite precision arithmetic, sin(n*PI) will NEVER + * be zero simply because n*PI is a rational number. hence + * it failed to work with our newer, more accurate sin() + * which uses true pi to do the argument reduction... + * temp = sin(pi*arg); + */ + t = floor(arg); + if (arg - t > 0.5e0) + t += 1.e0; /* t := integer nearest arg */ +#if defined(vax)||defined(tahoe) + if (arg == t) { + return(infnan(ERANGE)); /* +INF */ + } +#endif /* defined(vax)||defined(tahoe) */ + signgam = (int) (t - 2*floor(t/2)); /* signgam = 1 if t was odd, */ + /* 0 if t was even */ + signgam = signgam - 1 + signgam; /* signgam = 1 if t was odd, */ + /* -1 if t was even */ + t = arg - t; /* -0.5 <= t <= 0.5 */ + if (t < 0.e0) { + t = -t; + signgam = -signgam; + } + return(-log(arg*pos(arg)*sin(pi*t)/pi)); +} + +static double +pos(double arg) +{ + double n, d, s; + register i; + + if(arg < 2.) return(pos(arg+1.)/arg); + if(arg > 3.) return((arg-1.)*pos(arg-1.)); + + s = arg - 2.; + for(n=0,d=0,i=N-1; i>=0; i--){ + n = n*s + p2[i]; + d = d*s + q2[i]; + } + return(n/d); +} diff --git a/1/newlibc/soft/log.c b/1/newlibc/soft/log.c new file mode 100755 index 0000000..c30b10e --- /dev/null +++ b/1/newlibc/soft/log.c @@ -0,0 +1,53 @@ +#include + +/* + log returns the natural logarithm of its floating + point argument. + + The coefficients are #2705 from Hart & Cheney. (19.38D) + + It calls frexp. +*/ + +static double log2 = 0.693147180559945309e0; +static double ln10 = 2.302585092994045684; +static double sqrto2 = 0.707106781186547524e0; +static double log_p0 = -.240139179559210510e2; +static double log_p1 = 0.309572928215376501e2; +static double log_p2 = -.963769093368686593e1; +static double log_p3 = 0.421087371217979714e0; +static double log_q0 = -.120069589779605255e2; +static double log_q1 = 0.194809660700889731e2; +static double log_q2 = -.891110902798312337e1; + +double log(double arg) +{ + double x,z, zsq, temp; + int exp; + + if(arg <= 0.) { + return(-HUGE_VAL); + } + x = frexp(arg,&exp); + while(x<0.5) { + x = x*2; + exp = exp-1; + } + if(x +#include + +extern double Sqrt(); + +main () +{ + int power; + double f, x1, x2, y, t1, t2; + + for (y = 0; y < 100; y += 0.3435) { + t1 = sqrt (y); + t2 = Sqrt (y); + fprintf (stderr, "%g: %30.20g\t%30.20g\n", y, t2, t1); + } +} diff --git a/1/newlibc/soft/modf.c b/1/newlibc/soft/modf.c new file mode 100755 index 0000000..d3330f6 --- /dev/null +++ b/1/newlibc/soft/modf.c @@ -0,0 +1,54 @@ +#include "soft.h" + +#define shiftleft(dp,n) { /* n = 0 to 32 */ \ + dp->mant1 = ((dp->mant1 << (n)) + (dp->mant2 >> (32-(n)))) \ + & 0x0FFFFF; dp->mant2 <<= (n); dp->exp -= (n); } + + +/* Returns fractional part of d, stores integer part in *integ + */ +double Modf(double d, double *integ) +{ + struct bitdouble *dp = (struct bitdouble *)&d; + struct bitdouble *ip = (struct bitdouble *)integ; + int e = dp->exp - BIAS; + + if (e < 0) { /* no integer part */ + *integ = 0; + return d; + } + + /* compute integer: clear fractional part where necessary + */ + *integ = d; + if (e <= 20) { + ip->mant1 &= (-1L << (20-e)); /* split in mant1... */ + ip->mant2 = 0; + } + else + if (e <= 52) + ip->mant2 &= (-1L << (52-e)); /* split in mant2 */ + else return 0; /* no fractional part */ + + /* compute fractional part: shift left over integer part + */ + if (e) + if (e <= 32) + shiftleft(dp,e) + else { + dp->mant1 = (dp->mant2 << (e-32)) & 0x0FFFFF; + dp->mant2 = 0; + dp->exp -= e; + } + + /* adjust fractional part shifting left... + */ + if (dp->mant1==0 && dp->mant2==0) /* fraction is zero */ + return 0; + + while (!(dp->mant1 & 0x080000)) /* stack to the left */ + shiftleft(dp,1); + + shiftleft(dp,1); /* lose 'invisible bit' */ + return d; +} diff --git a/1/newlibc/soft/pow.c b/1/newlibc/soft/pow.c new file mode 100755 index 0000000..bd02fbe --- /dev/null +++ b/1/newlibc/soft/pow.c @@ -0,0 +1,33 @@ +#include + +/* + computes a^b. + uses log and exp + need error handling +*/ + +double pow(double arg1, double arg2) +{ + double temp; + long l; + + if(arg1 <= 0.) { + if(arg1 == 0.) { + if(arg2 <= 0.) + goto domain; + return(0.); + } + l = arg2; + if(l != arg2) + goto domain; + temp = exp(arg2 * log(-arg1)); + if(l & 1) + temp = -temp; + return(temp); + } + return(exp(arg2 * log(arg1))); + +domain: + errno = EDOM; + return(0.); +} diff --git a/1/newlibc/soft/sin.c b/1/newlibc/soft/sin.c new file mode 100755 index 0000000..fea3006 --- /dev/null +++ b/1/newlibc/soft/sin.c @@ -0,0 +1,67 @@ +#include + +/* + C program for floating point sin/cos. + Calls modf. + There are no error exits. + Coefficients are #3370 from Hart & Cheney (18.80D). +*/ + +static double twoopi = 0.63661977236758134308; +static double cos_p0 = .1357884097877375669092680e8; +static double cos_p1 = -.4942908100902844161158627e7; +static double cos_p2 = .4401030535375266501944918e6; +static double cos_p3 = -.1384727249982452873054457e5; +static double cos_p4 = .1459688406665768722226959e3; +static double cos_q0 = .8644558652922534429915149e7; +static double cos_q1 = .4081792252343299749395779e6; +static double cos_q2 = .9463096101538208180571257e4; +static double cos_q3 = .1326534908786136358911494e3; +static double sinus(double,int); + +double cos(double arg) +{ + if(arg<0) + arg = -arg; + return(sinus(arg, 1)); +} + +double sin(double arg) +{ + return(sinus(arg, 0)); +} + +static double sinus(double arg, int quad) +{ + double e, f; + double ysq; + double x,y; + int k; + double temcos_p1, temcos_p2; + + x = arg; + if(x<0) { + x = -x; + quad = quad + 2; + } + x = x*twoopi; /*underflow?*/ + if(x>32764){ + y = modf(x,&e); + e = e + quad; + modf(0.25*e,&f); + quad = e - 4*f; + }else{ + k = x; + y = x - k; + quad = (quad + k) & 03; + } + if (quad & 01) + y = 1-y; + if(quad > 1) + y = -y; + + ysq = y*y; + temcos_p1 = ((((cos_p4*ysq+cos_p3)*ysq+cos_p2)*ysq+cos_p1)*ysq+cos_p0)*y; + temcos_p2 = ((((ysq+cos_q3)*ysq+cos_q2)*ysq+cos_q1)*ysq+cos_q0); + return(temcos_p1/temcos_p2); +} diff --git a/1/newlibc/soft/sinh.c b/1/newlibc/soft/sinh.c new file mode 100755 index 0000000..f8ebed9 --- /dev/null +++ b/1/newlibc/soft/sinh.c @@ -0,0 +1,65 @@ +#include + +/* + sinh(arg) returns the hyperbolic sine of its floating- + point argument. + + The exponential function is called for arguments + greater in magnitude than 0.5. + + A series is used for arguments smaller in magnitude than 0.5. + The coefficients are #2029 from Hart & Cheney. (20.36D) + + cosh(arg) is computed from the exponential function for + all arguments. +*/ + +static double sinh_p0 = -0.6307673640497716991184787251e+6; +static double sinh_p1 = -0.8991272022039509355398013511e+5; +static double sinh_p2 = -0.2894211355989563807284660366e+4; +static double sinh_p3 = -0.2630563213397497062819489e+2; +static double sinh_q0 = -0.6307673640497716991212077277e+6; +static double sinh_q1 = 0.1521517378790019070696485176e+5; +static double sinh_q2 = -0.173678953558233699533450911e+3; + +double +sinh(arg) +double arg; +{ + double temp, argsq; + register sign; + + sign = 1; + if(arg < 0) { + arg = - arg; + sign = -1; + } + + if(arg > 21.) { + temp = exp(arg)/2; + if (sign>0) + return(temp); + else + return(-temp); + } + + if(arg > 0.5) { + return(sign*(exp(arg) - exp(-arg))/2); + } + + argsq = arg*arg; + temp = (((sinh_p3*argsq+sinh_p2)*argsq+sinh_p1)*argsq+sinh_p0)*arg; + temp /= (((argsq+sinh_q2)*argsq+sinh_q1)*argsq+sinh_q0); + return(sign*temp); +} + +double cosh(double arg) +{ + if(arg < 0) + arg = - arg; + if(arg > 21.) { + return(exp(arg)/2); + } + + return((exp(arg) + exp(-arg))/2); +} diff --git a/1/newlibc/soft/soft.h b/1/newlibc/soft/soft.h new file mode 100755 index 0000000..850b47a --- /dev/null +++ b/1/newlibc/soft/soft.h @@ -0,0 +1,46 @@ +#ifndef __SOFT_H +#define __SOFT_H + +#include +#include + +extern int finite(double); +extern double infnan(int); + +extern double pio2; +extern double *double_inf, *double_minf, *double_NaN; +extern double *double_huge, *double_tiny; +extern float *float_huge, *float_tiny; + +struct bitdouble { /* internal format of an IEEE double */ + unsigned mant2; + unsigned mant1 : 20; + unsigned exp : 11; + unsigned sign : 1; /* 0=pos, 1=neg */ +}; /* value = 2^(exp-BIAS) * 0b1.|mant|mant2 */ + +struct bitfloat { /* format of a float (single-precision IEEE) */ + unsigned mant : 23; + unsigned exp : 8; + unsigned sign : 1; +}; + +#define PI 3.141592653589793238 + +/* note: GNU CC floating-point constants are all treated as 'float's, + * so loss of precision will result accordingly when using constants; + * an eventual atof() should handle full double values, with which + * HUGEDOUBLE may be used. -meg + */ + +#define INFINITE (*double_inf) +#define NEG_INFINITE (*double_minf) +#define NOT_A_NUMBER (*double_NaN) +#define DHUGE (*double_huge) +#define DTINY (*double_tiny) +#define FHUGE (*float_huge) +#define FTINY (*float_tiny) + +#define BIAS 0x3ff /* added to exp of bitdouble */ + +#endif diff --git a/1/newlibc/soft/soft.h.old b/1/newlibc/soft/soft.h.old new file mode 100755 index 0000000..c2317a4 --- /dev/null +++ b/1/newlibc/soft/soft.h.old @@ -0,0 +1,62 @@ +#ifndef __SOFT_H +#define __SOFT_H + +#include +#include + +extern int finite(double); +extern double infnan(int); + +extern double pio2; +extern double *double_inf, *double_minf, *double_NaN; +extern double *double_huge, *double_tiny; +extern float *float_huge, *float_tiny; + +struct bitdouble { /* internal format of an IEEE double */ + unsigned mant2; + unsigned mant1 : 20; + unsigned exp : 11; + unsigned sign : 1; /* 0=pos, 1=neg */ +}; /* value = 2^(exp-BIAS) * 0b1.|mant|mant2 */ + +struct bitfloat { /* format of a float (single-precision IEEE) */ + unsigned mant : 23; + unsigned exp : 8; + unsigned sign : 1; +}; + +/* constants used by infnan() */ +#ifndef EDOM +#define EDOM 33 +#endif +#ifndef ERANGE +#define ERANGE 34 +#endif + +#define PI 3.141592653589793238 +#define HUGE 1.701411733192644270e38 +#define HUGEDOUBLE 3.59538626972463181545861038157804946723595395\ +7884613145468601623154653516110019262654169546448150720422402277597427\ +8671531757953762883324498569486127894824875553578684973097055260443920\ +2492188238906165904170011537676301364684925762947826221081654474326701\ +021369172596479894491876959432609670712659248448274431e308 + +/* note: GNU CC floating-point constants are all treated as 'float's, + * so loss of precision will result accordingly when using constants; + * an eventual atof() should handle full double values, with which + * HUGEDOUBLE may be used. -meg + */ + +#define INFINITE (*double_inf) +#define NEG_INFINITE (*double_minf) +#define NOT_A_NUMBER (*double_NaN) +#define DHUGE (*double_huge) +#define DTINY (*double_tiny) +#define FHUGE (*float_huge) +#define FTINY (*float_tiny) + +#define BIAS 0x3ff /* added to exp of bitdouble */ +#define MAXPREC 310 /* HUGEDOUBLE~=3.59...e308=2^1025 */ +#define MAXDIGITS 20 /* of possibly useful precision in a double */ + +#endif diff --git a/1/newlibc/soft/sqrt.c b/1/newlibc/soft/sqrt.c new file mode 100755 index 0000000..62c53aa --- /dev/null +++ b/1/newlibc/soft/sqrt.c @@ -0,0 +1,51 @@ +#include + +/* + sqrt returns the square root of its floating + point argument. Newton's method. + + calls frexp + need error handling +*/ + +double sqrt(double arg) +{ + double x, temp; + int exp; + int i; + + if(arg <= 0.) { + errno = EDOM; + return(0.); + } + x = frexp(arg,&exp); + while(x < 0.5) { + x *= 2; + exp--; + } + /* + * NOTE + * this wont work on 1's comp + */ + if(exp & 1) { + x *= 2; + exp--; + } + temp = 0.5*(1.0+x); + + while(exp > 60) { + temp *= (1L<<30); + exp -= 60; + } + while(exp < -60) { + temp /= (1L<<30); + exp += 60; + } + if(exp >= 0) + temp *= 1L << (exp/2); + else + temp /= 1L << (-exp/2); + for(i=0; i<=4; i++) + temp = 0.5*(temp + arg/temp); + return(temp); +} diff --git a/1/newlibc/soft/tan.c b/1/newlibc/soft/tan.c new file mode 100755 index 0000000..50ea62c --- /dev/null +++ b/1/newlibc/soft/tan.c @@ -0,0 +1,67 @@ +#include + +/* + floating point tangent + + A series is used after range reduction. + Coefficients are #4285 from Hart & Cheney. (19.74D) +*/ + +static double invpi = 1.27323954473516268; +static double tan_p0 = -0.1306820264754825668269611177e+5; +static double tan_p1 = 0.1055970901714953193602353981e+4; +static double tan_p2 = -0.1550685653483266376941705728e+2; +static double tan_p3 = 0.3422554387241003435328470489e-1; +static double tan_p4 = 0.3386638642677172096076369e-4; +static double tan_q0 = -0.1663895238947119001851464661e+5; +static double tan_q1 = 0.4765751362916483698926655581e+4; +static double tan_q2 = -0.1555033164031709966900124574e+3; + +double tan(double arg) +{ + double sign, temp, e, x, xsq; + int flag, i; + + flag = 0; + sign = 1.; + if(arg < 0.){ + arg = -arg; + sign = -1.; + } + arg = arg*invpi; /*overflow?*/ + x = modf(arg,&e); + i = e; + switch(i%4) { + case 1: + x = 1. - x; + flag = 1; + break; + + case 2: + sign = - sign; + flag = 1; + break; + + case 3: + x = 1. - x; + sign = - sign; + break; + + case 0: + break; + } + + xsq = x*x; + temp = ((((tan_p4*xsq+tan_p3)*xsq+tan_p2)*xsq+tan_p1)*xsq+tan_p0)*x; + temp = temp/(((1.0*xsq+tan_q2)*xsq+tan_q1)*xsq+tan_q0); + + if(flag == 1) { + if(temp == 0.) { + if (sign>0) + return(HUGE_VAL); + return(-HUGE_VAL); + } + temp = 1./temp; + } + return(sign*temp); +} diff --git a/1/newlibc/soft/tanh.c b/1/newlibc/soft/tanh.c new file mode 100755 index 0000000..37196db --- /dev/null +++ b/1/newlibc/soft/tanh.c @@ -0,0 +1,25 @@ +#include + +/* + tanh(arg) computes the hyperbolic tangent of its floating + point argument. + + sinh and cosh are called except for large arguments, which + would cause overflow improperly. +*/ + +double tanh(double arg) +{ + double sign; + + sign = 1.; + if(arg < 0.){ + arg = -arg; + sign = -1.; + } + + if(arg > 21.) + return(sign); + + return(sign*sinh(arg)/cosh(arg)); +} diff --git a/1/newlibc/stdio/._Makefile b/1/newlibc/stdio/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._clrerr.c b/1/newlibc/stdio/._clrerr.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._doprnt.c b/1/newlibc/stdio/._doprnt.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._doscan.c b/1/newlibc/stdio/._doscan.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._fdopen.c b/1/newlibc/stdio/._fdopen.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._fgetc.c b/1/newlibc/stdio/._fgetc.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._fgets.c b/1/newlibc/stdio/._fgets.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._filbuf.c b/1/newlibc/stdio/._filbuf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._findiop.c b/1/newlibc/stdio/._findiop.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._flsbuf.c b/1/newlibc/stdio/._flsbuf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._fopen.c b/1/newlibc/stdio/._fopen.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._fprintf.c b/1/newlibc/stdio/._fprintf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._fputc.c b/1/newlibc/stdio/._fputc.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._fputs.c b/1/newlibc/stdio/._fputs.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._fread.c b/1/newlibc/stdio/._fread.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._freopen.c b/1/newlibc/stdio/._freopen.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._fseek.c b/1/newlibc/stdio/._fseek.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._ftell.c b/1/newlibc/stdio/._ftell.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._fwrite.c b/1/newlibc/stdio/._fwrite.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._getchar.c b/1/newlibc/stdio/._getchar.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._gets.c b/1/newlibc/stdio/._gets.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._getw.c b/1/newlibc/stdio/._getw.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._printf.c b/1/newlibc/stdio/._printf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._putchar.c b/1/newlibc/stdio/._putchar.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._puts.c b/1/newlibc/stdio/._puts.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._putw.c b/1/newlibc/stdio/._putw.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._rew.c b/1/newlibc/stdio/._rew.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._scanf.c b/1/newlibc/stdio/._scanf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._setbuf.c b/1/newlibc/stdio/._setbuf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._setbuffe.c b/1/newlibc/stdio/._setbuffe.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._setvbuf.c b/1/newlibc/stdio/._setvbuf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._sprintf.c b/1/newlibc/stdio/._sprintf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._ungetc.c b/1/newlibc/stdio/._ungetc.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._vfprintf.c b/1/newlibc/stdio/._vfprintf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._vprintf.c b/1/newlibc/stdio/._vprintf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/._vsprintf.c b/1/newlibc/stdio/._vsprintf.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/Makefile b/1/newlibc/stdio/Makefile new file mode 100755 index 0000000..1ec2ed7 --- /dev/null +++ b/1/newlibc/stdio/Makefile @@ -0,0 +1,51 @@ +# +# Makefile for BSD compatible stdio library functions +# + +LIB =../Libc.a +#AR =gar +#AS =gas +#LD =gld +AR =ar +AS =as +LD =ld +LDFLAGS =-s -x +CC =gcc +INC =-nostdinc -I/../include +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + $(INC)# -DUSG -DSTDC_HEADERS +CPP =$(CC) -E $(INC) + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(CC) -c -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = clrerr.o doprnt.o doscan.o fdopen.o fgetc.o fgets.o filbuf.o \ + findiop.o flsbuf.o fopen.o fprintf.o fputc.o fputs.o fread.o \ + freopen.o fseek.o ftell.o fwrite.o getchar.o gets.o getw.o \ + printf.o putchar.o puts.o putw.o rew.o scanf.o setbuf.o \ + setbuffe.o sprintf.o ungetc.o vfprintf.o vprintf.o \ + vsprintf.o setvbuf.o + +all: library + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/stdio/clrerr.c b/1/newlibc/stdio/clrerr.c new file mode 100755 index 0000000..f4ca2eb --- /dev/null +++ b/1/newlibc/stdio/clrerr.c @@ -0,0 +1,19 @@ +/* This is file CLRERR.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)clrerr.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include +#undef clearerr + +void +clearerr(iop) + register FILE *iop; +{ + iop->_flag &= ~(_IOERR|_IOEOF); +} diff --git a/1/newlibc/stdio/doprnt.c b/1/newlibc/stdio/doprnt.c new file mode 100755 index 0000000..7c15d3a --- /dev/null +++ b/1/newlibc/stdio/doprnt.c @@ -0,0 +1,717 @@ +/* This is file DOPRNT.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted provided + * that: (1) source distributions retain this entire copyright notice and + * comment, and (2) distributions including binaries display the following + * acknowledgement: ``This product includes software developed by the + * University of California, Berkeley and its contributors'' in the + * documentation or other materials provided with the distribution and in + * all advertising materials mentioning features or use of this software. + * Neither the name of the University nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)doprnt.c 5.39 (Berkeley) 6/28/90"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include +#include +#ifdef linux +#include +#include +#endif + +/* 11-bit exponent (VAX G floating point) is 308 decimal digits */ +#define MAXEXP 308 +/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */ +#define MAXFRACT 39 + +#define DEFPREC 6 + +#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */ + +#define PUTC(ch) (void) putc(ch, fp) + +#define ARG(basetype) \ + _ulong = flags&LONGINT ? va_arg(argp, long basetype) : \ + flags&SHORTINT ? (short basetype)va_arg(argp, int) : \ + va_arg(argp, int) + +#define todigit(c) ((c) - '0') +#define tochar(n) ((n) + '0') + +/* have to deal with the negative buffer count kludge */ +#define NEGATIVE_COUNT_KLUDGE + +#define LONGINT 0x01 /* long integer */ +#define LONGDBL 0x02 /* long double; unimplemented */ +#define SHORTINT 0x04 /* short integer */ +#define ALT 0x08 /* alternate form */ +#define LADJUST 0x10 /* left adjustment */ +#define ZEROPAD 0x20 /* zero (as opposed to blank) pad */ +#define HEXPREFIX 0x40 /* add 0x or 0X prefix */ + +#ifdef linux +static int cvt(double number, int prec, int flags, char *signp, + u_char fmtch, char *startp, char *endp); + +static char * exponent(register char *p, int exp, u_char fmtch); + +static char * round(double fract, int *exp, char *start, char *end, + char ch, char *signp); +#endif + + +int +_doprnt(const char *fmt0, va_list argp, FILE *fp) +{ + const u_char *fmt; /* format string */ + int ch; /* character from fmt */ + int cnt; /* return value accumulator */ + int n; /* random handy integer */ + char *t; /* buffer pointer */ + double _double; /* double precision arguments %[eEfgG] */ + unsigned long _ulong; /* integer arguments %[diouxX] */ + int base; /* base for [diouxX] conversion */ + int dprec; /* decimal precision in [diouxX] */ + int fieldsz; /* field size expanded by sign, etc */ + int flags; /* flags as above */ + int fpprec; /* `extra' floating precision in [eEfgG] */ + int prec; /* precision from format (%.3d), or -1 */ + int realsz; /* field size expanded by decimal precision */ + int size; /* size of converted field or string */ + int width; /* width from format (%8d), or 0 */ + char sign; /* sign prefix (' ', '+', '-', or \0) */ + char softsign; /* temporary negative sign for floats */ + char *digs; /* digits for [diouxX] conversion */ + char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */ + + if (fp->_flag & _IORW) { + fp->_flag |= _IOWRT; + fp->_flag &= ~(_IOEOF|_IOREAD); + } + if ((fp->_flag & _IOWRT) == 0) + return (EOF); + fmt = fmt0; + digs = "0123456789abcdef"; + for (cnt = 0;; ++fmt) { + n = fp->_cnt; + for (t = (char *)fp->_ptr; (ch = *fmt) && ch != '%'; + ++cnt, ++fmt) + if ((--n < 0 +#ifdef NEGATIVE_COUNT_KLUDGE + && (!(fp->_flag & _IOLBF) || -n >= fp->_bufsiz)) +#endif + || (ch == '\n' && (fp->_flag & _IOLBF))) { + fp->_cnt = n; + fp->_ptr = t; + (void) _flsbuf((unsigned int)ch, fp); + n = fp->_cnt; + t = (char *)fp->_ptr; + } else + *t++ = ch; + fp->_cnt = n; + fp->_ptr = t; + if (!ch) + return (cnt); + + flags = 0; dprec = 0; fpprec = 0; width = 0; + prec = -1; + sign = '\0'; + +rflag: switch (*++fmt) { + case ' ': + /* + * ``If the space and + flags both appear, the space + * flag will be ignored.'' + * -- ANSI X3J11 + */ + if (!sign) + sign = ' '; + goto rflag; + case '#': + flags |= ALT; + goto rflag; + case '*': + /* + * ``A negative field width argument is taken as a + * - flag followed by a positive field width.'' + * -- ANSI X3J11 + * They don't exclude field widths read from args. + */ + if ((width = va_arg(argp, int)) >= 0) + goto rflag; + width = -width; + /* FALLTHROUGH */ + case '-': + flags |= LADJUST; + goto rflag; + case '+': + sign = '+'; + goto rflag; + case '.': + if (*++fmt == '*') + n = va_arg(argp, int); + else { + n = 0; + while (isascii(*fmt) && isdigit(*fmt)) + n = 10 * n + todigit(*fmt++); + --fmt; + } + prec = n < 0 ? -1 : n; + goto rflag; + case '0': + /* + * ``Note that 0 is taken as a flag, not as the + * beginning of a field width.'' + * -- ANSI X3J11 + */ + flags |= ZEROPAD; + goto rflag; + case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + n = 0; + do { + n = 10 * n + todigit(*fmt); + } while (isascii(*++fmt) && isdigit(*fmt)); + width = n; + --fmt; + goto rflag; + case 'L': + flags |= LONGDBL; + goto rflag; + case 'h': + flags |= SHORTINT; + goto rflag; + case 'l': + flags |= LONGINT; + goto rflag; + case 'c': + *(t = buf) = va_arg(argp, int); + size = 1; + sign = '\0'; + goto pforw; + case 'D': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'd': + case 'i': + ARG(int); + if ((long)_ulong < 0) { + _ulong = -_ulong; + sign = '-'; + } + base = 10; + goto number; + case 'e': + case 'E': + case 'f': + case 'g': + case 'G': + _double = va_arg(argp, double); + /* + * don't do unrealistic precision; just pad it with + * zeroes later, so buffer size stays rational. + */ + if (prec > MAXFRACT) { + if ((*fmt != 'g' && *fmt != 'G') || (flags&ALT)) + fpprec = prec - MAXFRACT; + prec = MAXFRACT; + } + else if (prec == -1) + prec = DEFPREC; + /* + * softsign avoids negative 0 if _double is < 0 and + * no significant digits will be shown + */ + if (_double < 0) { + softsign = '-'; + _double = -_double; + } + else + softsign = 0; + /* + * cvt may have to round up past the "start" of the + * buffer, i.e. ``intf("%.2f", (double)9.999);''; + * if the first char isn't NULL, it did. + */ +#ifdef linux + *buf = NILL; +#else + *buf = NULL; +#endif + size = cvt(_double, prec, flags, &softsign, + *fmt, buf, buf + sizeof(buf)); + if (softsign) + sign = '-'; + t = *buf ? buf : buf + 1; + goto pforw; + case 'n': + if (flags & LONGINT) + *va_arg(argp, long *) = cnt; + else if (flags & SHORTINT) + *va_arg(argp, short *) = cnt; + else + *va_arg(argp, int *) = cnt; + break; + case 'O': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'o': + ARG(unsigned); + base = 8; + goto nosign; + case 'p': + /* + * ``The argument shall be a pointer to void. The + * value of the pointer is converted to a sequence + * of printable characters, in an implementation- + * defined manner.'' + * -- ANSI X3J11 + */ + /* NOSTRICT */ + _ulong = (unsigned long)va_arg(argp, void *); + base = 16; + goto nosign; + case 's': + if (!(t = va_arg(argp, char *))) + t = "(null)"; + if (prec >= 0) { + /* + * can't use strlen; can only look for the + * NUL in the first `prec' characters, and + * strlen() will go further. + */ +#ifdef linux + char *p; +#else + char *p, *memchr(); +#endif + + if (p = memchr(t, 0, prec)) { + size = p - t; + if (size > prec) + size = prec; + } else + size = prec; + } else + size = strlen(t); + sign = '\0'; + goto pforw; + case 'U': + flags |= LONGINT; + /*FALLTHROUGH*/ + case 'u': + ARG(unsigned); + base = 10; + goto nosign; + case 'X': + digs = "0123456789ABCDEF"; + /* FALLTHROUGH */ + case 'x': + ARG(unsigned); + base = 16; + /* leading 0x/X only if non-zero */ + if (flags & ALT && _ulong != 0) + flags |= HEXPREFIX; + + /* unsigned conversions */ +nosign: sign = '\0'; + /* + * ``... diouXx conversions ... if a precision is + * specified, the 0 flag will be ignored.'' + * -- ANSI X3J11 + */ +number: if ((dprec = prec) >= 0) + flags &= ~ZEROPAD; + + /* + * ``The result of converting a zero value with an + * explicit precision of zero is no characters.'' + * -- ANSI X3J11 + */ + t = buf + BUF; + if (_ulong != 0 || prec != 0) { + do { + *--t = digs[_ulong % base]; + _ulong /= base; + } while (_ulong); + digs = "0123456789abcdef"; + if (flags & ALT && base == 8 && *t != '0') + *--t = '0'; /* octal leading 0 */ + } + size = buf + BUF - t; + +pforw: + /* + * All reasonable formats wind up here. At this point, + * `t' points to a string which (if not flags&LADJUST) + * should be padded out to `width' places. If + * flags&ZEROPAD, it should first be prefixed by any + * sign or other prefix; otherwise, it should be blank + * padded before the prefix is emitted. After any + * left-hand padding and prefixing, emit zeroes + * required by a decimal [diouxX] precision, then print + * the string proper, then emit zeroes required by any + * leftover floating precision; finally, if LADJUST, + * pad with blanks. + */ + + /* + * compute actual size, so we know how much to pad + * fieldsz excludes decimal prec; realsz includes it + */ + fieldsz = size + fpprec; + if (sign) + fieldsz++; + if (flags & HEXPREFIX) + fieldsz += 2; + realsz = dprec > fieldsz ? dprec : fieldsz; + + /* right-adjusting blank padding */ + if ((flags & (LADJUST|ZEROPAD)) == 0 && width) + for (n = realsz; n < width; n++) + PUTC(' '); + /* prefix */ + if (sign) + PUTC(sign); + if (flags & HEXPREFIX) { + PUTC('0'); + PUTC((char)*fmt); + } + /* right-adjusting zero padding */ + if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD) + for (n = realsz; n < width; n++) + PUTC('0'); + /* leading zeroes from decimal precision */ + for (n = fieldsz; n < dprec; n++) + PUTC('0'); + + /* the string or number proper */ + n = size; + if (fp->_cnt - n >= 0 && (fp->_flag & _IOLBF) == 0) { + fp->_cnt -= n; + bcopy(t, (char *)fp->_ptr, n); + fp->_ptr += n; + } else + while (--n >= 0) + PUTC(*t++); + /* trailing f.p. zeroes */ + while (--fpprec >= 0) + PUTC('0'); + /* left-adjusting padding (always blank) */ + if (flags & LADJUST) + for (n = realsz; n < width; n++) + PUTC(' '); + /* finally, adjust cnt */ + cnt += width > realsz ? width : realsz; + break; + case '\0': /* "%?" prints ?, unless ? is NULL */ + return (cnt); + default: + PUTC((char)*fmt); + cnt++; + } + } + /* NOTREACHED */ +} + +static int +cvt(double number, register int prec, int flags, char *signp, + u_char fmtch, char *startp, char *endp) +{ + register char *p, *t; + register double fract; + int dotrim, expcnt, gformat; + double integer, tmp; +#ifndef linux + double modf(); + char *exponent(), *round(); +#endif + +#ifdef hp300 + if (expcnt = isspecial(number, startp, signp)) + return(expcnt); +#endif + + dotrim = expcnt = gformat = 0; + fract = modf(number, &integer); + + /* get an extra slot for rounding. */ + t = ++startp; + + /* + * get integer portion of number; put into the end of the buffer; the + * .01 is added for modf(356.0 / 10, &integer) returning .59999999... + */ + for (p = endp - 1; integer; ++expcnt) { + tmp = modf(integer / 10, &integer); + *p-- = tochar((int)((tmp + .01) * 10)); + } + switch(fmtch) { + case 'f': + /* reverse integer into beginning of buffer */ + if (expcnt) + for (; ++p < endp; *t++ = *p); + else + *t++ = '0'; + /* + * if precision required or alternate flag set, add in a + * decimal point. + */ + if (prec || flags&ALT) + *t++ = '.'; + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) + do { + fract = modf(fract * 10, &tmp); + *t++ = tochar((int)tmp); + } while (--prec && fract); + if (fract) + startp = round(fract, (int *)NULL, startp, + t - 1, (char)0, signp); + } + for (; prec--; *t++ = '0'); + break; + case 'e': + case 'E': +eformat: if (expcnt) { + *t++ = *++p; + if (prec || flags&ALT) + *t++ = '.'; + /* if requires more precision and some integer left */ + for (; prec && ++p < endp; --prec) + *t++ = *p; + /* + * if done precision and more of the integer component, + * round using it; adjust fract so we don't re-round + * later. + */ + if (!prec && ++p < endp) { + fract = 0; + startp = round((double)0, &expcnt, startp, + t - 1, *p, signp); + } + /* adjust expcnt for digit in front of decimal */ + --expcnt; + } + /* until first fractional digit, decrement exponent */ + else if (fract) { + /* adjust expcnt for digit in front of decimal */ + for (expcnt = -1;; --expcnt) { + fract = modf(fract * 10, &tmp); + if (tmp) + break; + } + *t++ = tochar((int)tmp); + if (prec || flags&ALT) + *t++ = '.'; + } + else { + *t++ = '0'; + if (prec || flags&ALT) + *t++ = '.'; + } + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) + do { + fract = modf(fract * 10, &tmp); + *t++ = tochar((int)tmp); + } while (--prec && fract); + if (fract) + startp = round(fract, &expcnt, startp, + t - 1, (char)0, signp); + } + /* if requires more precision */ + for (; prec--; *t++ = '0'); + + /* unless alternate flag, trim any g/G format trailing 0's */ + if (gformat && !(flags&ALT)) { + while (t > startp && *--t == '0'); + if (*t == '.') + --t; + ++t; + } + t = exponent(t, expcnt, fmtch); + break; + case 'g': + case 'G': + /* a precision of 0 is treated as a precision of 1. */ + if (!prec) + ++prec; + /* + * ``The style used depends on the value converted; style e + * will be used only if the exponent resulting from the + * conversion is less than -4 or greater than the precision.'' + * -- ANSI X3J11 + */ + if (expcnt > prec || (!expcnt && fract && fract < .0001)) { + /* + * g/G format counts "significant digits, not digits of + * precision; for the e/E format, this just causes an + * off-by-one problem, i.e. g/G considers the digit + * before the decimal point significant and e/E doesn't + * count it as precision. + */ + --prec; + fmtch -= 2; /* G->E, g->e */ + gformat = 1; + goto eformat; + } + /* + * reverse integer into beginning of buffer, + * note, decrement precision + */ + if (expcnt) + for (; ++p < endp; *t++ = *p, --prec); + else + *t++ = '0'; + /* + * if precision required or alternate flag set, add in a + * decimal point. If no digits yet, add in leading 0. + */ + if (prec || flags&ALT) { + dotrim = 1; + *t++ = '.'; + } + else + dotrim = 0; + /* if requires more precision and some fraction left */ + if (fract) { + if (prec) { + do { + fract = modf(fract * 10, &tmp); + *t++ = tochar((int)tmp); + } while(!tmp); + while (--prec && fract) { + fract = modf(fract * 10, &tmp); + *t++ = tochar((int)tmp); + } + } + if (fract) + startp = round(fract, (int *)NULL, startp, + t - 1, (char)0, signp); + } + /* alternate format, adds 0's for precision, else trim 0's */ + if (flags&ALT) + for (; prec--; *t++ = '0'); + else if (dotrim) { + while (t > startp && *--t == '0'); + if (*t != '.') + ++t; + } + } + return(t - startp); +} + +static char * +round(double fract, int *exp, register char *start, char *end, + char ch, char *signp) +{ + double tmp; +#ifndef linux + double modf(); +#endif + + if (fract) + (void)modf(fract * 10, &tmp); + else + tmp = todigit(ch); + if (tmp > 4) + for (;; --end) { + if (*end == '.') + --end; + if (++*end <= '9') + break; + *end = '0'; + if (end == start) { + if (exp) { /* e/E; increment exponent */ + *end = '1'; + ++*exp; + } + else { /* f; add extra digit */ + *--end = '1'; + --start; + } + break; + } + } + /* ``"%.3f", (double)-0.0004'' gives you a negative 0. */ + else if (*signp == '-') + for (;; --end) { + if (*end == '.') + --end; + if (*end != '0') + break; + if (end == start) + *signp = 0; + } + return(start); +} + +static char * +exponent(register char *p, register int exp, u_char fmtch) +{ + register char *t; + char expbuf[MAXEXP]; + + *p++ = fmtch; + if (exp < 0) { + exp = -exp; + *p++ = '-'; + } + else + *p++ = '+'; + t = expbuf + MAXEXP; + if (exp > 9) { + do { + *--t = tochar(exp % 10); + } while ((exp /= 10) > 9); + *--t = tochar(exp); + for (; t < expbuf + MAXEXP; *p++ = *t++); + } + else { + *p++ = '0'; + *p++ = tochar(exp); + } + return(p); +} + +#ifdef hp300 +isspecial(d, bufp, signp) + double d; + char *bufp, *signp; +{ + register struct IEEEdp { + unsigned sign:1; + unsigned exp:11; + unsigned manh:20; + unsigned manl:32; + } *ip = (struct IEEEdp *)&d; + + if (ip->exp != 0x7ff) + return(0); + if (ip->manh || ip->manl) + (void)strcpy(bufp, "NaN"); + else + (void)strcpy(bufp, "Inf"); + return(3); +} +#endif diff --git a/1/newlibc/stdio/doscan.c b/1/newlibc/stdio/doscan.c new file mode 100755 index 0000000..0fa29d9 --- /dev/null +++ b/1/newlibc/stdio/doscan.c @@ -0,0 +1,301 @@ +/* This is file DOSCAN.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#include +#include +#ifdef linux +#include +#endif + +#define SPC 01 +#define STP 02 + +#define SHORT 0 +#define REGULAR 1 +#define LONG 2 +#define INT 0 +#define FLOAT 1 + +#ifdef linux +static char *_getccl(const char *s); +static int _innum(int **ptr, int type, int len, int size, FILE *iop, + int *eofptr); +static int _instr( char *ptr, int type, int len, FILE *iop, + int *eofptr); +#else +static char *_getccl(unsigned char *s); +#endif + +static char _sctab[256] = { + 0,0,0,0,0,0,0,0, + 0,SPC,SPC,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0, + SPC,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, +}; + + +int +_doscan(FILE *iop, const char *fmt, void **argp) +{ + register int ch; + int nmatch, len, ch1; + int **ptr, fileended, size; + + nmatch = 0; + fileended = 0; + for (;;) switch (ch = *fmt++) { + case '\0': + return (nmatch); + case '%': + if ((ch = *fmt++) == '%') + goto def; + ptr = (void *)NULL; + if (ch != '*') + ptr = (int **) argp++; + else + ch = *fmt++; + len = 0; + size = REGULAR; + while (isdigit(ch)) { + len = len*10 + ch - '0'; + ch = *fmt++; + } + if (len == 0) + len = 30000; + if (ch=='l') { + size = LONG; + ch = *fmt++; + } else if (ch=='h') { + size = SHORT; + ch = *fmt++; + } else if (ch=='[') + fmt = _getccl(fmt); + if (isupper(ch)) { + ch = tolower(ch); + size = LONG; + } + if (ch == '\0') + return(-1); + if (_innum(ptr, ch, len, size, iop, &fileended) && ptr) + nmatch++; + if (fileended) + return(nmatch? nmatch: -1); + break; + + case ' ': + case '\n': + case '\t': + while ((ch1 = getc(iop))==' ' || ch1=='\t' || ch1=='\n') + ; + if (ch1 != EOF) + ungetc(ch1, iop); + break; + + default: + def: + ch1 = getc(iop); + if (ch1 != ch) { + if (ch1==EOF) + return(-1); + ungetc(ch1, iop); + return(nmatch); + } + } +} + +static int +_innum(int **ptr, int type, int len, int size, FILE *iop, int *eofptr) +{ +#ifndef linux + extern double atof(); +#endif + register char *np; + char numbuf[64]; + register c, base; + int expseen, scale, negflg, c1, ndigit; + long lcval; + + if (type=='c' || type=='s' || type=='[') + return(_instr(ptr? *(char **)ptr: (char *)NULL, type, len, iop, eofptr)); + lcval = 0; + ndigit = 0; + scale = INT; + if (type=='e'||type=='f') + scale = FLOAT; + base = 10; + if (type=='o') + base = 8; + else if (type=='x') + base = 16; + np = numbuf; + expseen = 0; + negflg = 0; + while ((c = getc(iop))==' ' || c=='\t' || c=='\n'); + if (c=='-') { + negflg++; + *np++ = c; + c = getc(iop); + len--; + } else if (c=='+') { + len--; + c = getc(iop); + } + for ( ; --len>=0; *np++ = c, c = getc(iop)) { + if (isdigit(c) + || (base==16 && (('a'<=c && c<='f') || ('A'<=c && c<='F')))) { + ndigit++; + if (base==8) + lcval <<=3; + else if (base==10) + lcval = ((lcval<<2) + lcval)<<1; + else + lcval <<= 4; + c1 = c; + if (isdigit(c)) + c -= '0'; + else if ('a'<=c && c<='f') + c -= 'a'-10; + else + c -= 'A'-10; + lcval += c; + c = c1; + continue; + } else if (c=='.') { + if (base!=10 || scale==INT) + break; + ndigit++; + continue; + } else if ((c=='e'||c=='E') && expseen==0) { + if (base!=10 || scale==INT || ndigit==0) + break; + expseen++; + *np++ = c; + c = getc(iop); + if (c!='+'&&c!='-'&&('0'>c||c>'9')) + break; + } else + break; + } + if (negflg) + lcval = -lcval; + if (c != EOF) { + ungetc(c, iop); + *eofptr = 0; + } else + *eofptr = 1; + if (ptr==NULL || np==numbuf || (negflg && np==numbuf+1) )/* gene dykes*/ + return(0); + *np++ = 0; + switch((scale<<4) | size) { + + case (FLOAT<<4) | SHORT: + case (FLOAT<<4) | REGULAR: + **(float **)ptr = atof(numbuf); + break; + + case (FLOAT<<4) | LONG: + **(double **)ptr = atof(numbuf); + break; + + case (INT<<4) | SHORT: + **(short **)ptr = lcval; + break; + + case (INT<<4) | REGULAR: + **(int **)ptr = lcval; + break; + + case (INT<<4) | LONG: + **(long **)ptr = lcval; + break; + } + return(1); +} + +static int +_instr(char *ptr, int type, int len, FILE *iop, int *eofptr) +{ + register ch; + register char *optr; + int ignstp; + + *eofptr = 0; + optr = ptr; + if (type=='c' && len==30000) + len = 1; + ignstp = 0; + if (type=='s') + ignstp = SPC; + while ((ch = getc(iop)) != EOF && _sctab[ch] & ignstp) + ; + ignstp = SPC; + if (type=='c') + ignstp = 0; + else if (type=='[') + ignstp = STP; + while (ch!=EOF && (_sctab[ch]&ignstp)==0) { + if (ptr) + *ptr++ = ch; + if (--len <= 0) + break; + ch = getc(iop); + } + if (ch != EOF) { + if (len > 0) + ungetc(ch, iop); + *eofptr = 0; + } else + *eofptr = 1; + if (ptr && ptr!=optr) { + if (type!='c') + *ptr++ = '\0'; + return(1); + } + return(0); +} + +static char * +_getccl(register const char *s) +{ + register c, t; + + t = 0; + if (*s == '^') { + t++; + s++; + } + for (c = 0; c < (sizeof (_sctab) / sizeof (_sctab[0])); c++) + if (t) + _sctab[c] &= ~STP; + else + _sctab[c] |= STP; + if ((c = *s) == ']' || c == '-') { /* first char is special */ + if (t) + _sctab[c] |= STP; + else + _sctab[c] &= ~STP; + s++; + } + while ((c = *s++) != ']') { + if (c==0) + return((char *)--s); + else if (c == '-' && *s != ']' && s[-2] < *s) { + for (c = s[-2] + 1; c < *s; c++) + if (t) + _sctab[c] |= STP; + else + _sctab[c] &= ~STP; + } else if (t) + _sctab[c] |= STP; + else + _sctab[c] &= ~STP; + } + return((char *)s); +} diff --git a/1/newlibc/stdio/fdopen.c b/1/newlibc/stdio/fdopen.c new file mode 100755 index 0000000..c66308a --- /dev/null +++ b/1/newlibc/stdio/fdopen.c @@ -0,0 +1,93 @@ +/* This is file FDOPEN.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fdopen.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +/* + * Unix routine to do an "fopen" on file descriptor + * The mode has to be repeated because you can't query its + * status + */ + +#include +#include +#include + +#ifdef linux +#include +#endif + +extern FILE *_findiop(); + +FILE * +fdopen(int fd, const char *mode) +{ + static int nofile = -1; + register FILE *iop; +#ifndef linux + int new_mode = _fmode; +#endif + + if (nofile < 0) + nofile = getdtablesize(); + + if (fd < 0 || fd >= nofile) + return (NULL); + + iop = _findiop(); + if (iop == NULL) + return (NULL); + + iop->_cnt = 0; + iop->_file = fd; + iop->_bufsiz = 0; + iop->_base = iop->_ptr = NULL; + + switch (*mode) { + case 'r': + iop->_flag = _IOREAD; + break; + case 'a': + lseek(fd, (off_t)0, L_XTND); + /* fall into ... */ + case 'w': + iop->_flag = _IOWRT; + break; + default: + return (NULL); + } + +#ifdef linux + if (mode[1] == '+') + iop->_flag = _IORW; +#else + if (mode[1] == '+') + { + iop->_flag = _IORW; + mode++; + } + if (mode[1] == 't') + { + iop->_flag |= _IOTEXT; + new_mode = O_TEXT; + } + if (mode[1] == 'b') + { + new_mode = O_BINARY; + } + setmode(fd, new_mode); +#endif + + return (iop); +} diff --git a/1/newlibc/stdio/fgetc.c b/1/newlibc/stdio/fgetc.c new file mode 100755 index 0000000..73ca8e9 --- /dev/null +++ b/1/newlibc/stdio/fgetc.c @@ -0,0 +1,18 @@ +/* This is file FGETC.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fgetc.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include + +int +fgetc(fp) +FILE *fp; +{ + return(getc(fp)); +} diff --git a/1/newlibc/stdio/fgets.c b/1/newlibc/stdio/fgets.c new file mode 100755 index 0000000..04b7af3 --- /dev/null +++ b/1/newlibc/stdio/fgets.c @@ -0,0 +1,29 @@ +/* This is file FGETS.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fgets.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include + +char * +fgets(char *s, int n, register FILE *iop) +{ + register c; + register char *cs; + + cs = s; + while (--n>0 && (c = getc(iop)) != EOF) { + *cs++ = c; + if (c=='\n') + break; + } + if (c == EOF && cs==s) + return(NULL); + *cs++ = '\0'; + return(s); +} diff --git a/1/newlibc/stdio/filbuf.c b/1/newlibc/stdio/filbuf.c new file mode 100755 index 0000000..15d7b7f --- /dev/null +++ b/1/newlibc/stdio/filbuf.c @@ -0,0 +1,87 @@ +/* This is file FILBUF.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)filbuf.c 5.3 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include +#include +#include +#ifdef linux +#include +#include +#endif + +extern char *_smallbuf; + +int +_filbuf(iop) +register FILE *iop; +{ + int size; +#ifndef linux + struct stat stbuf; +#endif + char c; + + if (iop->_flag & _IORW) + iop->_flag |= _IOREAD; + + if ((iop->_flag&_IOREAD) == 0) + return(EOF); + if (iop->_flag&(_IOSTRG|_IOEOF)) + return(EOF); +tryagain: + if (iop->_base==NULL) { + if (iop->_flag&_IONBF) { + iop->_base = _smallbuf ? &_smallbuf[fileno(iop)] : &c; + goto tryagain; + } +#ifdef linux + size = BUFSIZ; +#else + if (fstat(fileno(iop), &stbuf) < 0 || stbuf.st_blksize <= NULL) + size = BUFSIZ; + else + size = stbuf.st_blksize; +#endif + if ((iop->_base = malloc(size)) == NULL) { + iop->_flag |= _IONBF; + goto tryagain; + } + iop->_flag |= _IOMYBUF; + iop->_bufsiz = size; + } + if (iop == stdin) { + if (stdout->_flag&_IOLBF) + fflush(stdout); + if (stderr->_flag&_IOLBF) + fflush(stderr); + } + iop->_cnt = read(fileno(iop), iop->_base, + iop->_flag & _IONBF ? 1 : iop->_bufsiz); + iop->_ptr = iop->_base; + if (iop->_flag & _IONBF && iop->_base == &c) + iop->_base = NULL; + if (--iop->_cnt < 0) { + if (iop->_cnt == -1) { + iop->_flag |= _IOEOF; + if (iop->_flag & _IORW) + iop->_flag &= ~_IOREAD; + } else + iop->_flag |= _IOERR; + iop->_cnt = 0; + return(EOF); + } + return(*iop->_ptr++&0377); +} diff --git a/1/newlibc/stdio/findiop.c b/1/newlibc/stdio/findiop.c new file mode 100755 index 0000000..6577965 --- /dev/null +++ b/1/newlibc/stdio/findiop.c @@ -0,0 +1,148 @@ +/* This is file FINDIOP.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1983, 1985 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)findiop.c 5.7 (Berkeley) 9/22/88"; +#endif LIBC_SCCS and not lint + +#include +#include + +#ifdef linux +#include + +#define NSTATIC OPEN_MAX /* stdin + stdout + stderr + the usual */ + +FILE _iob[NSTATIC] = { + { 0, NULL, NULL, 0, _IOREAD, 0}, /* stdin */ + { 0, NULL, NULL, 0, _IOWRT, 1}, /* stdout */ + { 0, NULL, NULL, 0, _IOWRT|_IONBF, 2}, /* stderr */ +}; + +#else + +extern void *calloc(); + +#define NSTATIC 20 /* stdin + stdout + stderr + the usual */ + +FILE _iob[NSTATIC] = { + { 0, NULL, NULL, 0, _IOREAD|_IOTEXT, 0 }, /* stdin */ + { 0, NULL, NULL, 0, _IOWRT|_IOTEXT, 1 }, /* stdout */ + { 0, NULL, NULL, 0, _IOWRT|_IONBF|_IOTEXT,2 }, /* stderr */ +}; + +#endif + +#define active(iop) ((iop)->_flag & (_IOREAD|_IOWRT|_IORW)) + +extern int errno; + +static int _f_morefiles(); + +static char sbuf[NSTATIC]; +char *_smallbuf = sbuf; +static FILE **iobglue = NULL; +static FILE **endglue = NULL; + +/* + * Find a free FILE for fopen et al. + * We have a fixed static array of entries, and in addition + * may allocate additional entries dynamically, up to the kernel + * limit on the number of open files. + * At first just check for a free slot in the fixed static array. + * If none are available, then we allocate a structure to glue together + * the old and new FILE entries, which are then no longer contiguous. + */ +FILE * +_findiop() +{ + register FILE **iov, *iop; + + if (iobglue == 0) { + for (iop = _iob; iop < _iob + NSTATIC; iop++) + if (!active(iop)) + return (iop); + + if (_f_morefiles() == 0) { + errno = ENOMEM; + return (NULL); + } + } + + iov = iobglue; + while (*iov != NULL && active(*iov)) + if (++iov >= endglue) { + errno = EMFILE; + return (NULL); + } + + if (*iov == NULL) + *iov = (FILE *)calloc(1, sizeof (FILE)); + + return (*iov); +} + +static int +_f_morefiles() +{ + register FILE **iov; + register FILE *fp; + int nfiles; + + nfiles = getdtablesize(); + + iobglue = (FILE **)calloc(nfiles, sizeof (FILE *)); + if (iobglue == NULL) + return (0); + + endglue = iobglue + nfiles; + + for (fp = _iob, iov = iobglue; fp < &_iob[NSTATIC]; /* void */) + *iov++ = fp++; + + _smallbuf = calloc(nfiles, sizeof(*_smallbuf)); + return (1); +} + +#ifndef linux +void +f_prealloc() +{ + register FILE **iov; + + if (iobglue == NULL && _f_morefiles() == 0) + return; + + for (iov = iobglue; iov < endglue; iov++) + if (*iov == NULL) + *iov = (FILE *)calloc(1, sizeof (FILE)); +} +#endif + + +void +_fwalk(function) + register int (*function)(); +{ + register FILE **iov; + register FILE *fp; + + if (iobglue == NULL) { + for (fp = _iob; fp < &_iob[NSTATIC]; fp++) + if (active(fp)) + (*function)(fp); + } else { + for (iov = iobglue; iov < endglue; iov++) + if (*iov && active(*iov)) + (*function)(*iov); + } +} diff --git a/1/newlibc/stdio/flsbuf.c b/1/newlibc/stdio/flsbuf.c new file mode 100755 index 0000000..82256da --- /dev/null +++ b/1/newlibc/stdio/flsbuf.c @@ -0,0 +1,170 @@ +/* This is file FLSBUF.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)flsbuf.c 5.5 (Berkeley) 6/18/90"; +#endif LIBC_SCCS and not lint + +#include +#include + +#ifdef linux +#include +#include + +extern int isatty (int); +extern void _fwalk(int (*) ()); + +#else +#include +char *malloc(); +#endif + + +int +_flsbuf(unsigned int c, register FILE *iop) +{ + register char *base; + register n, rn; + char c1; + int size; +#ifndef linux + struct stat stbuf; +#endif + + if (iop->_flag & _IORW) { + iop->_flag |= _IOWRT; + iop->_flag &= ~(_IOEOF|_IOREAD); + } + + if ((iop->_flag&_IOWRT)==0) + return(EOF); +tryagain: + if (iop->_flag&_IOLBF) { + base = iop->_base; + *iop->_ptr++ = c; + if ((rn = iop->_ptr - base) >= iop->_bufsiz || c == '\n') { + iop->_ptr = base; + iop->_cnt = 0; + } else { + /* we got here because _cnt is wrong, so fix it */ + iop->_cnt = -rn; + rn = n = 0; + } + } else if (iop->_flag&_IONBF) { + c1 = c; + rn = 1; + base = &c1; + iop->_cnt = 0; + } else { + if ((base=iop->_base)==NULL) { +#ifdef linux + size = BUFSIZ; +#else + if (fstat(fileno(iop), &stbuf) < 0 || + stbuf.st_blksize <= NULL) + size = BUFSIZ; + else + size = stbuf.st_blksize; +#endif + if ((iop->_base=base=malloc(size)) == NULL) { + iop->_flag |= _IONBF; + goto tryagain; + } + iop->_flag |= _IOMYBUF; + iop->_bufsiz = size; + if (iop==stdout && isatty(fileno(stdout))) { + iop->_flag |= _IOLBF; + iop->_ptr = base; + goto tryagain; + } + rn = n = 0; + } else + rn = iop->_ptr - base; + iop->_ptr = base; + iop->_cnt = iop->_bufsiz; + } + while (rn > 0) { + n = write(fileno(iop), base, rn); + if (n <= 0) { + iop->_flag |= _IOERR; + return(EOF); + } + rn -= n; + base += n; + } + if ((iop->_flag&(_IOLBF|_IONBF)) == 0) { + iop->_cnt--; + *iop->_ptr++ = c; + } + return(c); +} + +int +fpurge(register FILE *iop) +{ + iop->_ptr = iop->_base; + iop->_cnt = iop->_flag&(_IOLBF|_IONBF|_IOREAD) ? 0 : iop->_bufsiz; + return(0); +} + +int +fflush(register FILE *iop) +{ + register char *base; + register n, rn; + + if ((iop->_flag&(_IONBF|_IOWRT))==_IOWRT && + (base = iop->_base) != NULL && (rn = n = iop->_ptr - base) > 0) { + iop->_ptr = base; + iop->_cnt = (iop->_flag&(_IOLBF|_IONBF)) ? 0 : iop->_bufsiz; + do { + n = write(fileno(iop), base, rn); + if (n <= 0) { + iop->_flag |= _IOERR; + return(EOF); + } + rn -= n; + base += n; + } while (rn > 0); + } + return(0); +} + +int +fclose(register FILE *iop) +{ + register int r; + + r = EOF; + if (iop->_flag&(_IOREAD|_IOWRT|_IORW) && (iop->_flag&_IOSTRG)==0) { + r = fflush(iop); + if (close(fileno(iop)) < 0) + r = EOF; + if (iop->_flag&_IOMYBUF) + free(iop->_base); + } + iop->_cnt = 0; + iop->_base = (char *)NULL; + iop->_ptr = (char *)NULL; + iop->_bufsiz = 0; + iop->_flag = 0; + iop->_file = 0; + return(r); +} + +void +_cleanup() +{ + + _fwalk(fclose); +} diff --git a/1/newlibc/stdio/fopen.c b/1/newlibc/stdio/fopen.c new file mode 100755 index 0000000..38e1247 --- /dev/null +++ b/1/newlibc/stdio/fopen.c @@ -0,0 +1,92 @@ +/* This is file FOPEN.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fopen.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include +#include +#include + +#ifdef linux +#include +#endif + +extern FILE *_findiop(); + +FILE * +fopen(const char *file, register const char *mode) +{ + register FILE *iop; + register f, rw, oflags; +#ifndef linux + char tbchar; +#endif + + iop = _findiop(); + if (iop == NULL) + return (NULL); + + rw = (mode[1] == '+'); + + switch (*mode) { + case 'a': + oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + case 'r': + oflags = rw ? O_RDWR : O_RDONLY; + break; + case 'w': + oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + default: + return (NULL); + } + +#ifndef linux + if (mode[1] == '+') + tbchar = mode[2]; + else + tbchar = mode[1]; + if (tbchar == 't') + oflags |= O_TEXT; + else if (tbchar == 'b') + oflags |= O_BINARY; + else + oflags |= (_fmode & (O_TEXT|O_BINARY)); +#endif + + f = open(file, oflags, 0666); + if (f < 0) + return (NULL); + + if (*mode == 'a') + lseek(f, (off_t)0, L_XTND); + + iop->_cnt = 0; + iop->_file = f; + iop->_bufsiz = 0; + if (rw) + iop->_flag = _IORW; + else if (*mode == 'r') + iop->_flag = _IOREAD; + else + iop->_flag = _IOWRT; +#ifndef linux + if (oflags & O_TEXT) + iop->_flag |= _IOTEXT; +#endif + + iop->_base = iop->_ptr = NULL; + return (iop); +} diff --git a/1/newlibc/stdio/fprintf.c b/1/newlibc/stdio/fprintf.c new file mode 100755 index 0000000..2bae850 --- /dev/null +++ b/1/newlibc/stdio/fprintf.c @@ -0,0 +1,59 @@ +/* This is file FPRINTF.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fprintf.c 5.5 (Berkeley) 6/1/90"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +int +fprintf(register FILE *iop, const char *fmt, ...) +{ + va_list ap; + int len; + char localbuf[BUFSIZ]; + + va_start (ap, fmt); + if (iop->_flag & _IONBF) { + iop->_flag &= ~_IONBF; + iop->_ptr = iop->_base = localbuf; + iop->_bufsiz = BUFSIZ; + len = _doprnt(fmt, ap, iop); + fflush(iop); + iop->_flag |= _IONBF; + iop->_base = NULL; +#ifdef linux + iop->_bufsiz = 0; +#else + iop->_bufsiz = NULL; +#endif + iop->_cnt = 0; + } else + len = _doprnt(fmt, ap, iop); + va_end (ap); + return(ferror(iop) ? EOF : len); +} diff --git a/1/newlibc/stdio/fputc.c b/1/newlibc/stdio/fputc.c new file mode 100755 index 0000000..7621e0f --- /dev/null +++ b/1/newlibc/stdio/fputc.c @@ -0,0 +1,17 @@ +/* This is file FPUTC.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fputc.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include + +int +fputc(int c, register FILE *fp) +{ + return(putc(c, fp)); +} diff --git a/1/newlibc/stdio/fputs.c b/1/newlibc/stdio/fputs.c new file mode 100755 index 0000000..e3591d1 --- /dev/null +++ b/1/newlibc/stdio/fputs.c @@ -0,0 +1,50 @@ +/* This is file FPUTS.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1984 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fputs.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include + +int +fputs(register const char *s, register FILE *iop) +{ + register r = 0; + register c; + int unbuffered; + char localbuf[BUFSIZ]; + + unbuffered = iop->_flag & _IONBF; + if (unbuffered) { + iop->_flag &= ~_IONBF; + iop->_ptr = iop->_base = localbuf; + iop->_bufsiz = BUFSIZ; + } + + while (c = *s++) + r = putc(c, iop); + + if (unbuffered) { + fflush(iop); + iop->_flag |= _IONBF; + iop->_base = NULL; +#ifdef linux + iop->_bufsiz = 0; +#else + iop->_bufsiz = NULL; +#endif + iop->_cnt = 0; + } + + return(r); +} diff --git a/1/newlibc/stdio/fread.c b/1/newlibc/stdio/fread.c new file mode 100755 index 0000000..eee6f92 --- /dev/null +++ b/1/newlibc/stdio/fread.c @@ -0,0 +1,56 @@ +/* This is file FREAD.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fread.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include +#ifdef linux +#include +#endif + +int +fread(ptr, size, count, iop) + register void *ptr; + int size, count; + register FILE *iop; +{ + register int s; + int c; + + s = size * count; + while (s > 0) { + if (iop->_cnt < s) { + if (iop->_cnt > 0) { + bcopy(iop->_ptr, ptr, iop->_cnt); + ptr += iop->_cnt; + s -= iop->_cnt; + } + /* + * filbuf clobbers _cnt & _ptr, + * so don't waste time setting them. + */ + if ((c = _filbuf(iop)) == EOF) + break; + *(char *)ptr++ = c; + s--; + } + if (iop->_cnt >= s) { + bcopy(iop->_ptr, ptr, s); + iop->_ptr += s; + iop->_cnt -= s; + return (count); + } + } + return (size != 0 ? count - ((s + size - 1) / size) : 0); +} diff --git a/1/newlibc/stdio/freopen.c b/1/newlibc/stdio/freopen.c new file mode 100755 index 0000000..61fc22d --- /dev/null +++ b/1/newlibc/stdio/freopen.c @@ -0,0 +1,89 @@ +/* This is file FREOPEN.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)freopen.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include +#include +#include + +#ifdef linux +#include +#endif + +FILE * +freopen(const char *file, register const char *mode, + register FILE *iop) +{ + register f, rw, oflags; +#ifndef linux + char tbchar; +#endif + + rw = (mode[1] == '+'); + + fclose(iop); + + switch (*mode) { + case 'a': + oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + case 'r': + oflags = rw ? O_RDWR : O_RDONLY; + break; + case 'w': + oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY); + break; + default: + return (NULL); + } + +#ifndef linux + if (mode[1] == '+') + tbchar = mode[2]; + else + tbchar = mode[1]; + if (tbchar == 't') + oflags |= O_TEXT; + else if (tbchar == 'b') + oflags |= O_BINARY; + else + oflags |= (_fmode & (O_TEXT|O_BINARY)); +#endif + + f = open(file, oflags, 0666); + if (f < 0) + return (NULL); + + if (*mode == 'a') + lseek(f, (off_t)0, L_XTND); + + iop->_cnt = 0; + iop->_file = f; + iop->_bufsiz = 0; + if (rw) + iop->_flag = _IORW; + else if (*mode == 'r') + iop->_flag = _IOREAD; + else + iop->_flag = _IOWRT; + +#ifndef linux + if (oflags & O_TEXT) + iop->_flag |= _IOTEXT; +#endif + + iop->_base = iop->_ptr = NULL; + return (iop); +} diff --git a/1/newlibc/stdio/fseek.c b/1/newlibc/stdio/fseek.c new file mode 100755 index 0000000..9f230d6 --- /dev/null +++ b/1/newlibc/stdio/fseek.c @@ -0,0 +1,70 @@ +/* This is file FSEEK.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fseek.c 5.3 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +/* + * Seek for standard library. Coordinates with buffering. + */ + +#include +#ifdef linux +#include +#endif + +int +fseek(register FILE *iop, long offset, int ptrname) +{ + register resync, c; + long p = -1; /* can't happen? */ + + iop->_flag &= ~_IOEOF; + if (iop->_flag&_IOREAD) { + if (ptrname<2 && iop->_base && + !(iop->_flag&_IONBF)) { + c = iop->_cnt; + p = offset; + if (ptrname==0) { + long curpos = lseek(fileno(iop), 0L, 1); + if (curpos == -1) + return (-1); + p += c - curpos; + } else + offset -= c; + if(!(iop->_flag&_IORW) && c>0&&p<=c + && p>=iop->_base-iop->_ptr){ + iop->_ptr += (int)p; + iop->_cnt -= (int)p; + return(0); + } + resync = offset&01; + } else + resync = 0; + if (iop->_flag & _IORW) { + iop->_ptr = iop->_base; + iop->_flag &= ~_IOREAD; + resync = 0; + } + p = lseek(fileno(iop), offset-resync, ptrname); + iop->_cnt = 0; + if (resync && p != -1) + if (getc(iop) == EOF) + p = -1; + } + else if (iop->_flag & (_IOWRT|_IORW)) { + p = fflush(iop); + if (iop->_flag & _IORW) { + iop->_cnt = 0; + iop->_flag &= ~_IOWRT; + iop->_ptr = iop->_base; + } + return(lseek(fileno(iop), offset, ptrname) == -1 || p == EOF ? + -1 : 0); + } + return(p==-1?-1:0); +} diff --git a/1/newlibc/stdio/ftell.c b/1/newlibc/stdio/ftell.c new file mode 100755 index 0000000..2aeb68f --- /dev/null +++ b/1/newlibc/stdio/ftell.c @@ -0,0 +1,62 @@ +/* This is file FTELL.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)ftell.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +/* + * Return file offset. + * Coordinates with buffering. + */ + +#include +#ifdef linux +#include +#endif + +long ftell(iop) +register FILE *iop; +{ + register long tres; + register adjust; +#ifndef linux + int idx; +#endif + + if (iop->_cnt < 0) + iop->_cnt = 0; + if (iop->_flag&_IOREAD) + { + adjust = - iop->_cnt; +#ifndef linux + if (iop->_flag & _IOTEXT) /* if a text file */ + for (idx=-adjust-1; idx>=0; idx--) /* for every char in buf */ + if (iop->_ptr[idx] == '\n') /* if it's LF */ + adjust--; /* there was a CR also */ +#endif + } + else if (iop->_flag&(_IOWRT|_IORW)) { + adjust = 0; + if (iop->_flag&_IOWRT && iop->_base && (iop->_flag&_IONBF)==0) + { + adjust = iop->_ptr - iop->_base; +#ifndef linux + if (iop->_flag & _IOTEXT) + for (idx=0; idx_base[idx] == '\n') + adjust++; +#endif + } + } else + return(-1); + + tres = lseek(fileno(iop), 0L, 1); + if (tres<0) + return(tres); + tres += adjust; + return(tres); +} diff --git a/1/newlibc/stdio/fwrite.c b/1/newlibc/stdio/fwrite.c new file mode 100755 index 0000000..dbce33b --- /dev/null +++ b/1/newlibc/stdio/fwrite.c @@ -0,0 +1,60 @@ +/* This is file FWRITE.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)fwrite.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include + +#ifdef linux +#include +#endif + +int +fwrite(ptr, size, count, iop) + register const void *ptr; + int size, count; + register FILE *iop; +{ + register int s; + + s = size * count; + if (iop->_flag & _IOLBF) + while (s > 0) { + if (--iop->_cnt > -iop->_bufsiz && *(char *)ptr != '\n') + *iop->_ptr++ = *(char *)ptr++; + else if (_flsbuf(*(unsigned int *)ptr++, iop) == EOF) + break; + s--; + } + else while (s > 0) { + if (iop->_cnt < s) { + if (iop->_cnt > 0) { + bcopy(ptr, iop->_ptr, iop->_cnt); + ptr += iop->_cnt; + iop->_ptr += iop->_cnt; + s -= iop->_cnt; + } + if (_flsbuf(*(unsigned int *)ptr++, iop) == EOF) + break; + s--; + } + if (iop->_cnt >= s) { + bcopy(ptr, iop->_ptr, s); + iop->_ptr += s; + iop->_cnt -= s; + return (count); + } + } + return (size != 0 ? count - ((s + size - 1) / size) : 0); +} diff --git a/1/newlibc/stdio/getchar.c b/1/newlibc/stdio/getchar.c new file mode 100755 index 0000000..ac960ab --- /dev/null +++ b/1/newlibc/stdio/getchar.c @@ -0,0 +1,22 @@ +/* This is file GETCHAR.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)getchar.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +/* + * A subroutine version of the macro getchar. + */ +#include + +#undef getchar + +int +getchar() +{ + return(getc(stdin)); +} diff --git a/1/newlibc/stdio/gets.c b/1/newlibc/stdio/gets.c new file mode 100755 index 0000000..e6045c1 --- /dev/null +++ b/1/newlibc/stdio/gets.c @@ -0,0 +1,27 @@ +/* This is file GETS.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)gets.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include + +char * +gets(s) +char *s; +{ + register c; + register char *cs; + + cs = s; + while ((c = getchar()) != '\n' && c != EOF) + *cs++ = c; + if (c == EOF && cs==s) + return(NULL); + *cs++ = '\0'; + return(s); +} diff --git a/1/newlibc/stdio/getw.c b/1/newlibc/stdio/getw.c new file mode 100755 index 0000000..8bc4370 --- /dev/null +++ b/1/newlibc/stdio/getw.c @@ -0,0 +1,27 @@ +/* This is file GETW.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)getw.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include + +int +getw(iop) +register FILE *iop; +{ + register i; + register char *p; + int w; + + p = (char *)&w; + for (i=sizeof(int); --i>=0;) + *p++ = getc(iop); + if (feof(iop)) + return(EOF); + return(w); +} diff --git a/1/newlibc/stdio/printf.c b/1/newlibc/stdio/printf.c new file mode 100755 index 0000000..fdbe1c9 --- /dev/null +++ b/1/newlibc/stdio/printf.c @@ -0,0 +1,43 @@ +/* This is file PRINTF.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)printf.c 5.5 (Berkeley) 6/1/90"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +int +printf(const char *fmt, ...) +{ + va_list ap; + int len; + + va_start (ap, fmt); + len = _doprnt(fmt, ap, stdout); + va_end (ap); + return(ferror(stdout) ? EOF : len); +} diff --git a/1/newlibc/stdio/putchar.c b/1/newlibc/stdio/putchar.c new file mode 100755 index 0000000..ed49a5c --- /dev/null +++ b/1/newlibc/stdio/putchar.c @@ -0,0 +1,23 @@ +/* This is file PUTCHAR.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)putchar.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +/* + * A subroutine version of the macro putchar + */ +#include + +#undef putchar + +int +putchar(c) +register c; +{ + return (putc(c, stdout)); +} diff --git a/1/newlibc/stdio/puts.c b/1/newlibc/stdio/puts.c new file mode 100755 index 0000000..3fbf0fb --- /dev/null +++ b/1/newlibc/stdio/puts.c @@ -0,0 +1,22 @@ +/* This is file PUTS.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)puts.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include + +int +puts(s) +register const char *s; +{ + register c; + + while (c = *s++) + putchar(c); + return(putchar('\n')); +} diff --git a/1/newlibc/stdio/putw.c b/1/newlibc/stdio/putw.c new file mode 100755 index 0000000..bddd227 --- /dev/null +++ b/1/newlibc/stdio/putw.c @@ -0,0 +1,23 @@ +/* This is file PUTW.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)putw.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include + +int +putw(int w, register FILE *iop) +{ + register char *p; + register i; + + p = (char *)&w; + for (i=sizeof(int); --i>=0;) + putc(*p++, iop); + return(ferror(iop)); +} diff --git a/1/newlibc/stdio/rew.c b/1/newlibc/stdio/rew.c new file mode 100755 index 0000000..11c375e --- /dev/null +++ b/1/newlibc/stdio/rew.c @@ -0,0 +1,47 @@ +/* This is file REW.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)rew.c 5.5 (Berkeley) 6/1/90"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include +#include + +void +rewind(iop) + register FILE *iop; +{ + off_t lseek(); + + (void)fflush(iop); + (void)lseek(fileno(iop), 0L, L_SET); + iop->_cnt = 0; + iop->_ptr = iop->_base; + iop->_flag &= ~(_IOERR|_IOEOF); + if (iop->_flag & _IORW) + iop->_flag &= ~(_IOREAD|_IOWRT); +} diff --git a/1/newlibc/stdio/scanf.c b/1/newlibc/stdio/scanf.c new file mode 100755 index 0000000..cbc9a1f --- /dev/null +++ b/1/newlibc/stdio/scanf.c @@ -0,0 +1,56 @@ +/* This is file SCANF.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)scanf.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include +#include + +int +scanf(const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start (ap, fmt); + ret = _doscan(stdin, fmt, (void **) ap); + va_end (ap); + return(ret); +} + +int +fscanf(FILE *iop, const char *fmt, ...) +{ + va_list ap; + int ret; + + va_start (ap, fmt); + ret = _doscan(iop, fmt, (void **) ap); + va_end (ap); + return(ret); +} + +int +sscanf(char *str, const char *fmt, ...) +{ + va_list ap; + int ret; + FILE _strbuf; + + _strbuf._flag = _IOREAD|_IOSTRG; + _strbuf._ptr = _strbuf._base = str; + _strbuf._cnt = 0; + while (*str++) + _strbuf._cnt++; + _strbuf._bufsiz = _strbuf._cnt; + + va_start (ap, fmt); + ret = _doscan(&_strbuf, fmt, (void **) ap); + va_end (ap); + return(ret); +} diff --git a/1/newlibc/stdio/setbuf.c b/1/newlibc/stdio/setbuf.c new file mode 100755 index 0000000..8aafded --- /dev/null +++ b/1/newlibc/stdio/setbuf.c @@ -0,0 +1,42 @@ +/* This is file SETBUF.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)setbuf.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include +#ifdef linux +#include +#endif + +void +setbuf(iop, buf) +register FILE *iop; +char *buf; +{ + if (iop->_base != NULL && iop->_flag&_IOMYBUF) + free(iop->_base); + iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF); + if ((iop->_base = buf) == NULL) { + iop->_flag |= _IONBF; +#ifdef linux + iop->_bufsiz = 0; +#else + iop->_bufsiz = NULL; +#endif + } else { + iop->_ptr = iop->_base; + iop->_bufsiz = BUFSIZ; + } + iop->_cnt = 0; +} diff --git a/1/newlibc/stdio/setbuffe.c b/1/newlibc/stdio/setbuffe.c new file mode 100755 index 0000000..8c68010 --- /dev/null +++ b/1/newlibc/stdio/setbuffe.c @@ -0,0 +1,62 @@ +/* This is file SETBUFFE.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)setbuffer.c 5.2 (Berkeley) 3/9/86"; +#endif LIBC_SCCS and not lint + +#include + +#ifdef linux +#include +#endif + +void +setbuffer(iop, buf, size) + register FILE *iop; + char *buf; + int size; +{ + if (iop->_base != NULL && iop->_flag&_IOMYBUF) + free(iop->_base); + iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF); + if ((iop->_base = buf) == NULL) { + iop->_flag |= _IONBF; +#ifdef linux + iop->_bufsiz = 0; +#else + iop->_bufsiz = NULL; +#endif + } else { + iop->_ptr = iop->_base; + iop->_bufsiz = size; + } + iop->_cnt = 0; +} + +/* + * set line buffering for either stdout or stderr + */ +void +setlinebuf(iop) + register FILE *iop; +{ + char *buf; + + fflush(iop); + setbuffer(iop, NULL, 0); + buf = (char *) malloc(BUFSIZ); + if (buf != NULL) { + setbuffer(iop, buf, BUFSIZ); + iop->_flag |= _IOLBF|_IOMYBUF; + } +} diff --git a/1/newlibc/stdio/setvbuf.c b/1/newlibc/stdio/setvbuf.c new file mode 100755 index 0000000..f56207c --- /dev/null +++ b/1/newlibc/stdio/setvbuf.c @@ -0,0 +1,54 @@ +/* This is file SETVBUF.C */ +/* +** Copyright (C) 1991 DJ Delorie, 24 Kirsten Ave, Rochester NH 03867-2954 +** +** This file is distributed under the terms listed in the document +** "copying.dj", available from DJ Delorie at the address above. +** A copy of "copying.dj" should accompany this file; if not, a copy +** should be available from where this file was obtained. This file +** may not be distributed without a verbatim copy of "copying.dj". +** +** This file is distributed WITHOUT ANY WARRANTY; without even the implied +** warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +*/ + +#include + +#ifdef linux +#include +#endif + +int setvbuf(FILE *f, char *buf, int type, int len) +{ + int mine=0; + if (!f) + return -1; + fflush(f); + switch (type) + { + case _IOFBF: + case _IOLBF: + if (len <= 0) + return -1; + if (buf == 0) + { + buf = (char *)malloc(len); + if (buf == 0) + return -1; + mine = 1; + } + setbuffer(f, NULL, 0); + f->_flag &= ~_IONBF; + f->_flag |= type; + if (mine) + f->_flag |= _IOMYBUF; + f->_base = buf; + f->_bufsiz = len; + return 0; + case _IONBF: + setbuffer(f, NULL, 0); + return 0; + default: + return -1; + } +} diff --git a/1/newlibc/stdio/sprintf.c b/1/newlibc/stdio/sprintf.c new file mode 100755 index 0000000..850b3fc --- /dev/null +++ b/1/newlibc/stdio/sprintf.c @@ -0,0 +1,48 @@ +/* This is file SPRINTF.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)sprintf.c 5.6 (Berkeley) 6/1/90"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +int +sprintf(char *str, const char *fmt, ...) +{ + va_list ap; + FILE _strbuf; + int len; + + va_start (ap, fmt); + _strbuf._flag = _IOWRT+_IOSTRG; + _strbuf._ptr = str; + _strbuf._cnt = 32767; + len = _doprnt(fmt, ap, &_strbuf); + *_strbuf._ptr = 0; + va_end (ap); + return(len); +} diff --git a/1/newlibc/stdio/ungetc.c b/1/newlibc/stdio/ungetc.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/stdio/vfprintf.c b/1/newlibc/stdio/vfprintf.c new file mode 100755 index 0000000..8e85a39 --- /dev/null +++ b/1/newlibc/stdio/vfprintf.c @@ -0,0 +1,55 @@ +/* This is file VFPRINTF.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted provided + * that: (1) source distributions retain this entire copyright notice and + * comment, and (2) distributions including binaries display the following + * acknowledgement: ``This product includes software developed by the + * University of California, Berkeley and its contributors'' in the + * documentation or other materials provided with the distribution and in + * all advertising materials mentioning features or use of this software. + * Neither the name of the University nor the names of its contributors may + * be used to endorse or promote products derived from this software without + * specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)vfprintf.c 5.4 (Berkeley) 6/30/90"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +int +vfprintf(FILE *iop, const char *fmt, ...) +{ + va_list ap; + int len; + char localbuf[BUFSIZ]; + + va_start (ap, fmt); + if (iop->_flag & _IONBF) { + iop->_flag &= ~_IONBF; + iop->_ptr = iop->_base = localbuf; + iop->_bufsiz = BUFSIZ; + len = _doprnt(fmt, ap, iop); + (void)fflush(iop); + iop->_flag |= _IONBF; + iop->_base = NULL; + iop->_bufsiz = 0; + iop->_cnt = 0; + } else + len = _doprnt(fmt, ap, iop); + va_start (ap, fmt); + return (ferror(iop) ? EOF : len); +} diff --git a/1/newlibc/stdio/vprintf.c b/1/newlibc/stdio/vprintf.c new file mode 100755 index 0000000..e639d43 --- /dev/null +++ b/1/newlibc/stdio/vprintf.c @@ -0,0 +1,43 @@ +/* This is file VPRINTF.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)vprintf.c 5.3 (Berkeley) 6/1/90"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +int +vprintf(const char *fmt, ...) +{ + va_list ap; + int len; + + va_start (ap, fmt); + len = _doprnt(fmt, ap, stdout); + va_end (ap); + return (ferror(stdout) ? EOF : len); +} diff --git a/1/newlibc/stdio/vsprintf.c b/1/newlibc/stdio/vsprintf.c new file mode 100755 index 0000000..2f33b7e --- /dev/null +++ b/1/newlibc/stdio/vsprintf.c @@ -0,0 +1,48 @@ +/* This is file VSPRINTF.C */ +/* This file may have been modified by DJ Delorie (Jan 1991). If so, +** these modifications are Coyright (C) 1991 DJ Delorie, 24 Kirsten Ave, +** Rochester NH, 03867-2954, USA. +*/ + +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms are permitted + * provided that: (1) source distributions retain this entire copyright + * notice and comment, and (2) distributions including binaries display + * the following acknowledgement: ``This product includes software + * developed by the University of California, Berkeley and its contributors'' + * in the documentation or other materials provided with the distribution + * and in all advertising materials mentioning features or use of this + * software. Neither the name of the University nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)vsprintf.c 5.3 (Berkeley) 6/1/90"; +#endif /* LIBC_SCCS and not lint */ + +#include +#include + +int +vsprintf(char *str, const char *fmt, ...) +{ + va_list ap; + FILE f; + int len; + + va_start (ap, fmt); + f._flag = _IOWRT+_IOSTRG; + f._ptr = str; + f._cnt = 32767; + len = _doprnt(fmt, ap, &f); + *f._ptr = 0; + va_end (ap); + return (len); +} diff --git a/1/newlibc/termcap/._COPYING b/1/newlibc/termcap/._COPYING new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._COPYING.LIB b/1/newlibc/termcap/._COPYING.LIB new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._ChangeLog b/1/newlibc/termcap/._ChangeLog new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._Makefile.in b/1/newlibc/termcap/._Makefile.in new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._README b/1/newlibc/termcap/._README new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._bsearch.c b/1/newlibc/termcap/._bsearch.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._configure b/1/newlibc/termcap/._configure new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._conversions.c b/1/newlibc/termcap/._conversions.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._getopt.c b/1/newlibc/termcap/._getopt.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._getopt.h b/1/newlibc/termcap/._getopt.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._getopt1.c b/1/newlibc/termcap/._getopt1.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._makefile b/1/newlibc/termcap/._makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._termcap.c b/1/newlibc/termcap/._termcap.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._termcap.h b/1/newlibc/termcap/._termcap.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._tparam.c b/1/newlibc/termcap/._tparam.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._tput.c b/1/newlibc/termcap/._tput.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._tput.h b/1/newlibc/termcap/._tput.h new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/._tput.texinfo b/1/newlibc/termcap/._tput.texinfo new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/termcap/COPYING b/1/newlibc/termcap/COPYING new file mode 100755 index 0000000..a43ea21 --- /dev/null +++ b/1/newlibc/termcap/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/1/newlibc/termcap/COPYING.LIB b/1/newlibc/termcap/COPYING.LIB new file mode 100755 index 0000000..eb685a5 --- /dev/null +++ b/1/newlibc/termcap/COPYING.LIB @@ -0,0 +1,481 @@ + GNU LIBRARY GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the library GPL. It is + numbered 2 because it goes with version 2 of the ordinary GPL.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Library General Public License, applies to some +specially designated Free Software Foundation software, and to any +other libraries whose authors decide to use it. You can use it for +your libraries, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if +you distribute copies of the library, or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link a program with the library, you must provide +complete object files to the recipients so that they can relink them +with the library, after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + Our method of protecting your rights has two steps: (1) copyright +the library, and (2) offer you this license which gives you legal +permission to copy, distribute and/or modify the library. + + Also, for each distributor's protection, we want to make certain +that everyone understands that there is no warranty for this free +library. If the library is modified by someone else and passed on, we +want its recipients to know that what they have is not the original +version, so that any problems introduced by others will not reflect on +the original authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that companies distributing free +software will individually obtain patent licenses, thus in effect +transforming the program into proprietary software. To prevent this, +we have made it clear that any patent must be licensed for everyone's +free use or not licensed at all. + + Most GNU software, including some libraries, is covered by the ordinary +GNU General Public License, which was designed for utility programs. This +license, the GNU Library General Public License, applies to certain +designated libraries. This license is quite different from the ordinary +one; be sure to read it in full, and don't assume that anything in it is +the same as in the ordinary license. + + The reason we have a separate public license for some libraries is that +they blur the distinction we usually make between modifying or adding to a +program and simply using it. Linking a program with a library, without +changing the library, is in some sense simply using the library, and is +analogous to running a utility program or application program. However, in +a textual and legal sense, the linked executable is a combined work, a +derivative of the original library, and the ordinary General Public License +treats it as such. + + Because of this blurred distinction, using the ordinary General +Public License for libraries did not effectively promote software +sharing, because most developers did not use the libraries. We +concluded that weaker conditions might promote sharing better. + + However, unrestricted linking of non-free programs would deprive the +users of those programs of all benefit from the free status of the +libraries themselves. This Library General Public License is intended to +permit developers of non-free programs to use free libraries, while +preserving your freedom as a user of such programs to change the free +libraries that are incorporated in them. (We have not seen how to achieve +this as regards changes in header files, but we have achieved it as regards +changes in the actual functions of the Library.) The hope is that this +will lead to faster development of free libraries. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, while the latter only +works together with the library. + + Note that it is possible for a library to be covered by the ordinary +General Public License rather than by this special one. + + GNU LIBRARY GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library which +contains a notice placed by the copyright holder or other authorized +party saying it may be distributed under the terms of this Library +General Public License (also called "this License"). Each licensee is +addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also compile or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + c) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + d) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the source code distributed need not include anything that is normally +distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Library General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! diff --git a/1/newlibc/termcap/ChangeLog b/1/newlibc/termcap/ChangeLog new file mode 100755 index 0000000..f28d9e9 --- /dev/null +++ b/1/newlibc/termcap/ChangeLog @@ -0,0 +1,26 @@ +Thu Jul 11 22:23:01 1991 David J. MacKenzie (djm at nutrimat) + + * Version 1.0. + +Wed Jul 10 03:10:20 1991 David J. MacKenzie (djm at wookumz.gnu.ai.mit.edu) + + * Replace Makefile with configure and Makefile.in. + + * Update to GPL 2. + +Sat Aug 11 00:33:39 1990 David J. MacKenzie (djm at albert.ai.mit.edu) + + * tput.c (main): Don't strip leading path from argv[0]. + Remove -V +version option. + Rename a few things. + +Sun Dec 3 18:48:36 1989 David J. MacKenzie (djm at hobbes.ai.mit.edu) + + * tput.c, tput.texinfo: Merge short and long option usage + messages. + +Local Variables: +mode: indented-text +left-margin: 8 +version-control: never +End: diff --git a/1/newlibc/termcap/Makefile.in b/1/newlibc/termcap/Makefile.in new file mode 100755 index 0000000..1354a62 --- /dev/null +++ b/1/newlibc/termcap/Makefile.in @@ -0,0 +1,80 @@ +# Makefile for GNU tput +# Copyright (C) 1989-1991 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +SHELL = /bin/sh + +#### Start of system configuration section. #### + +CC = @CC@ +INSTALL = @INSTALL@ + +# Things you might add to DEFS: +# -DSTDC_HEADERS If you have ANSI C headers and libraries. +# -DUSG If you have System V/ANSI C string and +# memory functions and headers. +# -DSIGTYPE=int If your signal handlers return int, not void. + +DEFS = @DEFS@ + +CFLAGS = -I. -g $(DEFS) +LDFLAGS = -g +LIBS = @LIBS@ + +# Where to install the executable. +bindir = /usr/local/gnubin + +#### End of system configuration section. #### + +SRCS = tput.c conversions.c getopt.c getopt1.c termcap.c tparam.c bsearch.c +OBJS = tput.o conversions.o getopt.o getopt1.o termcap.o tparam.o @LIBOBJS@ +DISTFILES = COPYING COPYING.LIB ChangeLog Makefile.in configure README \ +tput.texinfo tput.h getopt.h termcap.h $(SRCS) +VERSION = 1.0 + +all: tput +.PHONY: all + +tput: $(OBJS) + $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) + +install: all + $(INSTALL) tput $(bindir) +.PHONY: install + +tput.o conversions.o: tput.h +getopt1.o tput.o: getopt.h + +clean: + rm -f tput *.o a.out tags TAGS core +.PHONY: clean + +realclean: clean + rm -f Makefile +.PHONY: realclean + +distclean: realclean + rm -f *.tar.Z +.PHONY: distclean + +dist: $(DISTFILES) + echo tput-$(VERSION) > .fname + rm -rf `cat .fname` + mkdir `cat .fname` + ln $(DISTFILES) `cat .fname` + tar chZf `cat .fname`.tar.Z `cat .fname` + rm -rf `cat .fname` .fname +.PHONY: dist diff --git a/1/newlibc/termcap/README b/1/newlibc/termcap/README new file mode 100755 index 0000000..c77562d --- /dev/null +++ b/1/newlibc/termcap/README @@ -0,0 +1,42 @@ +This directory contains GNU tput, a program to enable shell scripts to +portably use special terminal capabilities. Although its interface is +similar to that of terminfo-based tput programs, it actually uses termcap. + +To compile: + +1. Type `./configure'. This shell script attempts to guess correct +values for various system-dependent variables used during compilation, +and creates the file `Makefile'. This takes a minute or so. + +If your system requires unusual options for compilation or linking +that `configure' doesn't know about, you can give `configure' initial +values for variables by setting them in the environment; in +Bourne-compatible shells, you can do that on the command line like +this: +$ CC='gcc -traditional' LIBS=-lposix ./configure + +2. If you want to change the directory where the program will be +installed, or the optimization options, edit `Makefile' and change +those values. If you have an unusual system that needs special +compilation options that `configure' doesn't know about, and you +didn't pass them in the environment when running `configure', you +should add them to `Makefile' now. Alternately, teach `configure' how +to figure out that it is being run on a system where they are needed, +and mail the diffs to the address listed at the end of this file so we +can include them in the next release. + +3. Type `make'. + +4. If the program compiles successfully, type `make install' to +install it. + +5. After you have installed the program, you can remove the binary +from the source directory by typing `make clean'. Type `make +realclean' if you also want to remove `Makefile', for instance if you +are going to recompile next on another type of machine. + +To do for POSIX: +Add `init' and `reset' options. + +Mail suggestions and bug reports for GNU tput to +bug-gnu-utils@prep.ai.mit.edu. diff --git a/1/newlibc/termcap/bsearch.c b/1/newlibc/termcap/bsearch.c new file mode 100755 index 0000000..9943e25 --- /dev/null +++ b/1/newlibc/termcap/bsearch.c @@ -0,0 +1,61 @@ +/* Copyright (C) 1991 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Library General Public License as +published by the Free Software Foundation; either version 2 of the +License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Library General Public License for more details. + +You should have received a copy of the GNU Library General Public +License along with the GNU C Library; see the file COPYING.LIB. If +not, write to the Free Software Foundation, Inc., 675 Mass Ave, +Cambridge, MA 02139, USA. */ + +#ifdef STDC_HEADERS +#include +#else +#define NULL 0 +#include +#endif + +/* Perform a binary search for KEY in BASE which has NMEMB elements + of SIZE bytes each. The comparisons are done by (*COMPAR)(). */ +char * +bsearch (key, base, nmemb, size, compar) + register char *key; + register char *base; + size_t nmemb; + register size_t size; + register int (*compar) (); +{ + register size_t l, u, idx; + register char *p; + register int comparison; + + l = 0; + u = nmemb - 1; + while (l <= u) + { + idx = (l + u) / 2; + p = (char *) (((char *) base) + (idx * size)); + comparison = (*compar) (key, p); + /* Don't make U negative because it will wrap around. */ + if (comparison < 0) + { + if (idx == 0) + break; + u = idx - 1; + } + else if (comparison > 0) + l = idx + 1; + else + return (char *) p; + } + + return NULL; +} diff --git a/1/newlibc/termcap/configure b/1/newlibc/termcap/configure new file mode 100755 index 0000000..cebb067 --- /dev/null +++ b/1/newlibc/termcap/configure @@ -0,0 +1,129 @@ +: +# Guess values for system-dependant variables and create `Makefile'. +# Copyright (C) 1991 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +trap 'rm -f defstest defstest.c Makefile; exit 1' 1 3 15 + +set +u # Make sure unset variables are ok. + +# Make sure we don't find the System V /etc/install. +PATH=`echo $PATH|sed 's,^:,|, +s,:$,|, +s,:/usr/etc,,g +s,/usr/etc:,,g +s,:/etc,,g +s,/etc:,,g +s,|,:,g'` + +if test "$RANDOM" = "$RANDOM"; then + # Plain old Bourne shell. + echo checking for gcc + test -z "$CC" -a -n "`gcc 2>&1`" && CC="gcc -O" + + echo checking for install + if test -z "$INSTALL" -a -n "`install 2>&1`"; then + INSTALL="install -c" + fi +else + # ksh, bash or zsh. + echo checking for gcc + test -z "$CC" && type gcc && CC="gcc -O" + + echo checking for install + if test -z "$INSTALL" && type install; then + INSTALL="install -c" + fi +fi + +CC=${CC-cc} +INSTALL=${INSTALL-cp} +INCLUDEDIR=${INCLUDEDIR-/usr/include} + +rm -f defstest defstest.c +compile="$CC $DEFS defstest.c -o defstest $LIBS >/dev/null 2>&1" + +# Check for various header files. + +echo checking signal handler return type +grep 'int[ ]*(\*signal[ ]*(' $INCLUDEDIR/signal.h >/dev/null 2>&1 && + DEFS="$DEFS -DSIGTYPE=int" + +echo checking for ANSI C header files +echo "#include +#include +main () { exit(0); strerror(0); }" > defstest.c +eval $compile +if test -s defstest && ./defstest 2>/dev/null; then + DEFS="$DEFS -DSTDC_HEADERS" +fi +rm -f defstest defstest.c + +echo checking for BSD string and memory functions +echo "#include +main () { exit(0); rindex(0, 0); bzero(0, 0); }" > defstest.c +eval $compile +if test -s defstest && ./defstest 2>/dev/null; then : + else DEFS="$DEFS -DUSG" +fi +rm -f defstest defstest.c + +# Check whether various functions exist. + +# Functions we provide replacements for. +for func in bsearch +do + echo checking for $func + echo "main() { exit(0); ${func}(); }" > defstest.c + eval $compile + if test -s defstest && ./defstest 2>/dev/null; then : + else LIBOBJS="$LIBOBJS ${func}.o" + fi + rm -f defstest defstest.c +done + +# Check other misc. things. + +echo checking how to get alloca +echo ' +#ifdef __GNUC__ +#define alloca __builtin_alloca +#else +#ifdef sparc +#include +#else +#ifdef _AIX +#pragma alloca +#else +char *alloca (); +#endif +#endif +#endif +main() { char *p = (char *) alloca(1); exit(0); }' > defstest.c +eval $compile +if test -s defstest && ./defstest 2>/dev/null; then : +else LIBS="$LIBS -lPW" +fi +rm -f defstest defstest.c + +echo '# Generated automatically from Makefile.in by configure.' > Makefile +sed -e " +s,@CC@,$CC, +s,@INSTALL@,$INSTALL, +s,@DEFS@,$DEFS, +s,@LIBS@,$LIBS, +s,@LIBOBJS@,$LIBOBJS, +" Makefile.in >> Makefile diff --git a/1/newlibc/termcap/conversions.c b/1/newlibc/termcap/conversions.c new file mode 100755 index 0000000..92753c7 --- /dev/null +++ b/1/newlibc/termcap/conversions.c @@ -0,0 +1,337 @@ +/* conversions.c -- table of termcap/terminfo equivalencies + Copyright (C) 1989 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "tput.h" + +/* `conversions' is binary-searched to retrieve the termcap equivalent + of the given terminfo capability, along with information about what + type of capability it is. If you add entries, keep the table sorted + by terminfo capability and adjust `CAPABILITIES' in tput.h. */ + +struct conversion conversions[CAPABILITIES] = +{ + {"acsc", "ac", STR}, + {"am", "am", BOOL}, + {"bel", "bl", STR}, + {"blink", "mb", STR}, + {"bold", "md", STR}, + {"bw", "bw", BOOL}, + {"cbt", "bt", STR}, + {"chts", "HC", BOOL}, + {"civis", "vi", STR}, + {"clear", "cl", STR | PAD}, + {"cmdch", "CC", STR}, + {"cnorm", "ve", STR}, + {"cols", "co", NUM}, + {"cr", "cr", STR}, + {"csr", "cs", STR}, + {"cub", "LE", STR}, + {"cub1", "le", STR}, + {"cud", "DO", STR | PAD}, + {"cud1", "do", STR}, + {"cuf", "RI", STR}, + {"cuf1", "nd", STR}, + {"cup", "cm", STR}, + {"cuu", "UP", STR}, + {"cuu1", "up", STR}, + {"cvvis", "vs", STR}, + {"da", "da", BOOL}, + {"db", "db", BOOL}, + {"dch", "DC", STR}, + {"dch1", "dc", STR}, + {"dim", "mh", STR}, + {"dl", "DL", STR | PAD}, + {"dl1", "dl", STR}, + {"dsl", "ds", STR}, + {"ech", "ec", STR}, + {"ed", "cd", STR | PAD}, + {"el", "ce", STR}, + {"el1", "cb", STR}, + {"enacs", "eA", STR}, + {"eo", "eo", BOOL}, + {"eslok", "es", BOOL}, + {"ff", "ff", STR}, + {"flash", "vb", STR}, + {"fsl", "fs", STR}, + {"gn", "gn", BOOL}, + {"hc", "hc", BOOL}, + {"hd", "hd", STR}, + {"home", "ho", STR}, + {"hpa", "ch", STR}, + {"hs", "hs", BOOL}, + {"ht", "ta", STR}, + {"hts", "st", STR}, + {"hu", "hu", STR}, + {"hz", "hz", BOOL}, + {"ich", "IC", STR}, + {"ich1", "ic", STR}, + {"if", "if", STR}, + {"il", "AL", STR | PAD}, + {"il1", "al", STR}, + {"in", "in", BOOL}, + {"ind", "sf", STR}, + {"indn", "SF", STR | PAD}, + {"invis", "mk", STR}, + {"ip", "ip", STR}, + {"iprog", "iP", STR}, + {"is1", "i1", STR}, + {"is2", "is", STR}, + {"is3", "i3", STR}, + {"it", "it", NUM}, + {"kBEG", "&9", STR}, + {"kCAN", "&0", STR}, + {"kCMD", "*1", STR}, + {"kCPY", "*2", STR}, + {"kCRT", "*3", STR}, + {"kDC", "*4", STR}, + {"kDL", "*5", STR}, + {"kEND", "*7", STR}, + {"kEOL", "*8", STR}, + {"kEXT", "*9", STR}, + {"kFND", "*0", STR}, + {"kHLP", "#1", STR}, + {"kHOM", "#2", STR}, + {"kIC", "#3", STR}, + {"kLFT", "#4", STR}, + {"kMOV", "%b", STR}, + {"kMSG", "%a", STR}, + {"kNXT", "%c", STR}, + {"kOPT", "%d", STR}, + {"kPRT", "%f", STR}, + {"kPRV", "%e", STR}, + {"kRDO", "%g", STR}, + {"kRES", "%j", STR}, + {"kRIT", "%i", STR}, + {"kRPL", "%h", STR}, + {"kSAV", "!1", STR}, + {"kSPD", "!2", STR}, + {"kUND", "!3", STR}, + {"ka1", "K1", STR}, + {"ka3", "K3", STR}, + {"kb2", "K2", STR}, + {"kbeg", "@1", STR}, + {"kbs", "kb", STR}, + {"kc1", "K4", STR}, + {"kc3", "K5", STR}, + {"kcan", "@2", STR}, + {"kcbt", "kB", STR}, + {"kclo", "@3", STR}, + {"kclr", "kC", STR}, + {"kcmd", "@4", STR}, + {"kcpy", "@5", STR}, + {"kcrt", "@6", STR}, + {"kctab", "kt", STR}, + {"kcub1", "kl", STR}, + {"kcud1", "kd", STR}, + {"kcuf1", "kr", STR}, + {"kcuu1", "ku", STR}, + {"kdch1", "kD", STR}, + {"kdl1", "kL", STR}, + {"ked", "kS", STR}, + {"kel", "kE", STR}, + {"kend", "@7", STR}, + {"kent", "@8", STR}, + {"kext", "@9", STR}, + {"kf0", "k0", STR}, + {"kf1", "k1", STR}, + {"kf10", "k;", STR}, + {"kf11", "F1", STR}, + {"kf12", "F2", STR}, + {"kf13", "F3", STR}, + {"kf14", "F4", STR}, + {"kf15", "F5", STR}, + {"kf16", "F6", STR}, + {"kf17", "F7", STR}, + {"kf18", "F8", STR}, + {"kf19", "F9", STR}, + {"kf2", "k2", STR}, + {"kf20", "FA", STR}, + {"kf21", "FB", STR}, + {"kf22", "FC", STR}, + {"kf23", "FD", STR}, + {"kf24", "FE", STR}, + {"kf25", "FF", STR}, + {"kf26", "FG", STR}, + {"kf27", "FH", STR}, + {"kf28", "FI", STR}, + {"kf29", "FJ", STR}, + {"kf3", "k3", STR}, + {"kf30", "FK", STR}, + {"kf31", "FL", STR}, + {"kf32", "FM", STR}, + {"kf33", "FN", STR}, + {"kf34", "FO", STR}, + {"kf35", "FP", STR}, + {"kf36", "FQ", STR}, + {"kf37", "FR", STR}, + {"kf38", "FS", STR}, + {"kf39", "FT", STR}, + {"kf4", "k4", STR}, + {"kf40", "FU", STR}, + {"kf41", "FV", STR}, + {"kf42", "FW", STR}, + {"kf43", "FX", STR}, + {"kf44", "FY", STR}, + {"kf45", "FZ", STR}, + {"kf46", "Fa", STR}, + {"kf47", "Fb", STR}, + {"kf48", "Fc", STR}, + {"kf49", "Fd", STR}, + {"kf5", "k5", STR}, + {"kf50", "Fe", STR}, + {"kf51", "Ff", STR}, + {"kf52", "Fg", STR}, + {"kf53", "Fh", STR}, + {"kf54", "Fi", STR}, + {"kf55", "Fj", STR}, + {"kf56", "Fk", STR}, + {"kf57", "Fl", STR}, + {"kf58", "Fm", STR}, + {"kf59", "Fn", STR}, + {"kf6", "k6", STR}, + {"kf60", "Fo", STR}, + {"kf61", "Fp", STR}, + {"kf62", "Fq", STR}, + {"kf63", "Fr", STR}, + {"kf7", "k7", STR}, + {"kf8", "k8", STR}, + {"kf9", "k9", STR}, + {"kfnd", "@0", STR}, + {"khlp", "%1", STR}, + {"khome", "kh", STR}, + {"khts", "kT", STR}, + {"kich1", "kI", STR}, + {"kil1", "kA", STR}, + {"kind", "kF", STR}, + {"kll", "kH", STR}, + {"km", "km", BOOL}, + {"kmov", "%4", STR}, + {"kmrk", "%2", STR}, + {"kmsg", "%3", STR}, + {"knp", "kN", STR}, + {"knxt", "%5", STR}, + {"kopn", "%6", STR}, + {"kopt", "%7", STR}, + {"kpp", "kP", STR}, + {"kprt", "%9", STR}, + {"kprv", "%8", STR}, + {"krdo", "%0", STR}, + {"kref", "&1", STR}, + {"kres", "&5", STR}, + {"krfr", "&2", STR}, + {"kri", "kR", STR}, + {"krmir", "kM", STR}, + {"krpl", "&3", STR}, + {"krst", "&4", STR}, + {"ksav", "&6", STR}, + {"kslt", "*6", STR}, + {"kspd", "&7", STR}, + {"ktbc", "ka", STR}, + {"kund", "&8", STR}, + {"lf0", "l0", STR}, + {"lf1", "l1", STR}, + {"lf10", "la", STR}, + {"lf2", "l2", STR}, + {"lf3", "l3", STR}, + {"lf4", "l4", STR}, + {"lf5", "l5", STR}, + {"lf6", "l6", STR}, + {"lf7", "l7", STR}, + {"lf8", "l8", STR}, + {"lf9", "l9", STR}, + {"lh", "lh", NUM}, + {"lines", "li", NUM}, + {"ll", "ll", STR}, + {"lm", "lm", NUM}, + {"lw", "lw", NUM}, + {"mc0", "ps", STR}, + {"mc4", "pf", STR}, + {"mc5", "po", STR}, + {"mc5i", "5i", BOOL}, + {"mc5p", "pO", STR}, + {"mgc", "MC", STR}, + {"mir", "mi", BOOL}, + {"mrcup", "CM", STR}, + {"msgr", "ms", BOOL}, + {"nel", "nw", STR}, + {"nlab", "Nl", NUM}, + {"npc", "NP", BOOL}, + {"nrrmc", "NR", BOOL}, + {"nxon", "nx", BOOL}, + {"os", "os", BOOL}, + {"pad", "pc", STR}, + {"pb", "pb", NUM}, + {"pfkey", "pk", STR}, + {"pfloc", "pl", STR}, + {"pfx", "px", STR}, + {"pln", "pn", STR}, + {"prot", "mp", STR}, + {"rc", "rc", STR}, + {"rep", "rp", STR}, + {"rev", "mr", STR}, + {"rf", "rf", STR}, + {"rfi", "RF", STR}, + {"ri", "sr", STR}, + {"rin", "SR", STR | PAD}, + {"rmacs", "ae", STR}, + {"rmam", "RA", STR}, + {"rmcup", "te", STR}, + {"rmdc", "ed", STR}, + {"rmir", "ei", STR}, + {"rmkx", "ke", STR}, + {"rmln", "LF", STR}, + {"rmm", "mo", STR}, + {"rmp", "rP", STR}, + {"rmso", "se", STR}, + {"rmul", "ue", STR}, + {"rmxon", "RX", STR}, + {"rs1", "r1", STR}, + {"rs2", "r2", STR}, + {"rs3", "r3", STR}, + {"sc", "sc", STR}, + {"sgr", "sa", STR}, + {"sgr0", "me", STR}, + {"smacs", "as", STR}, + {"smam", "SA", STR}, + {"smcup", "ti", STR}, + {"smdc", "dm", STR}, + {"smgl", "ML", STR}, + {"smgr", "MR", STR}, + {"smir", "im", STR}, + {"smkx", "ks", STR}, + {"smln", "LO", STR}, + {"smm", "mm", STR}, + {"smso", "so", STR}, + {"smul", "us", STR}, + {"smxon", "SX", STR}, + {"tbc", "ct", STR}, + {"tsl", "ts", STR}, + {"uc", "uc", STR}, + {"ul", "ul", BOOL}, + {"vpa", "cv", STR}, + {"vt", "vt", NUM}, + {"wind", "wi", STR}, + {"wsl", "ws", NUM}, + {"xenl", "xn", BOOL}, + {"xhp", "xs", BOOL}, + {"xmc", "sg", NUM}, + {"xoffc", "XF", STR}, + {"xon", "xo", BOOL}, + {"xonc", "XN", STR}, + {"xsb", "xb", BOOL}, + {"xt", "xt", BOOL} +}; diff --git a/1/newlibc/termcap/getopt.c b/1/newlibc/termcap/getopt.c new file mode 100755 index 0000000..d7e2137 --- /dev/null +++ b/1/newlibc/termcap/getopt.c @@ -0,0 +1,596 @@ +/* Getopt for GNU. + Copyright (C) 1987, 1989, 1990, 1991 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#ifdef __STDC__ +#define CONST const +#else +#define CONST +#endif + +/* This version of `getopt' appears to the caller like standard Unix `getopt' + but it behaves differently for the user, since it allows the user + to intersperse the options with the other arguments. + + As `getopt' works, it permutes the elements of `argv' so that, + when it is done, all the options precede everything else. Thus + all application programs are extended to handle flexible argument order. + + Setting the environment variable _POSIX_OPTION_ORDER disables permutation. + Then the behavior is completely standard. + + GNU application programs can use a third alternative mode in which + they can distinguish the relative order of options and other arguments. */ + +#include + +/* If compiled with GNU C, use the built-in alloca */ +#ifdef __GNUC__ +#define alloca __builtin_alloca +#else /* not __GNUC__ */ +#ifdef sparc +#include +#else +#ifdef _AIX +#pragma alloca +#else +char *alloca (); +#endif +#endif /* sparc */ +#endif /* not __GNUC__ */ + +#if defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) +#include +#else /* STDC_HEADERS or __GNU_LIBRARY__ */ +char *getenv (); +char *malloc (); +#endif /* STDC_HEADERS or __GNU_LIBRARY__ */ + +#if defined(USG) || defined(STDC_HEADERS) || defined(__GNU_LIBRARY__) +#include +#define bcopy(s, d, n) memcpy ((d), (s), (n)) +#define index strchr +#else /* USG or STDC_HEADERS or __GNU_LIBRARY__ */ +#ifdef VMS +#include +#else /* VMS */ +#include +#endif /* VMS */ +/* Declaring bcopy causes errors on systems whose declarations are different. + If the declaration is omitted, everything works fine. */ +#endif /* USG or STDC_HEADERS or __GNU_LIBRARY__ */ + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +char *optarg = 0; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +int optind = 0; + +/* The next char to be scanned in the option-element + in which the last option character we returned was found. + This allows us to pick up the scan where we left off. + + If this is zero, or a null string, it means resume the scan + by advancing to the next ARGV-element. */ + +static char *nextchar; + +/* Callers store zero here to inhibit the error message + for unrecognized options. */ + +int opterr = 1; + +/* Describe how to deal with options that follow non-option ARGV-elements. + + If the caller did not specify anything, + the default is REQUIRE_ORDER if the environment variable + _POSIX_OPTION_ORDER is defined, PERMUTE otherwise. + + REQUIRE_ORDER means don't recognize them as options; + stop option processing when the first non-option is seen. + This is what Unix does. + This mode of operation is selected by either setting the environment + variable _POSIX_OPTION_ORDER, or using `+' as the first character + of the list of option characters. + + PERMUTE is the default. We permute the contents of ARGV as we scan, + so that eventually all the non-options are at the end. This allows options + to be given in any order, even with programs that were not written to + expect this. + + RETURN_IN_ORDER is an option available to programs that were written + to expect options and other ARGV-elements in any order and that care about + the ordering of the two. We describe each non-option ARGV-element + as if it were the argument of an option with character code 1. + Using `-' as the first character of the list of option characters + selects this mode of operation. + + The special argument `--' forces an end of option-scanning regardless + of the value of `ordering'. In the case of RETURN_IN_ORDER, only + `--' can cause `getopt' to return EOF with `optind' != ARGC. */ + +static enum +{ + REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER +} ordering; + +/* Describe the long-named options requested by the application. + _GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an + element containing a name which is zero. + The field `has_arg' is 1 if the option takes an argument, + 2 if it takes an optional argument. */ + +struct option +{ + char *name; + int has_arg; + int *flag; + int val; +}; + +CONST struct option *_getopt_long_options; + +int _getopt_long_only = 0; + +/* Index in _GETOPT_LONG_OPTIONS of the long-named option actually found. + Only valid when a long-named option was found. */ + +int option_index; + +/* Handle permutation of arguments. */ + +/* Describe the part of ARGV that contains non-options that have + been skipped. `first_nonopt' is the index in ARGV of the first of them; + `last_nonopt' is the index after the last of them. */ + +static int first_nonopt; +static int last_nonopt; + +/* Exchange two adjacent subsequences of ARGV. + One subsequence is elements [first_nonopt,last_nonopt) + which contains all the non-options that have been skipped so far. + The other is elements [last_nonopt,optind), which contains all + the options processed since those non-options were skipped. + + `first_nonopt' and `last_nonopt' are relocated so that they describe + the new indices of the non-options in ARGV after they are moved. */ + +static void +exchange (argv) + char **argv; +{ + int nonopts_size = (last_nonopt - first_nonopt) * sizeof (char *); + char **temp = (char **) alloca (nonopts_size); + + /* Interchange the two blocks of data in ARGV. */ + + bcopy (&argv[first_nonopt], temp, nonopts_size); + bcopy (&argv[last_nonopt], &argv[first_nonopt], + (optind - last_nonopt) * sizeof (char *)); + bcopy (temp, &argv[first_nonopt + optind - last_nonopt], nonopts_size); + + /* Update records for the slots the non-options now occupy. */ + + first_nonopt += (optind - last_nonopt); + last_nonopt = optind; +} + +/* Scan elements of ARGV (whose length is ARGC) for option characters + given in OPTSTRING. + + If an element of ARGV starts with '-', and is not exactly "-" or "--", + then it is an option element. The characters of this element + (aside from the initial '-') are option characters. If `getopt' + is called repeatedly, it returns successively each of the option characters + from each of the option elements. + + If `getopt' finds another option character, it returns that character, + updating `optind' and `nextchar' so that the next call to `getopt' can + resume the scan with the following option character or ARGV-element. + + If there are no more option characters, `getopt' returns `EOF'. + Then `optind' is the index in ARGV of the first ARGV-element + that is not an option. (The ARGV-elements have been permuted + so that those that are not options now come last.) + + OPTSTRING is a string containing the legitimate option characters. + If an option character is seen that is not listed in OPTSTRING, + return '?' after printing an error message. If you set `opterr' to + zero, the error message is suppressed but we still return '?'. + + If a char in OPTSTRING is followed by a colon, that means it wants an arg, + so the following text in the same ARGV-element, or the text of the following + ARGV-element, is returned in `optarg'. Two colons mean an option that + wants an optional arg; if there is text in the current ARGV-element, + it is returned in `optarg', otherwise `optarg' is set to zero. + + If OPTSTRING starts with `-' or `+', it requests different methods of + handling the non-option ARGV-elements. + See the comments about RETURN_IN_ORDER and REQUIRE_ORDER, above. + + Long-named options begin with `+' instead of `-'. + Their names may be abbreviated as long as the abbreviation is unique + or is an exact match for some defined option. If they have an + argument, it follows the option name in the same ARGV-element, separated + from the option name by a `=', or else the in next ARGV-element. + When `getopt' finds a long-named option, it returns 0 if that option's + `flag' field is nonzero, the value of the option's `val' field + otherwise. */ + +int +getopt (argc, argv, optstring) + int argc; + char **argv; + CONST char *optstring; +{ + optarg = 0; + + /* Initialize the internal data when the first call is made. + Start processing options with ARGV-element 1 (since ARGV-element 0 + is the program name); the sequence of previously skipped + non-option ARGV-elements is empty. */ + + if (optind == 0) + { + first_nonopt = last_nonopt = optind = 1; + + nextchar = 0; + + /* Determine how to handle the ordering of options and nonoptions. */ + + if (optstring[0] == '-') + { + ordering = RETURN_IN_ORDER; + ++optstring; + } + else if (optstring[0] == '+') + { + ordering = REQUIRE_ORDER; + ++optstring; + } + else if (getenv ("_POSIX_OPTION_ORDER") != 0) + ordering = REQUIRE_ORDER; + else + ordering = PERMUTE; + } + + if (nextchar == 0 || *nextchar == 0) + { + if (ordering == PERMUTE) + { + /* If we have just processed some options following some non-options, + exchange them so that the options come first. */ + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange (argv); + else if (last_nonopt != optind) + first_nonopt = optind; + + /* Now skip any additional non-options + and extend the range of non-options previously skipped. */ + + while (optind < argc + && (argv[optind][0] != '-' + || argv[optind][1] == 0) + && (_getopt_long_options == 0 + || argv[optind][0] != '+' + || argv[optind][1] == 0)) + optind++; + last_nonopt = optind; + } + + /* Special ARGV-element `--' means premature end of options. + Skip it like a null option, + then exchange with previous non-options as if it were an option, + then skip everything else like a non-option. */ + + if (optind != argc && !strcmp (argv[optind], "--")) + { + optind++; + + if (first_nonopt != last_nonopt && last_nonopt != optind) + exchange (argv); + else if (first_nonopt == last_nonopt) + first_nonopt = optind; + last_nonopt = argc; + + optind = argc; + } + + /* If we have done all the ARGV-elements, stop the scan + and back over any non-options that we skipped and permuted. */ + + if (optind == argc) + { + /* Set the next-arg-index to point at the non-options + that we previously skipped, so the caller will digest them. */ + if (first_nonopt != last_nonopt) + optind = first_nonopt; + return EOF; + } + + /* If we have come to a non-option and did not permute it, + either stop the scan or describe it to the caller and pass it by. */ + + if ((argv[optind][0] != '-' || argv[optind][1] == 0) + && (_getopt_long_options == 0 + || argv[optind][0] != '+' || argv[optind][1] == 0)) + { + if (ordering == REQUIRE_ORDER) + return EOF; + optarg = argv[optind++]; + return 1; + } + + /* We have found another option-ARGV-element. + Start decoding its characters. */ + + nextchar = argv[optind] + 1; + } + + if (_getopt_long_options != 0 + && (argv[optind][0] == '+' + || (_getopt_long_only && argv[optind][0] == '-')) + ) + { + CONST struct option *p; + char *s = nextchar; + int exact = 0; + int ambig = 0; + CONST struct option *pfound = 0; + int indfound; + + while (*s && *s != '=') + s++; + + /* Test all options for either exact match or abbreviated matches. */ + for (p = _getopt_long_options, option_index = 0; p->name; + p++, option_index++) + if (!strncmp (p->name, nextchar, s - nextchar)) + { + if (s - nextchar == strlen (p->name)) + { + /* Exact match found. */ + pfound = p; + indfound = option_index; + exact = 1; + break; + } + else if (pfound == 0) + { + /* First nonexact match found. */ + pfound = p; + indfound = option_index; + } + else + /* Second nonexact match found. */ + ambig = 1; + } + + if (ambig && !exact) + { + fprintf (stderr, "%s: option `%s' is ambiguous\n", + argv[0], argv[optind]); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + + if (pfound != 0) + { + option_index = indfound; + optind++; + if (*s) + { + if (pfound->has_arg > 0) + optarg = s + 1; + else + { + fprintf (stderr, + "%s: option `%c%s' doesn't allow an argument\n", + argv[0], argv[optind - 1][0], pfound->name); + nextchar += strlen (nextchar); + return '?'; + } + } + else if (pfound->has_arg == 1) + { + if (optind < argc) + optarg = argv[optind++]; + else + { + fprintf (stderr, "%s: option `%s' requires an argument\n", + argv[0], argv[optind - 1]); + nextchar += strlen (nextchar); + return '?'; + } + } + nextchar += strlen (nextchar); + if (pfound->flag) + { + *(pfound->flag) = pfound->val; + return 0; + } + return pfound->val; + } + /* Can't find it as a long option. If this is getopt_long_only, + and the option starts with '-' and is a valid short + option, then interpret it as a short option. Otherwise it's + an error. */ + if (_getopt_long_only == 0 || argv[optind][0] == '+' || + index (optstring, *nextchar) == 0) + { + if (opterr != 0) + fprintf (stderr, "%s: unrecognized option `%c%s'\n", + argv[0], argv[optind][0], nextchar); + nextchar += strlen (nextchar); + optind++; + return '?'; + } + } + + /* Look at and handle the next option-character. */ + + { + char c = *nextchar++; + char *temp = index (optstring, c); + + /* Increment `optind' when we start to process its last character. */ + if (*nextchar == 0) + optind++; + + if (temp == 0 || c == ':') + { + if (opterr != 0) + { + if (c < 040 || c >= 0177) + fprintf (stderr, "%s: unrecognized option, character code 0%o\n", + argv[0], c); + else + fprintf (stderr, "%s: unrecognized option `-%c'\n", + argv[0], c); + } + return '?'; + } + if (temp[1] == ':') + { + if (temp[2] == ':') + { + /* This is an option that accepts an argument optionally. */ + if (*nextchar != 0) + { + optarg = nextchar; + optind++; + } + else + optarg = 0; + nextchar = 0; + } + else + { + /* This is an option that requires an argument. */ + if (*nextchar != 0) + { + optarg = nextchar; + /* If we end this ARGV-element by taking the rest as an arg, + we must advance to the next element now. */ + optind++; + } + else if (optind == argc) + { + if (opterr != 0) + fprintf (stderr, "%s: option `-%c' requires an argument\n", + argv[0], c); + c = '?'; + } + else + /* We already incremented `optind' once; + increment it again when taking next ARGV-elt as argument. */ + optarg = argv[optind++]; + nextchar = 0; + } + } + return c; + } +} + +#ifdef TEST + +/* Compile with -DTEST to make an executable for use in testing + the above definition of `getopt'. */ + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + + c = getopt (argc, argv, "abc:d:0123456789"); + if (c == EOF) + break; + + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/1/newlibc/termcap/getopt.h b/1/newlibc/termcap/getopt.h new file mode 100755 index 0000000..151379f --- /dev/null +++ b/1/newlibc/termcap/getopt.h @@ -0,0 +1,102 @@ +/* declarations for getopt + Copyright (C) 1989, 1990, 1991 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* For communication from `getopt' to the caller. + When `getopt' finds an option that takes an argument, + the argument value is returned here. + Also, when `ordering' is RETURN_IN_ORDER, + each non-option ARGV-element is returned here. */ + +extern char *optarg; + +/* Index in ARGV of the next element to be scanned. + This is used for communication to and from the caller + and for communication between successive calls to `getopt'. + + On entry to `getopt', zero means this is the first call; initialize. + + When `getopt' returns EOF, this is the index of the first of the + non-option elements that the caller should itself scan. + + Otherwise, `optind' communicates from one call to the next + how much of ARGV has been scanned so far. */ + +extern int optind; + +/* Callers store zero here to inhibit the error message `getopt' prints + for unrecognized options. */ + +extern int opterr; + +/* Describe the long-named options requested by the application. + _GETOPT_LONG_OPTIONS is a vector of `struct option' terminated by an + element containing a name which is zero. + + The field `has_arg' is: + 0 if the option does not take an argument, + 1 if the option requires an argument, + 2 if the option takes an optional argument. + + If the field `flag' is nonzero, it points to a variable that is set + to the value given in the field `val' when the option is found, but + left unchanged if the option is not found. + + To have a long-named option do something other than set an `int' to + a compiled-in constant, such as set a value from `optarg', set the + option's `flag' field to zero and its `val' field to a nonzero + value (the equivalent single-letter option character, if there is + one). For long options that have a zero `flag' field, `getopt' + returns the contents of the `val' field. */ + +struct option +{ + char *name; + int has_arg; + int *flag; + int val; +}; + +#ifdef __STDC__ +extern const struct option *_getopt_long_options; +#else +extern struct option *_getopt_long_options; +#endif + +/* If nonzero, '-' can introduce long-named options. + Set by getopt_long_only. */ + +extern int _getopt_long_only; + +/* The index in GETOPT_LONG_OPTIONS of the long-named option found. + Only valid when a long-named option has been found by the most + recent call to `getopt'. */ + +extern int option_index; + +#ifdef __STDC__ +int getopt (int argc, char **argv, const char *shortopts); +int getopt_long (int argc, char **argv, const char *shortopts, + const struct option *longopts, int *longind); +int getopt_long_only (int argc, char **argv, const char *shortopts, + const struct option *longopts, int *longind); +void envopt(int *pargc, char ***pargv, char *optstr); +#else +int getopt (); +int getopt_long (); +int getopt_long_only (); +void envopt(); +#endif diff --git a/1/newlibc/termcap/getopt1.c b/1/newlibc/termcap/getopt1.c new file mode 100755 index 0000000..d739acb --- /dev/null +++ b/1/newlibc/termcap/getopt1.c @@ -0,0 +1,160 @@ +/* Getopt for GNU. + Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +#include "getopt.h" + +#ifdef __STDC__ +#define CONST const +#else +#define CONST +#endif + +#if !defined (NULL) +#define NULL 0 +#endif + +int +getopt_long (argc, argv, options, long_options, opt_index) + int argc; + char **argv; + CONST char *options; + CONST struct option *long_options; + int *opt_index; +{ + int val; + + _getopt_long_options = long_options; + val = getopt (argc, argv, options); + if (val == 0 && opt_index != NULL) + *opt_index = option_index; + return val; +} + +/* Like getopt_long, but '-' as well as '+' can indicate a long option. + If an option that starts with '-' doesn't match a long option, + but does match a short option, it is parsed as a short option + instead. */ + +int +getopt_long_only (argc, argv, options, long_options, opt_index) + int argc; + char **argv; + CONST char *options; + CONST struct option *long_options; + int *opt_index; +{ + int val; + + _getopt_long_options = long_options; + _getopt_long_only = 1; + val = getopt (argc, argv, options); + if (val == 0 && opt_index != NULL) + *opt_index = option_index; + return val; +} + + +#ifdef TEST + +#include + +int +main (argc, argv) + int argc; + char **argv; +{ + int c; + int digit_optind = 0; + + while (1) + { + int this_option_optind = optind ? optind : 1; + char *name = '\0'; + int option_index = 0; + static struct option long_options[] = + { + {"add", 1, 0, 0}, + {"append", 0, 0, 0}, + {"delete", 1, 0, 0}, + {"verbose", 0, 0, 0}, + {"create", 0, 0, 0}, + {"file", 1, 0, 0}, + {0, 0, 0, 0} + }; + + c = getopt_long (argc, argv, "abc:d:0123456789", + long_options, &option_index); + if (c == EOF) + break; + + switch (c) + { + case 0: + printf ("option %s", (long_options[option_index]).name); + if (optarg) + printf (" with arg %s", optarg); + printf ("\n"); + break; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (digit_optind != 0 && digit_optind != this_option_optind) + printf ("digits occur in two different argv-elements.\n"); + digit_optind = this_option_optind; + printf ("option %c\n", c); + break; + + case 'a': + printf ("option a\n"); + break; + + case 'b': + printf ("option b\n"); + break; + + case 'c': + printf ("option c with value `%s'\n", optarg); + break; + + case '?': + break; + + default: + printf ("?? getopt returned character code 0%o ??\n", c); + } + } + + if (optind < argc) + { + printf ("non-option ARGV-elements: "); + while (optind < argc) + printf ("%s ", argv[optind++]); + printf ("\n"); + } + + exit (0); +} + +#endif /* TEST */ diff --git a/1/newlibc/termcap/makefile b/1/newlibc/termcap/makefile new file mode 100755 index 0000000..455858f --- /dev/null +++ b/1/newlibc/termcap/makefile @@ -0,0 +1,45 @@ +# +# Makefile for some odd library functions +# + +LIB =../Libtermcap.a +AR =gar +AS =gas +LD =gld +LDFLAGS =-s -x +CC =gcc +INC =#-nostdinc -I/linux/usr/include +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions $(INC) -DUSG -DSTDC_HEADERS + +CPP =$(CC) -E $(INC) + +.c.s: + $(CC) $(CFLAGS) \ + -S -o $*.s $< +.s.o: + $(CC) -c -o $*.o $< +.c.o: + $(CC) $(CFLAGS) \ + -c -o $*.o $< + +OBJS = tput.o conversions.o getopt.o getopt1.o termcap.o tparam.o +OBJS = termcap.o tparam.o + +all: library + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/termcap/termcap.c b/1/newlibc/termcap/termcap.c new file mode 100755 index 0000000..9ea1bb8 --- /dev/null +++ b/1/newlibc/termcap/termcap.c @@ -0,0 +1,681 @@ +/* Work-alike for termcap, plus extra features. + Copyright (C) 1985, 1986 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +/* BUFSIZE is the initial size allocated for the buffer + for reading the termcap file. + It is not a limit. + Make it large normally for speed. + Make it variable when debugging, so can exercise + increasing the space dynamically. */ + +#ifdef emacs +#include "config.h" +#else +#if defined(USG) || defined(STDC_HEADERS) +#ifdef __STDC__ +#include +#include +#include +#endif +#define bcopy(s, d, n) memcpy ((d), (s), (n)) +#endif +#endif + +#ifndef BUFSIZE +#ifdef DEBUG +#define BUFSIZE bufsize + +int bufsize = 128; +#else +#define BUFSIZE 2048 +#endif +#endif + +#ifndef emacs +static void +memory_out () +{ + write (2, "Virtual memory exhausted\n", 25); + exit (1); +} + +static void * +xmalloc (size) + int size; +{ + register void *tem = malloc (size); + if (!tem) + memory_out (); + return tem; +} + +static void * +xrealloc (ptr, size) + void *ptr; + int size; +{ + register void *tem = realloc (ptr, size); + if (!tem) + memory_out (); + return tem; +} +#endif /* not emacs */ + +/* Looking up capabilities in the entry already found */ + +/* The pointer to the data made by tgetent is left here + for tgetnum, tgetflag and tgetstr to find. */ + +static char *term_entry; + +static char *tgetst1 (); + +/* This is the main subroutine that is used to search + an entry for a particular capability */ + +static char * +find_capability (bp, cap) + register char *bp, *cap; +{ + for (; *bp; bp++) + if (bp[0] == ':' + && bp[1] == cap[0] + && bp[2] == cap[1]) + return &bp[4]; + return 0; +} + +int +tgetnum (cap) + char *cap; +{ + register char *ptr = find_capability (term_entry, cap); + if (!ptr || ptr[-1] != '#') + return -1; + return atoi (ptr); +} + +int +tgetflag (cap) + char *cap; +{ + register char *ptr = find_capability (term_entry, cap); + return 0 != ptr && ptr[-1] == ':'; +} + +/* Look up a string-valued capability `cap'. + If `area' is nonzero, it points to a pointer to a block in which + to store the string. That pointer is advanced over the space used. + If `area' is zero, space is allocated with `malloc'. */ + +char * +tgetstr (cap, area) + char *cap; + char **area; +{ + register char *ptr = find_capability (term_entry, cap); + if (!ptr || (ptr[-1] != '=' && ptr[-1] != '~')) + return 0; + return tgetst1 (ptr, area); +} + +/* Table, indexed by a character in range 0100 to 0140 with 0100 subtracted, + gives meaning of character following \, or a space if no special meaning. + Eight characters per line within the string. */ + +static char esctab[] + = " \007\010 \033\014 \ + \012 \ + \015 \011 \013 \ + "; + +/* Given a pointer to a string value inside a termcap entry (`ptr'), + copy the value and process \ and ^ abbreviations. + Copy into block that *area points to, + or to newly allocated storage if area is 0. */ + +static char * +tgetst1 (ptr, area) + char *ptr; + char **area; +{ + register char *p, *r; + register int c; + register int size; + char *ret; + register int c1; + + if (!ptr) + return 0; + + /* `ret' gets address of where to store the string */ + if (!area) + { + /* Compute size of block needed (may overestimate) */ + p = ptr; + while ((c = *p++) && c != ':' && c != '\n'); + ret = (char *) xmalloc (p - ptr + 1); + } + else + ret = *area; + + /* Copy the string value, stopping at null or colon. */ + /* Also process ^ and \ abbreviations. */ + p = ptr; + r = ret; + while ((c = *p++) && c != ':' && c != '\n') + { + if (c == '^') + c = *p++ & 037; + else if (c == '\\') + { + c = *p++; + if (c >= '0' && c <= '7') + { + c -= '0'; + size = 0; + + while (++size < 3 && (c1 = *p) >= '0' && c1 <= '7') + { + c *= 8; + c += c1 - '0'; + p++; + } + } + else if (c >= 0100 && c < 0200) + { + c1 = esctab[(c & ~040) - 0100]; + if (c1 != ' ') + c = c1; + } + } + *r++ = c; + } + *r = 0; + /* Update *area */ + if (area) + *area = r + 1; + return ret; +} + +/* Outputting a string with padding */ + +short ospeed; +/* If OSPEED is 0, we use this as the actual baud rate. */ +int tputs_baud_rate; +char PC; + +/* Actual baud rate if positive; + - baud rate / 100 if negative. */ + +static short speeds[] = + { +#ifdef VMS + 0, 50, 75, 110, 134, 150, -3, -6, -12, -18, + -20, -24, -36, -48, -72, -96, -192 +#else /* not VMS */ + 0, 50, 75, 110, 135, 150, -2, -3, -6, -12, + -18, -24, -48, -96, -192, -384 +#endif /* not VMS */ + }; + +void +tputs (string, nlines, outfun) + register char *string; + int nlines; + register int (*outfun) (); +{ + register int padcount = 0; + register int speed; + +#ifdef emacs + extern baud_rate; + speed = baud_rate; +#else + if (ospeed == 0) + speed = tputs_baud_rate; + else + speed = speeds[ospeed]; +#endif + + if (string == (char *) 0) + return; + + while (*string >= '0' && *string <= '9') + { + padcount += *string++ - '0'; + padcount *= 10; + } + if (*string == '.') + { + string++; + padcount += *string++ - '0'; + } + if (*string == '*') + { + string++; + padcount *= nlines; + } + while (*string) + (*outfun) (*string++); + + /* padcount is now in units of tenths of msec. */ + padcount *= speeds[ospeed]; + padcount += 500; + padcount /= 1000; + if (speeds[ospeed] < 0) + padcount = -padcount; + else + { + padcount += 50; + padcount /= 100; + } + + while (padcount-- > 0) + (*outfun) (PC); +} + +/* Finding the termcap entry in the termcap data base */ + +struct buffer + { + char *beg; + int size; + char *ptr; + int ateof; + int full; + }; + +/* Forward declarations of static functions */ + +static int scan_file (); +static char *gobble_line (); +static int compare_contin (); +static int name_match (); + +#ifdef VMS + +#include +#include +#include + +static int +legal_filename_p (fn) + char *fn; +{ + struct FAB fab = cc$rms_fab; + struct NAM nam = cc$rms_nam; + char esa[NAM$C_MAXRSS]; + + fab.fab$l_fna = fn; + fab.fab$b_fns = strlen(fn); + fab.fab$l_nam = &nam; + fab.fab$l_fop = FAB$M_NAM; + + nam.nam$l_esa = esa; + nam.nam$b_ess = sizeof esa; + + return SYS$PARSE(&fab, 0, 0) == RMS$_NORMAL; +} + +#endif /* VMS */ + +/* Find the termcap entry data for terminal type `name' + and store it in the block that `bp' points to. + Record its address for future use. + + If `bp' is zero, space is dynamically allocated. */ + +int +tgetent (bp, name) + char *bp, *name; +{ + register char *tem; + register int fd; + struct buffer buf; + register char *bp1; + char *bp2; + char *term; + int malloc_size = 0; + register int c; + char *tcenv; /* TERMCAP value, if it contais :tc=. */ + char *indirect = 0; /* Terminal type in :tc= in TERMCAP value. */ + int filep; + + tem = (char *) getenv ("TERMCAP"); + if (tem && *tem == 0) tem = 0; + +#ifdef VMS + filep = tem && legal_filename_p (tem); +#else + filep = tem && (*tem == '/'); +#endif /* VMS */ + + /* If tem is non-null and starts with / (in the un*x case, that is), + it is a file name to use instead of /etc/termcap. + If it is non-null and does not start with /, + it is the entry itself, but only if + the name the caller requested matches the TERM variable. */ + + if (tem && !filep && !strcmp (name, getenv ("TERM"))) + { + indirect = tgetst1 (find_capability (tem, "tc"), 0); + if (!indirect) + { + if (!bp) + bp = tem; + else + strcpy (bp, tem); + goto ret; + } + else + { /* we will need to read /etc/termcap */ + tcenv = tem; + tem = 0; + } + } + else + indirect = (char *) 0; + + if (!tem) +#ifdef VMS + tem = "emacs_library:[etc]termcap.dat"; +#else + tem = "/etc/termcap"; +#endif + + /* Here we know we must search a file and tem has its name. */ + + fd = open (tem, 0, 0); + if (fd < 0) + return -1; + + buf.size = BUFSIZE; + /* Add 1 to size to ensure room for terminating null. */ + buf.beg = (char *) xmalloc (buf.size + 1); + term = indirect ? indirect : name; + + if (!bp) + { + malloc_size = indirect ? strlen (tcenv) + 1 : buf.size; + bp = (char *) xmalloc (malloc_size); + } + bp1 = bp; + + if (indirect) /* copy the data from the environment variable */ + { + strcpy (bp, tcenv); + bp1 += strlen (tcenv); + } + + while (term) + { + /* Scan file, reading it via buf, till find start of main entry */ + if (scan_file (term, fd, &buf) == 0) + return 0; + + /* Free old `term' if appropriate. */ + if (term != name) + free (term); + + /* If `bp' is malloc'd by us, make sure it is big enough. */ + if (malloc_size) + { + malloc_size = bp1 - bp + buf.size; + tem = (char *) xrealloc (bp, malloc_size); + bp1 += tem - bp; + bp = tem; + } + + bp2 = bp1; + + /* Copy the line of the entry from buf into bp. */ + tem = buf.ptr; + while ((*bp1++ = c = *tem++) && c != '\n') + /* Drop out any \ newline sequence. */ + if (c == '\\' && *tem == '\n') + { + bp1--; + tem++; + } + *bp1 = 0; + + /* Does this entry refer to another terminal type's entry? */ + /* If something is found, copy it into heap and null-terminate it */ + term = tgetst1 (find_capability (bp2, "tc"), 0); + } + + close (fd); + free (buf.beg); + + if (malloc_size) + { + bp = (char *) xrealloc (bp, bp1 - bp + 1); + } + + ret: + term_entry = bp; + if (malloc_size) + return (int) bp; + return 1; +} + +/* Given file open on `fd' and buffer `bufp', + scan the file from the beginning until a line is found + that starts the entry for terminal type `string'. + Returns 1 if successful, with that line in `bufp', + or returns 0 if no entry found in the file. */ + +static int +scan_file (string, fd, bufp) + char *string; + int fd; + register struct buffer *bufp; +{ + register char *end; + + bufp->ptr = bufp->beg; + bufp->full = 0; + bufp->ateof = 0; + *bufp->ptr = 0; + + lseek (fd, 0L, 0); + + while (!bufp->ateof) + { + /* Read a line into the buffer */ + end = 0; + do + { + /* if it is continued, append another line to it, + until a non-continued line ends */ + end = gobble_line (fd, bufp, end); + } + while (!bufp->ateof && end[-2] == '\\'); + + if (*bufp->ptr != '#' + && name_match (bufp->ptr, string)) + return 1; + + /* Discard the line just processed */ + bufp->ptr = end; + } + return 0; +} + +/* Return nonzero if NAME is one of the names specified + by termcap entry LINE. */ + +static int +name_match (line, name) + char *line, *name; +{ + register char *tem; + + if (!compare_contin (line, name)) + return 1; + /* This line starts an entry. Is it the right one? */ + for (tem = line; *tem && *tem != '\n' && *tem != ':'; tem++) + if (*tem == '|' && !compare_contin (tem + 1, name)) + return 1; + + return 0; +} + +static int +compare_contin (str1, str2) + register char *str1, *str2; +{ + register int c1, c2; + while (1) + { + c1 = *str1++; + c2 = *str2++; + while (c1 == '\\' && *str1 == '\n') + { + str1++; + while ((c1 = *str1++) == ' ' || c1 == '\t'); + } + if (c2 == '\0') /* end of type being looked up */ + { + if (c1 == '|' || c1 == ':') /* If end of name in data base, */ + return 0; /* we win. */ + else + return 1; + } + else if (c1 != c2) + return 1; + } +} + +/* Make sure that the buffer <- `bufp' contains a full line + of the file open on `fd', starting at the place `bufp->ptr' + points to. Can read more of the file, discard stuff before + `bufp->ptr', or make the buffer bigger. + + Returns the pointer to after the newline ending the line, + or to the end of the file, if there is no newline to end it. + + Can also merge on continuation lines. If `append_end' is + nonzero, it points past the newline of a line that is + continued; we add another line onto it and regard the whole + thing as one line. The caller decides when a line is continued. */ + +static char * +gobble_line (fd, bufp, append_end) + int fd; + register struct buffer *bufp; + char *append_end; +{ + register char *end; + register int nread; + register char *buf = bufp->beg; + register char *tem; + + if (append_end == 0) + append_end = bufp->ptr; + + while (1) + { + end = append_end; + while (*end && *end != '\n') end++; + if (*end) + break; + if (bufp->ateof) + return buf + bufp->full; + if (bufp->ptr == buf) + { + if (bufp->full == bufp->size) + { + bufp->size *= 2; + /* Add 1 to size to ensure room for terminating null. */ + tem = (char *) xrealloc (buf, bufp->size + 1); + bufp->ptr = (bufp->ptr - buf) + tem; + append_end = (append_end - buf) + tem; + bufp->beg = buf = tem; + } + } + else + { + append_end -= bufp->ptr - buf; + bcopy (bufp->ptr, buf, bufp->full -= bufp->ptr - buf); + bufp->ptr = buf; + } + if (!(nread = read (fd, buf + bufp->full, bufp->size - bufp->full))) + bufp->ateof = 1; + bufp->full += nread; + buf[bufp->full] = 0; + } + return end + 1; +} + +#ifdef TEST + +#include + +main (argc, argv) + int argc; + char **argv; +{ + char *term; + char *buf; + + term = argv[1]; + printf ("TERM: %s\n", term); + + buf = (char *) tgetent (0, term); + if ((int) buf <= 0) + { + printf ("No entry.\n"); + return 0; + } + + printf ("Entry: %s\n", buf); + + tprint ("cm"); + tprint ("AL"); + + printf ("co: %d\n", tgetnum ("co")); + printf ("am: %d\n", tgetflag ("am")); +} + +tprint (cap) + char *cap; +{ + char *x = tgetstr (cap, 0); + register char *y; + + printf ("%s: ", cap); + if (x) + { + for (y = x; *y; y++) + if (*y <= ' ' || *y == 0177) + printf ("\\%0o", *y); + else + putchar (*y); + free (x); + } + else + printf ("none"); + putchar ('\n'); +} + +#endif /* TEST */ + diff --git a/1/newlibc/termcap/termcap.h b/1/newlibc/termcap/termcap.h new file mode 100755 index 0000000..9cd702b --- /dev/null +++ b/1/newlibc/termcap/termcap.h @@ -0,0 +1,42 @@ +/* Header file for termcap library. */ + +#ifdef __STDC__ + +extern int tgetent (char *buffer, char *termtype); + +extern int tgetnum (char *name); +extern int tgetflag (char *name); +extern char *tgetstr (char *name, char **area); + +extern char PC; +extern short ospeed; +extern int tputs (char *string, int nlines, int (*outfun) ()); + +extern char *tparam (char *ctlstring, char *buffer, int size, ...); + +extern char *UP; +extern char *BC; + +extern char *tgoto (char *cstring, int hpos, int vpos); + +#else /* not ANSI C */ + +extern int tgetent (); + +extern int tgetnum (); +extern int tgetflag (); +extern char *tgetstr (); + +extern char PC; +extern short ospeed; + +extern int tputs (); + +extern char *tparam (); + +extern char *UP; +extern char *BC; + +extern char *tgoto (); + +#endif /* not ANSI C */ diff --git a/1/newlibc/termcap/tparam.c b/1/newlibc/termcap/tparam.c new file mode 100755 index 0000000..ff5bfae --- /dev/null +++ b/1/newlibc/termcap/tparam.c @@ -0,0 +1,283 @@ +/* Merge parameters into a termcap entry string. + Copyright (C) 1985, 1987 Free Software Foundation, Inc. + +This file is part of GNU Emacs. + +GNU Emacs is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 1, or (at your option) +any later version. + +GNU Emacs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GNU Emacs; see the file COPYING. If not, write to +the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +/* config.h may rename various library functions such as malloc. */ +#ifdef emacs +#include "config.h" +#else +#if defined(USG) || defined(STDC_HEADERS) +#ifdef __STDC__ +#include +#include +#endif +#define bcopy(s, d, n) memcpy ((d), (s), (n)) +#endif +#endif + +/* Assuming STRING is the value of a termcap string entry + containing `%' constructs to expand parameters, + merge in parameter values and store result in block OUTSTRING points to. + LEN is the length of OUTSTRING. If more space is needed, + a block is allocated with `malloc'. + + The value returned is the address of the resulting string. + This may be OUTSTRING or may be the address of a block got with `malloc'. + In the latter case, the caller must free the block. + + The fourth and following args to tparam serve as the parameter values. */ + +static char *tparam1 (); + +/* VARARGS 2 */ +char * +tparam (string, outstring, len, arg0, arg1, arg2, arg3) + char *string; + char *outstring; + int len; + int arg0, arg1, arg2, arg3; +{ +#ifdef NO_ARG_ARRAY + int arg[4]; + arg[0] = arg0; + arg[1] = arg1; + arg[2] = arg2; + arg[3] = arg3; + return tparam1 (string, outstring, len, 0, 0, arg); +#else + return tparam1 (string, outstring, len, 0, 0, &arg0); +#endif +} + +char *BC; +char *UP; + +static char tgoto_buf[50]; + +char * +tgoto (cm, hpos, vpos) + char *cm; + int hpos, vpos; +{ + int args[2]; + if (!cm) + return 0; + args[0] = vpos; + args[1] = hpos; + return tparam1 (cm, tgoto_buf, 50, UP, BC, args); +} + +static char * +tparam1 (string, outstring, len, up, left, argp) + char *string; + char *outstring; + int len; + char *up, *left; + register int *argp; +{ + register int c; + register char *p = string; + register char *op = outstring; + char *outend; + int outlen = 0; + + register int tem; + int *oargp = argp; + int doleft = 0; + int doup = 0; + + outend = outstring + len; + + while (1) + { + /* If the buffer might be too short, make it bigger. */ + if (op + 5 >= outend) + { + register char *new; + if (outlen == 0) + { + new = (char *) malloc (outlen = 40 + len); + outend += 40; + bcopy (outstring, new, op - outstring); + } + else + { + outend += outlen; + new = (char *) realloc (outstring, outlen *= 2); + } + op += new - outstring; + outend += new - outstring; + outstring = new; + } + if (!(c = *p++)) + break; + if (c == '%') + { + c = *p++; + tem = *argp; + switch (c) + { + case 'd': /* %d means output in decimal */ + if (tem < 10) + goto onedigit; + if (tem < 100) + goto twodigit; + case '3': /* %3 means output in decimal, 3 digits. */ + if (tem > 999) + { + *op++ = tem / 1000 + '0'; + tem %= 1000; + } + *op++ = tem / 100 + '0'; + case '2': /* %2 means output in decimal, 2 digits. */ + twodigit: + tem %= 100; + *op++ = tem / 10 + '0'; + onedigit: + *op++ = tem % 10 + '0'; + argp++; + break; + + case 'C': + /* For c-100: print quotient of value by 96, if nonzero, + then do like %+ */ + if (tem >= 96) + { + *op++ = tem / 96; + tem %= 96; + } + case '+': /* %+x means add character code of char x */ + tem += *p++; + case '.': /* %. means output as character */ + if (left) + { + /* If want to forbid output of 0 and \n and \t, + and this is one of them, increment it. */ + while (tem == 0 || tem == '\n' || tem == '\t') + { + tem++; + if (argp == oargp) + doup++, outend -= strlen (up); + else + doleft++, outend -= strlen (left); + } + } + *op++ = tem | 0200; + case 'f': /* %f means discard next arg */ + argp++; + break; + + case 'b': /* %b means back up one arg (and re-use it) */ + argp--; + break; + + case 'r': /* %r means interchange following two args */ + argp[0] = argp[1]; + argp[1] = tem; + oargp++; + break; + + case '>': /* %>xy means if arg is > char code of x, */ + if (argp[0] > *p++) /* then add char code of y to the arg, */ + argp[0] += *p; /* and in any case don't output. */ + p++; /* Leave the arg to be output later. */ + break; + + case 'a': /* %a means arithmetic */ + /* Next character says what operation. + Add or subtract either a constant or some other arg */ + /* First following character is + to add or - to subtract + or = to assign. */ + /* Next following char is 'p' and an arg spec + (0100 plus position of that arg relative to this one) + or 'c' and a constant stored in a character */ + tem = p[2] & 0177; + if (p[1] == 'p') + tem = argp[tem - 0100]; + if (p[0] == '-') + argp[0] -= tem; + else if (p[0] == '+') + argp[0] += tem; + else if (p[0] == '*') + argp[0] *= tem; + else if (p[0] == '/') + argp[0] /= tem; + else + argp[0] = tem; + + p += 3; + break; + + case 'i': /* %i means add one to arg, */ + argp[0] ++; /* and leave it to be output later. */ + argp[1] ++; /* Increment the following arg, too! */ + break; + + case '%': /* %% means output %; no arg. */ + goto ordinary; + + case 'n': /* %n means xor each of next two args with 140 */ + argp[0] ^= 0140; + argp[1] ^= 0140; + break; + + case 'm': /* %m means xor each of next two args with 177 */ + argp[0] ^= 0177; + argp[1] ^= 0177; + break; + + case 'B': /* %B means express arg as BCD char code. */ + argp[0] += 6 * (tem / 10); + break; + + case 'D': /* %D means weird Delta Data transformation */ + argp[0] -= 2 * (tem % 16); + break; + } + } + else + /* Ordinary character in the argument string. */ + ordinary: + *op++ = c; + } + *op = 0; + while (doup-- > 0) + strcat (op, up); + while (doleft-- > 0) + strcat (op, left); + return outstring; +} + +#ifdef DEBUG + +main (argc, argv) + int argc; + char **argv; +{ + char buf[50]; + int args[3]; + args[0] = atoi (argv[2]); + args[1] = atoi (argv[3]); + args[2] = atoi (argv[4]); + tparam1 (argv[1], buf, "LEFT", "UP", args); + printf ("%s\n", buf); + return 0; +} + +#endif /* DEBUG */ diff --git a/1/newlibc/termcap/tput.c b/1/newlibc/termcap/tput.c new file mode 100755 index 0000000..256ac4b --- /dev/null +++ b/1/newlibc/termcap/tput.c @@ -0,0 +1,341 @@ +/* tput -- shell-level interface to terminfo, emulated by termcap. + Copyright (C) 1989 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Usage: tput [-T termtype] [+terminal=termtype] capability [parameter...] + + Options: + -T termtype + +terminal=termtype Override $TERM. + + Link with -ltermcap. + Requires the GNU termcap library. + Also requires the bsearch library function. + + David MacKenzie */ + +#include +#include +#include +#include +#include +#include "tput.h" + +#ifndef SIGTYPE +#define SIGTYPE void +#endif + +/* Exit codes. */ +#define CAP_PRESENT 0 /* Normal operation. */ +#define BOOLEAN_FALSE 1 /* Boolean capability not present. */ +#define USAGE_ERROR 2 /* Invalid arguments given. */ +#define UNKNOWN_TERM 3 /* $TERM not found in termcap file. */ +#define MISSING_CAP 4 /* Termcap entry lacks this capability. */ +#define ERROR_EXIT 5 /* Real error or signal. */ + +char *bsearch (); +char *getenv (); + +int info_compare (); +SIGTYPE signal_handler (); +int tcputchar (); +struct conversion *find_info (); +void put_bool (); +void put_num (); +void put_str (); +void restore_translations (); +void translations_off (); +void setup_termcap (); +void usage (); + +/* The name this program was run with, for error messages. */ +char *program_name; + +struct option long_options[] = +{ + {"terminal", 1, NULL, 0}, + {NULL, 0, NULL, 0} +}; + +void +main (argc, argv) + int argc; + char **argv; +{ + struct conversion *conv; /* Conversion table entry. */ + char *term; /* Terminal type. */ + int c; /* Option character. */ + + program_name = argv[0]; + term = getenv ("TERM"); + + while ((c = getopt_long (argc, argv, "T:", long_options, (int *) 0)) != EOF) + { + switch (c) + { + case 0: + break; + + case 'T': + term = optarg; + break; + + default: + usage (); + } + } + + if (optind == argc) + usage (); + + setup_termcap (term); + + conv = find_info (argv[optind]); + if (conv == NULL) + { + fprintf (stderr, "%s: Unknown terminfo capability `%s'\n", + program_name, argv[optind]); + exit (MISSING_CAP); + } + + ++optind; + + if (conv->type & NUM) + put_num (conv); + else if (conv->type & BOOL) + put_bool (conv); + else + put_str (conv, argv, argc); + + exit (CAP_PRESENT); +} + +/* Return a pointer to the conversion table entry for terminfo + capability INFONAME. + Return NULL if INFONAME is not a valid terminfo capability. */ + +struct conversion * +find_info (infoname) + char *infoname; +{ + struct conversion conv; + + conv.info = infoname; + return (struct conversion *) + bsearch ((char *) &conv, (char *) conversions, CAPABILITIES, + sizeof (struct conversion), info_compare); +} + +/* Terminfo capability name comparison function for bsearch. */ + +int +info_compare (conv1, conv2) + struct conversion *conv1, *conv2; +{ + return strcmp (conv1->info, conv2->info); +} + +void +put_num (conv) + struct conversion *conv; +{ + printf ("%d\n", tgetnum (conv->cap)); +} + +void +put_bool (conv) + struct conversion *conv; +{ + if (!tgetflag (conv->cap)) + exit (BOOLEAN_FALSE); +} + +void +put_str (conv, argv, argc) + struct conversion *conv; + char **argv; + int argc; +{ + char *string_value; /* String capability. */ + int lines_affected; /* Number of lines affected by capability. */ + + string_value = tgetstr (conv->cap, (char **) NULL); + if (string_value == NULL) + exit (MISSING_CAP); + + if (!strcmp (conv->cap, "cm")) + { + BC = tgetstr ("le", (char **) NULL); + UP = tgetstr ("up", (char **) NULL); + + /* The order of command-line arguments is `vertical horizontal'. + If horizontal is not given, it defaults to 0. */ + switch (argc - optind) + { + case 0: + break; + case 1: + string_value = tgoto (string_value, 0, atoi (argv[optind])); + break; + default: + string_value = tgoto (string_value, + atoi (argv[optind + 1]), atoi (argv[optind])); + break; + } + } + else + /* Although the terminfo `sgr' capability can take 9 parameters, + the GNU tparam function only accepts up to 4. + I don't know whether tparam could interpret an `sgr' + capability reasonably even if it could accept that many + parameters. For now, we'll live with the 4-parameter limit. */ + switch (argc - optind) + { + case 0: + break; + case 1: + string_value = tparam (string_value, (char *) NULL, 0, + atoi (argv[optind])); + break; + case 2: + string_value = tparam (string_value, (char *) NULL, 0, + atoi (argv[optind]), + atoi (argv[optind + 1])); + break; + case 3: + string_value = tparam (string_value, (char *) NULL, 0, + atoi (argv[optind]), + atoi (argv[optind + 1]), + atoi (argv[optind + 2])); + break; + default: + string_value = tparam (string_value, (char *) NULL, 0, + atoi (argv[optind]), + atoi (argv[optind + 1]), + atoi (argv[optind + 2]), + atoi (argv[optind + 3])); + break; + } + + /* Since we don't know where the cursor is, we have to be + pessimistic for capabilities that need padding proportional to + the number of lines affected, and tell them that the whole + screen is affected. */ + if (conv->type & PAD) + lines_affected = tgetnum ("li"); + else + lines_affected = 1; + + if (lines_affected < 1) + lines_affected = 1; + + translations_off (); + tputs (string_value, lines_affected, tcputchar); + fflush (stdout); + restore_translations (); +} + +/* Output function for tputs. */ + +int +tcputchar (c) + char c; +{ + putchar (c & 0x7f); + return c; +} + +/* Read in the needed termcap strings for terminal type TERM. */ + +void +setup_termcap (term) + char *term; +{ + char *tc_pc; /* "pc" termcap string. */ + + if (term == NULL) + { + fprintf (stderr, "%s: No value for $TERM and no -T specified\n", + program_name); + exit (UNKNOWN_TERM); + } + switch (tgetent ((char *) NULL, term)) + { + case 0: + fprintf (stderr, "%s: Unknown terminal type `%s'\n", program_name, term); + exit (UNKNOWN_TERM); + case -1: + fprintf (stderr, "%s: No termcap database\n", program_name); + exit (UNKNOWN_TERM); + } + + tc_pc = tgetstr ("pc", (char **) NULL); + PC = tc_pc ? *tc_pc : 0; +} + +struct sgttyb old_modes, new_modes; + +/* Turn off expansion of tabs into spaces, saving the old + terminal settings first. + Also set OSPEED. */ + +void +translations_off () +{ + if (isatty (1)) + { + gtty (1, &old_modes); + + if (signal (SIGINT, SIG_IGN) != SIG_IGN) + signal (SIGINT, signal_handler); + if (signal (SIGHUP, SIG_IGN) != SIG_IGN) + signal (SIGHUP, signal_handler); + if (signal (SIGQUIT, SIG_IGN) != SIG_IGN) + signal (SIGQUIT, signal_handler); + signal (SIGTERM, signal_handler); + + new_modes = old_modes; + new_modes.sg_flags &= ~XTABS; + stty (1, &new_modes); + ospeed = old_modes.sg_ospeed; + } + else + ospeed = 0; +} + +/* Restore the old terminal settings. */ + +void +restore_translations () +{ + stty (1, &old_modes); +} + +SIGTYPE +signal_handler () +{ + restore_translations (); + exit (ERROR_EXIT); +} + +void +usage () +{ + fprintf (stderr, "\ +Usage: %s [-T termtype] [+terminal=termtype] capability [parameter...]\n", + program_name); + exit (USAGE_ERROR); +} diff --git a/1/newlibc/termcap/tput.h b/1/newlibc/termcap/tput.h new file mode 100755 index 0000000..988b93a --- /dev/null +++ b/1/newlibc/termcap/tput.h @@ -0,0 +1,35 @@ +/* tput.h -- constants and declarations for tput + Copyright (C) 1989 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + +/* Capability types. */ +#define BOOL 1 /* Boolean capability. */ +#define NUM 2 /* Numeric capability. */ +#define STR 4 /* String capability. */ +#define PAD 8 /* String accepts padding. */ + +struct conversion +{ + char *info; /* Terminfo name. */ + char *cap; /* Termcap name. */ + char type; /* Capability type. */ +}; + +/* The number of entries in `conversions'. */ + +#define CAPABILITIES 310 + +extern struct conversion conversions[]; diff --git a/1/newlibc/termcap/tput.texinfo b/1/newlibc/termcap/tput.texinfo new file mode 100755 index 0000000..09d9720 --- /dev/null +++ b/1/newlibc/termcap/tput.texinfo @@ -0,0 +1,651 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header +@setfilename tput.info +@settitle @code{tput}: Portable Terminal Control for Shell Scripts +@setchapternewpage odd +@c %**end of header + +@ifinfo +This file documents the the GNU @code{tput} command for translating +terminal capability names into escape and control codes for a particular +terminal. + +Copyright @copyright{} 1989-1991 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Foundation. +@end ifinfo + +@titlepage +@title The GNU @code{tput} Command +@subtitle Portable Terminal Control for Shell Scripts + +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1989-1991 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Foundation. +@end titlepage + +@node Top, , (dir), (dir) +@comment node-name, next, previous, up +@chapter @code{tput}: Portable Terminal Control for Shell Scripts + +The @code{tput} command translates the terminal-independent name of a +terminal capability into its actual value for the terminal type being +used. This allows shell scripts to do things like clear the screen, +underline text, and center text no matter how wide the screen is. + +@code{tput} takes as an argument the name of a Unix System V terminfo +capability, which it translates into the equivalent termcap capability +name (@pxref{Capabilities}, for a list of the equivalencies). + +There are three types of terminfo (and termcap) capabilities: string, +Boolean, and numeric. String capabilities either cause a special +effect on the terminal when they are displayed or are the value sent by +a special key on the terminal (the latter type are probably of no use +in shell scripts). Numeric and Boolean capabilities give +information about the terminal such as how many columns wide it is or +whether whether it has a meta key. @xref{Output}, for more detailed +information on the three types of capabilities. + +The format of the @code{tput} command is illustrated below, with the +optional portions in square brackets, @samp{[@dots{}]}: + +@example +tput [-T @var{terminal-type}] [+terminal=@var{terminal-type}] @var{capability} [@var{parameter} @dots{}] +@end example + +Here is an example of how to clear the terminal screen using @code{tput}: + +@example +tput clear +@end example + +@menu +* Using tput:: Using the @code{tput} command. +* Output:: Output and exit status. +* More Examples:: More examples of using @code{tput}. +* Capabilities:: Summary of terminfo capabilities. +* Error Messages:: Error messages produced by @code{tput}. +* Notes:: Miscellaneous information about @code{tput}. +@end menu + +@node Using tput, Output, , Top +@c node-name, next, previous, up +@section Using the @code{tput} Command + +The format of the @code{tput} command is illustrated below, with the +optional portions in square brackets, @samp{[@dots{}]}: + +@example +tput [-T @var{terminal-type}] [+terminal=@var{terminal-type}] @var{capability} [@var{parameter} @dots{}] +@end example + +Some string capabilities accept parameters, such as the number of lines +to delete or the column to move to. These parameters are specified on +the command line following the capability name. They are always numbers. + +@table @samp +@item -T @var{termtype} +@itemx +terminal=@var{termtype} +This option indicates the type of terminal. By default, this value is +taken from the @samp{TERM} environment variable. +@end table + +Below are some example uses of @code{tput}. @xref{Capabilities}, for +a complete list of the functions that @code{tput} can cause terminals to +perform. Note that not all terminals can perform any given function. +@xref{More Examples}, for some more complex samples of @code{tput} use. + +The following command moves the cursor to row 10, column 30 of the screen: + +@example +tput cup 10 30 +@end example + +The following command makes the cursor invisible: + +@example +tput civis +@end example + +The following command makes the cursor visible again: + +@example +tput cnorm +@end example + +The following command deletes 10 lines below and including the one +on which the cursor is positioned: + +@example +tput dl 10 +@end example + +@node Output, More Examples, Using tput, Top +@comment node-name, next, previous, up +@section Output and Exit Status + +The @code{tput} command produces different kinds of output for each of +the three types of terminal capabilities: string, numeric, and Boolean. + +If the terminfo capability given on the command line is a string +capability, @code{tput} displays its value and exits with a status of 0. +If the capability is not defined for the terminal type being used, +@code{tput} produces no output and exits with a status of 1. + +If the capability is a numeric capability, @code{tput} displays its +value (an integer). If the capability is not defined for the terminal +type being used, @code{tput} displays the value @samp{-1}. The exit +status is always 0 for numeric capabilities, unless an error occurs +(@pxref{Notes} for a complete list of the possible exit status +values).@refill + +If the capability is a Boolean capability, @code{tput} produces no +output and exits with status 0 if the capability is defined for the +terminal type being used, or status 1 if the capability is not defined. +@xref{Capabilities,,Definitions of the Terminal Capabilities,termcap,Termcap}, +for a more detailed description of termcap capabilities.@refill + +The values of numeric capabilities should be saved into shell +variables so they can be used later without having to run @code{tput} +again. Here is how it can be done: + +@example +For the Bourne, Bourne-again, and Korn shells: + +To set an environment variable: COLUMNS=`tput cols` export COLUMNS + +To set a local variable: tabwidth=`tput it` + +For the C shell: + +To set an environment variable: setenv COLUMNS `tput cols` + +To set a local variable: set tabwidth = `tput it` +@end example + +@noindent +The values of string capabilities can be saved in shell variables in the +same way, then displayed later using the @code{echo} command. Since +@code{echo} is built into most shells, it runs more quickly than +@code{tput} does. However, using @code{echo} instead of @code{tput} to +display string values can cause problems for capabilities that use +padding, because null padding characters cannot be passed as arguments +to commands, including @code{echo}. + +@node More Examples, Capabilities, Output, Top +@c node-name, next, previous, up +@section Yet More Examples + +Here are some more advanced examples of using @code{tput}; most involve +some shell programming. Because the C shell's flow control (decision +making) constructs differ from those of the other shells, these +examples do not work under the C shell. + +The following sequence of commands prints @samp{I am infalible} and +then crosses it out on terminals that can overstrike, and prints +@samp{I am on strike} on terminals that cannot. + +@example +if tput os; then + echo 'I am infalible\r- -- ---------' +else + echo 'I am on strike' +fi +@end example + +The following example is a shell script that centers a line of text +given as command line arguments. An alternative approach would be to +have @code{tput} send the @samp{rep} terminfo capability to print the +multiple spaces instead of using the @code{while} loop. + +@example +COLUMNS=`tput cols` export COLUMNS # Get screen width. +echo "$@@" | awk ' +@{ spaces = ('$COLUMNS' - length) / 2 + while (spaces-- > 0) printf (" ") + print +@}' +@end example + +The following commands cause the terminal to save the current cursor +position, print @samp{Hello, World} centered in the screen in reverse +video, then return to the original cursor position. + +@example +COLUMNS=`tput cols` +LINES=`tput lines` +line=`expr $LINES / 2` +column=`expr \( $COLUMNS - 6 \) / 2` +tput sc +tput cup $line $column +tput rev +echo 'Hello, World' +tput sgr0 +tput rc +@end example + +@node Capabilities, Error Messages, More Examples, Top +@c node-name, next, previous, up +@section Capabilities + +@subsection Boolean Capabilities + +@example +Name Termcap Description + Equiv. + +am am Has automatic margins +bw bw @samp{cub1} wraps from column 0 to last column +chts HC Cursor is hard to see +da da Display may be retained above screen +db db Display may be retained below screen +eo eo Can erase overstrikes with a blank +eslok es Using escape on status line is ok +gn gn Generic line type (e.g., @samp{dialup}, @samp{switch}) +hc hc Hardcopy terminal +hs hs Has a status line +hz hz Hazeltine; cannot print tildes +in in Insert mode distinguishes nulls +km km Has a meta key (a shift that sets parity bit) +mc5i 5i Data sent to printer does not echo on screen +mir mi Safe to move while in insert mode +msgr ms Safe to move in standout modes +npc NP No pad character is needed +nrrmc NR @samp{smcup} does not reverse @samp{rmcup} +nxon nx Padding does not work; xon/xoff is required +os os Overstrikes +ul ul Underline character overstrikes +xenl xn Newline ignored after 80 columns (Concept) +xhp xs Standout is not erased by overwriting (HP) +xon xo Uses xon/xoff handshaking +xsb xb Beehive (f1=escape, f2=ctrl-c) +xt xt Tabs are destructive, magic @samp{smso} (t1061) +@end example + +@subsection Numeric Capabilities + +@example +Name Termcap Description + Equiv. + +cols co Number of columns in a line +it it Width of initial tab settings +lh lh Number of rows in each label +lines li Number of lines on screen or page +lm lm Lines of memory if > @samp{lines}; 0 means varies +lw lw Number of columns in each label +nlab Nl Number of labels on screen (start at 1) +pb pb Lowest baud rate where padding is needed +vt vt Virtual terminal number (CB/Unix) +wsl ws Number of columns in status line +xmc sg Number of blanks left by @samp{smso} or @samp{rmso} +@end example + +@subsection String Capabilities + +In the following table, @samp{(P)} following an explanation means +that the capability takes one or more parameters (and is evaluated by +the @code{tparam} function, or in the case of @samp{cup}, +@code{tgoto}); @samp{(*)} means that padding may be based on the +number of lines affected; and @samp{#n} refers to the @samp{n}th +parameter.@refill + +@example +Name Termcap Description + Equiv. + +acsc ac Graphic character set pairs aAbBcC - default vt100 +bel bl Ring bell (beep) +blink mb Begin blinking mode +bold md Begin double intensity mode +cbt bt Back tab +civis vi Make cursor invisible +clear cl Clear screen (*) +cmdch CC Settable command character in prototype +cnorm ve Make cursor normal (undo @samp{cvvis} & @samp{civis)} +cr cr Carriage return (*) +csr cs Change scrolling region to lines #1 through #2 (P) +cub LE Move cursor left #1 spaces (P) +cub1 le Move cursor left one space +cud DO Move cursor down #1 lines (P*) +cud1 do Move cursor down one line +cuf RI Move cursor right #1 spaces (P*) +cuf1 nd Move cursor right one space +cup cm Move cursor to row #1, column #2 of screen (P) +cuu UP Move cursor up #1 lines (P*) +cuu1 up Move cursor up one line +cvvis vs Make cursor very visible +dch DC Delete #1 characters (P*) +dch1 dc Delete one character (*) +dim mh Begin half intensity mode +dl DL Delete #1 lines (P*) +dl1 dl Delete one line (*) +dsl ds Disable status line +ech ec Erase #1 characters (P) +ed cd Clear to end of display (*) +el ce Clear to end of line +el1 cb Clear to beginning of line, inclusive +enacs eA Enable alternate character set +ff ff Form feed for hardcopy terminal (*) +flash vb Visible bell (must not move cursor) +fsl fs Return from status line +hd hd Move cursor down one-half line +home ho Home cursor (if no @samp{cup}) +hpa ch Move cursor to column #1 (P) +ht ta Tab to next 8 space hardware tab stop +hts st Set a tab in all rows, current column +hu hu Move cursor up one-half line +ich IC Insert #1 blank characters (P*) +ich1 ic Insert one blank character +if if Name of file containing initialization string +il AL Add #1 new blank lines (P*) +il1 al Add one new blank line (*) +ind sf Scroll forward (up) one line +indn SF Scroll forward #1 lines (P) +invis mk Begin invisible text mode +ip ip Insert pad after character inserted (*) +iprog iP Path of program for initialization +is1 i1 Terminal initialization string +is2 is Terminal initialization string +is3 i3 Terminal initialization string +kBEG &9 Shifted beginning key +kCAN &0 Shifted cancel key +kCMD *1 Shifted command key +kCPY *2 Shifted copy key +kCRT *3 Shifted create key +kDC *4 Shifted delete char key +kDL *5 Shifted delete line key +kEND *7 Shifted end key +kEOL *8 Shifted clear line key +kEXT *9 Shifted exit key +kFND *0 Shifted find key +kHLP #1 Shifted help key +kHOM #2 Shifted home key +kIC #3 Shifted input key +kLFT #4 Shifted left arrow key +kMOV %b Shifted move key +kMSG %a Shifted message key +kNXT %c Shifted next key +kOPT %d Shifted options key +kPRT %f Shifted print key +kPRV %e Shifted prev key +kRDO %g Shifted redo key +kRES %j Shifted resume key +kRIT %i Shifted right arrow +kRPL %h Shifted replace key +kSAV !1 Shifted save key +kSPD !2 Shifted suspend key +kUND !3 Shifted undo key +ka1 K1 Upper left of keypad +ka3 K3 Upper right of keypad +kb2 K2 Center of keypad +kbeg @@1 Beginning key +kbs kb Backspace key +kc1 K4 Lower left of keypad +kc3 K5 Lower right of keypad +kcan @@2 Cancel key +kcbt kB Back tab key +kclo @@3 Close key +kclr kC Clear screen or erase key +kcmd @@4 Command key +kcpy @@5 Copy key +kcrt @@6 Create key +kctab kt Clear tab key +kcub1 kl Left arrow key +kcud1 kd Down arrow key +kcuf1 kr Right arrow key +kcuu1 ku Up arrow key +kdch1 kD Delete character key +kdl1 kL Delete line key +ked kS Clear to end of screen key +kel kE Clear to end of line key +kend @@7 End key +kent @@8 Enter/send key (unreliable) +kext @@9 Exit key +kf0 k0 Function key f0 +kf1 k1 Function key f1 +kf10 k; Function key f10 +kf11 F1 Function key f11 +kf12 F2 Function key f12 +kf13 F3 Function key f13 +kf14 F4 Function key f14 +kf15 F5 Function key f15 +kf16 F6 Function key f16 +kf17 F7 Function key f17 +kf18 F8 Function key f18 +kf19 F9 Function key f19 +kf2 k2 Function key f2 +kf20 FA Function key f20 +kf21 FB Function key f21 +kf22 FC Function key f22 +kf23 FD Function key f23 +kf24 FE Function key f24 +kf25 FF Function key f25 +kf26 FG Function key f26 +kf27 FH Function key f27 +kf28 FI Function key f28 +kf29 FJ Function key f29 +kf3 k3 Function key f3 +kf30 FK Function key f30 +kf31 FL Function key f31 +kf32 FM Function key f32 +kf33 FN Function key f13 +kf34 FO Function key f34 +kf35 FP Function key f35 +kf36 FQ Function key f36 +kf37 FR Function key f37 +kf38 FS Function key f38 +kf39 FT Function key f39 +kf4 k4 Function key f4 +kf40 FU Function key f40 +kf41 FV Function key f41 +kf42 FW Function key f42 +kf43 FX Function key f43 +kf44 FY Function key f44 +kf45 FZ Function key f45 +kf46 Fa Function key f46 +kf47 Fb Function key f47 +kf48 Fc Function key f48 +kf49 Fd Function key f49 +kf5 k5 Function key f5 +kf50 Fe Function key f50 +kf51 Ff Function key f51 +kf52 Fg Function key f52 +kf53 Fh Function key f53 +kf54 Fi Function key f54 +kf55 Fj Function key f55 +kf56 Fk Function key f56 +kf57 Fl Function key f57 +kf58 Fm Function key f58 +kf59 Fn Function key f59 +kf6 k6 Function key f6 +kf60 Fo Function key f60 +kf61 Fp Function key f61 +kf62 Fq Function key f62 +kf63 Fr Function key f63 +kf7 k7 Function key f7 +kf8 k8 Function key f8 +kf9 k9 Function key f9 +kfnd @@0 Find key +khlp %1 Help key +khome kh Home key +khts kT Set tab key +kich1 kI Ins char/enter ins mode key +kil1 kA Insert line key +kind kF Scroll forward/down key +kll kH Home down key +kmov %4 Move key +kmrk %2 Mark key +kmsg %3 Message key +knp kN Next page key +knxt %5 Next object key +kopn %6 Open key +kopt %7 Options key +kpp kP Previous page key +kprt %9 Print or copy key +kprv %8 Previous object key +krdo %0 Redo key +kref &1 Reference key +kres &5 Resume key +krfr &2 Refresh key +kri kR Scroll backward/up key +krmir kM @code{rmir} or @code{smir} in insert mode +krpl &3 Replace key +krst &4 Restart key +ksav &6 Save key +kslt *6 Select key +kspd &7 Suspend key +ktbc ka Clear all tabs key +kund &8 Undo key +lf0 l0 Label on function key f0 if not @samp{f0} +lf1 l1 Label on function key f1 if not @samp{f1} +lf10 la Label on function key f10 if not @samp{f10} +lf2 l2 Label on function key f2 if not @samp{f2} +lf3 l3 Label on function key f3 if not @samp{f3} +lf4 l4 Label on function key f4 if not @samp{f4} +lf5 l5 Label on function key f5 if not @samp{f5} +lf6 l6 Label on function key f6 if not @samp{f6} +lf7 l7 Label on function key f7 if not @samp{f7} +lf8 l8 Label on function key f8 if not @samp{f8} +lf9 l9 Label on function key f9 if not @samp{f9} +ll ll Go to last line, first column (if no @samp{cup}) +mc0 ps Print screen contents +mc4 pf Turn printer off +mc5 po Turn printer on +mc5p pO Turn printer on for #1 bytes (P) +mgc MC Clear left and right soft margins +mrcup CM Move cursor to row #1, column #2 of memory (P) +nel nw Newline (like cr followed by lf) +pad pc Pad character (rather than nul) +pfkey pk Program function key #1 to type string #2 (P) +pfloc pl Program function key #1 to execute string #2 (P) +pfx px Program function key #1 to transmit string #2 (P) +pln pn Program label #1 to show string #2 (P) +prot mp Begin protected mode +rc rc Restore cursor to position of last @samp{sc} +rep rp Repeat character #1, #2 times (P*) +rev mr Begin reverse video mode +rf rf Name of file containing reset string +rfi RF Send next input character (for ptys) +ri sr Scroll backward (down) one line +rin SR Scroll backward #1 lines (P) +rmacs ae End alternate character set +rmam RA Turn off automatic margins +rmcup te String to end programs that use @samp{cup} +rmdc ed End delete mode +rmir ei End insert mode +rmkx ke End keypad transmit mode +rmln LF Turn off soft labels +rmm mo End meta mode +rmp rP Like @samp{ip} but when in replace mode +rmso se End standout mode +rmul ue End underscore mode +rmxon RX Turn off xon/xoff handshaking +rs1 r1 Reset terminal to sane modes +rs2 r2 Reset terminal to sane modes +rs3 r3 Reset terminal to sane modes +sc sc Save cursor position +sgr sa Define video attributes #1 through #9 (P) +sgr0 me Turn off all attributes +smacs as Begin alternate character set +smam SA Turn on automatic margins +smcup ti String to begin programs that use @samp{cup} +smdc dm Begin delete mode +smgl ML Set soft left margin to #1 (P) +smgr MR Set soft right margin to #1 (P) +smir im Begin insert mode +smkx ks Begin keypad transmit mode +smln LO Turn on soft labels +smm mm Begin meta mode (8th bit set) +smso so Begin standout mode +smul us Begin underscore mode +smxon SX Turn on xon/xoff handshaking +tbc ct Clear all tab stops +tsl ts Go to status line, column #1 (P) +uc uc Underscore one character and move past it +vpa cv Move cursor to row #1 (P) +wind wi Set window to lines #1-#2, columns #3-#4 (P) +xoffc XF xoff character +xonc XN xon character +@end example + +@node Error Messages, Notes, Capabilities, Top +@c node-name, next, previous, up +@section Error Messages + +@code{tput} displays various error messages if problems occur. In +addition, it exits with one of the following status values: + +@table @asis +@item 0 +Normal status; the given capability is present. + +@item 1 +The given Boolean or string capability is not present. + +@item 2 +Usage error; @code{tput} was given invalid arguments. + +@item 3 +The terminal type given (either in the @samp{TERM} environment variable +or by the @samp{-T} switch) is unknown, or the termcap database can not +be read. + +@item 4 +The given capability is unknown. +@end table + +@node Notes, , Error Messages, Top +@c node-name, next, previous, up +@section Notes + +Terminfo is a database that is similar to termcap but which has +different capability names and is stored in a different format. The GNU +@code{tput} command takes a terminfo name as an argument to make it +compatible with the Unix System V @code{tput} command; there is no +equivalent command, using termcap, in Berkeley Unix. + +@subsection Bugs + +The @samp{longname}, @samp{init}, and @samp{reset} options of the +System V @code{tput} command are not implemented; however, the @code{tset} +command can perform the latter two functions.@refill + +@subsection Author + +David MacKenzie wrote the GNU @code{tput} command. + +@bye diff --git a/1/newlibc/unistd/._Makefile b/1/newlibc/unistd/._Makefile new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/.__exit.c b/1/newlibc/unistd/.__exit.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._access.c b/1/newlibc/unistd/._access.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._acct.c b/1/newlibc/unistd/._acct.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._alarm.c b/1/newlibc/unistd/._alarm.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._brk.c b/1/newlibc/unistd/._brk.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._chdir.c b/1/newlibc/unistd/._chdir.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._chmod.c b/1/newlibc/unistd/._chmod.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._chown.c b/1/newlibc/unistd/._chown.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._chroot.c b/1/newlibc/unistd/._chroot.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._close.c b/1/newlibc/unistd/._close.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._creat.c b/1/newlibc/unistd/._creat.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._dup.c b/1/newlibc/unistd/._dup.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._dup2.c b/1/newlibc/unistd/._dup2.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._exec.c b/1/newlibc/unistd/._exec.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._execp.c b/1/newlibc/unistd/._execp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._execve.c b/1/newlibc/unistd/._execve.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._fcntl.c b/1/newlibc/unistd/._fcntl.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._fork.c b/1/newlibc/unistd/._fork.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._fstat.c b/1/newlibc/unistd/._fstat.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._getegid.c b/1/newlibc/unistd/._getegid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._geteuid.c b/1/newlibc/unistd/._geteuid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._getgid.c b/1/newlibc/unistd/._getgid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._getgroups.c b/1/newlibc/unistd/._getgroups.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._gethostnam.c b/1/newlibc/unistd/._gethostnam.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._getpgrp.c b/1/newlibc/unistd/._getpgrp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._getpid.c b/1/newlibc/unistd/._getpid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._getppid.c b/1/newlibc/unistd/._getppid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._getrlimit.c b/1/newlibc/unistd/._getrlimit.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._getrusage.c b/1/newlibc/unistd/._getrusage.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._gettime.c b/1/newlibc/unistd/._gettime.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._getuid.c b/1/newlibc/unistd/._getuid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._ioctl.c b/1/newlibc/unistd/._ioctl.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._kill.c b/1/newlibc/unistd/._kill.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._link.c b/1/newlibc/unistd/._link.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._lseek.c b/1/newlibc/unistd/._lseek.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._lstat.c b/1/newlibc/unistd/._lstat.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._mkdir.c b/1/newlibc/unistd/._mkdir.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._mknod.c b/1/newlibc/unistd/._mknod.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._mount.c b/1/newlibc/unistd/._mount.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._nice.c b/1/newlibc/unistd/._nice.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._open.c b/1/newlibc/unistd/._open.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._pause.c b/1/newlibc/unistd/._pause.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._pipe.c b/1/newlibc/unistd/._pipe.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._read.c b/1/newlibc/unistd/._read.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._readlink.c b/1/newlibc/unistd/._readlink.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._rmdir.c b/1/newlibc/unistd/._rmdir.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._select.c b/1/newlibc/unistd/._select.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._setgid.c b/1/newlibc/unistd/._setgid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._setgroups.c b/1/newlibc/unistd/._setgroups.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._sethostnam.c b/1/newlibc/unistd/._sethostnam.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._setpgrp.c b/1/newlibc/unistd/._setpgrp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._setregid.c b/1/newlibc/unistd/._setregid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._setreuid.c b/1/newlibc/unistd/._setreuid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._setrlimit.c b/1/newlibc/unistd/._setrlimit.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._setsid.c b/1/newlibc/unistd/._setsid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._settime.c b/1/newlibc/unistd/._settime.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._setuid.c b/1/newlibc/unistd/._setuid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._signal.c b/1/newlibc/unistd/._signal.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._sigpend.c b/1/newlibc/unistd/._sigpend.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._sigsusp.c b/1/newlibc/unistd/._sigsusp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._stat.c b/1/newlibc/unistd/._stat.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._stime.c b/1/newlibc/unistd/._stime.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._symlink.c b/1/newlibc/unistd/._symlink.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._sync.c b/1/newlibc/unistd/._sync.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._time.c b/1/newlibc/unistd/._time.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._times.c b/1/newlibc/unistd/._times.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._ulimit.c b/1/newlibc/unistd/._ulimit.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._umask.c b/1/newlibc/unistd/._umask.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._umount.c b/1/newlibc/unistd/._umount.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._uname.c b/1/newlibc/unistd/._uname.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._unlink.c b/1/newlibc/unistd/._unlink.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._uselib.c b/1/newlibc/unistd/._uselib.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._ustat.c b/1/newlibc/unistd/._ustat.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._utime.c b/1/newlibc/unistd/._utime.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._wait.c b/1/newlibc/unistd/._wait.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/._write.c b/1/newlibc/unistd/._write.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/Makefile b/1/newlibc/unistd/Makefile new file mode 100755 index 0000000..bf9527e --- /dev/null +++ b/1/newlibc/unistd/Makefile @@ -0,0 +1,53 @@ +# +# Makefile for some ansi-library functions +# + +OBJS = _exit.o access.o acct.o alarm.o brk.o chdir.o chmod.o chown.o \ +chroot.o close.o creat.o dup.o dup2.o exec.o execp.o execve.o fcntl.o \ +fork.o fstat.o getegid.o geteuid.o getgid.o getpid.o getppid.o getuid.o \ +getpgrp.o ioctl.o kill.o link.o lseek.o mkdir.o mknod.o mount.o nice.o \ +open.o pause.o pipe.o read.o rmdir.o setgid.o setpgrp.o setsid.o setuid.o \ +signal.o stat.o stime.o sync.o time.o times.o ulimit.o umask.o umount.o \ +uname.o unlink.o ustat.o utime.o wait.o write.o setreuid.o setregid.o \ +sigsusp.o sigpend.o sethostnam.o gethostnam.o \ +getgroups.o setgroups.o \ +symlink.o lstat.o readlink.o uselib.o +#select.o setrlimit.o getrlimit.o getrusage.o gettime.o settime.o + +LIB =../Libc.a +AR =/usr/local/bin/ar +AS =/usr/local/bin/as +LD =/usr/local/bin/ld +LDFLAGS =-s -x +CC =/usr/local/bin/gcc -B/usr/local/bin/ +INC =-nostdinc \ + -I../include +CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer \ + -finline-functions $(INC) +CPP =$(CC) -E $(INC) + +.c.s: + $(CC) $(CFLAGS) -S -o $*.s $< +.s.o: + $(CC) -c -o $*.o $< + +.c.o: + $(CC) $(CFLAGS) -c -o $*.o $< + +all: library + +library: $(OBJS) + $(AR) uvc $(LIB) $(OBJS) + sync + +clean: + $(RM) -f core *.o *.a tmp_make + for i in *.c;do $(RM) -f `basename $$i .c`.s;done + +dep: + sed '/\#\#\# Dependencies/q' < Makefile > tmp_make + (for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \ + $(CPP) -M $$i;done) >> tmp_make + cp tmp_make Makefile + +### Dependencies: diff --git a/1/newlibc/unistd/_exit.c b/1/newlibc/unistd/_exit.c new file mode 100755 index 0000000..c58ba9d --- /dev/null +++ b/1/newlibc/unistd/_exit.c @@ -0,0 +1,12 @@ +#define __LIBRARY__ +#include + +volatile void _exit(int exit_code) +{ +#ifdef PRE_GCC_2 + __asm__("movl %1,%%ebx\n\t" + "int $0x80"::"a" (__NR_exit),"g" (exit_code): "bx"); +#else + __asm__("int $0x80"::"a" (__NR_exit),"b" (exit_code)); +#endif +} diff --git a/1/newlibc/unistd/access.c b/1/newlibc/unistd/access.c new file mode 100755 index 0000000..e763a80 --- /dev/null +++ b/1/newlibc/unistd/access.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,access,const char *,filename,mode_t,mode) diff --git a/1/newlibc/unistd/acct.c b/1/newlibc/unistd/acct.c new file mode 100755 index 0000000..b60ea4b --- /dev/null +++ b/1/newlibc/unistd/acct.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,acct,const char *,filename) diff --git a/1/newlibc/unistd/alarm.c b/1/newlibc/unistd/alarm.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/brk.c b/1/newlibc/unistd/brk.c new file mode 100755 index 0000000..3f81756 --- /dev/null +++ b/1/newlibc/unistd/brk.c @@ -0,0 +1,48 @@ +#define __LIBRARY__ +#include +#include + +#if 1 +extern long _end; + +static void * ___brk_addr = &_end; +#else +void * ___brk_addr = NULL; +#endif + +int brk(void * end_data_seg) +{ +#ifdef PRE_GCC_2 + __asm__ volatile ("movl %0,%%ebx" : : "g" (end_data_seg): "bx"); + __asm__ volatile ("int $0x80" + :"=a" (___brk_addr) + :"0" (__NR_brk)); +#else + __asm__ volatile ("int $0x80" + :"=a" (___brk_addr) + :"0" (__NR_brk),"b" (end_data_seg)); +#endif + if (___brk_addr == end_data_seg) + return 0; + errno = ENOMEM; + return -1; +} + +void * sbrk(ptrdiff_t increment) +{ + void * tmp = ___brk_addr+increment; +#ifdef PRE_GCC_2 + __asm__ volatile ("movl %0,%%ebx" : : "g" (tmp): "bx"); + __asm__ volatile ("int $0x80" + :"=a" (___brk_addr) + :"0" (__NR_brk)); +#else + __asm__ volatile ("int $0x80" + :"=a" (___brk_addr) + :"0" (__NR_brk),"b" (tmp)); +#endif + if (___brk_addr == tmp) + return tmp-increment; + errno = ENOMEM; + return ((void *) -1); +} diff --git a/1/newlibc/unistd/chdir.c b/1/newlibc/unistd/chdir.c new file mode 100755 index 0000000..140c5a0 --- /dev/null +++ b/1/newlibc/unistd/chdir.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,chdir,const char *,pathname) diff --git a/1/newlibc/unistd/chmod.c b/1/newlibc/unistd/chmod.c new file mode 100755 index 0000000..b9488c5 --- /dev/null +++ b/1/newlibc/unistd/chmod.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,chmod,const char *,filename,mode_t,mode) diff --git a/1/newlibc/unistd/chown.c b/1/newlibc/unistd/chown.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/chroot.c b/1/newlibc/unistd/chroot.c new file mode 100755 index 0000000..fd1848b --- /dev/null +++ b/1/newlibc/unistd/chroot.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,chroot,const char *,pathname) diff --git a/1/newlibc/unistd/close.c b/1/newlibc/unistd/close.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/creat.c b/1/newlibc/unistd/creat.c new file mode 100755 index 0000000..2b94677 --- /dev/null +++ b/1/newlibc/unistd/creat.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,creat,const char *,filename,mode_t,mode) diff --git a/1/newlibc/unistd/dup.c b/1/newlibc/unistd/dup.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/dup2.c b/1/newlibc/unistd/dup2.c new file mode 100755 index 0000000..7b626ad --- /dev/null +++ b/1/newlibc/unistd/dup2.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,dup2,int,fd1,int,fd2) diff --git a/1/newlibc/unistd/exec.c b/1/newlibc/unistd/exec.c new file mode 100755 index 0000000..6bc64a2 --- /dev/null +++ b/1/newlibc/unistd/exec.c @@ -0,0 +1,30 @@ +#define __LIBRARY__ +#include +#include +#include +#include +#include +#include +#include + +extern char ** environ; + +static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp) + +int execv(const char * pathname, char ** argv) +{ + return execve(pathname,argv,environ); +} + +int execl(const char * pathname, char * arg0, ...) +{ + return execve(pathname,&arg0,environ); +} + +int execle(const char * pathname, char * arg0, ...) +{ + char ** env = &arg0; + + while (!*(env++)) ; + return execve(pathname,&arg0,env); +} diff --git a/1/newlibc/unistd/execp.c b/1/newlibc/unistd/execp.c new file mode 100755 index 0000000..4c060f8 --- /dev/null +++ b/1/newlibc/unistd/execp.c @@ -0,0 +1,60 @@ +#define __LIBRARY__ +#include +#include +#include +#include +#include +#include +#include + +extern char ** environ; + +static char tmp_path[PATH_MAX+1]; + +static inline _syscall3(int,execve,const char *,file,char **,argv,char **,envp) + +static int execvep(const char * file, char ** argv, char ** envp) +{ + char * path, * tmp; + int len; + struct stat st; + + if (*file=='/' || !*file || !(path=getenv("PATH"))) + return execve(file,argv,envp); + while (*path) { + tmp=tmp_path; + len=0; + while (len=PATH_MAX) + continue; + strncpy(tmp,file,PATH_MAX-len); + if (stat(tmp_path,&st)) + continue; + else + if (!(st.st_mode & S_IFREG)) + continue; + if (!access(tmp_path,1)) + return execve(tmp_path,argv,envp); + } + errno = ENOEXEC; + return -1; +} + +int execvp(const char * file, char ** argv) +{ + return execvep(file,argv,environ); +} + +int execlp(const char * file, char * arg0, ...) +{ + return execvep(file,&arg0,environ); +} diff --git a/1/newlibc/unistd/execve.c b/1/newlibc/unistd/execve.c new file mode 100755 index 0000000..03772e3 --- /dev/null +++ b/1/newlibc/unistd/execve.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall3(int,execve,const char *,file,char **,argv,char **,envp) diff --git a/1/newlibc/unistd/fcntl.c b/1/newlibc/unistd/fcntl.c new file mode 100755 index 0000000..bf505a5 --- /dev/null +++ b/1/newlibc/unistd/fcntl.c @@ -0,0 +1,27 @@ +#define __LIBRARY__ +#include +#include + +int fcntl(int fildes, int cmd, ...) +{ + register int res; + va_list arg; + + va_start(arg,cmd); +#ifdef PRE_GCC_2 + __asm__("movl %0,%%ebx" : : "g" (fildes) : "bx"); + __asm__("movl %0,%%ecx" : : "g" (cmd)); + __asm__("movl %0,%%edx" : : "g" (va_arg(arg,int))); + __asm__("int $0x80" :"=a" (res) :"0" (__NR_fcntl)); +#else + __asm__("int $0x80" + :"=a" (res) + :"0" (__NR_fcntl),"b" (fildes),"c" (cmd), + "d" (va_arg(arg,int))); +#endif + if (res>=0) + return res; + errno = -res; + va_end (arg); + return -1; +} diff --git a/1/newlibc/unistd/fork.c b/1/newlibc/unistd/fork.c new file mode 100755 index 0000000..651e1e5 --- /dev/null +++ b/1/newlibc/unistd/fork.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall0(int,fork) diff --git a/1/newlibc/unistd/fstat.c b/1/newlibc/unistd/fstat.c new file mode 100755 index 0000000..d191465 --- /dev/null +++ b/1/newlibc/unistd/fstat.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,fstat,int,fd,struct stat *,stat_buf) diff --git a/1/newlibc/unistd/getegid.c b/1/newlibc/unistd/getegid.c new file mode 100755 index 0000000..8afdfb1 --- /dev/null +++ b/1/newlibc/unistd/getegid.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall0(int,getegid) diff --git a/1/newlibc/unistd/geteuid.c b/1/newlibc/unistd/geteuid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/getgid.c b/1/newlibc/unistd/getgid.c new file mode 100755 index 0000000..9873de2 --- /dev/null +++ b/1/newlibc/unistd/getgid.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall0(int,getgid) diff --git a/1/newlibc/unistd/getgroups.c b/1/newlibc/unistd/getgroups.c new file mode 100755 index 0000000..8491dea --- /dev/null +++ b/1/newlibc/unistd/getgroups.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,getgroups,int,getsetlen,gid_t *,gidset) diff --git a/1/newlibc/unistd/gethostnam.c b/1/newlibc/unistd/gethostnam.c new file mode 100755 index 0000000..8869a9d --- /dev/null +++ b/1/newlibc/unistd/gethostnam.c @@ -0,0 +1,16 @@ +#include +#include +#include + +int gethostname(char *name, int len) +{ + struct utsname uts; + + uname(&uts); + if (strlen(uts.nodename)+1 > len) { + errno = EINVAL; + return -1; + } + strcpy(name, uts.nodename); + return 0; +} diff --git a/1/newlibc/unistd/getpgrp.c b/1/newlibc/unistd/getpgrp.c new file mode 100755 index 0000000..4f4b440 --- /dev/null +++ b/1/newlibc/unistd/getpgrp.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall0(pid_t,getpgrp) diff --git a/1/newlibc/unistd/getpid.c b/1/newlibc/unistd/getpid.c new file mode 100755 index 0000000..73fccfd --- /dev/null +++ b/1/newlibc/unistd/getpid.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall0(int,getpid) diff --git a/1/newlibc/unistd/getppid.c b/1/newlibc/unistd/getppid.c new file mode 100755 index 0000000..e59099a --- /dev/null +++ b/1/newlibc/unistd/getppid.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall0(int,getppid) diff --git a/1/newlibc/unistd/getrlimit.c b/1/newlibc/unistd/getrlimit.c new file mode 100755 index 0000000..021727d --- /dev/null +++ b/1/newlibc/unistd/getrlimit.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,getrlimit,int,resource,struct rlimit *,rlp) diff --git a/1/newlibc/unistd/getrusage.c b/1/newlibc/unistd/getrusage.c new file mode 100755 index 0000000..16f2e81 --- /dev/null +++ b/1/newlibc/unistd/getrusage.c @@ -0,0 +1,5 @@ +#define __LIBRARY__ +#include + +_syscall2(int,getrusage,int,who,struct rusage *,rusage) + diff --git a/1/newlibc/unistd/gettime.c b/1/newlibc/unistd/gettime.c new file mode 100755 index 0000000..12c1971 --- /dev/null +++ b/1/newlibc/unistd/gettime.c @@ -0,0 +1,5 @@ +#define __LIBRARY__ +#include + +_syscall2(int,gettimeofday,struct timeval *,tv,struct timezone *,tz) + diff --git a/1/newlibc/unistd/getuid.c b/1/newlibc/unistd/getuid.c new file mode 100755 index 0000000..eb43aaa --- /dev/null +++ b/1/newlibc/unistd/getuid.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall0(int,getuid) diff --git a/1/newlibc/unistd/ioctl.c b/1/newlibc/unistd/ioctl.c new file mode 100755 index 0000000..d9ea4f0 --- /dev/null +++ b/1/newlibc/unistd/ioctl.c @@ -0,0 +1,27 @@ +#define __LIBRARY__ +#include +#include + +int ioctl(int fildes, int cmd, ...) +{ + register int res; + va_list arg; + + va_start(arg,cmd); +#ifdef PRE_GCC_2 + __asm__("movl %0,%%ebx" : : "g" (fildes) : "bx"); + __asm__("movl %0,%%ecx" : : "g" (cmd)); + __asm__("movl %0,%%edx" : : "g" (va_arg(arg,int))); + __asm__("int $0x80" :"=a" (res) :"0" (__NR_ioctl)); +#else + __asm__("int $0x80" + :"=a" (res) + :"0" (__NR_ioctl),"b" (fildes),"c" (cmd), + "d" (va_arg(arg,int))); +#endif + if (res>=0) + return res; + errno = -res; + va_end(arg); + return -1; +} diff --git a/1/newlibc/unistd/kill.c b/1/newlibc/unistd/kill.c new file mode 100755 index 0000000..4e0a48b --- /dev/null +++ b/1/newlibc/unistd/kill.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,kill,pid_t,pid,int,signal) diff --git a/1/newlibc/unistd/link.c b/1/newlibc/unistd/link.c new file mode 100755 index 0000000..7bb5e2a --- /dev/null +++ b/1/newlibc/unistd/link.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,link,const char *,filename1,const char *,filename2) diff --git a/1/newlibc/unistd/lseek.c b/1/newlibc/unistd/lseek.c new file mode 100755 index 0000000..9e6a718 --- /dev/null +++ b/1/newlibc/unistd/lseek.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall3(int,lseek,int,fildes,off_t,offset,int,origin) diff --git a/1/newlibc/unistd/lstat.c b/1/newlibc/unistd/lstat.c new file mode 100755 index 0000000..ec8768a --- /dev/null +++ b/1/newlibc/unistd/lstat.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,lstat,const char *,filename,struct stat *,stat_buf) diff --git a/1/newlibc/unistd/mkdir.c b/1/newlibc/unistd/mkdir.c new file mode 100755 index 0000000..3354793 --- /dev/null +++ b/1/newlibc/unistd/mkdir.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,mkdir,const char *,pathname,mode_t,mode) diff --git a/1/newlibc/unistd/mknod.c b/1/newlibc/unistd/mknod.c new file mode 100755 index 0000000..9ebb388 --- /dev/null +++ b/1/newlibc/unistd/mknod.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall3(int,mknod,const char *,nodename,mode_t,mode,dev_t,dev) diff --git a/1/newlibc/unistd/mount.c b/1/newlibc/unistd/mount.c new file mode 100755 index 0000000..da3f371 --- /dev/null +++ b/1/newlibc/unistd/mount.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall3(int,mount,const char *,specialfile,const char *,dir,int,rwflag) diff --git a/1/newlibc/unistd/nice.c b/1/newlibc/unistd/nice.c new file mode 100755 index 0000000..3544e7b --- /dev/null +++ b/1/newlibc/unistd/nice.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,nice,int,val) diff --git a/1/newlibc/unistd/open.c b/1/newlibc/unistd/open.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/pause.c b/1/newlibc/unistd/pause.c new file mode 100755 index 0000000..30238c3 --- /dev/null +++ b/1/newlibc/unistd/pause.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall0(int,pause) diff --git a/1/newlibc/unistd/pipe.c b/1/newlibc/unistd/pipe.c new file mode 100755 index 0000000..1b01eb0 --- /dev/null +++ b/1/newlibc/unistd/pipe.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,pipe,int *,fildes) diff --git a/1/newlibc/unistd/read.c b/1/newlibc/unistd/read.c new file mode 100755 index 0000000..47e8335 --- /dev/null +++ b/1/newlibc/unistd/read.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall3(int,read,int,fd,char *,buf,off_t,count) diff --git a/1/newlibc/unistd/readlink.c b/1/newlibc/unistd/readlink.c new file mode 100755 index 0000000..e6f1236 --- /dev/null +++ b/1/newlibc/unistd/readlink.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall3(int,readlink,const char *,path,char *,buffer,int,bufsiz) diff --git a/1/newlibc/unistd/rmdir.c b/1/newlibc/unistd/rmdir.c new file mode 100755 index 0000000..888ce66 --- /dev/null +++ b/1/newlibc/unistd/rmdir.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,rmdir,const char *,pathname) diff --git a/1/newlibc/unistd/select.c b/1/newlibc/unistd/select.c new file mode 100755 index 0000000..3a0ac19 --- /dev/null +++ b/1/newlibc/unistd/select.c @@ -0,0 +1,24 @@ +#define __LIBRARY__ +#include +#include + +int select(int nd, fd_set * in, fd_set * out, fd_set * ex, + struct timeval * tv) +{ + long __res; + +#ifdef PRE_GCC_2 + __asm__ volatile ("movl %0,%%ebx" : : "g" ((long) &nd) + : "bx"); + __asm__ volatile ("int $0x80" : "=a" (__res) + : "0" (__NR_select)); +#else + __asm__ volatile ("int $0x80" + : "=a" (__res) + : "0" (__NR_select),"b" ((long) &nd)); +#endif + if (__res >= 0) + return (int) __res; + errno = -__res; + return -1; +} diff --git a/1/newlibc/unistd/setgid.c b/1/newlibc/unistd/setgid.c new file mode 100755 index 0000000..2d2f245 --- /dev/null +++ b/1/newlibc/unistd/setgid.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,setgid,gid_t,gid) diff --git a/1/newlibc/unistd/setgroups.c b/1/newlibc/unistd/setgroups.c new file mode 100755 index 0000000..7a96b47 --- /dev/null +++ b/1/newlibc/unistd/setgroups.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,setgroups,int,getsetlen,gid_t *,gidset) diff --git a/1/newlibc/unistd/sethostnam.c b/1/newlibc/unistd/sethostnam.c new file mode 100755 index 0000000..4756773 --- /dev/null +++ b/1/newlibc/unistd/sethostnam.c @@ -0,0 +1,5 @@ +#define __LIBRARY__ +#include + +_syscall2(int,sethostname,char *, name,int,len) + diff --git a/1/newlibc/unistd/setpgrp.c b/1/newlibc/unistd/setpgrp.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/setregid.c b/1/newlibc/unistd/setregid.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/setreuid.c b/1/newlibc/unistd/setreuid.c new file mode 100755 index 0000000..fd5a16c --- /dev/null +++ b/1/newlibc/unistd/setreuid.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,setreuid,uid_t,uid1,uid_t,uid2) diff --git a/1/newlibc/unistd/setrlimit.c b/1/newlibc/unistd/setrlimit.c new file mode 100755 index 0000000..64ee9fe --- /dev/null +++ b/1/newlibc/unistd/setrlimit.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,setrlimit,int,resource,struct rlimit *,rlp) diff --git a/1/newlibc/unistd/setsid.c b/1/newlibc/unistd/setsid.c new file mode 100755 index 0000000..730abf0 --- /dev/null +++ b/1/newlibc/unistd/setsid.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall0(pid_t,setsid) diff --git a/1/newlibc/unistd/settime.c b/1/newlibc/unistd/settime.c new file mode 100755 index 0000000..b080369 --- /dev/null +++ b/1/newlibc/unistd/settime.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,settimeofday,struct timeval *,tv,struct timezone *,tz) diff --git a/1/newlibc/unistd/setuid.c b/1/newlibc/unistd/setuid.c new file mode 100755 index 0000000..cb3d7ce --- /dev/null +++ b/1/newlibc/unistd/setuid.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,setuid,uid_t,uid) diff --git a/1/newlibc/unistd/signal.c b/1/newlibc/unistd/signal.c new file mode 100755 index 0000000..a52f0a1 --- /dev/null +++ b/1/newlibc/unistd/signal.c @@ -0,0 +1,64 @@ +#define __LIBRARY__ +#include +#include + +extern void ___sig_restore(); +extern void ___masksig_restore(); + +int ___ssetmask(int mask) +{ + long res; +#ifdef PRE_GCC_2 + __asm__("movl %0,%%ebx" : : "g" (mask) : "bx"); + __asm__("int $0x80" :"=a" (res) :"0" (__NR_ssetmask)); +#else + __asm__("int $0x80":"=a" (res) + :"0" (__NR_ssetmask),"b" (mask)); +#endif + return res; +} + +int ___sgetmask(void) +{ + long res; + __asm__("int $0x80":"=a" (res) + :"0" (__NR_sgetmask)); + return res; +} + +void (*signal(int sig, void (*func)(int)))(int) +{ + void (*res)(); + +#ifdef PRE_GCC_2 + __asm__("movl %0,%%ebx" : : "g" (sig) : "bx"); + __asm__("movl %0,%%ecx" : : "g" (func)); + __asm__("movl %0,%%edx" : : "g" ((long)___sig_restore)); + __asm__("int $0x80" :"=a" (res) :"0" (__NR_signal)); +#else + __asm__("int $0x80":"=a" (res): + "0" (__NR_signal),"b" (sig),"c" (func),"d" ((long)___sig_restore)); +#endif + return res; +} + +int sigaction(int sig,struct sigaction * sa, struct sigaction * old) +{ + if (sa->sa_flags & SA_NOMASK) + sa->sa_restorer=___sig_restore; + else + sa->sa_restorer=___masksig_restore; +#ifdef PRE_GCC_2 + __asm__("movl %0,%%ebx" : : "g" (sig) : "bx"); + __asm__("movl %0,%%ecx" : : "g" (sa)); + __asm__("movl %0,%%edx" : : "g" (old)); + __asm__("int $0x80" :"=a" (sig) :"0" (__NR_sigaction)); +#else + __asm__("int $0x80":"=a" (sig) + :"0" (__NR_sigaction),"b" (sig),"c" (sa),"d" (old)); +#endif + if (sig>=0) + return sig; + errno = -sig; + return -1; +} diff --git a/1/newlibc/unistd/sigpend.c b/1/newlibc/unistd/sigpend.c new file mode 100755 index 0000000..934ff49 --- /dev/null +++ b/1/newlibc/unistd/sigpend.c @@ -0,0 +1,5 @@ +#define __LIBRARY__ +#include +#include + +_syscall1(int,sigpending,sigset_t *,sigmask) diff --git a/1/newlibc/unistd/sigsusp.c b/1/newlibc/unistd/sigsusp.c new file mode 100755 index 0000000..251d991 --- /dev/null +++ b/1/newlibc/unistd/sigsusp.c @@ -0,0 +1,24 @@ +#define __LIBRARY__ +#include +#include + +int sigsuspend(sigset_t *set) +{ + int res; + +#ifdef PRE_GCC_2 + __asm__("xorl %%ebx,%%ebx" : : : "bx"); + __asm__("xorl %%ecx,%%ecx" : : : "cx"); + __asm__("movl %0,%%edx" : : "g" (*set)); + __asm__("int $0x80" :"=a" (res) :"0" (__NR_sigsuspend)); +#else + __asm__("int $0x80" + :"=a" (res) + :"0" (__NR_sigsuspend), "b" (0), "c" (0), "d" (*set) + :"bx","cx"); +#endif + if (res >= 0) + return res; + errno = -res; + return -1; +} diff --git a/1/newlibc/unistd/stat.c b/1/newlibc/unistd/stat.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/stime.c b/1/newlibc/unistd/stime.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/symlink.c b/1/newlibc/unistd/symlink.c new file mode 100755 index 0000000..c22cfb3 --- /dev/null +++ b/1/newlibc/unistd/symlink.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,symlink,const char *,filename1,const char *,filename2) diff --git a/1/newlibc/unistd/sync.c b/1/newlibc/unistd/sync.c new file mode 100755 index 0000000..9c5ba50 --- /dev/null +++ b/1/newlibc/unistd/sync.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall0(int,sync) diff --git a/1/newlibc/unistd/time.c b/1/newlibc/unistd/time.c new file mode 100755 index 0000000..8de53b7 --- /dev/null +++ b/1/newlibc/unistd/time.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(time_t,time,time_t *,tptr) diff --git a/1/newlibc/unistd/times.c b/1/newlibc/unistd/times.c new file mode 100755 index 0000000..4abeed4 --- /dev/null +++ b/1/newlibc/unistd/times.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(time_t,times,struct tms *,tms_buf) diff --git a/1/newlibc/unistd/ulimit.c b/1/newlibc/unistd/ulimit.c new file mode 100755 index 0000000..7fd128b --- /dev/null +++ b/1/newlibc/unistd/ulimit.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,ulimit,int,cmd,long,limit) diff --git a/1/newlibc/unistd/umask.c b/1/newlibc/unistd/umask.c new file mode 100755 index 0000000..328ba48 --- /dev/null +++ b/1/newlibc/unistd/umask.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(mode_t,umask,mode_t,mask) diff --git a/1/newlibc/unistd/umount.c b/1/newlibc/unistd/umount.c new file mode 100755 index 0000000..5b35f10 --- /dev/null +++ b/1/newlibc/unistd/umount.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,umount,const char *,specialfile) diff --git a/1/newlibc/unistd/uname.c b/1/newlibc/unistd/uname.c new file mode 100755 index 0000000..3dcc6e7 --- /dev/null +++ b/1/newlibc/unistd/uname.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,uname,struct utsname *,uname_buf) diff --git a/1/newlibc/unistd/unlink.c b/1/newlibc/unistd/unlink.c new file mode 100755 index 0000000..1c8a163 --- /dev/null +++ b/1/newlibc/unistd/unlink.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,unlink,const char *,filename) diff --git a/1/newlibc/unistd/uselib.c b/1/newlibc/unistd/uselib.c new file mode 100755 index 0000000..b40d14e --- /dev/null +++ b/1/newlibc/unistd/uselib.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall1(int,uselib,const char *,filename) diff --git a/1/newlibc/unistd/ustat.c b/1/newlibc/unistd/ustat.c new file mode 100755 index 0000000..e69de29 diff --git a/1/newlibc/unistd/utime.c b/1/newlibc/unistd/utime.c new file mode 100755 index 0000000..e4aa542 --- /dev/null +++ b/1/newlibc/unistd/utime.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall2(int,utime,const char *,filename,struct utimbuf *,times) diff --git a/1/newlibc/unistd/wait.c b/1/newlibc/unistd/wait.c new file mode 100755 index 0000000..a14555c --- /dev/null +++ b/1/newlibc/unistd/wait.c @@ -0,0 +1,10 @@ +#define __LIBRARY__ +#include +#include + +_syscall3(pid_t,waitpid,pid_t,pid,int *,wait_stat,int,options) + +pid_t wait(int * wait_stat) +{ + return waitpid(-1,wait_stat,0); +} diff --git a/1/newlibc/unistd/write.c b/1/newlibc/unistd/write.c new file mode 100755 index 0000000..2613f17 --- /dev/null +++ b/1/newlibc/unistd/write.c @@ -0,0 +1,4 @@ +#define __LIBRARY__ +#include + +_syscall3(int,write,int,fd,const char *,buf,off_t,count) diff --git a/1/rundev/._0.11-dev.bxrc b/1/rundev/._0.11-dev.bxrc new file mode 100755 index 0000000000000000000000000000000000000000..ed468115a07b8ddda62c778b027d5f656a6385c5 GIT binary patch literal 4096 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDJkFz{^v(m+1nBL)UWIUt(=a103vVh{+) zgy>+H0aPxEriBs6hl-0P=jZAr78K;9>J^qI7A5ADWagzZ7#LU>S(_Q8SX!D}T3Uyv zI%g!7Sfd#-${h`X(GVC7fzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4FTj30ChG&7!2e> zGBS%5ic*X7ON)|I71HvHvK2D(N>YK{&iuT@oSaI9oYb@ug`}Lsylh}!7^-VXQ>gxj Ldqsvp?*D%P$Vqox1Ojhs@R)|o50+1L3ClDJkFz{^v(m+1nBL)UWIUt(=a103vVh{+) zhUj3J0aPxEriBs6hl-0P=jZAr78K;9>J^qI7A5ADWagzZ7#LU>S(_Q8SX!D}T3Uyv zI%g!7Sfd#-${h`X(GVC7fzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4FTj30ChG&7!2e> zGBS%5ic*X7ON)|I71HvHvK2D(N>YK{&iuT@oSaI9oYb@ug`}Lsylh}!7^-VXQ>gxj Ldqsvp?*D%P1dA%p literal 0 HcmV?d00001 diff --git a/1/rundev/._rundev b/1/rundev/._rundev new file mode 100755 index 0000000000000000000000000000000000000000..b4309426e405a88c4c483f0ea075ee313ec79c3e GIT binary patch literal 4096 zcmZQz6=P>$Vqox1Ojhs@R)|o50+1L3ClDJkFz{^v(m+1nBL)UWIUt(=a103vVh{+) zh3H_I0aPxEriBs6hl-0P=jZAr78K;9>J^qI7A5ADWagzZ7#LU>S(_Q8SX!D}T3Uyv zI%g!7Sfd#-${h`X(GVC7fzc2c4S~@R7!85Z5Eu=C(GVC7fzc2c4FTj30ChG&7!2e> zGBS%5ic*X7ON)|I71HvHvK2D(N>YK{&iuT@oSaI9oYb@ug`}Lsylh}!7^-VXQ>gxj Ldqsvp?*D%PBh@O< literal 0 HcmV?d00001 diff --git a/1/rundev/0.11-dev.bxrc b/1/rundev/0.11-dev.bxrc new file mode 100755 index 0000000..29169e6 --- /dev/null +++ b/1/rundev/0.11-dev.bxrc @@ -0,0 +1,31 @@ +megs: 16 + +romimage: file=$BXSHARE/BIOS-bochs-latest + +# with the LGPL BIOS, X windows can be used +vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest + +boot: floppy + +floppya: type=1_44 +floppya: 1_44="0/linux/Image", status=inserted + +floppyb: type=1_44 +floppyb: 1_44=vvfat:"b/", status=inserted + +ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 +ata0-master: type=disk, path="images/rootimage-0.11", mode=flat, cylinders=512, heads=2, spt=20 + +log: bochsout.txt +panic: action=ask +error: action=report +info: action=report +debug: action=ignore + +pci: enabled=1, chipset=i440fx +vga: extension=vbe, update_freq=15 +keyboard: serial_delay=250, paste_delay=100000 +cpu: ips=15000000 +clock: sync=slowdown +mouse: enabled=0 + diff --git a/1/rundev/readme.txt b/1/rundev/readme.txt new file mode 100755 index 0000000..4ffca2f --- /dev/null +++ b/1/rundev/readme.txt @@ -0,0 +1,5 @@ +这些辅助文件的作用是用版本0内核启动虚拟机(不依赖符号链接cur),用于编译用户程序。 + +使用方法: +. 将文件rundev放入目录 linux-0.11-lab +. 将文件0.11-dev.bxrc放入目录 linux-0.11-lab/conf/ \ No newline at end of file diff --git a/1/rundev/rundev b/1/rundev/rundev new file mode 100755 index 0000000..668b5ba --- /dev/null +++ b/1/rundev/rundev @@ -0,0 +1,3 @@ +#!/bin/sh +bochs -q -f conf/0.11-dev.bxrc +